Exemplo n.º 1
0
function connexion_base()
{
    $DB = NewADOConnection(BASE_TYPE);
    $DB->Connect(SERVEURBASE, USERBASE, USERPASSWD, BASE);
    //$DB->debug = true;
    return $DB;
}
Exemplo n.º 2
0
 /**
  * Connect to database.
  */
 public static function Connect()
 {
     if (isset(self::$ado)) {
         //return forced new adodb connection
         $new = NewADOConnection(DATABASE_DRIVER);
         $new->autoRollback = true;
         // default is false
         if (!@$new->NConnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME)) {
             throw new Exception("Connect to database failed");
         }
     } else {
         self::$ado = NewADOConnection(DATABASE_DRIVER);
         self::$ado->autoRollback = true;
         // default is false
         if (!@self::$ado->Connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME)) {
             die("Connect to database failed");
         }
         $new = self::$ado;
     }
     if (self::is_mysql()) {
         // For MySQL
         $new->Execute('SET NAMES "utf8"');
     } elseif (self::is_postgresql()) {
         // For PostgreSQL
         @$new->Execute('SET bytea_output = "escape";');
     }
     return $new;
 }
Exemplo n.º 3
0
 function setup()
 {
     if ($this->isType('mysql')) {
         if ($this->getCreateTarget() == true) {
             $this->connection =& NewADOConnection($this->dbConfig->getDBType());
             $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getRootUserName(), $this->dbConfig->getRootPassword());
             if (!$ok) {
                 throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']);
             }
             // Drop database if already exists
             $sql = "drop database IF EXISTS " . $this->dbConfig->getDatabaseName();
             $result = $this->connection->Execute($sql);
             $this->checkError($result, $sql);
             $sql = 'create database ' . $this->dbConfig->getDatabaseName();
             if ($this->supportUTF8 == true) {
                 $sql .= " default character set utf8 default collate utf8_general_ci";
             }
             $result = $this->connection->Execute($sql);
             $this->checkError($result, $sql);
             $this->connection->Close();
         }
         $this->connection =& NewADOConnection($this->dbConfig->getDBType());
         $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getUserName(), $this->dbConfig->getPassword(), $this->dbConfig->getDatabaseName());
         if (!$ok) {
             throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']);
         }
         $result = $this->connection->_Execute("SET interactive_timeout=28800", false);
         $result = $this->connection->_Execute("SET wait_timeout=28800", false);
         $result = $this->connection->_Execute("SET net_write_timeout=900", false);
     }
 }
Exemplo n.º 4
0
 /**
  * Open a connection to the database and set connection parameters
  * @param string $dbhost hostname where the database server uses
  * @param string $dbuser username to connect to the database
  * @param string $dbpass password to connect to the database
  * @param string $dbname
  * @param string $dbtype database driver to use, currently :
  *  "mysql", "mysqli","pdo_mysql" "pgsql", "pdo_pgsql" should work correctly.
  * @param string $dbprefix database prefix.
  */
 public function dbOpen($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '', $dbtype = '', $dbprefix = '')
 {
     $this->dbtype = $dbtype;
     $this->dbprefix = $dbprefix;
     $ADODB_COUNTRECS = false;
     $this->dblink = NewADOConnection($this->dbtype);
     $this->dblink->Connect($dbhost, $dbuser, $dbpass, $dbname);
     if ($this->dblink === false || !empty($this->dbprefix) && !preg_match('/^[a-z][a-z0-9_]+$/i', $this->dbprefix)) {
         die('Flyspray was unable to connect to the database. ' . 'Check your settings in flyspray.conf.php');
     }
     $this->dblink->SetFetchMode(ADODB_FETCH_BOTH);
     /*
      * this will work only in the following systems/PHP versions
      *
      * PHP4 and 5 with postgresql
      * PHP5 with "mysqli" or "pdo_mysql" driver (not "mysql" driver)
      * using mysql 4.1.11 or later and mysql 5.0.6 or later.
      *
      * in the rest of the world, it will silently return FALSE.
      */
     $this->dblink->SetCharSet('utf8');
     //enable debug if constact DEBUG_SQL is defined.
     !defined('DEBUG_SQL') || ($this->dblink->debug = true);
     if ($dbtype === 'mysql' || $dbtype === 'mysqli') {
         $dbinfo = $this->dblink->ServerInfo();
         if (isset($dbinfo['version']) && version_compare($dbinfo['version'], '5.0.2', '>=')) {
             $this->dblink->Execute("SET SESSION SQL_MODE='TRADITIONAL'");
         }
     }
 }
