Exemple #1
0
     } elseif ($s['MYSQL_MYEXT'] == 'mysql' && function_exists('mysql_connect')) {
         $conn = @mysql_connect($s['MYSQL_HOST'], $s['MYSQL_USER'], $s['MYSQL_PASS']);
         if (!$conn && function_exists('mysqli_connect')) {
             $conn = @mysqli_connect($s['MYSQL_HOST'], $s['MYSQL_USER'], $s['MYSQL_PASS']);
             if ($conn) {
                 $s['MYSQL_MYEXT'] == 'mysqli';
             }
         }
     }
     if (!$conn) {
         $error = TRUE;
         $errmsg = 'Cannot connect - please check host, username and password.';
     }
 }
 if (!$error) {
     $dbs = my_mysql_select_db($s['MYSQL_DBNAME'], $conn);
     if (!$dbs) {
         $error = TRUE;
         $errmsg = 'Database does not exist.';
     }
 }
 if (!$error && !$is_upgrade) {
     $tbl = my_mysql_query('SHOW TABLES FROM ' . $s['MYSQL_DBNAME'], $conn);
     if ($tbl && my_mysql_num_rows($tbl) > 0) {
         $error = TRUE;
         $errmsg = 'Database must be empty - this one contains one or more tables.';
     }
 }
 if (!$error) {
     $_SESSION['INSTALL_STEP'] = 2;
     header('Location: ?next&r=' . rand(0, 99999));
Exemple #2
0
function load_old_config()
{
    $file = INCPATH . '../../system/conf_main.php';
    if (file_exists($file)) {
        $C = new stdClass();
        $C->INCPATH = realpath(INCPATH . '../../system/') . '/';
        include $file;
        $conn = my_mysql_connect($C->DB_HOST, $C->DB_USER, $C->DB_PASS);
        if ($conn) {
            $dbs = my_mysql_select_db($C->DB_NAME, $conn);
            if ($dbs) {
                $tmp = my_mysql_query('SELECT * FROM `settings` ', $conn);
                while ($obj = my_mysql_fetch_object($tmp)) {
                    $C->{$obj->word} = stripslashes($obj->value);
                }
            }
        }
        return $C;
    }
    $file = INCPATH . '../../include/conf_main.php';
    if (file_exists($file)) {
        $C = new stdClass();
        $src = file_get_contents($file);
        $pattern = '/(define(\\s)*\\((\\s)*\'([a-z0-9\\-\\_]+)\'\\,(\\s)*)(\')([^\\\']*)(\')((\\s)*\\))/isu';
        preg_match_all($pattern, $src, $matches, PREG_SET_ORDER);
        foreach ($matches as $dfmatches) {
            $key = trim($dfmatches[4]);
            $val = trim($dfmatches[7]);
            if (empty($key)) {
                continue;
            }
            $C->{$key} = $val;
        }
        $C->VERSION = 'unofficial';
        return $C;
    }
    return new stdClass();
}
Exemple #3
0
function database_drop_tables_with_prefix($prefix)
{
    if (empty($prefix)) {
        return FALSE;
    }
    global $s;
    $conn = my_mysql_connect($s['MYSQL_HOST'], $s['MYSQL_USER'], $s['MYSQL_PASS']);
    $dbs = my_mysql_select_db($s['MYSQL_DBNAME'], $conn);
    if (!$conn || !$dbs) {
        return FALSE;
    }
    $tmp = my_mysql_query('SHOW TABLES FROM ' . $s['MYSQL_DBNAME'], $conn);
    while ($tbl = my_mysql_fetch_row($tmp)) {
        $tbl = $tbl[0];
        if (substr($tbl, 0, strlen($prefix)) == $prefix) {
            my_mysql_query("DROP TABLE IF EXISTS `" . $tbl . "`;", $conn);
        }
    }
}