home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2013 / 2013.06.linuxmafia.com / linuxmafia.com / pub / linux / network / calendar.phps < prev    next >
Text File  |  2013-06-26  |  23KB  |  3 lines

  1. <code><span style="color: #000000">
  2. <html><head></head><body><code><span style="color: rgb(0, 0, 0);"><br /><span style="color: rgb(0, 0, 187);">&lt;?php<br><br></span><span style="color: rgb(255, 128, 0);">/*&nbsp;*****&nbsp;BEGIN&nbsp;LICENSE&nbsp;BLOCK&nbsp;*****<br /><br>&nbsp;*&nbsp;Version:&nbsp;MPL&nbsp;1.1/GPL&nbsp;2.0/LGPL&nbsp;2.1<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;The&nbsp;contents&nbsp;of&nbsp;this&nbsp;file&nbsp;are&nbsp;subject&nbsp;to&nbsp;the&nbsp;Mozilla&nbsp;Public&nbsp;License&nbsp;Version<br /><br>&nbsp;*&nbsp;1.1&nbsp;(the&nbsp;"License");&nbsp;you&nbsp;may&nbsp;not&nbsp;use&nbsp;this&nbsp;file&nbsp;except&nbsp;in&nbsp;compliance&nbsp;with<br /><br>&nbsp;*&nbsp;the&nbsp;License.&nbsp;You&nbsp;may&nbsp;obtain&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;License&nbsp;at<br /><br>&nbsp;*&nbsp;http://www.mozilla.org/MPL/<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;Software&nbsp;distributed&nbsp;under&nbsp;the&nbsp;License&nbsp;is&nbsp;distributed&nbsp;on&nbsp;an&nbsp;"AS&nbsp;IS"&nbsp;basis,<br /><br>&nbsp;*&nbsp;WITHOUT&nbsp;WARRANTY&nbsp;OF&nbsp;ANY&nbsp;KIND,&nbsp;either&nbsp;express&nbsp;or&nbsp;implied.&nbsp;See&nbsp;the&nbsp;License<br /><br>&nbsp;*&nbsp;for&nbsp;the&nbsp;specific&nbsp;language&nbsp;governing&nbsp;rights&nbsp;and&nbsp;limitations&nbsp;under&nbsp;the<br /><br>&nbsp;*&nbsp;License.<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;The&nbsp;Original&nbsp;Code&nbsp;is&nbsp;a&nbsp;PHP&nbsp;iCal&nbsp;over&nbsp;WebDAV&nbsp;server.<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;The&nbsp;Initial&nbsp;Developer&nbsp;of&nbsp;the&nbsp;Original&nbsp;Code&nbsp;is<br /><br>&nbsp;*&nbsp;Frederik&nbsp;Vanderstraeten.<br /><br>&nbsp;*&nbsp;Portions&nbsp;created&nbsp;by&nbsp;the&nbsp;Initial&nbsp;Developer&nbsp;are&nbsp;Copyright&nbsp;(C)&nbsp;2006<br /><br>&nbsp;*&nbsp;the&nbsp;Initial&nbsp;Developer.&nbsp;All&nbsp;Rights&nbsp;Reserved.<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;Contributor(s):<br>&nbsp;*&nbsp;&nbsp;None<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;Alternatively,&nbsp;the&nbsp;contents&nbsp;of&nbsp;this&nbsp;file&nbsp;may&nbsp;be&nbsp;used&nbsp;under&nbsp;the&nbsp;terms&nbsp;of<br /><br>&nbsp;*&nbsp;either&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;Version&nbsp;2&nbsp;or&nbsp;later&nbsp;(the&nbsp;"GPL"),&nbsp;or<br /><br>&nbsp;*&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public&nbsp;License&nbsp;Version&nbsp;2.1&nbsp;or&nbsp;later&nbsp;(the&nbsp;"LGPL"),<br /><br>&nbsp;*&nbsp;in&nbsp;which&nbsp;case&nbsp;the&nbsp;provisions&nbsp;of&nbsp;the&nbsp;GPL&nbsp;or&nbsp;the&nbsp;LGPL&nbsp;are&nbsp;applicable&nbsp;instead<br /><br>&nbsp;*&nbsp;of&nbsp;those&nbsp;above.&nbsp;If&nbsp;you&nbsp;wish&nbsp;to&nbsp;allow&nbsp;use&nbsp;of&nbsp;your&nbsp;version&nbsp;of&nbsp;this&nbsp;file&nbsp;only<br /><br>&nbsp;*&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;either&nbsp;the&nbsp;GPL&nbsp;or&nbsp;the&nbsp;LGPL,&nbsp;and&nbsp;not&nbsp;to&nbsp;allow&nbsp;others&nbsp;to<br /><br>&nbsp;*&nbsp;use&nbsp;your&nbsp;version&nbsp;of&nbsp;this&nbsp;file&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;MPL,&nbsp;indicate&nbsp;your<br /><br>&nbsp;*&nbsp;decision&nbsp;by&nbsp;deleting&nbsp;the&nbsp;provisions&nbsp;above&nbsp;and&nbsp;replace&nbsp;them&nbsp;with&nbsp;the&nbsp;notice<br /><br>&nbsp;*&nbsp;and&nbsp;other&nbsp;provisions&nbsp;required&nbsp;by&nbsp;the&nbsp;GPL&nbsp;or&nbsp;the&nbsp;LGPL.&nbsp;If&nbsp;you&nbsp;do&nbsp;not&nbsp;delete<br /><br>&nbsp;*&nbsp;the&nbsp;provisions&nbsp;above,&nbsp;a&nbsp;recipient&nbsp;may&nbsp;use&nbsp;your&nbsp;version&nbsp;of&nbsp;this&nbsp;file&nbsp;under<br /><br>&nbsp;*&nbsp;the&nbsp;terms&nbsp;of&nbsp;any&nbsp;one&nbsp;of&nbsp;the&nbsp;MPL,&nbsp;the&nbsp;GPL&nbsp;or&nbsp;the&nbsp;LGPL.<br /><br>&nbsp;*<br /><br>&nbsp;*&nbsp;*****&nbsp;END&nbsp;LICENSE&nbsp;BLOCK&nbsp;*****&nbsp;*/<br><br>//&nbsp;Run&nbsp;the&nbsp;following&nbsp;SQL&nbsp;to&nbsp;make&nbsp;your&nbsp;database:<br><br>/*<br><br>CREATE&nbsp;TABLE&nbsp;`calendar`&nbsp;(<br /><br>&nbsp;&nbsp;`content`&nbsp;text&nbsp;NOT&nbsp;NULL<br /><br>)&nbsp;TYPE=MyISAM;<br><br>INSERT&nbsp;INTO&nbsp;`calendar`&nbsp;VALUES&nbsp;('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Mozilla.org/NONSGML&nbsp;Mozilla&nbsp;Calendar&nbsp;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>//&nbsp;Variables:<br><br></span><span style="color: rgb(0, 0, 187);">$mysql_host&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">'localhost'</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;MySQL&nbsp;host<br></span><span style="color: rgb(0, 0, 187);">$mysql_username&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;MySQL&nbsp;username<br></span><span style="color: rgb(0, 0, 187);">$mysql_password&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;MySQL&nbsp;password<br></span><span style="color: rgb(0, 0, 187);">$mysql_database&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;MySQL&nbsp;database&nbsp;name<br><br></span><span style="color: rgb(0, 0, 187);">$upload_username&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Username&nbsp;to&nbsp;change&nbsp;the&nbsp;calendar<br></span><span style="color: rgb(0, 0, 187);">$upload_password&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;Password&nbsp;to&nbsp;change&nbsp;the&nbsp;calendar<br><br></span><span style="color: rgb(0, 0, 187);">$this_url&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(255, 128, 0);">//&nbsp;URL&nbsp;this&nbsp;script&nbsp;will&nbsp;be&nbsp;available&nbsp;from<br><br>//&nbsp;No&nbsp;need&nbsp;to&nbsp;edit&nbsp;after&nbsp;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);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">$mysql_username</span><span style="color: rgb(0, 119, 0);">,&nbsp;</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);">]&nbsp;==&nbsp;</span><span style="color: rgb(221, 0, 0);">'PUT'</span><span style="color: rgb(0, 119, 0);">){<br><br>&nbsp;&nbsp;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);">]&nbsp;!=&nbsp;</span><span style="color: rgb(0, 0, 187);">$upload_username&nbsp;</span><span style="color: rgb(0, 119, 0);">||&nbsp;</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);">]&nbsp;!=&nbsp;</span><span style="color: rgb(0, 0, 187);">$upload_password</span><span style="color: rgb(0, 119, 0);">){<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</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&nbsp;401&nbsp;Unauthorized'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;&nbsp;&nbsp;</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:&nbsp;Basic&nbsp;realm="Calendar&nbsp;update"'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;}&nbsp;else&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$putdata&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</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);">,&nbsp;</span><span style="color: rgb(221, 0, 0);">'r'</span><span style="color: rgb(0, 119, 0);">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</span><span style="color: rgb(0, 0, 187);">$data&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</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);">,&nbsp;</span><span style="color: rgb(0, 0, 187);">1024</span><span style="color: rgb(0, 119, 0);">)){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$information&nbsp;</span><span style="color: rgb(0, 119, 0);">.=&nbsp;</span><span style="color: rgb(0, 0, 187);">$data</span><span style="color: rgb(0, 119, 0);">;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</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&nbsp;`calendar`&nbsp;SET&nbsp;`content`&nbsp;=&nbsp;'"&nbsp;</span><span style="color: rgb(0, 119, 0);">.&nbsp;</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);">)&nbsp;.&nbsp;</span><span style="color: rgb(221, 0, 0);">"'"</span><span style="color: rgb(0, 119, 0);">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</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&nbsp;201&nbsp;Created'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</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:&nbsp;'&nbsp;</span><span style="color: rgb(0, 119, 0);">.&nbsp;</span><span style="color: rgb(0, 0, 187);">$this_url</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;&nbsp;&nbsp;</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:&nbsp;text/plain;&nbsp;charset=UTF-8'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: rgb(0, 0, 187);">$this_url</span><span style="color: rgb(0, 119, 0);">;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;}<br><br>}&nbsp;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);">]&nbsp;==&nbsp;</span><span style="color: rgb(221, 0, 0);">'GET'</span><span style="color: rgb(0, 119, 0);">){<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$information&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</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&nbsp;`content`&nbsp;FROM&nbsp;`calendar`"</span><span style="color: rgb(0, 119, 0);">));<br>&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 187);">$information&nbsp;</span><span style="color: rgb(0, 119, 0);">=&nbsp;</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>&nbsp;&nbsp;<br>&nbsp;&nbsp;</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&nbsp;200&nbsp;OK'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;</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:&nbsp;text/calendar;&nbsp;charset=UTF-8'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;echo&nbsp;</span><span style="color: rgb(0, 0, 187);">$information</span><span style="color: rgb(0, 119, 0);">;<br>&nbsp;&nbsp;<br>}&nbsp;else&nbsp;{<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;</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&nbsp;405&nbsp;Method&nbsp;Not&nbsp;Allowed'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;</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:&nbsp;PUT,&nbsp;GET'</span><span style="color: rgb(0, 119, 0);">);<br>&nbsp;&nbsp;<br>}<br><br></span><span style="color: rgb(0, 0, 187);">?&gt;<br></span><br /></span><br /></code></body></html></span>
  3. </code>