Example #1
0
function connect_db()
{
    global $myserv;
    $myserv = mysql_connect("localhost", MYSQL_USER, MYSQL_PASSWD);
    mysql_select_db(MYSQL_DATABASE);
    mysql_set_charset('utf8');
}
Example #2
0
function getTangentText($type, $keyword)
{
    global $dbHost, $dbUser, $dbPassword, $dbName;
    $link = @mysql_connect($dbHost, $dbUser, $dbPassword);
    if (!$link) {
        die("Cannot connect : " . mysql_error());
    }
    if (!@mysql_select_db($dbName, $link)) {
        die("Cannot find database : " . mysql_error());
    }
    $result = mysql_query("SELECT sr_keywords, sr_text FROM soRandom WHERE sr_type = '" . $type . "' ORDER BY sr_ID ASC;", $link);
    $tempCounter = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $pKey = "/" . $keyword . "/";
        $pos = preg_match($pKey, $row['sr_keywords']);
        //echo $pos . " is pos<br>";
        //echo $keyword;
        //echo " is keyword and this is the search return: " . $row['keywords'];
        if ($pos != 0) {
            $text[$tempCounter] = stripslashes($row["sr_text"]);
            $tempCounter++;
        }
    }
    mysql_close($link);
    //$text=htmlentities($text);
    return $text;
}
Example #3
0
 function db($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'utf8', $pconnect = 0)
 {
     if ($pconnect) {
         if (!($this->mlink = @mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     } else {
         if (!($this->mlink = @mysql_connect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     }
     if ($this->version() > '4.1') {
         if ('utf-8' == strtolower($dbcharset)) {
             $dbcharset = 'utf8';
         }
         if ($dbcharset) {
             mysql_query("SET character_set_connection={$dbcharset}, character_set_results={$dbcharset}, character_set_client=binary", $this->mlink);
         }
         if ($this->version() > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->mlink);
         }
     }
     if ($dbname) {
         mysql_select_db($dbname, $this->mlink);
     }
 }
function Global_Init()
{
    //session_start();
    Load_Configs();
    if (!strnatcasecmp(trim($GLOBALS['db']['type']), "LB")) {
        require_once 'inc/dbmodule_LB.php';
    }
    if (!strnatcasecmp(trim($GLOBALS['db']['type']), "GD")) {
        require_once 'inc/dbmodule_GD.php';
    }
    //echo "GLOBALS: <BR>"; print_r($GLOBALS['db']); echo "<BR>";
    $source_db_ok = SQL_DB_OK("source");
    if ($source_db_ok['error'] === false) {
        $GLOBALS['db']['s_resource'] = @mysql_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server. : " . mysql_error());
        @mysql_selectdb($GLOBALS['db']['s_base']) or die("Could not connect to Source database [" . $GLOBALS['db']['s_base'] . "] : " . mysql_error());
        $GLOBALS['db']['x_resource'] = @mysql_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray  MySQL Server. : " . mysql_error());
        @mysql_selectdb($GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database [" . $GLOBALS['db']['x_base'] . "] : " . mysql_error());
        $GLOBALS['db']['s_link'] = mysqli_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass'], $GLOBALS['db']['s_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['s_link']));
        mysqli_select_db($GLOBALS['db']['s_link'], $GLOBALS['db']['s_base']) or die("Could not connect to Source database (multilink) [" . $GLOBALS['db']['s_base'] . "] : " . mysqli_error($GLOBALS['db']['s_link']));
        $GLOBALS['db']['x_link'] = mysqli_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass'], $GLOBALS['db']['x_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['x_link']));
        mysqli_select_db($GLOBALS['db']['x_link'], $GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database (multilink) [" . $GLOBALS['db']['x_base'] . "] : " . mysqli_error($GLOBALS['db']['x_link']));
    } else {
        $config_error .= $source_db_ok['message'] . "<BR>";
    }
    //	array_key_exists('form', $_POST) && $_POST['form']!="" ? $_GET = $_POST : NULL;
    //	array_key_exists('force', $_GET) && $_GET['force']!="" ? $_POST = $_GET : NULL;
    if (count($_GET) > 0) {
        $_POST = $_GET;
    }
    //	if($_POST['form']!=""){$_GET = $_POST;}
    //	if($_GET['force']!=""){$_POST = $_GET;}
    if (!FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true)) {
        $GLOBALS['worlds'] = Get_Worlds_Enabled();
    }
}
 private function validate()
 {
     if (!defined('DB_HOSTNAME')) {
         $this->error['warning'] = 'Host required!';
     }
     if (!defined('DB_USERNAME')) {
         $this->error['warning'] = 'User required!';
     }
     if (!defined('DB_DATABASE')) {
         $this->error['warning'] = 'Database Name required!';
     }
     if (!($connection = @mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD))) {
         $this->error['warning'] = 'Error: Could not connect to the database please make sure the database server, username and password is correct in the config.php file!';
     } else {
         if (!@mysql_select_db(DB_DATABASE, $connection)) {
             $this->error['warning'] = 'Error: Database "' . DB_DATABASE . '" does not exist!';
         }
         mysql_close($connection);
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
Example #6
0
 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         if ($this->pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
Example #7
0
 /**
  * DB Connect
  * this method is private
  * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
  * @return resource
  */
 function __connect($connection)
 {
     // Ignore if no DB information exists
     if (strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) {
         $connection["db_hostname"] .= ':' . $connection["db_port"];
     }
     // Attempt to connect
     $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
     if (!$result) {
         exit('XE cannot connect to DB.');
     }
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     // Error appears if the version is lower than 4.1
     if (version_compare(mysql_get_server_info($result), '4.1', '<')) {
         $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is ' . mysql_get_server_info());
         return;
     }
     // select db
     @mysql_select_db($connection["db_database"], $result);
     if (mysql_error()) {
         $this->setError(mysql_errno(), mysql_error());
         return;
     }
     return $result;
 }
function db_connect()
{
    // połączenie z mysql
    mysql_connect(DBHOST, DBUSER, DBPASS) or die('<h2>ERROR</h2> MySQL Server is not responding');
    // wybór bazy danych
    mysql_select_db(DBNAME) or die('<h2>ERROR</h2> Cannot connect to specified database');
}
Example #9
0
 /**
  * 连接数据库方法
  * @access public
  * @throws ThinkExecption
  */
 public function connect($config = '', $linkNum = 0, $force = false)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         // 是否长连接
         $pconnect = !empty($config['params']['persist']) ? $config['params']['persist'] : $this->pconnect;
         if ($pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum]) || C('SPARE_DB_DEBUG')) {
             $errStr = mysql_error();
             $errno = mysql_errno();
             if ($errno == 13047 || C('SPARE_DB_DEBUG')) {
                 if (C('SMS_ALERT_ON')) {
                     Sms::send('mysql超额被禁用,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
                 }
                 //[sae]启动备用数据库
                 if (C('SPARE_DB_HOST')) {
                     $this->linkID[$linkNum] = mysql_connect(C('SPARE_DB_HOST') . (C('SPARE_DB_PORT') ? ':' . C('SPARE_DB_PORT') : ''), C('SPARE_DB_USER'), C('SPARE_DB_PWD'), true, CLIENT_MULTI_RESULTS);
                     if (!$this->linkID[$linkNum]) {
                         throw_exception('备用数据库连接失败');
                     }
                     mysql_select_db(C('SPARE_DB_NAME'), $this->linkID[$linkNum]);
                     //标记使用备用数据库状态
                     $this->is_spare = true;
                 } else {
                     throw_exception($errStr);
                 }
             } else {
                 //[sae] 短信预警
                 if (C('SMS_ALERT_ON')) {
                     Sms::send('数据库连接时出错,请在SAE日志中心查看详情', $errStr, Sms::MYSQL_ERROR);
                 }
                 throw_exception($errStr);
             }
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= '4.1') {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
Example #10
0
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
    $link=mysql_connect ("$servername","$dbuser","$dbpassword",TRUE);
    if(!$link){die("Could not connect to MySQL");}
    mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
    return $link;
}
Example #11
0
function check_connection($user, $pass, $host)
{
    if (!($connection = @mysql_connect("{$host}", "{$user}", "{$pass}"))) {
        return false;
    }
    return $connection;
}
Example #12
0
function HackingLog()
{
    echo "You're not allowed to use this program! This attempted violation has been logged and your IP address was captured.";
    Warehouse('footer');
    if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    if ($openSISNotifyAddress) {
        mail($openSISNotifyAddress, 'HACKING ATTEMPT', "INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
    }
    /*if($openSISNotifyAddress)
    		mail($openSISNotifyAddress,'HACKING ATTEMPT',"INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");*/
    if (false && function_exists('mysql_query')) {
        if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        $link = @mysql_connect('os4ed.com', 'openSIS_log', 'openSIS_log');
        @mysql_select_db('openSIS_log');
        @mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('{$_SERVER['SERVER_NAME']}','{$ip}','" . date('Y-m-d') . "','{$openSISVersion}','{$_SERVER['PHP_SELF']}','{$_SERVER['DOCUMENT_ROOT']}','{$_SERVER['SCRIPT_NAME']}','{$_REQUEST['modname']}','" . User('USERNAME') . "')");
        @mysql_close($link);
        /*$link = @mysql_connect('os4ed.com','openSIS_log','openSIS_log');
        		@mysql_select_db('openSIS_log');
        		@mysql_query("INSERT INTO HACKING_LOG (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$_SERVER[REMOTE_ADDR]','".date('Y-m-d')."','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','".User('USERNAME')."')");
        		@mysql_close($link);*/
    }
}
Example #13
0
function Open($dbType, $connectType = "c", $connect, $username = "", $password = "", $dbName)
{
    switch ($dbType) {
        case "mssql":
            if ($connectType == "c") {
                $idCon = mssql_connect($connect, $username, $password);
            } else {
                $idCon = mssql_pconnect($connect, $username, $password);
            }
            mssql_select_db($dbName);
            break;
        case "mysql":
            if ($connectType == "c") {
                $idCon = @mysql_connect($connect, $username, $password);
            } else {
                $idCon = @mysql_pconnect($connect, $username, $password);
            }
            $idCon1 = mysql_select_db($dbName, $idCon);
            break;
        case "pg":
            if ($connectType == "c") {
                $idCon = pg_connect($connect . " user="******" password="******" dbname=" . $dbName);
            } else {
                $idCon = pg_pconnect($connect . " user="******" password="******" dbname=" . $dbName);
            }
            break;
        default:
            $idCon = 0;
            break;
    }
    return $idCon;
}
 function connect()
 {
     require_once 'db_config.php';
     $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
     $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
     return $con;
 }
Example #15
0
 private function dbConnection()
 {
     // Stabilisce connessione al DB
     $this->connectionResource = @mysql_connect($this->DB_HOST, $this->DB_USER, $this->DB_PASS) or conf::showerror();
     $dbSelect = @mysql_select_db($this->DB_NAME, $this->connectionResource) or conf::showerror();
     mysql_query("set names utf8") or conf::showerror();
 }
Example #16
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->authorizeObj = new authorize($this->testSubject['employeeId'], $this->testSubject['isAdmin']);
     $conf = new Conf();
     $this->connection = mysql_connect($conf->dbhost . ":" . $conf->dbport, $conf->dbuser, $conf->dbpass);
     mysql_select_db($conf->dbname);
     $this->_deleteTestData();
     // Insert job titles
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB001', 'Manager', 'Manager job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB002', 'Driver', 'Driver job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " . "VALUES('JOB003', 'Director', 'Director job title', 'no comments', null)");
     $this->_runQuery("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_nick_name, coun_code) " . "VALUES (11, NULL, 'Arnold', 'Subasinghe', 'Arnold', 'AF')");
     $this->_runQuery("INSERT INTO `hs_hr_employee`(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, emp_nick_name) " . "VALUES (12, NULL, 'Mohanjith', 'Sudirikku', 'Hannadige', 'MOHA')");
     // employees with job titles
     // Driver
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(13, '0013', 'Rajasinghe', 'Saman', 'Marlon', 'JOB002', '*****@*****.**')");
     // Manager
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(14, '0014', 'Jayasinghe', 'Aruna', 'Shantha', 'JOB001', '*****@*****.**')");
     // Insert director
     $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code, emp_work_email) " . "VALUES(15, '0032', 'Samuel', 'John', 'A', 'JOB003', '*****@*****.**')");
     mysql_query("INSERT INTO `hs_hr_emp_reportto` VALUES ('012', '011', 1);");
     mysql_query("INSERT INTO hs_hr_customer(customer_id, name, description, deleted) " . "VALUES(1, 'Test customer', 'description', 0)");
     mysql_query("INSERT INTO hs_hr_project(project_id, customer_id, name, description, deleted) " . "VALUES(1, 1, 'Test project 1', 'a test proj 1', 0)");
     mysql_query("INSERT INTO hs_hr_project(project_id, customer_id, name, description, deleted) " . "VALUES(2, 1, 'Test project 2', 'a test proj 2', 0)");
 }
