cvs: php-master-web /fetch stats.php /include functions.inc login.inc /manage user-notes.php
| From: | Gabor Hojtsy | Date: | Thu, 10 Jun 2004 09:21:11 +0000 |
| Subject: | cvs: php-master-web /fetch stats.php /include functions.inc login.inc /manage user-notes.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-24917@lists.php.net to get a copy of this message | ||
goba Thu Jun 10 05:21:11 2004 EDT
Modified files:
/php-master-web/fetch stats.php
/php-master-web/include functions.inc login.inc
/php-master-web/manage user-notes.php
Log:
introduce require_token() and connection without dying (used on pages called from cron and not
seen by humans)
http://cvs.php.net/diff.php/php-master-web/fetch/stats.php?r1=1.3&r2=1.4&ty=u
Index: php-master-web/fetch/stats.php
diff -u php-master-web/fetch/stats.php:1.3 php-master-web/fetch/stats.php:1.4
--- php-master-web/fetch/stats.php:1.3 Sat Sep 6 01:09:07 2003
+++ php-master-web/fetch/stats.php Thu Jun 10 05:21:10 2004
@@ -1,14 +1,13 @@
<?php
-require 'functions.inc';
+// $Id: stats.php,v 1.4 2004/06/10 09:21:10 goba Exp $
-# token required, since this should only get accessed from rsync.php.net
-if (!isset($token) || md5($token) != "19a3ec370affe2d899755f005e5cd90e")
- die("token not correct.");
+include_once 'functions.inc';
-// Connect and generate the list from the DB
-if (@mysql_connect("localhost","nobody","")) {
- echo mysql_get_one("SELECT COUNT(*) FROM php3.note"), "\n";
- echo mysql_get_one("SELECT COUNT(*) FROM phphosts.hosts"), "\n";
- echo mysql_get_one("SELECT COUNT(*) FROM php3.bugdb"), "\n";
- echo mysql_get_one("SELECT COUNT(*) FROM php3.bugdb WHERE status='Open' OR
status='Assigned' OR status='Analyzed' OR status='Critical'"),
"\n";
+require_token();
+
+if (db_connect(FALSE)) {
+ echo db_get_one("SELECT COUNT(*) FROM php3.note"), "\n";
+ echo db_get_one("SELECT COUNT(*) FROM phphosts.hosts"), "\n";
+ echo db_get_one("SELECT COUNT(*) FROM php3.bugdb"), "\n";
+ echo db_get_one("SELECT COUNT(*) FROM php3.bugdb WHERE status IN ('Open',
'Assigned', 'Analyzed', 'Critical')"), "\n";
}
http://cvs.php.net/diff.php/php-master-web/include/functions.inc?r1=1.10&r2=1.11&ty=u
Index: php-master-web/include/functions.inc
diff -u php-master-web/include/functions.inc:1.10 php-master-web/include/functions.inc:1.11
--- php-master-web/include/functions.inc:1.10 Thu Jun 10 05:08:41 2004
+++ php-master-web/include/functions.inc Thu Jun 10 05:21:10 2004
@@ -1,5 +1,15 @@
<?php
-// $Id: functions.inc,v 1.10 2004/06/10 09:08:41 goba Exp $
+// $Id: functions.inc,v 1.11 2004/06/10 09:21:10 goba Exp $
+
+// -----------------------------------------------------------------------------------
+
+// used in scripts which should only be called from particular machines
+function require_token()
+{
+ if (!isset($_GET['token']) || md5($_GET['token']) !=
"19a3ec370affe2d899755f005e5cd90e") {
+ die("Token not correct.");
+ }
+}
// -----------------------------------------------------------------------------------
@@ -41,6 +51,23 @@
// -----------------------------------------------------------------------------------
+function db_connect($dieonerror = TRUE)
+{
+ if (!@mysql_connect("localhost", "nobody", "")) {
+ if ($dieonerror) {
+ die(format_warn("Unable to connect to database!"));
+ }
+ return FALSE;
+ }
+ elseif (!@mysql_select_db("php3")) {
+ if ($dieonerror) {
+ die(format_warn("Unable to select database!"));
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+
function db_query($query)
{
$res = @mysql_query($query);
@@ -50,21 +77,17 @@
return $res;
}
-function db_connect()
+
+function db_get_one($query)
{
- @mysql_connect("localhost", "nobody", "")
- or die(format_warn("Unable to connect to database!"));
- @mysql_select_db("php3")
- or die(format_warn("Unable to select database!"));
+ $res = @mysql_query($query);
+ if ($res && mysql_num_rows($res)) {
+ return mysql_result($res, 0);
+ }
+ return FALSE;
}
-function mysql_get_one($query) {
- $res = mysql_query($query);
- if ($res && mysql_num_rows($res)) {
- return mysql_result($res,0);
- }
- return false;
-}
+// -----------------------------------------------------------------------------------
function array_to_url($array,$overlay=0) {
if ($overlay) $array = array_merge($array,$overlay);
http://cvs.php.net/diff.php/php-master-web/include/login.inc?r1=1.5&r2=1.6&ty=u
Index: php-master-web/include/login.inc
diff -u php-master-web/include/login.inc:1.5 php-master-web/include/login.inc:1.6
--- php-master-web/include/login.inc:1.5 Thu Jun 10 05:08:41 2004
+++ php-master-web/include/login.inc Thu Jun 10 05:21:10 2004
@@ -1,5 +1,5 @@
<?php
-/* $Id: login.inc,v 1.5 2004/06/10 09:08:41 goba Exp $ */
+/* $Id: login.inc,v 1.6 2004/06/10 09:21:10 goba Exp $ */
include_once 'cvs-auth.inc';
@@ -30,7 +30,7 @@
<title>You must log in!</title>
</head>
<body>
-<form method="post" action="<?php echo $PHP_SELF,
query_string();?>">
+<form method="post" action="<?php echo $_SERVER['PHP_SELF'],
query_string();?>">
<?php echo preserve_form_fields();?>
<input type="hidden" name="save" value="1" />
<table>
http://cvs.php.net/diff.php/php-master-web/manage/user-notes.php?r1=1.42&r2=1.43&ty=u
Index: php-master-web/manage/user-notes.php
diff -u php-master-web/manage/user-notes.php:1.42 php-master-web/manage/user-notes.php:1.43
--- php-master-web/manage/user-notes.php:1.42 Thu Jun 10 05:08:41 2004
+++ php-master-web/manage/user-notes.php Thu Jun 10 05:21:10 2004
@@ -1,5 +1,5 @@
<?php
-// $Id: user-notes.php,v 1.42 2004/06/10 09:08:41 goba Exp $
+// $Id: user-notes.php,v 1.43 2004/06/10 09:21:10 goba Exp $
// Force login before action can be taken
include_once 'login.inc';