Exemplo n.º 5
0
function smarty_modifier_glossary($input)
{
    $plain = strtolower(preg_replace('/[^a-zA-Z0-9]+/', ' ', str_replace("'", '', strip_tags($input))));
    $words = preg_split('/ +/', $plain);
    $db = NewADOConnection($GLOBALS['DSN']);
    if (!$db) {
        die('Database connection failed');
    }
    print "<pre>{$plain}</pre>";
    $all = $db->getAssoc("select \n\tsource_word,\n\tgroup_concat(tran_word) as tran_word,\n\tgroup_concat(tran_lang) as tran_lang,\n\tgroup_concat(tran_dialect) as tran_dialect,\n\tgroup_concat(tran_definition) as tran_definition,\n\tgroup_concat(source_lang) as source_lang,\n\tgroup_concat(source_dialect) as source_dialect\n\tfrom glossary\n\tgroup by source_word");
    foreach ($all as $word => $row) {
        $wordregex = str_replace(')(*', '\\w*)(', str_replace('*)(', ')(\\w*', '(\\b)(' . $word . ')(\\b)'));
        if (strpos($row['tran_word'], ',') !== FALSE) {
            $tran_words = explode(',', $row['tran_word']);
            $tran_langs = explode(',', $row['tran_lang']);
            $tran_dialects = explode(',', $row['tran_dialect']);
            $tran_definitions = explode(',', $row['tran_definition']);
            $source_langs = explode(',', $row['source_lang']);
            $source_dialects = explode(',', $row['source_dialect']);
            $text = '';
            foreach ($tran_words as $i => $tran_word) {
                if ($text) {
                    $text .= "\n-------------------------------\n";
                }
                $text .= "Meaning: {$tran_word} ({$tran_langs[$i]} {$tran_dialects[$i]})\n{$tran_definitions[$i]}\n Source: {$source_langs[$i]} {$source_dialects[$i]}";
            }
        } else {
            $text = "Meaning: {$row['tran_word']} ({$row['tran_lang']} {$row['tran_dialect']})\n{$row['tran_definition']}\n Source: {$row['source_lang']} {$row['source_dialect']}";
        }
        $input = preg_replace('/' . $wordregex . '/i', "\$1<acronym title=\"{$text}\">\$2</acronym>\$3", $input);
    }
    return $input;
}
Exemplo n.º 6
0
 function getConnID()
 {
     require_once 'library/adodb/adodb.inc.php';
     //导入ADODB类库
     $this->connID = NewADOConnection($this->dbType);
     //生成数据库连接对象
     if ($this->dbType == 'mysql' || $this->dbType == 'mssql') {
         //如果为MySQL数据库或者SQL Server数据库
         $this->connID->Connect($this->host, $this->userName, $this->password, $this->dbName);
         //通过Connect()方法建立与数据库连接
         if ($this->dbType == 'mysql') {
             $this->connID->Execute('set names gb2312');
             //设置数据库编码
         }
     } elseif ($this->dbType == 'access') {
         //如过为ACCESS数据库
         $this->connID->Connect('Driver = {Microsoft Access Driver (*.mdb)}; Dbq =' . realpath($this->dbName) . ';Uid = ' . $this->userName . ';Pwd = ' . $this->password . ';');
     } else {
         return false;
     }
     $this->connID->debug = $this->isDebug;
     //是否调试
     return $this->connID;
     //返回数据库连接对象
 }
