function checkInstall($lang) { global $install_message; //1. check if config file exist if (!file_exists('db.tematres.php')) { return message("<span class=\"error\">{$install_message['201']}</span>"); } else { message("<span class=\"success\">{$install_message['202']}</span>"); include 'db.tematres.php'; } //2. check connection to server if (!($linkDB = @mysqli_connect($DBCFG["Server"], $DBCFG["DBLogin"], $DBCFG["DBPass"]))) { return message('<span class="error">' . sprintf($install_message[203], $DBCFG[Server], $DBCFG[DBLogin]) . '</span>'); } else { message('<span class="success">' . sprintf($install_message[204], $DBCFG[Server]) . '</span>'); } //3. check connection to database if (!mysqli_select_db($linkDB, $DBCFG["DBName"])) { return message('<span class="error">' . sprintf($install_message[205], $DBCFG[DBName], $DBCFG[Server]) . '</span>'); } else { message('<span class="success">' . sprintf($install_message[206], $DBCFG[DBName], $DBCFG[Server]) . '</span>'); } //4. check tables $sql = mysqli_query($linkDB, "SHOW TABLES from {$DBCFG['DBName']} where Tables_in_{$DBCFG['DBName']} in ('{$DBCFG['DBprefix']}config','{$DBCFG['DBprefix']}indice','{$DBCFG['DBprefix']}notas','{$DBCFG['DBprefix']}tabla_rel','{$DBCFG['DBprefix']}tema','{$DBCFG['DBprefix']}usuario','{$DBCFG['DBprefix']}values')"); if (mysqli_affected_rows($linkDB) == '7') { return message("<span class=\"error\">{$install_message['301']}</span>"); } else { //Final step: dump or form if (isset($_POST['send'])) { $sqlInstall = SQLtematres($DBCFG, $linkDB); } else { echo HTMLformInstall($lang); } } }
function checkInstall($lang) { global $install_message; $conf_file_path = str_replace("install.php", "db.tematres.php", "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']); //1. check if config file exist if (!file_exists('db.tematres.php')) { return message('<div class="alert alert-danger" role="alert">' . sprintf($install_message[201], $conf_file_path) . '</div><br/>'); } else { include 'db.tematres.php'; } if ($DBCFG["debugMode"] == 0) { //silent warnings error_reporting(0); $label_login = ''; $label_dbname = ''; $label_server = ''; } else { $label_login = $DBCFG["DBLogin"]; $label_dbname = $DBCFG["DBName"]; $label_server = $DBCFG["Server"]; } //2. check connection to server require_once T3_ABSPATH . 'common/include/adodb5/adodb.inc.php'; //default driver $DBCFG["DBdriver"] = $DBCFG["DBdriver"] ? $DBCFG["DBdriver"] : "mysqli"; $DB = NewADOConnection($DBCFG["DBdriver"]); if (!$DB->Connect($DBCFG["Server"], $DBCFG["DBLogin"], $DBCFG["DBPass"])) { return message('<div class="alert alert-danger" role="alert">' . sprintf($install_message[203], $label_server, $label_login, $conf_file_path) . '</div><br/>'); } //~ //3. check connection to database if (!$DB->Connect($DBCFG["Server"], $DBCFG["DBLogin"], $DBCFG["DBPass"], $DBCFG["DBName"])) { return message('<div class="alert alert-danger" role="alert">' . sprintf($install_message[205], $label_dbname, $label_server, $conf_file_path) . '</div><br/>'); } //4. check tables $sql = $DB->Execute('SHOW TABLES from `' . $DBCFG["DBName"] . '` where `tables_in_' . $DBCFG["DBName"] . '` in (\'' . $DBCFG["DBprefix"] . 'config\',\'' . $DBCFG["DBprefix"] . 'indice\',\'' . $DBCFG["DBprefix"] . 'notas\',\'' . $DBCFG["DBprefix"] . 'tabla_rel\',\'' . $DBCFG["DBprefix"] . 'tema\',\'' . $DBCFG["DBprefix"] . 'usuario\',\'' . $DBCFG["DBprefix"] . 'values\')'); if ($DB->Affected_Rows() == '7') { return message('<div class="alert alert-danger" role="alert">' . $install_message["301"] . '</div>'); } else { //Final step: dump or form if (isset($_POST['send'])) { $arrayInstallData = checkDataInstall($_POST); if (count($arrayInstallData) == 7) { SQLtematres($DBCFG, $DB, $arrayInstallData); } else { echo $arrayInstallData["error_msg"]; echo HTMLformInstall($lang); } } else { echo HTMLformInstall($lang); } } }