/** * Create new User's Informer object. * * Throws Exception with code 300 if user was not found. * * @param string $user * @param int $width * @param int $height * @param Habrometr_Model $habrometr */ public function __construct($user, $width, $height, Habrometr_Model $habrometr = null) { $this->_width = $width; $this->_height = $height; $this->_user = $user; if (!is_null($habrometr)) { $this->_habrometr = $habrometr; } else { $this->_habrometr = Habrometr_Model::getInstance(); } if (!($this->_userId = $this->_habrometr->code2UserId($this->_user))) { $this->_showError("User `{$user}` not found"); } }
public function getAction() { $view = Lpf_Dispatcher::getView(); $view->sizes = array(array('x' => 425, 'y' => 120), array('x' => 88, 'y' => 120), array('x' => 88, 'y' => 15), array('x' => 88, 'y' => 31), array('x' => 31, 'y' => 31), array('x' => 350, 'y' => 20)); $user = Habrometr_Model::getInstance()->getUser($this->_userId); $view->userCode = $user['user_code']; }
Log::debug('pull.php: started'); set_time_limit(0); $errorConsoleWriter = new Zend\Log\Writer\Stream('php://stderr'); $logger->addWriter($errorConsoleWriter); $filter = new Zend\Log\Filter\Priority(Zend\Log\Logger::NOTICE); $errorConsoleWriter->addFilter($filter); if (isset($_SERVER['REQUEST_METHOD'])) { Log::warn(sprintf('pull.php: web access attempt (%s)', $_SERVER['REQUEST_URI'])); header('Forbidden', true, 403); die('Forbidden'); } isset($argv) && isset($argv[1]) && ($argv[1] == '-q' || $argv[1] == '--quiet') && ($quiet = true) or $quiet = false; Log::info(sprintf('pull.php: verbosity %s', $quiet ? ' disabled' : 'enabled')); !$quiet && (print "=== Update process started ===\r\n"); Log::info('pull.php: update process started '); $h = Habrometr_Model::getInstance(); $list = $h->getUserList(); $users = $list['list']; $errorCounter = 0; foreach ($users as $key => $user) { try { $h->pullValues($user); system('rm -f ' . __DIR__ . '/image_cache/habrometr_*_' . escapeshellcmd($user['user_code']) . '.png'); $errorCounter = 0; Log::debug(sprintf('pull.php: user [%s] %s updated', $key, $user['user_code'])); } catch (Exception $e) { $errorCounter++; !$quiet && (print "Error updating user [{$key}] {$user['user_code']}"); Log::err(sprintf('pull.php: error updating user [%s] %s)', $key, $user['user_code'])); if ($errorCounter > 20) { Log::crit('pull.php: consecutive errors counter exceed 20 - break update process)');