Exemplo n.º 7
0
Arquivo: Ak.php Projeto: joeymetal/v1
    /**
    * Gets an instance of AdoDb database connection
    *
    * Whenever a database connection is required you can get a
    * reference to the default database connection by doing:
    *
    * $db =& Ak:db(); // get an adodb instance
    * 
    * AdoDB manual can be found at http://phplens.com/adodb/
    *
    * @access public
    * @param    string    $dns    A string containing Data Source Name (information
    * regarding database connection)
    * http://phplens.com/adodb/code.initialization.html#dsnsupport
    * @static
    * @return resource Php AdoDb instance.
    */
    function &db($dsn = null, $connection_id = null)
    {
        static $db, $default_connection_id;

        // In order to retrieve a database connection we just need to provide its identifier
        if(empty($default_connection_id)){
            $default_connection_id = md5($dsn);
        }
        $connection_id = empty($connection_id) ? $default_connection_id : $connection_id;
        
        if(empty($db[$connection_id])){
            require_once(AK_CONTRIB_DIR.DS.'adodb'.DS.'adodb.inc.php');

            if(substr($dsn, 0, 6) == 'mysql:'){
                $dsn = substr_replace($dsn, 'mysqlt:', 0, 6);
            }

            if (!$db[$connection_id] = (AK_DEBUG ? NewADOConnection($dsn) : @NewADOConnection($dsn))){
                error_reporting(E_ALL);
                if(defined('AK_DATABASE_CONNECTION_FAILURE_CALLBACK') && function_exists(AK_DATABASE_CONNECTION_FAILURE_CALLBACK)){
                    $fn = AK_DATABASE_CONNECTION_FAILURE_CALLBACK;
                    $fn();
                }
                if(!AK_PHP5 && substr($dsn,0,6) == 'sqlite'){
                    echo "\nWarning, sqlite support is not available by default on PHP4.\n Check your PHP version by running \"env php -v\", and change the first line in your scripts/ so they point to a php5 binary\n\n";
                }
                die(Ak::t('Connection to the database failed.').' '.
                (AK_DEBUG?preg_replace('/\/\/(\w+):(.*)@/i','//$1:******@', urldecode($dsn))."\n":''));
            }
            $db[$connection_id]->debug = AK_DEBUG == 2;
            defined('AK_DATABASE_CONNECTION_AVAILABLE') ? null : define('AK_DATABASE_CONNECTION_AVAILABLE', true);
            $dsn = '';
        }
        return $db[$connection_id];
    }
 function bBlog()
 {
     // connect to database
     $this->_adb = NewADOConnection('mysql://' . DB_USERNAME . ':' . DB_PASSWORD . '@' . DB_HOST . '/' . DB_DATABASE . '?persist');
     //$this->_db = new db(DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_HOST);
     $this->num_rows =& $this->_db->num_rows;
     $this->insert_id =& $this->_db->insert_id;
     //Load the config
     $config =& new configHandler($this->_adb);
     $config->loadConfig();
     $this->assign('blogname', C_BLOGNAME);
     $this->assign('blogdescription', C_BLOG_DESCRIPTION);
     $this->assign('blogurl', BLOGURL);
     $this->assign('bblogurl', BBLOGURL);
     $this->assign('metakeywords', C_META_KEYWORDS);
     $this->assign('metadescription', C_META_DESCRIPTION);
     $this->assign('charset', C_CHARSET);
     $this->assign('direction', C_DIRECTION);
     $this->assign('C_CAPTCHA_ENABLE', C_CAPTCHA_ENABLE);
     // initial time from config table, based on last updated stuff.
     // this is just the initial value.
     //$this->lastmodified = C_LAST_MODIFIED;
     //$this->register_postfilter("update_when_compiled");
     // load up the sections
     $this->get_sections();
     //start the session that we need so much ;)
     if (!session_id()) {
         session_start();
     }
     $this->_ph =& new postHandler(&$this->_adb);
     Smarty::Smarty();
 }
