/** * Optimize all existing tables * Warning: This does only work for MyISAM-, BDB- and InnoDB tables */ public function optimizeTables() { $tables = $this->getExistingTables(); foreach ($tables as $table => $tableLower) { $this->db->query("OPTIMIZE TABLE `{$table}`"); } }
/** * Get content */ public function getContent() { $errors = $checkErrors = array(); $writeableFolders = array(CHOQ_ACTIVE_MODULE_DIRECTORY, CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/static", CHOQ_ACTIVE_MODULE_DIRECTORY . "/public/img/favicons", CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp"); foreach ($writeableFolders as $folder) { if (!is_dir($folder)) { $errors[] = sprintf(t("install.folder.notexist"), $folder); break; } if (!is_writable($folder)) { $errors[] = sprintf(t("install.folder.writeable"), $folder); break; } } if (!ini_get("allow_url_fopen")) { $errors[] = sprintf(t("install.php.feature"), "allow_url_fopen"); } if (!function_exists("fsockopen")) { $errors[] = sprintf(t("install.php.feature"), "fsockopen/sockets"); } if (!function_exists("simplexml_load_file")) { $errors[] = sprintf(t("install.php.feature"), "SimpleXML"); } if (!CHOQ_DB_Mysql::isAvailable()) { $errors[] = sprintf(t("install.php.feature"), "MySQLi"); } if (post("install")) { try { $connString = "mysql://" . post("mysql-user") . ":" . post("mysql-pass") . "@" . post("mysql-host") . "/" . post("mysql-db"); CHOQ_DB::add($connString, "test"); db("test")->query("DROP TABLE IF EXISTS " . db("test")->quote("RDR_test")); db("test")->query("CREATE TABLE " . db("test")->quote("RDR_test") . " (" . db("test")->quote("id") . " INT NOT NULL)"); db("test")->query("DROP TABLE IF EXISTS " . db("test")->quote("RDR_test")); $fileData = "<?php\nif(!defined(\"CHOQ\")) die();\n/**\n * Local Configuration\n**/\n\n"; $fileData .= 'CHOQ_DB::add(\'' . $connString . '\');' . "\n"; $fileData .= 'v("hash.salt", "' . uniqid(NULL, true) . sha1(microtime() . uniqid(NULL, true)) . '");' . "\n"; $tmpfile = CHOQ_ACTIVE_MODULE_DIRECTORY . "/tmp/_RDR.local.tmp.php"; file_put_contents($tmpfile, $fileData); include $tmpfile; $generator = CHOQ_DB_Generator::create(db()); $tables = $generator->getExistingTables(); foreach ($tables as $table) { if ($table == "_choqled_metadata" || substr(strtolower($table), 0, 3) == "rdr_") { db()->query("DROP TABLE " . db()->quote($table)); } } RDR_DBUpdate::run(); $user = new RDR_User(db()); $user->username = post("admin-user"); $user->setPassword(post("admin-pass")); $user->role = RDR_User::ROLE_ADMIN; $user->store(); rename($tmpfile, CHOQ_ACTIVE_MODULE_DIRECTORY . "/_RDR.local.php"); redirect(url()->getByAlias("base")); } catch (Exception $e) { $checkErrors[] = $e->getMessage(); } } ?> <div class="center"> <img src="<?php echo url()->getByAlias("public", "img/logo-1.png"); ?> " alt=""/> </div> <?php if (!$errors) { $this->showErrors($checkErrors); $form = $this->getForm(); $formTable = new Form_Table($form); $formTable->addSubmit(t("install.finish")); echo $formTable->getHtml(); echo "<div class='center'><br/>" . t("install.warn") . "</div>"; } else { $this->showErrors($errors); } }