Пример #1
0
 public static function getRowsCount($table, $condition = array())
 {
     Trace::addMessage(__CLASS__, sprintf('getRowsCount. Table:"%s", $condition:%s', $table, print_r($condition, true)));
     $result = parent::getRowsCount($table, $condition);
     Trace::addMessage(__CLASS__, 'Rows counting finished');
     return $result;
 }
Пример #2
0
 public static function pack()
 {
     $count = DBSimple::getRowsCount(Record::tableName);
     if (self::IsLogTooBig($count)) {
         self::storeExtraRecords();
     }
 }
Пример #3
0
 public function testReSave()
 {
     $this->factoryColumn(self::Login);
     $this->column->setValue(['facebook' => self::UID]);
     $this->column->onUpdate(new \Extasy\ORM\QueryBuilder('select'));
     //
     $this->assertEquals(1, DBSimple::getRowsCount(SocialNetworks::UIDTable));
 }
Пример #4
0
 public function testGrant()
 {
     ACL::create('test/test2');
     ACL::grant('test/test2', 'e1');
     $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE));
     $found = DBSimple::get(ACL_GRANT_TABLE, array('actionId' => 2));
     $this->assertEquals('e1', $found['entity']);
 }
Пример #5
0
 public function testAuditRecordCreated()
 {
     $fixture = DBSimple::getRowsCount(Record::tableName);
     //
     $api = new RestartServer();
     $api->exec();
     //
     $this->assertEquals($fixture + 1, DBSimple::getRowsCount(Record::tableName));
 }
Пример #6
0
 public function testNewTasksNotRestarted()
 {
     $job = new TestAction();
     $job->insert();
     //
     $api = new Restart(['id' => $job->id->getValue(), 'actionDate' => '']);
     $api->exec();
     //
     $this->assertEquals(1, DBSimple::getRowsCount(TestAction::TableName));
 }
Пример #7
0
 public function testDeleteAndCheckEntityDeletion()
 {
     ACL::create('test/test2/test3');
     ACL::grant('test/test2/test3', 'o1');
     ACL::grant('test', 'o2');
     ACL::remove('test/test2');
     $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE));
     // Проверяем, что удалились именно нужные данные
     $this->assertEquals(true, ACL::isGranted('test', 'o2'));
 }
Пример #8
0
 public function testGarbageCollection()
 {
     $job = new TestAction();
     $job->status = Job::FinishedStatus;
     $job->actionDate = date('Y-m-d H:i:s', strtotime('-1 day'));
     $job->insert();
     $this->assertEquals(1, DBSimple::getRowsCount(Job::TableName));
     $runner = new Runner();
     $runner->resolveJobs();
     $this->assertEquals(0, DBSimple::getRowsCount(Job::TableName));
 }
Пример #9
0
 /**
  * 
  */
 public function testRemoveEntity()
 {
     ACL::create('test');
     ACL::create('test2');
     ACL::create('test3');
     ACL::grant('test', 'obj1');
     ACL::grant('test2', 'obj2');
     ACL::grant('test3', 'obj1');
     ACL::removeEntity('obj1');
     $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE));
     $this->assertEquals(true, ACL::isGranted('test2', 'obj2'));
 }
Пример #10
0
 protected function loadLastFail()
 {
     $lastId = !empty($this->successId) ? $this->successId : 0;
     $condition = array('user_id' => $this->user->id->getValue(), 'status' => LoginAttempt::FailStatus, sprintf('`id` > "%d"', DB::escape($lastId)), sprintf('`date` < NOW() '));
     $this->failCount = DBSimple::getRowsCount(LoginAttempt::TableName, $condition);
     $last = DBSimple::get(LoginAttempt::TableName, $condition, 'order by `id` desc');
     if (!empty($last)) {
         $model = new LoginAttempt($last);
         $this->failLastIp = $model->host->getValue();
         $this->failLastDate = $model->date->getValue();
     }
 }
Пример #11
0
 public function testRecordNotAddedInEnableLoggingDisabled()
 {
     $initial = DBSimple::getRowsCount(Record::tableName);
     //
     $log = Log::getByName('Log1');
     $log->setupLogging(false);
     //
     $result = Record::add('Log1', '1', '2');
     $this->assertTrue(empty($result));
     //
     $result = DBSimple::getRowsCount(Record::tableName);
     $this->AssertEquals($initial, $result);
 }
Пример #12
0
 protected function getRowsCount()
 {
     return DBSimple::getRowsCount(SYSTEMREGISTER_TABLE);
 }
Пример #13
0
 protected function getRowsCount()
 {
     return DBSimple::getRowsCount(ACL_TABLE);
 }
Пример #14
0
 protected function isUniq($login)
 {
     $count = DBSimple::getRowsCount(USERS_TABLE, array('login' => $login, sprintf('id <> %d', $this->document->id->getValue())));
     return $count == 0;
 }
Пример #15
0
 protected function getItemTitle($row)
 {
     $pageTitle = sprintf('<a class="itemTitle" href="./%s?parent=%d">%s</a>', $this->getPageUrl(), $row['id'], $row['name']);
     if (empty($row['visible'])) {
         $pageTitle .= ' <span class="important">[Скрыта]</span>';
     }
     $count = \Faid\DBSimple::getRowsCount(SITEMAP_TABLE, ['parent' => $row['id']]);
     if (!empty($count)) {
         $pageTitle .= sprintf('<span>, имеет %d %s %s</span>', $count, IntegerHelper::formatWord($count, 'дочерни', array('й', 'х', 'х')), IntegerHelper::formatWord($count, 'документ', array('', 'а', 'ов')));
     }
     if (!empty($row['document_name'])) {
         $pageTitle = $this->userFilterDescription($row, $pageTitle);
     }
     return $pageTitle;
 }
Пример #16
0
 public static function getNewCount()
 {
     return DBSimple::getRowsCount(Record::tableName, array('viewed' => 0));
 }
Пример #17
0
 protected function getViewedCount()
 {
     return DBSimple::getRowsCount(Record::tableName, array('viewed' => '1'));
 }
Пример #18
0
 /**
  *
  */
 public static function testLoginAttempts()
 {
     self::reloadAttemptsConfig();
     //
     $host = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     // Check that per-host limit not exceeded
     $perHostAttempts = 1 + DBSimple::getRowsCount(self::LoginAttemptsTable, array('host' => ip2long($host), 'date > NOW() - INTERVAL 1 hour'));
     // Check that per-session limit not exceeded
     if (empty($_SESSION[self::LogSessionKey])) {
         $_SESSION[self::LogSessionKey] = 1;
     } else {
         $_SESSION[self::LogSessionKey]++;
     }
     $perSessionAttempts = $_SESSION[self::LogSessionKey];
     if ($perHostAttempts > self::$perHost) {
         $error = sprintf('Per host login/forgot password attempts exceeded. Current host count: %d, limit: %d ', $perHostAttempts, self::$perHost);
         throw new LoginAttemptsException($error);
     }
     //
     if ($perSessionAttempts > self::$perSession) {
         throw new LoginAttemptsException(sprintf('Per session login/forgot password attempts exceeded %d:%d', $perSessionAttempts, self::$perSession));
     }
 }