示例#1
0
        echo "Successful insert ADMIN data into Admin table<br>\n";
        $db->exec("INSERT INTO Post (Id, Title, Value, Date, Author, View) values (1, 'First Post','" . $instance->compress_string('Hello World!') . "', '" . time() . "', '" . $username . "', '1');");
        echo "Successful insert first post into your website!<br>\n";
        $comment = "(1, '" . $username . "','" . htmlentities($_SERVER['SERVER_ADMIN']) . "', '" . $instance->compress_string("First Comment") . "', '1', '" . time() . "', '" . $_SERVER['REMOTE_ADDR'] . "')";
        $db->exec("INSERT INTO Comment (Id, Name, Email, Value, PostID, Time, Ip) values " . $comment . ";");
        echo "Successful insert first comment into your website!<br>\n";
        // release SQLITE handle to the file
        // so we can rename our file without an error
        $db->close();
        $junk_db_name = "database_" . hash('crc32b', $instance->str_rand(100)) . ".db";
        echo "Rename mysqlite.db into " . $junk_db_name . "<br>\n";
        if (!rename('./database/mysqlite.db', './database/' . $junk_db_name)) {
            throw new Exception("Error when trying to rename database file.<br>\n");
        }
        echo "Insert junk string data into config.php file..<br>\n";
        $instance->file_str_replace('config.php', '/DEFINE\\(\'random_str\'\\, \'.*?\'\\)\\;/', "DEFINE('random_str', '" . $instance->str_rand_junk(60) . "');");
        echo "Finish insert junk data !<br>\n";
        echo "Insert database filename into config.php file..<br>\n";
        $instance->file_str_replace('config.php', '/DEFINE\\(\'sqlite_file\'\\, \'.*?\'\\)\\;/', "DEFINE('sqlite_file', './database/" . $junk_db_name . "');");
        echo "Finish insert database filename!<br>\n";
        echo "Successful creating database !<br>\n";
    } catch (Exception $e) {
        echo "Exception caught! \nException Error message : " . $e->getMessage() . "\n";
        echo "SQLITE message -> " . $db->lastErrorMsg() . " \n";
        unlink('./database/mysqlite.db');
        die;
    }
    ?>

        </div>
        <br><br><br>