phpslash-commit Mailing List for phpSlash (Page 80)
Brought to you by:
joestewart,
nhruby
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(59) |
Dec
(60) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(52) |
Feb
(77) |
Mar
(118) |
Apr
(76) |
May
(106) |
Jun
(145) |
Jul
(9) |
Aug
(15) |
Sep
(78) |
Oct
(83) |
Nov
(105) |
Dec
(51) |
2003 |
Jan
(105) |
Feb
(100) |
Mar
(111) |
Apr
(149) |
May
(95) |
Jun
(56) |
Jul
(8) |
Aug
(2) |
Sep
|
Oct
(22) |
Nov
(117) |
Dec
(6) |
2004 |
Jan
(1) |
Feb
|
Mar
(3) |
Apr
(25) |
May
|
Jun
(11) |
Jul
(26) |
Aug
(85) |
Sep
(119) |
Oct
(312) |
Nov
(271) |
Dec
(5) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(12) |
May
(7) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Joe S. <joe...@us...> - 2002-09-03 15:08:49
|
Update of /cvsroot/phpslash/phpslash-ft/contrib In directory usw-pr-cvs1:/tmp/cvs-serv17261/contrib Added Files: tz_bench.php3 tz_test_localtime.php3 tz_test_mktime.php3 tz_test_strftime.php3 tz_test_strtotime.php3 Log Message: [ 580757 ] Site-wide date formats and TIMEZONES --- NEW FILE: tz_bench.php3 --- <?php require("config.php3"); require("/usr/local/lib/php/Benchmark/Timer.php"); $timer = new Benchmark_Timer; // get code blocks $filename || $filename = 'tz_test_basic.php'; $lines = file($filename); $file = join('',$lines); //echo "file: <pre>", htmlentities($file), "</pre><br>\n"; preg_match_all('/<\?php(.*)\?>/Us',$file,$matches,PREG_SET_ORDER); //echo "matches: <pre>"; //print_r($matches); //echo "</pre>"; // fill in bench array foreach(array(true,false) as $native_flag) { unset($_TZ['obj']); $_TZ['native'] = $native_flag; $native_int = (int) $native_flag; foreach($matches as $i=>$match) { list($string,$code) = $match; if (!$bench[$i]['code']) { ob_start(); highlight_string($string); $bench[$i]['code']=ob_get_contents(); ob_end_clean(); } ob_start(); $marker = $i + 2 * $native_int; $timer->setMarker("Start $marker"); eval($code); $timer->setMarker("End $marker"); $bench[$i][$native_int]['result'] = ob_get_contents(); ob_end_clean(); $bench[$i][$native_int]['time'] = $timer->timeElapsed("Start $marker","End $marker"); } } // output $tpl = new Template($_PSL['templatedir']); // $tpl->debug=true; $tpl->set_file('bench','tz_bench.tpl'); $tpl->set_block('bench','each_code_block','EACH_CODE_BLOCK'); $tpl->set_block('bench','each_link','EACH_LINK'); $tpl->set_var('FILENAME',$filename); $tpl->set_var('PHP_SELF',$PHP_SELF); $float_fmt = "%01.10f"; foreach($bench as $i => $record) { $tpl->set_var(array('CODE'=>$record['code'], 'RESULT_NATIVE'=>$record[1]['result'], 'RESULT_NONNATIVE'=>$record[0]['result'], 'TIME_NATIVE'=>sprintf($float_fmt,$record[1]['time']), 'TIME_NONNATIVE'=>sprintf($float_fmt,$record[0]['time']))); $tpl->parse('EACH_CODE_BLOCK','each_code_block',true); } $_PSL['debug'] = true; $dir = opendir("."); while (false !== ($availablefilename = readdir($dir))) { if (preg_match('/^tz_test_.*\.php/',$availablefilename)) { debug("availablefilename",$availablefilename); $tpl->set_var('AVAILABLE_FILENAME',$availablefilename); $tpl->parse('EACH_LINK','each_link',true); } } $tpl->parse('OUT','bench'); echo $tpl->get('OUT'); ?> --- NEW FILE: tz_test_localtime.php3 --- <?php // set the time zone tz_select('America/Los_Angeles'); echo get_class($_TZ['obj']); ?> <?php // now print_r(tz_localtime(time(),true)); ?> <?php // when do we spring forward? $t = gmmktime(9,59,59,4,7,2002); print_r(tz_localtime($t,true)); print_r(tz_localtime(++$t,true)); ?> <?php // and fall back? $t = gmmktime(8,59,59,10,27,2002); print_r(tz_localtime($t,true)); print_r(tz_localtime(++$t,true)); ?> <?php // set the time zone again, this time with a string tz_select('FST+3FDT,M4.1.0,M10.5.0'); echo get_class($_TZ['obj']); ?> <?php // now print_r(tz_localtime(time())); ?> <?php // when do we spring forward? $t = gmmktime(4,59,59,4,7,2002); print_r(tz_localtime($t,true)); print_r(tz_localtime(++$t,true)); ?> <?php // and fall back? $t = gmmktime(3,59,59,10,27,2002); print_r(tz_localtime($t,true)); print_r(tz_localtime(++$t,true)); ?> --- NEW FILE: tz_test_mktime.php3 --- <?php $fmt = "%A %B %e, %Y, %r %Z\n"; // set the time zone tz_select('America/Los_Angeles'); echo get_class($_TZ['obj']); ?> <?php // Spring Forward in working time zone $t1 = tz_mktime(1,59,59,4,7,2002); echo $t1; ?> <?php // server time: GMT-5 $t2 = mktime(1,59,59,4,7,2002); echo $t2; ?> <?php echo tz_strftime($fmt,$t2); ?> <?php echo strftime($fmt,$t1); ?> --- NEW FILE: tz_test_strftime.php3 --- <?php $fmt = "%A %B %e, %Y, %r %Z\n"; // set the time zone tz_select('America/Los_Angeles'); echo get_class($_TZ['obj']); ?> <?php // now echo tz_strftime($fmt,time()); ?> <?php // when do we spring forward? $t = gmmktime(9,59,59,4,7,2002); echo tz_strftime($fmt,$t); echo tz_strftime($fmt,++$t); ?> <?php // and fall back? $t = gmmktime(8,59,59,10,27,2002); echo tz_strftime($fmt,$t); echo tz_strftime($fmt,++$t); ?> <?php // set the time zone again, this time with a string tz_select('FST+3FDT,M4.1.0,M10.5.0'); echo get_class($_TZ['obj']); ?> <?php // now echo tz_strftime($fmt,time()); ?> <?php // when do we spring forward? $t = gmmktime(4,59,59,4,7,2002); echo tz_strftime($fmt,$t); echo tz_strftime($fmt,++$t); ?> <?php // and fall back? $t = gmmktime(3,59,59,10,27,2002); echo tz_strftime($fmt,$t); echo tz_strftime($fmt,++$t); ?> --- NEW FILE: tz_test_strtotime.php3 --- <?php // set the time zone tz_select('America/Chicago'); echo get_class($_TZ['obj']); $fmt = "%A %B %e, %Y, %r %Z\n"; $date = "7 April 2002 1:59:59am"; ?> <?php $t = tz_strtotime($date); echo $t, "\n"; echo strftime($fmt,$t); ?> <?php echo tz_strftime($fmt, $t); ?> <?php // this should not be adjusted $t2 = tz_strtotime("$date PST"); echo $t2, "\n"; echo tz_strftime($fmt,$t2); ?> <?php echo strftime($fmt,strtotime("12:00pm MDT")); ?> |
From: Joe S. <joe...@us...> - 2002-09-03 15:07:39
|
Update of /cvsroot/phpslash/phpslash-ft/public_html In directory usw-pr-cvs1:/tmp/cvs-serv16651/phpslash-ft/public_html Added Files: tz_select.php3 Log Message: [ 580757 ] Site-wide date formats and TIMEZONES --- NEW FILE: tz_select.php3 --- <?php require("config.php3"); page_open(array('sess' => 'slashSess', 'auth' => 'slashAuth', 'perm' => 'slashPerm')); slashhead("Select Time Zone","Customization"); if ($HTTP_GET_VARS['submit']) { echo $_TZ['obj']->get_confirm_form($HTTP_GET_VARS, $_PSL['rooturl'] .'?TZ=' . $HTTP_GET_VARS['region'], $HTTP_SERVER_VARS['PHP_SELF']); } else { echo $_TZ['obj']->get_select_form(); } slashfoot(); ?> |
From: Joe S. <joe...@us...> - 2002-09-03 15:07:39
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv16651/phpslash-ft/class Added Files: tz_posix.class libtz.inc Log Message: [ 580757 ] Site-wide date formats and TIMEZONES --- NEW FILE: tz_posix.class --- <?php /** * time zone defined by a POSIX-compatible string. * * @link http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_431.html */ class tz_posix extends tz_nonnative { /** * @var array POSIX-compliant offset strings to get to UTC * e.g., +2 means local time is 2 hours behind UTC * 0=>standard timezone abbreviation (e.g. EST) * 1=>daylight savings timezone abbreviation (e.g., EDT) */ var $offset; /** * @var array POSIX-compliant date string for when time changes occur * (e.g., M4.1.0 means first Sunday in April) */ var $switch_date; /** * @var array POSIX-compliant time string for when time changes occur * (e.g. 2:30:45, 2:30, or just 2) */ var $switch_time; /** * @var array year-indexed array of timestamps indicating DST/STD transitions */ var $ats_by_year; /** * constructor * * @param string time zone string */ function tz_posix($name='') { tz::tz($name); } /** * validate time zone * * takes the timezone string and breaks it up into pieces with a fancy regex. * populates $ttis, $offset, $switch_date, and $switch_time. * * @param string time zone string */ function validate() { $name = $this->name; // patterns cribbed from tzselect(8) $tzabbr_pat = "[^-+,0-9][^-+,0-9][^-+,0-9]+"; $time = "[0-2]?[0-9](?::[0-5][0-9](?::[0-5][0-9])?)?"; $offset = "[-+]?$time"; $date = "(?:J?[0-9]+|M[0-9]+\.[0-9]+\.[0-9]+)"; $datetime = ",$date(/$time)?"; $tzpattern="($tzabbr_pat)($offset)(?:($tzabbr_pat)($offset)?(?:,($date)(?:/($time))?)(?:,($date)(?:/($time))?))?"; if (preg_match("%^$tzpattern\$%",$name,$matches)) { //echo "pattern match:"; //print_r($matches); list($this->name, $tzabbr[0], $this->offset[0], $tzabbr[1], $this->offset[1], $this->switch_date[1], // "spring forward" $this->switch_time[1], $this->switch_date[0], // "fall back" $this->switch_time[0]) = $matches; $gmtoff[0] = $this->offset_to_seconds($this->offset[0]); if (!$this->switch_time[0]) $this->switch_time[0] = '2'; $this->ttis = array(); $this->ttis[] = array('gmtoff'=>$gmtoff[0], 'is_dst'=>0, 'tzabbr'=>$tzabbr[0]); if ($tzabbr[1]) { if ($this->offset[1]) $gmtoff[1] = $this->offset_to_seconds($this->offset[1]); else $gmtoff[1] = $gmtoff[0] + SECONDS_PER_HOUR; if (!$this->switch_time[1]) $this->switch_time[1] = '2'; $this->ttis[] = array('gmtoff'=>$gmtoff[1], 'is_dst'=>1, 'tzabbr'=>$tzabbr[1]); } return true; } else { $this->ttis[] = array('gmtoff'=>0, 'is_dst'=>false, 'tzabbr'=>$name); $this->error = "tz_posix::tz_posix: string does not match regexp: $name"; // echo $this->error, "\n"; return false; } } /** * compute the transition timesstamps for a given year * * @param integer year */ function set_ats_by_year($year) { /* have to convert strings like "123", "J234", and "M4.1.0" to a ysec, once we know the year. */ $nye_ts = gmmktime(0,0,0,1,1,$year); $secs_per_day = HOURS_PER_DAY * SECONDS_PER_HOUR; /* find the unix timestamp for the time when the local clock switches to DST */ $dsec = $this->time_to_dsec($this->switch_time[1]); $yday = $this->date_to_yday($this->switch_date[1],$year); /* (gm)?mktime is unreliable around daylight savings time. This might be a bug in PHP which may have been fixed after 4.0.5, but we get around it by using mktime to only get the timestamp of New Year's Eve. Then we add on seconds accordingly. */ $dst_at = $nye_ts + $yday * $secs_per_day + $dsec - $this->ttis[0]['gmtoff']; // echo "dst_at=$dst_at ", gmdate("(r)",$dst_at), "\n"; /* find the unix timestamp for the time when the local clock switches back to regular time. */ $std_at = $nye_ts + $this->date_to_yday($this->switch_date[0],$year) * $secs_per_day + $this->time_to_dsec($this->switch_time[0]) - $this->ttis[1]['gmtoff']; // echo "std_at=$std_at ", gmdate("(r)",$std_at), "\n"; $this->ats_by_year[$year] = array($dst_at,$std_at); } /** * compute the time offset from UTC * * @see tz::get_offset() */ function get_offset($t) { // echo "begin: get_offset($t)\n"; if (count($this->ttis) > 1) { $year = gmdate('Y',$t); if (!is_array($this->ats_by_year[$year])) { $this->set_ats_by_year($year); } $ats = $this->ats_by_year[$year]; $i = (($t >= $ats[0]) && ($t < $ats[1]) ? 1 : 0); } else { $i = 0; } return $this->ttis[$i]; } /** * convert a POSIX offset string to seconds * * find hours, minutes, and seconds, and converts that all to * seconds. result is the differential between UTC and local time, * so negated from the standard. * * @param string * @return integer */ function offset_to_seconds($offset_str) { if (preg_match('%^(-|\+)?([0-2]?[0-9])(?::([0-5][0-9])?(?::([0-5][0-9])?)?)?$%',$offset_str,$matches)) { list($match,$plusminus,$hours,$minutes,$seconds) = $matches; $seconds = $hours * SECONDS_PER_HOUR + ($minutes ? $minutes : 0) * SECONDS_PER_MINUTE + ($seconds ? $seconds : 0); // POSIX gives the offset as utc - local, but we want the opposite if ('-' != $plusminus) $seconds = -$seconds; return $seconds; } else { echo "doesn't match\n"; } } /** * convert a POSIX date string to number of days elapsed since New Year's. * * @param string date string (e.g. M10.5.0) * @param integer in what year * @return integer days */ function date_to_yday($date_str,$year) { // echo "begin: date_to_yday($date_str,$year)\n"; if (preg_match('/^[0-9]+$/',$date_str,$matches)) { $days = $date_str; } elseif (preg_match('/^J([0-9]+)/',$date_str,$matches)) { // Julian days, without regard to leap year $days = $matches[1] + (is_year_year($year) ? 1 : 0 ); } elseif (preg_match('/^M([0-1]?[0-9]).([1-5]).([0-6])$/',$date_str,$matches)) { // M4.1.0 or M10.5.0 etc list($date_str,$month,$num,$dow) = $matches; // print_r(compact('month','dow','num')); if ($num < 0) { // makes no sense return false; } if ($num < 5) { $firstday = mktime(12,0,0,$month,1,$year); $firstdow = strftime('%w',$firstday); $moredays = $this->int_remainder($dow - $firstdow,DAYS_PER_WEEK); //echo "moredays=$moredays\n"; $mday = 1 + $moredays + DAYS_PER_WEEK * ($num - 1); //echo "firstday=$firstday\n"; //echo "firstdow=$firstdow\n"; //echo "mday=$mday\n"; } else { $lastday = mktime(0,0,0,$month+1,0,$year); list($lastdow,$lastdaynum) = split(' ',date('w j',$lastday)); $mday = $lastdaynum - (($lastdow - $dow) % DAYS_PER_WEEK); } $days = date('z',mktime(0,0,0,$month,$mday,$year)); } else { echo "date_to_yday::don't understand date: $date_str\n"; } if ($days) return $days; else return false; } /** * determine whether $y is a leap year. * * Only works reliably since standardization of leap years (which * was when??). Count on it at least back to the earliest possible * date representable as a unix timestamp. * * @param integer year in question * @return boolean if it's a leap year. */ function is_leap_year($y) { return (((($y) % 4) == 0 && (($y) % 100) != 0) || (($y) % 400) == 0); } /** * calculate the positive remainder of a modulo b. * * Given integers a and b with b > 0, a % b should return the * integer r >= 0 such that a = bq + r. But some tests have given * the wrong answer for this (discovered it when -1 % 7 returned * -1). * * @access private * @param integer dividend * @param integer divisor * @return integer remainder */ function int_remainder($a,$b) { if (is_int($a) && is_int($b)) { if ($b < 0) { $b = -$b; } $ans = $a % $b; return ($ans < 0 ? $ans + $b : $ans); } else { return false; } } /** * convert a time string to the number of seconds elapsed since midnight * * @param string POSIX-compliant time string * @retrn integer seconds */ function time_to_dsec($time_str) { if (empty($time_str)) $time_str = '02:00:00'; return $this->offset_to_seconds('-' . $time_str); } /** * @see tz::get_select_form() */ function get_select_form($action_url='',$method='GET') { $tpl = new Template($this->templatedir); $action_url || $action_url = $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']; $tpl->set_file('current_time','tz_show.tpl'); $tpl->set_file('form','tz_form_posix.tpl'); $tpl->set_block('form','each_zone','EACH_ZONE'); $tpl->set_var(array('ACTION_URL'=>$action_url, 'METHOD'=>'GET')); $tpl->set_var(array('ZONE_MESSAGE'=>'The current zone is', 'TIME_MESSAGE'=>'The current time is', 'ZONE_NAME'=>$this->name, 'LOCAL_TIME'=>$this->strftime($this->show_format,time()))); $tpl->parse('CURRENT_TIME','current_time'); $choices = array('GMT+0'=>'Greenwich Mean (Universal) Time', 'GMT+0BST,M4.1.0/1,M10.5.0/2'=>"Greenwich with British Summer Time", 'WAT+1'=>'West Africa Time', 'AT+2'=>'Azores', 'NST+3:30NDT,M4.1.0,M10.5.0'=>'Newfoundland Time', 'AST+4ADT,M4.1.0,M10.5.0'=>'Atlantic Time', 'EST+5'=>'Eastern Standard Time', 'EST+5EDT,M4.1.0,M10.5.0'=>'Eastern Time with Daylight Savings Time', 'CST+6CDT,M4.1.0,M10.5.0'=>'Central Time', 'MST+7'=>'Mountain Standard Time', 'MST+7MDT,M4.1.0,M10.5.0'=>'Mountain Time with Daylight Savings Time', 'PST+8PDT,M4.1.0,M10.5.0'=>'Pacific Time', 'YST+9YDT,M4.1.0,M10.5.0'=>'Yukon Time', 'HAST+10'=>'Alaska/Hawaii Standard Time', 'HAST+10HDT,M4.1.0,M10.5.0'=>'Hawaii Time with DST', 'IDLW+12'=>'International Date Line West', 'CET-1CEST,M3.5.0,M10.5.0'=>'Central European Time', 'EET-2EEST,M3.5.0,M10.5.0'=>'Eastern European Time', 'AST-3ADT,J91/3,J273/3'=>'Baghdad Time', 'GET-4GEST,M3.5.0,M10.5.0'=>'Georgia Time', 'KGT-5KGST,M4,2,0,M10.5.0'=>'Kyrgyztan Time', 'IST-5:30'=>'India Time', 'BDT-6'=>'Bangladesh Time', 'ICT-7'=>'Indochina Time', 'WST-8'=>'Western Australia Time', 'JST-9'=>'Japan Standard Time', 'EST-10'=>'Eastern Australian Time', 'IDLE-12'=>'International Date Line East', 'NZST-12NZDT,M10.1.0,M3.3.0'=>'New Zealand Time'); foreach($choices as $value=>$name) { $tpl->set_var(array('ZONE_NAME'=>$name, 'ZONE_VALUE'=>$value)); $tpl->parse('EACH_ZONE','each_zone',true); } $tpl->parse('FORM','form'); return $tpl->get('FORM'); } } ?> --- NEW FILE: libtz.inc --- <?php /** * functions for working with the tz classes * * $Id: libtz.inc,v 1.1 2002/09/03 15:07:36 joestewart Exp $ */ /** * select the working time zone * * sets $_TZ['name'] and $_TZ['obj']. * * @param string name of the time zone * @return boolean success (whether the time zone name made sense) */ function tz_select($tz_name) { GLOBAL $_TZ; $tz =& $_TZ['obj']; if (is_object($tz) && $tz->name == $tz_name) { // do nothing; we've already selected the right one return true; } elseif ($_TZ['native']) { $tz = new tz_env($tz_name); return $tz->valid; } else { /* we have non-native time zone objects selected. We need to * figure out which object to use based on the name. * Luckily each object constructor (though it can't return a * value) sets the "valid" member to indicate if the * construction succeeded in something useful. */ /* First try a file. */ $tz = new tz_file($tz_name); if ($tz->valid) { return true; } else { /* OK, maybe a string */ $tz = new tz_posix($tz_name); if ($tz->valid) return true; else { /* We're stumped! We use the dumbest object*/ $tz = new tz($tz_name); $tz->error = "Can't understand time zone name: $tz_name"; return false; } } } } /** * generic time zone object wrapper * * @access private */ function tz_generic() { $fn = "tz_generic"; // echo "$fn: begin\n"; GLOBAL $_TZ; $argv = func_get_args(); $method = array_shift($argv); //echo "method: $method\n"; //echo "object class: ", get_class($_TZ['obj']), "\n"; return call_user_func_array(array(&$_TZ['obj'],$method),$argv); } /** * get the local time, with timezone adjustment * * uses the $_TZ['obj'] object * * @link http://www.php.net/localtime * @see tz::localtime * @param integer timestamp (defaults to current time) * @param boolean whether to return as associative array * @global mixed TZ environment * @return array simple or (if $is_assoc==true) associative array * like the C tm structure */ function tz_localtime($t=false,$is_assoc=0) { return tz_generic('localtime',$t,$is_assoc); } /** * Get UNIX timestamp for a date * * uses the $_TZ['obj'] object * * @link http://www.php.net/mktime * @see tz::mktime * @param integer hour * @param integer minute * @param integer second * @param integer month * @param integer day * @param integer year * @param integer is_dst * @param string time zone name (effectively defaults to $TZ) * @return integer timestamp * */ function tz_mktime($hour=false,$minute=false,$second=false, $month=false,$day=false,$year=false,$is_dst=-1,$tz_str='') { return tz_generic('mktime',$hour,$minute,$second,$month,$day,$year,$is_dst); } /** * format time, with time zone adjustment * * uses the $_TZ['obj'] object * * @link http://www.php.net/strftime * @see tz::strftime * @param string format * @param integer timestamp (defaults to current time) * @return string */ function tz_strftime($fmt,$t=false) { return tz_generic('strftime',$fmt,$t); } /** * convert human-readable date/time string to timestamp, minding time zone. * * uses the $_TZ['obj'] object. * * @see tz::strtotime * @param string date/time string * @return integer timestamp */ function tz_strtotime($str) { return tz_generic('strtotime',$str); } /** * @global mixed $_TZ */ $_TZ['default'] = ':/etc/localtime'; // $_TZ['name'] = 'America/Chicago'; $_TZ['dir'] = '/usr/share/zoneinfo'; // $_TZ['native'] = false; ?> |
From: Joe S. <joe...@us...> - 2002-09-03 15:06:10
|
Update of /cvsroot/phpslash/phpslash-ft/public_html In directory usw-pr-cvs1:/tmp/cvs-serv16180/phpslash-ft/public_html Modified Files: comment.php3 Log Message: [ 580757 ] Site-wide date formats and TIMEZONES Index: comment.php3 =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/public_html/comment.php3,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** comment.php3 31 Aug 2002 14:10:55 -0000 1.15 --- comment.php3 3 Sep 2002 15:06:08 -0000 1.16 *************** *** 122,125 **** --- 122,126 ---- email => $email, time => date("l, F d @h:iA", time()), + timestamp => time(), action_url => $PHP_SELF ); |
From: Joe S. <joe...@us...> - 2002-09-03 15:06:10
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv16180/phpslash-ft/class Modified Files: functions.inc Added Files: tz.class tz_env.class tz_file.class tz_functions.inc tz_nonnative.class Log Message: [ 580757 ] Site-wide date formats and TIMEZONES --- NEW FILE: tz.class --- <?php /** * Time Zone classes */ /** * some constants */ define("SECONDS_PER_HOUR",3600); define("SECONDS_PER_MINUTE",60); define("HOURS_PER_DAY",24); define("DAYS_PER_WEEK",7); /** * base time zone class * */ class tz { /** * @var string name of the time zone */ var $name; /** * @var string default time zone name */ var $default; /** * @var string directory where time zone database is kept (if necessary) * */ var $tzdir = '/usr/share/zoneinfo/'; /** * @var boolean whether constructor succeeded */ var $valid; /** * @var string error message */ var $error; /** * @var string format to display time for diagnostic */ var $show_format; /** * constructor * * @param string name * @global time zone init array */ function tz($name='') { if (is_array($name)) { $ary = $name; } else { $ary = $GLOBALS['_TZ']; $name || $name = $ary['name']; $ary['name'] = $name; } $this->set_member($ary); $this->valid = $this->validate(); } /** * mutator * * If $key is an an associative array, the values will be copied as * members into the object. Otherwise, a single member is set. * * @param string member name * @param string member value */ function set_member($key,$val='') { if (is_array($key)) $members = $key; else $members[$key] = $val; foreach($members as $key => $value) { $this->$key = $value; } } /** * select time zone * * In different classes there may be checking for this. * * @param string time zone * @return boolean success */ function select($name) { if ($this->name == $name) return true; else { $this->name = $name; return $this->validate(); } } /** * validate time zone * */ function validate() { return $this->check_dir(); } /** * set the root timezone directory * * @param string directory name * @return boolean success (if the directory exists and is readable) */ function check_dir($dir='') { $fn = "tz::check_dir"; if (!$dir) { $dir = $this->dir; } if (empty($dir)) { $this->error = "$fn: no default directory: $dir"; return false; } elseif(!is_dir($dir)) { $this->error = "$fn: not a directory: $dir"; return false; } elseif(!is_readable($dir)) { $this->error = "$fn: directory not readable: $dir"; } else { // success! $this->dir = $dir; return true; } } /** * get the local time, with timezone adjustment * * computes localtime and adjusts via tz_offset() * * @link http://www.php.net/localtime * @param integer timestamp (defaults to current time) * @param boolean whether to return as associative array * @return array simple or (if $is_assoc==true) associative array * like the C tm structure */ function localtime($t=false,$is_assoc=0) { return localtime($t,$is_assoc); } /** * format time, with time zone adjustment * * @link http://www.php.net/strftime * @param string format * @param integer timestamp (defaults to current time) * @return string */ function strftime($fmt,$t=false) { return strftime($fmt,$t); } /** * Get UNIX timestamp for a date * * Works just like {@link http://www.php.net/mktime mktime} except it * minds the time zone. * * Not sure how well this works with is_dst set * * @param integer hour * @param integer minute * @param integer second * @param integer month * @param integer day * @param integer year * @param integer is_dst * @param string time zone name (effectively defaults to $TZ) * @return integer timestamp * */ function mktime($hour=false,$minute=false,$second=false, $month=false,$day=false,$year=false,$is_dst=-1) { return mktime($hour,$minute,$second,$month,$day,$year,$is_dst); } /** * convert human-readable date/time string to timestamp, minding time zone. * * Should work just like {@link http://www.php.net/strtotime}, except * correcting based on the time zone. I'm not at all confident this works! * * @link http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html * @param string date/time string * @return integer timestamp */ function strtotime($time_str) { return strtotime($time_str); } /** * get a time-zone selection form * * JavaScript makes this form fun! * * @link http://linuxcommand.org/man_pages/tzselect8.html * @param string directory to find templates (defaults to current directory) * @param string URL to direct the form to (defaults to $PHP_SELF) * @param string form method * @return string HTML/JavaScript for form * */ function get_select_form($action_url='',$method='GET') { $action_url || $action_url = $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']; $tpl = new Template($this->templatedir); // $tpl->debug=true; $tpl->set_file('form','tz_form_native.tpl'); $tpl->set_file('current_time','tz_show.tpl'); $tpl->set_block('form','each_continent_array','EACH_CONTINENT_ARRAY'); $tpl->set_block('each_continent_array','each_country_array','EACH_COUNTRY_ARRAY'); $tpl->set_block('each_country_array','each_region_array','EACH_REGION_ARRAY'); $tpl->set_block('form','each_continent_option','EACH_CONTINENT_OPTION'); $tpl->set_block('form','each_country_option','EACH_COUNTRY_OPTION'); $tpl->set_block('form','each_region_option','EACH_REGION_OPTION'); $tpl->debug=false; $tz_file_lines = file($this->tzdir . '/zone.tab'); $country_file_lines = file($this->tzdir . '/iso3166.tab'); $continents = array('Africa'=>array(), 'America'=>array('name'=>'Americas'), 'Antarctica'=>array(), 'Arctic'=>array('name'=>'Arctic Ocean'), 'Asia'=>array(), 'Atlantic'=>array('name'=>'Atlantic Ocean'), 'Australia'=>array(), 'Europe'=>array(), 'Indian'=>array('name'=>'Indian Ocean'), 'Pacific'=>array('name'=>'Pacific Ocean')); /* process the country code table file */ foreach($country_file_lines as $line) { $line = trim($line); if (preg_match('/^#/',$line)) continue; list($cc,$name) = explode("\t",$line); $countries[$cc]['name'] = $name; } /* process the time zone table file */ foreach($tz_file_lines as $line) { $line = trim($line); if (preg_match('/^#/',$line)) continue; list($cc,$coords,$zone,$description) = explode("\t",$line); list($continent,$region) = explode("/",$zone,2); $continents[$continent]['countries'][$cc] = $countries[$cc]['name']; $region_name = ($description ? $description : $region); $countries[$cc]['regions'][$zone] = $region_name; $regions[$zone]['name'] = $region; $regions[$zone]['description'] = $description; } /* Now we're ready to begin building the form */ $tpl->set_var(array('ZONE_MESSAGE'=>'The current zone is', 'TIME_MESSAGE'=>'The current time is', 'ZONE_NAME'=>$this->name, 'LOCAL_TIME'=>$this->strftime($this->show_format,time()))); $tpl->parse('CURRENT_TIME','current_time'); $tpl->set_var(array('ACTION_URL'=>$action_url, 'METHOD'=>$method)); $i=0; foreach($continents as $cont_key => $continent) { $continent['name'] || $continent['name'] = $cont_key; $tpl->set_var('CONTINENT_INDEX',$i); asort($continent['countries']); $tpl->set_var('CONTINENT_KEY',$cont_key); $tpl->set_var(array('CONTINENT_NAME'=>$continent['name'], 'CONTINENT_VALUE'=>$cont_key)); $j=0; $tpl->set_var('EACH_COUNTRY_ARRAY',''); foreach($continent['countries'] as $cc => $num) { $country = $countries[$cc]; $tpl->set_var('COUNTRY_INDEX',$j++); $tpl->set_var('COUNTRY_CODE',$cc); $tpl->set_var('COUNTRY_NAME',$country['name']); asort($country['regions']); $k=0; $tpl->set_var('EACH_REGION_ARRAY',''); foreach($country['regions'] as $zone=>$region) { $tpl->set_var('REGION_INDEX',$k++); $tpl->set_var('REGION_NAME',str_replace('_',' ',$region)); $tpl->set_var('ZONE_NAME',$zone); $tpl->parse('EACH_REGION_ARRAY','each_region_array',true); } $tpl->parse('EACH_COUNTRY_ARRAY','each_country_array',true); // $tpl->parse('EACH_COUNTRY_OPTION','each_country_option',true); } $i++; $tpl->parse('EACH_CONTINENT_ARRAY','each_continent_array',true); } $tpl->debug=false; /* Now in case JavaScript is not available, we put all the regions into the * region array. */ ksort($regions); foreach($regions as $zone => $region) { $region_name = $zone; if ($region['description']) $region_name .= " [" . $region['description'] . "]"; $region_name = htmlentities($region_name); $tpl->set_var(array('ZONE_NAME'=>$zone, 'REGION_NAME'=>$region_name)); $tpl->parse('EACH_REGION_OPTION','each_region_option',true); } $tpl->parse('OUT','form'); return $tpl->get('OUT'); } /** * get the confirm form or message * * @param array form values * @param string template directory * @param string URL to return to */ function get_confirm_form($ary,$accept_url="",$reject_url='') { $reject_url || $reject_url = $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']; $tpl = new Template($this->templatedir); $tpl->set_file('form','tz_form_confirm.tpl'); $tpl->set_file('current_time','tz_show.tpl'); $old_name = $this->name; if (!$this->select($ary['region'])) { error($this->error); return false; } $tpl->set_var(array('ZONE_MESSAGE'=>'You have selected the zone', 'TIME_MESSAGE'=>'The current time is', 'ZONE_NAME'=>$this->name, 'LOCAL_TIME'=>$this->strftime($this->show_format,time()))); $tpl->parse('CURRENT_TIME','current_time'); $tpl->set_var(array('ZONE_NAME'=>$this->name, 'ACCEPT_URL'=>$accept_url, 'REJECT_URL'=>$reject_url, 'LOCAL_TIME'=>$local_time, 'UTC_TIME'=>$utc_time)); $tpl->parse('OUT','form'); return $tpl->get('OUT'); } } ?> --- NEW FILE: tz_env.class --- <?php /** * Time Zone classes */ /** * time zone class implemented by environment variables. * */ class tz_env extends tz{ /** * set the time zone environment variable * * @return boolean success */ function set_env($tzname='') { if (!$tzname) $tzname = $this->name; if (!$tzname) $tzname = $this->default; if (@putenv("TZ=$tzname")) return true; else { $this->error = "tz_env::set_env: putenv failed.\n"; return false; } } /** * unset the time zone environment variable * * There is no unsetenv function in PHP. * This is why we need the default member. * * @return boolean success */ function unset_env() { return $this->set_env($this->default); } /** * basic method * * set defaults, set the environment variable, call a regular function, * unset environment variable, exit. * * number of parameters varies, but the FIRST is always the function * which will be called, and the LAST is an optional argument * setting a time zone name different than the one in $_TZ['name'] * or $tz::name. */ function generic() { $argv = func_get_args(); $func = array_shift($argv); $this->set_env(); /* an ideal function to use at this point would be call_user_func_array. But I'm pretty sure that doesn't work on functions which are not user-defined. Soo...we work around that. This only handles argument lists of atomic type. */ foreach($argv as $arg) { if (is_bool($arg)) { $new_arg = ($arg ? 'TRUE' : 'FALSE'); } elseif(is_int($arg)) { $new_arg = $arg; } else { $new_arg = "'$arg'"; } $new_argv[] = $new_arg; } $code=sprintf('$ans=%s(%s);',$func,join(',',$new_argv)); // debug('code',$code); eval($code); $this->unset_env(); return $ans; } /** * @see tz::localtime */ function localtime($t=false,$is_assoc=false) { return $this->generic('localtime',$t,$is_assoc); } /** * @see tz::strftime */ function strftime($fmt,$t=false) { return $this->generic('strftime',$fmt,$t); } /** * @see tz::mktime */ function mktime($hour=false,$minute=false,$second=false, $month=false,$day=false,$year=false,$is_dst=-1) { return $this->generic('mktime',$hour,$minute,$second,$month,$day,$year, $is_dst); } /** * @see tz:strtotime */ function strtotime($time_str) { return $this->generic('strtotime',$time_str); } } ?> --- NEW FILE: tz_file.class --- <?php /** * timezone class interfacing the public-domain time zone database * * see tzfile(5) for full description of the time zone information files * * @see tz * @link http://www.twinsun.com/tz/tz-link.htm */ class tz_file extends tz_nonnative { /** * @var string name */ var $name; /** * @var string full path of time zone file * @access private */ var $filename; /** * @var integer number of leap second records in the zone * @access private */ var $leapcnt; /** * @var integer number of time transitions * @access private */ var $timecnt; /** * @var integer number of time "types" (standard, daylight, ...) * @access private */ var $typecnt; /** * @var integer number of total chars in zone abbrevs * @access private */ var $charcnt; /** * @var array timestamps at which a transition of local time is made */ var $ats; /** * @var array time types to be followed at each transition */ var $types; /** * @var mixed array of ttinfo "structures" (implemented in PHP as associative arrays) */ var $ttis; /** * @var array characters from which the time zone abbreviations are read */ var $chars; /** * @var array leap second records */ var $lsis; /** * @var array which of the time transition points are standard (local) time */ var $ttisstd; /** * @var array which of the time transtition points are universal (greenwich) time */ var $ttisgmt; function validate() { if (!$this->check_dir()) return false; $filename = $this->dir . '/' . $this->name; if (!file_exists($filename)) { $this->error = "$fn: no such file: $filename"; return false; } elseif (!is_readable($filename)) { $this->error = "$fn: file not readable: $filename"; return false; } else { $this->filename = $filename; return $this->load_data(); } } /** * loads TZif file into class members * * @return boolean success */ function load_data() { // echo "tz_file::load_data()\n"; $TZFILE = fopen($this->filename,'rb'); /* The time zone information files used by tzset(3) begin with the magic characters "TZif" to identify then as time zone information files, ... */ $magic = fread($TZFILE,4); if ('TZif' != $magic) { $this->error = "tz_file::load_data: bad file type: $this->filename"; return false; } /* ...followed by sixteen bytes reserved for future use,... */ fread($TZFILE,16); /* ...followed by six four-byte values of type long, written in a ``standard'' byte order (the high-order byte of the value is written first). These values are, in order: tzh_ttisgmtcnt The number of UTC/local indicators stored in the file. tzh_ttisstdcnt The number of standard/wall indicators stored in the file. tzh_leapcnt The number of leap seconds for which data is stored in the file. tzh_timecnt The number of "transition times" for which data is stored in the file. tzh_typecnt The number of "local time types" for which data is stored in the file (must not be zero). tzh_charcnt The number of characters of "time zone abbreviation strings" stored in the file. */ $tzh = unpack('Ntzh_ttisgmtcnt/Ntzh_ttisstdcnt/' .'Ntzh_leapcnt/Ntzh_timecnt/' .'Ntzh_typecnt/Ntzh_charcnt', fread($TZFILE,24)); $this->ttisstdcnt = $tzh['tzh_ttisstdcnt']; $this->ttisgmtcnt = $tzh['tzh_ttisgmtcnt']; $this->leapcnt = $tzh['tzh_leapcnt']; $this->timecnt = $tzh['tzh_timecnt']; $this->typecnt = $tzh['tzh_typecnt']; $this->charcnt = $tzh['tzh_charcnt']; /* The above header is followed by tzh_timecnt four-byte val ues of type long, sorted in ascending order. These values are written in ``standard'' byte order. Each is used as a transition time (as returned by time(2)) at which the rules for computing local time change. */ for($i = 0; $i < $this->timecnt; $i++) { extract(unpack('Ntime',fread($TZFILE,4))); $this->ats[$i] = $time; } /* Next come tzh_timecnt one-byte values of type unsigned char; each one tells which of the different types of ``local time'' types described in the file is associated with the same- indexed transition time. */ for($i = 0; $i < $this->timecnt; $i++) { extract(unpack('ctype',fread($TZFILE,1))); $this->types[$i] = $type; } /* These values serve as indices into an array of ttinfo structures that appears next in the file; these structures are defined as follows: struct ttinfo { long tt_gmtoff; int tt_isdst; unsigned int tt_abbrind; }; Each structure is written as a four-byte value for tt_gmtoff of type long, in a standard byte order, followed by a one-byte value for tt_isdst and a one-byte value for tt_abbrind. In each structure, tt_gmtoff gives the number of seconds to be added to UTC, tt_isdst tells whether tm_isdst should be set by localtime (3) ... */ for ($i = 0; $i < $this->typecnt; $i++) { $ttdata = fread($TZFILE,6); $ttinfo = unpack('Ngmtoff/cis_dst/ctt_abbrind',$ttdata); $this->ttis[$i] = $ttinfo; } /* ... and tt_abbrind serves as an index into the array of time zone abbreviation characters that follow the ttinfo structure(s) in the file. */ for ($i = 0; $i < $this->charcnt; $i++) { extract(unpack('cchar',fread($TZFILE,1))); $this->chars[$i] = $char; } /* Then there are tzh_leapcnt pairs of four-byte values, written in standard byte order; the first value of each pair gives the time (as returned by time(2)) at which a leap second occurs; the second gives the total number of leap seconds to be applied after the given time. The pairs of values are sorted in ascending order by time. */ for ($i = 0; $i < $this->leapcnt; $i++) { $leapinfo = unpack('Nls_trans/Nls_corr',fread($TZFILE,8)); $this->lsis[$i] = $leapinfo; } /* Then there are tzh_ttisstdcnt standard/wall indicators, each stored as a one-byte value; they tell whether the transition times associated with local time types were specified as standard time or wall clock time, and are used when a time zone file is used in handling POSIX-style time zone environment variables. */ for ($i = 0; $i < $this->ttisstdcnt; $i++) { extract(unpack('cstd',fread($TZFILE,1))); $this->ttisstd[$i] = $std; } /* Finally there are tzh_ttisgmtcnt UTC/local indicators, each stored as a one-byte value; they tell whether the transition times associated with local time types were specified as UTC or local time, and are used when a time zone file is used in handling POSIX-style time zone envi ronment variables. */ for ($i = 0; $i < $this->ttisgmtcnt; $i++) { extract(unpack('cgmt',fread($TZFILE,1))); $this->ttisgmt[$i] = $gmt; } fclose($TZFILE); return true; } /** * convert the tt_abbrind and chars information into a tzabbr string * * @access private * @param integer index for ttis array */ function set_tzabbr($i) { $tti =& $this->ttis[$i]; $j = $tti['tt_abbrind']; $tti['tzabbr'] = ''; while($c = $this->chars[$j++]) $tti['tzabbr'] .= chr($c); return $tti['tzabbr']; } /** * compute offset from UTC at timestamp $t * * This code ported from the localtime source. It seems like it * could be optimized. * * @see tz::get_offset() * @param integer timestamp * @return integer offset */ function get_offset($t) { // echo "begin: get_offset($t)\n"; // echo "this->timecnt=$this->timecnt\n"; if ($this->timecnt == 0 || $t < $this->ats[0]) { $i = 0; while ($this->ttis[$i]['isdst']) if (++$i >= $this->typecnt) { $i = 0; break; } } else { for ($i = 1; $i < $this->timecnt; ++$i) if ($t < $this->ats[$i]) break; $i = $this->types[$i - 1]; } /* Find the abbreviation name */ if (!$this->ttis[$i]['tzabbr']) $this->set_tzabbr($i); $tti = $this->ttis[$i]; /* find the leap seconds. I'm actually not sure if this works. */ $i = $this->leapcnt; while (--$i >= 0) { $l = $this->lsis[$i]; if ($t >= $l['ls_trans']) { if ($t == $l['ls_trans']) { $hit = (($i == 0 && $l['ls_corr'] > 0) || $l['ls_corr'] > $this->lsis[$i - 1]['ls_corr']); if ($hit) while ($i > 0 && $this->lsis[$i]['ls_trans'] == $this->lsis[$i - 1]['ls_trans'] + 1 && $this->lsis[$i]['ls_corr'] == $this->lsis[$i - 1]['ls_corr'] + 1) { ++$hit; --$i; } } $corr = $l['ls_corr']; break; } } if (is_int($corr)) $tti['gmtoff'] -= $corr; return $tti; } } ?> --- NEW FILE: tz_functions.inc --- <?php /** * functions for working with the tz classes * * $Id: tz_functions.inc,v 1.1 2002/09/03 15:06:08 joestewart Exp $ */ /** * select the working time zone * * sets $_TZ['name'] and $_TZ['obj']. * * @param string name of the time zone * @return boolean success (whether the time zone name made sense) */ function tz_select($tz_name) { GLOBAL $_TZ; $tz =& $_TZ['obj']; if (is_object($tz) && $tz->name == $tz_name) { // do nothing; we've already selected the right one return true; } elseif ($_TZ['native']) { $tz = new tz_env($tz_name); return $tz->valid; } else { /* we have non-native time zone objects selected. We need to * figure out which object to use based on the name. * Luckily each object constructor (though it can't return a * value) sets the "valid" member to indicate if the * construction succeeded in something useful. */ /* First try a file. */ $tz = new tz_file($tz_name); if ($tz->valid) { return true; } else { /* OK, maybe a string */ $tz = new tz_posix($tz_name); if ($tz->valid) return true; else { /* We're stumped! We use the dumbest object*/ $tz = new tz($tz_name); $tz->error = "Can't understand time zone name: $tz_name"; return false; } } } } /** * generic time zone object wrapper * * @access private */ function tz_generic() { $fn = "tz_generic"; // echo "$fn: begin\n"; GLOBAL $_TZ; $argv = func_get_args(); $method = array_shift($argv); //echo "method: $method\n"; //echo "object class: ", get_class($_TZ['obj']), "\n"; return call_user_func_array(array(&$_TZ['obj'],$method),$argv); } /** * get the local time, with timezone adjustment * * uses the $_TZ['obj'] object * * @link http://www.php.net/localtime * @see tz::localtime * @param integer timestamp (defaults to current time) * @param boolean whether to return as associative array * @global mixed TZ environment * @return array simple or (if $is_assoc==true) associative array * like the C tm structure */ function tz_localtime($t=false,$is_assoc=0) { return tz_generic('localtime',$t,$is_assoc); } /** * Get UNIX timestamp for a date * * uses the $_TZ['obj'] object * * @link http://www.php.net/mktime * @see tz::mktime * @param integer hour * @param integer minute * @param integer second * @param integer month * @param integer day * @param integer year * @param integer is_dst * @param string time zone name (effectively defaults to $TZ) * @return integer timestamp * */ function tz_mktime($hour=false,$minute=false,$second=false, $month=false,$day=false,$year=false,$is_dst=-1,$tz_str='') { return tz_generic('mktime',$hour,$minute,$second,$month,$day,$year,$is_dst); } /** * format time, with time zone adjustment * * uses the $_TZ['obj'] object * * @link http://www.php.net/strftime * @see tz::strftime * @param string format * @param integer timestamp (defaults to current time) * @return string */ function tz_strftime($fmt,$t=false) { return tz_generic('strftime',$fmt,$t); } /** * convert human-readable date/time string to timestamp, minding time zone. * * uses the $_TZ['obj'] object. * * @see tz::strtotime * @param string date/time string * @return integer timestamp */ function tz_strtotime($str) { return tz_generic('strtotime',$str); } /** * @global mixed $_TZ */ $_TZ['default'] = ':/etc/localtime'; // $_TZ['name'] = 'America/Chicago'; $_TZ['dir'] = '/usr/share/zoneinfo'; // $_TZ['native'] = false; ?> --- NEW FILE: tz_nonnative.class --- <?php /** * base class to manually compute time zone offsets * * now things get interesting! */ class tz_nonnative extends tz { /** * compute UTC offset * * This method must be overwritten in descendants. Given the unix * timestamp $t, compute the seconds local time is off from UTC. * * @param integer unix timestamp (seconds elapsed since epoch) * @return array associative array * gmtoff=>seconds off of UTC (integer) * is_dst=>is daylight savings time (boolean) * tzabbr=>abbreviation of time zone (string) */ function get_offset($t) { return false; } /** * munge timestamp * * The idea is that the altered timestamp, when entered into * functions that use server's timezone adjustments, reflect the given * timestamp in the working timezone. * * $t itself is changed, not a copy of it (is that a good idea?). * * If $tti is not given, it is computed by the get_offset() method. * * @param integer timestamp * @param ttinfo timezone info structure. * @param boolean adjust backwards */ function adjust_timestamp(&$t,$tti=false,$reverse=false) { $fn = get_class($this) . '::adjust_timestamp'; //echo "$fn: begin\n"; $tcopy = $t; $tti || $tti = $this->get_offset($t); // echo "tti:"; // print_r($tti); // echo "\n"; $gmtoff = $tti['gmtoff']; //echo "gmtoff=$gmtoff\n"; $t += $gmtoff; $server_offset = date("Z",$t); // echo "server_offset=$server_offset\n"; $t -= $server_offset; // echo "new t=$t\n"; /* it's possible that we have crossed a time change transition point of the local server. If so, we need to readjust the time */ $new_server_offset = date("Z",$t); // echo "new server_offset=$new_server_offset\n"; $t += $server_offset - $new_server_offset; if ($reverse) $t = $tcopy - ($t - $tcopy); // echo "$fn: end\n"; } /** * just like adjust_timestamp, but in reverse * * @see adjust_timestamp * @param integer time * @param ttinfo time zone structure */ function adjust_timestamp_reverse(&$t,$tti=false) { $this->adjust_timestamp($t,$tti,true); } /** * get the local time, with timezone adjustment * * @see tz::localtime */ function localtime($t=false,$is_assoc=false) { if (false===$t) $t = time(); $tti = $this->get_offset($t); //print_r($tti); // $server_offset = date("Z",$t); //$t += $tti['gmtoff']; //$t -= $server_offset; $this->adjust_timestamp($t,$tti); $tm = localtime($t,$is_assoc); $index = ($is_assoc ? 'tm_isdst' : count($tm) - 1); $tm[$index] = $tti['is_dst']; return $tm; } /** * format time, with time zone adjustment * * @link http://www.php.net/strftime * @param string format * @param integer timestamp (defaults to current time) * @return string */ function strftime($fmt,$t=false) { $fn = get_class($this) . '::strftime'; //echo "$fn: begin\n"; if (false === $t) { $t = time(); } $tti = $this->get_offset($t); $this->adjust_timestamp($t,$tti); // replace the %Z string...but not the %%Z string! $fmt = preg_replace('/(%)?(%Z)/e', '("\\1" == "%" ? "\\0" : $tti["tzabbr"])',$fmt); // echo "fmt=$fmt\n"; // echo "$fn: end\n"; return strftime($fmt,$t); } /** * Get UNIX timestamp for a date * * Works just like {@link http://www.php.net/mktime mktime} except it * minds the time zone. * * Not sure how well this works with is_dst set * * @param integer hour * @param integer minute * @param integer second * @param integer month * @param integer day * @param integer year * @param integer is_dst * @return integer timestamp * */ function mktime($hour=false,$minute=false,$second=false,$month=false,$day=false,$year=false,$is_dst=-1) { /* Set defaults. This involves a localtime call, so let's first make sure it *needs* to be done. Notice the default argument is FALSE at first and we use the super-strict type equality check so that zero is not corrected. */ if (($hour === false) || ($minute === false) || ($second === false) || ($month === false) || ($day === false) || ($year === false)) { $tm = $this->localtime(false,true); // echo "current tm:"; // print_r($tm); foreach(array('hour'=>'tm_hour', 'minute'=>'tm_min', 'second'=>'tm_sec', 'month'=>'tm_mon', 'day'=>'tm_day', 'year'=>'tm_year') as $key => $val) { if ($$key === false) $$key = $tm[$val]; } } // gmmktime is oblivious to DST $gmtime = gmmktime($hour,$minute,$second,$month,$day,$year); // print_r(gmdate("M d Y H:i:s\n",$gmtime)); $tti = $this->get_offset($gmtime); // print_r($tti); $guess = $gmtime - $tti['gmtoff']; $check = $this->localtime($guess,true); // print_r($check); /* if we were unlucky enough have a DST conversion between us and Greenwich, the time might be off. So we adjust, allowing for the idiotic case that this zone's DST adjustment is any number of hours, minutes, and seconds. */ $guess -= ($check['tm_hour'] - $hour) * SECONDS_PER_HOUR + ($check['tm_min'] - $minute) * SECONDS_PER_MINUTE + ($check['tm_sec'] - $second); /* the other possibility is that the user entered an is_dst. If the specified dst indicator and the normal one for the zone are the same, no problem. Otherwise, either the time returned is DST and the user wanted standard, meaning we subtract an hour (3pm DST happens BEFORE 3pm standard), or vice versa, mutatis mutandis, et cetera. Here I think we have to assume that the DST adjustment is standardized. */ if (($is_dst != -1) && ($is_dst != $tti['is_dst'])) { $guess += ($is_dst ? -1 : 1) * SECONDS_PER_HOUR; } return $guess; } /** * convert human-readable date/time string to timestamp, minding time zone. * * Should work just like {@link http://www.php.net/strtotime}, except * correcting based on the time zone. I'm not at all confident this works! * * @link http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html * @param string date/time string * @param string time zone string (effectively defaults to $TZ) * @return integer timestamp */ function strtotime($time_str) { /* If time_str has a time zone indicator in it, we should NOT * correct. */ $tz_offset = '(-|\+)[0-9]{4}'; $zone_indicator = '\b(#+000 GMT# for Greenwich Mean |UT|UTC# for Universal (Coordinated) |WET# for Western European and |Z# for militaries #+100 |WAT# for West Africa and |A#for militaries. #+200 |AT# for Azores and |B# for militaries. #+300 |C# for militaries. #+400 |AST# for Atlantic Standard and |D# for militaries. #+500 |E# for militaries and |EST$ for Eastern Standard. #+600 |CST# for Central Standard and |F# for militaries. #+700 |G# for militaries and |MST# for Mountain Standard. #+800 |H# for militaries and |PST# for Pacific Standard. #+900 |I# for militaries and |YST# for Yukon Standard. #+1000 |AHST# for Alaska-Hawaii Standard, |CAT# for Central Alaska, |HST# for Hawaii Standard and |K# for militaries. #+1100 |L# for militaries and |NT# for Nome. # +1200 |IDLW# for International Date Line West and |M# for militaries. #-100 |CET# for Central European, |FWT# for French Winter, |MET# for Middle European, |MEWT# for Middle European Winter, |N# for militaries and |SWT# for Swedish Winter. #-200 |EET# for Eastern European, USSR Zone 1 and |O# for militaries. #-300 |BT# for Baghdad, USSR Zone 2 and |P# for militaries. #-400 |Q# for militaries and |ZP4# for USSR Zone 3. #-500 |R# for militaries and |ZP5# for USSR Zone 4. #-600 |S# for militaries and |ZP6# for USSR Zone 5. #-700 |T# for militaries and |WAST# for West Australian Standard. #-800 |CCT# for China Coast, USSR Zone 7 and |U# for militaries. #-900 |JST# for Japan Standard, USSR Zone 8 and |V# for militaries. #-1000 |EAST# for East Australian Standard, |GST# for Guam Standard, USSR Zone 9 and |W# for militaries. #-1100 |X# for militaries. #-1200 |IDLE# for International Date Line East, |NZST# for New Zealand Standard, |NZT# for New Zealand and |Y# for militaries. )\b'; $dst_zone_indicator = '\b(#0 BST# for British Summer. #+400 |ADT# for Atlantic Daylight. #+500 |EDT# for Eastern Daylight. #+600 |CDT# for Central Daylight. #+700 |MDT# for Mountain Daylight. #+800 |PDT# for Pacific Daylight. #+900 |YDT# for Yukon Daylight. #+1000 |HDT# for Hawaii Daylight. #-100 |MEST# for Middle European Summer, |MESZ# for Middle European Summer, |SST# for Swedish Summer and |FST# for French Summer. #-700 |WADT# for West Australian Daylight. #-1000 |EADT# for Eastern Australian Daylight. #-1200 |NZDT# for New Zealand Daylight. )\b'; $guess = strtotime($time_str); if (!preg_match("/$zone_indicator|$dst_zone_indicator/x",$time_str)) { $this->adjust_timestamp_reverse($guess); } return $guess; } } ?> Index: functions.inc =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/functions.inc,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** functions.inc 20 Jun 2002 23:48:37 -0000 1.108 --- functions.inc 3 Sep 2002 15:06:07 -0000 1.109 *************** *** 877,880 **** --- 877,972 ---- /** + * look up a keyword in localinfo + * + * @param string category (the constant, NOT the string!) + * @param string keyword to lookup + * @param string locale (defaults to the current locale for the given category + * @return string looked-up answer, or $keyword if not found. + */ + function psl_getLocalinfo($category,$keyword,$locale=false) { + GLOBAL $_PSL; + static $localinfo; + static $catcodes; + + if (!$catcodes) { + foreach(array('LC_CTYPE','LC_COLLATE','LC_MONETARY','LC_NUMERIC','LC_TIME') as $cat) + $catcodes[constant($cat)] = $cat; + } + if (is_int($category)) { + $catcode = $category; + $category = $catcodes[$catcode]; + } + else { + $catcode = constant($category); + } + + $locale || $locale = $_PSL['locale'][$category]; + if (!is_array($localinfo[$locale][$category])) { + $filename = sprintf('%s/%s.%s.php3',$_PSL['localedir'],$locale,$category); + if (!is_readable($filename)) { + error("psl_getLocalinfo: file either nonexistent or not readable: $filename"); + } + else { + include($filename); // sets a variable $pslstrings + $localinfo[$locale][$category] = $pslstrings; + } + } + $ans = $localinfo[$locale][$category][$keyword]; + if (!isset($ans)) { + /* Hm. it's not in the localinfo array. We'll try first looking + in the localinfo for the en_US locale (sorry for the hegemony), + and then just give up if that fails. */ + if ($locale != 'en_US') + $ans = psl_getLocalinfo($category,$keyword,'en_US'); + else + $ans = $keyword; + } + return $ans; + } + + /** + * format time, with keyword lookup + * + * @param string strftime format string OR localinfo LC_TIME keyword + * @param integer timestamp + * @return formatted string + */ + function psl_strftime($fmt,$t) { + GLOBAL $_PSL; + $oldlocale = setlocale(LC_TIME,0); + $locale = $_PSL['locale']['LC_TIME']; + setlocale(LC_TIME,$locale); + $fmt = psl_getLocalinfo('LC_TIME',$fmt); + $strftime = ($_PSL['timezone']['engine'] ? 'tz_strftime' : 'strftime'); + $ans = $strftime($fmt,$t); + setlocale(LC_TIME,$oldlocale); + return $ans; + } + + function psl_dateLong($t) { + return psl_strftime('date_format_long',$t); + } + + function psl_dateShort($t) { + return psl_strftime('date_format_short',$t); + } + + function psl_time12($t) { + return psl_strftime('time_format_12',$t); + } + + function psl_time24($t) { + return psl_strftime('time_format_24',$t); + } + + function psl_dateTimeLong($t) { + return psl_strftime('date_time_format_long',$t); + } + + function psl_dateTimeShort($t) { + return psl_strftime('date_time_format_short',$t); + } + + /** * function setLang returns languagefile * *************** *** 1048,1052 **** } header("Location: ".$_PSL[phpself].$query_string); ! } } elseif (@is_dir($templatedir . "/" . basename($_PSL['defaultskin']))) { $new_skin = $_PSL['defaultskin']; --- 1140,1144 ---- } header("Location: ".$_PSL[phpself].$query_string); ! } } elseif (@is_dir($templatedir . "/" . basename($_PSL['defaultskin']))) { $new_skin = $_PSL['defaultskin']; *************** *** 1073,1076 **** --- 1165,1229 ---- return $templatedir; } + + /** + * function set_TZ - setup time zone environment + * + * To function, requires that safe_mode not preclude setting the TZ environment variable + * + * @param string string for new time zone + * @param string "" for no saving or "cookie" to save a cookie + * @access public + * + * @return name of the time zone set, or false if no environment variable is set. + */ + function set_TZ($new_tzname='',$method='') { + global $_PSL, $HTTP_GET_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS; + $fn = "set_TZ"; + // debug("$fn: start",$new_tzname); + + // default: value in _PSL array. + $default_TZ = $_PSL['timezone']['name']; + if (!$default_TZ && $_PSL['timezone']['native']) + $default_TZ = $_PSL['timezone']['default']; + // start with cookie value if it's set + $cookie_TZ = $HTTP_COOKIE_VARS['TZ']; + if (!empty($cookie_TZ)) + $tzname = $cookie_TZ; + // override if an argument is passed. + if ($new_tzname) + $tzname = $new_tzname; + // check it. tz_select returns a success value. + if (empty($tzname) || !tz_select($tzname)) { + /* Try the default. Yes, I *do* want a single equals there. If + * $default_TZ is true, this will succeed. */ + if ($tzname = $default_TZ) { + if (!tz_select($tzname)) + { + // complain if the default is set, because it's bad. + error("specified default time zone is invalid: $default_TZ"); + return false; + } + } + else { + // given timezone is bad and no default, so just exit quietly + return false; + } + } + //$host = str_replace('www.','',$HTTP_SERVER_VARS['SERVER_NAME']); + if ('cookie'==$method) { + // save the cookie + setcookie('TZ',$tzname,time() + 15552000,'/',$host); + /* + * in setSkinTpl a redirect is called. Is that really + * necessary? + */ + } + elseif (!empty($cookie_TZ) && $tzname != $cookie_TZ) { + // you gave me a bad cookie; I need to delete it + // setcookie('TZ','','','/',$host); + setcookie('TZ'); + } + return $tzname; + } /** |
From: Joe S. <joe...@us...> - 2002-09-03 15:04:37
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv15359/phpslash-ft/class Modified Files: Comment.class Story_admin.class Story_base.class Log Message: [ 580757 ] Site-wide date formats and TIMEZONES Index: Comment.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Comment.class,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Comment.class 18 Jun 2002 15:52:16 -0000 1.28 --- Comment.class 3 Sep 2002 15:04:35 -0000 1.29 *************** *** 113,116 **** --- 113,117 ---- comment_text, date_format(date,\"%W, %M %d \@%h:%i%p\") AS time + UNIX_TIMESTAMP(date) AS timestamp FROM psl_comment WHERE story_id = '$ary[story_id]' "; *************** *** 160,163 **** --- 161,165 ---- comment_text, date_format(date,\"%W, %M %d \@%h:%i%p\") AS time + UNIX_TIMESTAMP(date) AS timestamp FROM psl_comment WHERE comment_id = '$comment_id'"; *************** *** 260,264 **** 'MODE' => $this->mode, 'ORDER' => $this->order, ! 'TIME' => $ary['time'] )); if ($this->perm->have_perm("comment")) { --- 262,267 ---- 'MODE' => $this->mode, 'ORDER' => $this->order, ! // 'TIME' => $ary['time'] ! 'TIME' => psl_dateTimeLong($ary['timestamp']) )); if ($this->perm->have_perm("comment")) { *************** *** 617,620 **** --- 620,624 ---- $comment_id = generateID("psl_comment_seq"); $fdate = date("Y-m-d H:i:s",time()); + $timestamp = time(); $q = "INSERT INTO psl_comment (comment_id, *************** *** 632,636 **** '$ary[story_id]', '$ary[user_id]', ! '$fdate', '$ary[name]', '$ary[email]', --- 636,640 ---- '$ary[story_id]', '$ary[user_id]', ! FROM_UNIXTIME($timestamp), '$ary[name]', '$ary[email]', Index: Story_admin.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Story_admin.class,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Story_admin.class 13 Jun 2002 20:03:44 -0000 1.2 --- Story_admin.class 3 Sep 2002 15:04:35 -0000 1.3 *************** *** 158,170 **** } ! $q = "SELECT date_format('$ary[datetime]',$this->article_dateformat) AS datef"; ! $this->db->query($q); ! $this->db->next_record(); ! $datef = $this->db->f("datef"); ! ! if (!$datef) { ! $datef = date( "l F j @ h:i A"); ! } /* only the topic_id is passed in the topic_id_ary --- 158,166 ---- } ! $timestamp = strtotime($ary['datetime']); ! if ($timestamp == -1) { ! $timestamp = time(); } + $datef = psl_dateTimeLong($timestamp); /* only the topic_id is passed in the topic_id_ary *************** *** 274,278 **** author.author_name, commentcount.count AS commentcount, ! date_format(time,$this->admin_dateformat) AS df FROM psl_story story, psl_author author,"; --- 270,275 ---- author.author_name, commentcount.count AS commentcount, ! date_format(time,$this->admin_dateformat) AS df, ! UNIX_TIMESTAMP(time) AS timestamp FROM psl_story story, psl_author author,"; *************** *** 304,308 **** $q .= "AND '$section_id' = psl_section_lut.section_id "; } ! $q .= "ORDER BY time DESC"; $this->db->query($q); --- 301,305 ---- $q .= "AND '$section_id' = psl_section_lut.section_id "; } ! $q .= "ORDER BY timestamp DESC"; $this->db->query($q); *************** *** 412,417 **** 'HITS' => $this->db->Record["hits"], 'COMMENTCOUNT' => $this->db->Record["commentcount"], ! 'DATE' => $this->db->Record["df"] ! )); if ($i%2 == 0) { $this->template->parse("rows","row","true"); --- 409,414 ---- 'HITS' => $this->db->Record["hits"], 'COMMENTCOUNT' => $this->db->Record["commentcount"], ! 'DATE' => psl_dateTimeShort($this->db->Record["timestamp"]) ! )); if ($i%2 == 0) { $this->template->parse("rows","row","true"); Index: Story_base.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Story_base.class,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Story_base.class 13 Aug 2002 14:36:35 -0000 1.14 --- Story_base.class 3 Sep 2002 15:04:35 -0000 1.15 *************** *** 24,28 **** var $auth; var $message; ! var $article_dateformat = "\"%W %M %d, %Y \@ %h:%i%p\""; // date for the article page var $index_dateformat = "\"%W %M %d %Y \@ %h:%i%p\""; // date for the index page --- 24,36 ---- var $auth; var $message; ! var $psl; ! ! ! /* These are dateformats to be fed to MySQL. We are phasing them * ! * out. Instead of formatting the date with a MySQL function ! * (DATE_FORMAT), we will fetch the UNIX_TIMESTAMP, and convert it ! * with PHP to a nice string. This will allow i18n, site-wide ! * configuration, and time zone correction (yay!). ! */ var $article_dateformat = "\"%W %M %d, %Y \@ %h:%i%p\""; // date for the article page var $index_dateformat = "\"%W %M %d %Y \@ %h:%i%p\""; // date for the index page *************** *** 37,40 **** --- 45,49 ---- $this->perm = $GLOBALS['perm']; $this->message = ''; + $this->psl = $GLOBALS['_PSL']; } /* *************** *** 50,53 **** --- 59,63 ---- story.user_id, date_format(story.time,$this->article_dateformat) AS datef, + UNIX_TIMESTAMP(story.time) AS timestamp, story.intro_text, story.body_text, *************** *** 106,110 **** $this->story_ary['name'] = $this->db->Record["name"]; $this->story_ary['realname'] = $this->db->Record["realname"]; ! $this->story_ary['datef'] = $this->db->Record["datef"]; $this->story_ary['topic_id'] = $this->db->Record["topic_id"]; $this->story_ary['topic_name'] = $this->db->Record["topic_name"]; --- 116,121 ---- $this->story_ary['name'] = $this->db->Record["name"]; $this->story_ary['realname'] = $this->db->Record["realname"]; ! // $this->story_ary['datef'] = $this->db->Record["datef"]; ! $this->story_ary['datef'] = psl_dateTimeLong($this->db->Record['timestamp']); $this->story_ary['topic_id'] = $this->db->Record["topic_id"]; $this->story_ary['topic_name'] = $this->db->Record["topic_name"]; *************** *** 169,172 **** --- 180,184 ---- psl_story.title, date_format(psl_story.time,$this->index_dateformat) AS dateformat, + UNIX_TIMESTAMP(psl_story.time) AS timestamp, psl_story.intro_text, psl_story.body_text, *************** *** 368,372 **** // $stories_ary[$i]['name'] = $this->db->Record["author_name"]; $stories_ary[$i]['name'] = $this->db->Record["author_realname"]; ! $stories_ary[$i]['datef'] = $this->db->Record["dateformat"]; $stories_ary[$i]['hits'] = $this->db->Record["hits"]; $stories_ary[$i]['topic_id'] = $this->db->Record["topic_id"]; --- 380,385 ---- // $stories_ary[$i]['name'] = $this->db->Record["author_name"]; $stories_ary[$i]['name'] = $this->db->Record["author_realname"]; ! // $stories_ary[$i]['datef'] = $this->db->Record["dateformat"]; ! $stories_ary[$i]['datef'] = psl_dateTimeLong($this->db->Record['timestamp']); $stories_ary[$i]['hits'] = $this->db->Record["hits"]; $stories_ary[$i]['topic_id'] = $this->db->Record["topic_id"]; *************** *** 473,476 **** --- 486,490 ---- } } + $ary['timestamp'] = strtotime($ary['datetime']); $ary['title'] = eregi_replace("\"",""",addslashes($ary['title'])); *************** *** 502,507 **** SET user_id = '$ary[author_id]', title = '$ary[title]', ! time = '$ary[datetime]', ! dept = '$ary[dept]', intro_text = '$ary[intro_text]', body_text = '$ary[body_text]', --- 516,521 ---- SET user_id = '$ary[author_id]', title = '$ary[title]', ! time = '$ary[datetime]', ! dept = '$ary[dept]', intro_text = '$ary[intro_text]', body_text = '$ary[body_text]', |
From: Joe S. <joe...@us...> - 2002-09-03 15:04:37
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv15359/phpslash-ft Modified Files: CHANGES Log Message: [ 580757 ] Site-wide date formats and TIMEZONES Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.545 retrieving revision 1.546 diff -C2 -d -r1.545 -r1.546 *** CHANGES 31 Aug 2002 14:10:52 -0000 1.545 --- CHANGES 3 Sep 2002 15:04:34 -0000 1.546 *************** *** 13,16 **** --- 13,29 ---- 9 - Removal of something (kill -9 :) + 2002-September-3 9:00AM CDT Joe Stewart <joe...@us...> + [F] - Matthew Leingang's implementation of Site-wide date formats and TIMEZONES. Patch [ 580757 ] Site-wide date formats and TIMEZONES! and + Feature Request [ 513262 ] Consistent date/time formatting. + Affected files - Comment.class, Poll.class, Story_admin.class, + Story_base.class, functions.inc, comment.php3, config.php3, tz.class, + tz_env.class, tz_file.class, tz_functions.inc, tz_nonnative.class, + tz_posix.class, libtz.inc, tz_select.php3, tz_bench.php3, + tz_test_basic.php3, tz_test_localtime.php3, tz_test_mktime.php3, + tz_test_strftime.php3, tz_test_strtotime.php3, tz_bench.tpl, + tz_form_confirm.tpl, tz_form_native.tpl, tz_form_posix.tpl, + tz_show.tpl, en_GB.LC_TIME.php3, en_US.LC_TIME.php3, fr.LC_TIME.php3, + fr_FR.LC_TIME.php3, and phpslash.sgml. + 2002-August-31 9:00AM CDT Joe Stewart <joe...@us...> [E] - slashAuthCR.class, slash-all.sql, comment.php3 - experimental use of |
From: Joe S. <joe...@us...> - 2002-08-31 14:11:25
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv325/phpslash-ft Modified Files: CHANGES Log Message: experimental nobody user Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.544 retrieving revision 1.545 diff -C2 -d -r1.544 -r1.545 *** CHANGES 31 Aug 2002 13:00:37 -0000 1.544 --- CHANGES 31 Aug 2002 14:10:52 -0000 1.545 *************** *** 13,16 **** --- 13,21 ---- 9 - Removal of something (kill -9 :) + 2002-August-31 9:00AM CDT Joe Stewart <joe...@us...> + [E] - slashAuthCR.class, slash-all.sql, comment.php3 - experimental use of + nobody user to define anonymous user's permissions. + Author.class - minor quoting fix it getID. + 2002-August-31 8:00AM CDT Joe Stewart <joe...@us...> [B] - Story.class - getStories should display correct template if called |
From: Joe S. <joe...@us...> - 2002-08-31 14:10:58
|
Update of /cvsroot/phpslash/phpslash-ft/public_html In directory usw-pr-cvs1:/tmp/cvs-serv325/phpslash-ft/public_html Modified Files: comment.php3 Log Message: experimental nobody user Index: comment.php3 =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/public_html/comment.php3,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** comment.php3 18 Jun 2002 15:52:17 -0000 1.14 --- comment.php3 31 Aug 2002 14:10:55 -0000 1.15 *************** *** 8,11 **** --- 8,13 ---- page_open(array("sess"=>"slashSess","auth"=>"slashAuth","perm"=>"slashPerm")); + $auth->login_if(!$perm->have_perm('commentPost')); + /* if we are the result of a post operation, then setup the session variables */ |
From: Joe S. <joe...@us...> - 2002-08-31 14:10:58
|
Update of /cvsroot/phpslash/phpslash-ft/tables/0.7 In directory usw-pr-cvs1:/tmp/cvs-serv325/phpslash-ft/tables/0.7 Modified Files: slash-all.sql Log Message: experimental nobody user Index: slash-all.sql =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/tables/0.7/slash-all.sql,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** slash-all.sql 9 Jul 2002 20:34:56 -0000 1.9 --- slash-all.sql 31 Aug 2002 14:10:54 -0000 1.10 *************** *** 137,141 **** INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_mailinglist_seq', '2'); INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_glossary_seq', '1'); ! INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_blocktype_seq ', '10'); INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_section_block_lut_seq', '280'); INSERT INTO db_sequence VALUES ('psl_permission_seq',80); --- 137,141 ---- INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_mailinglist_seq', '2'); INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_glossary_seq', '1'); ! INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_blocktype_seq ', '14'); INSERT INTO db_sequence (seq_name, nextid) VALUES ( 'psl_section_block_lut_seq', '280'); INSERT INTO db_sequence VALUES ('psl_permission_seq',80); *************** *** 144,148 **** INSERT INTO db_sequence VALUES ('psl_group_permission_lut_seq',109); INSERT INTO db_sequence VALUES ('psl_group_group_lut_seq',64); ! INSERT INTO db_sequence VALUES ('psl_author_group_lut_seq',26); CREATE TABLE psl_author ( --- 144,148 ---- INSERT INTO db_sequence VALUES ('psl_group_permission_lut_seq',109); INSERT INTO db_sequence VALUES ('psl_group_group_lut_seq',64); ! INSERT INTO db_sequence VALUES ('psl_author_group_lut_seq',27); CREATE TABLE psl_author ( *************** *** 166,169 **** --- 166,170 ---- INSERT INTO psl_author (author_id, author_name, author_realname, url, email, quote, password, seclev, perms, author_options) VALUES ( '1', 'god', '', 'http://www.god.com', 'go...@he...', 'God doesn't need a 'quote'!', MD5('god:password'), '1000000', 'root,nobody,user,topic,comment,story,storyeditor,section,submission,block,poll,author,variable,glossary,mailinglist,logging',''); + INSERT INTO psl_author VALUES (20,'nobody','Anonymous','','','','7dae6bd6d92a6c64367c27ea48169e4e',0,'','N;'); # *************** *** 184,187 **** --- 185,190 ---- INSERT INTO psl_author_group_lut VALUES (26,1,24); + INSERT INTO psl_author_group_lut VALUES (27,20,20); + # -------------------------------------------------------- # *************** *** 508,512 **** INSERT INTO psl_group VALUES (18,'topic','Topic Admin'); INSERT INTO psl_group VALUES (19,'variable','Variable Admin'); ! INSERT INTO psl_group VALUES (20,'nobody','Anon user (not effective)'); INSERT INTO psl_group VALUES (21,'user','logged in user privileges. General users.'); INSERT INTO psl_group VALUES (22,'commentUser','User comment privileges'); --- 511,515 ---- INSERT INTO psl_group VALUES (18,'topic','Topic Admin'); INSERT INTO psl_group VALUES (19,'variable','Variable Admin'); ! INSERT INTO psl_group VALUES (20,'nobody','Anon user'); INSERT INTO psl_group VALUES (21,'user','logged in user privileges. General users.'); INSERT INTO psl_group VALUES (22,'commentUser','User comment privileges'); |
From: Joe S. <joe...@us...> - 2002-08-31 14:10:57
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv325/phpslash-ft/class Modified Files: slashAuthCR.class Author.class Log Message: experimental nobody user Index: slashAuthCR.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/slashAuthCR.class,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** slashAuthCR.class 20 Jun 2002 23:48:37 -0000 1.14 --- slashAuthCR.class 31 Aug 2002 14:10:53 -0000 1.15 *************** *** 123,127 **** --- 123,133 ---- } } + } else if ($this->nobody) { + $uid = $this->auth["uid"] = "nobody"; + $aid = Author::getId($uid); + $this->auth["perm"] = $this->get_userperms($aid); + return $uid; } + } *************** *** 143,147 **** } else if ($this->nobody) { ## provides for "default login cancel" $uid = $this->auth["uid"] = "nobody"; ! return $uid; } --- 149,155 ---- } else if ($this->nobody) { ## provides for "default login cancel" $uid = $this->auth["uid"] = "nobody"; ! $aid = Author::getId($uid); ! $this->auth["perm"] = $this->get_userperms($aid); ! return $uid; } Index: Author.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Author.class,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Author.class 9 Jul 2002 19:48:46 -0000 1.27 --- Author.class 31 Aug 2002 14:10:53 -0000 1.28 *************** *** 597,601 **** $q = "SELECT author_id FROM psl_author ! WHERE author_name = $name"; $this->db->query($q); $this->db->next_record(); --- 597,601 ---- $q = "SELECT author_id FROM psl_author ! WHERE author_name = '$name' "; $this->db->query($q); $this->db->next_record(); |
From: Joe S. <joe...@us...> - 2002-08-31 13:00:40
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv18276/phpslash-ft/class Modified Files: Story.class Log Message: getStories multiple call/multiple template fix Index: Story.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Story.class,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Story.class 13 Aug 2002 14:36:34 -0000 1.39 --- Story.class 31 Aug 2002 13:00:38 -0000 1.40 *************** *** 447,451 **** "template" => "$tpl_file" )); ! $template = "template"; } else { debug ( "Story.class::getStories:Template file doesn't exist, using default instead", $tpl); --- 447,454 ---- "template" => "$tpl_file" )); ! // reset previous values ! unset($this->template->varvals['template']); ! unset($this->template->varkeys['template']); ! $template = "template"; } else { debug ( "Story.class::getStories:Template file doesn't exist, using default instead", $tpl); *************** *** 583,587 **** $this->template->set_var(array( 'rows' => "", ! 'alsoblock' => "" )); --- 586,591 ---- $this->template->set_var(array( 'rows' => "", ! 'alsoblock' => "", ! 'stories' => "" )); |
From: Joe S. <joe...@us...> - 2002-08-31 13:00:40
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv18276/phpslash-ft Modified Files: CHANGES Log Message: getStories multiple call/multiple template fix Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.543 retrieving revision 1.544 diff -C2 -d -r1.543 -r1.544 *** CHANGES 29 Aug 2002 13:29:56 -0000 1.543 --- CHANGES 31 Aug 2002 13:00:37 -0000 1.544 *************** *** 13,16 **** --- 13,20 ---- 9 - Removal of something (kill -9 :) + 2002-August-31 8:00AM CDT Joe Stewart <joe...@us...> + [B] - Story.class - getStories should display correct template if called + multiple times now. + 2002-August-29 8:30AM CDT Joe Stewart <joe...@us...> [F] - blockAdmin.php3 - Matthew Leingang's patch to refresh the block's cache |
From: Joe S. <joe...@us...> - 2002-08-29 13:30:00
|
Update of /cvsroot/phpslash/phpslash-ft/public_html/admin In directory usw-pr-cvs1:/tmp/cvs-serv4076/phpslash-ft/public_html/admin Modified Files: blockAdmin.php3 Log Message: [ 601801 ] Refresh method for blocks Index: blockAdmin.php3 =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/public_html/admin/blockAdmin.php3,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** blockAdmin.php3 7 Jun 2002 16:24:59 -0000 1.5 --- blockAdmin.php3 29 Aug 2002 13:29:56 -0000 1.6 *************** *** 42,45 **** --- 42,47 ---- break; case "view": + $block->getBlock($id); + $block->doParse(); /* refreshes block cache in db */ $content .= $block->doBlock($id); if ($perm->have_perm("blockList")) { |
From: Joe S. <joe...@us...> - 2002-08-29 13:30:00
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv4076/phpslash-ft Modified Files: CHANGES Log Message: [ 601801 ] Refresh method for blocks Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.542 retrieving revision 1.543 diff -C2 -d -r1.542 -r1.543 *** CHANGES 13 Aug 2002 14:36:33 -0000 1.542 --- CHANGES 29 Aug 2002 13:29:56 -0000 1.543 *************** *** 13,16 **** --- 13,21 ---- 9 - Removal of something (kill -9 :) + 2002-August-29 8:30AM CDT Joe Stewart <joe...@us...> + [F] - blockAdmin.php3 - Matthew Leingang's patch to refresh the block's cache + from the Block Admin page. Feature Request [ 601801 ] Refresh method + for blocks. + 2002-August-13 9:00AM CDT Joe Stewart <joe...@us...> [B] - Story.class, Story_base.class - Added {HITS} placemarker for article |
From: Joe S. <joe...@us...> - 2002-08-13 14:36:39
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv7304/phpslash-ft/class Modified Files: Story.class Story_base.class Log Message: HITS in story.tpl and cronmail improvements Index: Story.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Story.class,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Story.class 20 Jun 2002 18:56:18 -0000 1.38 --- Story.class 13 Aug 2002 14:36:34 -0000 1.39 *************** *** 347,350 **** --- 347,351 ---- 'INTRO_TEXT' => $ary['intro_text'], 'BODY_TEXT' => $ary['body_text'], + 'HITS' => $ary['hits'], 'DEPT' => $ary['dept'], 'URL' => str_html($ary['url']), Index: Story_base.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Story_base.class,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Story_base.class 13 Jun 2002 20:03:44 -0000 1.13 --- Story_base.class 13 Aug 2002 14:36:35 -0000 1.14 *************** *** 52,55 **** --- 52,56 ---- story.intro_text, story.body_text, + story.hits, story.topic_cache, story.story_options, *************** *** 97,100 **** --- 98,102 ---- $this->story_ary['intro_text'] = $intro_text; $this->story_ary['body_text'] = $body_text; + $this->story_ary['hits'] = $this->db->Record["hits"]; $this->story_ary['dept'] = $dept; $this->story_ary['user_id'] = $this->db->Record["user_id"]; |
From: Joe S. <joe...@us...> - 2002-08-13 14:36:37
|
Update of /cvsroot/phpslash/phpslash-ft/contrib In directory usw-pr-cvs1:/tmp/cvs-serv7304/phpslash-ft/contrib Modified Files: cronmail.php3 Log Message: HITS in story.tpl and cronmail improvements Index: cronmail.php3 =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/contrib/cronmail.php3,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cronmail.php3 24 Jun 2002 19:57:02 -0000 1.3 --- cronmail.php3 13 Aug 2002 14:36:34 -0000 1.4 *************** *** 1,10 **** #!/usr/bin/php <?php ! // $id $ // Written by 'Blake' // Modified for phpSlash (v0.65) by: // Luis Mondesi <le...@ho...> ! // Last modified: 2002-Jun-12 // // NOTES: // The following is an example of how the tables should --- 1,19 ---- #!/usr/bin/php <?php ! // $Id$ // Written by 'Blake' // Modified for phpSlash (v0.65) by: // Luis Mondesi <le...@ho...> ! // Last modified: 2002-Jul-28 // + // USAGE: create a cron job that calls this file every 15 minutes + // starting at 1:00 am up to 6:30 am + // example: + // 00,15,30,45 1-6 * * * /usr/bin/php /path/to/cronmail.php3 2>&1> /dev/null + // + // of course, do not put the 2>&... redirection to /dev/null if you want to + // get a report on what was done :-) + // + // // NOTES: // The following is an example of how the tables should *************** *** 24,31 **** // UNIQUE email (email) //); ! // ! // ALTER TABLE psl_mailinglist MODIFY id int(30) DEFAULT '0' NOT NULL auto_increment, MODIFY email varchar(100) DEFAULT '' NOT NULL, MODIFY name varchar(100), MODIFY timestamp timestamp(14), ADD html tinyint(2) DEFAULT '0' NOT NULL; ! // ! // // // Table structure for table 'mailing_frequency' --- 33,37 ---- // UNIQUE email (email) //); ! // // Table structure for table 'mailing_frequency' *************** *** 37,41 **** //); // ! //ALTER TABLE psl_mailinglist_frequency MODIFY id int(30) DEFAULT '0' NOT NULL, MODIFY frequency char(30) DEFAULT '' NOT NULL, MODIFY dayback int(11) DEFAULT '0' NOT NULL; // // --- 43,51 ---- //); // ! // Table modifications for existing installations ! // ! // ALTER TABLE psl_mailinglist MODIFY id int(30) DEFAULT '0' NOT NULL auto_increment, MODIFY email varchar(100) DEFAULT '' NOT NULL, MODIFY name varchar(100), MODIFY timestamp timestamp(14), ADD html tinyint(2) DEFAULT '0' NOT NULL; ! // ! // ALTER TABLE psl_mailinglist_frequency MODIFY id int(30) DEFAULT '0' NOT NULL, MODIFY frequency char(30) DEFAULT '' NOT NULL, MODIFY dayback int(11) DEFAULT '0' NOT NULL; // // *************** *** 44,48 **** // phpSlash Daily Headline Mailer // - // // MORE NOTES: // The Debian folks should get the php4-cgi --- 54,57 ---- *************** *** 58,61 **** --- 67,79 ---- // that mess...) // + // CHANGELOG: + // 2002-06-27 -took off HTML stuff for some of the code + // -fixed formatting for some of the strings + // -fixed 'empty' messages being mailed + // -fixed missing days of the week ... not + // sure why some were missing... + // -fixed build_body() to return NULL if there + // is no messages pulled from the database + // // And now the code..... //.......................... *************** *** 75,79 **** $choplength = 600; ! //since you want to include a message daily, it's a separate file //remember to make it HTML if you are using the HTML option. //tags are stripped for plain text --- 93,97 ---- $choplength = 600; ! //since you want to include a message daily, it's a seperate file //remember to make it HTML if you are using the HTML option. //tags are stripped for plain text *************** *** 84,87 **** --- 102,110 ---- fclose ($fd); + // comment this out if you don't care about it + $header .= "\n"; + $header .= `/usr/games/fortune -s` ; // a little bit of fun! + $header .= "\n"; + $sitename = $_PSL['site_name']; // used in the title, and subject, and body of mail $siteurl = $_PSL['rooturl']; *************** *** 107,114 **** if ($rightnow == "0100"){ ! $limit = "0,100"; ! $today = date("w"); ! if($today=="1") { $offset = "3"; } ! else { $offset = "2"; } $frequency = "DAY"; $html =0; --- 130,140 ---- if ($rightnow == "0100"){ ! $limit = "0,100"; ! $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "2"; ! } $frequency = "DAY"; $html =0; *************** *** 136,141 **** $limit = "300,100"; $today = date("w"); ! if($today=="1") { $offset = "3"; } ! else { $offset = "2"; } $frequency = "DAY"; $html =0; --- 162,170 ---- $limit = "300,100"; $today = date("w"); ! if($today=="1") { ! $offset = "3"; ! } else { ! $offset = "2"; ! } $frequency = "DAY"; $html =0; *************** *** 257,260 **** --- 286,299 ---- $today = date("w"); $html =0; + if($today=="2") { + $offset = "7"; + $frequency = "TUESDAY"; + } else { + die; + } + } elseif ($rightnow == "0500") { + $limit = "0,200"; + $today = date("w"); + $html =0; if($today=="3") { $offset = "7"; *************** *** 263,267 **** die; } ! } elseif ($rightnow == "0500") { $limit = "0,200"; $today = date("w"); --- 302,316 ---- die; } ! } elseif ($rightnow == "0515") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="4") { ! $offset = "7"; ! $frequency = "THURSDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0530") { $limit = "0,200"; $today = date("w"); *************** *** 273,277 **** die; } ! } elseif ($rightnow == "0515") { $limit = "0,200"; $today = date("w"); --- 322,336 ---- die; } ! } elseif ($rightnow == "0545") { ! $limit = "0,200"; ! $today = date("w"); ! $html =0; ! if($today=="6") { ! $offset = "7"; ! $frequency = "SATURDAY"; ! } else { ! die; ! } ! } elseif ($rightnow == "0600") { $limit = "0,200"; $today = date("w"); *************** *** 285,289 **** } ///here is the experimental HTML one ! elseif ($rightnow == "0530") { $limit = "0,100"; $today = date("w"); --- 344,348 ---- } ///here is the experimental HTML one ! /*elseif ($rightnow == "0615") { $limit = "0,100"; $today = date("w"); *************** *** 295,299 **** $frequency = "DAY"; $html = 1; ! } /* use functions.inc format_mail() so that you can scrub things ;-) --- 354,358 ---- $frequency = "DAY"; $html = 1; ! }*/ /* use functions.inc format_mail() so that you can scrub things ;-) *************** *** 325,397 **** } ! function chopit ($str) ! { ! GLOBAL $choplength; ! $string = substr($str, 0, $choplength); ! $pos = strrpos ($string, "."); ! $finalstring = substr($string, 0, $pos); ! return $finalstring; ! } ! function build_body($offset) ! { ! GLOBAL $offset; ! $slash_q = new slashDB; ! $bmonth = date("m"); ! $bday = date("d") - $offset; ! $byear = date("Y"); ! $emonth = date("m"); ! $eday = date("d"); ! $eyear = date("Y"); ! $begdate = date("Y-m-d H:i:s", mktime(0,0,0,$bmonth,$bday,$byear)); ! $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! // this should get the stories using the class ! // but, for the moment 2002-06-12 luis mondesi: ! $sql="SELECT story_id, title, dept, ". " date_format(time, \"%W %M %d %h %i %p\") as pretty_time, ". " intro_text FROM psl_story ". " WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time DESC"; ! $slash_q->query($sql); ! while($slash_q->next_record()){ ! GLOBAL $siteurl; ! $headline = "\n".format_mail($slash_q->Record["title"],500,true) . "\n"; ! $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.\n"; ! $headline .= " Posted on: \"" . $slash_q->Record["pretty_time"] . "\n"; ! $headline .= " Story: " . format_mail($slash_q->Record["intro_text"],500,true) . ".\n"; ! $headline .= " ".$siteurl."article.php3?story_id=" . $slash_q->Record["story_id"]."\n"; ! $headline .= "---------------------------------------------------------------------------------------------\n\n"; ! $headline = stripslashes($headline); ! $thisHead .= $headline; ! } ! return $thisHead; ! } ! function build_html_body($offset) ! { ! GLOBAL $offset; ! $slash_q = new slashDB; ! $bmonth = date("m"); ! $bday = date("d") - $offset; ! $byear = date("Y"); ! $emonth = date("m"); ! $eday = date("d"); ! $eyear = date("Y"); ! $begdate = date("Y-m-d H:i:s", mktime(0,0,0,$bmonth,$bday,$byear)); ! $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! $sql=" SELECT story_id, title, dept, ". " date_format(time, \"%W %M %d %h %i %p\") as pretty_time, ". " intro_text FROM psl_story ". " WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time DESC"; ! $slash_q->query($sql); ! while($slash_q->next_record()) { ! GLOBAL $siteurl; $headline = "<B>".format_mail($slash_q->Record["title"],500,true) . "</B><BR>\n"; $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.<BR>\n"; $headline .= " Posted on: \"" . $slash_q->Record["pretty_time"] . "<BR>\n"; $headline .= " Story: " . format_mail(chopit($slash_q->Record["intro_text"]),500,true) . ".</I><BR>\n"; ! $headline .= "<A HREF=\"".$siteurl."article.php3?story_id=" . $slash_q->Record["story_id"] . "\">Full Story</A>\n"; $headline .= "<BR>---------------------------------------------------------------------------------------------<BR>\n\n"; $headline = stripslashes($headline); --- 384,461 ---- } ! function chopit ($str){ ! GLOBAL $choplength; ! $string = substr($str, 0, $choplength); ! $pos = strrpos ($string, "."); ! $finalstring = substr($string, 0, $pos); ! return $finalstring; ! } ! function build_body($offset) { ! GLOBAL $offset; ! $slash_q = new slashDB; ! $bmonth = date("m"); ! $bday = date("d") - $offset; // pull stories since yesterday or since Friday if today is Monday ! $byear = date("Y"); ! $emonth = date("m"); ! $eday = date("d"); ! $eyear = date("Y"); ! $begdate = date("Y-m-d H:i:s", mktime(0,0,0,$bmonth,$bday,$byear)); ! $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! // this should get the stories using the class ! // but, for the moment 2002-06-12 luis mondesi: ! $sql="SELECT story_id, title, dept, ". " date_format(time, \"%W %M %d %h %i %p\") as pretty_time, ". " intro_text FROM psl_story ". " WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time DESC"; ! $slash_q->query($sql); ! ! // 2002-06-27 luis: it makes no sense to continue if there ! // is nothing! ! if ( $slash_q->num_rows() > 0 ) { ! while($slash_q->next_record()){ ! GLOBAL $siteurl; ! $headline = "\n".format_mail($slash_q->Record["title"],500,true) . "\n"; ! $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.\n"; ! $headline .= " Posted on: \"" . $slash_q->Record["pretty_time"] . "\n"; ! $headline .= " Story: " . format_mail($slash_q->Record["intro_text"],500,true) . ".\n"; ! $headline .= " ".$siteurl."/article.php3?story_id=" . $slash_q->Record["story_id"]."\n"; ! $headline .= "---------------------------------------------------------------------------------------------\n\n"; ! $headline = stripslashes($headline); ! $thisHead .= $headline; ! } // end while() next_record ! return $thisHead; ! } // end if $slash_q is empty ! ! return ""; // return empty string if no records selected ! ! }// end build_body() ! function build_html_body($offset) { ! GLOBAL $offset; ! $slash_q = new slashDB; ! $bmonth = date("m"); ! $bday = date("d") - $offset; ! $byear = date("Y"); ! $emonth = date("m"); ! $eday = date("d"); ! $eyear = date("Y"); ! $begdate = date("Y-m-d H:i:s", mktime(0,0,0,$bmonth,$bday,$byear)); ! $enddate = date("Y-m-d H:i:s", mktime(0,0,0,$emonth,$eday + 1,$eyear)); ! $sql=" SELECT story_id, title, dept, ". " date_format(time, \"%W %M %d %h %i %p\") as pretty_time, ". " intro_text FROM psl_story ". " WHERE time >= '$begdate' AND time <= '$enddate' ORDER BY time DESC"; ! $slash_q->query($sql); ! while($slash_q->next_record()) { ! GLOBAL $siteurl; $headline = "<B>".format_mail($slash_q->Record["title"],500,true) . "</B><BR>\n"; $headline .= " From the: \"" . $slash_q->Record["dept"] . "\" dept.<BR>\n"; $headline .= " Posted on: \"" . $slash_q->Record["pretty_time"] . "<BR>\n"; $headline .= " Story: " . format_mail(chopit($slash_q->Record["intro_text"]),500,true) . ".</I><BR>\n"; ! $headline .= "<A HREF=\"".$siteurl."/article.php3?story_id=" . $slash_q->Record["story_id"] . "\">Full Story</A>\n"; $headline .= "<BR>---------------------------------------------------------------------------------------------<BR>\n\n"; $headline = stripslashes($headline); *************** *** 399,403 **** } return $thisHead; ! } // mail goes out below here now --- 463,467 ---- } return $thisHead; ! }// end build_html_body() // mail goes out below here now *************** *** 408,416 **** // limit is blank for some reason... ! $limit = ($limit == '')? "0,100":$limit; // if HTML is null ... then select text ! $html = ($html == '')? "0":$html; // if frequency is null, then select DAY ! $frequency = ($frequency == '')? "DAY":$frequency; $sql_query="SELECT email, dayback, frequency" --- 472,480 ---- // limit is blank for some reason... ! $limit = ($limit == '') ? "0,100":$limit; // if HTML is null ... then select text ! $html = ($html == '') ? "0":$html; // if frequency is null, then select DAY ! $frequency = ($frequency == '') ? "DAY":$frequency; $sql_query="SELECT email, dayback, frequency" *************** *** 435,443 **** GLOBAL $html; //first part is the plain text email ! if($html==0) { set_time_limit(0); $header= strip_tags($header); $body = $header; ! $body .= build_body($row[2]); $body .= strip_tags($footer); $subject = $mailsubj; --- 499,518 ---- GLOBAL $html; //first part is the plain text email ! // 2002-06-27 luis: no HTML messages. will ! // put it back later ! //if($html==0) { ! //if ( $row[2] > '' ) { ! ! // 2002-06-27 luis: to avoid empty emails ! // we will check to see if build_body() returns ! // something, else we will just die/leave ! ! $my_message = build_body($row[2]); ! ! if ( $my_message > "" ) { set_time_limit(0); $header= strip_tags($header); $body = $header; ! $body .= $my_message; // takes the body from my_message $body .= strip_tags($footer); $subject = $mailsubj; *************** *** 445,454 **** $headers .= "From:$sender\r\n"; if (mail($row[0], $subject, $body, $headers)) ! echo "\n" . $row[0]. $row[2] . "\n... sent\n"; else $errors[] = $row[0]; $tmpDay = $row[2]; sleep($sleep); ! } //closes if html=0 so that means the HTML goes out from below here else { set_time_limit(0); --- 520,531 ---- $headers .= "From:$sender\r\n"; if (mail($row[0], $subject, $body, $headers)) ! echo "\n" . $row[0]." ". $row[2] . "\n... sent\n"; else $errors[] = $row[0]; $tmpDay = $row[2]; sleep($sleep); ! } // end if $my_message > null ! //} //closes if html=0 so that means the HTML goes out from below here ! /* html disable until further notice else { set_time_limit(0); *************** *** 468,471 **** --- 545,549 ---- sleep($sleep); }//closes else for html = 0 + */ }//closes the mail function ?> |
From: Joe S. <joe...@us...> - 2002-08-13 14:36:37
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv7304/phpslash-ft Modified Files: CHANGES Log Message: HITS in story.tpl and cronmail improvements Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.541 retrieving revision 1.542 diff -C2 -d -r1.541 -r1.542 *** CHANGES 9 Aug 2002 18:21:30 -0000 1.541 --- CHANGES 13 Aug 2002 14:36:33 -0000 1.542 *************** *** 13,16 **** --- 13,21 ---- 9 - Removal of something (kill -9 :) + 2002-August-13 9:00AM CDT Joe Stewart <joe...@us...> + [B] - Story.class, Story_base.class - Added {HITS} placemarker for article + pageviews to story.tpl. + [B] - cronmail.php3 - Luis' improvements to sending newsletters. + 2002-August-09 1:00PM CDT Joe Stewart <joe...@us...> [B] - slashPerm.class - AND, OR permissions tweak. |
From: Joe S. <joe...@us...> - 2002-08-09 18:21:34
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv11590/phpslash-ft Modified Files: CHANGES Log Message: permissions tweak Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.540 retrieving revision 1.541 diff -C2 -d -r1.540 -r1.541 *** CHANGES 7 Aug 2002 19:30:18 -0000 1.540 --- CHANGES 9 Aug 2002 18:21:30 -0000 1.541 *************** *** 13,16 **** --- 13,19 ---- 9 - Removal of something (kill -9 :) + 2002-August-09 1:00PM CDT Joe Stewart <joe...@us...> + [B] - slashPerm.class - AND, OR permissions tweak. + 2002-August-07 2:00PM CDT Joe Stewart <joe...@us...> [B] - basic/sectionNew.tpl, basic/sectionList.tpl - missed update on these |
From: Joe S. <joe...@us...> - 2002-08-09 18:21:34
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv11590/phpslash-ft/class Modified Files: slashPerm.class Log Message: permissions tweak Index: slashPerm.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/slashPerm.class,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** slashPerm.class 23 May 2002 18:41:24 -0000 1.5 --- slashPerm.class 9 Aug 2002 18:21:30 -0000 1.6 *************** *** 95,101 **** while( $j < count($po_ary)) { // boolean AND ! $p_ary = split( ",|&{2}", $po_ary[0]); $i = 0; - $status = true; $max = count($p_ary); while( $i < $max) { --- 95,100 ---- while( $j < count($po_ary)) { // boolean AND ! $p_ary = split( ",|&{2}", $po_ary[$j]); $i = 0; $max = count($p_ary); while( $i < $max) { *************** *** 105,114 **** $k = trim($p_ary[$i]); if( !$ary[$k]) { - $status = false; $i = $max; } $i++; } ! if(!empty($status)) { return true; } elseif(is_array($ary)) { --- 104,112 ---- $k = trim($p_ary[$i]); if( !$ary[$k]) { $i = $max; } $i++; } ! if($i == $max) { return true; } elseif(is_array($ary)) { *************** *** 125,154 **** return false; } ! /* ! function have_perm($p, $ary='') { ! if (! isset($this->auth->auth['perm']) ) { ! $this->auth->auth['perm'] = ""; ! } ! if( !is_array($ary)) { ! $ary = $this->auth->auth['perm']; ! } ! if(!empty($ary[$p])) { ! return true; ! } elseif(is_array($ary)) { ! while(list($k, $v) = each($ary)) { ! if(is_array($ary[$k])) { ! if($this->have_perm($p, $v)) { ! return true; ! } ! } ! } ! // debug("false1" , $p); ! return false; ! } else { ! // debug("false2" , $p); ! return false; ! } ! } ! */ function perm_islisted($perms_ary, $look_for) { if (isset($perms_ary[$look_for]) ) { --- 123,127 ---- return false; } ! function perm_islisted($perms_ary, $look_for) { if (isset($perms_ary[$look_for]) ) { |
From: Joe S. <joe...@us...> - 2002-08-07 19:30:21
|
Update of /cvsroot/phpslash/phpslash-ft/public_html/templates/en/basic In directory usw-pr-cvs1:/tmp/cvs-serv23356/phpslash-ft/public_html/templates/en/basic Modified Files: sectionList.tpl sectionNew.tpl Log Message: basic templates - section admin problems Index: sectionList.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/public_html/templates/en/basic/sectionList.tpl,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sectionList.tpl 14 Jun 2002 21:31:08 -0000 1.4 --- sectionList.tpl 7 Aug 2002 19:30:18 -0000 1.5 *************** *** 5,14 **** <table border="0" cellpadding="3"> <tr> - <td> - <input type="submit" name="submit" value="update" /> - <input type="submit" name="submit" value="delete" /> - </td> - </tr> - <tr> <th>Name</th> <th>Description</th> --- 5,8 ---- *************** *** 19,23 **** <tr class="firstRow"> <td> ! {SECTION_NAME}" </td> <td> --- 13,17 ---- <tr class="firstRow"> <td> ! {SECTION_NAME} </td> <td> *************** *** 48,57 **** </tr> <!-- END row2 --> - <tr> - <td> - <input type="submit" name="submit" value="update" /> - <input type="submit" name="submit" value="delete" /> - </td> - </tr> </table> </form> --- 42,45 ---- Index: sectionNew.tpl =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/public_html/templates/en/basic/sectionNew.tpl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sectionNew.tpl 14 Jun 2002 20:27:01 -0000 1.3 --- sectionNew.tpl 7 Aug 2002 19:30:18 -0000 1.4 *************** *** 3,6 **** --- 3,7 ---- <div id="sectionNew"> <form action="{ACTION_URL}" method="post"> + <input type=hidden name="section_id" value="{SECTION_ID}"> <table border="0"> <tr> *************** *** 28,32 **** <tr> <td> </td> ! <td><input type="submit" name="submit" value="new" /></td> </tr> </table> --- 29,33 ---- <tr> <td> </td> ! <td><input type="submit" name="submit" value="update" /></td> </tr> </table> |
From: Joe S. <joe...@us...> - 2002-08-07 19:30:21
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv23356/phpslash-ft Modified Files: CHANGES Log Message: basic templates - section admin problems Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.539 retrieving revision 1.540 diff -C2 -d -r1.539 -r1.540 *** CHANGES 9 Jul 2002 20:48:09 -0000 1.539 --- CHANGES 7 Aug 2002 19:30:18 -0000 1.540 *************** *** 13,16 **** --- 13,20 ---- 9 - Removal of something (kill -9 :) + 2002-August-07 2:00PM CDT Joe Stewart <joe...@us...> + [B] - basic/sectionNew.tpl, basic/sectionList.tpl - missed update on these + templates. + 2002-July-09 1:00PM CDT Joe Stewart <joe...@us...> [B] - Block.class - [ 578685 ] html block edit adds backslashes - krabu. |
From: Joe S. <joe...@us...> - 2002-07-09 20:48:14
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv16964/phpslash-ft Modified Files: CHANGES Log Message: block title slash problem Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.538 retrieving revision 1.539 diff -C2 -d -r1.538 -r1.539 *** CHANGES 9 Jul 2002 20:34:56 -0000 1.538 --- CHANGES 9 Jul 2002 20:48:09 -0000 1.539 *************** *** 13,16 **** --- 13,19 ---- 9 - Removal of something (kill -9 :) + 2002-July-09 1:00PM CDT Joe Stewart <joe...@us...> + [B] - Block.class - [ 578685 ] html block edit adds backslashes - krabu. + 2002-July-09 3:30PM CDT Joe Stewart <joe...@us...> [S] - slash-all.sql, 65_to_7.sql - psl_block - title field expanded to |
From: Joe S. <joe...@us...> - 2002-07-09 20:48:14
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv16964/phpslash-ft/class Modified Files: Block.class Log Message: block title slash problem Index: Block.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Block.class,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Block.class 7 Jun 2002 16:24:04 -0000 1.14 --- Block.class 9 Jul 2002 20:48:10 -0000 1.15 *************** *** 227,231 **** while ( list($key, $val) = each($block_array) ) { ! $block_array[$key] = addslashes($val); } --- 227,231 ---- while ( list($key, $val) = each($block_array) ) { ! $block_array[$key] = clean($val,true); } |
From: Joe S. <joe...@us...> - 2002-07-09 20:35:00
|
Update of /cvsroot/phpslash/phpslash-ft In directory usw-pr-cvs1:/tmp/cvs-serv12793/phpslash-ft Modified Files: CHANGES Log Message: expanded block title length Index: CHANGES =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/CHANGES,v retrieving revision 1.537 retrieving revision 1.538 diff -C2 -d -r1.537 -r1.538 *** CHANGES 9 Jul 2002 19:48:46 -0000 1.537 --- CHANGES 9 Jul 2002 20:34:56 -0000 1.538 *************** *** 13,16 **** --- 13,20 ---- 9 - Removal of something (kill -9 :) + 2002-July-09 3:30PM CDT Joe Stewart <joe...@us...> + [S] - slash-all.sql, 65_to_7.sql - psl_block - title field expanded to + 255 chars from 30. + 2002-July-09 1:00PM CDT Joe Stewart <joe...@us...> [B] - Author.class - [ 577877 ] Author.class - misplaced bracket - krabu. |