예제 #1
0
/**
 * - JINZORA | Web-based Media Streamer -  
 * 
 * Jinzora is a Web-based media streamer, primarily desgined to stream MP3s 
 * (but can be used for any media file that can stream from HTTP). 
 * Jinzora can be integrated into a CMS site, run as a standalone application, 
 * or integrated into any PHP website.  It is released under the GNU GPL.
 * 
 * - Resources -
 * - Jinzora Author: Ross Carlson <*****@*****.**>
 * - Web: http://www.jinzora.org
 * - Documentation: http://www.jinzora.org/docs	
 * - Support: http://www.jinzora.org/forum
 * - Downloads: http://www.jinzora.org/downloads
 * - License: GNU GPL <http://www.gnu.org/copyleft/gpl.html>
 * 
 * - Contributors -
 * Please see http://www.jinzora.org/modules.php?op=modload&name=jz_whois&file=index
 * 
 * - Code Purpose -
 * This is the media backend for the database adaptor.
 *
 * @since 05.10.04
 * @author Ben Dodson <*****@*****.**>
 */
function jz_db_connect()
{
    global $sql_type, $sql_pw, $sql_socket, $sql_db, $sql_usr;
    switch ($sql_type) {
        case "DBX_MSSQL":
            $sqlt = DBX_MSSQL;
            break;
        case "DBX_ODBC":
            $sqlt = DBX_ODBC;
            break;
        case "DBX_FBSQL":
            $sqlt = DBX_FBSQL;
            break;
        case "DBX_SYBASECT":
            $sqlt = DBX_SYBASECT;
            break;
        case "DBX_OCI8":
            $sqlt = DBX_OCI8;
            break;
        case "DBX_SQLITE":
            $sqlt = DBX_SQLITE;
            break;
    }
    return dbx_connect($sqlt, $sql_socket, $sql_db, $sql_usr, $sql_pw);
}
function da_sql_pconnect($config)
{
    if ($config[sql_use_http_credentials] == 'yes') {
        global $HTTP_SERVER_VARS;
        $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
        $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
    } else {
        $SQL_user = $config[sql_username];
        $SQL_passwd = $config[sql_password];
    }
    // FIXME: This function is still Postgres specific. Needs to be configurable.
    return @dbx_connect(DBX_PGSQL, "{$server}", "{$config['sql_database']}", "{$SQL_user}", "{$SQL_passwd}", DBX_PERSISTENT);
}
예제 #3
0
 /**
  * Get a database connection. This function shouldn't be used by you, as a connection to the database is established automatically.
  *
  * @param  boolean		Whether to create a persistant connection
  * @param  string			The database name
  * @param  string			The database host (the server)
  * @param  string			The database connection username
  * @param  string			The database connection password
  * @param  boolean		Whether to on error echo an error and return with a NULL, rather than giving a critical error
  * @return ?array			A database connection (note for mySQL, it's actually a pair, containing the database name too: because we need to select the name before each query on the connection) (NULL: error)
  */
 function db_get_connection($persistent, $db_name, $db_host, $db_user, $db_password, $fail_ok = false)
 {
     if (!function_exists('dbx_connect')) {
         $error = 'dbx not on server (anymore?). Try using the \'mysql\' database driver. To use it, edit the info.php config file.';
         if ($fail_ok) {
             echo $error;
             return NULL;
         }
         critical_error('PASSON', $error);
     }
     // Potential cacheing
     global $CACHE_DB;
     $x = serialize(array($db_name, $db_host));
     if (array_key_exists($x, $CACHE_DB)) {
         return array($x, $db_name);
     }
     $db = @dbx_connect('mysql', $db_host, $db_name, $db_user, $db_password, $persistent ? 1 : 0);
     if ($db === false || is_null($db)) {
         $error = 'Could not connect to database/database-server';
         if ($fail_ok) {
             echo $error . chr(10);
             return NULL;
         }
         critical_error('PASSON', $error);
         //warn_exit(do_lang_tempcode('CONNECT_DB_ERROR')); // purposely not ===false
     }
     global $LAST_SELECT_DB;
     $LAST_SELECT_DB = $db;
     global $SITE_INFO;
     if (!array_key_exists('database_charset', $SITE_INFO)) {
         $SITE_INFO['database_charset'] = strtolower(get_charset()) == 'utf-8' ? 'utf8' : 'latin1';
     }
     @dbx_query($db, 'SET NAMES "' . addslashes($SITE_INFO['database_charset']) . '"');
     @dbx_query($db, 'SET SQL_BIG_SELECTS=1');
     if (get_forum_type() == 'ocf') {
         @dbx_query($db, 'SET sql_mode=STRICT_ALL_TABLES');
     }
     return array($db, $db_name);
 }
 function auth($user, $pass, $args)
 {
     $r = $db_pw = false;
     $dsn = access_query("authanydb", 0);
     $col_login = access_query("authanydblogincolumn", 0) or $col_login = "******";
     $col_pass = access_query("authanydbpasswordcolumn", 0) or $col_pass = "******";
     $desc = parse_url($dsn);
     $desc["database"] = strtok($desc["path"], "/");
     $table = strtok("/");
     $dsn = substr($dsn, 0, strrpos($dsn, "/"));
     if (function_exists("newadoconnection") && ($db = NewAdoConnection($desc["scheme"])) && $db->connect($desc["host"], $desc["user"], $desc["pass"], $desc["database"])) {
         $user = $db->qstr($user);
         $SQL = "SELECT {$col_pass} FROM {$table} WHERE {$col_login}={$user}";
         if ($row = $db->GetRow($SQL)) {
             $db_pw = $row[0];
         }
         $db->Close();
     } elseif (class_exists("DB")) {
         $db = DB::connect($dsn);
         $user = $db->quoteString($user);
         $SQL = "SELECT {$col_pass} FROM {$table} WHERE {$col_login}='{$user}'";
         if ($row = $db->getRow($SQL)) {
             $db_pw = $row[0];
         }
     } elseif (function_exists("dbx_connect") && ($db = dbx_connect($desc["scheme"], $desc["host"], $desc["database"], $desc["user"], $desc["pass"]))) {
         $user = dbx_escape_string($db, $user);
         $SQL = "SELECT {$col_pass} FROM {$table} WHERE {$col_login}='{$user}'";
         if ($result = dbx_query($db, $SQL)) {
             $db_pw = $result->data[0][0];
         }
         dbx_close($db);
     } else {
         techo("mod_auth_anydb: no database interface used (db auth problem?)", NW_EL_WARNING);
         return $r = false;
     }
     $r = strlen($db_pw) && strlen($pass) && ($db_pw == $pass or $db_pw == crypt($pass, substr($db_pw, 0, 2)) or $db_pw == md5($pass));
     return $r;
 }
