"Fossies" - the Fresh Open Source Software Archive

Member "node-runner-0.6.0/sql/nr-mysql-setup.php" (22 Dec 2004, 4848 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. For more information about "nr-mysql-setup.php" see the Fossies "Dox" file reference documentation.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    1 <?php
    2 
    3 // This file is used to populate the database for new installations
    4 // of Node Runner.  This file is called from the install script,
    5 // but if you absolutely *need* to build the database manually,
    6 // you can fill in the values below can call the script from the
    7 // php interpreter.  Otherwise, leave them blank.
    8 
    9 $database_host = '';
   10 $database_name = '';
   11 $database_user = '';
   12 $database_pass = '';
   13 
   14 if (!$dbhost) { $dbhost = $database_host; }
   15 if (!$db) { $db = $database_name; }
   16 if (!$dbuser) { $dbhost = $database_user; }
   17 if (!$dbpass) { $dbhost = $database_pass; }
   18 
   19 if ($database_host && $database_name && $database_user && $database_pass) {
   20   unset($err_msg);
   21   $connect = mysql_connect($database_host,$database_user,$database_pass);
   22   if (!$connect) { $err_msg .= mysql_error()."\n"; }
   23 }
   24 
   25 # --------------------------------------------------------
   26 #
   27 # Table structure for table 'alert_log'
   28 #
   29 
   30 $pre_query1 = "DROP TABLE IF EXISTS alert_log";
   31 $pre_result1 = mysql_db_query($db, $pre_query1);
   32 if (!$pre_result1) {
   33     $err_msg .= mysql_error()."\n";
   34 }
   35 
   36 $query1 = "
   37 CREATE TABLE alert_log (
   38    id int(11) NOT NULL auto_increment,
   39    dependency char(10) NOT NULL,
   40    description char(100) NOT NULL,
   41    ipaddress char(30) NOT NULL,
   42    port char(10) NOT NULL,
   43    query_type tinytext NOT NULL,
   44    server char(1) NOT NULL,
   45    time int(11) NOT NULL,
   46    downtime int(11) NOT NULL,
   47    lastnotif int(11) NOT NULL,
   48    ptime int(11) NOT NULL,
   49    url varchar(255) NULL,
   50    snmp_comm tinytext NULL,
   51    resolved char(1) NOT NULL,
   52    PRIMARY KEY (id)
   53 )";
   54 $result1 = mysql_db_query($db, $query1);
   55 if (!$result1) {
   56     $err_msg .= mysql_error()."\n";
   57 }
   58 
   59 
   60 # --------------------------------------------------------
   61 #
   62 # Table structure for table 'mail_group'
   63 #
   64 
   65 $pre_query2 = "DROP TABLE IF EXISTS mail_group";
   66 $pre_result2 = mysql_db_query($db, $pre_query2);
   67 if (!$pre_result2) {
   68     $err_msg .= mysql_error()."\n";
   69 }
   70 
   71 $query2 = "
   72 CREATE TABLE mail_group (
   73    id int(11) NOT NULL auto_increment,
   74    name varchar(100) NOT NULL,
   75    email text NOT NULL,
   76    PRIMARY KEY (id)
   77 )";
   78 $result2 = mysql_db_query($db, $query2);
   79 if (!$result2) {
   80     $err_msg .= mysql_error()."\n";
   81 }
   82 
   83 
   84 #
   85 # Default data for table 'mail_group'
   86 #
   87 
   88 $query3 = "INSERT INTO mail_group (id, name, email) VALUES ( '1', 'root', 'root@localhost');";
   89 $result3 = mysql_db_query($db, $query3);
   90 if (!$result3) {
   91     $err_msg .= mysql_error()."\n";
   92 }
   93 
   94 
   95 
   96 # --------------------------------------------------------
   97 #
   98 # Table structure for table 'objects'
   99 #
  100 
  101 $pre_query4 = "DROP TABLE IF EXISTS objects";
  102 $pre_result4 = mysql_db_query($db, $pre_query4);
  103 if (!$pre_result4) {
  104     $err_msg .= mysql_error()."\n";
  105 }
  106 
  107 $query4 = "
  108 CREATE TABLE objects (
  109    id int(11) NOT NULL auto_increment,
  110    dependency char(10) NOT NULL,
  111    description char(100) NOT NULL,
  112    ipaddress char(30) NOT NULL,
  113    port char(10) NOT NULL,
  114    query_type tinytext NOT NULL,
  115    server char(1) NOT NULL,
  116    enabled char(1) NOT NULL,
  117    mail_group char(10) NOT NULL,
  118    ptime int(11) NOT NULL,
  119    smon_time int(11) NOT NULL,
  120    emon_time int(11) NOT NULL,
  121    url varchar(255) NULL,
  122    snmp_comm tinytext NULL,
  123    days varchar(27) NOT NULL,
  124    comments text NOT NULL,
  125    auth_user varchar(255) NULL,
  126    auth_pass varchar(255) NULL,
  127    PRIMARY KEY (id)
  128 );";
  129 $result4 = mysql_db_query($db, $query4);
  130 if (!$result4) {
  131     $err_msg .= mysql_error()."\n";
  132 }
  133 
  134 #
  135 # Default data for table 'objects'
  136 #
  137 
  138 $query5 = "INSERT INTO objects (id, dependency, description, ipaddress, port, query_type, server, enabled, mail_group, ptime, smon_time, emon_time, url, days, comments, auth_user, auth_pass) VALUES ( '1', 'NONE', 'NODE RUNNER', '127.0.0.1', '80', 'TCP', '', 'Y', '1', '5', '0', '2359', NULL, 'Sun Mon Tue Wed Thu Fri Sat','', NULL, NULL);";
  139 $result5 = mysql_db_query($db, $query5);
  140 if (!$result5) {
  141     $err_msg .= mysql_error()."\n";
  142 }
  143 
  144 
  145 
  146 # --------------------------------------------------------
  147 #
  148 # Table structure for table 'users'
  149 #
  150 
  151 $pre_query6 = "DROP TABLE IF EXISTS users";
  152 $pre_result6 = mysql_db_query($db, $pre_query6);
  153 if (!$pre_result6) {
  154     $err_msg .= mysql_error()."\n";
  155 }
  156 
  157 $query6 = "
  158 CREATE TABLE users (
  159    userid int(11) NOT NULL auto_increment,
  160    username varchar(255) NOT NULL,
  161    password text NOT NULL,
  162    admin int(1) NOT NULL,
  163    PRIMARY KEY (userid)
  164 );";
  165 $result6 = mysql_db_query($db, $query6);
  166 if (!$result6) {
  167     $err_msg .= mysql_error()."\n";
  168 }
  169 
  170 
  171 #
  172 # Default data for table 'users'
  173 #
  174 
  175 $query7 = "INSERT INTO users VALUES('','admin','0260dc1993945f6ee97424b2c4d6d02d','1');";
  176 $result7 = mysql_db_query($db, $query7);
  177 if (!$result7) {
  178     $err_msg .= mysql_error()."\n";
  179 }
  180 
  181 
  182 # Generate some output if this files is run by itself.
  183 if ($database_host && $database_name && $database_user && $database_pass) {
  184   if ($err_msg) {
  185     echo "\nMySQL ERROR:\n\n".$err_msg."\n\n";
  186   } else {
  187     echo "\nDatabase populated successfully.\n\n";
  188   }
  189 }
  190 
  191 ?>