cvs: php-master-web / event.sql /entry event.php
| From: | jim winstead | Date: | Mon, 04 Mar 2002 01:25:49 +0000 |
| Subject: | cvs: php-master-web / event.sql /entry event.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-8936@lists.php.net to get a copy of this message | ||
jimw Sun Mar 3 20:25:49 2002 EDT
Added files:
/php-master-web/entry event.php
/php-master-web event.sql
Log:
event submission
Index: php-master-web/entry/event.php
+++ php-master-web/entry/event.php
<?php
#$mailto = 'php-mirrors@lists.php.net';
$mailto = 'jimw@apache.org';
$re = array(
1 => 'First',
2 => 'Second',
3 => 'Third',
4 => 'Fourth',
-1 => 'Last',
-2 => 'Second to Last',
-3 => 'Third to Last'
);
function day($in) {
return strftime('%A',mktime(12,0,0,4,$in,2001));
}
if (empty($sdesc) || empty($email) || empty($country) || empty($category) || empty($type))
die("missing some parameters.");
@mysql_connect("localhost","nobody", "")
or die("failed to connect to database");
@mysql_select_db("php3")
or die("failed to select database");
switch($type) {
case 'single':
if (!checkdate($smonth, $sday, $syear))
die("invalid start date");
$query = "INSERT INTO phpcal SET tipo=1,"
. "sdato='$syear-$smonth-$sday',"
. "sdesc='$sdesc',"
. "url='$url',"
. "email='$email',"
. "ldesc='$ldesc',"
. "country='$country',"
. "category='$category'";
$msg = "Date: $syear-$smonth-$sday\n";
break;
case 'multi':
if (!checkdate($smonth, $sday, $syear))
die("invalid start date");
if (!checkdate($emonth, $eday, $eyear))
die("invalid end date");
$sd = mktime(0,0,0,$smonth,$sday,$syear);
$ed = mktime(0,0,59,$emonth,$eday,$eyear);
if ($sd > $ed)
die("end date is after start date");
if ($smonth == $emonth && $sday == $eday && $syear == $eyear)
die("start and end dates are identical");
$query = "INSERT INTO phpcal SET tipo=2,"
. "sdato='$syear-$smonth-$sday',"
. "edato='$eyear-$emonth-$eday',"
. "sdesc='$sdesc',"
. "url='$url',"
. "email='$email',"
. "ldesc='$ldesc',"
. "country='$country',"
. "category='$category'";
$msg = "Start Date: $syear-$smonth-$sday\n"
. "End Date: $eyear-$emonth-$eday\n";
break;
case 'recur':
if (!is_numeric($recur) || !is_numeric($recur_day))
die("recurring event sequence is invalid");
$query = "INSERT INTO phpcal SET tipo=3,"
. "recur='$recur:$recur_day',"
. "sdesc='$sdesc',"
. "url='$url',"
. "email='$email',"
. "ldesc='$ldesc',"
. "country='$country',"
. "category='$category'";
$msg = "Recurs Every: $re[$recur] ".day($recur_day);
break;
default:
die("invalid type");
}
mysql_query($query) or die("query failed: ".mysql_error()."<br />$query");
$new_id = mysql_insert_id();
$msg .= "Country: ".stripslashes($country)."\n"
. "Category: ".stripslashes($category)."\n"
. ($url ? "URL: ".stripslashes($url)."\n" : "")
. "\n".wordwrap(stripslashes($ldesc),72);
# add signature/actions
$msg .= "\n-- \n"
. "http://master.php.net/manage/event.php?id=$new_id&action=approve\n"
. "http://master.php.net/manage/event.php?id=$new_id&action=reject\n"
. "http://master.php.net/manage/event.php?id=$new_id&action=edit\n";
mail($mailto,"Event #$new_id: ".stripslashes($sdesc),$msg,"From:
".stripslashes($email)."\r\nMessage-ID: <event-$new_id@php.net>");
Index: php-master-web/event.sql
+++ php-master-web/event.sql
#
# Table structure for table 'phpcal'
#
CREATE TABLE phpcal (
id INT(8) NOT NULL AUTO_INCREMENT,
sdato DATE DEFAULT NULL,
edato DATE DEFAULT NULL,
recur VARCHAR(12) DEFAULT NULL,
sdesc VARCHAR(16) NOT NULL DEFAULT '',
url VARCHAR(128) DEFAULT NULL,
email VARCHAR(128) DEFAULT NULL,
ldesc TEXT,
tipo INT(1) NOT NULL DEFAULT '0',
approved INT(1) NOT NULL DEFAULT '0',
app_by VARCHAR(16) DEFAULT NULL,
country CHAR(3) NOT NULL DEFAULT '',
category TINYINT(4) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
KEY sdato (sdato),
KEY edato (edato),
KEY country (country),
KEY category (category)
) TYPE=MyISAM;