From 40a11965e54beb30ce3f3e0cd8ff39f98b45fd0b Mon Sep 17 00:00:00 2001 From: Igor V Belousov Date: Mon, 23 Jan 2017 13:25:19 +0300 Subject: [PATCH] 13:25 --- frm/App.php | 32 ++++++++++++++++++++++++++++++-- frm/Controller.php | 6 +++++- frm/View.php | 9 ++++++++- src/C/CAPTCHAController.php | 7 +++++-- src/C/IndexController.php | 10 +++++++--- src/M/AdModel.php | 4 ++-- src/start.php | 4 +++- 7 files changed, 60 insertions(+), 12 deletions(-) diff --git a/frm/App.php b/frm/App.php index e5b79e9..30f04c4 100644 --- a/frm/App.php +++ b/frm/App.php @@ -6,17 +6,45 @@ * Time: 01:58 */ -namespace FRM; +namespace PFRM; class App { + protected $user_agent; + + protected $user_IP; + + protected $route_table; + function __construct() { date_default_timezone_set('Europe/Moscow'); error_reporting(E_ALL); + $this->user_agent = $_SERVER['HTTP_USER_AGENT']; + $this->user_IP = $_SERVER['REMOTE_ADDR']; + $this->setRoute('/^\/$/','Index','index'); } - function run(){ + /** + * @return mixed + */ + public function getUseragent() { + return $this->user_agent; + } + + /** + * @return mixed + */ + public function getUserIP() { + return $this->user_IP; + } + + public function setRoute( $regexp, $controller, $action = 'index') { + $this->route_table[] = array($regexp,$controller,$action); + } + + + public function run(){ } } \ No newline at end of file diff --git a/frm/Controller.php b/frm/Controller.php index a5e336f..d53a26c 100644 --- a/frm/Controller.php +++ b/frm/Controller.php @@ -6,12 +6,16 @@ * Time: 01:49 */ -namespace FRM; +namespace PFRM; class Controller { + public $app; + function __construct() { + global $app; + $this->app = $app; session_start(); } diff --git a/frm/View.php b/frm/View.php index 1a3b29e..cd7e819 100644 --- a/frm/View.php +++ b/frm/View.php @@ -6,9 +6,16 @@ * Time: 02:45 */ -namespace FRM; +namespace PFRM; class View { + public $app; + function __construct() { + } + + public function render( ) { + + } } \ No newline at end of file diff --git a/src/C/CAPTCHAController.php b/src/C/CAPTCHAController.php index 7fe6c5a..ce8e547 100644 --- a/src/C/CAPTCHAController.php +++ b/src/C/CAPTCHAController.php @@ -6,9 +6,12 @@ * Time: 00:18 */ -namespace PTEST; +namespace PTEST\Controller; -class CAPTCHAController { +class CAPTCHA { + public function indexAction() { + + } } \ No newline at end of file diff --git a/src/C/IndexController.php b/src/C/IndexController.php index e8b1c97..0e1ae1c 100644 --- a/src/C/IndexController.php +++ b/src/C/IndexController.php @@ -6,11 +6,15 @@ * Time: 00:16 */ -namespace PTEST; +namespace PTEST\Controller; -use FRM\Controller; +use PFRM\Controller; -class IndexController extends Controller { +class Index extends Controller { + + public function indexAction() { + print "index action"; + } } \ No newline at end of file diff --git a/src/M/AdModel.php b/src/M/AdModel.php index 5d6685d..b4557e6 100644 --- a/src/M/AdModel.php +++ b/src/M/AdModel.php @@ -6,10 +6,10 @@ * Time: 00:20 */ -namespace PTEST; +namespace PTEST\Model; -class AdModel { +class Ad { protected $id; diff --git a/src/start.php b/src/start.php index ab1be18..226a560 100644 --- a/src/start.php +++ b/src/start.php @@ -8,6 +8,8 @@ require_once __DIR__ . '/../vendor/autoload.php'; -$app = new \FRM\App(); +use \PFRM\App; +$app = new App(); +$app->setRoute('/^CAPCHA.png$/','CAPTCHA'); $app->run(); \ No newline at end of file