Gå til innhold

Kalender script hjelp


Anbefalte innlegg

Hei!

 

Jeg har sett litt rundt på forskjellige sider etter noen gode kalender scripts.

 

Har sett på hotscripts og pixel2life....men finner ikke helt det jeg trenger.

 

Det jeg trenger er en kalender som:

-Viser dato

-bla frem og tilbake måneder

-vise hva som skjer en spesiell dato

-legge til ting som kommer til å skje

 

Kan noen hjelpe meg finne noen gode tutorials?

 

MvH Knut Erik

Lenke til kommentar
Videoannonse
Annonse
etter litt søking så havnet jeg på php koder som kanskje andre har bruk for og fant denne

http://home.no.net/endrebjo/prove/date/calendar.php

 

med litt redigering så skal vel alle problermer være løst

7871779[/snapback]

Nice;)

 

Fant både kalender (som jeg har lett etter), óg slik visning av ALL kildekode man har på en side :)

7887666[/snapback]

 

 

søking eier:p selv om jeg ikke er så god på det selv

Lenke til kommentar

Selve kalenderen er bygget fra en annet script, så det er en del unødvendig kode med i scriptet, men jeg har ikke orket å rydde :p

 

calendar.php:

<?php 
if (!defined('IN_SCRIPT')) define("IN_SCRIPT", true);
require_once("core.inc.php");

if (isset($_GET['yr'])) $yr = intval(calendar_realsafehtml($_GET['yr']));
else $yr = "";
if (isset($_GET['mn'])) $mn = intval(calendar_realsafehtml($_GET['mn']));
else $mn = "";
if (isset($_GET['day'])) $day = intval(calendar_realsafehtml($_GET['day']));
else $day = "";

if ((empty($yr)) || ($yr < 2006) || ($yr>2035)) $yr = date("Y");
if ((empty($mn)) || ($mn<1) || ($mn>12)) $mn = date("n");
if ((empty($day)) || ($day<1) || ($day > 31)) $day = date("d");

if (!checkdate($mn, $day, $yr)) {
$yr = date("Y");
$mn = date("m");
$day = date("d");
}

//************************************************************
//External variables:  (ex. calendar.php?mn=12&dy=3&yr=2003)
//************************************************************
// tcs = Set Table Cell Spacing
// tcp = Set Table Cell Padding
// tbd = Set Table Border
// mn = Set month (1-12)
// dy = Set day (1-31)
// yr = Set year (4 digit year)
// nm = Set to Next Month (equal to 1)
// lm = Set to Last Month (equal to 1)
// mt = Set Calendar to Mark Today (equal to 1)
// dbh = Set Day Box Height (pixel height of day boxes)
// dbw = Set Day Box Width (pixel width of day boxes)
// wbh = Set Weekday Box Height (pixel height of weekday boxes)
// ctfs = Set Calendar Title Font Size (ex. 10, 12, 14)
// ctfw = Set Calendar Title Font Weight (ex. bold)
// ctfc = Set Calendar Title Font Color (ex. 000000)
// ctbc = Set Calendar Title Background Color (ex. 000000)
// ctal = Set Calendar Title Alignment (ex. left, right, center)
// ndfs = Set Normal Day Font Size (ex. 10, 12, 14)
// ndfc = Set Normal Day Font Color (ex. 000000)
// ndbc = Set Normal Day Background Color (ex. 000000)
// ndal = Set Normal Day Alignment (ex. left, right, center)
// ndva = Set Normal Day Vertical Alignment (ex. top, middle, bottom)
// mdfc = Set Mark Day Font Color (ex. FF0000)
// mdbc = Set Mark Day Background Color (ex. 000000)
// bdbc = Set Blank Day Background Color (ex. 000000)
// wtfs = Set Weekday Title Font Size (ex. 10, 12, 14)
// wtfc = Set Weekday Title Font Color (ex. 000000)
// wtbc = Set Weekday Title Background Color (ex. 000000)
// wtal = Set Weekday Title Alignment (ex. left, right, center)
// wtva = Set Weekday Title Vertical Alignment (ex. top, middle, bottom)
// wk = Set weekday titles to Full names (equal to 1)  

// *******************************
// ctfn = Calendar Title Font Name
// ndfn = Normal Day Font Name
// mdfn = Mark Day Font Name
// wtfn = Weekday Title Font Name
// *******************************

// Set the above variables to one of the following:
// 1 = Verdana, Arial, Helvetica, sans-serif
// 2 = Arial, Helvetica, sans-serif
// 3 = Times New Roman, Times, serif
// 4 = Courier New, Courier, mono
// 5 = Georgia, Times New Roman, Times, serif
// 6 = Geneva, Arial, Helvetica, sans-serif

//Set the months of the year into an array. 
$month[1] = "Januar"; 
$month[2] = "Februar"; 
$month[3] = "Mars"; 
$month[4] = "April"; 
$month[5] = "Mai"; 
$month[6] = "Juni"; 
$month[7] = "Juli"; 
$month[8] = "August"; 
$month[9] = "September"; 
$month[10] = "Oktober"; 
$month[11] = "November"; 
$month[12] = "Desember"; 

//Set week title names for the days of the week. 
if (isset($wk)) { 
   //Use full names for week days 
   $week[0] = "Mandag";  // Monday 
   $week[1] = "Tirsdag";  // Tuesday 
   $week[2] = "Onsdag";  // Wednesday 
   $week[3] = "Torsdag";  // Thursday 
   $week[4] = "Fredag";  // Friday 
   $week[5] = "Lørdag";  // Saturday 
   $week[6] = "Søndag";  // Sunday 
} 

else { 
//Use short names for week days 
$week[0] = "M";  // Monday 
$week[1] = "T";  // Tuesday 
$week[2] = "O";  // Wednesday 
$week[3] = "T";  // Thursday 
$week[4] = "F";  // Friday 
$week[5] = "L";  // Saturday 
$week[6] = "S";  // Sunday 
} 

//Get current day, returned in numeric format 1-31 
if (!isset($dy)) { 
$current_day = date("j"); 
} 
else { 
$current_day = $dy; 
} 

//Get current month, returned in numeric format 1-12 
if (empty($mn)) { 
$current_month = date("n"); 
} 
else { 
$current_month = $mn; 
}

//Get current year, returned in numeric format, 4-digits 
if (empty($yr)) { 
$current_year = date("Y"); 
} 
else { 
$current_year = $yr; 
}  


