function set_config($config)
 {
     parent::set_config($config);
     if (!empty($this->config['slave'])) {
         $sid = array_rand($this->config['slave']);
         $this->slaveid = 1000 + $sid;
         $this->config[$this->slaveid] = $this->config['slave'][$sid];
         if ($this->config['common']['slave_except_table']) {
             $this->excepttables = explode(',', str_replace(' ', '', $this->config['common']['slave_except_table']));
         }
         unset($this->config['slave']);
     }
 }
Exemple #2
0
    }
    include_once DISCUZ_ROOT . './uc_client/lib/xml.class.php';
    $post = xml_unserialize(file_get_contents('php://input'));
    if (in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcredit', 'getcreditsettings', 'updatecreditsettings', 'addfeed'))) {
        $uc_note = new uc_note();
        echo $uc_note->{$get}['action']($get, $post);
        exit;
    } else {
        exit(API_RETURN_FAILED);
    }
} else {
    define('DISCUZ_ROOT', $app['extra']['apppath']);
    require_once DISCUZ_ROOT . './config/config_global.php';
    require_once DISCUZ_ROOT . './source/class/class_core.php';
    $discuz = new db_mysql();
    $discuz->set_config($_config['db']);
    $discuz->connect();
}
class uc_note
{
    var $dbconfig = '';
    var $db = '';
    var $tablepre = '';
    var $appdir = '';
    function _serialize($arr, $htmlon = 0)
    {
        if (!function_exists('xml_serialize')) {
            include_once DISCUZ_ROOT . './uc_client/lib/xml.class.php';
        }
        return xml_serialize($arr, $htmlon);
    }
Exemple #3
0
function mysql_connect_test($config, $type)
{
    global $setting;
    static $error_code = array('connect_error' => -1, 'table_error' => -2);
    static $db;
    $ret = true;
    if ($db === null) {
        require_once DISCUZ_ROOT . './include/db.class.php';
        $db = new db_mysql();
    }
    $db->set_config($config);
    $check = $db->connect(false);
    if (!$check) {
        $ret = $error_code['connect_error'];
    } else {
        if (isset($setting['tablecheck'][$type])) {
            $find = $db->fetch_first("SHOW TABLES LIKE '{$config[tablepre]}{$setting['tablecheck'][$type]}'");
            if (!$find) {
                $ret = $error_code['table_error'];
            }
        }
    }
    $db->close();
    return $ret;
}