Example #17
0
 function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre = '', $time = 0)
 {
     $this->dbhost = $dbhost;
     $this->dbuser = $dbuser;
     $this->dbpw = $dbpw;
     $this->dbname = $dbname;
     $this->dbcharset = $dbcharset;
     $this->pconnect = $pconnect;
     $this->tablepre = $tablepre;
     $this->time = $time;
     if ($pconnect) {
         if (!($this->link = mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL server');
         }
     } else {
         if (!($this->link = mysql_connect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL server');
         }
     }
     if ($this->version() > '4.1') {
         if ($dbcharset) {
             mysql_query("SET character_set_connection=" . $dbcharset . ", character_set_results=" . $dbcharset . ", character_set_client=binary", $this->link);
         }
         if ($this->version() > '5.0.1') {
             //mysql_query("SET sql_mode=''", $this->link); //关闭严格模式
         }
     }
     if ($dbname) {
         mysql_select_db($dbname, $this->link);
     }
 }
Example #18
0
 private function __construct()
 {
     $this->connection = mysql_connect(DB_HOST, DB_USER, DB_PASS);
     if ($this->connection) {
         mysql_select_db(DB_NAME);
     }
 }
Example #19
0
/**
 * Connects to a database. After connecting, you should always call disconnect_db() to close it when
 * done.
 */
function gd_db_connect()
{
    global $g_table_prefix, $g_db_hostname, $g_db_username, $g_db_password, $g_db_name;
    $link = mysql_connect($g_db_hostname, $g_db_username, $g_db_password) or die("Couldn't connect to database.");
    @mysql_select_db($g_db_name) or die("couldn't find database '{$g_db_name}'.");
    return $link;
}
Example #20
0
 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->password = $sqlpassword;
     $this->server = $sqlserver;
     $this->dbname = $database;
     if ($this->persistency) {
         $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
     } else {
         $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
     }
     if ($this->db_connect_id) {
         if ($database != "") {
             $this->dbname = $database;
             $dbselect = @mysql_select_db($this->dbname);
             if (!$dbselect) {
                 @mysql_close($this->db_connect_id);
                 $this->db_connect_id = $dbselect;
             }
         }
         return $this->db_connect_id;
     } else {
         return false;
     }
 }
Example #21
0
 function DBConnection($aDBInfo)
 {
     global $aQueries;
     // Initialize query array.
     $aQueries = array();
     // Populate the special queries list.
     $this->aSpecialQueries[CONCAT_ATTACHMENT] = "UPDATE attachment SET filedata = concat(filedata, '%s') WHERE id=%u";
     $this->aSpecialQueries[CONCAT_AVATAR] = "UPDATE avatar SET datum = concat(datum, '%s') WHERE id=%u";
     // Try and connect to the database server.
     if ($this->objConnection = @mysql_connect($aDBInfo['address'], $aDBInfo['username'], $aDBInfo['password'])) {
         // Try and select our database.
         if (@mysql_select_db($aDBInfo['database'])) {
             // Destroy the database connection information.
             unset($aDBInfo['address']);
             unset($aDBInfo['username']);
             unset($aDBInfo['password']);
             unset($aDBInfo['database']);
             // Flag selection success.
             $this->objSelect = TRUE;
         } else {
             // Flag selection failure.
             $this->objSelect = FALSE;
         }
     } else {
         // Flag connection failure.
         $this->objConnection = FALSE;
     }
 }
Example #22
0
 /**
  * 连接数据库方法
  * @access public
  * @throws ThinkExecption
  */
 public function connect($config='',$linkNum=0,$force=false) {
     if ( !isset($this->linkID[$linkNum]) ) {
         if(empty($config))  $config =   $this->config;
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'].($config['hostport']?":{$config['hostport']}":'');
         // 是否长连接
         $pconnect   = !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
         if($pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],131072);
         }else{
             $this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,131072);
         }
         if ( !$this->linkID[$linkNum] || (!empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) ) {
             E(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         //使用UTF8存取数据库
         mysql_query("SET NAMES '".C('DB_CHARSET')."'", $this->linkID[$linkNum]);
         //设置 sql_model
         if($dbVersion >'5.0.1'){
             mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected    =   true;
         // 注销数据库连接配置信息
         if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
     }
     return $this->linkID[$linkNum];
 }
function alertnoticias_consultar($consulta,$accion)
{
	$enlace = mysql_connect('atc-nh-natsdb.nationalnet.com', 'staffcenter','XgwofvLY2ayLf') or die('No pudo conectarse : ' . mysql_error());
	mysql_select_db('staffcenter',$enlace) or die('No pudo seleccionarse la BD.');
	$sql = $consulta;
	$resultado = mysql_query($sql,$enlace) or die('La consulta fall&oacute;: ' . mysql_error());
	while ($row = mysql_fetch_array($resultado)){
	
		switch($accion)
		{
			case "noticiasdeldia":
				$idsnoticias[]=$row['idnoticia'].",".$row['titulo'];
			break;
		
		}
	}
	mysql_free_result($resultado);
	
	switch($accion)
	{
		case "noticiasdeldia":
			return $idsnoticias;
		break;
	}
}
Example #24
0
/**
 *
 */
function validate_request()
{
    global $_REQUEST;
    $errors = array();
    $link = @mysql_connect($_REQUEST['dbhost'], $_REQUEST['dbuser'], $_REQUEST['dbpass']);
    if (!$link) {
        $errors['db'][] = "Unable to connect to the database. Please check your credentials and try again.";
    }
    if (!mysql_select_db($_REQUEST['dbname'])) {
        $errors['db'][] = "The database name you specified does not exist.";
    }
    require_once "include/class.twitter.php";
    $twitter = new twitter();
    $twitter->username = $_REQUEST['twuser'];
    $twitter->password = $_REQUEST['twpass'];
    if (!$twitter->verifyCredentials()) {
        $errors['twitter'][] = 'The Twitter username and password you entered is incorrect. Do you need <a href="http://twitter.com/account/resend_password">a reminder of your password</a>?';
    }
    // make sure tag has a value
    // make sure title and subtitle exists
    // make sure cache is writable
    if (count($errors) == 0) {
        return NULL;
    }
    return $errors;
}
Example #25
0
 /**
  * Construct the OAuthStoreMySQL.
  * In the options you have to supply either:
  * - server, username, password and database (for a mysql_connect)
  * - conn (for the connection to be used)
  * 
  * @param array options
  */
 function __construct($options = array())
 {
     if (isset($options['conn'])) {
         $this->conn = $options['conn'];
     } else {
         if (isset($options['server'])) {
             $server = $options['server'];
             $username = $options['username'];
             if (isset($options['password'])) {
                 $this->conn = mysql_connect($server, $username, $options['password']);
             } else {
                 $this->conn = mysql_connect($server, $username);
             }
         } else {
             // Try the default mysql connect
             $this->conn = mysql_connect();
         }
         if ($this->conn === false) {
             throw new OAuthException2('Could not connect to MySQL database: ' . mysql_error());
         }
         if (isset($options['database'])) {
             if (!mysql_select_db($options['database'], $this->conn)) {
                 $this->sql_errcheck();
             }
         }
         $this->query('set character set utf8');
     }
 }
Example #26
0
 function _Connect()
 {
     $value = false;
     if (!$this->connected) {
         if (!$this->server) {
             $this->server = 'localhost';
         }
         $host = $this->server;
         if ($this->port) {
             $host .= ':' . $this->port;
         }
         $this->link_id = mysql_connect($host, $this->username, $this->password);
     }
     if ($this->link_id > 0) {
         if (empty($this->database)) {
             $value = true;
         } elseif ($this->link_id !== -1) {
             $value = mysql_select_db($this->database, $this->link_id);
         } else {
             $value = mysql_select_db($this->database);
         }
     }
     if (!$value) {
         $this->error = mysql_error();
     }
     return $value;
 }
Example #27
0
function MSD_mysql_connect($encoding = 'utf8', $keycheck_off = false, $actual_table = '')
{
    global $config, $databases;
    $port = isset($config['dbport']) && !empty($config['dbport']) ? ':' . $config['dbport'] : '';
    $socket = isset($config['dbsocket']) && !empty($config['dbsocket']) ? ':' . $config['dbsocket'] : '';
    $config['dbconnection'] = mysql_connect($config['dbhost'] . $port . $socket, $config['dbuser'], $config['dbpass']) or die(SQLError("Database connection error: ", mysql_error()));
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    if (!isset($config['mysql_standard_character_set']) || $config['mysql_standard_character_set'] == '') {
        get_sql_encodings();
    }
    if ($config['mysql_standard_character_set'] != $encoding) {
        $set_encoding = @mysql_query('SET NAMES \'' . $encoding . '\'', $config['dbconnection']);
        if ($set_encoding === false) {
            $config['mysql_can_change_encoding'] = false;
        } else {
            $config['mysql_can_change_encoding'] = true;
        }
    }
    if ($keycheck_off) {
        mysql_query('SET FOREIGN_KEY_CHECKS=0', $config['dbconnection']);
    }
    return $config['dbconnection'];
}
Example #28
0
 /**
  * Non-persistent database connection
  *
  * @access	private called by the base class
  * @return	resource
  */
 private function db_connect()
 {
     if ($this->port != '') {
         $this->db_hostname .= ':' . $this->port;
     }
     return @mysql_connect($this->db_hostname, $this->db_username, $this->db_password, TRUE);
 }
 function connect($zf_host, $zf_user, $zf_password, $zf_database, $zf_pconnect = 'false', $zp_real = false)
 {
     $this->database = $zf_database;
     // pconnect disabled
     if (!$zf_pconnect == 'false') {
         $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
     } else {
         $this->link = @mysql_connect($zf_host, $zf_user, $zf_password, true);
     }
     if ($this->link) {
         if (@mysql_select_db($zf_database, $this->link)) {
             $this->db_connected = true;
             // set the character set
             $sql = "SET NAMES utf8";
             mysql_query($sql, $this->link);
             $sql = "SET CHARACTER SET utf8";
             mysql_query($sql, $this->link);
             return true;
         } else {
             $this->set_error(mysql_errno(), mysql_error(), $zp_real);
             return false;
         }
     } else {
         $this->set_error(mysql_errno(), mysql_error(), $zp_real);
         return false;
     }
 }
Example #30
0
function runSQL($query)
{
    global $conf;
    $link = mysql_connect($conf['db_hostname'], $conf['db_user'], $conf['db_password']);
    mysql_select_db($conf['db_name']);
    return mysql_query($query);
}