// Set the dates to use in links to next month
if ($current_month == 12) {
$next_month = 1;
$next_month_yr = $current_year + 1;
}
else {
$next_month = $current_month + 1; 
 	$next_month_yr = $current_year;
}

// Set the dates to use in links to last month
if ($current_month == 1) {
$last_month = 12;
$last_month_yr = $current_year - 1;
}
else {
$last_month = $current_month - 1; 
 	$last_month_yr = $current_year;
}


//Get Days in this month, returned in numeric format 28-31 
$days_in_month = date("t", mktime(0,0,0, $current_month, $current_day, $current_year)); 

//Get the day of the week that the first day of the month falls on, returned numeric format 0-6 
// (same numbering for days of week as the $week array above) 
$first_day = date("w", mktime(0,0,0,$current_month,1,$current_year)); 
// To prevent bug if first day is sunday
if ($first_day == 0) $first_day = 7; 

//Table Properties 
if (!isset($tcs)) { $tcs = 1; }       //Cell Spacing 
if (!isset($tcp)) { $tcp = 0; }      //Cell Padding 
if (!isset($tbd)) { $tbd = 0; }      //Border 

//Set Day Box Height 
//If no value is passed, then default to mini calendar settings. 
if (!isset($dbh)) { $dbh = "16"; } 

//Set Day Box Width 
//If no value is passed, then default to mini calendar settings. 
if (!isset($dbw)) { $dbw = "23"; } 

//Set Weekday Box Height 
//If no value is passed, then default to mini calendar settings. 
if (!isset($wbh)) { $wbh = "0"; } 

//Set to mark Today 
if (!isset($mt)) { $mt = 1; } 