Exemplo n.º 9
0
 /**
  * Establishes a DB connection
  * @access public
  * @return bool
  */
 public function open()
 {
     // check if connected already
     if ($this->db) {
         return true;
     }
     // need adodb and exceptions
     include_once EP_LIBS_ADODB . '/adodb-exceptions.inc.php';
     include_once EP_LIBS_ADODB . '/adodb.inc.php';
     // connect db now
     try {
         // $this->db = & ADONewConnection($this->dsn);
         $this->db =& NewADOConnection('pdo');
         // convert PEAR DSN into PDO DSN
         $dsn_pdo = $this->_convertDsn($this->dsn, $username, $password, $phptype);
         // set db type
         $this->_setDbType($phptype);
         // connect through PDO
         $this->db->Connect($dsn_pdo, $username, $password);
     } catch (Exception $e) {
         throw new epExceptionDbAdodb('Cannot connect db: ' . $e->getMessage());
         return false;
     }
     // set fetch mode to assoc
     $this->db->SetFetchMode(ADODB_FETCH_ASSOC);
     return true;
 }
Exemplo n.º 10
0
/**
 * This function creates the DB on new installs
 */
function make_db($dbhost, $dbuname, $dbpass, $dbname, $prefix_table, $dbtype, $dbmake)
{
    global $db;
    echo '<font class="oos-title">' . INPUT_DATA . '</font>';
    echo '<table align="center"><tr><td align="left">';
    if ($dbmake) {
        $db =& NewADOConnection($dbtype);
        $dbh = $db->Connect($dbhost, $dbuname, $dbpass);
        if (!$dbh) {
            $dbpass = "";
            die("{$dbtype}://{$dbuname}:{$dbpass}@{$dbhost} failed to connect" . $db->ErrorMsg());
        }
        $dict = NewDataDictionary($db);
        if (!$dict) {
            continue;
        }
        $dict->debug = 1;
        // ToDo CREATE DATABASE $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
        $sqlarray = $dict->CreateDatabase($dbname);
        $dict->ExecuteSQLArray($sqlarray);
    }
    oosDBInit($dbhost, $dbuname, $dbpass, $dbname, $dbtype);
    if (!$prefix_table == '') {
        $prefix_table = $prefix_table . '_';
    }
    include 'newtables.php';
    echo '</td></tr></table>';
}
Exemplo n.º 11
0
 function connect()
 {
     if ($this->openqrm->get('config', 'DATABASE_TYPE') === "db2") {
         $db =& ADONewConnection('odbc');
         $db->PConnect($this->openqrm->get('config', 'DATABASE_NAME'), $this->openqrm->get('config', 'DATABASE_USER'), $this->openqrm->get('config', 'DATABASE_PASSWORD'));
         $db->SetFetchMode(ADODB_FETCH_ASSOC);
         return $db;
     } else {
         if ($this->openqrm->get('config', 'DATABASE_TYPE') === "oracle") {
             $db = NewADOConnection("oci8po");
             $db->Connect($this->openqrm->get('config', 'DATABASE_NAME'), $this->openqrm->get('config', 'DATABASE_USER'), $this->openqrm->get('config', 'DATABASE_PASSWORD'));
         } else {
             if (strlen($this->openqrm->get('config', 'DATABASE_PASSWORD'))) {
                 $dsn = $this->openqrm->get('config', 'DATABASE_TYPE') . '://';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_USER') . ':';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_PASSWORD') . '@';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_SERVER') . '/';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_NAME') . '?persist';
             } else {
                 $dsn = $this->openqrm->get('config', 'DATABASE_TYPE') . '://';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_USER') . '@';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_SERVER') . '/';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_NAME') . '?persist';
             }
             $db =& ADONewConnection($dsn);
         }
     }
     $db->SetFetchMode(ADODB_FETCH_ASSOC);
     return $db;
 }
