Category Archives: Date and Time

Create Zip Archive of Folder and All Contents

PHP code snippet to Create Zip Archive of Folder and All Contents – without the full directory path being included.

<?php

//function to zip an entire folder to back a backup
//saves to archive/year/month/day/filename.zip
function createZip($zipName,$folderToZip)
{
      // get year digits
      $year = date("Y");
      //create year directory if doesn't exist
      if (!is_dir('archive/'.$year))
      {
          mkdir('archive/'.$year);
      }

      //get month digits
      $month = date("m");
      //create month directory if doesn't exist
      if (!is_dir('archive/'.$year.'/'.$month))
      {
          mkdir('archive/'.$year.'/'.$month);
      }

      //get day digits
      $day = date("d");
      //create day directory if doesn't exist
      if (!is_dir('archive/'.$year.'/'.$month.'/'.$day))
      {
          mkdir('archive/'.$year.'/'.$month.'/'.$day);
      }

      $zipFile = 'archive/'.$year.'/'.$month.'/'.$day.'/'.$zipName.'.zip';

      ini_set("max_execution_time", 300);
      // create object
      $zip = new ZipArchive();
      // open archive
      if ($zip->open($zipFile, ZIPARCHIVE::CREATE) !== TRUE)
      {
            die ("Could not open archive");
      }
      // initialize an iterator
      // pass it the directory to be processed
      $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folderToZip."/"));
      // iterate over the directory
      // add each file found to the archive
      foreach ($iterator as $key=>$value)
      {
            $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
      }
      // close and save archive
      $zip->close();
      echo "Archive created successfully.";

      return $zipFile;
}
?>

PHP Date Range script

Web Date Range script that can be included in any web page.Script checks for valid dates and return correct dates as $date1 and $date2.”Invalid date” message will be shown on choosing invalid date range when checked.This free web date select form can be used as in example: HAdd.User can select dates as today, yesterday, etc or choose between a range of dates.Simple to integrate in to any page. The script uses php and javascript.Just Download for free and Use it.

<!--
(c) copyright 2004, HIOX INDIA
This  is  a free tool provided by hioxidia.com
visit us at http://www.hscripts.com
-->

<table align=center cellpadding=0 cellspacing=0 style="font-size: 14px;">
<tr><td align=left>
<script language=javascript>
function addd(sd)
{
if(sd == 1)
{
document.xc.d1.disabled = true;
document.xc.d2.disabled = true;
document.xc.m1.disabled = true;
document.xc.m2.disabled = true;
document.xc.y1.disabled = true;
document.xc.y2.disabled = true;
document.xc.when.disabled = false;
document.xc.opt.value = "op1";
}
else
{
document.xc.d1.disabled = false;
document.xc.d2.disabled = false;
document.xc.m1.disabled = false;
document.xc.m2.disabled = false;
document.xc.y1.disabled = false;
document.xc.y2.disabled = false;
document.xc.when.disabled = true;
document.xc.opt.value = "op2";
}
}
</script>

<?php
$option = $_POST['opt'];
$when = $_POST['when'];
$d1 = $_POST['d1'];
$m1 = $_POST['m1'];
$y1 = $_POST['y1'];
$d2 = $_POST['d2'];
$m2 = $_POST['m2'];
$y2 = $_POST['y2'];
if($option == "")
$option = "op1";
?>

<form name=xc action="<?php echo($PHP_SELF); ?>" method=POST>
<?php
if($option != "op2")
{
echo "<input type=radio name=myradio value=1 checked onchange=addd('1')>";
echo "<select name=when>";
}
else
{
echo "<input type=radio name=myradio value=1 onchange=addd('1')>";
echo "<select name=when disabled>";
}

if($when == "today")
echo "<option value=today selected>today</option>";
else
echo "<option value=today>today</option>";
if($when == "yesterday")
echo "<option value=yesterday selected>yesterday</option>";
else
echo "<option value=yesterday>yesterday</option>";
if($when == "ago2")
echo "<option value=ago2 selected>2 days ago</option>";
else
echo "<option value=ago2>2 days ago</option>";
if($when == "week")
echo "<option value=week selected>this week</option>";
else
echo "<option value=week>this week</option>";
if($when == "month")
echo "<option value=month selected>this month</option>";
else
echo "<option value=month>this month</option>";
?>
</select><br>


<!-- option two starts here -->
<?php
if($option == "op2")
{
echo "<input type=radio name=myradio value=2 checked onchange=addd('2')>";
echo "<select name=m1>";
}
else
{
echo "<input type=radio name=myradio value=2 onchange=addd('2')>";
echo "<select name=m1 disabled>";
}

for($j=1; $j<13; $j++)
{
if($m1 == $j)
echo "<option value=$j selected>$j</option>";
else
echo "<option value=$j>$j</option>";
}
?>
</select>

<?php
if($option == "op2")
echo "<select name=d1>";
else
echo "<select name=d1 disabled>";

for($j=1; $j<32; $j++)
{
if($d1 == $j)
echo "<option value=$j selected>$j</option>";
else
echo "<option value=$j>$j</option>";
}
?>
</select>

<?php
if($option == "op2")
echo "<select name=y1>";
else
echo "<select name=y1 disabled>";

$year = date("Y");
echo "<option value=2005>2005</option>";
for($j=2006; $j<=$year; $j++)
{
if($y1 == $j)
echo "<option value=$j selected>$j</option>";
else
echo "<option value=$j>$j</option>";
}
?>
</select>

to

<?php
if($option == "op2")
echo "<select name=m2>";
else
echo "<select name=m2 disabled>";

for($j=1; $j<13; $j++)
{
if($m2 == $j)
echo "<option value=$j selected>$j</option>";
else
echo "<option value=$j>$j</option>";
}
?>
</select>

