public static function validateRequest() { $headers = self::getHeaders(); if (isset($headers['Authorization'])) { $dataAuthorisation = explode(' ', $headers['Authorization']); $apiData = explode(':', base64_decode($dataAuthorisation[1])); if (count($apiData) != 2) { throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization failed!')); } $apiKey = erLhAbstractModelRestAPIKey::findOne(array('enable_sql_cache' => true, 'filter' => array('active' => 1, 'api_key' => $apiData[1]))); if (!$apiKey instanceof erLhAbstractModelRestAPIKey) { throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization failed!')); } if ($apiKey->user->username != $apiData[0]) { throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization failed!')); } // API Key self::$apiKey = $apiKey; if (isset($_GET['update_activity'])) { $db = ezcDbInstance::get(); $stmt = $db->prepare('UPDATE lh_userdep SET last_activity = :last_activity WHERE user_id = :user_id'); $stmt->bindValue(':last_activity', time(), PDO::PARAM_INT); $stmt->bindValue(':user_id', self::$apiKey->user->id, PDO::PARAM_INT); $stmt->execute(); } } else { throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization header is missing!')); } }
public static function createDB($client_id) { $cfg = erConfigClassLhConfig::getInstance(); self::deleteDB($client_id); $db = ezcDbInstance::get(); $db->query('CREATE DATABASE ' . $cfg->getSetting('db', 'database_user_prefix') . $client_id . ';'); }
function hasGeometry($sql, $id) { $db = ezcDbInstance::get(); $stmt = $db->prepare($sql); $stmt->execute(array($id)); return $stmt->fetchColumn(); }
public function removeThis() { $q = ezcDbInstance::get()->createDeleteQuery(); // Messages $q->deleteFrom('lh_msg')->where($q->expr->eq('chat_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); // Transfered chats $q->deleteFrom('lh_transfer')->where($q->expr->eq('chat_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); // Delete user footprint $q->deleteFrom('lh_chat_online_user_footprint')->where($q->expr->eq('chat_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); // Delete screen sharing $q->deleteFrom('lh_cobrowse')->where($q->expr->eq('chat_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); // Delete speech settings $q->deleteFrom('lh_speech_chat_language')->where($q->expr->eq('chat_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); erLhcoreClassModelChatFile::deleteByChatId($this->id); erLhcoreClassChat::getSession()->delete($this); erLhcoreClassChat::updateActiveChats($this->user_id); }
public static function getSession() { if (!isset(self::$persistentSession)) { self::$persistentSession = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('./pos/lhfaq')); } return self::$persistentSession; }
public static function cleanup() { $db = ezcDbInstance::get(); $stmt = $db->prepare('DELETE FROM lh_chat_accept WHERE ctime < :ctime'); $stmt->bindValue(':ctime', (int) (time() - 24 * 3600), PDO::PARAM_INT); $stmt->execute(); }
protected function setUp() { try { $this->db = ezcDbInstance::get(); } catch (Exception $e) { $this->markTestSkipped(); } $this->q = $this->db->createSelectQuery(); $this->e = $this->q->expr; $this->assertNotNull($this->db, 'Database instance is not initialized.'); try { $this->db->exec('DROP TABLE query_test'); $this->db->exec('DROP TABLE query_test2'); } catch (Exception $e) { } // eat // insert some data $this->db->exec('CREATE TABLE query_test ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL )'); $this->db->exec("INSERT INTO query_test VALUES ( 1, 'eZ systems', 'Norway', 20 )"); $this->db->exec("INSERT INTO query_test VALUES ( 2, 'IBM', 'Norway', 500 )"); $this->db->exec("INSERT INTO query_test VALUES ( 3, 'eZ systems', 'Ukraine', 10 )"); $this->db->exec("INSERT INTO query_test VALUES ( 4, 'IBM', 'Germany', null )"); // insert some data $this->db->exec('CREATE TABLE query_test2 ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL )'); $this->db->exec("INSERT INTO query_test2 VALUES ( 1, 'eZ systems', 'Norway', 20 )"); $this->db->exec("INSERT INTO query_test2 VALUES ( 2, 'IBM', 'Norway', 500 )"); $this->db->exec("INSERT INTO query_test2 VALUES ( 3, 'eZ systems', 'Ukraine', 10 )"); $this->db->exec("INSERT INTO query_test2 VALUES ( 4, 'IBM', 'Germany', null )"); }
protected function setUp() { try { $this->db = ezcDbInstance::get(); } catch (Exception $e) { $this->markTestSkipped("No Database connection available"); } if ($this->db->getName() !== 'oracle') { $this->markTestSkipped("Skipping tests for Oracle"); } if (!$this->db instanceof ezcDbHandlerOracle) { $this->markTestSkipped(); } $this->testFilesDir = dirname(__FILE__) . '/testfiles/'; $this->tempDir = $this->createTempDir('ezcDatabaseOracleTest'); $tables = $this->db->query("SELECT table_name FROM user_tables")->fetchAll(); array_walk($tables, create_function('&$item,$key', '$item = $item[0];')); foreach ($tables as $tableName) { $this->db->query("DROP TABLE \"{$tableName}\""); } $sequences = $this->db->query("SELECT sequence_name FROM user_sequences")->fetchAll(); array_walk($sequences, create_function('&$item,$key', '$item = $item[0];')); foreach ($sequences as $sequenceName) { $this->db->query("DROP SEQUENCE \"{$sequenceName}\""); } }
public function doLogin() { // obtain credentials from POST $user = isset($_POST['user']) ? $_POST['user'] : null; $password = isset($_POST['password']) ? $_POST['password'] : null; $redirUrl = isset($_POST['redirUrl']) ? $_POST['redirUrl'] : '/'; $database = new ezcAuthenticationDatabaseInfo(ezcDbInstance::get(), 'user', array('id', 'password')); $databaseFilter = new ezcAuthenticationDatabaseFilter($database); $options = new ezcAuthenticationSessionOptions(); $options->validity = 86400; $session = new ezcAuthenticationSession($options); $session->start(); // use the options object when creating a new Session object $credentials = new ezcAuthenticationPasswordCredentials($user, md5($password)); $authentication = new ezcAuthentication($credentials); $authentication->session = $session; $authentication->addFilter($databaseFilter); if (!$authentication->run()) { $request = clone $this->request; $status = $authentication->getStatus(); $request->variables['redirUrl'] = $redirUrl; $request->variables['reasons'] = $status; $request->uri = '/login-required'; return new ezcMvcInternalRedirect($request); } $res = new ezcMvcResult(); $res->status = new ezcMvcExternalRedirect($redirUrl); return $res; }
protected function setUp() { try { $this->db = ezcDbInstance::get(); } catch (Exception $e) { $this->markTestSkipped(); } $this->q = $this->db->createSelectQuery(); $this->e = $this->db->createExpression(); $this->assertNotNull($this->db, 'Database instance is not initialized.'); try { $this->db->exec('DROP TABLE query_test'); } catch (Exception $e) { } // eat // insert some data if ($this->db->getName() === 'mssql') { $this->db->exec('CREATE TABLE query_test ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL, somedate DATETIME NULL )'); } else { $this->db->exec('CREATE TABLE query_test ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL, somedate TIMESTAMP )'); } if ($this->db->getName() === 'oracle') { $this->db->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"); // set the timestamp format } $this->db->exec("INSERT INTO query_test VALUES ( 1, 'eZ systems', 'Norway', 20, '2007-05-03 11:54:17' )"); $this->db->exec("INSERT INTO query_test VALUES ( 2, 'IBM', 'Norway', 500, null )"); $this->db->exec("INSERT INTO query_test VALUES ( 3, 'eZ systems', 'Ukraine', 10, null )"); $this->db->exec("INSERT INTO query_test VALUES ( 4, 'IBM', 'Germany', null, null )"); }
public function doDebug() { $res = new ezcMvcResult(); $q = ezcDbInstance::get()->query("SELECT * FROM user"); //var_dump( $q ); //$s = $q->prepare(); $q->execute(); $r = $q->fetchAll(); $res->variables['debugMessage'] = $r; $res->variables['type'] = $this->type; return $res; $q = ezcDbInstance::get()->createSelectQuery(); $q->select('*')->from('message')->innerJoin('user', 'message.user_id', 'user.id')->where($q->expr->eq('message.id', $this->id))->orderBy('date', ezcQuerySelect::DESC)->limit(25); $s = $q->prepare(); $s->execute(); $r = $s->fetchAll(); if ($_SESSION['ezcAuth_id'] == $r[0]['user_id']) { $q = ezcDbInstance::get()->createDeleteQuery(); $q->deleteFrom('message')->where($q->expr->eq('id', $q->bindValue($this->id))); $s = $q->prepare(); $s->execute(); $q = ezcDbInstance::get()->createDeleteQuery(); $q->deleteFrom('message_tag')->where($q->expr->eq('message_id', $q->bindValue($this->id))); $s = $q->prepare(); $s->execute(); die("OK"); } die("FAIL"); }
protected function setUp() { try { $this->db = ezcDbInstance::get(); } catch (Exception $e) { $this->markTestSkipped(); } }
public static function deleteHash($id) { $db = ezcDbInstance::get(); $stmt = $db->prepare('DELETE FROM lh_forgotpasswordhash WHERE id =:id LIMIT 1'); $stmt->bindValue(':id', $id); $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->execute(); }
public function setUp() { try { $this->db = ezcDbInstance::get(); } catch (Exception $e) { $this->markTestSkipped('There was no database configured'); } }
public static function cleanup() { $db = ezcDbInstance::get(); $db->exec("DROP TABLE " . $db->quoteIdentifier("PO_test") . ";"); if ($db->getName() == 'pgsql') { $db->exec("DROP SEQUENCE " . $db->quoteIdentifier("PO_test_seq") . ";"); } }
public static function getInstance() { if (self::$instanceChat !== null) { return self::$instanceChat; } ezcDbInstance::get(); return self::$instanceChat; }
public static function cleanup() { $db = ezcDbInstance::get(); $db->exec('DROP TABLE PO_test'); if ($db->getName() == 'pgsql') { $db->exec('DROP SEQUENCE po_test_seq'); } }
public static function assignChatToPageviews(erLhcoreClassModelChatOnlineUser $onlineUser) { $db = ezcDbInstance::get(); $stmt = $db->prepare('UPDATE lh_chat_online_user_footprint SET chat_id = :chat_id WHERE online_user_id = :online_user_id'); $stmt->bindValue(':chat_id', (int) $onlineUser->chat_id, PDO::PARAM_INT); $stmt->bindValue(':online_user_id', (int) $onlineUser->id, PDO::PARAM_INT); $stmt->execute(); }
public function testDelayedInit2() { try { $instance2 = ezcDbInstance::get('delayed2'); } catch (ezcDbHandlerNotFoundException $e) { $this->assertEquals("Could not find the database handler: 'delayed2'.", $e->getMessage()); } }
public static function cleanup() { $db = ezcDbInstance::get(); if ($db->getName() == "oracle") { $db->exec("DROP SEQUENCE " . $db->quoteIdentifier("PO_database_type_test_id_seq")); } $db->exec("DROP TABLE " . $db->quoteIdentifier("PO_database_type_test")); }
public static function getRoleFunctions($role_id) { $db = ezcDbInstance::get(); $stmt = $db->prepare('SELECT * FROM lh_rolefunction WHERE role_id = :role_id ORDER BY id ASC'); $stmt->bindValue(':role_id', $role_id); $stmt->execute(); $rows = $stmt->fetchAll(); return $rows; }
public static function cleanup() { $db = ezcDbInstance::get(); if ($db->getName() == "oracle") { $db->exec("DROP SEQUENCE " . $db->quoteIdentifier("PO_person_id_seq")); } $db->exec("DROP TABLE " . $db->quoteIdentifier("PO_person")); $db->exec("DROP TABLE " . $db->quoteIdentifier("PO_sibling")); }
public static function configureObject( $instance ) { return new ezcPersistentSession( ezcDbInstance::get(), new ezcPersistentMultiManager( array( new ezcPersistentCodeManager( 'kernel/private/rest/classes/po_maps/' ), new ezcPersistentCodeManager( 'kernel/private/oauth/classes/persistentobjects/' ) )) ); }
public function removeThis() { $q = ezcDbInstance::get()->createDeleteQuery(); // Messages $q->deleteFrom('lh_abstract_survey_item')->where($q->expr->eq('survey_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); erLhcoreClassAbstract::getSession()->delete($this); }
public function afterRemove() { $db = ezcDbInstance::get(); $stmt = $db->prepare('DELETE FROM lh_userdep WHERE dep_group_id = :dep_group_id AND user_id = :user_id'); $stmt->bindValue(':dep_group_id', $this->dep_group_id); $stmt->bindValue(':user_id', $this->user_id); $stmt->execute(); erLhcoreClassModelDepartamentGroupMember::updateUserDepartmentsIds($this->user_id); }
public function removeThis() { erLhcoreClassDepartament::getSession()->delete($this); // Delete user assigned departaments $q = ezcDbInstance::get()->createDeleteQuery(); $q->deleteFrom('lh_departament')->where($q->expr->eq('id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); }
public function removeThis() { // Delete question answers $q = ezcDbInstance::get()->createDeleteQuery(); $q->deleteFrom('lh_question_answer')->where($q->expr->eq('question_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); erLhcoreClassQuestionary::getSession()->delete($this); }
public function removeThis() { $q = ezcDbInstance::get()->createDeleteQuery(); // Messages $q->deleteFrom(erLhcoreClassModelChatArchiveRange::$archiveMsgTable)->where($q->expr->eq('chat_id', $this->id)); $stmt = $q->prepare(); $stmt->execute(); erLhcoreClassChat::getSession()->delete($this); }
/** * Return the sql to generate the list */ public function getListSQL() { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $q = $db->createSelectQuery(); $where = "emo_code='STREET_LIGHTING' AND em_object_id=" . (int) $this->sl_id; $q->select("em_object_id, co_id, co_start_date, co_end_date, co_value, co_value_tep, co_value_kwh, co_value_co2, co_bill, co_bill_specific")->from('consumption_data')->where($where); return $q; }
public static function getRoleNotAssignedGroups($role_id) { $db = ezcDbInstance::get(); $stmt = $db->prepare('SELECT lh_group.* FROM lh_group WHERE lh_group.id NOT IN ( SELECT group_id FROM lh_grouprole WHERE role_id = :role_id) ORDER BY id ASC'); $stmt->bindValue(':role_id', $role_id); $stmt->execute(); $rows = $stmt->fetchAll(); return $rows; }