예제 #5
0
 function Cache_Container_dbx($options)
 {
     if (!is_array($options)) {
         return new Cache_Error('No options specified!', __FILE__, __LINE__);
     }
     $this->setOptions($options, array_merge($this->allowed_options, array('module', 'host', 'db', 'username', 'password', 'cache_table', 'persistent')));
     if (!$this->module) {
         return new Cache_Error('No module specified!', __FILE__, __LINE__);
     }
     $this->db = dbx_connect($this->module, $this->host, $this->db, $this->username, $this->password, $this->persistent);
     if (dbx_error($this->db)) {
         return new Cache_Error('DBx connect failed: ' . dbx_error($this->db), __FILE__, __LINE__);
     } else {
         //not implemented yet in dbx
         //$this->db->setFetchMode(DB_FETCHMODE_ASSOC);
     }
 }
예제 #6
0
 /**
  * DBXStore constructor
  */
 function DBXStore($server, $user, $password, $database)
 {
     // Open a database connection
     if (!is_object($this->handle = dbx_connect(DBX_MYSQL, $server, $database, $user, $password))) {
         // An error has occurred
         die("Could not open connection to MySQL database!\n");
     }
 }
예제 #7
0
파일: any.php 프로젝트: gpuenteallott/rox
 function anydb_connect($host = "localhost", $user = "", $pw = "", $dbname = "test", $dbtype = "mysql")
 {
     global $anydb_handle;
     class_exists("DB") and $db = DB::connect("{$dbtype}://{$user}:{$pw}@{$host}/{$dbname}") and is_a($db, "db_common") and ($db->setFetchMode(DB_FETCHMODE_ASSOC) or true) or function_exists("newadoconnection") and $db = NewAdoConnection($dbtype) and $db->connect($host, $user, $pw, $dbname) and ($db->setFetchMode(ADODB_FETCH_ASSOC) or true) or $dbtype[0] == "p" and function_exists("pg_connect") and $db = pg_connect("dbname={$dbname} user={$user} password={$pw}") or function_exists("mysql_connect") and $db = mysql_connect($host, $user, $pw) and mysql_query("USE {$dbname}") or function_exists("dbx_connect") and $db = dbx_connect($dbtype, $host, $dbname, $user, $pw) or $db = false;
     if ($anydb_handle = $db) {
         $charset = EWIKI_DB_UTF8 ? "UTF8" : "ISO-8859-1";
         @anydb_query("SET NAMES '{$charset}'");
         #-- not all databases support this
     }
     return $db;
 }