Exemplo n.º 1
0
function checkInputValues()
{
    global $fdb;
    // Check connection
    $conn = @mysql_connect($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password']);
    if (!$conn) {
        myerror('Unable to connect to MySQL server. Please check your settings again.<br><br><a href="?page=settings">Go back to settings</a>');
    }
    // Check databases
    if (!@mysql_select_db($_SESSION['php_db_clean'], $conn)) {
        // Fetch database list
        $list = '';
        $result = @mysql_query('SHOW databases', $conn);
        while ($ob = mysql_fetch_row($result)) {
            $list .= ' &nbsp <a href="?page=settings&newdb=' . $ob[0] . '">' . $ob[0] . '</a><br>' . "\n";
        }
        // Close connection and show message
        mysql_close($conn);
        myerror('Unable to select database.' . '<br><br>Found these databases:<br><font color="gray">' . $list . '</font>' . '<br><a href="?page=settings">Go back to settings</a>');
    }
    mysql_close($conn);
    // Include FORUM's config file
    include './' . $_SESSION['forum'] . '/_config.php';
    // Check prefix
    $fdb = new DBLayer($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password'], $_SESSION['php_db_clean'], $_SESSION['php_prefix'], false);
    $res = $fdb->query('SELECT count(*) FROM ' . $_SESSION['php'] . $tables['Users']);
    if (intval($fdb->result($res, 0)) == 0) {
        // Select a list of tables
        $list = array();
        $res = $fdb->query('SHOW TABLES IN ' . $_SESSION['php_db']);
        while ($ob = $fdb->fetch_row($res)) {
            $list[] = $ob[0];
        }
        // check list size
        sizeof($list) == 0 ? $list[] = 'None' : null;
        // Get list of "proabable" prefixes
        $prefix_list = '';
        $res = $fdb->query('SHOW TABLES FROM ' . $_SESSION['php_db'] . ' LIKE \'%' . $tables['Posts'] . '\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
        //			$res = $fdb->query('SHOW TABLES FROM '.$_SESSION['php_db'].' LIKE \'%'.$tables['Users'].'\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
        while ($ob = $fdb->fetch_row($res)) {
            $prefix = substr($ob[0], 0, strlen($ob[0]) - strlen($tables['Users']));
            $prefix_list .= ' &nbsp; <a href="?page=settings&newprefix=' . $prefix . '">' . $prefix . '</a><br>' . "\n";
        }
        // Print message
        $prefix = $_SESSION['php_prefix'] == '' ? 'no' : '\'' . $_SESSION['php_prefix'] . '\'';
        myerror('Unable to find ' . $_SESSION['forum'] . ' tables! (using prefix: <i>' . $prefix . '</i>)' . '<br><br>Go back to settings and choose another prefix, or select one of these prefixes:<br><font color="gray">' . $prefix_list . '</font>' . '<br>These are the tables in the selected database:<br><font color="gray"> &nbsp; ' . implode("<br> &nbsp; ", $list) . '</font>' . '<br><br><a href="?page=settings">Go back to settings</a>');
    }
}
$outland_inst = array(540, 542, 543, 544, 545, 546, 547, 548, 550, 552, 553, 554, 555, 556, 557, 558, 559, 562, 564, 565);
$northrend_inst = array(533, 574, 575, 576, 578, 599, 600, 601, 602, 603, 604, 608, 615, 616, 617, 619, 624);
require_once "../libs/js/JsHttpRequest/Php.php";
$JsHttpRequest = new Subsys_JsHttpRequest_Php("utf-8");
$arcm_db_PM = new DBLayer($hostr, $userr, $passwordr, $dbr);
if (!$arcm_db_PM->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
$logon_db_PM = new DBLayer($hostl, $userl, $passwordl, $dbl);
$arcm_db_PM->query("SET NAMES {$database_encoding}");
$gm_online = 0;
$gm_accounts = array();
$query = $logon_db_PM->query("SELECT GROUP_CONCAT(`acct` SEPARATOR ' ') FROM `accounts` WHERE `gm`<>'0'");
if ($query) {
    if ($result = $logon_db_PM->fetch_row($query)) {
        $gm_accounts = explode(' ', $result[0]);
    }
}
$groups = array();
$characters_db_PM = new DBLayer($host, $user, $password, $db);
if (!$characters_db_PM->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
$characters_db_PM->query("SET NAMES {$database_encoding}");
$query = $characters_db_PM->query("SELECT `leaderGuid`,`memberGuid` FROM `group_member` WHERE `memberGuid` IN(SELECT `guid` FROM `characters` WHERE `online`='1')");
if ($query) {
    while ($result = $characters_db_PM->fetch_assoc($query)) {
        $groups[$result['memberGuid']] = $result['leaderGuid'];
    }
Exemplo n.º 3
0
         break;
     case 'sqlite':
         if (strtolower($db_prefix) == 'sqlite_') {
             error($lang_install['Prefix reserved']);
         }
         break;
 }
 // Make sure FluxBB isn't already installed
 $result = $db->query('SELECT 1 FROM ' . $db_prefix . 'users WHERE id=1');
 if ($db->num_rows($result)) {
     error(sprintf($lang_install['Existing table error'], $db_prefix, $db_name));
 }
 // Check if InnoDB is available
 if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
     $result = $db->query('SHOW VARIABLES LIKE \'have_innodb\'');
     list(, $result) = $db->fetch_row($result);
     if (strtoupper($result) != 'YES') {
         error($lang_install['InnoDB off']);
     }
 }
 // Start a transaction
 $db->start_transaction();
 // Create all tables
 $schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'username' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'ip' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'email' => array('datatype' => 'VARCHAR(80)', 'allow_null' => true), 'message' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'expire' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'ban_creator' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'), 'INDEXES' => array('username_idx' => array('username')));
 if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
     $schema['INDEXES']['username_idx'] = array('username(25)');
 }
 $db->create_table('bans', $schema) or error('Unable to create bans table', __FILE__, __LINE__, $db->error());
 $schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'cat_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New Category\''), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
 $db->create_table('categories', $schema) or error('Unable to create categories table', __FILE__, __LINE__, $db->error());
 $schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'search_for' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\''), 'replace_with' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
Exemplo n.º 4
0
$Alliance_races = 0x44d;
$outland_inst = array(540, 542, 543, 544, 545, 546, 547, 548, 550, 552, 553, 554, 555, 556, 557, 558, 559, 562, 564, 565);
$northrend_inst = array(533, 574, 575, 576, 578, 599, 600, 601, 602, 603, 604, 608, 615, 616, 617, 619, 624);
require_once "../libs/js/JsHttpRequest/Php.php";
$JsHttpRequest = new Subsys_JsHttpRequest_Php("utf-8");
$realm_db = new DBLayer($hostr, $userr, $passwordr, $dbr);
if (!$realm_db->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
$realm_db->query("SET NAMES {$database_encoding}");
$gm_online = 0;
$gm_accounts = array();
$query = $realm_db->query("SELECT GROUP_CONCAT(`id` SEPARATOR ' ') FROM `account` WHERE `gmlevel`>'0'");
if ($query) {
    if ($result = $realm_db->fetch_row($query)) {
        $gm_accounts = explode(' ', $result[0]);
    }
}
$groups = array();
$characters_db = new DBLayer($host, $user, $password, $db);
if (!$characters_db->isValid()) {
    $_RESULT['status']['online'] = 2;
    exit;
}
$characters_db->query("SET NAMES {$database_encoding}");
$query = $characters_db->query("SELECT `leaderGuid`,`memberGuid` FROM `group_member` WHERE `memberGuid` IN(SELECT `guid` FROM `characters` WHERE `online`='1')");
if ($query) {
    while ($result = $characters_db->fetch_assoc($query)) {
        $groups[$result['memberGuid']] = $result['leaderGuid'];
    }
Exemplo n.º 5
0
 //collect category data
 $query = array('SELECT' => 'id, title, description, ref', 'FROM' => 'categories');
 $cat_query = $imp->query_build($query) or error(__FILE__, __LINE__);
 //collect link data
 $query = array('SELECT' => 'id, title, description, url, category, ip, accepted', 'FROM' => 'pages');
 $link_query = $imp->query_build($query) or error(__FILE__, __LINE__);
 //DBlayers switched table, so $db must be re-introduced
 $db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
 while ($row = $imp->fetch_assoc($cat_query)) {
     $query = array('INSERT' => 'title, description, active, father_id, old_id, old_id_backup', 'INTO' => 'categories', 'VALUES' => '"' . $row['title'] . '", "' . $row['description'] . '", 1, "' . $row['ref'] . '", "' . $row['id'] . '", "' . $row['id'] . '"');
     $db->query_build($query) or error(__FILE__, __LINE__);
 }
 while ($lrow = $imp->fetch_assoc($link_query)) {
     $query = array('SELECT' => 'id', 'FROM' => 'categories', 'WHERE' => 'old_id=' . $lrow['ref']);
     $new_cat_id = $db->query_build($query) or error(__FILE__, __LINE__);
     $new_cat_id = $db->fetch_row($new_cat_id);
     $query = array('INSERT' => 'title, url, description, active, category_id, ip, type, payment_status, old_category_id_backup', 'INTO' => 'links', 'VALUES' => '"' . $lrow['title'] . '", "' . $lrow['url'] . '", "' . $lrow['description'] . '", ' . ($lrow['accepted'] == 'y' ? 1 : 0) . ', ' . $new_cat_id[0] . ',  "' . $lrow['ip'] . '", "a", "ok", ' . $lrow['category']);
     $db->query_build($query) or error(__FILE__, __LINE__);
 }
 //re-sort father_ids
 $query = array('UPDATE' => 'categories', 'SET' => 'father_id=' . intval($_POST['category_id']), 'WHERE' => 'father_id=0 AND old_id<>0');
 $db->query_build($query) or error(__FILE__, __LINE__);
 $query = array('SELECT' => 'id, father_id, old_id', 'FROM' => 'categories', 'WHERE' => 'father_id <> ' . intval($_POST['category_id']) . ' AND old_id<>0 ORDER BY father_id ASC');
 $sql_resort = $db->query_build($query) or error(__FILE__, __LINE__);
 while ($res = $db->fetch_assoc($sql_resort)) {
     $query = array('SELECT' => 'id', 'FROM' => 'categories', 'WHERE' => 'old_id=' . $res['father_id']);
     $get_id = $db->query_build($query) or error(__FILE__, __LINE__);
     $get_id = $db->fetch_row($get_id);
     $query = array('UPDATE' => 'categories', 'SET' => 'father_id=' . intval($get_id[0]), 'WHERE' => 'id=' . $res['id']);
     $db->query_build($query) or error(__FILE__, __LINE__);
 }