<?php
if($option == "op2")
echo "<select name=d2>";
else
echo "<select name=d2 disabled>";

for($j=1; $j<32; $j++)
{
if($d2 == $j)
echo "<option value=$j selected>$j</option>";
else
echo "<option value=$j>$j</option>";
}
?>
</select>

<?php
if($option == "op2")
echo "<select name=y2>";
else
echo "<select name=y2 disabled>";

$year = date("Y");
echo "<option value=2005>2005</option>";
for($j=2006; $j<=$year; $j++)
{
if($y2 == $j)
echo "<option value=$j selected>$j</option>";
else
echo "<option value=$j>$j</option>";
}

echo "</select><br>";
echo "<input type=hidden name=opt value=$option>";
?>
<input type=submit value="view stats">
</form>

<?php

if($option != "op2")
{
if($when=="today"){$dd = 0;}
else if($when=="yesterday"){$dd = -1;}
else if($when=="ago2"){$dd = -2;}
else if($when=="week"){
$dfs = "two";
$dd1 = 0;
$dd2 = -7;
}
else if($when=="week"){
$dfs = "two";
$dd1 = 0; $dd2 = -6; $mm1 = 0; $mm2 = 0;
}
else if($when=="month"){
$dfs = "two";
$dd1 = 0; $dd2 = -(date("d")-1); $mm1 = 0; $mm2 = 0;
}
}
else
{
$dfs = "three";
}

if($dfs == "two")
{
$date1 = date("Y-m-d",mktime(0, 0, 0, date("m")+$mm1, date("d")+$dd1, date("Y")));
$date2 = date("Y-m-d",mktime(0, 0, 0, date("m")+$mm2, date("d")+$dd2, date("Y")));
include "action.php";
}
else if($dfs == "three")
{
if(checkdate($m1,$d1,$y1) == true &amp;&amp; checkdate($m2,$d2,$y2) ==  true)
{
$t1 = mktime(0, 0, 0, $m1, $d1, $y1);
$t2 = mktime(0, 0, 0, $m2, $d2, $y2);
if($t1 > $t2)
{
echo "<br><br><font color=red>Invalid date range</font><br><br>";
}
else
{
$date2 = date("Y-m-d",mktime(0, 0, 0, $m1, $d1, $y1));
$date1 = date("Y-m-d",mktime(0, 0, 0, $m2, $d2, $y2));
include "action.php";
}
}
else
{
echo "<br><br><font color=red>Invalid date [you might have selected date as 31 for month 2]</font><br><br>";
}
}
else
{
$date1 = date("Y-m-d",mktime(0, 0, 0, date("m"), date("d")+$dd, date("Y")));
$date2 = $date1;
include "action.php";
}
?>
</td></tr></table>

Clock – cross-browser; status bar clock + message

Display the date and time in your browser’s status bar. Or just the date, or just the time, or maybe a cheerful message to brighten someone’s day. It’s quite customizable.

Paste this script Between the <HEAD> tags of your web page.
Edit " Your Message here"

Author: Ben Jones

http://www.benf16.supanet.com



<!-- begin -->

<script language="JavaScript">
<!--

function Clock() {

window.setTimeout( "Clock()", 1000 );

now = new Date();
localtime = now.toString();
hours = now.getHours();
mins = now.getMinutes();
secs = now.getSeconds();

self.status = hours + ":" + mins + ":" + secs + " Your Message Here".toString();

}
Clock()
// -->
</script>

<!-- end -->

Project Calendar script providesDate and Time

Project Calendar script provides you an upgradeable calendar module.

<? include_once("./includes/application_top.php"); ?>
<?
 if (!@wrap_session_is_registered('valid_user')) {
 header('Location: ' . href_link(FILENAME_LOGIN, 'origin=' . FILENAME_UPDATE, 'NONSSL'));
 wrap_exit();
 }
?>
<?
$page_title = "Update User Information";

$page_error_message = '';
$update_result = false; // default

if ($_POST['update'] == "") {

 $user_info_fields = get_user_information($_SESSION['valid_user']);
 if (!(count($user_info_fields)>0)) {
 $page_error_message = "Your user information could not be found! Please try again. ".$_SESSION['valid_user']."";
 $update_result = false;
 } else {
 // Set the $_POST variable for the Form fields below.
 foreach (array_keys($user_info_fields) as $key) {
 $_POST[$key] = addslashes($user_info_fields[$key]);
 }
 }

} else if ($_POST['update'] != "") { // Update Form Submit

 if ($_POST['username'] == "" || $_POST['email'] == "") {  // check forms filled in - required fields
 $page_title = "Problem Updating User Information!";
 $page_error_message = "You have not filled the form out correctly. " .
 "Please make sure to fill out all required fields.";
 }
 elseif (!validate_email($_POST['email'])) {  // email address not valid
 $page_title = "Problem Updating User Information!";
 $page_error_message = "Your email address is not valid. Please try again.";
 }

 if ($page_error_message == '') {  // attempt to update user info if no error message
 $update_result = update_user_information($_POST['username'], $_POST['firstname'],
 $_POST['lastname'], $_POST['email']);
 if ($update_result) {
 $page_title = "Update Successful!";
 } else {
 // update problem: database error, etc
 $page_title = "Problem Updating User Information!3";
 $page_error_message = $update_result;
 }
 }

} // end of if ($_POST['update']
?>
<?
$page_title = "Booking Calendar - User Information Update";
$page_title_bar = "User Information Update:";
include_once("header.php");

if ($update_result) {

 // Update Successful!
 echo '<p align="center">Your update was successful!</p>';

}

 // Update Form or Update Problem.
