cvs: php-master-web /fetch events.php index.php mirrors.php user-notes.php

From: Date: Fri, 21 Sep 2001 19:01:10 +0000
Subject: cvs: php-master-web /fetch events.php index.php mirrors.php user-notes.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-6539@lists.php.net to get a copy of this message
jimw Fri Sep 21 15:01:10 2001 EDT Added files: /php-master-web/fetch events.php index.php mirrors.php user-notes.php Log: code for fetching events, mirror list, and user-notes Index: php-master-web/fetch/events.php +++ php-master-web/fetch/events.php <?php # token required, since this should only get accessed from rsync.php.net if (!isset($token) || md5($token) != "19a3ec370affe2d899755f005e5cd90e") die("token not correct."); @mysql_connect('localhost','nobody','') or exit; @mysql_select_db('php3') or exit; $re = array(1=>'First',2=>'Second',3=>'Third',4=>'Fourth',-1=>'Last',-2=>'2nd Last',-3=>'3rd Last'); if(!isset($a)) { if(isset($HTTP_GET_VARS['a'])) $a = $HTTP_GET_VARS['a']; else $a=0; } if (!isset($cm)) $cm = (int)strftime('%m'); if (!isset($cy)) $cy = (int)strftime('%Y'); if (!isset($cd)) $cd = (int)strftime('%d'); if (!isset($nm)) $nm = 1; while ($nm) { $entries = load_month($cy,$cm); $last = last_day($cy,$cm); for ($i=$cd; $i<=$last; $i++) { if (is_array($entries[$i])) foreach($entries[$i] as $row) { echo "$i,$cm,$cy,\"http://www.php.net/cal.php?cm=$cm&cy=$cy&ev=", $row['id'], "\",\"", addslashes($row['sdesc']), "\"\n"; } } $nm--; $cd = 1; if($nm) { $cm++; if($cm==13) { $cy++; $cm=1; } } } /* * Find the first, second, third, last, second-last etc. weekday of a month * * args: day 1 = Monday * which 1 = first * 2 = second * 3 = third * -1 = last * -2 = second-last */ function weekday($year, $month, $day, $which) { $ts = mktime(12,0,0,$month+(($which>0)?0:1),($which>0)?1:0,$year); $done = false; $match = 0; $inc = 3600*24; while(!$done) { if(strftime('%w',$ts)==$day-1) { $match++; } if($match==abs($which)) $done=true; else $ts += (($which>0)?1:-1)*$inc; } return $ts; } function load_unapproved_events() { global $re; $days = days(); $result = mysql_query("select * from phpcal where approved=0 order by sdato"); if(!$result) echo mysql_error(); else { while($row = mysql_fetch_array($result)) { switch($row['tipo']) { case 1: $events[] = array($row['id'],$row['sdato'],$row['sdesc'],$row['ldesc'],$row['url']); break; case 2: $events[] = array($row['id'],$row['sdato'].' to '.$row['edato'],$row['sdesc'],$row['ldesc'],$row['url']); break; case 3: list($which,$day) = explode(':',$row['recur']); $events[] = array($row['id'],'Every '.$re[(int)$which].' '.$days[$day],$row['sdesc'],$row['ldesc'],$row['url']); break; } } } return $events; } function load_month($year, $month) { $result = mysql_query("select * from phpcal where (((MONTH(sdato)=$month or MONTH(edato)=$month) and (YEAR(sdato)=$year or YEAR(edato)=$year) and tipo<3) or tipo=3) and approved=1"); if(!$result) echo mysql_error(); else { while($row = mysql_fetch_array($result)) { switch($row['tipo']) { case 1: list(,,$dd) = explode('-',$row['sdato']); $events[(int)$dd][] = $row; break; case 2: list(,$mm,$dd) = explode('-',$row['sdato']); list(,$m2,$d2) = explode('-',$row['edato']); if((int)$mm==(int)$m2) { for($i=(int)$dd; $i<=(int)$d2; $i++) { $events[$i][] = $row; } } elseif((int)$mm==$month) { for($i=(int)$dd; $i<32; $i++) { $events[$i][] = $row; } } else { for($i=1; $i<=(int)$d2; $i++) { $events[$i][] = $row; } } break; case 3: list($which,$dd) = explode(':',$row['recur']); $ts = weekday($year,$month,$dd,$which); $events[(int)strftime('%d',$ts)][] = $row; break; } } } return($events); } function start_month($year, $month) { $ts = mktime(12,0,0,$month,1,$year); return strftime('%w',$ts); } function last_day($year,$month) { $ts = mktime(12,0,0,$month+1,0,$year); return strftime('%e',$ts); } function months() { static $months=NULL; if(!$months) for($i=1;$i<=12;$i++) { $months[$i] = strftime('%B',mktime(12,0,0,$i,1)); } return $months; } /* returns array of Days starting with 1 = Sunday */ function days() { static $days=NULL; if(!$days) for($i=1;$i<=7;$i++) { $days[$i] = strftime('%A',mktime(12,0,0,4,$i,2001)); } return $days; } Index: php-master-web/fetch/index.php +++ php-master-web/fetch/index.php <?php header("http://www.php.net/"); ?> Index: php-master-web/fetch/mirrors.php +++ php-master-web/fetch/mirrors.php <?php # token required, since this should only get accessed from rsync.php.net if (!isset($token) || md5($token) != "19a3ec370affe2d899755f005e5cd90e") die("token not correct."); // Connect and generate the list from the DB if (@mysql_connect("localhost","nobody","")) { if (@mysql_select_db("php3")) { $res = @mysql_query("SELECT * FROM mirrors ORDER BY cc"); if ($res) { echo "<?php\n\$MIRRORS = array(\n"; while ($row = @mysql_fetch_array($res)) { if (!strstr("http:",$row[hostname])) { $row[hostname]="http://$row[hostname]/"; } // Set inactive mirrors to type 2 so they won't show up in the drop-down. if (!$row["active"]) { $row["mirrortype"] = 2; } echo " \"$row[hostname]\" => array(\"$row[cc]\",\"$row[providername]\",$row[has_stats],\"$row[providerurl]\",$row[mirrortype],$row[has_search],\"$row[lang]\"),\n"; } echo ' 0 => array("xx", "Unknown", 0, "/", 2, 0, "en")', "\n"; echo ");\n"; echo "?>\n"; } } } Index: php-master-web/fetch/user-notes.php +++ php-master-web/fetch/user-notes.php <?php # token required, since this should only get accessed from rsync.php.net if (!isset($token) || md5($token) != "19a3ec370affe2d899755f005e5cd90e") die("token not correct."); @mysql_connect("localhost","nobody","") or exit; @mysql_select_db("php3") or exit; if ($since) { mysql_query("CREATE TEMPORARY TABLE updated TYPE = HEAP SELECT DISTINCT sect FROM note WHERE ts > FROM_UNIXTIME($since) OR updated > FROM_UNIXTIME($since) OR removed") or exit; # purge entries marked for removal mysql_query("DELETE FROM note WHERE removed"); } $query = "SELECT DISTINCT id,note.sect,user,note,UNIX_TIMESTAMP(ts) AS ts,"; $query .= "IF(votes=0, 10, rating/votes) AS rate"; $query .= " FROM note"; if ($since) { $query .= ",updated WHERE note.sect=updated.sect AND NOT removed"; } else { $query .= " WHERE NOT removed"; } $query .= " ORDER BY sect,rate DESC,ts"; $res = @mysql_query($query) or exit; while ($row = mysql_fetch_array($res)) { # get rid of the ordered fields, we just want the named ones. for ($i = count($row) / 2; $i >= 0; $i--) unset($row[$i]); echo "$row[id]|$row[sect]|$row[rate]|$row[ts]|$row[user]|", base64_encode(gzcompress($row[note],3)),"\n"; }

« previous php.mirrors (#6539) next »