Jump to content
xisto Community
irishpeck

Need Some Help With The Events Page! Need some help with the events page

Recommended Posts

Ok so if you visit http://forums.xisto.com/no_longer_exists/ you will be taken to index.php which calls the file main.php and displays the categories etc in the middle. Well we now have an events page which is the index.php file (renamed to events.php) which calls another file called events1.php to the middle instead of main. Now this events1.php contains the upcoming_events.inc.php file and the calendar of events also which we have but as you can see on the website its not working for me! Please help!

Heres the files that you will need.

**events1.php**

<img src="images/whats-on.png" width="150" height="45" alt="Whats On" /><?phprequire_once("config.inc.php");?><table border="0" cellspacing="0" cellpadding="3" width="98%" class="dir"><tr><table width="525" height="60" border="0">  <tr>	<td><?php include("caltest.php"); ?></td>     </tr></table><table width="525" height="60" border="0">  <tr>	<td><?php include("upcoming_events.inc.php"); ?></td>     </tr></table>

**calendar.cls.php**
<?phpclass calendar{ function display($urlformat, $weekday_start=0, $weekdays="", $months="", $year=0, $month=0, $specialdates="", $cellwidth=20) {  // Get year and month  if($year && $month)  {   $day = date("d");   $t = mktime(0, 0, 0, $month, $day, $year);   if($year == date("Y") && $month == date("m")) $highlighttoday = TRUE;  }  else  {   $year = date("Y");   $month = date("m");   $day = date("d");   $t = time();   $highlighttoday = TRUE;  }  // Save year and month  //setcookie("_xzcal_m", $month);  //setcookie("_xzcal_y", $year);  // Get weekday and month names  if(!$weekdays)  {   $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");  }  if(!$months)  {   $months = array("January","February","March","April","May","June","July","August","September","October","November","December");  }  $weekdays_small = array();  foreach($weekdays as $k=>$wd)  {   $weekdays_small[$k] = substr($wd, 0, 1);   if(ord($weekdays_small[$k]) >= 128) $weekdays_small[$k] .= substr($wd, 1, 1);  }    // Calendar title  $caltitle = $months[$month-1] . " " . $year;  // Prev and next month links  if ($month == 1)  {   $prev_month = 12;   $prev_month_year = $year-1;  }  else  {   $prev_month = $month-1;   $prev_month_year = $year;  }  if ($month == 12)  {   $next_month = 1;   $next_month_year = $year+1;  }  else  {   $next_month = $month+1;   $next_month_year = $year;  }  $month_link = "?";  $qsA = $_GET; unset($qsA['_xzcal_m'], $qsA['_xzcal_y']);  foreach($qsA as $k=>$v) $month_link .= "$k=$v&";  $prev_month_link = $month_link . "_xzcal_m=$prev_month&_xzcal_y=$prev_month_year";  $next_month_link = $month_link . "_xzcal_m=$next_month&_xzcal_y=$next_month_year";  $cal = <<< EOB  <table cellspacing="1" border="0" cellpadding="0" class="calendar">  <tr>  <td class="cal_header_month"><a href="$prev_month_link">«</a></td>  <td colspan="5" class="cal_header_month">$caltitle</td>  <td class="cal_header_month"><a href="$next_month_link">»</a></td>  </tr>  <tr>EOB;  // Weekdays  $j = $weekday_start;  for ($i=0; $i<7; $i++)  {   $wds = $weekdays_small[$j];   $cal .= <<< EOB   <td class="cal_header_week" width="$cellwidth">$wds</td>EOB;   $j++;   if ($j==7) $j=0;  }  $cal .= <<< EOB  </tr>EOB;  // Days  $firstday_weekday = date("w", mktime(0, 0, 0, $month, 1, $year));    $empty_cells = ($firstday_weekday >= $weekday_start) ? 	  ($firstday_weekday - $weekday_start) : 	  7 - $weekday_start;  if ($empty_calls) $cal .= "<tr>";  for ($i=0; $i<$empty_cells; $i++)   $cal .= "<td> </td>";  $lastday = date("t", $t);  //$datepre = date("Y-m-", $t);  $today = date("j", $t);  for ($d=1; $d<=$lastday; $d++, $i++)  {   $url = $urlformat;   $url = str_replace("[email="{@T"]{@T[/email]}", mktime(0, 0, 0, $month, $d, $year), $url);   $url = str_replace("[email="{@D"]{@D[/email]}", str_pad($d, 2, "0", STR_PAD_LEFT), $url);   $url = str_replace("[email="{@M"]{@M[/email]}", $month, $url);   $url = str_replace("[email="{@Y"]{@Y[/email]}", $year, $url);   $url = str_replace("[email="{@W"]{@W[/email]}", $i, $url);   if ($i%7==0) $cal .= "<tr>";   $cal .= "<td";   if ($d == $today && $highlighttoday) $cal .= " id=\"today\"";   if ($specialdates[$d]) $cal .= " class=\"content_date\"";   $cal .= "><a href=\"$url\">$d</a></td>";   if ($i%7==6) $cal .= "</tr>";  }  if ($i%7 != 0)  {   for(; $i%7!=0; $i++) $cal .= "<td> </td>";  }  $cal .= "</tr></table>";  echo $cal; }}?>

**caltest.php**
<?phpinclude("calendar.cls.php");$url = "[email="page?day={@D"]page?day={@D[/email]}";calendar::display($url, 0);?>

Share this post


Link to post
Share on other sites

Hi!

 

This error you got: Fatal error: Cannot redeclare class calendar in /home/sites/flog-it.ie/public_html/calendar.cls.php on line 4

Comes because you are including the file calendar.cls.php more then one time. When the Calendar class already exists, you can not include another (or the same) class with this name. I can't find you your code the second place you including this file, so maybe you are inclduing it another place?

 

What I would advise you to do is look for other places this file is included. But as a quick way to fix this change line 2 in caltest.php

 

from: include("calendar.cls.php");

to: include_once "calendar.cls.php";

 

What this does is, is including the file if, and only if it has'nt been included earlier.

 

As a reminder: when you develop systems as this. Make sure you have control over the files that get included, so errors like this doesnt happend.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.