Exemplo n.º 12
0
 /** Connect this object to the database! */
 function DbConnect()
 {
     $ADODB_CACHE_DIR = '/tmp';
     /*	$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;	*/
     require_once 'adodb/adodb.inc.php';
     if ($this->ini_cfg['database']['dbtype'] == "postgres") {
         if (isset($this->ini_cfg["database"]['hostname']) && strlen($this->ini_cfg["database"]['hostname']) > 0) {
             $datasource = 'pgsql://' . $this->ini_cfg["database"]['user'] . ':' . $this->ini_cfg["database"]['password'] . '@' . $this->ini_cfg["database"]['hostname'] . '/' . $this->ini_cfg["database"]['dbname'];
         } else {
             $datasource = 'pgsql://dbname=' . $this->ini_cfg["database"]['dbname'] . ' user='******'user'];
             if (strlen($this->ini_cfg["database"]['password'])) {
                 $datasource .= ' password='******'password'];
             }
         }
     } else {
         $datasource = 'mysql://' . $this->ini_cfg['database']['user'] . ':' . $this->ini_cfg['database']['password'] . '@' . $this->ini_cfg['database']['hostname'] . '/' . $this->ini_cfg['database']['dbname'];
     }
     //echo "Datasource: $datasource \n";
     $this->dbhandle = NewADOConnection($datasource);
     if (!$this->dbhandle) {
         return false;
     }
     $this->dbhandle->setFetchMode(ADODB_FETCH_ASSOC);
     return true;
 }
Exemplo n.º 13
0
 function ConnectionHandler($ruta_raiz)
 {
     if (!defined('ADODB_ASSOC_CASE')) {
         define('ADODB_ASSOC_CASE', 1);
     }
     include "{$ruta_raiz}/adodb/adodb.inc.php";
     include_once "{$ruta_raiz}/adodb/adodb-paginacion.inc.php";
     include_once "{$ruta_raiz}/adodb/tohtml.inc.php";
     include "{$ruta_raiz}/config.php";
     $ADODB_COUNTRECS = false;
     $this->driver = $driver;
     //$dsn= $driver.'://'.$usuario.':'.$contrasena.'@'.$servidor.'/'.$servicio;
     $this->conn = NewADOConnection($driver);
     //	$this->conn->debug=true;
     $this->rutaRaiz = $ruta_raiz;
     if (!$this->conn or $this->conn->Connect($servidor, $usuario, $contrasena, $servicio) == false) {
         die("Error de conexi&oacute;n a la B.D. comun&iacute;quese con el Administrador");
     }
     $this->entidad = $entidad;
     $this->entidad_largo = $entidad_largo;
     $this->entidad_tel = $entidad_tel;
     $this->entidad_dir = $entidad_dir;
     if ($this->driver == 'mssql') {
         $this->conn->query("Set DateFirst 1");
     }
 }
Exemplo n.º 14
0
 /**
  * connect to database
  * @param $host
  * @param $user
  * @param $pass
  * @param $dbname
  */
 public static function connect($host, $user, $pass, $dbname)
 {
     global $DB;
     $DB = NewADOConnection('mysql');
     $conn = $DB->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     return $conn;
 }
