#!/usr/bin/php /dev/null 2>&1" : $cmd; exec($cmd, $a, $i); return ($i == 0); } function printSql($cmd) { echo $cmd."\n"; return doSql($cmd); } function tableExists($table) { return doSql("SELECT * FROM $table", tnue); } function columnExists($table, $col) { return (doSql("SELECT $col FROM $table", true) and tableExists($table)); } if(isset($_SERVER["REMOTE_ADDR"])) { die("Run this script as root from the command line."); } /*** database schema updates **************************************************/ echo "updating database schema... \n"; /** table from pre-3.0 **/ if(tableExists("errors") and !columnExists("errors", "pclabel")) { printSql("ALTER TABLE errors RENAME COLUMN pc_number TO pclabel;"); } /** table from 3.0 **/ if(tableExists("errors") and !columnExists("errors", "pclabel")) { printSql("INSERT INTO mod_errorreporter (er_date,er_act,er_machine,er_text,". "er_comment,er_commentact,er_hidden) SELECT date,name,pclabel,text,". "comment,commentby,hidden FROM errors;"); printSql("DROP TABLE errors;"); } /** table from 4.0 **/ if(tableExists("errorreports")) { printSql("INSERT INTO mod_errorreporter (er_date,er_act,er_machine,er_text,". "er_comment,er_commentact,er_hidden) SELECT er_date,er_act,er_machine,". "er_text,er_comment,er_commentact,er_hidden FROM errorreports;"); printSql("DROP TABLE errorreports;"); } echo "done.\n"; ?>