PageRenderTime 449ms CodeModel.GetById 292ms app.highlight 11ms RepoModel.GetById 140ms app.codeStats 0ms

/docs/examples/wordpress/silver-update.php

https://bitbucket.org/ianb/silverlining/
PHP | 50 lines | 40 code | 5 blank | 5 comment | 7 complexity | c852095cc8a21012d2da3c23059904bd MD5 | raw file
 1<?
 2function table_exists ($table, $db) {
 3    $tables = mysql_list_tables ($db);
 4    while (list ($temp) = mysql_fetch_array ($tables)) {
 5        if ($temp == $table) {
 6            return TRUE;
 7        }
 8    }
 9    return FALSE;
10}
11
12$password = $_SERVER['CONFIG_MYSQL_PASSWORD'];
13if (! $password) {
14    $password = null;
15}
16
17//echo "mysql_connect({$_SERVER[CONFIG_MYSQL_HOST]}, {$_SERVER[CONFIG_MYSQL_USER]}, {$password});";
18
19mysql_connect($_SERVER['CONFIG_MYSQL_HOST'], $_SERVER['CONFIG_MYSQL_USER'],
20                    $password);
21//mysql_select_db($_SERVER[CONFIG_MYSQL_DBNAME], $db);
22
23if (! table_exists("wp_posts", $_SERVER['CONFIG_MYSQL_DBNAME'])) {
24    define('WP_INSTALLING', TRUE);
25    /** Load WordPress Bootstrap */
26    require_once(dirname(__FILE__) . '/wordpress/wp-load.php');
27    /** Load WordPress Administration Upgrade API */
28    require_once(dirname(__FILE__) . '/wordpress/wp-admin/includes/upgrade.php');
29    /* FIXME: hardcoding example email address, and Public=True */
30    echo "Setting up tables and basic information; admin information needed...\n";
31    echo "Admin user (default: admin): ";
32    flush();
33    $handle = fopen("php://stdin", "r");
34    $username = trim(fgets(STDIN));
35    if (! $username) {
36        $username = 'admin';
37    }
38    echo "Email: ";
39    flush();
40    $email = trim(fgets(STDIN));
41    $result = wp_install('Just Another Blog', $username, $email, TRUE);
42    echo "Blog created:\n";
43    echo "  username: {$username}\n";
44    echo "  password: {$result['password']}\n";
45    echo "Installed.\n";
46} else {
47    echo "Database already available.\n";
48}
49
50?>