cvs: php-gtk-web /include config.inc cvs-auth.inc layout.php shared-manual.inc

[email protected] ("Steph Fox") Sun, 09 Jul 2006 08:37:09 -0000
Newsgroups php.gtk.webmaster
Message-ID <cvssfox1152434229@cvsserver>
sfox		Sun Jul  9 08:37:09 2006 UTC

  Modified files:              
    /php-gtk-web/include	config.inc cvs-auth.inc layout.php 
                        	shared-manual.inc 
  Log:
  This might break the site (more to come)
sfox-20060709083709.txt (text/plain, 14.5 KB)
http://cvs.php.net/viewvc.cgi/php-gtk-web/include/config.inc?r1=1.4&r2=1.5&diff_format=u
Index: php-gtk-web/include/config.inc
diff -u php-gtk-web/include/config.inc:1.4 php-gtk-web/include/config.inc:1.5
--- php-gtk-web/include/config.inc:1.4	Sat Jul  8 18:13:30 2006
+++ php-gtk-web/include/config.inc	Sun Jul  9 08:37:09 2006
@@ -7,18 +7,35 @@
 /* filepaths */
 define('DB_DIR', '/local/Web/php-gtk-notes-db');
 
-$notesfile =  DB_DIR.'/gtknotes.sqlite';
-$queuefile =  DB_DIR.'/gtkqueue.sqlite';
-$blockfile =  DB_DIR.'/gtkblocked.txt';
-$stats     =  DB_DIR.'/gtkstats.txt';
-$last_id   =  DB_DIR.'/gtklastid.txt';
-$okfile    =  DB_DIR.'/gtkgolive.txt';
-
-/* NOTE: none of this can be seen from shared-manual.inc... */
+/**
+ * NOTE: We need a stable 'lastid' because the databases are out of
+ * sync, both with each other and with the mail archives we're currently
+ * using to monitor activity. If we 'lose' the mail part in the future
+ * (which we probably will if it's all looking stable) we can move to
+ * using sqlite_last_insert_rowid(). Just in case y'all wondered :)
+ */
+$notesfile  =  DB_DIR.'/gtknotes.sqlite';
+$queuefile  =  DB_DIR.'/gtkqueue.sqlite';
+$blockfile  =  DB_DIR.'/gtkblocked.txt';
+$stats      =  DB_DIR.'/gtkstats.txt';
+$last_id    =  DB_DIR.'/gtklastid.txt';
+$okfile     =  DB_DIR.'/gtkgolive.txt';
 
 /* db update checks. Settings of 15, 10 and 2 could have prevented phpdoc's last attack */
 $recent     = strtotime("15 minutes ago");
 $veryrecent = strtotime("10 minutes ago");
 $likely     = 2;
 
+/* some things need restricted access */
+$systems = array('andrei', 'sfox');
+$docteam = array('andrei', 'cweiske', 'sfox', 'anant', 'scottmattocks');
+
+$user = get_user();
+if ($user && isset($_COOKIE[$user])) {
+	$mailto    = $_COOKIE[$user];
+	$notesfile = DB_DIR."/$user.notes.sqlite";
+	$queuefile = DB_DIR."/$user.queue.sqlite";
+	$last_id   = DB_DIR."/$user.lastid.txt";
+}
+
 ?>
http://cvs.php.net/viewvc.cgi/php-gtk-web/include/cvs-auth.inc?r1=1.6&r2=1.7&diff_format=u
Index: php-gtk-web/include/cvs-auth.inc
diff -u php-gtk-web/include/cvs-auth.inc:1.6 php-gtk-web/include/cvs-auth.inc:1.7
--- php-gtk-web/include/cvs-auth.inc:1.6	Fri Jul  7 13:32:36 2006
+++ php-gtk-web/include/cvs-auth.inc	Sun Jul  9 08:37:09 2006
@@ -1,8 +1,8 @@
 <?php