?>
<form method="post" action="<?=FILENAME_UPDATE?>">
<input type="hidden" name="username" value="<? echo stripslashes($_POST['username']); ?>">
<table cellpadding="2" cellspacing="0" border="0" width="100%">
<tr><td align="right">Your Username:</td><td><? echo stripslashes($_POST['username']); ?></td></tr>
<tr><td align="center" colspan="2"><table cellpadding="0" cellspacing="0" border="0" width="50%"><tr><td><img
src="/spacer.gif" width="300" height="1" alt="" /></td></tr></table></td></tr>
<tr><td align="center" colspan="2"><span>
Note: Blank fields are updated!</span></td></tr>
<tr><td align="right">First Name: </td>
<td><INPUT TYPE="text" name="firstname" value="<? echo stripslashes($_POST['firstname']) ?>" size="25" maxlength="90"></td></tr>
<tr><td align="right">Last Name: </td>
<td><INPUT TYPE="text" name="lastname" value="<? echo stripslashes($_POST['lastname']) ?>" size="25" maxlength="90"></td></tr>
<tr><td align="right">E-mail Address: <br /><span><em>(required)</em></span> </td>
<td><INPUT TYPE="text" name="email" value="<? echo stripslashes($_POST['email']); ?>" size="30" maxlength="90"></td></tr>
<tr><td align="center" colspan="2"><br />
<input type="hidden" name="groups" value="">
<input type="hidden" name="update" value="yes">
<input type="submit" name="update" value="Submit New User Information">
</td></tr></table>
</form>
<?

include_once("footer.php");
?>
<? include_once("application_bottom.php"); ?>

&amp;nbsp;

PHP Calendar application was designed Tame-Date

This isnt just another PHP calendar application. This calendar application was designed with booking and tracking in mind. It provides a unique database design which establishes an index of time slots, enabling more features with less CPU usage.

 

<? include_once("./includes/application_top.php"); ?>
<?

$page_title = "Booking Calendar - Forgot Password";
$page_title_bar = "Forgot Password?";

$page_error_message = '';
$password_changed = false;

if ($_POST['forgot_password'] != "") { // Forgot Passwd Form Submit

 if ($_POST['username'] == "" || $_POST['email'] == "") {
 $page_title = "Reset Password Problem";
 $page_error_message = "You have not filled out the form completely. Please try again.";
 }
 elseif (!wrap_validate_email($_POST['email'])) {  // email address not valid
 $page_title = "Reset Password Problem";
 $page_error_message = "Your email address is not valid. Please try again.";
 }

 if ($page_error_message == '') {
 $reset_passwd = reset_password($_POST['username'], $_POST['email']);
 if ($reset_passwd != false &amp;&amp; $reset_passwd != '') {
 $password_changed = true;
 $msg =  "Your user password has been changed to $reset_passwd \n" .
 "Please change it next time you log in. Thank You. \n";
 if (send_mail("", "", $_POST['email'], $_POST['email'],
 "Booking Calendar: User Login Information", $msg)) {
 $page_title = "Resetting Password Successful!";
 $page_info_message = "Your new password has been sent to your email address.";
 } else {
 $page_title = "Resetting Password E-mail Problem";
 $page_error_message = "Your password could not be e-mailed to you. Try pressing your refresh button.";
 }
 } else {
 $page_title = "Resetting Password Problem";
 $page_error_message = "Your password could not be reset. Make sure you typed in the correct username and email address and try again.";
 }
 }

} // end of if ($_POST['forgot_password'] != "")
?>
<?
include_once("header.php");

if ($password_changed) {
 // Display Change Success
} else {
 // display HTML form to reset and email password
?>

<p align="center">
<form action="user_forgot_passwd.php" method="post">
<table cellpadding="2" cellspacing="0" border="0">
<tr><td nowrap="nowrap" align="right">Username: </td>
<td><input type="text" name="username" size="16" maxlength="16"></td></tr>
<tr><td align="right">E-mail Address: <br /><span><em>(required)</em></span> </td>
<td><INPUT TYPE="text" name="email" value="<? echo stripslashes($_POST['email']); ?>" size="30" maxlength="60"></td></tr>
<tr><td colspan="2" align="center"><br />
<input type="hidden" name="forgot_password" value="yes">
<input type="submit" name="submit" value="Submit Information">
</td></tr></table>
</p>
<?
}

include_once("footer.php");
?>
<? include_once("application_bottom.php"); ?>

&amp;nbsp;

&amp;nbsp;

 

 

 

Object oriented calendar scripts Time-Date

Max’s Calendar is an object oriented calendar script written in PHP. Installation and setup is very easy. You only need to upload the relevant files and insert some lines of code into your own script to display a calendar on your own page. You can display as many months at once as you want. The look of the calendar is easily changeable using CSS.

 

 

<?php

/* This file handles the generation of the RSS feed. */

include_once(dirname(__FILE__).'/plog-load-config.php');

