PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Mark Kintigh   cDates   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example file
Class: cDates
Display month calendars denoting event dates
Author: By
Last change:
Date: 15 years ago
Size: 2,448 bytes
 

Contents

Class file image Download
<!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>Untitled Document</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="application/x-www-form-urlencoded">
Holiday check: <input name="testdate" maxlength="10" size="10" />&nbsp;<input type="submit" value="test" />
<hr />
Date 1: <input name="date1" maxlength="10" size="10" /><br />
Date 2: <input name="date2" maxlength="10" size="10" /><br />
Difference: <select name="datediff">
    <option value="1">Years</option>
    <option value="2">Months</option>
    <option value="3">Days</option>
    <option value="4">Hours</option>
    <option value="5">Minutes</option>
    <option value="6">Seconds</option>
</select><br />
<input type="submit" value="test" />
<br />
<br />
<?php
   
include_once("cDates.php");
    if(isset(
$_POST['testdate'])) {
        if(
strlen(trim($_POST['testdate']))>0) {
           
$md = new cDates();
            echo
"<hr />\nHoliday (if any):<ul>\n\t<li>"
               
. $md->isHoliday($_POST['testdate'])
                .
"</li>\n</ul>\n";
           
$md->addEvent("1","1","Test");
           
$md->addEvent("1","5","Test 2");
           
$md->addEvent("1","10","Test 3");
           
$md->addEvent("Jan","January %YEAR% second sunday","Test Formula");
           
$md->delEvent("1","10","Test");
           
$md->drawCalendar($_POST['testdate'],true, true);
            echo
"<ul>\n";
            foreach(
$md->my_events[1] as $v) {
                echo
"<li>$v</li>\n";
            }
            echo
"</ul>\n";
        }
    }
    if(isset(
$_POST['date1']) && isset($_POST['date2'])) {
        if(
strlen(trim($_POST['date1']))>0 && strlen(trim($_POST['date2']))>0) {
           
$md2 = new cDates();
            echo
"<hr>Difference between "
               
. date("m/d/Y",$md2->fixDate(trim($_POST['date1'])))
                .
" and "
               
. date("m/d/Y",$md2->fixDate(trim($_POST['date2'])))
                .
" in ";
            switch(
intval($_POST['datediff'])) {
                case
1: echo "years.<br>"; break;
                case
2: echo "months.<br>"; break;
                case
3: echo "days.<br>"; break;
                case
4: echo "hours.<br>"; break;
                case
5: echo "minutes.<br>"; break;
                case
6: echo "seconds.<br>"; break;
            }
            echo
"<ul>\n\t<li>"
               
. $md2->diff(trim($_POST['date1']), trim($_POST['date2']),
                   
intval($_POST['datediff']))
                .
"</li>\n</ul>\n";
        }
    }
?>
</form>
</body>
</html>