예제 #1
0
function connectMitraDb()
{
    global $mitradb, $SqlDatabase;
    $rs = $SqlDatabase->FetchRow("SELECT Data FROM FSetting s WHERE s.UserID = '-1' AND s.Type = 'mitra' AND s.Key = 'database';");
    $settings = json_decode($rs['Data']);
    $mitradb = new SqlDatabase();
    if ($mitradb->open($settings->host, $settings->username, $settings->password)) {
        if ($mitradb->SelectDatabase($settings->database)) {
            return true;
        } else {
            die('fail<!--separate-->Could find database ' . $settings->database . '. Is your configuration correct?');
        }
    } else {
        die('fail<!--separate-->Could not connect to Mitra database at ' . $settings->host . '. Is your configuration correct?');
    }
}
예제 #2
0
파일: friend.php 프로젝트: seem8/friendup
 $Config->Hostname = $ar['host'];
 $Config->Username = $ar['login'];
 $Config->Password = $ar['password'];
 $Config->DbName = $ar['dbname'];
 $Config->FCHost = $ar['fchost'];
 $Config->FCPort = $ar['fcport'];
 $Config->FCUpload = $ar['fcupload'];
 // Temporary folder
 $Config->FCTmp = isset($ar['fctmp']) ? $ar['fctmp'] : '/tmp/';
 if (substr($Config->FCTmp, -1, 1) != '/') {
     $Config->FCTmp .= '/';
 }
 $GLOBALS['Config'] =& $Config;
 $SqlDatabase = new SqlDatabase();
 $SqlDatabase->Open($ar['host'], $ar['login'], $ar['password']);
 $SqlDatabase->SelectDatabase($ar['dbname']);
 $GLOBALS['SqlDatabase'] =& $SqlDatabase;
 // User application info
 $UserApplication = false;
 // Get user information
 $User = new dbIO('FUser');
 if (isset($GLOBALS['args']->sessionid)) {
     $User->SessionID = $GLOBALS['args']->sessionid;
     $User = $User->FindSingle();
     //$logger->log( 'User logged in with sessionid:' . ( $User ? ( $User->ID . ' ' . print_r( $args, 1 ) ) : ( 'No user id!' . print_r( $args, 1 ) ) ) );
 }
 if (isset($User->SessionID) && trim($User->SessionID) && $User->Load()) {
     //$logger->log( 'fop' );
     $GLOBALS['User'] =& $User;
 } else {
     //$logger->log( 'lop' );