function generate_RSS_feed ($level, $id, $search = '') {
 global $config;

 $config['feed_title'] = SmartStripSlashes($config['feed_title']);

 // remove plog-rss from the end, if present .. is there a better way to determine the full url?
 $is_rss = strpos($config['baseurl'], 'plog-rss.php');
 if ($is_rss !== false) {
 $config['baseurl'] = substr($config['baseurl'], 0, $is_rss);
 }

 if (!empty($search)) $level = 'search';

 // Aggregate feed of all albums with collection specified by id
 if ($level == 'collection') {
 if ($config['feed_content'] == 0 ) {
 plogger_init_albums(array(
 'collection_id' => $id,
 'sortby' => 'id',
 'sortdir' => 'DESC',
 'from' => 0,
 'limit' => $config['feed_num_entries']
 ));
 } else {
 plogger_init_pictures(array(
 'type' => 'collection',
 'value' => $id,
 'limit' => $config['feed_num_entries'],
 'sortby' => 'id',
 ));
 }
 $collection = get_collection_by_id($id);
 $config['feed_title'] .= ': '.$collection['name'];

 } else if ($level == 'album') {
 plogger_init_pictures(array(
 'type' => 'album',
 'value' => $id,
 'limit' => $config['feed_num_entries'],
 'sortby' => 'id',
 ));
 $album = get_album_by_id($id);
 $config['feed_title'] .= ': '.$album['album_name'];

 } else if ($level == 'picture') {
 plogger_init_picture(array(
 'id' => $id,
 'comments' => 'DESC'
 ));
 $picture = get_picture_by_id($id);
 $config['feed_title'] .= ': '.basename($picture['path']);

 } else if ($level == 'search') {
 plogger_init_search(array(
 'searchterms' => $search,
 'limit' => $config['feed_num_entries'],
 ));

 } else if (($level == 'collections') or ($level == '')) {
 plogger_init_albums(array(
 'collection_id' => -1,
 'sortby' => 'id',
 'sortdir' => 'DESC',
 'from' => 0,
 'limit' => $config['feed_num_entries']
 ));
 $config['feed_title'] .= ': '.plog_tr('Entire Gallery');
 }

 // generate RSS header
 $rssFeed = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
 $rssFeed.= "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:media=\"http://search.yahoo.com/mrss/\">\n";

 $rssFeed.= "<channel>\n";
 $rssFeed.= "<title>".$config['feed_title']."</title>\n";
 $rssFeed.= "<description>".plog_tr('Plogger RSS Feed')."</description>\n";
 $rssFeed.= "<language>".$GLOBALS['locale']."</language>\n";
 $rssFeed.= "<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
 $rssFeed.= "<generator>Plogger</generator>\n";
 $rssFeed.= "<link>".$config['gallery_url']."</link>\n";
 $rssFeed.= "<atom:link href=\"http://".$_SERVER['HTTP_HOST'].str_replace('&amp;', '&amp;amp;', $_SERVER['REQUEST_URI'])."\" rel=\"self\" type=\"application/rss+xml\" />\n";

 $header = 1;

 while(plogger_has_albums()) {
 plogger_load_album();

 if ($header) {
 $submitdate = date('D, d M Y H:i:s O');

 $rssFeed.= "<pubDate>".$submitdate."</pubDate>\n";
 $rssFeed.= "<lastBuildDate>".$submitdate."</lastBuildDate>\n";
 $header = 0;
 }

 $sql = "SELECT UNIX_TIMESTAMP(`date_modified`) AS `pubdate` FROM `".PLOGGER_TABLE_PREFIX."pictures` WHERE `parent_album` = '".plogger_get_album_id()."' ORDER BY `date_modified` DESC LIMIT 1";
 $result = run_query($sql);
 $row = mysql_fetch_assoc($result);
 $pubdate = date('D, d M Y H:i:s O', $row['pubdate']);

 $title = plogger_get_album_name();
 $num = plogger_album_picture_count();
 $num_pictures = ($num == 1) ? plog_tr('image') : plog_tr('images');
 $pagelink = plogger_get_album_url();
 $thumbpath = str_replace(array('%2F', '%3A'), array('/', ':'), rawurlencode(plogger_get_album_thumb()));
 $descript = '&amp;lt;p&amp;gt;&amp;lt;a href="'.$pagelink.'"
 title="'
.$title.'"&amp;gt;
 &amp;lt;img src="'
.$thumbpath.'" alt="'.$title.'" style="border: 2px solid #000;" /&amp;gt;
 &amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;'
.$title.' ('.$num.' '.$num_pictures.')&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;'.htmlspecialchars(plogger_get_album_description()).'&amp;lt;/p&amp;gt;';

 $rssFeed .= "<item>\n";
 $rssFeed .= "\t<pubDate>".$pubdate."</pubDate>\n";
 $rssFeed .= "\t<title>".$title."</title>\n";
 $rssFeed .= "\t<link>".$pagelink."</link>\n";
 $rssFeed .= "\t<description>".$descript."</description>\n";
 $rssFeed .= "\t<guid isPermaLink=\"false\">".$thumbpath."</guid>\n";
 $rssFeed .= "\t<media:content url=\"".$thumbpath."\" type=\"image/jpeg\" />\n";
 $rssFeed .= "\t<media:title>".$title."</media:title>\n";
 $rssFeed .= "</item>\n";

 }

 while(plogger_has_pictures()) {
 plogger_load_picture();
 // If at picture level, check to make sure it has comments first
 if ($level != 'picture' || plogger_picture_has_comments()) {

 if ($header) {
 $submitdate = plogger_get_picture_date('D, d M Y H:i:s O', 1);
 $takendate = plogger_get_picture_date();

 $rssFeed.= "<pubDate>".$submitdate."</pubDate>\n";
 $rssFeed.= "<lastBuildDate>".$submitdate."</lastBuildDate>\n";
 $header = 0;
 }

 $rssFeed .= "<item>\n";
 if ($config['allow_fullpic']) {
 $urlPath = str_replace(array('%2F', '%3A'), array('/', ':'), rawurlencode(plogger_get_source_picture_url()));
 } else {
 $urlPath = str_replace(array('%2F', '%3A'), array('/', ':'), rawurlencode(plogger_get_picture_thumb(THUMB_LARGE)));
 }

 $caption = plogger_get_picture_caption();
 $thumbpath = plogger_get_picture_thumb(THUMB_RSS);

 $pagelink = plogger_get_picture_url();

 if ($caption == '' || $caption == '&amp;nbsp;') $caption = plog_tr('New Image (no caption)');
 $caption .= ' - '.$takendate;

 $descript = '&amp;lt;p&amp;gt;&amp;lt;a href="'.$pagelink.'"
 title="'
.$caption.'"&amp;gt;
 &amp;lt;img src="'
.$thumbpath.'" alt="'.$caption.'" style="border: 2px solid #000;" /&amp;gt;
 &amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;'
.$caption.'&amp;lt;/p&amp;gt;';

 $descript .= '&amp;lt;p&amp;gt;'.htmlspecialchars(plogger_get_picture_description()).'&amp;lt;/p&amp;gt;';

 $rssFeed .= "\t<pubDate>".$submitdate."</pubDate>\n";
 $rssFeed .= "\t<title>".$caption."</title>\n";
 $rssFeed .= "\t<link>".$pagelink."</link>\n";
 $rssFeed .= "\t<description>".$descript."</description>\n";
 $rssFeed .= "\t<guid isPermaLink=\"false\">".$thumbpath."</guid>\n";
 $rssFeed .= "\t<media:content url=\"".$urlPath."\" type=\"image/jpeg\" />\n";
 $rssFeed .= "\t<media:title>".$caption."</media:title>\n";
 $rssFeed .= "</item>\n";
 if ($level == 'picture') {
 while(plogger_picture_has_comments()) {
 plogger_load_comment();
 $rssFeed .= "<item>\n";
 $rssFeed .= "\t<pubDate>".plogger_get_comment_date('D, d M Y H:i:s O')."</pubDate>\n";
 $rssFeed .= "\t<title>Comment by ".plogger_get_comment_author()."</title>\n";
 $rssFeed .= "\t<link>".$pagelink."</link>\n";
 $rssFeed .= "\t<description>".plogger_get_comment_text()."</description>\n";
 $rssFeed .= "\t<guid isPermaLink=\"true\">".$pagelink."#Comment-".plogger_get_comment_id()."</guid>\n";
 $rssFeed .= "</item>\n";
 }
 }
 }
 }

 $rssFeed .= "</channel>\n</rss>";
 echo $rssFeed;
}

