function verifyTables() { $mysqlfile = "/usr/share/roundcube/SQL/mysql.initial.sql"; if (!is_file($mysqlfile)) { return null; } $q = new mysql(); $users = new usersMenus(); $f = RoundCubeMysqlTablesList(); $unix = new unix(); $mysqlbin = $unix->find_program("mysql"); $token[] = "--host={$users->mysql_server}"; if ($users->mysql_admin != null) { $token[] = "--user={$users->mysql_admin}"; } if ($users->mysql_password != null) { $token[] = "--password={$users->mysql_password}"; } $token[] = "--database={$GLOBALS["MYSQL_DB"]}"; $token[] = "--silent"; $cmdline = "{$mysqlbin} " . @implode(" ", $token); $verif = true; while (list($num, $table) = each($f)) { if (!$q->TABLE_EXISTS($table, $GLOBALS["MYSQL_DB"])) { echo "\"{$table}\" no such table in {$GLOBALS["MYSQL_DB"]}\n"; $verif = false; } } if (!$verif) { $initial = $cmdline . " < " . $users->roundcube_folder . "/SQL/mysql.initial.sql"; shell_exec($initial); if ($GLOBALS["VERBOSE"]) { echo "{$initial}\n"; } $update = $cmdline . " < " . $users->roundcube_folder . "/SQL/mysql.update.sql"; shell_exec($update); if ($GLOBALS["VERBOSE"]) { echo "{$update}\n"; } return; } unset($f); $f[] = "contactgroupmembers"; $f[] = "contactgroups"; $verif = true; while (list($num, $table) = each($f)) { if (!$q->TABLE_EXISTS($table, $GLOBALS["MYSQL_DB"])) { echo "\"{$table}\" no such table in {$GLOBALS["MYSQL_DB"]}\n"; $verif = false; } } if (!$verif) { $update = $cmdline . " < " . $users->roundcube_folder . "/SQL/mysql.update.sql"; $q->QUERY_SQL($update, $GLOBALS["MYSQL_DB"]); shell_exec($update); if ($GLOBALS["VERBOSE"]) { echo "{$update}\n"; } return; } echo "All are ok, nothing to do...\n"; }
function verifyTables() { $mysqlfile = "/usr/share/roundcube/SQL/mysql.initial.sql"; $mysqlupdatefile = "/usr/share/roundcube/SQL/mysql.update.sql"; if (!is_file($mysqlfile)) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [{$roundcube->database}] {$mysqlfile} no such file !!\n"; } return null; } $q = new mysql(); $users = new usersMenus(); $f = RoundCubeMysqlTablesList(); $unix = new unix(); $mysqlbin = $unix->find_program("mysql"); $roundcube = new roundcube(); $cmdline = "{$mysqlbin} " . $roundcube->MYSQL_CMDLINES; $verif = true; while (list($num, $table) = each($f)) { if (!$roundcube->TABLE_EXISTS($table, $GLOBALS["MYSQL_DB"])) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [{$roundcube->database}] \"{$table}\" no such table\n"; } $verif = false; } } if (!$verif) { $initial = $cmdline . " {$roundcube->database} < " . $mysqlfile; shell_exec($initial); if (is_file($mysqlupdatefile)) { $update = $cmdline . " {$roundcube->database} < {$mysqlupdatefile}"; shell_exec($update); } return; } unset($f); $f[] = "contactgroupmembers"; $f[] = "contactgroups"; $verif = true; $roundcube = new roundcube(); while (list($num, $table) = each($f)) { if (!$roundcube->TABLE_EXISTS($table)) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [{$roundcube->database}] \"{$table}\" no such table\n"; } $verif = false; } } if (!$verif) { $update = $cmdline . " {$roundcube->database} < {$mysqlupdatefile}"; $roundcube->QUERY_SQL($update, $GLOBALS["MYSQL_DB"]); shell_exec($update); if ($GLOBALS["VERBOSE"]) { echo "{$update}\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} DB: [{$roundcube->database}]: All are ok, nothing to do...\n"; } }