Exemplo n.º 15
0
 /**
  * Opens connection to the database.
  * You must call this function after instanciating your class, before doing queries.
  * Otherways all queries will fail! You also must have authentificated a user, before
  * you can use this class!
  */
 function open($dbhost = "", $dbuser = "", $dbpasswd = "", $database = "")
 {
     global $c;
     // initialize configuratin variables.
     if ($dbhost == "") {
         $dbhost = $c["dbhost"];
     }
     if ($dbuser == "") {
         $dbuser = $c["dbuser"];
     }
     if ($dbpasswd == "") {
         $dbpasswd = $c["dbpasswd"];
     }
     if ($database == "") {
         $database = $c["database"];
     }
     if ($c["dbdriver"] == "mysql") {
         $this->ADODB = NewADOConnection($this->type);
         $this->ADODB->PConnect($dbhost, $dbuser, $dbpasswd, $database);
     } else {
         if ($c["dbdriver"] == "mssql") {
             $this->ADODB =& ADONewConnection("ado_mssql");
             $dsn = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=" . $dbhost . ";DATABASE=" . $database . ";UID=" . $dbuser . ";PWD=" . $dbpasswd . ";";
             $this->ADODB->Connect($dsn);
         }
     }
 }
Exemplo n.º 16
0
Arquivo: AGDO.php Projeto: hlag/svs
	private function __construct()
	{
		$this->DBConnector = new DBConnector;
		$this->mode = ADODB_FETCH_ASSOC;
		$this->conn = NewADOConnection($this->DBConnector->getDBMS());
		if (!($this->conn->Connect($this->DBConnector->getHost(),
									$this->DBConnector->getUser(),
									$this->DBConnector->getPasswd(),
									$this->DBConnector->getDBName())))
		{
			echo "Probleme mit der Datenbank";
			exit();
		}
		else
		{
			$SQLQuery ="SET NAMES 'UTF8'";					//MG 11.09.2007
			try
			{
				$this->conn->debug=false;
				$this->conn->Execute($SQLQuery);

			}
			catch (exception $e)
			{
    			//print_r($e);
			}
		}
	}
Exemplo n.º 17
0
 function initConnect()
 {
     $this->_db = NewADOConnection('mysqli');
     $this->_db->Connect($this->_dbAddr, $this->_dbUser, $this->_dbPwd, $this->_dbName);
     $this->_db->Query('set names utf8');
     $this->_db->SetFetchMode(ADODB_FETCH_ASSOC);
 }
Exemplo n.º 18
0
function db_connect_real($host,$user,$pass,$db_name,$db_type, $port = "3306", $retries = 20) {
	global $cnn_id;

	$i = 0;
	$cnn_id = NewADOConnection($db_type);

	// set oracle date format
	if (isset($cnn_id->NLS_DATE_FORMAT)) {
		$cnn_id->NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
	}

	$hostport = $host . ":" . $port;

	while ($i <= $retries) {
		if ($cnn_id->PConnect($hostport,$user,$pass,$db_name)) {
			return(1);
		}

		$i++;

		usleep(40000);
	}

	die("FATAL: Cannot connect to server on '$host'. Please make sure you have specified a valid database name in 'include/config.php'\n");

	return(0);
}
Exemplo n.º 19
0
 /**
  * Gets MongoDb Collection
  *
  * @return  ADOConnection Returns the instance of the ADOConnection
  */
 protected function getDb()
 {
     if ($this->db === null) {
         $this->db = NewADOConnection($this->options['dsn']);
         $this->db->SetFetchMode(ADODB_FETCH_ASSOC);
     }
     return $this->db;
 }
Exemplo n.º 20
0
 public function __construct($type, $host, $user, $pass, $db)
 {
     $vendorDir = __DIR__ . '/../../../../../../vendor';
     require_once $vendorDir . '/adodb/adodb-php/adodb.inc.php';
     require_once $vendorDir . '/adodb/adodb-php/adodb-exceptions.inc.php';
     $this->_db = NewADOConnection($type);
     $this->_db->Connect($host, $user, $pass, $db);
 }