// Send proper header
header('Content-Type: application/xml');

$level = isset($_GET['level']) ? $_GET['level'] : '';
$id = isset($_GET['id']) ? intval($_GET['id']) : '0';

// Process path here - is set if mod_rewrite is in use

// Some Estonian remarks were here
if (!empty($_REQUEST['path'])) {
 // The following line calculates the path in the album and excludes any subdirectories if
 // Plogger is installed in one
 $path = join('/', array_diff(explode('/', $_SERVER['REQUEST_URI']), explode('/', $_SERVER['PHP_SELF'])));
 $resolved_path = resolve_path($path);
 $level = (isset($resolved_path['level'])) ? $resolved_path['level'] : 'collections';
 $id = (isset($resolved_path['id'])) ? $resolved_path['id'] : 0;
}

$parts = parse_url($_SERVER['REQUEST_URI']);

if (isset($parts['query'])) {
 parse_str($parts['query'], $query_parts);
}

if (isset($query_parts['searchterms'])) {
 generate_RSS_feed($level, $id, $query_parts['searchterms']);
} else {
 generate_RSS_feed($level, $id);
}

close_db();

?>

&amp;nbsp;

PHP Script is compatible Time Date

PHP Calendar Basic is a free and easy to use PHP Calendar. You may choose whether to let people post events or add them yourself.The script is compatible with all major web browsers and is very easy to install and use.

 

 

<?php

require_once('common.php');
require_once('myform.php');

$form_output = '';
$filename = 'config.php';
if (!is_writable($filename))
 {
 $form_output = '<p><font color="red">Please change the file permissions to <strong>777</strong> for the following files and/or folders:</font><br /> <strong>config.php</strong></p>';
 }
else
 {
 $form = new myform(); // not a database form

 $form->set('hostname', array(
 'type'     => 'text',
 'label'    => 'Hostname:',
 'value'    => 'localhost',
 'html'     => 'size="60" maxlength="60"',
 'validation' => 'validate_mysql_access',
 'required' => 1,
 'error'    => 'A MySQL hostname is required.',
 ));

 $form->set('database', array(
 'type'     => 'text',
 'label'    => 'Database:',
 'value'    => '',
 'html'     => 'size="20" maxlength="60"',
 'required' => 1,
 'error'    => 'A MySQL database is required.',
 ));

 $form->set('username', array(
 'type'     => 'text',
 'label'    => 'MySQL Username:',
 'value'    => 'root',
 'html'     => 'size="20" maxlength="60"',
 'required' => 1,
 'error'    => 'A MySQL username is required.',
 ));

 $form->set('password', array(
 'type'     => 'text',
 'label'    => 'MySQL Password:',
 'value'    => '',
 'html'     => 'size="20" maxlength="60"',
 'required' => 0,
 'error'    => '',
 ));

 $form->set('affiliate_id', array(
 'type'     => 'text',
 'label'    => 'Calendar.com id:',
 'value'    => '',
 'html'     => 'size="20" maxlength="60"',
 'required' => 1,
 'error'    => 'A calendar.com affiliate ID is required.',
 ));

 $form->set('products_per_page', array(
 'type'     => 'text',
 'label'    => 'Products per page:',
 'value'    => '10',
 'process'  => 'process_products',
 'validation' => 'validate_products',
 'html'     => 'size="10" maxlength="10"',
 'required' => 1,
 'error'    => 'Number of products to display per page is required.',
 ));

 $form->set('datafeed_dir', array(
 'type'     => 'text',
 'label'    => 'Datafeed Directory:',
 'value'    => '../datafeeds',
 'html'     => 'size="30" maxlength="60"',
 'required' => 1,
 'error'    => 'Datafeed directory is required.',
 ));

 $form->set('admin_userid', array(
 'type'     => 'text',
 'label'    => 'Admin Userid:',
 'value'    => 'admin',
 'html'     => 'size="20" maxlength="60"',
 'required' => 1,
 'error'    => 'An admin userid is required.',
 ));

 $form->set('admin_password', array(
 'type'     => 'text',
 'label'    => 'Admin Password:',
 'value'    => '',
 'html'     => 'size="20" maxlength="60"',
 'required' => 1,
 'error'    => 'An admin password is required.',
 ));

 $form->set('default_category', array(
 'type'     => 'text',
 'label'    => 'Default category:',
 'value'    => '0',
 'process'  => 'process_category',
 'validation' => 'validate_category',
 'html'     => 'size="10" maxlength="10"',
 'required' => 1,
 'error'    => 'A default category is required. Use 0 if not sure.',
 ));



 $form_output = $form->process();

 if ($form_output == '1')
 {
 $hostname = custom_post('hostname');
 $database = custom_post('database');
 $username = custom_post('username');
 $password = custom_post('password');
 restore_database($hostname, $database, $username, $password, 'database.sql');
 include ('write_config.php');
 header("location: install_step2.php");
 exit();
 }
 }


