function importMessages($log, $category) { $data = selectMessages($category); foreach ($data as $record) { Record::add($log->name, $record['message'], $record['message']); } }
protected static function postLogRecord($category, $message, $fullMessage) { try { Record::add($category, $message, $fullMessage); } catch (\Exception $e) { } }
public function getCurrentSession() { $helper = new FacebookJavaScriptLoginHelper(); try { if (!empty($_SESSION[self::SessionKey])) { $accessToken = $_SESSION[self::SessionKey]; $_SESSION[self::SessionKey] = null; $session = new \Facebook\FacebookSession($accessToken); } else { $session = $helper->getSession(); $accessToken = $session->getAccessToken(); $_SESSION[self::SessionKey] = (string) $accessToken; } } catch (\Exception $ex) { Record::add(__CLASS__, $ex->getMessage(), $ex); throw $ex; } if ($session) { try { $user_profile = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className()); return ['id' => $user_profile->getId(), 'name' => $user_profile->getName()]; } catch (FacebookRequestException $e) { $error = "Exception occured, code: " . $e->getCode() . " with message: " . $e->getMessage(); Record::add(__CLASS__, $error, $e); throw $e; } } }
protected function action() { // event should exists Log::getByName($this->GetParam('event')); Record::add($this->GetParam('event'), $this->GetParam('short'), $this->GetParam('full')); return true; }
public function resolveJobs() { if ($this->noNeedToRun()) { return; } $timeLimit = $this->getTimeLimit(); $startTime = time(); do { try { $job = $this->getLastJob(); if (is_object($job)) { $job->run(); } } catch (\Exception $e) { Record::add(self::LogName, $e); if (!empty($job)) { $job->status = Job::ErrorStatus; $job->update(); } } $timeToStop = !empty($timeLimit) ? time() >= $startTime + $timeLimit : true; if (!$timeToStop) { sleep(1); } } while (!$timeToStop); $this->deleteOldRows(); }
protected function action() { try { Cleaner::pack(); } catch (\Exception $e) { \Extasy\Audit\Record::add(__CLASS__, $e->getMessage(), $e); } $job = new CleanerJob(); $job->actionDate->setTime('+1 hour'); $job->insert(); }
protected function checkACL() { if (!empty($this->requiredACLRights)) { try { ACLUser::checkCurrentUserGrants($this->requiredACLRights); } catch (Exception $e) { $errorMsg = sprintf('Failed to execute operation:%s. Current user - ', self::MethodName, UsersLogin::isLogined() ? sprintf('%s:%d', UsersLogin::getCurrentSession()->login->getValue(), UsersLogin::getCurrentSession()->id->getValue()) : ''); Record::add('api', $errorMsg); throw $e; } } }
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); }
protected function validateParameter($name, $value) { if (is_array($value)) { foreach ($value as $key => $row) { $this->validateParameter(sprintf('%s[%s]', $name, $key), $row); } } else { foreach ($this->patterns as $regExp) { if (preg_match($regExp, $value)) { $short = sprintf('`%s` matches injection pattern "%s" ', htmlspecialchars($name), htmlspecialchars($regExp)); $full = sprintf('<b>%s</b><br>Page URL: %s<br>Matching Pattern: %s<br>Request:<br>%s<br>', htmlspecialchars($name), htmlspecialchars(print_r($this->uri(), true)), htmlspecialchars(print_r($regExp, true)), htmlspecialchars(print_r($this->data, true))); \Extasy\Audit\Record::add(self::LogName, $short, $full); } } } }
public static function checkCurrentUserGrants($aclActionList) { if (empty($aclActionList)) { return; } if (!is_array($aclActionList)) { throw new ACLException('Property `aclActionList` should be array type '); } $grantList = self::getCurrentUserGrants(); $result = self::testGrants($aclActionList, $grantList); if (!$result) { $msg = "User not have enough rights to access requested action - " . self::$rightFailed; $fullMsg = sprintf("%s\r\nRequested grants:%s\r\nCurrent user:\r\n%s\r\n%s", $msg, print_r($aclActionList, true), print_r(UsersLogin::getCurrentSession(), true), \Faid\Debug\defaultDebugBackTrace(false)); \Extasy\Audit\Record::add(__CLASS__, $msg, $fullMsg); throw new ForbiddenException($msg); } }
public function login($login, $password, $captchaCode = '', $remember = false) { // fix for cases with captcha if (!empty($_REQUEST['remember'])) { $remember = $_REQUEST['remember'] == 'true'; } // проверяем код капчи /** * @todo Избавиться от этой зависимости */ require_once APPLICATION_PATH . 'kcaptcha/helper.php'; if (!kcaptchaHelper::check($captchaCode)) { $this->errorCode = self::kcaptchaFailed; return $this->main(); } try { UsersLogin::login($login, $password, $remember); EventController::callEvent('users_registration_after_login', UsersLogin::getCurrentSession()); $this->aParse['loginSuccess'] = true; } catch (\Extasy\Users\login\UserNotConfirmedException $e) { $this->jump('/signup/?code='); } catch (Exception $e) { \Extasy\Audit\Record::add(UsersLogin::LogName, $e->getMessage(), $e); $this->exception = $e; // Поддержка ajax-а if (empty($_REQUEST['ajaxRequest'])) { $this->main(); } } // Если передавался параметр страниц if (!empty($this->pageId)) { $sitemap = Sitemap_Sample::get($this->pageId); if (!empty($sitemap)) { $this->jump($sitemap['full_url']); } } elseif (!empty($_POST['backUrl'])) { $backUrl = preg_replace("#\n.*#", "", $_POST['backUrl']); $this->jump($backUrl); } // Поддержка аякса if (!empty($_REQUEST['ajaxRequest'])) { $this->output('/users/login/form'); } $this->jump('/'); }
protected function action() { try { UsersLogin::testLoginAttempts(); } catch (\Exception $e) { Record::add(__CLASS__, $e->getMessage(), $e); throw $e; } // $this->api = \Extasy\Users\Social\OdnoklassnikiApiFactory::getInstance(); $userOdnoklassnikiProfile = $this->api->getCurrentSession(); $uid = $userOdnoklassnikiProfile['id']; $user = \Extasy\Users\Columns\SocialNetworks::getByUID($uid, 'odnoklassniki'); UsersLogin::testConfirmationCode($user); UsersLogin::forceLogin($user); $log = sprintf('Odnoklassniki login successfully finished. User ("%s", "%d") logged with uid ("%s" )', $user->login->getValue(), $user->id->getValue(), $userOdnoklassnikiProfile['id']); Record::add(__CLASS__, $log); }
public static function addMessage($category, $szMessage) { Record::add($category, $szMessage, $szMessage); }
public function testEmailSentOnCriticalLogMessage() { Record::add('Log2', '', ''); $this->assertTrue($this->mailer->isSent()); }
/** * */ public static function logout() { if (self::isLogined()) { EventController::callEvent('users_after_logout'); try { $user = self::getCurrentUser(); CMSLog::addMessage(__CLASS__, sprintf('User `%s` logged out', $user->login->getValue())); } catch (\Exception $e) { $short = 'Failed to logout user. Probably, there is an issue inside User Sesison'; $full = sprintf("%s\r\n%s", $short, $e); Record::add(__CLASS__, $short, $full); } } self::unsetSession(); self::$currentUser = null; }