"Fossies" - the Fresh Open Source Software Archive

Member "node-runner-0.6.0/sql/update-nr-to-v0.3.php" (28 Dec 2004, 2654 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.2 to v0.3.  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 ptime column to alert_log and objects tables.
   30 # 2) Adds smon_time and emon_time column to objects for monitoring timeframe.
   31 # 3) Inserts 10 into ptime columns for alert_log and objects tables.
   32 # 4) Inserts default monitoring timeframe into objects table.
   33 
   34 $query1 = "ALTER TABLE alert_log ADD ptime int NOT NULL";
   35 $result1 = mysql_db_query($db, $query1);
   36 if (!$result1) {
   37     $err_msg .= mysql_error()."\n";
   38 }
   39 
   40 $query2 = "ALTER TABLE objects ADD ptime int NOT NULL";
   41 $result2 = mysql_db_query($db, $query2);
   42 if (!$result2) {
   43     $err_msg .= mysql_error()."\n";
   44 }
   45 
   46 $query3 = "ALTER TABLE objects ADD smon_time int NOT NULL";
   47 $result3 = mysql_db_query($db, $query3);
   48 if (!$result3) {
   49     $err_msg .= mysql_error()."\n";
   50 }
   51 
   52 $query4 = "ALTER TABLE objects ADD emon_time int NOT NULL";
   53 $result4 = mysql_db_query($db, $query4);
   54 if (!$result4) {
   55     $err_msg .= mysql_error()."\n";
   56 }
   57 
   58 $query5 = "UPDATE alert_log SET ptime=10";
   59 $result5 = mysql_db_query($db, $query5);
   60 if (!$result5) {
   61     $err_msg .= mysql_error()."\n";
   62 }
   63 
   64 $query6 = "UPDATE objects SET ptime=10";
   65 $result6 = mysql_db_query($db, $query6);
   66 if (!$result6) {
   67     $err_msg .= mysql_error()."\n";
   68 }
   69 
   70 $query7 = "UPDATE objects SET smon_time=0";
   71 $result7 = mysql_db_query($db, $query7);
   72 if (!$result7) {
   73     $err_msg .= mysql_error()."\n";
   74 }
   75 
   76 $query8 = "UPDATE objects SET emon_time=2359";
   77 $result8 = mysql_db_query($db, $query8);
   78 if (!$result8) {
   79     $err_msg .= mysql_error()."\n";
   80 }
   81 
   82 # Generate some output if this files is run by itself.
   83 if ($database_host && $database_name && $database_user && $database_pass) {
   84   if ($err_msg) {
   85     echo "\nMySQL ERROR:\n\n".$err_msg."\n\n";
   86   } else {
   87     echo "\nDatabase populated successfully.\n\n";
   88   }
   89 }
   90 
   91 ?>