// generate page

$tpl = new template();
$tpl->set('form_output',$form_output);
$main_content = $tpl->fetch('templates/install.tpl');

$tpl2 = new template();
$tpl2->set('main_content',$main_content);
echo $tpl2->fetch('templates/install_master.tpl');


function validate_category($value)
 {
 if (!is_numeric($value))
 {
 return ('Category must be numeric.');
 }
 }

function process_category($value)
 {
 return strtolower(trim($value));
 }

function validate_products($value)
 {
 if (!is_numeric($value))
 {
 return ('Number of results to return must be numeric.');
 }
 if ($value < 1 || $value > 100)
 {
 return ('Number of results to return must be between 1 and 100.');
 }

 }

function process_products($value)
 {
 return strtolower(trim($value));
 }

function validate_mysql_access($value)
 {
 $hostname = custom_post('hostname');
 $database = custom_post('database');
 $username = custom_post('username');
 $password = custom_post('password');

 $mydb = @mysql_connect($hostname, $username, $password);
 if (!$mydb)
 {
 return mysql_error();
 }

 $mytest = mysql_select_db($database, $mydb);

 if (!$mytest)
 {
 return mysql_error();
 }

 return;

 }

?>

&amp;nbsp;

PHP calendar class, suitable Time Date

PHP Calendar is a PHP calendar class, suitable for any PHP version. It is very customisable and has the following features: – Month View – Year View – Specify start day of week – Specify start month of year for Year View – Highlight today’s date – Forward and Backward navigation between months and years – Individual days within a month may be optionally linked to another page. – Appearance set by CSS style sheet.

 

 

<?php

require_once('config.php');
require_once('common.php');

$page = custom_get('page',1);
$cat = custom_get('cat',0);

if (!is_numeric($page)) $page = 1;

// get category lists

$query = "SELECT id, name FROM categories WHERE parent_id = '$cat';";
database_inquiry($query, $rows);
$categories = $rows;

if (sizeof($categories) == 0)
 {
 $query = "SELECT id, name FROM categories WHERE id = '$cat';";
 database_inquiry($query, $rows);
 $categories = $rows;
 }

// do some stuff on categories

//-----------------------------------------//
// if cat selected...work backwards (tree) //
//-----------------------------------------//

$nav = '';
if ($cat != 0)
 {
 $cat2 = $cat;
 $delim = '';
 for ($i=1;$i<10;$i++)
 {
 $query = "SELECT id, parent_id, name from categories WHERE id = '$cat2'";
 database_inquiry($query, $rows);
 $idx = $rows[0]['id'];
 $namex = $rows[0]['name'];
 $nav = "<a href=\"product_list.php?cat=$idx\">$namex</a> $delim".$nav;
 $delim = '&amp;gt; ';
 $cat2 = $rows[0]['parent_id'];
 if ($cat2 == 0){break;}
 }
 }

$banner_navigation = $nav;

//----------------------------------------------------//
// if cat selected....figure out all child categories //
//----------------------------------------------------//

$child_cats = '';
if ($cat != 0)
 {
 $child_cats = " category IN ($cat";
 getchildren($cat);
 $child_cats.= ")";
 }

// set database limits

$start = ($page-1)*$cfg['products_per_page'];
$limits = " LIMIT $start,$cfg[products_per_page]";

// create next/prev links

$query = "SELECT count(*) AS count from products WHERE $child_cats;";
database_inquiry($query, $rows);
$product_count = $rows[0]['count'];

$total_pages = $product_count / $cfg['products_per_page'];
if ($total_pages != intval($total_pages)) $total_pages++;
$total_pages = (int) $total_pages;
if ($total_pages < 1) $total_pages = 1;

// create page numbers

$from_page = $page-4;
$to_page = $page+4;
if ($from_page < 1){$from_page = 1;}
if ($to_page > $total_pages){$to_page = $total_pages;}

$page_array = '';
for ($i=$from_page;$i<=$to_page;$i++)
 {
 $page_array .= "<a href=\"product_list.php?page=$i&amp;cat=$cat\">$i </a>";
 }

$next_prev = '';
$prev_page = $page-1;
$next_page = $page+1;
if ($page > 1) $next_prev .= "<a href=\"product_list.php?page=$prev_page&amp;cat=$cat\">&amp;lt;&amp;lt;Prev</a> | "; else $next_prev .= "&amp;lt;&amp;lt;Prev | ";
$next_prev .= $page_array;
if ($page < $total_pages) $next_prev .= "<a href=\"product_list.php?page=$next_page&amp;cat=$cat\">| Next&amp;gt;&amp;gt;</a>"; else $next_prev .= "| Next&amp;gt;&amp;gt;";

// Get product list