Exemplo n.º 21
0
 /**
  * Synchronize a single course ID.
  * @global type $db
  * @param int $course_id
  */
 public function __construct($course_id = null, $cperiod_id = null)
 {
     global $db;
     $course = Models_Course::get($course_id);
     if ($course) {
         $audience = $course->getAudience($cperiod_id);
         if ($audience) {
             $ldap_sync_date = time();
             foreach ($audience as $a) {
                 $a->setLdapSyncDate($ldap_sync_date);
                 if (!$a->update()) {
                     application_log("error", "Unable to update ldap_sync_date for caudience_id " . $a->getID() . ".");
                 }
             }
         }
     }
     $this->ldap_connection = NewADOConnection("ldap");
     $this->ldap_connection->SetFetchMode(ADODB_FETCH_ASSOC);
     $query = "SELECT a.`course_code`, a.`course_id`, a.`organisation_id`, b.`cperiod_id`, b.`audience_value` AS `group_id`, c.`curriculum_type_id`, c.`start_date`, c.`finish_date`, a.`sync_ldap_courses`, a.`sync_groups`\n                    FROM `courses` AS a\n                    JOIN `course_audience` AS b\n                    ON a.`course_id` = b.`course_id`\n                    JOIN `curriculum_periods` AS c\n                    ON b.`cperiod_id` = c.`cperiod_id`\n                    WHERE a.`course_id` = ?\n                    AND a.`sync_ldap` = '1'\n                    AND a.`course_active` = '1'\n                    AND b.`audience_active` = '1'\n                    AND c.`active` = '1'\n                    AND UNIX_TIMESTAMP(NOW()) > c.`start_date` - 1209600 \n                    AND UNIX_TIMESTAMP(NOW()) < c.`finish_date`";
     $results = $db->GetAll($query, array($course_id));
     if ($results) {
         foreach ($results as $result) {
             $this->ldap_audience = array();
             $this->course = $result;
             $this->course_year = date("Y", $this->course["start_date"]);
             $this->setQueryParams($this->course["start_date"], $this->course["organisation_id"]);
             $this->fetchCourseCodes();
             if (!$this->fetchGroupID()) {
                 $this->createCourseGroup();
             }
             $this->fetchCourseAudienceMembers();
             if ($this->fetchCommunityID()) {
                 $this->fetchCommunityAudience();
             }
             if (!empty($this->course_codes)) {
                 if ($this->fetchLdapAudience()) {
                     foreach ($this->ldap_audience as $course_audience_member) {
                         $member_ldap_data = $this->fetchLdapAudienceMemberDetails($course_audience_member);
                         $this->handleUser($member_ldap_data);
                     }
                     if (!empty($this->community_audience)) {
                         // The audience members remaining were not in the ldap sync, they need to be deactiviated.
                         foreach ($this->community_audience as $audience_member => $cmember) {
                             $this->removeCommunityAudienceMember($audience_member);
                         }
                     }
                 }
             } else {
                 application_log("error", "There were no course codes attached to this course. That should be impossible.");
             }
             if ($this->course["sync_groups"] == "1") {
                 $this->syncCourseGroups();
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 22
0
 public function __construct()
 {
     try {
         $this->db = NewADOConnection('mysqli');
         $this->db->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     } catch (exception $e) {
         echo 'Connection failed: ' . $e->getMessage();
     }
 }
Exemplo n.º 23
0
 static function getInstance()
 {
     global $sqltype, $host, $username, $password, $database;
     $DB = NewADOConnection($sqltype);
     $DB->Connect($host, $username, $password, $database);
     $DbInstance = new self();
     $DbInstance->db = $DB;
     return $DbInstance;
 }
Exemplo n.º 24
0
 public static function conn()
 {
     static $conn;
     if (!$conn) {
         $conn = NewADOConnection(DSN);
         $conn->SetFetchMode(ADODB_FETCH_ASSOC);
     }
     return $conn;
 }
Exemplo n.º 25
0
function getDB()
{
    $dbhandle = NewADOConnection("pgsql://dbname=nmtest host=localhost");
    if (!$dbhandle) {
        throw new Exception("Cannot connect to db!");
    }
    $dbhandle->setFetchMode(ADODB_FETCH_ASSOC);
    return $dbhandle;
}
Exemplo n.º 26
0
function insertAuditLog($strId, $errorcounter, $runcounter, $ip, $action)
{
    $db = NewADOConnection(getDbType());
    $db->Connect("localhost", "xxxxx", "xxxxx", "xxxxxx");
    $sql = "INSERT INTO open_audit_log_t  (oac_errorn, oac_runn, oac_user, oac_ip, oac_action)VALUES({$errorcounter}, {$runcounter}, '{$strId}', '{$ip}', {$action})";
    $db->Execute($sql);
    $db->Close();
    return 0;
}
 /**
  * Constructor
  */
 function UploadManager()
 {
     global $CONF;
     $this->db = NewADOConnection($GLOBALS['DSN']);
     if (!$this->db) {
         die('Database connection failed: ' . mysql_error());
     }
     $this->tmppath = isset($CONF['photo_upload_dir']) ? $CONF['photo_upload_dir'] : '/tmp';
 }
Exemplo n.º 28
0
function getJournal($str)
{
    global $config;
    global $ADODB_FETCH_MODE;
    $db = NewADOConnection('mysql');
    $db->Connect("localhost", $config['db_user'], $config['db_passwd'], $config['db_name']);
    // Ensure fields are (only) indexed by column name
    $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    $str = str_replace(' of ', ' ', $str);
    $str = str_replace(' for ', ' ', $str);
    $str = preg_replace('/^The /', '', $str);
    $str = str_replace('(', '', $str);
    $str = str_replace(')', '', $str);
    $str = str_replace(',', '', $str);
    $str = str_replace(':', '', $str);
    $str = str_replace('\'', '', $str);
    $str = str_replace('.', '%', $str);
    // Yuck!
    $str = str_replace('é', 'e', $str);
    $str = preg_replace('/\\s\\s*/', ' ', $str);
    $str = str_replace(' ', '%', $str);
    $str .= '%';
    $sql = 'SELECT * FROM issn
		WHERE title LIKE ' . $db->Quote($str) . '
		ORDER BY title
		LIMIT 10';
    //echo $sql;
    $result = $db->Execute($sql);
    if ($result == false) {
        die("failed");
    }
    $json = "{\"results\":\n[";
    $count = 0;
    while (!$result->EOF) {
        if ($count > 0) {
            $json .= ",";
        }
        $json .= "\n";
        $json .= "{";
        // fix quotes
        $title = $result->fields['title'];
        $title = str_replace("'", "\\\\'", $title);
        $title = str_replace('"', '\\"', $title);
        // Note UTF-8 encoding
        //		$json .= '"title":"' . utf8_encode($title) . '",';
        // Use as-is because table is in UTF-8
        $json .= '"title":"' . $title . '",';
        $json .= '"issn":"' . $result->fields['issn'] . '",';
        $json .= '"language_code":"' . $result->fields['language_code'] . '"';
        $json .= "}";
        $count++;
        $result->MoveNext();
    }
    $json .= "\n]\n}\n";
    return $json;
}
Exemplo n.º 29
0
 /**
  * Constructor
  */
 public function __construct()
 {
     global $config;
     $this->sid = session_id();
     if (empty($this->sid)) {
         session_start();
     }
     $this->db = NewADOConnection($config['dbtype']);
     $this->db->Connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']);
 }
Exemplo n.º 30
0
 private function open_connection()
 {
     $SERVIDOR = filter_input_array(INPUT_SERVER);
     $PATH = $SERVIDOR['DOCUMENT_ROOT'] . "/kamarena/quiniclubs_server";
     include "{$PATH}/core/adodb5/adodb.inc.php";
     $bd = NewADOConnection("mysql");
     $bd->Connect(self::$db_host, self::$db_user, self::$db_pass, self::$db_name);
     mysql_query("SET NAMES 'utf8'");
     self::$conn = $bd;
 }