Exemplo n.º 1
0
function create_tables()
{
    global $errors, $DFLT;
    //$PHP_SELF = $_SERVER['PHP_SELF'];
    $gallery_dir = strtr(dirname($_SERVER['PHP_SELF']), '\\', '/');
    $gallery_url_prefix = 'http://' . $_SERVER['HTTP_HOST'] . $gallery_dir . (substr($gallery_dir, -1) == '/' ? '' : '/');
    $db_schema = "{$DFLT['sql_d']}/schema.sql";
    $db_basic = "{$DFLT['sql_d']}/basic.sql";
    if (($sch_open = fopen($db_schema, 'r')) === FALSE) {
        $errors .= "<hr /><br />The file '{$db_schema}' could not be found. Check that you have uploaded all Coppermine files to your server<br /><br />";
        return;
    } else {
        $sql_query = fread($sch_open, filesize($db_schema));
        if (($bas_open = fopen($db_basic, 'r')) === FALSE) {
            $errors .= "<hr /><br />The file '{$db_basic}' could not be found. Check that you have uploaded all Coppermine files to your server<br /><br />";
            return;
        } else {
            $sql_query .= fread($bas_open, filesize($db_basic));
        }
    }
    // Insert the admin account
    $sql_query .= "INSERT INTO CPG_users (user_id, user_group, user_active, user_name, user_password, user_lastvisit, user_regdate, user_group_list, user_email, user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6, user_actkey ) VALUES (1, 1, 'YES', '{$_POST['admin_username']}', md5('{$_POST['admin_password']}'), NOW(), NOW(), '', '{$_POST['admin_email']}', '', '', '', '', '', '', '');\n";
    // Set configuration values for image package
    $sql_query .= "REPLACE INTO CPG_config VALUES ('thumb_method', '{$_POST['thumb_method']}');\n";
    $sql_query .= "REPLACE INTO CPG_config VALUES ('impath', '{$_POST['impath']}');\n";
    $sql_query .= "REPLACE INTO CPG_config VALUES ('ecards_more_pic_target', '{$gallery_url_prefix}');\n";
    $sql_query .= "REPLACE INTO CPG_config VALUES ('gallery_admin_email', '{$_POST['admin_email']}');\n";
    // Enable silly_safe_mode if test has shown that it is not configured properly
    if (test_silly_safe_mode() == TRUE) {
        $sql_query .= "REPLACE INTO CPG_config VALUES ('silly_safe_mode', '1');\n";
    }
    // Test write permissions for main dir
    if (!is_writable('.')) {
        $sql_query .= "REPLACE INTO CPG_config VALUES ('default_dir_mode', '0777');\n";
        $sql_query .= "REPLACE INTO CPG_config VALUES ('default_file_mode', '0666');\n";
    }
    // Update table prefix
    $sql_query = preg_replace('/CPG_/', $_POST['table_prefix'], $sql_query);
    $sql_query = remove_remarks($sql_query);
    $sql_query = split_sql_file($sql_query, ';');
    foreach ($sql_query as $q) {
        if (!mysql_query($q)) {
            $errors .= "mySQL Error: " . mysql_error() . " on query '{$q}'<br /><br />";
            return;
        }
    }
}
Exemplo n.º 2
0
function build_cfg_file()
{
    global $DFLT, $HTTP_POST_VARS;
    $silly_safe_mode = test_silly_safe_mode() ? "// Silly safe mode\ndefine('SILLY_SAFE_MODE', 1);\n\n" : '';
    return <<<EOT
<?php
// Coppermine configuration file
{$silly_safe_mode}
// MySQL configuration
\$CONFIG['dbserver'] =                         '{$HTTP_POST_VARS['dbserver']}';        // Your database server
\$CONFIG['dbuser'] =                         '******'dbuser']}';        // Your mysql username
\$CONFIG['dbpass'] =                         '******'dbpass']}';                // Your mysql password
\$CONFIG['dbname'] =                         '{$HTTP_POST_VARS['dbname']}';        // Your mysql database name


// MySQL TABLE NAMES PREFIX
\$CONFIG['TABLE_PREFIX'] =                '{$HTTP_POST_VARS['table_prefix']}';
?>
EOT;
}