$query = "SELECT * from products WHERE $child_cats$limits;";
database_inquiry($query, $rows);
$products = $rows;

// format price and description
$i=0;
foreach ($products as $item)
 {
 $item['price'] = '$'.number_format($item['price'],2,'.',',');
 $products[$i] = $item;
 $i++;
 }

// get category name

$query = "SELECT name from categories WHERE id = '$cat';";
database_inquiry($query, $rows);
$category_name = $rows[0]['name'];


// Generate inner template

$tpl = &amp; new Template();
$tpl->set('products',$products);
$tpl->set('next_prev',$next_prev);
$tpl->set('banner_navigation',$banner_navigation);
$tpl->set('category_name',$category_name);
$main_content = $tpl->fetch('templates/product_list.tpl');

// Generate outer template

$tpl2 = &amp; new Template();
$tpl2->set('main_content',$main_content);
$tpl2->set('categories',$categories);
$x = $tpl2->fetch('templates/master.tpl');

// Generate html page

echo $x;

function getchildren($parent)
{

 global $child_cats;

 $query = "SELECT * from categories where parent_id = '$parent'";
 database_inquiry($query, $rows);

 foreach ($rows as $row)
 {
 $id = $row['id'];
 $child_cats .= ", $row[id]";
 getchildren($id);
 }
}

?>

&amp;nbsp;

Easy PHP Calendar Scripts Time Date

Easy PHP Calendar is a powerful PHP calendar script that is easily integrated into web sites and is simple to customize.This attractive, full-featured calendar is suitable for display on a calendar of events page, home page, or any other page that needs a calendar. With the Easy PHP Calendar, you can easily customize colors, font sizes, table sizes and more by adjusting a single CSS file. It’s simple to take complete control over the PHP calendar’s looks and how it interacts

 

 

<?php

require_once('config.php');
require_once('common.php');

// Get main categories

$query = "SELECT * from categories WHERE parent_id = '$cfg[default_category]';";
database_inquiry($query, $rows);
$categories = $rows;

//----------------------------------------------------//
// if cat selected....figure out all child categories //
//----------------------------------------------------//

$child_cats = '';
if ($cfg['default_category'] != 0)
 {
 $child_cats = "WHERE category IN ($cfg[default_category]";
 getchildren($cfg['default_category']);
 $child_cats.= ")";
 }

// get products

$query = "SELECT * from `products` $child_cats ORDER BY RAND() LIMIT $cfg[products_per_page];";
database_inquiry($query, $rows);
$products = $rows;

// format price
$i=0;
foreach ($products as $item)
 {
 $item['price'] = '$'.number_format($item['price'],2,'.',',');
 $products[$i] = $item;
 $i++;
 }


// Generate inner template

$tpl = &amp; new Template();
$tpl->set('products',$products);
$main_content = $tpl->fetch('templates/index.tpl');

// Generate outer template

$tpl2 = &amp; new Template();
$tpl2->set('categories',$categories);
$tpl2->set('main_content',$main_content);
$x = $tpl2->fetch('templates/master.tpl');

// Generate html page

echo $x;

function getchildren($parent)
{

 global $child_cats;

 $query = "SELECT * from categories where parent_id = '$parent'";
 database_inquiry($query, $rows);

 foreach ($rows as $row)
 {
 $id = $row['id'];
 $child_cats .= ", $row[id]";
 getchildren($id);
 }
}

?>

&amp;nbsp;

 

PHP Calendars script allows Time Date

The PHP Calendars script allows you to instantly create an online store to sell Calendars as a Calendars.com affiliate. The script comes complete with a default template, integrated Google Adsense, and a current copy of the Calendars.com datafeed. You can tailor the store to display all calendars from every category, or display calendars from a particular category or sub-category. Features: – The PHP Calendars script is FREE. However, to keep this script free we ask that when you sign up at Calendars.

 

 

<?php

function get_file_list($directory)
{

$files = array();

$fp = opendir($directory);
while ($filename = readdir($fp))
 {
 if (is_dir("$directory/$filename")) continue;

 if ($filename != "." &amp;&amp; $filename != "..")
 {
 $tmp['filename'] = $filename;
 $tmp['last_modified'] = filemtime("$directory/$filename");
 $tmp['file_size'] = filesize("$directory/$filename");
 $files[] = $tmp;
 }
 }
closedir($fp);

return ($files);

}


function print_z($array)
{

$x = print_r($array, TRUE);
$lines = explode(chr(10),$x);
foreach ($lines as $line)
 {
 echo "$line<br>\n";
 }

}


//--------------------------------------------//
// function custom_get($get_var, $default="") //
//--------------------------------------------//

function custom_get($get_var, $default="")
{

 $value = $default;

 if (!get_magic_quotes_gpc()) {
 if (isset($_GET["$get_var"])) {$value = addslashes($_GET["$get_var"]);}
 } else {
 if (isset($_GET["$get_var"])) {$value = $_GET["$get_var"];}
 }

 return(htmlspecialchars($value));

}


//---------------------------------------------//
// function custom_post($get_var, $default="") //
//---------------------------------------------//

function custom_post($get_var, $default="")
{

 $value = $default;

 if (!get_magic_quotes_gpc()) {
 if (isset($_POST["$get_var"])) {$value = addslashes($_POST["$get_var"]);}
 } else {
 if (isset($_POST["$get_var"])) {$value = $_POST["$get_var"];}
 }

 return($value);

}

class Template {

 var $vars;

 function Template($file = null) {
 $this->file = $file;
 $this->vars['null'] = 'null';
 }

 function set($name, $value) {
 $this->vars[$name] = is_object($value) ? $value->fetch() : $value;
 }

 function fetch($file = null) {
 if(!$file) $file = $this->file;

 extract($this->vars);
 ob_start();
 include($file);
 $contents = ob_get_contents();
 ob_end_clean();
 return $contents;
 }
}

