diff --git a/app/Action.php b/app/Action.php
index 63c7cca..eeebd3a 100644
--- a/app/Action.php
+++ b/app/Action.php
@@ -11,21 +11,21 @@
abstract class Action
{
-
+
protected $template;
-
+
/**
* @var PHPView
*/
protected $view;
-
+
public function __construct()
{
$this->view = FrontController::getInstance()->getView();
$this->extractParams();
$this->execute();
}
-
+
protected function extractParams()
{
foreach (Env::getParam() as $name => $value) {
@@ -34,12 +34,12 @@ abstract class Action
}
}
}
-
+
abstract protected function execute();
-
+
/**
* Redirect
- *
+ *
* @param mixed $url
*/
protected function redirect($url = null)
@@ -47,15 +47,15 @@ abstract class Action
header('Location: ' . (($url) ? $url : Env::getRequestUri()));
exit();
}
-
+
protected function getTemplate()
{
$class = get_class($this);
- $template = ($this->template) ? $this->template : substr($class, 0, -6/*strlen('Action')*/);
+ $template = ($this->template) ? $this->template : substr($class, 0, -6 /*strlen('Action')*/);
$dir = array_slice(explode('/', Load::getFilePath($class)), -2, 1);
return '/actions/' . array_pop($dir) . '/' . $template;
}
-
+
public function fetch()
{
$this->view->assignObject($this);
diff --git a/app/AjaxAction.php b/app/AjaxAction.php
index 3dd86d7..0316bf1 100644
--- a/app/AjaxAction.php
+++ b/app/AjaxAction.php
@@ -12,11 +12,12 @@
*/
/**
-* базовый класс для всей экшенов выполняющихся по аякс-запросу
-*/
+ * базовый класс для всей экшенов выполняющихся по аякс-запросу
+ */
abstract class AjaxAction extends Action
{
public $data = 1;
+
protected $encode = true;
function __construct()
diff --git a/app/ErrorAction.php b/app/ErrorAction.php
index 9afca12..ed24c53 100644
--- a/app/ErrorAction.php
+++ b/app/ErrorAction.php
@@ -11,18 +11,18 @@
class ErrorAction extends Action
{
-
+
/**
* @var ErrorException
*/
public $exception;
-
+
public function __construct($exception)
{
$this->exception = $exception;
parent::__construct();
}
-
+
protected function execute()
{
$this->template = 500;
@@ -38,12 +38,12 @@ class ErrorAction extends Action
$this->logError();
$this->sendHTTPCode();
}
-
+
protected function getTemplate()
{
return '/actions/' . $this->template;
}
-
+
protected function sendHttpCode()
{
if (headers_sent()) {
@@ -67,7 +67,7 @@ class ErrorAction extends Action
if ($ex instanceof ErrorException) {
$error = $ex->getSeverity();
}
-
+
switch ($error) {
case E_NOTICE:
$error = 'Notice';
diff --git a/app/FrontController.php b/app/FrontController.php
index 1412d48..23cc62e 100644
--- a/app/FrontController.php
+++ b/app/FrontController.php
@@ -15,20 +15,20 @@ class FrontController
* @var Router
*/
protected $router;
-
+
/**
* @var string
*/
protected $view = 'PHPView';
-
+
protected $base_url = '';
-
+
/**
* @var FrontController
*/
protected static $instance;
-
-
+
+
private function __construct()
{
ErrorHandler::init();
@@ -37,7 +37,7 @@ class FrontController
}
$this->router = new Router();
}
-
+
/**
* Refuse cloning
*/
@@ -53,7 +53,7 @@ class FrontController
}
return self::$instance;
}
-
+
/**
* @param string $view
* @return FrontController
@@ -63,9 +63,9 @@ class FrontController
$this->view = $view;
return $this;
}
-
+
/**
- *
+ *
* @return iView
*/
public function getView($view = null)
@@ -73,7 +73,7 @@ class FrontController
$view = ($view) ? $view : $this->view;
return new $view(Config::get($view));
}
-
+
/**
* @param string $url
*/
@@ -82,12 +82,12 @@ class FrontController
$this->base_url = rtrim($url, '/');
return $this;
}
-
+
public function getBaseUrl()
{
return $this->base_url;
}
-
+
/**
* @return Router
*/
@@ -95,7 +95,7 @@ class FrontController
{
return $this->router;
}
-
+
public function execute()
{
try {
@@ -104,18 +104,18 @@ class FrontController
if (!$route) {
throw new Error404Exception('Route for "' . $request . '" not found');
}
-
+
$action_class = $route->getAction();
if (!class_exists($action_class)) {
throw new GeneralException('Action class "' . $action_class . '" not found.');
}
-
+
$action = new $action_class();
$layout_class = $route->getLayout();
if (!class_exists($layout_class)) {
throw new GeneralException('Layout class "' . $layout_class . '" not found.');
}
-
+
$layout = new $layout_class();
$html = $layout->fetch($action);
if (DEBUG) {
diff --git a/app/PagerAction.php b/app/PagerAction.php
index 957db46..cd150d9 100644
--- a/app/PagerAction.php
+++ b/app/PagerAction.php
@@ -11,9 +11,12 @@
class PagerAction extends Action
{
- public $page = 1;
+ public $page = 1;
+
public $last_page = 1;
+
protected $offset = 0;
+
protected $limit;
public function __construct($limit = 20)
@@ -45,10 +48,10 @@ class PagerAction extends Action
{
return (int) $this->limit;
}
-
+
protected function getTemplate()
{
- $template = ($this->template) ? $this->template : substr(get_class($this), 0, -6/*strlen('Action')*/);
+ $template = ($this->template) ? $this->template : substr(get_class($this), 0, -6 /*strlen('Action')*/);
return '/actions/' . $template;
}
}
\ No newline at end of file
diff --git a/app/StaticAction.php b/app/StaticAction.php
index ec858be..eff6f75 100644
--- a/app/StaticAction.php
+++ b/app/StaticAction.php
@@ -11,13 +11,13 @@
abstract class StaticAction extends Action
{
-
+
protected function getTemplate()
{
- $template = ($this->template) ? $this->template : substr(get_class($this), 0, -6/*strlen('Action')*/);
+ $template = ($this->template) ? $this->template : substr(get_class($this), 0, -6 /*strlen('Action')*/);
return '/static/' . $template;
}
-
+
public function fetch()
{
return $this->view->fetch($this->getTemplate());
diff --git a/cache/CacheKey.php b/cache/CacheKey.php
index 572518e..8121026 100644
--- a/cache/CacheKey.php
+++ b/cache/CacheKey.php
@@ -16,11 +16,12 @@ class CacheKey
* @var Cacher
*/
protected $cacher;
-
+
/**
* @var CacheKey
*/
protected $key;
+
protected $expire = 0;
/**
@@ -32,11 +33,11 @@ class CacheKey
*/
public function __construct($cacher, $key, $params = array(), $expire = 0)
{
- $this->cacher = $cacher;
+ $this->cacher = $cacher;
$this->key = $key;
if ($params) {
$params = (is_array($params)) ? implode('|', $params) : $params;
- $this->key = $key . '_' . $params;
+ $this->key = $key . '_' . $params;
}
$this->expire = $expire;
}
diff --git a/cache/Cacher.php b/cache/Cacher.php
index f6269f6..3760432 100644
--- a/cache/Cacher.php
+++ b/cache/Cacher.php
@@ -11,15 +11,14 @@
class Cacher
{
-
+
/**
* Initialized cachers
- *
+ *
* @var array
*/
static protected $caches = array();
-
-
+
static public function get($cacher, $config = null)
{
if (!isset(self::$caches[$cacher])) {
diff --git a/captcha/Captcha.php b/captcha/Captcha.php
index 919bc9e..d843c20 100644
--- a/captcha/Captcha.php
+++ b/captcha/Captcha.php
@@ -11,47 +11,49 @@
class Captcha
{
-
+
protected $font_size = 38;
- protected $width = 200;
- protected $height = 70;
+
+ protected $width = 200;
+
+ protected $height = 70;
public function getImage($token)
{
$font = dirname(__FILE__) . '/poh.ttf';
-
+
$image = imagecreatetruecolor($this->width, $this->height);
// белый фон
$background = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image, 0, 0, $this->width, $this->height, $background);
-
+
// основная магия тут
if (Session::get('_ctoken') == $token && Session::get('_ccode')) {
-
+
$code = Session::get('_ccode');
-
+
$color = imagecolorallocate($image, 81, 81, 81);
-
+
for ($j = 0; $j < 5; $j++) {
- imageellipse($image, rand(-$this->width, $this->width * 2),
- rand(-$this->height, $this->height * 2),
+ imageellipse($image, rand(-$this->width, $this->width * 2),
+ rand(-$this->height, $this->height * 2),
$this->width, $this->width, $color);
}
-
+
$letters = preg_split("//u", strtoupper($code));
$length = count($letters);
$step = floor($this->width / $length);
$i = 2;
-
+
foreach ($letters as $key => $letter) {
- imagettftext($image, $this->font_size, 0,
- rand($i + 2, $i + 4), ($this->font_size + $this->height) / 2,
+ imagettftext($image, $this->font_size, 0,
+ rand($i + 2, $i + 4), ($this->font_size + $this->height) / 2,
$color, $font, $letter);
- $i = $i + $step ;
+ $i = $i + $step;
}
}
-
+
ob_start();
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Content-Type: image/jpg");
@@ -59,7 +61,7 @@ class Captcha
imagedestroy($image);
return ob_get_clean();
}
-
+
public function getToken()
{
$token = md5(microtime() . uniqid());
@@ -68,10 +70,10 @@ class Captcha
Session::set('_ccode', $code);
return $token;
}
-
+
public function checkCode($token, $code)
{
- if (Session::get('_ctoken') == $token && Session::get('_ccode') == strtoupper($code)){
+ if (Session::get('_ctoken') == $token && Session::get('_ccode') == strtoupper($code)) {
// Housekeeping
Session::del('_ccode');
Session::del('_ctoken');
diff --git a/captcha/CaptchaImageAction.php b/captcha/CaptchaImageAction.php
index d0d6109..b551295 100644
--- a/captcha/CaptchaImageAction.php
+++ b/captcha/CaptchaImageAction.php
@@ -11,11 +11,11 @@
class CaptchaImageAction
{
-
+
public function __construct()
{
$captcha = new Captcha();
echo $captcha->getImage(Env::Get('ctoken'));
- exit();
+ exit();
}
}
\ No newline at end of file
diff --git a/captcha/CaptchaValidator.php b/captcha/CaptchaValidator.php
index 4bb9f48..4638655 100644
--- a/captcha/CaptchaValidator.php
+++ b/captcha/CaptchaValidator.php
@@ -13,9 +13,9 @@ class CaptchaValidator extends Validator
{
const WRONG_CODE = 'is_empty';
-
+
protected $templates = array(self::WRONG_CODE => 'Entered code wrong');
-
+
public function isValid($value, $context = null)
{
if (!$context || !isset($context['ctoken']) || !isset($context['ccode'])) {
diff --git a/classes/MJException.class.php b/classes/MJException.class.php
deleted file mode 100644
index 6fb9ed4..0000000
--- a/classes/MJException.class.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
- * @link
- * @package Majestic
- * @subpackage Core
- * @since
- * @version SVN: $Id$
- * @filesource $URL$
- */
-class MJException extends Exception
-{
- private $line_range = 6;
-
- public function terminate()
- {
- if (!DEBUG_ENABLE) {
- trigger_error($this->getMessage());
- throw new StaticPageException(500);
- }
-
- $return = "MJ Error: ";
- $return .= str_replace("\n", "
\n", $this->getMessage())."
\n";
-
- $trace = $this->getTrace();
-
- $file = reset($trace);
-
- //смещение в трейсе, указаное при вызове эксепшена (2й параметр). Нужно для более инофрмативного вывода
- if ($shift = abs($this->getCode())) {
- while($shift--) {
- $file = next($trace);
- }
- }
-
- if ($fp = fopen($file['file'], 'r')) {
- $error_line = $file['line'];
- $start = $error_line - $this->line_range;
- $end = $error_line + $this->line_range;
- $i = 1;
- $return .= "
"; - while ($line = fgets($fp, 4096) and $i<=$end) { - $line = htmlspecialchars($line); - if ($i >= $start && $i <= $end) { - if ($i == $error_line) $return .= '"; - fclose($fp); - } - - $return .= ''.$i.' '.$line.''; - else $return .= $i.' '.$line; - } - $i++; - } - $return .= "
".$this->getFile().' | '.$this->getLine().' |
".$row['file'].' | '.$row['line'].' |
' . nl2br($trace) . '
';
}
-
+
/**
* @param Exception $exception
*/
@@ -73,22 +73,22 @@ class ErrorHandler
{
ob_clean();
$class = get_class($exception);
-
+
$method = Env::Server('REQUEST_METHOD', '');
$uri = Env::getRequestUri();
$source = self::getSource($exception->getFile(), $exception->getLine());
$time = date('r', Env::Server('REQUEST_TIME', time()));
-
+
$trace = nl2br($exception->getTraceAsString());
-
+
$get = self::wrapArray(Env::Get(), 'GET');
$post = self::wrapArray(Env::Post(), 'POST');
$session = self::wrapArray(Session::get(), 'SESSION');
$files = self::wrapArray(Env::Files(), 'FILES');
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE');
$server = self::wrapArray(Env::Server(), 'SERVER');
-
- $message =<<