Пример #1
0
 echo 'Configuration appears correct.';
 echo '<h2>Checking database...</h2>';
 $reqiredtables = array("ads", "announcements", "banlist", "bannedhashes", "blotter", "boards", "board_filetypes", "embeds", "events", "filetypes", "front", "loginattempts", "modlog", "module_settings", "posts", "reports", "sections", "staff", "watchedthreads", "wordfilter");
 foreach ($reqiredtables as $tablename) {
     if (KU_DBTYPE == 'mysql' || KU_DBTYPE == 'mysqli') {
         if (!mysql_table_exists(KU_DBDATABASE, KU_DBPREFIX . $tablename)) {
             die("Couldn't find the table <strong>" . KU_DBPREFIX . $tablename . "</strong> in the database. Please <a href=\"install-mysql.php\"><strong><u>insert the mySQL dump</u></strong></a>.");
         }
     }
     if (KU_DBTYPE == 'postgres7' || KU_DBTYPE == 'postgres8' || KU_DBTYPE == 'postgres') {
         if (!pgsql_table_exists(KU_DBDATABASE, KU_DBPREFIX . $tablename)) {
             die("Couldn't find the table <strong>" . KU_DBPREFIX . $tablename . "</strong> in the database. Please <a href=\"install-pgsql.php\"><strong><u>insert the PostgreSQL dump</u></strong></a>.");
         }
     }
     if (KU_DBTYPE == 'sqlite') {
         if (!sqlite_table_exists(KU_DBDATABASE, KU_DBPREFIX . $tablename)) {
             die("Couldn't find the table <strong>" . KU_DBPREFIX . $tablename . "</strong> in the database. Please <a href=\"install-sqlite.php\"><strong><u>insert the SQLite dump</u></strong></a>.");
         }
     }
 }
 echo 'Database appears correct.';
 echo '<h2>Inserting default administrator account...</h2>';
 $result_exists = $tc_db->GetOne("SELECT COUNT(*) FROM `" . KU_DBPREFIX . "staff` WHERE `username` = 'admin'");
 if ($result_exists == 0) {
     $salt = CreateSalt();
     $result = $tc_db->Execute("INSERT INTO `" . KU_DBPREFIX . "staff` ( `username` , `salt`, `password` , `type` , `addedon` ) VALUES ( 'admin' , '" . $salt . "', '" . md5("admin" . $salt) . "' , '1' , '" . time() . "' )");
     echo 'Account inserted.';
     $result = true;
 } else {
     echo 'There is already an administrator account inserted.';
     $result = true;
Пример #2
0
 /**
  * 判断一个表是否存在
  * 
  * @param      string      $table 表名
  * @access     public
  * @return     bool
  */
 function table_exists($table)
 {
     if (function_exists('sqlite_table_exists')) {
         return sqlite_table_exists($this->conn, $table);
     } else {
         $sql = "SELECT count(name) FROM sqlite_master WHERE ((type = 'table') and (name = '{$table}'))";
         if ($res = sqlite_query($this->conn, $sql)) {
             return sqlite_fetch_single($res) > 0;
         } else {
             return false;
         }
     }
 }