示例#1
0
 public function __construct()
 {
     if (MyDatabase::isConfigured()) {
         MyDatabase::connect();
         $this->querySize();
     }
     $this->template = HtmlTemplate::fromFile('index.html');
     $this->user = new User();
     $this->template->assign('user');
 }
            $fp = fopen('mysql.php', 'w');
            $filedata = '<?php $server = \'' . $_POST['server'] . '\'; $username = \'' . $_POST['username'] . '\'; $password = \'' . $_POST['password'] . '\'; $database = \'' . $_POST['database'] . '\'; ?>';
            fwrite($fp, $filedata, strlen($filedata));
            fclose($fp);
            chmod('mysql.php', 0400);
            mkdir(Image::PATH, 0755);
            mkdir(Statistics::STATS_DIR, 0755);
            $error = '';
        } else {
            $error = 'no file';
        }
    }
}
if ($error == '') {
    require_once 'tools/MyDatabase.php';
    MyDatabase::connect();
    $table_books = mysql_query('describe books;');
    if ($table_books == null) {
        // no table, so create
        $new_table = 'CREATE TABLE `books` (';
        $new_table .= '`id` bigint(20) NOT NULL auto_increment,';
        $new_table .= '`auth_key` varchar(32) NOT NULL,';
        $new_table .= '`mail` varchar(128) NOT NULL,';
        $new_table .= '`created` datetime NOT NULL,';
        $new_table .= '`expires` datetime NOT NULL,';
        $new_table .= '`expired` datetime,';
        $new_table .= '`author` varchar(128) NOT NULL,';
        $new_table .= '`title` varchar(128) NOT NULL,';
        $new_table .= '`year` decimal(4,0) NOT NULL,';
        $new_table .= '`price` decimal(5,2) NOT NULL,';
        $new_table .= '`isbn` varchar(17) NOT NULL,';