"Fossies" - the Fresh Open Source Software Archive

Member "node-runner-0.6.0/sql/update-nr-to-v0.4.2.php" (22 Dec 2004, 2147 Bytes) of package /linux/www/old/node-runner-0.6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 
    3 // This file is used to upgrade the database tables from Node Runner
    4 // v0.4 thru 4.1 to v0.4.2.  If you need to upgrade from an older version, you
    5 // MUST run each of the older update files first.  It is HIGHLY
    6 // recommended that you just use the install script (select UPGRADE),
    7 // but if you absolutely *need* to update the database manually,
    8 // you can fill in the values below can call the script from the
    9 // php interpreter.  Otherwise, leave them blank.
   10 
   11 $database_host = '';
   12 $database_name = '';
   13 $database_user = '';
   14 $database_pass = '';
   15 
   16 if (!$dbhost) { $dbhost = $database_host; }
   17 if (!$db) { $db = $database_name; }
   18 if (!$dbuser) { $dbhost = $database_user; }
   19 if (!$dbpass) { $dbhost = $database_pass; }
   20 
   21 if ($database_host && $database_name && $database_user && $database_pass) {
   22   unset($err_msg);
   23   $connect = mysql_connect($database_host,$database_user,$database_pass);
   24   if (!$connect) { $err_msg .= mysql_error()."\n"; }
   25 }
   26 
   27 
   28 # DATABASE CHANGELOG:
   29 # 1) Adds days column to objects table for ability to query nodes
   30 #    on specified days.
   31 # 2) Adds resolved column to alert_log for re-polling.
   32 # 3) Sets default days to all.
   33 # 4) Sets default resolved to Y.
   34 #    (recommend making sure all nodes are working before updating db tables.)
   35 
   36 $query1 = "ALTER TABLE objects ADD days varchar(27) NOT NULL";
   37 $result1 = mysql_db_query($db, $query1);
   38 if (!$result1) {
   39     $err_msg .= mysql_error()."\n";
   40 }
   41 
   42 $query2 = "ALTER TABLE alert_log ADD resolved char(1) NOT NULL";
   43 $result2 = mysql_db_query($db, $query2);
   44 if (!$result2) {
   45     $err_msg .= mysql_error()."\n";
   46 }
   47 
   48 $query3 = "UPDATE objects SET days=\"Sun Mon Tue Wed Thu Fri Sat\"";
   49 $result3 = mysql_db_query($db, $query3);
   50 if (!$result3) {
   51     $err_msg .= mysql_error()."\n";
   52 }
   53 
   54 $query4 = "UPDATE alert_log SET resolved='Y'";
   55 $result4 = mysql_db_query($db, $query4);
   56 if (!$result4) {
   57     $err_msg .= mysql_error()."\n";
   58 }
   59 
   60 
   61 # Generate some output if this files is run by itself.
   62 if ($database_host && $database_name && $database_user && $database_pass) {
   63   if ($err_msg) {
   64     echo "\nMySQL ERROR:\n\n".$err_msg."\n\n";
   65   } else {
   66     echo "\nDatabase populated successfully.\n\n";
   67   }
   68 }
   69 
   70 ?>