home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2013
/
2013.06.linuxmafia.com
/
linuxmafia.com
/
pub
/
linux
/
network
/
calendar.phps
< prev
next >
Wrap
Text File
|
2013-06-26
|
23KB
|
3 lines
<code><span style="color: #000000">
<html><head></head><body><code><span style="color: rgb(0, 0, 0);"><br /><span style="color: rgb(0, 0, 187);"><?php<br><br></span><span style="color: rgb(255, 128, 0);">/* ***** BEGIN LICENSE BLOCK *****<br /><br> * Version: MPL 1.1/GPL 2.0/LGPL 2.1<br /><br> *<br /><br> * The contents of this file are subject to the Mozilla Public License Version<br /><br> * 1.1 (the "License"); you may not use this file except in compliance with<br /><br> * the License. You may obtain a copy of the License at<br /><br> * http://www.mozilla.org/MPL/<br /><br> *<br /><br> * Software distributed under the License is distributed on an "AS IS" basis,<br /><br> * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License<br /><br> * for the specific language governing rights and limitations under the<br /><br> * License.<br /><br> *<br /><br> * The Original Code is a PHP iCal over WebDAV server.<br /><br> *<br /><br> * The Initial Developer of the Original Code is<br /><br> * Frederik Vanderstraeten.<br /><br> * Portions created by the Initial Developer are Copyright (C) 2006<br /><br> * the Initial Developer. All Rights Reserved.<br /><br> *<br /><br> * Contributor(s):<br> * None<br /><br> *<br /><br> * Alternatively, the contents of this file may be used under the terms of<br /><br> * either the GNU General Public License Version 2 or later (the "GPL"), or<br /><br> * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),<br /><br> * in which case the provisions of the GPL or the LGPL are applicable instead<br /><br> * of those above. If you wish to allow use of your version of this file only<br /><br> * under the terms of either the GPL or the LGPL, and not to allow others to<br /><br> * use your version of this file under the terms of the MPL, indicate your<br /><br> * decision by deleting the provisions above and replace them with the notice<br /><br> * and other provisions required by the GPL or the LGPL. If you do not delete<br /><br> * the provisions above, a recipient may use your version of this file under<br /><br> * the terms of any one of the MPL, the GPL or the LGPL.<br /><br> *<br /><br> * ***** END LICENSE BLOCK ***** */<br><br>// Run the following SQL to make your database:<br><br>/*<br><br>CREATE TABLE `calendar` (<br /><br> `content` text NOT NULL<br /><br>) TYPE=MyISAM;<br><br>INSERT INTO `calendar` VALUES ('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:/mozilla.org/20050126_1/Europe/Brussels\r\nX-LIC-LOCATION:Europe/Brussels\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n');<br><br>*/<br><br>// Variables:<br><br></span><span style="color: rgb(0, 0, 187);">$mysql_host </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">'localhost'</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// MySQL host<br></span><span style="color: rgb(0, 0, 187);">$mysql_username </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// MySQL username<br></span><span style="color: rgb(0, 0, 187);">$mysql_password </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// MySQL password<br></span><span style="color: rgb(0, 0, 187);">$mysql_database </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// MySQL database name<br><br></span><span style="color: rgb(0, 0, 187);">$upload_username </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// Username to change the calendar<br></span><span style="color: rgb(0, 0, 187);">$upload_password </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// Password to change the calendar<br><br></span><span style="color: rgb(0, 0, 187);">$this_url </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(255, 128, 0);">// URL this script will be available from<br><br>// No need to edit after this<br><br></span><span style="color: rgb(0, 0, 187);">mysql_connect</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$mysql_host</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(0, 0, 187);">$mysql_username</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(0, 0, 187);">$mysql_password</span><span style="color: rgb(0, 119, 0);">);<br></span><span style="color: rgb(0, 0, 187);">mysql_select_db</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$mysql_database</span><span style="color: rgb(0, 119, 0);">);<br><br>if(</span><span style="color: rgb(0, 0, 187);">$_SERVER</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'REQUEST_METHOD'</span><span style="color: rgb(0, 119, 0);">] == </span><span style="color: rgb(221, 0, 0);">'PUT'</span><span style="color: rgb(0, 119, 0);">){<br><br> if(</span><span style="color: rgb(0, 0, 187);">$_SERVER</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'PHP_AUTH_USER'</span><span style="color: rgb(0, 119, 0);">] != </span><span style="color: rgb(0, 0, 187);">$upload_username </span><span style="color: rgb(0, 119, 0);">|| </span><span style="color: rgb(0, 0, 187);">$_SERVER</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'PHP_AUTH_PW'</span><span style="color: rgb(0, 119, 0);">] != </span><span style="color: rgb(0, 0, 187);">$upload_password</span><span style="color: rgb(0, 119, 0);">){<br> <br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'HTTP/1.0 401 Unauthorized'</span><span style="color: rgb(0, 119, 0);">);<br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'WWW-Authenticate: Basic realm="Calendar update"'</span><span style="color: rgb(0, 119, 0);">);<br> <br> } else {<br><br> </span><span style="color: rgb(0, 0, 187);">$putdata </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">fopen</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'php://input'</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(221, 0, 0);">'r'</span><span style="color: rgb(0, 119, 0);">);<br><br> while (</span><span style="color: rgb(0, 0, 187);">$data </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">fread</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$putdata</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(0, 0, 187);">1024</span><span style="color: rgb(0, 119, 0);">)){<br> </span><span style="color: rgb(0, 0, 187);">$information </span><span style="color: rgb(0, 119, 0);">.= </span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">;<br> }<br><br> </span><span style="color: rgb(0, 0, 187);">mysql_query</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">"UPDATE `calendar` SET `content` = '" </span><span style="color: rgb(0, 119, 0);">. </span><span style="color: rgb(0, 0, 187);">mysql_real_escape_string</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$information</span><span style="color: rgb(0, 119, 0);">) . </span><span style="color: rgb(221, 0, 0);">"'"</span><span style="color: rgb(0, 119, 0);">);<br><br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'HTTP/1.1 201 Created'</span><span style="color: rgb(0, 119, 0);">);<br> <br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'Location: ' </span><span style="color: rgb(0, 119, 0);">. </span><span style="color: rgb(0, 0, 187);">$this_url</span><span style="color: rgb(0, 119, 0);">);<br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'Content-Type: text/plain; charset=UTF-8'</span><span style="color: rgb(0, 119, 0);">);<br> echo </span><span style="color: rgb(0, 0, 187);">$this_url</span><span style="color: rgb(0, 119, 0);">;<br> <br> }<br><br>} elseif(</span><span style="color: rgb(0, 0, 187);">$_SERVER</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'REQUEST_METHOD'</span><span style="color: rgb(0, 119, 0);">] == </span><span style="color: rgb(221, 0, 0);">'GET'</span><span style="color: rgb(0, 119, 0);">){<br> <br> </span><span style="color: rgb(0, 0, 187);">$information </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">mysql_fetch_assoc</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">mysql_query</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">"SELECT `content` FROM `calendar`"</span><span style="color: rgb(0, 119, 0);">));<br> </span><span style="color: rgb(0, 0, 187);">$information </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">$information</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'content'</span><span style="color: rgb(0, 119, 0);">];<br> <br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'HTTP/1.1 200 OK'</span><span style="color: rgb(0, 119, 0);">);<br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'Content-Type: text/calendar; charset=UTF-8'</span><span style="color: rgb(0, 119, 0);">);<br> <br> echo </span><span style="color: rgb(0, 0, 187);">$information</span><span style="color: rgb(0, 119, 0);">;<br> <br>} else {<br> <br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'HTTP/1.1 405 Method Not Allowed'</span><span style="color: rgb(0, 119, 0);">);<br> </span><span style="color: rgb(0, 0, 187);">header</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'Allow: PUT, GET'</span><span style="color: rgb(0, 119, 0);">);<br> <br>}<br><br></span><span style="color: rgb(0, 0, 187);">?><br></span><br /></span><br /></code></body></html></span>
</code>