-/* $Id: cvs-auth.inc,v 1.6 2006/07/07 13:32:36 sfox Exp $ */
+/* $Id: cvs-auth.inc,v 1.7 2006/07/09 08:37:09 sfox Exp $ */
 require_once('config.inc');
 
-function get_auth($name, $pass, $connect=null) {
+function get_auth($name, $pass, $connect = null) {
 
 	static $cvs_encode = array(
 		32, 120,  53,  35,  36, 109,  72, 108,
@@ -51,13 +51,13 @@
 
 	if (strlen($user) > 0 && strlen($pass) > 0) {
 
-		if (!isset($_COOKIE['GTK'])) {
+		if (!isset($_COOKIE['PHP-GTK'])) {
 
 			$auth = get_auth($user, $pass, true);
 
 			if ($auth == true) {
 				$encoded = get_auth($user, $pass);
-				setcookie('GTK', base64_encode($user.':'.$encoded), time()+(3600*24), '/');
+				setcookie('PHP-GTK', base64_encode($user.':'.$encoded), time()+(3600*24), '/');
 				file_put_contents(DB_DIR."/$user.txt", $encoded);
 			}
 		}
@@ -67,8 +67,8 @@
 
 function get_user() {
 
-	if (isset($_COOKIE['GTK'])) {
-		list($user, $pass) = explode(':', base64_decode($_COOKIE['GTK']));
+	if (isset($_COOKIE['PHP-GTK'])) {
+		list($user, $pass) = explode(':', base64_decode($_COOKIE['PHP-GTK']));
 		$stored = file_get_contents(DB_DIR."/$user.txt");
 		if ($pass == $stored) {
 			return $user;
http://cvs.php.net/viewvc.cgi/php-gtk-web/include/layout.php?r1=1.54&r2=1.55&diff_format=u
Index: php-gtk-web/include/layout.php
diff -u php-gtk-web/include/layout.php:1.54 php-gtk-web/include/layout.php:1.55
--- php-gtk-web/include/layout.php:1.54	Fri Jul  7 15:37:39 2006
+++ php-gtk-web/include/layout.php	Sun Jul  9 08:37:09 2006
@@ -1,10 +1,10 @@
 <?php
-/* $Id: layout.php,v 1.54 2006/07/07 15:37:39 sfox Exp $ */
+/* $Id: layout.php,v 1.55 2006/07/09 08:37:09 sfox Exp $ */
 
 # spacer()
 # print a IMG tag for a sized spacer GIF
 #
-function spacer($width=1, $height=1, $align=false, $extras=false) {
+function spacer($width = 1, $height = 1, $align = false, $extras = false) {
     printf('<img src="/gifs/spacer.gif" width="%d" height="%d" border="0" alt="" %s%s />',
         $width,
         $height,
@@ -16,7 +16,7 @@
 # resize_image()
 # tag the output of make_image() and resize it manually
 #
-function resize_image($img, $width=1, $height=1) {
+function resize_image($img, $width = 1, $height = 1) {
     $str = preg_replace('/width=\"([0-9]+?)\"/i', '', $img);
     $str = preg_replace('/height=\"([0-9]+?)\"/i', '', $str);
     $str = substr($str, 0, -1) . sprintf(' height="%s" width="%s">', $height, $width);
@@ -26,9 +26,8 @@
 # make_image()
 # return an IMG tag for a given file (relative to the images dir)
 #
-function make_image($file, $alt=false, $align=false, $extras=false, $dir=false, $border=0) {
+function make_image($file, $alt = false, $align = false, $extras = false, $dir = false, $border = 0) {
     if (!$dir) {
-        // ALTER FOR LOCAL $dir = '../../php-gtk-web/gifs';
         $dir = "/gifs";
     }
 
@@ -58,16 +57,15 @@
 # print_image()
 # print an IMG tag for a given file
 #
-function print_image($file, $alt=false, $align=false, $extras=false, $dir=false, $border=0) {
+function print_image($file, $alt = false, $align = false, $extras = false, $dir = false, $border = 0) {
     print make_image($file, $alt, $align, $extras, $dir);
 }
 
 # make_submit()
 #  - make a submit button image
 #
-function make_submit($file, $alt=false, $align=false, $extras=false, $dir=false, $border=0) {
+function make_submit($file, $alt = false, $align = false, $extras = false, $dir = false, $border = 0) {
     if (!$dir) {
-        //ALTER FOR LOCAL $dir = '../../php-gtk-web/gifs';
         $dir = "/gifs";
     }
 
@@ -80,11 +78,11 @@
 # delim()
 # print a pipe delimiter
 #
-function delim($color=false) {
+function delim($color = false) {
     if (!$color) {
         return '&nbsp;|&nbsp;';
     }
-    return sprintf('<font color="%s">&nbsp;|&nbsp;</font>', $color);
+    return sprintf('<span style="color: %s">&nbsp;|&nbsp;</span>', $color);
 }
 
 # hdelim()
@@ -109,14 +107,14 @@
 # print_link()
 # echo a hyperlink to something, within the site
 #
-function print_link($url, $linktext=false, $target=false, $extras=false) {
+function print_link($url, $linktext = false, $target = false, $extras = false) {
     echo make_link($url, $linktext, $target, $extras);
 }
 
 # make_email()
 # make an e-mail hyperlink
 # 
-function make_email($email, $linktext=false) {
+function make_email($email, $linktext = false) {
     return sprintf("<a href=\"mailto:%s\">%s</a>",
         $email,
         ($linktext ? $linktext : $email)
@@ -126,14 +124,14 @@
 # print_email()
 # echo an e-mail hyperlink
 # 
-function print_email($email, $linktext=false) {
+function print_email($email, $linktext = false) {
     echo make_email($email, $linktext);
 }
 
 # commonheader()
 #
 #
-function commonHeader($title=false, $padding=true) {
+function commonHeader($title = false, $padding = true) {
 	global $SIDEBAR_DATA;
 	ob_start();
 ?>
@@ -176,15 +174,15 @@
      print_link('/changelog.php', 'changelog', false, 'class="menuBlack"');
      echo delim();
      print_link('/resources.php', 'resources', false, 'class="menuBlack"');
-     if (isset($_COOKIE['GTK'])) {
+     if (isset($_COOKIE['PHP-GTK'])) {
          echo delim();
          print_link('/admin-logout.php', 'logout', false, 'class="menuBlack"');
      }
     ?>&nbsp;<br />
-    <?php spacer(2,2); ?><br />
+    <?php spacer(2, 2); ?><br />
    </td>
   </tr>
-  <tr bgcolor="#000033"><td colspan="2"><?php spacer(1,1); ?><br /></td></tr>
+  <tr bgcolor="#000033"><td colspan="2"><?php spacer(1, 1); ?><br /></td></tr>
   <tr bgcolor="#006699">
    <td align="right" valign="top" colspan="2" nowrap>
     <form method="post" action="/search.php" style="display:inline">
@@ -206,7 +204,7 @@
     </form>
    </td>
   </tr>
-  <tr bgcolor="#000033"><td colspan="2"><?php spacer(1,1) ;?><br /></td></tr>
+  <tr bgcolor="#000033"><td colspan="2"><?php spacer(1, 1) ;?><br /></td></tr>
  </table>
 
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
@@ -221,7 +219,7 @@
      </tr>
     </table>
    </td>
-   <td bgcolor="#CCCCCC" style="background-image:url(/gifs/checkerboard.gif)"><?php spacer(1,1); ?><br /></td>
+   <td bgcolor="#CCCCCC" style="background-image:url(/gifs/checkerboard.gif)"><?php spacer(1, 1); ?><br /></td>
     <?php endif; ?>
    <td>
     <table width="100%" cellpadding="<?php if ($padding) { print("10"); } else { print("0"); } ?>" cellspacing="0">
@@ -245,7 +243,7 @@
     </table>
    </td>
    <?php if (isset($RIGHT_SIDEBAR_DATA)): ?>
-   <td bgcolor="#CCCCCC" style="background-image:url(/gifs/checkerboard.gif)"><?php spacer(1,1); ?><br /></td>
+   <td bgcolor="#CCCCCC" style="background-image: url(/gifs/checkerboard.gif)"><?php spacer(1, 1); ?><br /></td>
    <td width="170" bgcolor="#F0F0F0">
     <table width="100%" cellpadding="4" cellspacing="0">
      <tr valign="top">
@@ -295,76 +293,6 @@
 <?php
 }
 
-# clean_note()
-#
-#
-function clean_note($text) {
-    $text = htmlentities($text);
-    $allowed = array(
-        'from' => array(
-            '&lt;br&gt;', 
-            '&lt;br /&gt;', 
-            '&lt;br/&gt;', 
-            '&lt;p&gt;', 
-            '&lt;/p&gt;', 
-            '&lt;b&gt;',
-            '&lt;/b&gt;',
-            '&lt;strong&gt;',
-            '&lt;/strong&gt;',
-            '&lt;i&gt;',
-            '&lt;/i&gt;',
-            '&lt;em&gt;',
-            '&lt;/em&gt;'
-        ),
-        'to' => array(
-            '<br />', 
-            '<br />', 
-            '<br />', 
-            '<p>', 
-            '</p>',
-            '<b>',
-            '</b>',
-            '<strong>',
-            '</strong>',
-            '<i>',
-            '</i>',
-            '<em>',
-            '</em>'
-        )
-    );
-    foreach ($fixes as $f) {
-        $text = str_ireplace($allow['from'], $allowed['to'], $text);
-    }
-	$text = '<tt>' . nl2br($text) . '</tt>';
-	return $text;
-}
-
-# sect_to_file()
-#
-#
-function sect_to_file($string) {
-    $string = strtolower($string);
-    $string = str_replace(' ', '-', $string);
-    $string = str_replace('_', '-', $string);
-
-    $func   = "function.$string.php";
-    $chap   = "ref.$string.php";
-    $feat   = "features.$string.php";
-    $struct = "control-structures.$string.php";
-
-    if (is_file($func)) {
-        return $func;
-    } elseif (is_file($chap)) {
-        return $chap;
-    } elseif (is_file($feat)) {
-        return $feat;
-    } elseif (is_file($struct)) {
-        return $struct;
-    } else {
-        return "$string.php";
-    }
-}
-
 function stretchPage($pixels) {
 	$div = "<div style = 'margin: ".$pixels."%'>";
 	return $div;
http://cvs.php.net/viewvc.cgi/php-gtk-web/include/shared-manual.inc?r1=1.71&r2=1.72&diff_format=u
Index: php-gtk-web/include/shared-manual.inc
diff -u php-gtk-web/include/shared-manual.inc:1.71 php-gtk-web/include/shared-manual.inc:1.72
--- php-gtk-web/include/shared-manual.inc:1.71	Sat Jul  8 18:37:31 2006
+++ php-gtk-web/include/shared-manual.inc	Sun Jul  9 08:37:09 2006
@@ -1,5 +1,7 @@
 <?php
 
+require_once('cvs-auth.inc');
+
 define('NAV_NONE', 0);
 define('NAV_CLASSENTRY', 1);
 define('NAV_CONSTRUCTOR', 2);
@@ -105,7 +107,7 @@
 }
 
 function navigationBar($title, $id, $loc) {
-	global $NEXT, $PREV, $tstamp;
+	global $NEXT, $PREV, $tstamp, $LANGUAGES, $man2_languages;
 
 	echo '<table border="0" width="100%" bgcolor="#e0e0e0" cellpadding="0" cellspacing="4">';
 	echo '<tr><td>';
@@ -129,14 +131,11 @@
 	echo '<tr>';
 	echo '<td align="right" colspan="2"><small>Last updated: '.$tstamp.'<br />';
 
-	global $LANGUAGES, $man2_languages;
 	$links = array();
 
-	if ($LANGUAGES){
-		foreach($LANGUAGES as $code=>$name) {
-			if (in_array($code, $man2_languages) && file_exists("../$code/$id")) {
-				$links[] = make_link("../$code/$id", $name);
-			}
+	foreach($LANGUAGES as $code=>$name) {
+		if (in_array($code, $man2_languages) && file_exists("../$code/$id")) {
+			$links[] = make_link("../$code/$id", $name);
 		}
 	}
 
@@ -178,12 +177,11 @@
 	echo "<br />\n</td>\n";
 	echo "<td align='right' nowrap><small>";
 
-	if (isset($_COOKIE['GTK']) && $show_admin) {
+	if (get_user() && $show_admin) {
 
-		$get = isset($_GET['let']) ? "&let={$_GET['let']}" : null;
-		if (!$get) {
-			$get = isset($_GET['y']) ? "&y={$_GET['y']}" : null;
-		}
+		$get = (isset($_POST['queue']) || array_key_exists('q', $_GET)) ? '&q': null;
+		$get .= isset($_GET['let']) ? "&let={$_GET['let']}" : null;
+		$get .= isset($_GET['y']) ? "&y={$_GET['y']}" : null;
 
 		print_link("{$_SERVER['PHP_SELF']}?edit={$row['id']}$get",
 			make_image('notes-edit.gif', 'edit note'));
@@ -280,11 +278,13 @@
 
 function manualGetUserNotes($id) {
 
+	global $okfile, $notesfile;
+
 	$notes = array();
 
-	if (file_exists('/local/Web/php-gtk-notes-db/gtkgolive.txt') || isset($_COOKIE['GTK'])) {
+	if (file_exists($okfile) || $user = get_user()) {
 
-		$db = sqlite_open('/local/Web/php-gtk-notes-db/gtknotes.sqlite');
+		$db = sqlite_open($notesfile);
 		$result = sqlite_array_query($db, "SELECT * FROM notes WHERE page = '$id' ORDER BY date DESC");
 		foreach ($result as $row) {
 			$notes[] = $row;
@@ -379,7 +379,19 @@
 
 	$SIDEBAR_DATA = "<form method='POST' action='browse-notes.php'>\n".
 	"<table border='0' cellpadding='0' cellspacing='0' align='center'>\n".
-	"<tr><td valign='bottom' colspan='3'><br /><b>Order by:</b></td></tr>\n".
+	"<tr><td valign='top' colspan='3'><br />\n".
+	make_link('../admin-login.php', '<b>Admin home</b>')."<br />\n<br />\n</td></tr>\n";
+	if (strstr($_SERVER['PHP_SELF'], '/manual/browse-notes.php')) {
+		$SIDEBAR_DATA .= "<tr><td valign='top' colspan='3'>\n";
+		if (!isset($_POST['queue']) && !array_key_exists('q', $_GET)) {
+			$SIDEBAR_DATA .= make_link($_SERVER['PHP_SELF'].'?q','<b>Queue administration</b>');
+		} else {
+			$SIDEBAR_DATA .= make_link($_SERVER['PHP_SELF'],'<b>Notes administration</b>').
+			"<input type='hidden' name='queue' value='1' />";
+		}
+		$SIDEBAR_DATA .= "<br />\n<br />\n</td></tr>\n";
+	}
+	$SIDEBAR_DATA .= "<tr><td valign='bottom' colspan='3'><br /><b>Order notes by:</b></td></tr>\n".
 	"<tr><td valign='top'><br />page (default)</td>\n".
 	"<td colspan='2'><br /><input type='radio' name='order' value='page'";
 	if ($order == 'page') $SIDEBAR_DATA .= " checked";
@@ -392,7 +404,7 @@
 	"<td><input type='radio' name='order' value='date'";
 	if ($order == 'date') $SIDEBAR_DATA .= " checked";
 	$SIDEBAR_DATA .= " /></td>\n<td>&nbsp;&nbsp;".
-	make_submit('small_submit.gif', 'Order by', 'bottom').
+	make_submit('small_submit.gif', 'Order by', 'bottom', "height='11', width='11'").
 	"</td></tr>\n</table>\n</form>\n";
 }