//--------------------------------------------//
// function database_inquiry ($query, &amp;$rows) //
//--------------------------------------------//

function database_inquiry ($query, &amp;$rows)
{
 global $cfg;

 $mydb = @mysql_connect($cfg['hostname'], $cfg['username'], $cfg['password']) or die("Unable to connect to database<br><br>".mysql_error());
 mysql_select_db($cfg['database'], $mydb);
 $result = mysql_query($query) or die ("There is a problem with the database<br><br>".mysql_error().$query);

 $rows = array();

 while($row = mysql_fetch_assoc($result))
 {
 $rows[] = $row;
 }

 return mysql_num_rows($result);
}

//------------------------------------------------//
// function database_update ($query, &amp;$insert_id) //
//------------------------------------------------//

function database_update ($query, &amp;$insert_id)
{
 global $cfg;

 if ($cfg['demo'] == 1) return (array());

 $mydb = @mysql_connect($cfg['hostname'], $cfg['username'], $cfg['password']) or die("Unable to connect to database<br><br>".mysql_error());
 mysql_select_db($cfg['database'], $mydb);
 $result = mysql_query($query) or die ("There is a problem with the database<br><br>".mysql_error().$query);
 $insert_id = mysql_insert_id();
 return mysql_affected_rows();

}

//************************************************************************
//              Backup database function
//************************************************************************

 function backup_database($hostname, $database, $username, $password, $drop_tables=1, $define_tables=1, $include_data=1) {

 define("LNBR","\r\n");
 $query = '';
 $mydb = @mysql_connect($hostname, $username, $password) or die("Unable to connect to database<br><br>".mysql_error());
 $tables = mysql_list_tables($database, $mydb);
 while ($row = mysql_fetch_row($tables)) { $table_list[] = $row[0]; }

 for ($i = 0; $i < count($table_list); $i++) {

 $results = mysql_query('DESCRIBE ' . $table_list[$i]);

 if ($drop_tables) $query .= 'DROP TABLE IF EXISTS ' . $table_list[$i] . ';' . LNBR;

 if($define_tables)
 {
 $query .= LNBR . 'CREATE TABLE ' . $table_list[$i] . ' (' . LNBR;

 $tmp = '';

 while ($row = mysql_fetch_assoc($results))
 {
 $query .= '' . $row['Field'] . ' ' . $row['Type'];
 if ($row['Null'] != 'YES') { $query .= ' NOT NULL'; }
 if ($row['Default'] != '') { $query .= ' DEFAULT \'' . $row['Default'] . '\''; }
 if ($row['Extra']) { $query .= ' ' . strtoupper($row['Extra']); }
 if ($row['Key'] == 'PRI') { $tmp = 'primary key(' . $row['Field'] . ')'; }
 $query .= ','. LNBR;
 }
 $query .= $tmp . LNBR . ');' . str_repeat(LNBR, 2);
 }

 if ($include_data)
 {
 $results = mysql_query('SELECT * FROM ' .$table_list[$i]);

 while ($row = mysql_fetch_assoc($results)) {

 $query .= 'INSERT INTO ' . $table_list[$i] .' (';

 $data = Array();

 while (list($key, $value) = each($row)) { $data['keys'][] = $key; $data['values'][] = addslashes($value); }

 $query .= join($data['keys'], ', ') . ')' . ' VALUES (\'' . join($data['values'], '\', \'') . '\');' . LNBR;

 }

 $query .= str_repeat(LNBR, 2);
 }

 }

 //------------------------------------------------------------------------
 //              Determine filename to create
 //------------------------------------------------------------------------

 $filename = $database.date("-Y-m-d_H-i-s").".sql";


 //------------------------------------------------------------------------
 //              Open dialog box to save file
 //------------------------------------------------------------------------

 header("Content-type: application/octet-stream");
 header("Content-Disposition: attachment; filename=".$filename);
 header("Pragma: no-cache");
 header("Expires: 0");
 echo $query;

 }


//************************************************************************
//              Restore database function
//************************************************************************

function restore_database($hostname, $database, $username, $password, $file_name)
{

 $mydb = @mysql_connect($hostname, $username, $password) or die("Unable to connect to database.<br>".mysql_error());
 mysql_select_db($database, $mydb);

 $ignoreerrors = false;
 $file_content = file($file_name);
 $query = '';
 foreach($file_content as $sql_line) {
 $tsl = trim($sql_line);
 if (($sql_line != "") &amp;&amp; (substr($tsl, 0, 2) != "--") &amp;&amp; (substr($tsl, 0, 1) != "#")) {
 $query .= $sql_line;
 if(preg_match("/;\s*$/", $sql_line)) {
 $query = str_replace(";", "", "$query");
 $result = mysql_query($query);
 if (!$result &amp;&amp; !$ignoreerrors) die($query.'<br>'.mysql_error());
 $query = "";
 }
 }
 }
//    if (!$file_name) exit("No file specified.<br>");
//
//    $mydb = @mysql_connect($hostname, $username, $password) or die("Unable to connect to database.<br>".mysql_error());
//    mysql_select_db($database, $mydb);
//
//    $sql_query = '';
//    $sql_file = file($file_name);
//    foreach( $sql_file as $line )
//       {
//         if ((substr($line, 0, 1) == '#') || (substr($line, 0, 2) == '--')) $line = '';
//         $sql_query .= $line;
//       }
//
//    $sql = explode(';'.chr(13), $sql_query);
//    foreach ($sql as $v)
//       {
//         $v = trim($v);
//       if (empty($v)) continue;
//       mysql_query($v);
//         if (mysql_errno()) die ($v . "<br><br>Error: " . mysql_error());
//       }
}
?>

&amp;nbsp;