Jump to content

madspof

Members
  • Posts

    271
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

madspof's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Ok ive fixed that problem i had to put the php variables into javascript ones before i entered it into the function btw i now have a problem with hidding a table i am changing the style.display to block and none trying to hide the form at certain point but cannot get it to work properly for the form with a table in does anyone know why this might be ?
  2. Ok i have been playing and if i pass text through the varaibles into the stopUpload function it will not work it just stops for some reason but if they are numerical values it does is there some kind of syntax i am missing ?
  3. Hi all i have decided to have a play with ajax but as i have no javascript knoweldge i am having a few problems i have got the code below to work when it is sending the result variable from the upload.php back to the form but when i tried to send another variable containing a string, the php script will upload the file but the java script in the form will not show uploaded : Here is the link to the upload www.desfun.co.nr/dolphins/upload/ and the code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Max's AJAX File Uploader</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript"> <!-- function startUpload(){ document.getElementById('f1_upload_process').style.visibility = 'visible'; document.getElementById('f1_upload_form').style.visibility = 'hidden'; return true; } function stopUpload(success,url){ var result = ''; var url = ""; if (success == 1){ result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>'; } else { result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>'; } document.getElementById('f1_upload_process').style.visibility = 'hidden'; document.getElementById('f1_upload_form').innerHTML = result + url + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>'; document.getElementById('f1_upload_form').style.visibility = 'visible'; return true; } //--> </script> </head> <body> <div id="container"> <div id="header"><div id="header_left"></div> <div id="header_main">Max's AJAX File Uploader</div><div id="header_right"></div></div> <div id="content"> <form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload();" > <p id="f1_upload_process">Loading...<br/><img src="loader.gif" /><br/></p> <p id="f1_upload_form" align="center"><br/> <label>File: <input name="myfile" type="file" size="30" /><BR /> </label> <label><input name="sd" type="text" id="sd" value="lol" /></label><BR /> <label> <input type="submit" name="submitBtn" class="sbtn" value="Upload" /> </label> </p> <iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe> </form> </div> <div id="footer"><a href="http://www.ajaxf1.com" target="_blank">Powered by AJAX F1</a></div> </div> </body> And the php <?php include("../connect.php"); $id = "3"; $BFA = "213"; $BFAl = "F"; $BREED = $_POST['sd']; $HEIGHT = "232"; $NAME = "hah"; $URL = "ollol"; // Edit upload location here $destination_path = 'C:\Deskfun\Dolphins\asa\\'; mysql_query("INSERT INTO dogs VALUES ('$id','$BFA','$BFAl','$BREED','$HEIGHT','$NAME','$URL')"); $result = 0; //echo $to; $target_path = $destination_path . basename( $_FILES['myfile']['name']); if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) { $result = 1; } sleep(1); ?> <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo "$result,$URL"; ?>);</script> can anyone see why?? Thanks before hand :)
  4. lol the $date.txt works might not be effiecent but it works :s anyway i figured out what was wrong the file i was trying to edit was in a directory above that bloody file school boy error lol thanks
  5. It does it is running on windows machine with abbyss server with php 5 still absolutly wammied with this one :s
  6. oh year should of mentioned that been declared and i have put an echo before hand to make sure the variable are all set but the functions are just not writing to the txt file
  7. I have this bit of code $myFile = "$date.txt"; echo $myFile; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $page); fclose($fh); and it will not write to the txt file and i cannot figure out why can anyone else see why ? thanks b4 hand madspof x
  8. So can anyone see why i cannot retrive the cookie info whilst running this class ?
  9. ok the cookie data is definatly there and i can retrive it using the same bit of code on a php page that does not include the calendar system so it must be some thing to do with the calendar system as i cannot echo the cookia data when the it is on the same page as the calendar system code :s any ideas frazzled
  10. i have also added this $this->rank; in the public function __construct() section
  11. ok here is my new code for the class and php file but it does not work <?php /** EasyPhpEventCalendar Class version 1.0.0 Copyright (c) 2009 JF Nutbroek <jfnutbroek@gmail.com> For more information visit http://wwww.mywebmymail.com Permission to use, copy, modify, and/or distribute this software for any purpose without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ class easyphpeventcalendar { /** * URL to gfx directory with calendar backgrounds * * @var string */ public $Gfxurl; public $rank; /** * Days; array with 7 string values representing the days * [0]: Sunday * [1]: Monday * [2]: Tuesday * [3]: Wednesday * [4]: Thursday * [5]: Friday * [6]: Saturday * * @var array */ public $Days; /** * Months; array with 12 string values representing the months * [0]: January * [1]: February * [2]: March * [3]: April * [4]: May * [5]: June * [6]: July * [7]: August * [8]: September * [9]: October * [10]: November * [11]: December * * @var array */ public $Months; /** * Events; array with arrays representing the events * [0]: array ('YYYYMMDD','Event 1 as text with html markup') * [1]: array ('YYYYMMDD','Event 2 as text with html markup') * [2]: etc. * * @var array */ public $Events; /** * Class constructor * */ public function __construct() { $this->Gfxurl = 'gfx'; $this->Days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $this->Months = array('January','February','March','April','May','June','July','August','September','October','November','December'); $this->Events = array(); } /** * Creates Event Calendar * * @param string/array $filename * @param string $output */ public function CreateEventCalendar() { $this->Gfxurl=rtrim($this->Gfxurl,'/'); echo "<div id=\"eventcalendar\">\n"; echo "<style type=\"text/css\">\n"; echo ".eventtable {\n"; echo " text-align : center;\n"; echo " font-family : Verdana, Helvetica, Arial, sans-serif;\n"; echo " font-size : 13px;\n"; echo " color : #000000;\n"; echo " border-collapse : separate;\n"; echo " border-spacing : 2px;\n"; echo " width : 410px;\n"; echo "}\n"; echo ".eventweekmonth {\n"; echo " background-image : url('$this->Gfxurl/weekmonth.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 25px;\n"; echo " width : 40px;\n"; //echo " font-weight : bold;\n"; echo "}\n"; echo ".eventweekmonthactive {\n"; echo " background-image : url('$this->Gfxurl/weekmonth_event.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 25px;\n"; echo " width : 40px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo ".eventweekend {\n"; echo " background-image : url('$this->Gfxurl/weekend.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo "}\n"; echo ".eventweekendactive {\n"; echo " background-image : url('$this->Gfxurl/weekend_event.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo ".eventday {\n"; echo " background-image : url('$this->Gfxurl/day.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo "}\n"; echo ".eventdayactive {\n"; echo " background-image : url('$this->Gfxurl/day_event.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo ".eventdaydisabled {\n"; echo " background-image : url('$this->Gfxurl/day.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo " color : #969696;\n"; echo "}\n"; echo ".eventdetails {\n"; echo " background-image : url('$this->Gfxurl/eventdetails.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " text-align : left;\n"; echo " vertical-align : top;\n"; echo " height : 160px;\n"; echo " width : 304px;\n"; echo " padding : 5px;\n"; echo "}\n"; echo ".eventcalendartitle {\n"; echo " background-image : url('$this->Gfxurl/title.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 25px;\n"; echo " width : 304px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo "</style>\n"; // Get current date $date=time();$month=date('m',$date);$year=date('Y',$date); // Left column with months echo "<table class=\"eventtable\"><tr><td style=\"vertical-align : top;width : 44px;\">\n"; echo "<table style=\"vertical-align : top;border-collapse : separate;border-spacing : 2px;width : 44px;\">\n"; echo "<tr><td style=\"height : 25px;\"> </td></tr>\n"; if ($this->eventcheck(1)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('1')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[0],0,3) . "</td></tr>\n"; if ($this->eventcheck(2)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('2')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[1],0,3) . "</td></tr>\n"; if ($this->eventcheck(3)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('3')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[2],0,3) . "</td></tr>\n"; if ($this->eventcheck(4)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('4')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[3],0,3) . "</td></tr>\n"; if ($this->eventcheck(5)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('5')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[4],0,3) . "</td></tr>\n"; if ($this->eventcheck(6)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('6')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[5],0,3) . "</td></tr>\n"; echo "</table>\n"; echo "</td><td style=\"vertical-align : top;width : 308px;\">\n"; // Add Events $data = $this->rank; //$data = $_COOKIE['cookie_info']; $check = strpos($data,'-'); $gh = strlen($data); $fg = strpos($data,'@'); $jk = ($fg-1)-$check; $rank = substr($data,$fg+1,$gh); $a = "lol"; if($rank == "STAFF"){ $a = "dfdfdff"; }elseif($rank == "NCO"){ $a = "dfdfdff"; } foreach ($this->Events as $key => $event) { $eventmonth=intval(substr($event[0],4,2));$eventyear=intval(substr($event[0],0,4));$eventday=intval(substr($event[0],6,2)); if (checkdate($eventmonth,$eventday,$eventyear)) { $day_no=date('N',mktime(0,0,0,$eventmonth,$eventday,$eventyear));$month_no=date('n',mktime(0,0,0,$eventmonth,$eventday,$eventyear))-1; if ($day_no==7) {$day_no=0;} $date=$this->Days[$day_no] . ' ' . $eventday . ' ' . $this->Months[$month_no] . ' ' . $eventyear; echo "<div id=\"" . ($key + 13) ."\" style=\"display: none\">\n"; echo "<table style=\"width : 308px;vertical-align : top;border-collapse : separate;border-spacing : 2px;\"><tr><td class=\"eventcalendartitle\">$date</td></tr><tr><td class=\"eventdetails\" onClick=\"expandCollapse($eventmonth)\" onMouseOver=\"this.style.cursor='pointer';\">" . $data . $rank . $event[1] . "</td></tr></table>\n"; echo "</div>\n"; } } // Add Months for ($m=1;$m<13;$m++) { if ($m==$month) { echo "<div id=\"$m\">\n"; $this->eventcalendar(mktime(0,0,0,$m,1,$year)); echo "</div>\n"; } else { if ($m<$month) {$i=1;} else {$i=0;} echo "<div id=\"$m\" style=\"display: none\">\n"; $this->eventcalendar(mktime(0,0,0,$m,1,$year+$i)); echo "</div>\n"; } } // Right column with months echo "</td><td style=\"vertical-align : top;width : 44px;\">\n"; echo "<table style=\"width : 44px;vertical-align : top;border-collapse : separate;border-spacing : 2px;\">\n"; echo "<tr><td style=\"height : 25px;\"> </td></tr>\n"; if ($this->eventcheck(7)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('7')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[6],0,3) . "</td></tr>\n"; if ($this->eventcheck() {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('8')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[7],0,3) . "</td></tr>\n"; if ($this->eventcheck(9)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('9')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[8],0,3) . "</td></tr>\n"; if ($this->eventcheck(10)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('10')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[9],0,3) . "</td></tr>\n"; if ($this->eventcheck(11)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('11')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[10],0,3) . "</td></tr>\n"; if ($this->eventcheck(12)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('12')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[11],0,3) . "</td></tr>\n"; echo "</table>\n"; echo "</td></tr></table>\n"; // Javascript to show and hide content echo "<script language=\"JavaScript\">\n"; echo "<!-- EasyPhpEventCalendar Copyright (c) 2009 JF Nutbroek -->\n"; echo "<!-- More information on http://www.mywebmymail.com -->\n"; echo "function expandCollapse(divsection) {\n"; echo " for(i=1;i<" . (13+count($this->Events)) . ";i++) {Collapse(i);}\n"; echo " var element = document.getElementById(divsection);\n"; echo " element.style.display = \"block\";\n"; echo "}\n"; echo "function Collapse(divsection) {\n"; echo " var element = document.getElementById(divsection);\n"; echo " element.style.display = \"none\";\n"; echo "}\n"; echo "</script>\n"; echo "</div>\n"; } /** * Check if month has an event * */ private function eventcheck($month) { foreach ($this->Events as $key => $event) { if (intval(substr($event[0],4,2))==$month) return true; } return false; } /** * Print the month * */ private function eventcalendar($date) { $day=date('d',$date);$month=date('m',$date);$year=date('Y',$date);$first_day=mktime(0,0,0,$month,1,$year);$title=$this->Months[date('n',mktime(0,0,0,$month,$day,$year))-1]; $days_in_month=cal_days_in_month(0,$month,$year);$day_of_week=date('N',$first_day); if ($day_of_week==7) {$blank=0;} else {$blank=$day_of_week;} echo "<table style=\"vertical-align : top;border-collapse : separate;border-spacing : 2px;width : 308px;\">";echo "<tr><td colspan=\"7\" class=\"eventcalendartitle\">$title $year</td></tr>"; echo "<tr><td class=\"eventweekmonth\">". substr($this->Days[0],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[1],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[2],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[3],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[4],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[5],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[6],0,3) . "</td></tr>"; if (($month-1)==0) {$prevmonth=1;$prevyear=($year-1);} else {$prevmonth=($month-1);$prevyear=$year;} $day_prevmonth=cal_days_in_month(0,$prevmonth,$prevyear)-($blank-1);echo "<tr>"; $day_num=1;$day_count=1;$datenow=time();$monthnow=date('n',$datenow);$yearnow=date('Y',$datenow);$daynow=date('j',$datenow); while ($blank>0) {echo "<td class=\"eventdaydisabled\">$day_prevmonth</td>";$blank=$blank-1;$day_count++;$day_prevmonth++;} while ($day_num<=$days_in_month) { $class="class=\"eventday\"";$id=0; if ($day_count==1 || $day_count==7) {$class="class=\"eventweekend\"";} foreach ($this->Events as $key => $event) { $eventyear=intval(substr($event[0],0,4));$eventmonth=intval(substr($event[0],4,2));$eventday=intval(substr($event[0],6,2)); if ($eventyear==$year && $eventmonth==$month && $eventday==$day_num) { $class="class=\"eventdayactive\""; if ($day_count==1 || $day_count==7) {$class="class=\"eventweekendactive\"";} $id=($key +13);break; } } if ($yearnow==$year && $monthnow==$month && $daynow==$day_num) {$textstyle='style="color : #FF0000;font-weight : bold;"';} else {$textstyle='';} if ($id>0) { echo "<td $class $textstyle onClick=\"expandCollapse($id)\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\"> $day_num </td>"; } else { echo "<td $class $textstyle> $day_num </td>"; } $day_num++;$day_count++; if ($day_count>7) {echo "</tr><tr>";$day_count=1;} } $day_nextmonth=1; if ($day_count==1) { echo "<td colspan=\"7\"> </td>"; } else { while ($day_count>1 && $day_count<=7 ) {echo "<td class=\"eventdaydisabled\">$day_nextmonth</td>";$day_count++;$day_nextmonth++;} } echo "</tr></table>\n"; } } ?> <?php // Include the Class - Paths are relative to the file that included the class include_once('./easyphpeventcalendar.php'); // Initialize the Class $calendar = new easyphpeventcalendar; // Configure the Calendar // Provide the path to the class background images // Paths are relative to the file that included the class $calendar -> Gfxurl = '../gfx'; $calendar -> rank = isset($_COOKIE['cookie_info']) ? $_COOKIE['cookie_info'] : null; // Optional: Override the English language by providing the days and months in another language // $calendar -> Days = array('Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'); // $calendar -> Months = array('Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'); // Method 1: Add events manually // Format: $calendar -> Events[] = array('YYYYMMDD','Event as text with optional html markup') $calendar -> Events[] = array('20091225','<b>Christmasday</b><br /><br />Merry X-mas!!'); $calendar -> Events[] = array(date('Y'). '0801','<div style="text-align: center;padding: 50px 10px;"><b>1st of August!!</b></div>'); // Method 2: Add events from textfiles // Provide the path/location to your directory with events stored in textfiles with filenames 'YYYYMMDD.txt' $eventslocation='events'; if ($dir=@opendir($eventslocation)) { while ($file=@readdir($dir)) { if (@strtolower(substr($file,-3))=='txt') { if ($fp=@fopen("$eventslocation/".$file,'r+')) { $text=fread($fp,filesize("$eventslocation/".$file)); @fclose($fp); $calendar -> Events[] = array(substr($file,0,,$text); } } } } // Method 3: Add events from a database // Place your custom code here ... // Print the Event Calendar // You could position it anywhere on a page using a <div> $calendar -> CreateEventCalendar(); ?>
  12. here is the class <?php /** EasyPhpEventCalendar Class version 1.0.0 Copyright (c) 2009 JF Nutbroek <jfnutbroek@gmail.com> For more information visit http://wwww.mywebmymail.com Permission to use, copy, modify, and/or distribute this software for any purpose without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ class easyphpeventcalendar { /** * URL to gfx directory with calendar backgrounds * * @var string */ public $Gfxurl; /** * Days; array with 7 string values representing the days * [0]: Sunday * [1]: Monday * [2]: Tuesday * [3]: Wednesday * [4]: Thursday * [5]: Friday * [6]: Saturday * * @var array */ public $Days; /** * Months; array with 12 string values representing the months * [0]: January * [1]: February * [2]: March * [3]: April * [4]: May * [5]: June * [6]: July * [7]: August * [8]: September * [9]: October * [10]: November * [11]: December * * @var array */ public $Months; /** * Events; array with arrays representing the events * [0]: array ('YYYYMMDD','Event 1 as text with html markup') * [1]: array ('YYYYMMDD','Event 2 as text with html markup') * [2]: etc. * * @var array */ public $Events; /** * Class constructor * */ public function __construct() { $this->Gfxurl = 'gfx'; $this->Days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $this->Months = array('January','February','March','April','May','June','July','August','September','October','November','December'); $this->Events = array(); } /** * Creates Event Calendar * * @param string/array $filename * @param string $output */ public function CreateEventCalendar() { $this->Gfxurl=rtrim($this->Gfxurl,'/'); echo "<div id=\"eventcalendar\">\n"; echo "<style type=\"text/css\">\n"; echo ".eventtable {\n"; echo " text-align : center;\n"; echo " font-family : Verdana, Helvetica, Arial, sans-serif;\n"; echo " font-size : 11px;\n"; echo " color : #000000;\n"; echo " border-collapse : separate;\n"; echo " border-spacing : 2px;\n"; echo " width : 410px;\n"; echo "}\n"; echo ".eventweekmonth {\n"; echo " background-image : url('$this->Gfxurl/weekmonth.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 25px;\n"; echo " width : 40px;\n"; echo "}\n"; echo ".eventweekmonthactive {\n"; echo " background-image : url('$this->Gfxurl/weekmonth_event.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 25px;\n"; echo " width : 40px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo ".eventweekend {\n"; echo " background-image : url('$this->Gfxurl/weekend.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo "}\n"; echo ".eventweekendactive {\n"; echo " background-image : url('$this->Gfxurl/weekend_event.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo ".eventday {\n"; echo " background-image : url('$this->Gfxurl/day.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo "}\n"; echo ".eventdayactive {\n"; echo " background-image : url('$this->Gfxurl/day_event.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo ".eventdaydisabled {\n"; echo " background-image : url('$this->Gfxurl/day.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 19px;\n"; echo " width : 40px;\n"; echo " color : #969696;\n"; echo "}\n"; echo ".eventdetails {\n"; echo " background-image : url('$this->Gfxurl/eventdetails.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " text-align : left;\n"; echo " vertical-align : top;\n"; echo " height : 160px;\n"; echo " width : 304px;\n"; echo " padding : 5px;\n"; echo "}\n"; echo ".eventcalendartitle {\n"; echo " background-image : url('$this->Gfxurl/title.gif');\n"; echo " background-repeat : no-repeat;\n"; echo " height : 25px;\n"; echo " width : 304px;\n"; echo " font-weight : bold;\n"; echo "}\n"; echo "</style>\n"; // Get current date $date=time();$month=date('m',$date);$year=date('Y',$date); // Left column with months echo "<table class=\"eventtable\"><tr><td style=\"vertical-align : top;width : 44px;\">\n"; echo "<table style=\"vertical-align : top;border-collapse : separate;border-spacing : 2px;width : 44px;\">\n"; echo "<tr><td style=\"height : 25px;\"> </td></tr>\n"; if ($this->eventcheck(1)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('1')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[0],0,3) . "</td></tr>\n"; if ($this->eventcheck(2)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('2')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[1],0,3) . "</td></tr>\n"; if ($this->eventcheck(3)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('3')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[2],0,3) . "</td></tr>\n"; if ($this->eventcheck(4)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('4')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[3],0,3) . "</td></tr>\n"; if ($this->eventcheck(5)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('5')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[4],0,3) . "</td></tr>\n"; if ($this->eventcheck(6)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('6')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[5],0,3) . "</td></tr>\n"; echo "</table>\n"; echo "</td><td style=\"vertical-align : top;width : 308px;\">\n"; // Add Events foreach ($this->Events as $key => $event) { $eventmonth=intval(substr($event[0],4,2));$eventyear=intval(substr($event[0],0,4));$eventday=intval(substr($event[0],6,2)); if (checkdate($eventmonth,$eventday,$eventyear)) { $day_no=date('N',mktime(0,0,0,$eventmonth,$eventday,$eventyear));$month_no=date('n',mktime(0,0,0,$eventmonth,$eventday,$eventyear))-1; if ($day_no==7) {$day_no=0;} $date=$this->Days[$day_no] . ' ' . $eventday . ' ' . $this->Months[$month_no] . ' ' . $eventyear; echo "<div id=\"" . ($key + 13) ."\" style=\"display: none\">\n"; echo "<table style=\"width : 308px;vertical-align : top;border-collapse : separate;border-spacing : 2px;\"><tr><td class=\"eventcalendartitle\">$date</td></tr><tr><td class=\"eventdetails\" onClick=\"expandCollapse($eventmonth)\" onMouseOver=\"this.style.cursor='pointer';\">" . $event[1] . "</td></tr></table>\n"; echo "</div>\n"; } } // Add Months for ($m=1;$m<13;$m++) { if ($m==$month) { echo "<div id=\"$m\">\n"; $this->eventcalendar(mktime(0,0,0,$m,1,$year)); echo "</div>\n"; } else { if ($m<$month) {$i=1;} else {$i=0;} echo "<div id=\"$m\" style=\"display: none\">\n"; $this->eventcalendar(mktime(0,0,0,$m,1,$year+$i)); echo "</div>\n"; } } // Right column with months echo "</td><td style=\"vertical-align : top;width : 44px;\">\n"; echo "<table style=\"width : 44px;vertical-align : top;border-collapse : separate;border-spacing : 2px;\">\n"; echo "<tr><td style=\"height : 25px;\"> </td></tr>\n"; if ($this->eventcheck(7)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('7')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[6],0,3) . "</td></tr>\n"; if ($this->eventcheck() {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('8')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[7],0,3) . "</td></tr>\n"; if ($this->eventcheck(9)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('9')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[8],0,3) . "</td></tr>\n"; if ($this->eventcheck(10)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('10')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[9],0,3) . "</td></tr>\n"; if ($this->eventcheck(11)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('11')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[10],0,3) . "</td></tr>\n"; if ($this->eventcheck(12)) {$class='eventweekmonthactive';} else {$class='eventweekmonth';} echo "<tr><td class=\"$class\" onClick=\"expandCollapse('12')\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\">". substr($this->Months[11],0,3) . "</td></tr>\n"; echo "</table>\n"; echo "</td></tr></table>\n"; // Javascript to show and hide content echo "<script language=\"JavaScript\">\n"; echo "<!-- EasyPhpEventCalendar Copyright (c) 2009 JF Nutbroek -->\n"; echo "<!-- More information on http://www.mywebmymail.com -->\n"; echo "function expandCollapse(divsection) {\n"; echo " for(i=1;i<" . (13+count($this->Events)) . ";i++) {Collapse(i);}\n"; echo " var element = document.getElementById(divsection);\n"; echo " element.style.display = \"block\";\n"; echo "}\n"; echo "function Collapse(divsection) {\n"; echo " var element = document.getElementById(divsection);\n"; echo " element.style.display = \"none\";\n"; echo "}\n"; echo "</script>\n"; echo "</div>\n"; } /** * Check if month has an event * */ private function eventcheck($month) { foreach ($this->Events as $key => $event) { if (intval(substr($event[0],4,2))==$month) return true; } return false; } /** * Print the month * */ private function eventcalendar($date) { $day=date('d',$date);$month=date('m',$date);$year=date('Y',$date);$first_day=mktime(0,0,0,$month,1,$year);$title=$this->Months[date('n',mktime(0,0,0,$month,$day,$year))-1]; $days_in_month=cal_days_in_month(0,$month,$year);$day_of_week=date('N',$first_day); if ($day_of_week==7) {$blank=0;} else {$blank=$day_of_week;} echo "<table style=\"vertical-align : top;border-collapse : separate;border-spacing : 2px;width : 308px;\">";echo "<tr><td colspan=\"7\" class=\"eventcalendartitle\">$title $year</td></tr>"; echo "<tr><td class=\"eventweekmonth\">". substr($this->Days[0],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[1],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[2],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[3],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[4],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[5],0,3) . "</td><td class=\"eventweekmonth\">". substr($this->Days[6],0,3) . "</td></tr>"; if (($month-1)==0) {$prevmonth=1;$prevyear=($year-1);} else {$prevmonth=($month-1);$prevyear=$year;} $day_prevmonth=cal_days_in_month(0,$prevmonth,$prevyear)-($blank-1);echo "<tr>"; $day_num=1;$day_count=1;$datenow=time();$monthnow=date('n',$datenow);$yearnow=date('Y',$datenow);$daynow=date('j',$datenow); while ($blank>0) {echo "<td class=\"eventdaydisabled\">$day_prevmonth</td>";$blank=$blank-1;$day_count++;$day_prevmonth++;} while ($day_num<=$days_in_month) { $class="class=\"eventday\"";$id=0; if ($day_count==1 || $day_count==7) {$class="class=\"eventweekend\"";} foreach ($this->Events as $key => $event) { $eventyear=intval(substr($event[0],0,4));$eventmonth=intval(substr($event[0],4,2));$eventday=intval(substr($event[0],6,2)); if ($eventyear==$year && $eventmonth==$month && $eventday==$day_num) { $class="class=\"eventdayactive\""; if ($day_count==1 || $day_count==7) {$class="class=\"eventweekendactive\"";} $id=($key +13);break; } } if ($yearnow==$year && $monthnow==$month && $daynow==$day_num) {$textstyle='style="color : #FF0000;font-weight : bold;"';} else {$textstyle='';} if ($id>0) { echo "<td $class $textstyle onClick=\"expandCollapse($id)\" onMouseOver=\"this.style.cursor='pointer';this.style.textDecoration='underline';\" onMouseOut=\"this.style.textDecoration='none';\"> $day_num </td>"; } else { echo "<td $class $textstyle> $day_num </td>"; } $day_num++;$day_count++; if ($day_count>7) {echo "</tr><tr>";$day_count=1;} } $day_nextmonth=1; if ($day_count==1) { echo "<td colspan=\"7\"> </td>"; } else { while ($day_count>1 && $day_count<=7 ) {echo "<td class=\"eventdaydisabled\">$day_nextmonth</td>";$day_count++;$day_nextmonth++;} } echo "</tr></table>\n"; } } ?> and here is the php file that calls the function <?php // Include the Class - Paths are relative to the file that included the class include_once('./easyphpeventcalendar.php'); // Initialize the Class $calendar = new easyphpeventcalendar; // Configure the Calendar // Provide the path to the class background images // Paths are relative to the file that included the class $calendar -> Gfxurl = '../gfx'; $calendar -> rank = isset($_COOKIE['cookie_info']) ? $_COOKIE['cookie_info'] : null; // Optional: Override the English language by providing the days and months in another language // $calendar -> Days = array('Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'); // $calendar -> Months = array('Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'); // Method 1: Add events manually // Format: $calendar -> Events[] = array('YYYYMMDD','Event as text with optional html markup') $calendar -> Events[] = array('20091225','<b>Christmasday</b><br /><br />Merry X-mas!!'); $calendar -> Events[] = array(date('Y'). '0801','<div style="text-align: center;padding: 50px 10px;"><b>1st of August!!</b></div>'); // Method 2: Add events from textfiles // Provide the path/location to your directory with events stored in textfiles with filenames 'YYYYMMDD.txt' $eventslocation='events'; if ($dir=@opendir($eventslocation)) { while ($file=@readdir($dir)) { if (@strtolower(substr($file,-3))=='txt') { if ($fp=@fopen("$eventslocation/".$file,'r+')) { $text=fread($fp,filesize("$eventslocation/".$file)); @fclose($fp); $calendar -> Events[] = array(substr($file,0,,$text); } } } } // Method 3: Add events from a database // Place your custom code here ... // Print the Event Calendar // You could position it anywhere on a page using a <div> $calendar -> CreateEventCalendar(); ?> how do i pass a variable from the php file to the class file ?
  13. how you pass a variable from the php file calling the php class to the actualy php class being used ?
  14. erm im not sure which bit of code to show so could you just tell me how you pass a variable from the php file calling the php class to the actualy php class being used ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.