//Calendar Title Options 
//******************** 
if (!isset($ctfs)) { $ctfs = 10; }         //Set Font Size 
if (!isset($ctfw)) { $ctfw = "bold"; }      //Set Font Weight 
if (!isset($ctfc)) { $ctfc = "#000000"; }   //Set Font Color 
if (!isset($ctbc)) { $ctbc = ""; }         //Set Cell Background Color 
if (!isset($ctal)) { $ctal = "center"; }      //Set Alignment 
if ((!isset($ctfn)) || ($ctfn==1)) { $ctfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($ctfn==2) { $ctfn = "Arial, Helvetica, sans-serif"; }       
if ($ctfn==3) { $ctfn = "Times New Roman, Times, serif"; } 
if ($ctfn==4) { $ctfn = "Courier New, Courier, mono"; } 
if ($ctfn==5) { $ctfn = "Georgia, Times New Roman, Times, serif"; } 
if ($ctfn==6) { $ctfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
//Normal Day Options 
//******************** 
if (!isset($ndfs)) { $ndfs = 10; }         //Font Size 
if (!isset($ndfc)) { $ndfc = "#000000"; }   //Font Color 
if (!isset($ntfw)) { $ntfw = ""; }      //Set Font Weight 
if (!isset($ndbc)) { $ndbc = "#F7F7F7"; }   //Background Color ecf8ff 
if (!isset($ndal)) { $ndal = "center"; }      //Text Alignment 
if (!isset($ndva)) { $ndva = "middle"; }      //Vertical Alignment 
if ((!isset($ndfn)) || ($ndfn==1)) { $ndfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($ndfn==2) { $ndfn = "Arial, Helvetica, sans-serif"; }       
if ($ndfn==3) { $ndfn = "Times New Roman, Times, serif"; } 
if ($ndfn==4) { $ndfn = "Courier New, Courier, mono"; } 
if ($ndfn==5) { $ndfn = "Georgia, Times New Roman, Times, serif"; } 
if ($ndfn==6) { $ndfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
//Mark Day Options 
//******************** 
if (!isset($mdfc)) { $mdfc = "#FF0000"; }   //Font Color 
if (!isset($mdbc)) { $mdbc = "#EAF5FF"; }   //Background Color ecf8ff 
if ((!isset($mdfn)) || ($mdfn==1)) { $mdfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($mdfn==2) { $mdfn = "Arial, Helvetica, sans-serif"; }       
if ($mdfn==3) { $mdfn = "Times New Roman, Times, serif"; } 
if ($mdfn==4) { $mdfn = "Courier New, Courier, mono"; } 
if ($mdfn==5) { $mdfn = "Georgia, Times New Roman, Times, serif"; } 
if ($mdfn==6) { $mdfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
//Blank Day Options 
//******************** 
if (!isset($bdbc)) { $bdbc = "#EEEEEE"; }   //Background Color eaf5ff 

//Weekday Title Options 
//******************** 
if (!isset($wtfs)) { $wtfs = 10; }         //Font Size 
if (!isset($wtfc)) { $wtfc = "#000000"; }   //Font Color 
if (!isset($wtfw)) { $wtfw = "bold"; }      //Set Font Weight 
if (!isset($wtbc)) { $wtbc = "#C9C9C9"; }   //Background Color ffffe8 
if (!isset($wtal)) { $wtal = "center"; }    //Text Alignment 
if (!isset($wtva)) { $wtva = "middle"; }      //Vertical Alignment 
if ((!isset($wtfn)) || ($wtfn==1)) { $wtfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($wtfn==2) { $wtfn = "Arial, Helvetica, sans-serif"; }       
if ($wtfn==3) { $wtfn = "Times New Roman, Times, serif"; } 
if ($wtfn==4) { $wtfn = "Courier New, Courier, mono"; } 
if ($wtfn==5) { $wtfn = "Georgia, Times New Roman, Times, serif"; } 
if ($wtfn==6) { $wtfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
?> 

<style type="text/css"> 
<!-- 
.CalendarTitle { 
 font-family: <?php print $ctfn; ?>; 
 font-size: <?php print $ctfs; ?>px; 
 font-weight: <?php print $ctfw; ?>; 
 color: <?php print $ctfc; ?>; 
 background-color: <?php print $ctbc; ?>; 
 text-align: <?php print $ctal; ?>; 
} 

.NormalDay { 
 font-family: <?php print $ndfn; ?>; 
 font-size: <?php print $ndfs; ?>px; 
 font-weight: <?php print $ntfw; ?>; 
 color: <?php print $ndfc; ?>; 
 background-color: <?php print $ndbc; ?>; 
 text-align: <?php print $ndal; ?>; 
 vertical-align: <?php print $ndva; ?>; 
} 

.MarkDay { 
 font-family: <?php print $mdfn; ?>; 
 font-size: <?php print $ndfs; ?>px; 
 color: <?php print $ndfc; ?>; 
 background-color: #F0E2E2; 
 text-align: <?php print $ndal; ?>; 
 vertical-align: <?php print $ndva; ?>; 
} 

.EventDay { 
 font-family: <?php print $mdfn; ?>; 
 font-size: <?php print $ndfs; ?>px;
 font-weight: bold; 
 color: <?php print $ndfc; ?>; 
 background-color: <?php print $mdbc; ?>; 
 text-align: <?php print $ndal; ?>; 
 vertical-align: <?php print $ndva; ?>; 
} 

.BlankDay { 
 background-color: <?php print $bdbc; ?>; 
} 

.WeekdayTitle { 
 font-family: <?php print $wtfn; ?>; 
 font-size: <?php print $wtfs; ?>px; 
 font-weight: <?php print $wtfw; ?>; 
 color: <?php print $wtfc; ?>; 
 background-color: <?php print $wtbc; ?>; 
 text-align: <?php print $wtal; ?>; 
 vertical-align: <?php print $wtva; ?>; 
} 

.eventStart {
 font-family: verdana; 
 font-size: 10px; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
.eventEnd {
 font-family: verdana; 
 font-size: 10px; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
.eventTittel {
 font-family: verdana; 
 font-size: 10px;
 font-weight: bold; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
.eventBeskriv {
 font-family: verdana; 
 font-size: 10px; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
--> 
</style> 

<table border="<?php print $tbd; ?>" cellpadding="<?php print $tcp; ?>" cellspacing="<?php print $tcs; ?>" width="<?php print $dbw * 7; ?>"> 

  <tr> 
    <td class="CalendarTitle"> 
<?php
if ($mn.$yr != date("nY")) echo "<font size=\"1\"><a href=\"$PHP_SELF?yr=".date("Y")."&mn=".date("n")."\">Vis dagen i dag</a></font><br>";

echo "<a href=\"$PHP_SELF?yr=$last_month_yr&mn=$last_month\"><--</a> "; 
print "$month[$current_month] $current_year"; 
echo " <a href=\"$PHP_SELF?yr=$next_month_yr&mn=$next_month\">--></a>";
?> 
    </td> 
  </tr> 
</table> 

<table border="<?php print $tbd; ?>" cellpadding="<?php print $tcp; ?>" cellspacing="<?php print $tcs; ?>" width="<?php print $dbw * 7; ?>"> 

<tr> 
 <?php 
//Loop through days of the week and display the short names above the columns in the calendar 

for ($i=0;$i<7;$i++) { 
print "<td width=\"$dbw\" height=\"$wbh\" class=\"WeekdayTitle\">".$week[$i]."</td>\r\n"; 
} 
?> 
</tr> 
<?php 
$events = getEventsSQL($current_year, $current_month);

//Set the day counter to the first day, 1. 
$day_counter = 1; 

//This line continues running the loop until all the days of the month have been displayed. 
while($day_counter <= $days_in_month) { 
print "<tr>\r\n"; 

//Loop through the days of the week to display each day number. 
for($i = 0; $i < 7; $i++) { 
 if ((($day_counter <= $days_in_month) && ($first_day != 0) && ($first_day == $i+1)) || (($day_counter <= $days_in_month) && ($first_day == 0))) { 
 	//check to see if the current day counter is today's day 
 	if (($day_counter == $current_day) && ($mt)) { 
     $cur_day_event = date("Ymd", mktime(0,0,1,$current_month,$day_counter,$current_year));
   if (isset($events[$cur_day_event])) echo "<td width=\"$dbw\" height=\"$dbh\" class=\"EventDay\"><a title='".stripslashes($events[$cur_day_event])."' href=\"". $url_root_full. "calendar_details.php?day=$day_counter&mn=$current_month&yr=$current_year&showevent\">$day_counter</a></td>\r\n";
   else if ($current_year == date("Y") && ($current_month == date("n"))) print "<td width=\"$dbw\" height=\"$dbh\" class=\"MarkDay\">$day_counter</td>\r\n";  
   else print "<td width=\"$dbw\" height=\"$dbh\" class=\"NormalDay\">$day_counter</td>\r\n";    
 	} 
 	
 	else {
     $cur_day_event = date("Ymd", mktime(0,0,1,$current_month,$day_counter,$current_year)); 
     if (isset($events[$cur_day_event])) echo "<td width=\"$dbw\" height=\"$dbh\" class=\"EventDay\"><a title=\"".$events[$cur_day_event]."\" href=\"". $url_root_full. "calendar_details.php?day=$day_counter&mn=$current_month&yr=$current_year&showevent\">$day_counter</a></td>\r\n";
   else print "<td width=\"$dbw\" height=\"$dbh\" class=\"NormalDay\">$day_counter</td>\r\n"; 
 	} 

 //Resetting first_day tells us that the first day of the month has already been drawn. 
       $first_day = 0; 
       $day_counter++;
 } 
 
 else { 
 	//No day number should be drawn on this calendar spot, therefore draw a blank spot. 
 	print "<td width=\"$dbw\" height=\"$dbh\" class=\"BlankDay\"> </td>\r\n"; 
 } 
} 
print "</tr>\r\n"; 
} 


echo "</table>"; 

?> 

 

calendar_details.php:

<?php
define("IN_SCRIPT", true);
require_once("core.inc.php");

$yr = intval(calendar_realsafehtml($_GET['yr']));
$mn = intval(calendar_realsafehtml($_GET['mn']));
$day = intval(calendar_realsafehtml($_GET['day']));

if ((empty($yr)) || ($yr < 2006) || ($yr>2035)) $yr = date("Y");
if ((empty($mn)) || ($mn<1) || ($mn>12)) $mn = date("n");
if ((empty($day)) || ($day<1) || ($day > 31)) $day = date("d");

if (!checkdate($mn, $day, $yr)) {
$yr = date("Y");
$mn = date("m");
$day = date("d");
}

//Set the months of the year into an array. 
$month[1] = "Januar"; 
$month[2] = "Februar"; 
$month[3] = "Mars"; 
$month[4] = "April"; 
$month[5] = "Mai"; 
$month[6] = "Juni"; 
$month[7] = "Juli"; 
$month[8] = "August"; 
$month[9] = "September"; 
$month[10] = "Oktober"; 
$month[11] = "November"; 
$month[12] = "Desember"; 

//Set week title names for the days of the week. 
if ($wk) { 
//Use full names for week days 
$week[0] = "Mandag";  // Monday 
$week[1] = "Tirsdag";  // Tuesday 
   $week[2] = "Onsdag";  // Wednesday 
   $week[3] = "Torsdag";  // Thursday 
   $week[4] = "Fredag";  // Friday 
   $week[5] = "Lørdag";  // Saturday 
   $week[6] = "Søndag";  // Sunday 
} 

else { 
//Use short names for week days 
$week[0] = "M";  // Monday 
$week[1] = "T";  // Tuesday 
$week[2] = "O";  // Wednesday 
$week[3] = "T";  // Thursday 
$week[4] = "F";  // Friday 
$week[5] = "L";  // Saturday 
$week[6] = "S";  // Sunday 
} 
//Get current day, returned in numeric format 1-31 
if (!$dy) { 
$current_day = date("j"); 
} 
else { 
$current_day = $dy; 
} 

//Get current month, returned in numeric format 1-12 
if (!$mn) { 
$current_month = date("n"); 
} 
else { 
$current_month = $mn; 
}

//Get current year, returned in numeric format, 4-digits 
if (!$yr) { 
$current_year = date("Y"); 
} 
else { 
$current_year = $yr; 
}  


// Set the dates to use in links to next month
if ($current_month == 12) {
$next_month = 1;
$next_month_yr = $current_year + 1;
}
else {
$next_month = $current_month + 1; 
 	$next_month_yr = $current_year;
}

// Set the dates to use in links to last month
if ($current_month == 1) {
$last_month = 12;
$last_month_yr = $current_year - 1;
}
else {
$last_month = $current_month - 1; 
 	$last_month_yr = $current_year;
}


//Get Days in this month, returned in numeric format 28-31 
$days_in_month = date("t", mktime(0,0,0, $current_month, $current_day, $current_year)); 

//Get the day of the week that the first day of the month falls on, returned numeric format 0-6 
// (same numbering for days of week as the $week array above) 
$first_day = date("w", mktime(0,0,0,$current_month,1,$current_year)); 

$tittel = "Kalender";
include_once 'header.inc.php';

$timestamp_start = mktime(0, 0, 1, $mn, $day, $yr);
$timestamp_end = mktime(23, 59, 59, $mn, $day, $yr);
 
 	$query = "SELECT tittel, beskrivelse, start_time, end_time FROM kalender WHERE ";
 	$query .= "(start_time>$timestamp_start AND end_time<$timestamp_end) OR";
 	$query .= "(start_time<$timestamp_end AND end_time>$timestamp_start)";
 	
 	$result = mysql_query($query) or die("<br>Query failed:<br> $query"); 
 	$num = mysql_num_rows($result);
 	
 	//echo "$query - $num";

echo "<center><h2>$tittel</h2></center>";

 
 	$i=0;
 	while ($num>$i) {
 $tittel = stripslashes(mysql_result($result, $i, "tittel"));
 $beskrivelse = mysql_result($result, $i, "beskrivelse");
 $start_time = mysql_result($result, $i, "start_time");
 $end_time = mysql_result($result, $i, "end_time");
 
 $start_time2 = date("d.m.y H:i", $start_time);
 $end_time2 = date("d.m.y H:i", $end_time);

 echo "<font size=2 face=verdana>$start_time2 - $end_time2: <b>$tittel</b></font><br>";
 //echo "<p class=\"eventEnd\">Til: </p>";
 //echo "<p class=\"eventTittel\">$tittel</p>";	
 //echo "<p class=\"eventBeskriv\"></p>";
//echo "<hr>";
 ++$i;
 	}
       include_once 'footer.inc.php';
?>

 

I tillegg har jeg en core.inc.php som jeg har oppkobling mot databasen og slikt i samt dette:

function getEventsSQL($year, $month) {
$timestamp_start = mktime(0, 0, 1, $month, 1, $year);
$timestamp_end = mktime(23, 59, 59, $month, date("t"), $year);
 	$query = "SELECT tittel, start_time, end_time FROM kalender";
 	$result = mysql_query($query) or die("<br>Query failed:<br> $query"); 
 	$num = mysql_num_rows($result);
 	
 	$i=0;
     while ($num>$i) {
               $tittel = mysql_result($result, $i, "tittel");
     $timestamp_start_res = mysql_result($result, $i, "start_time");
     $timestamp_end_res = mysql_result($result, $i, "end_time");
    
     $start_mnyr = date("Ym", $timestamp_start_res);
    $start_day = date("d", $timestamp_start_res);
    $end_mnyr = date("Ym", $timestamp_end_res);
    $end_day = date("d", $timestamp_end_res);
    
    if ($start_mnyr.$start_day == $end_mnyr.$end_day) {
 	if (isset($eventDate[$start_mnyr.$start_day])) $eventDate[$start_mnyr.$start_day] ="Flere hendelser, klikk for detaljer";
 	else $eventDate[$start_mnyr.$start_day] = $tittel; 
 }
    else {
       $timestamp_start_day = mktime(0,0,0,date("m", $timestamp_start_res), $start_day, date("Y", $timestamp_start_res));
       $timestamp_end_day = mktime(0,0,0,date("m", $timestamp_end_res), $end_day, date("Y", $timestamp_end_res));
       
while ($timestamp_start_day<=$timestamp_end_day) {
         $start_mnyr = date("Ym", $timestamp_start_day);
      $start_day = date("d", $timestamp_start_day);
       
               if (isset($eventDate[$start_mnyr.$start_day])) $eventDate[$start_mnyr.$start_day] = "Flere hendelser, klikk for detaljer";
     	else $eventDate[$start_mnyr.$start_day] = $tittel;
     	if (isset($eventDate[$end_mnyr.$end_day])) $eventDate[$end_mnyr.$end_day] = "Flere hendelser, klikk for detaljer";
                       else $eventDate[$end_mnyr.$end_day] = $tittel;
     	$timestamp_start_day += (60*60*24);
 	}
 	
    
    }
 ++$i;
}	return $eventDate;
}

function calendar_realsafehtml($str) {
   // Don't do anything if there's no difference or if the original string is empty
   $oldstr = "";

   while($str != $oldstr) {
       $oldstr = $str;
       //nuke script and header tags and anything inbetween
       $str = preg_replace("'<script[^>]*>.*</script>'siU", "", $str);
       $str = preg_replace("'<head[^>]*>.*</head>'siU", "", $str);

       //listed of tags that will not be striped but whose attributes will be (br|b|i, etc)
       $allowed = "";
       //start nuking those suckers. don you just love MS Word's HTML?
       $str = preg_replace("/<((?!\/?($allowed)\b)[^>]*>)/xis", "", $str);
       $str = preg_replace("/<($allowed).*?>/i", "<\\1>", $str);
   }
   return mysql_escape_string($str);
}

 

:)

Lenke til kommentar
  • 7 måneder senere...

Klikk for å se/fjerne innholdet nedenfor

Selve kalenderen er bygget fra en annet script, så det er en del unødvendig kode med i scriptet, men jeg har ikke orket å rydde :p

 

calendar.php:

<?php 
if (!defined('IN_SCRIPT')) define("IN_SCRIPT", true);
require_once("core.inc.php");

if (isset($_GET['yr'])) $yr = intval(calendar_realsafehtml($_GET['yr']));
else $yr = "";
if (isset($_GET['mn'])) $mn = intval(calendar_realsafehtml($_GET['mn']));
else $mn = "";
if (isset($_GET['day'])) $day = intval(calendar_realsafehtml($_GET['day']));
else $day = "";

if ((empty($yr)) || ($yr < 2006) || ($yr>2035)) $yr = date("Y");
if ((empty($mn)) || ($mn<1) || ($mn>12)) $mn = date("n");
if ((empty($day)) || ($day<1) || ($day > 31)) $day = date("d");

if (!checkdate($mn, $day, $yr)) {
$yr = date("Y");
$mn = date("m");
$day = date("d");
}

//************************************************************
//External variables:  (ex. calendar.php?mn=12&dy=3&yr=2003)
//************************************************************
// tcs = Set Table Cell Spacing
// tcp = Set Table Cell Padding
// tbd = Set Table Border
// mn = Set month (1-12)
// dy = Set day (1-31)
// yr = Set year (4 digit year)
// nm = Set to Next Month (equal to 1)
// lm = Set to Last Month (equal to 1)
// mt = Set Calendar to Mark Today (equal to 1)
// dbh = Set Day Box Height (pixel height of day boxes)
// dbw = Set Day Box Width (pixel width of day boxes)
// wbh = Set Weekday Box Height (pixel height of weekday boxes)
// ctfs = Set Calendar Title Font Size (ex. 10, 12, 14)
// ctfw = Set Calendar Title Font Weight (ex. bold)
// ctfc = Set Calendar Title Font Color (ex. 000000)
// ctbc = Set Calendar Title Background Color (ex. 000000)
// ctal = Set Calendar Title Alignment (ex. left, right, center)
// ndfs = Set Normal Day Font Size (ex. 10, 12, 14)
// ndfc = Set Normal Day Font Color (ex. 000000)
// ndbc = Set Normal Day Background Color (ex. 000000)
// ndal = Set Normal Day Alignment (ex. left, right, center)
// ndva = Set Normal Day Vertical Alignment (ex. top, middle, bottom)
// mdfc = Set Mark Day Font Color (ex. FF0000)
// mdbc = Set Mark Day Background Color (ex. 000000)
// bdbc = Set Blank Day Background Color (ex. 000000)
// wtfs = Set Weekday Title Font Size (ex. 10, 12, 14)
// wtfc = Set Weekday Title Font Color (ex. 000000)
// wtbc = Set Weekday Title Background Color (ex. 000000)
// wtal = Set Weekday Title Alignment (ex. left, right, center)
// wtva = Set Weekday Title Vertical Alignment (ex. top, middle, bottom)
// wk = Set weekday titles to Full names (equal to 1)  

// *******************************
// ctfn = Calendar Title Font Name
// ndfn = Normal Day Font Name
// mdfn = Mark Day Font Name
// wtfn = Weekday Title Font Name
// *******************************

// Set the above variables to one of the following:
// 1 = Verdana, Arial, Helvetica, sans-serif
// 2 = Arial, Helvetica, sans-serif
// 3 = Times New Roman, Times, serif
// 4 = Courier New, Courier, mono
// 5 = Georgia, Times New Roman, Times, serif
// 6 = Geneva, Arial, Helvetica, sans-serif

//Set the months of the year into an array. 
$month[1] = "Januar"; 
$month[2] = "Februar"; 
$month[3] = "Mars"; 
$month[4] = "April"; 
$month[5] = "Mai"; 
$month[6] = "Juni"; 
$month[7] = "Juli"; 
$month[8] = "August"; 
$month[9] = "September"; 
$month[10] = "Oktober"; 
$month[11] = "November"; 
$month[12] = "Desember"; 

//Set week title names for the days of the week. 
if (isset($wk)) { 
   //Use full names for week days 
   $week[0] = "Mandag";  // Monday 
   $week[1] = "Tirsdag";  // Tuesday 
   $week[2] = "Onsdag";  // Wednesday 
   $week[3] = "Torsdag";  // Thursday 
   $week[4] = "Fredag";  // Friday 
   $week[5] = "Lørdag";  // Saturday 
   $week[6] = "Søndag";  // Sunday 
} 

else { 
//Use short names for week days 
$week[0] = "M";  // Monday 
$week[1] = "T";  // Tuesday 
$week[2] = "O";  // Wednesday 
$week[3] = "T";  // Thursday 
$week[4] = "F";  // Friday 
$week[5] = "L";  // Saturday 
$week[6] = "S";  // Sunday 
} 

//Get current day, returned in numeric format 1-31 
if (!isset($dy)) { 
$current_day = date("j"); 
} 
else { 
$current_day = $dy; 
} 

//Get current month, returned in numeric format 1-12 
if (empty($mn)) { 
$current_month = date("n"); 
} 
else { 
$current_month = $mn; 
}

//Get current year, returned in numeric format, 4-digits 
if (empty($yr)) { 
$current_year = date("Y"); 
} 
else { 
$current_year = $yr; 
}  


// Set the dates to use in links to next month
if ($current_month == 12) {
$next_month = 1;
$next_month_yr = $current_year + 1;
}
else {
$next_month = $current_month + 1; 
 	$next_month_yr = $current_year;
}

// Set the dates to use in links to last month
if ($current_month == 1) {
$last_month = 12;
$last_month_yr = $current_year - 1;
}
else {
$last_month = $current_month - 1; 
 	$last_month_yr = $current_year;
}


//Get Days in this month, returned in numeric format 28-31 
$days_in_month = date("t", mktime(0,0,0, $current_month, $current_day, $current_year)); 

//Get the day of the week that the first day of the month falls on, returned numeric format 0-6 
// (same numbering for days of week as the $week array above) 
$first_day = date("w", mktime(0,0,0,$current_month,1,$current_year)); 
// To prevent bug if first day is sunday
if ($first_day == 0) $first_day = 7; 

//Table Properties 
if (!isset($tcs)) { $tcs = 1; }       //Cell Spacing 
if (!isset($tcp)) { $tcp = 0; }      //Cell Padding 
if (!isset($tbd)) { $tbd = 0; }      //Border 

//Set Day Box Height 
//If no value is passed, then default to mini calendar settings. 
if (!isset($dbh)) { $dbh = "16"; } 

//Set Day Box Width 
//If no value is passed, then default to mini calendar settings. 
if (!isset($dbw)) { $dbw = "23"; } 

//Set Weekday Box Height 
//If no value is passed, then default to mini calendar settings. 
if (!isset($wbh)) { $wbh = "0"; } 

//Set to mark Today 
if (!isset($mt)) { $mt = 1; } 

//Calendar Title Options 
//******************** 
if (!isset($ctfs)) { $ctfs = 10; }         //Set Font Size 
if (!isset($ctfw)) { $ctfw = "bold"; }      //Set Font Weight 
if (!isset($ctfc)) { $ctfc = "#000000"; }   //Set Font Color 
if (!isset($ctbc)) { $ctbc = ""; }         //Set Cell Background Color 
if (!isset($ctal)) { $ctal = "center"; }      //Set Alignment 
if ((!isset($ctfn)) || ($ctfn==1)) { $ctfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($ctfn==2) { $ctfn = "Arial, Helvetica, sans-serif"; }       
if ($ctfn==3) { $ctfn = "Times New Roman, Times, serif"; } 
if ($ctfn==4) { $ctfn = "Courier New, Courier, mono"; } 
if ($ctfn==5) { $ctfn = "Georgia, Times New Roman, Times, serif"; } 
if ($ctfn==6) { $ctfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
//Normal Day Options 
//******************** 
if (!isset($ndfs)) { $ndfs = 10; }         //Font Size 
if (!isset($ndfc)) { $ndfc = "#000000"; }   //Font Color 
if (!isset($ntfw)) { $ntfw = ""; }      //Set Font Weight 
if (!isset($ndbc)) { $ndbc = "#F7F7F7"; }   //Background Color ecf8ff 
if (!isset($ndal)) { $ndal = "center"; }      //Text Alignment 
if (!isset($ndva)) { $ndva = "middle"; }      //Vertical Alignment 
if ((!isset($ndfn)) || ($ndfn==1)) { $ndfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($ndfn==2) { $ndfn = "Arial, Helvetica, sans-serif"; }       
if ($ndfn==3) { $ndfn = "Times New Roman, Times, serif"; } 
if ($ndfn==4) { $ndfn = "Courier New, Courier, mono"; } 
if ($ndfn==5) { $ndfn = "Georgia, Times New Roman, Times, serif"; } 
if ($ndfn==6) { $ndfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
//Mark Day Options 
//******************** 
if (!isset($mdfc)) { $mdfc = "#FF0000"; }   //Font Color 
if (!isset($mdbc)) { $mdbc = "#EAF5FF"; }   //Background Color ecf8ff 
if ((!isset($mdfn)) || ($mdfn==1)) { $mdfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($mdfn==2) { $mdfn = "Arial, Helvetica, sans-serif"; }       
if ($mdfn==3) { $mdfn = "Times New Roman, Times, serif"; } 
if ($mdfn==4) { $mdfn = "Courier New, Courier, mono"; } 
if ($mdfn==5) { $mdfn = "Georgia, Times New Roman, Times, serif"; } 
if ($mdfn==6) { $mdfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
//Blank Day Options 
//******************** 
if (!isset($bdbc)) { $bdbc = "#EEEEEE"; }   //Background Color eaf5ff 

//Weekday Title Options 
//******************** 
if (!isset($wtfs)) { $wtfs = 10; }         //Font Size 
if (!isset($wtfc)) { $wtfc = "#000000"; }   //Font Color 
if (!isset($wtfw)) { $wtfw = "bold"; }      //Set Font Weight 
if (!isset($wtbc)) { $wtbc = "#C9C9C9"; }   //Background Color ffffe8 
if (!isset($wtal)) { $wtal = "center"; }    //Text Alignment 
if (!isset($wtva)) { $wtva = "middle"; }      //Vertical Alignment 
if ((!isset($wtfn)) || ($wtfn==1)) { $wtfn = "Verdana, Arial, Helvetica, sans-serif"; }//Font Name 
/*if ($wtfn==2) { $wtfn = "Arial, Helvetica, sans-serif"; }       
if ($wtfn==3) { $wtfn = "Times New Roman, Times, serif"; } 
if ($wtfn==4) { $wtfn = "Courier New, Courier, mono"; } 
if ($wtfn==5) { $wtfn = "Georgia, Times New Roman, Times, serif"; } 
if ($wtfn==6) { $wtfn = "Geneva, Arial, Helvetica, sans-serif"; } 
*/
?> 

<style type="text/css"> 
<!-- 
.CalendarTitle { 
 font-family: <?php print $ctfn; ?>; 
 font-size: <?php print $ctfs; ?>px; 
 font-weight: <?php print $ctfw; ?>; 
 color: <?php print $ctfc; ?>; 
 background-color: <?php print $ctbc; ?>; 
 text-align: <?php print $ctal; ?>; 
} 

.NormalDay { 
 font-family: <?php print $ndfn; ?>; 
 font-size: <?php print $ndfs; ?>px; 
 font-weight: <?php print $ntfw; ?>; 
 color: <?php print $ndfc; ?>; 
 background-color: <?php print $ndbc; ?>; 
 text-align: <?php print $ndal; ?>; 
 vertical-align: <?php print $ndva; ?>; 
} 

.MarkDay { 
 font-family: <?php print $mdfn; ?>; 
 font-size: <?php print $ndfs; ?>px; 
 color: <?php print $ndfc; ?>; 
 background-color: #F0E2E2; 
 text-align: <?php print $ndal; ?>; 
 vertical-align: <?php print $ndva; ?>; 
} 

.EventDay { 
 font-family: <?php print $mdfn; ?>; 
 font-size: <?php print $ndfs; ?>px;
 font-weight: bold; 
 color: <?php print $ndfc; ?>; 
 background-color: <?php print $mdbc; ?>; 
 text-align: <?php print $ndal; ?>; 
 vertical-align: <?php print $ndva; ?>; 
} 

.BlankDay { 
 background-color: <?php print $bdbc; ?>; 
} 

.WeekdayTitle { 
 font-family: <?php print $wtfn; ?>; 
 font-size: <?php print $wtfs; ?>px; 
 font-weight: <?php print $wtfw; ?>; 
 color: <?php print $wtfc; ?>; 
 background-color: <?php print $wtbc; ?>; 
 text-align: <?php print $wtal; ?>; 
 vertical-align: <?php print $wtva; ?>; 
} 

.eventStart {
 font-family: verdana; 
 font-size: 10px; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
.eventEnd {
 font-family: verdana; 
 font-size: 10px; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
.eventTittel {
 font-family: verdana; 
 font-size: 10px;
 font-weight: bold; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
.eventBeskriv {
 font-family: verdana; 
 font-size: 10px; 
 line-height: 1.5em;
 margin-top: 0px;
 margin-bottom: 0px;
}
--> 
</style> 

<table border="<?php print $tbd; ?>" cellpadding="<?php print $tcp; ?>" cellspacing="<?php print $tcs; ?>" width="<?php print $dbw * 7; ?>"> 

  <tr> 
    <td class="CalendarTitle"> 
<?php
if ($mn.$yr != date("nY")) echo "<font size=\"1\"><a href=\"$PHP_SELF?yr=".date("Y")."&mn=".date("n")."\">Vis dagen i dag</a></font><br>";

echo "<a href=\"$PHP_SELF?yr=$last_month_yr&mn=$last_month\"><--</a> "; 
print "$month[$current_month] $current_year"; 
echo " <a href=\"$PHP_SELF?yr=$next_month_yr&mn=$next_month\">--></a>";
?> 
    </td> 
  </tr> 
</table> 

<table border="<?php print $tbd; ?>" cellpadding="<?php print $tcp; ?>" cellspacing="<?php print $tcs; ?>" width="<?php print $dbw * 7; ?>"> 

<tr> 
 <?php 
//Loop through days of the week and display the short names above the columns in the calendar 

for ($i=0;$i<7;$i++) { 
print "<td width=\"$dbw\" height=\"$wbh\" class=\"WeekdayTitle\">".$week[$i]."</td>\r\n"; 
} 
?> 
</tr> 
<?php 
$events = getEventsSQL($current_year, $current_month);

//Set the day counter to the first day, 1. 
$day_counter = 1; 

//This line continues running the loop until all the days of the month have been displayed. 
while($day_counter <= $days_in_month) { 
print "<tr>\r\n"; 

//Loop through the days of the week to display each day number. 
for($i = 0; $i < 7; $i++) { 
 if ((($day_counter <= $days_in_month) && ($first_day != 0) && ($first_day == $i+1)) || (($day_counter <= $days_in_month) && ($first_day == 0))) { 
 	//check to see if the current day counter is today's day 
 	if (($day_counter == $current_day) && ($mt)) { 
     $cur_day_event = date("Ymd", mktime(0,0,1,$current_month,$day_counter,$current_year));
   if (isset($events[$cur_day_event])) echo "<td width=\"$dbw\" height=\"$dbh\" class=\"EventDay\"><a title='".stripslashes($events[$cur_day_event])."' href=\"". $url_root_full. "calendar_details.php?day=$day_counter&mn=$current_month&yr=$current_year&showevent\">$day_counter</a></td>\r\n";
   else if ($current_year == date("Y") && ($current_month == date("n"))) print "<td width=\"$dbw\" height=\"$dbh\" class=\"MarkDay\">$day_counter</td>\r\n";  
   else print "<td width=\"$dbw\" height=\"$dbh\" class=\"NormalDay\">$day_counter</td>\r\n";    
 	} 
 	
 	else {
     $cur_day_event = date("Ymd", mktime(0,0,1,$current_month,$day_counter,$current_year)); 
     if (isset($events[$cur_day_event])) echo "<td width=\"$dbw\" height=\"$dbh\" class=\"EventDay\"><a title=\"".$events[$cur_day_event]."\" href=\"". $url_root_full. "calendar_details.php?day=$day_counter&mn=$current_month&yr=$current_year&showevent\">$day_counter</a></td>\r\n";
   else print "<td width=\"$dbw\" height=\"$dbh\" class=\"NormalDay\">$day_counter</td>\r\n"; 
 	} 

 //Resetting first_day tells us that the first day of the month has already been drawn. 
       $first_day = 0; 
       $day_counter++;
 } 
 
 else { 
 	//No day number should be drawn on this calendar spot, therefore draw a blank spot. 
 	print "<td width=\"$dbw\" height=\"$dbh\" class=\"BlankDay\"> </td>\r\n"; 
 } 
} 
print "</tr>\r\n"; 
} 


echo "</table>"; 

?> 

 

calendar_details.php:

<?php
define("IN_SCRIPT", true);
require_once("core.inc.php");

$yr = intval(calendar_realsafehtml($_GET['yr']));
$mn = intval(calendar_realsafehtml($_GET['mn']));
$day = intval(calendar_realsafehtml($_GET['day']));

if ((empty($yr)) || ($yr < 2006) || ($yr>2035)) $yr = date("Y");
if ((empty($mn)) || ($mn<1) || ($mn>12)) $mn = date("n");
if ((empty($day)) || ($day<1) || ($day > 31)) $day = date("d");

if (!checkdate($mn, $day, $yr)) {
$yr = date("Y");
$mn = date("m");
$day = date("d");
}

//Set the months of the year into an array. 
$month[1] = "Januar"; 
$month[2] = "Februar"; 
$month[3] = "Mars"; 
$month[4] = "April"; 
$month[5] = "Mai"; 
$month[6] = "Juni"; 
$month[7] = "Juli"; 
$month[8] = "August"; 
$month[9] = "September"; 
$month[10] = "Oktober"; 
$month[11] = "November"; 
$month[12] = "Desember"; 

//Set week title names for the days of the week. 
if ($wk) { 
//Use full names for week days 
$week[0] = "Mandag";  // Monday 
$week[1] = "Tirsdag";  // Tuesday 
   $week[2] = "Onsdag";  // Wednesday 
   $week[3] = "Torsdag";  // Thursday 
   $week[4] = "Fredag";  // Friday 
   $week[5] = "Lørdag";  // Saturday 
   $week[6] = "Søndag";  // Sunday 
} 

else { 
//Use short names for week days 
$week[0] = "M";  // Monday 
$week[1] = "T";  // Tuesday 
$week[2] = "O";  // Wednesday 
$week[3] = "T";  // Thursday 
$week[4] = "F";  // Friday 
$week[5] = "L";  // Saturday 
$week[6] = "S";  // Sunday 
} 
//Get current day, returned in numeric format 1-31 
if (!$dy) { 
$current_day = date("j"); 
} 
else { 
$current_day = $dy; 
} 

//Get current month, returned in numeric format 1-12 
if (!$mn) { 
$current_month = date("n"); 
} 
else { 
$current_month = $mn; 
}

//Get current year, returned in numeric format, 4-digits 
if (!$yr) { 
$current_year = date("Y"); 
} 
else { 
$current_year = $yr; 
}  


// Set the dates to use in links to next month
if ($current_month == 12) {
$next_month = 1;
$next_month_yr = $current_year + 1;
}
else {
$next_month = $current_month + 1; 
 	$next_month_yr = $current_year;
}

// Set the dates to use in links to last month
if ($current_month == 1) {
$last_month = 12;
$last_month_yr = $current_year - 1;
}
else {
$last_month = $current_month - 1; 
 	$last_month_yr = $current_year;
}


//Get Days in this month, returned in numeric format 28-31 
$days_in_month = date("t", mktime(0,0,0, $current_month, $current_day, $current_year)); 

//Get the day of the week that the first day of the month falls on, returned numeric format 0-6 
// (same numbering for days of week as the $week array above) 
$first_day = date("w", mktime(0,0,0,$current_month,1,$current_year)); 

$tittel = "Kalender";
include_once 'header.inc.php';

$timestamp_start = mktime(0, 0, 1, $mn, $day, $yr);
$timestamp_end = mktime(23, 59, 59, $mn, $day, $yr);
 
 	$query = "SELECT tittel, beskrivelse, start_time, end_time FROM kalender WHERE ";
 	$query .= "(start_time>$timestamp_start AND end_time<$timestamp_end) OR";
 	$query .= "(start_time<$timestamp_end AND end_time>$timestamp_start)";
 	
 	$result = mysql_query($query) or die("<br>Query failed:<br> $query"); 
 	$num = mysql_num_rows($result);
 	
 	//echo "$query - $num";

echo "<center><h2>$tittel</h2></center>";

 
 	$i=0;
 	while ($num>$i) {
 $tittel = stripslashes(mysql_result($result, $i, "tittel"));
 $beskrivelse = mysql_result($result, $i, "beskrivelse");
 $start_time = mysql_result($result, $i, "start_time");
 $end_time = mysql_result($result, $i, "end_time");
 
 $start_time2 = date("d.m.y H:i", $start_time);
 $end_time2 = date("d.m.y H:i", $end_time);

 echo "<font size=2 face=verdana>$start_time2 - $end_time2: <b>$tittel</b></font><br>";
 //echo "<p class=\"eventEnd\">Til: </p>";
 //echo "<p class=\"eventTittel\">$tittel</p>";	
 //echo "<p class=\"eventBeskriv\"></p>";
//echo "<hr>";
 ++$i;
 	}
       include_once 'footer.inc.php';
?>

 

I tillegg har jeg en core.inc.php som jeg har oppkobling mot databasen og slikt i samt dette:

function getEventsSQL($year, $month) {
$timestamp_start = mktime(0, 0, 1, $month, 1, $year);
$timestamp_end = mktime(23, 59, 59, $month, date("t"), $year);
 	$query = "SELECT tittel, start_time, end_time FROM kalender";
 	$result = mysql_query($query) or die("<br>Query failed:<br> $query"); 
 	$num = mysql_num_rows($result);
 	
 	$i=0;
     while ($num>$i) {
               $tittel = mysql_result($result, $i, "tittel");
     $timestamp_start_res = mysql_result($result, $i, "start_time");
     $timestamp_end_res = mysql_result($result, $i, "end_time");
    
     $start_mnyr = date("Ym", $timestamp_start_res);
    $start_day = date("d", $timestamp_start_res);
    $end_mnyr = date("Ym", $timestamp_end_res);
    $end_day = date("d", $timestamp_end_res);
    
    if ($start_mnyr.$start_day == $end_mnyr.$end_day) {
 	if (isset($eventDate[$start_mnyr.$start_day])) $eventDate[$start_mnyr.$start_day] ="Flere hendelser, klikk for detaljer";
 	else $eventDate[$start_mnyr.$start_day] = $tittel; 
 }
    else {
       $timestamp_start_day = mktime(0,0,0,date("m", $timestamp_start_res), $start_day, date("Y", $timestamp_start_res));
       $timestamp_end_day = mktime(0,0,0,date("m", $timestamp_end_res), $end_day, date("Y", $timestamp_end_res));
       
while ($timestamp_start_day<=$timestamp_end_day) {
         $start_mnyr = date("Ym", $timestamp_start_day);
      $start_day = date("d", $timestamp_start_day);
       
               if (isset($eventDate[$start_mnyr.$start_day])) $eventDate[$start_mnyr.$start_day] = "Flere hendelser, klikk for detaljer";
     	else $eventDate[$start_mnyr.$start_day] = $tittel;
     	if (isset($eventDate[$end_mnyr.$end_day])) $eventDate[$end_mnyr.$end_day] = "Flere hendelser, klikk for detaljer";
                       else $eventDate[$end_mnyr.$end_day] = $tittel;
     	$timestamp_start_day += (60*60*24);
 	}
 	
    
    }
 ++$i;
}	return $eventDate;
}

function calendar_realsafehtml($str) {
   // Don't do anything if there's no difference or if the original string is empty
   $oldstr = "";

   while($str != $oldstr) {
       $oldstr = $str;
       //nuke script and header tags and anything inbetween
       $str = preg_replace("'<script[^>]*>.*</script>'siU", "", $str);
       $str = preg_replace("'<head[^>]*>.*</head>'siU", "", $str);

       //listed of tags that will not be striped but whose attributes will be (br|b|i, etc)
       $allowed = "";
       //start nuking those suckers. don you just love MS Word's HTML?
       $str = preg_replace("/<((?!\/?($allowed)\b)[^>]*>)/xis", "", $str);
       $str = preg_replace("/<($allowed).*?>/i", "<\\1>", $str);
   }
   return mysql_escape_string($str);
}

 

:)

7925437[/snapback]

 

Har du script for å lage tabell med alle feltene som trengs?

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...