Example #1
20
 public function myAccount()
 {
     if (isset($this->session->userdata["user_id"])) {
         $data = array();
         $model = new Common_model();
         $user_id = $this->session->userdata["user_id"];
         $username = $this->session->userdata["user_username"];
         if ($this->input->post()) {
             $arr = $this->input->post();
             //                prd($arr);
             if (isset($arr["btn_submit"])) {
                 $user_dob = NULL;
                 if (!empty($arr['dob_dd']) && !empty($arr['dob_mm']) && !empty($arr['dob_yy'])) {
                     $user_dob = $arr['dob_yy'] . '-' . $arr['dob_mm'] . '-' . $arr['dob_dd'];
                 }
                 $location_details = get_location_details_from_google(trim($arr['user_location']));
                 $location_lat_long = getLatLonByAddress(trim($arr['user_location']));
                 $data_array = array('user_fullname' => addslashes($arr['user_fullname']), 'user_gender' => addslashes($arr['user_gender']), 'user_location' => addslashes($arr['user_location']), 'user_city' => $location_details['city'], 'user_state' => $location_details['state'], 'user_country' => $location_details['country'], 'user_location' => trim($arr['user_location']), 'user_latitude' => $location_lat_long['latitude'], 'user_longitude' => $location_lat_long['longitude'], 'user_tagline' => addslashes($arr['user_tagline']), 'user_about' => addslashes($arr['user_about']), 'user_relationship_status' => addslashes($arr['user_relationship_status']), 'user_dob' => $user_dob);
                 if (isset($arr['user_username'])) {
                     $username = trim($arr['user_username']);
                     $checkUsername = $model->is_exists("user_id", TABLE_USERS, array("username" => $username, "user_id !=" => $user_id));
                     if (!empty($checkUsername)) {
                         $this->session->set_flashdata("error", "That username is already taken. Please choose another.");
                     } else {
                         $data_array['user_username'] = $username;
                         $data_array['user_changed_username'] = '******';
                     }
                 }
                 $this->session->set_flashdata("success", "Personal details updated successfully");
                 $model->updateData(TABLE_USERS, $data_array, array("user_id" => $user_id));
                 // updating redis keys now
                 $this->redis_functions->set_user_profile_data($username);
                 @$this->session->set_userdata("user_fullname", trim($arr["user_fullname"]));
                 @$this->session->set_userdata("user_username", $username);
             }
             redirect(base_url('my-account'));
         } else {
             $record = $this->redis_functions->get_user_profile_data($username);
             $page_title = $record["user_fullname"];
             $input_arr = array(base_url() => 'Home', '#' => $page_title);
             $breadcrumbs = get_breadcrumbs($input_arr);
             $data["record"] = $record;
             $data["breadcrumbs"] = $breadcrumbs;
             $data["page_title"] = $page_title;
             $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME');
             $this->template->write_view("content", "pages/user/my-account", $data);
             $this->template->render();
         }
     } else {
         require_once APPPATH . 'controllers/index.php';
         $index_controller = new Index();
         $index_controller->login();
     }
 }
Example #2
0
 public function redirect()
 {
     require 'app/controllers/indexcontroller.php';
     $controller = new Index();
     $controller->index();
     return false;
 }
Example #3
0
 public function __construct()
 {
     $url = isset($_GET["url"]) ? $_GET["url"] : null;
     $url = rtrim($url, "/");
     $url = explode("/", $url);
     if (empty($url[0])) {
         require "controllers/index.php";
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = "controllers/" . $url[0] . ".php";
     if (file_exists($file)) {
         require $file;
     } else {
         require "controllers/error.php";
         $controller = new Error();
         return false;
     }
     $controller = new $url[0]();
     $controller->LoadModel($url[0]);
     if (isset($url[2])) {
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}($url[2]);
         } else {
             echo "Error ошибка";
         }
     } else {
         if (isset($url[1])) {
             $controller->{$url[1]}();
         } else {
             $controller->index();
         }
     }
 }
Example #4
0
 public function add_new($step = 1, $url_key = NULL)
 {
     if (isset($this->session->userdata["user_id"])) {
         $data = array();
         $user_id = $this->session->userdata["user_id"];
         $model = new Common_model();
         switch ($step) {
             case 1:
                 // meta info
                 $this->add_new_step_one($url_key);
                 break;
             case 2:
                 // regions
                 $this->add_new_step_two($url_key);
                 break;
             case 3:
                 // budgets
                 $this->add_new_step_three($url_key);
                 break;
             case 4:
                 // media
                 $this->add_new_step_four($url_key);
                 break;
         }
     } else {
         require_once APPPATH . 'controllers/index.php';
         $index_controller = new Index();
         $index_controller->login();
     }
 }
Example #5
0
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     //print_r($url);
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         $this->error();
     }
     $controller = new $url[0]();
     $controller->loadModel($url[0]);
     // calling methods
     if (isset($url[1])) {
         if (method_exists($controller, $url[1])) {
             if (isset($url[2])) {
                 $controller->{$url[1]}($url[2]);
             } else {
                 $controller->{$url[1]}();
             }
         } else {
             $this->error();
         }
     } else {
         $controller->index();
     }
 }
Example #6
0
 function __construct()
 {
     $url = filter_input(INPUT_GET, 'url');
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     if (empty($url[0])) {
         require 'controllers/controllerIndex.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/controller' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         require 'controllers/controllerError.php';
         $controller = new Error();
         $controller->index($url[0]);
         return false;
     }
     $controller = new $url[0]();
     if (isset($url[1])) {
         if (method_exists($controller, $url[1])) {
             if (isset($url[2])) {
                 $controller->{$url[1]}($url[2]);
             } else {
                 $controller->{$url[1]}();
             }
         } else {
             $controller->index();
         }
     } else {
         $controller->index();
     }
 }
Example #7
0
 function __construct()
 {
     $route = isset($_GET['route']) ? $_GET['route'] : null;
     $route = rtrim($route, '/');
     $route = explode('/', $route);
     if (empty($route[0])) {
         //если путь пуст, вызывает главную страницу
         require_once 'controllers/index.php';
         //вызываем вид
         $controller = new Index('index');
         $controller->Index();
         return false;
     }
     $file = 'controllers/' . $route[0] . '.php';
     //если есть страница, указанная в маршруте, подключаем ее
     if (file_exists($file)) {
         require_once $file;
     } else {
         $controller = new Error();
     }
     //вызываем обьект подключенного файла
     $controller = new $route[0]($route[0]);
     //загружаем модель
     $controller->loadModel($route[0]);
     //$controller->Index();
     if (isset($route[1])) {
         $controller->{$route[1]}();
     } else {
         $controller->Index();
     }
 }
Example #8
0
 /**
  * Returns the data
  *
  * @return String
  */
 public function getData()
 {
     if (is_null($this->data)) {
         $this->data = $this->index->getParser()->getData($this->getOffset());
     }
     return $this->data;
 }
Example #9
0
 function logOut()
 {
     session_destroy();
     echo "<div class='alert alert-warning' role='alert'>Je bent nu uitgelogd.</div>";
     $index = new Index();
     $index->redirect('index.php');
 }
Example #10
0
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         throw new Exception("file doesnt exits");
     }
     $controller = new $url[0]();
     $controller->loadModel($url[0]);
     if (isset($url[2])) {
         $controller->{$url[1]}($url[2]);
     } else {
         if (isset($url[1])) {
             $controller->{$url[1]}();
         } else {
             $controller->index();
         }
     }
 }
 function __construct()
 {
     $urlll = '';
     //$url = isset($_GET['url']) ? $_GET['url']: null;
     if (isset($_GET['url']) && is_string($_GET['url'])) {
         $url = $_GET['url'];
         // name in $_GET['url'] is ok, so you can set it
         $url = filter_var($url, FILTER_SANITIZE_URL);
         $urll = rtrim($url, '/');
         //right trim if there are more than on /
         $urlll = explode('/', $urll);
     }
     /*
      *print_r($urlll);//for debugging
      *echo '<br/>';
      */
     //when there is empty url
     if (empty($urlll[0])) {
         //echo 'bootstrap initiating Main Index page, \'controllers/Index.php\'</br>';
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
         //the remaining below code is not executed
     }
     $file = 'controllers/' . $urlll[0] . '.php';
     //never user controllers, instead use config.ini
     if (file_exists($file)) {
         //checking if url exists
         //incude the file
         require $file;
     } else {
         $this->error();
         return false;
         //stops the execution of code and returns
     }
     //initializes the class of the 'included' controller
     $controller = new $urlll[0]();
     //redirecting to the controller's php file
     $controller->loadModel($urlll[0]);
     if (isset($urlll[2])) {
         if (method_exists($controller, $urlll[1])) {
             $controller->{$urlll[1]}($urlll[2]);
             //function(param)
         } else {
             $this->error();
         }
     } else {
         if (isset($urlll[1])) {
             if (method_exists($controller, $urlll[1])) {
                 $controller->{$urlll[1]}();
                 //function()
             } else {
                 $this->error();
             }
         } else {
             $controller->index();
         }
     }
 }
Example #12
0
 function error()
 {
     require 'controllers/index.php';
     $controller = new Index();
     $controller->LoadModel('index');
     $controller->loadError();
     return false;
 }
Example #13
0
 public function testIndexActionException()
 {
     $this->request->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $exception = new \Exception();
     $this->request->expects($this->once())->method('getPost')->will($this->throwException($exception));
     $this->logger->expects($this->once())->method('logException')->with($this->identicalTo($exception));
     $this->response->expects($this->once())->method('setHttpResponseCode')->with(500);
     $this->model->execute();
 }
Example #14
0
 function __construct($http, $url, $controller, $method, $params)
 {
     if ($http == "GET") {
         if ($params = null) {
             return true;
         }
         $burl = isset($_GET['url']) ? $_GET['url'] : null;
         $burl = rtrim($burl, '/');
         $burl = explode('/', $burl);
         $url = rtrim($url, '/');
         $url = explode('/', $url);
         if (empty($burl[0])) {
             require 'app/controllers/indexcontroller.php';
             $controller = new Index();
             $controller->index();
             return false;
         } elseif ($burl[0] == 'index' || $burl[0] == "Index") {
             require 'app/controllers/indexcontroller.php';
             $controller = new Index();
             $controller->index();
             return false;
         }
         /////////////////////////////////////////////////////////////////////////////////////////////
         if ($burl == $url) {
             $file = 'app/controllers/' . $controller . '.php';
             if (file_exists($file)) {
                 require $file;
             } else {
                 $this->error();
                 return false;
             }
             $findcont = $controller;
             $class = rtrim($controller, 'controller');
             $classname = $class;
             $class = new $class();
             if (isset($params)) {
                 if (method_exists($findcont, $method)) {
                     $findcont->{$method}($params);
                 } else {
                     $this->methoderror();
                     return false;
                 }
             } else {
                 if (isset($controller)) {
                     if (method_exists($classname, $method)) {
                         $class->{$method}();
                     } else {
                         $this->methoderror();
                         return false;
                     }
                 }
             }
         }
         ///////////end of if burl = url[0]
     }
 }
Example #15
0
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, "/");
     $url = explode("/", $url);
     if (empty($url[0])) {
         require '../controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     // CONTROLLER
     // Only allow a controller name with dashes & alphanumeric characters
     if (preg_match('/[^0-9a-z-]/i', $url[0])) {
         require '../controllers/error.php';
         $controller = new Error("Invalid Character In Controller Name.");
         return false;
     }
     // For the script to read past this line, the controller must be alphanumeric w/ dash
     $file = '../controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         // controller file not found
         // HOW CAN I LOG ERRORS HERE? PUT THEM INTO A DATABASE?
         require '../controllers/error.php';
         $controller = new Error("Controller not found: " . $url[0]);
         return false;
         //throw new Exception("The file '$file' does not exist!");
     }
     $controller = new $url[0]();
     $controller->loadModule($url[0]);
     // CALLING METHODS -------------------------------
     if (isset($url[2])) {
         // CHECK IF METHOD EXISTS
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}($url[2]);
         } else {
             require '../controllers/error.php';
             $controller = new Error("Method not found: " . $url[1]);
         }
         return false;
     } elseif (isset($url[1])) {
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}();
         } else {
             require '../controllers/error.php';
             $controller = new Error("Method not found: " . $url[1]);
         }
         return false;
     } else {
         $controller->index();
     }
 }
 public function Index()
 {
     $Index = new Index();
     $data = array();
     $data['html'] = $Index->index();
     $view = new View();
     $view->setData($data);
     $view->setTemplate('../view/_Index.php');
     $view->setLayout('../template/Layout.php');
     $view->render();
 }
Example #17
0
 function Index()
 {
     //print_r($_SESSION);
     //print_r($_COOKIE);
     /**
      * session cookie tourists
      * 
      * 1.判断是登陆,服务器是否保留session
      * 2.如果没有session可取,判断是否本地保存cookie
      * 3.如果session cookie 都没有值可取采用游客登录
      * 
      */
     if (isset($_SESSION['username']) && !empty($_SESSION['username'])) {
         //检测session
         $this->assign('username', $_SESSION['username']);
     } else {
         if (!empty($_COOKIE["username"])) {
             //检测cookie
             $userCookie = $_COOKIE["username"];
             $this->assign('username', $userCookie);
         } else {
             //游客登陆
             $tourists_id = Login::getTouristsId();
             if ($tourists_id == null) {
                 Login::setTouristsId();
             }
         }
     }
     /**
      * 获取顶部banner1数据
      * 
      */
     $index = new Index();
     $banner1 = $index->getBanner1();
     if ($banner1) {
         $this->assign('banner1', $banner1);
     }
     /**
      * 获取banner2数据
      *
      */
     $banner2 = $index->getBanner2();
     if ($banner2) {
         $this->assign('banner2', $banner2);
     }
     /**
      * 获取website数据
      *
      */
     $websites = $index->getWebsites();
     if ($websites) {
         $this->assign('websites', $websites);
     }
 }
Example #18
0
 public function actionCreate()
 {
     $column = new Column();
     $column->TABLE_NAME = $this->table;
     $table = Table::model()->findByPk(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table));
     if (isset($_POST['Column'])) {
         $column->attributes = $_POST['Column'];
         /*
          * Add index
          */
         $addIndices = array();
         if (isset($_POST['createIndexPrimary'])) {
             $column->createPrimaryKey = true;
         }
         if (isset($_POST['createIndex'])) {
             $addIndices['INDEX'] = $column->COLUMN_NAME;
         }
         if (isset($_POST['createIndexUnique'])) {
             $column->createUniqueKey = true;
         }
         if (isset($_POST['createIndexFulltext'])) {
             $addIndices['FULLTEXT'] = $column->COLUMN_NAME . (array_search($column->COLUMN_NAME, $addIndices) !== false ? '_fulltext' : '');
         }
         if ($sql = $column->save()) {
             $response = new AjaxResponse();
             $response->addNotification('success', Yii::t('core', 'successAddColumn', array('{col}' => $column->COLUMN_NAME)), null, $sql);
             $response->refresh = true;
             foreach ($addIndices as $type => $indexName) {
                 try {
                     $index = new Index();
                     $index->throwExceptions = true;
                     $index->TABLE_NAME = $this->table;
                     $index->TABLE_SCHEMA = $this->schema;
                     $index->INDEX_NAME = $indexName;
                     $index->setType($type);
                     $indexCol = new IndexColumn();
                     $indexCol->COLUMN_NAME = $column->COLUMN_NAME;
                     $index->columns = array($indexCol);
                     $sql = $index->save();
                     $response->addNotification('success', Yii::t('core', 'successCreateIndex', array('{index}' => $index->INDEX_NAME)), null, $sql);
                 } catch (DbException $ex) {
                     $response->addNotification('error', Yii::t('core', 'errorCreateIndex', array('{index}' => $index->INDEX_NAME)), $ex->getText(), $ex->getSql());
                 }
             }
             $this->sendJSON($response);
         }
     }
     $collations = Collation::model()->findAll(array('order' => 'COLLATION_NAME', 'select' => 'COLLATION_NAME, CHARACTER_SET_NAME AS collationGroup'));
     CHtml::generateRandomIdPrefix();
     $data = array('column' => $column, 'table' => $table, 'collations' => $collations);
     $data['formBody'] = $this->renderPartial('formBody', $data, true);
     $this->render('form', $data);
 }
Example #19
0
 public function __construct()
 {
     // метод, который вызовется автоматом при создании класса
     if (isset($_GET[url])) {
         $url = $_GET[url];
     } else {
         $url = NULL;
     }
     $url = rtrim($url, "/");
     // убираем слеш в конце строки
     $url = explode("/", $url);
     // разбиваем строку в массив, что потом делать запросы
     if (empty($url[0])) {
         require "controllers/index.php";
         // если  $url[0] не передается, то мы подклюаем индекс
         $controller = new Index();
         $controller->index();
         return false;
     }
     Cookie::set('basket');
     $file = "controllers/" . $url[0] . ".php";
     if (file_exists($file)) {
         // проверяем существование файла
         require $file;
         // подключаем файл, если он сущесвует
     } else {
         require "controllers/error.php";
         // если файла "controllers/".$url[0].".php" нету, то выдаем ошибку
         $controller = new Error();
         return false;
     }
     $controller = new $url[0]();
     $controller->LoadModel($url[0]);
     // загружаем модель и передаем в нее параметр
     if (isset($url[2])) {
         // проверяем наличие параметра метода
         if (method_exists($controller, $url[1])) {
             // проверяем наличие метода, и если он есть то передаем в него параметр, если нет, то выдаем ошибку
             $controller->{$url[1]}($url[2]);
         } else {
             echo "Ошибка при вызове метода";
         }
     } else {
         // если второго параметра нет, то запускаем просто метод на выполнение
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}();
         } else {
             $controller->index();
             // если и метода нет, то запускаем индексовый метод
         }
     }
 }
 public function testCompareDifferentOrder()
 {
     $c1 = new Column('Foo');
     $c2 = new Column('Bar');
     $i1 = new Index('Foo_Bar_Index');
     $i1->addColumn($c1);
     $i1->addColumn($c2);
     $c3 = new Column('Foo');
     $c4 = new Column('Bar');
     $i2 = new Index('Foo_Bar_Index');
     $i2->addColumn($c4);
     $i2->addColumn($c3);
     $this->assertTrue(PropelIndexComparator::computeDiff($i1, $i2));
 }
Example #21
0
 /**
  * Create url: get url and make from it an array
  */
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     //check if site.ru/index or just site.ru
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     /**
      * Service function to check if the array was constructed properly
      */
     //print_r($url);
     //require 'controllers/' . $url[0] . '.php';
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
     } else {
         $this->error();
     }
     $controller = new $url[0]();
     $controller->loadModel($url[0]);
     /**
      * С помощью данной магии мы из массива с url
      * вызываем необходимую функцию, например,
      * mvc.example/help/other where help is a controller
      * and other is a function
      * calling methods
      */
     if (isset($url[2])) {
         if (method_exists($controller, $url[1])) {
             $controller->{$url[1]}($url[2]);
         } else {
             $this->error();
         }
     } else {
         if (isset($url[1])) {
             if (method_exists($controller, $url[1])) {
                 $controller->{$url[1]}();
             } else {
                 $this->error();
             }
         } else {
             $controller->index();
         }
     }
 }
Example #22
0
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = explode('/', $url);
     //print_r($url);
     //if empty redirect to index
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require $file;
         $controller = new $url[0]();
         if (isset($url[1])) {
             if ($url[1] == "") {
                 $controller->index();
             } else {
                 if (isset($url[2])) {
                     if ($url[2] == "") {
                         $controller->{$url}[1]();
                     } else {
                         $controller->{$url}[1]($url[2]);
                     }
                 } else {
                     if (method_exists($controller, $url[1])) {
                         //	$controller->index();
                         $controller->{$url}[1]();
                     } else {
                         require 'controllers/error.php';
                         $controller = new Error();
                         $controller->index();
                         return false;
                     }
                 }
             }
         }
         if (!isset($url[1])) {
             $controller->index();
         }
     } else {
         require 'controllers/error.php';
         $controller = new Error();
         $controller->index();
         return false;
     }
 }
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : null;
     $url = rtrim($url, '/');
     $url = filter_var($url, FILTER_SANITIZE_URL);
     $url = explode('/', $url);
     // no url, then direct to index page
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $this->direct($url);
 }
Example #24
0
 public function __call($method, $arguments)
 {
     if ($method === 'index' || array_key_exists($method, Column::$TYPES)) {
         if (count($arguments) <= 0) {
             throw new MissingArgumentException($method, __CLASS__);
         }
         $column = $arguments[0];
         $options = !empty($arguments[1]) ? $arguments[1] : array();
         if ($method === 'index') {
             if (!is_array($column)) {
                 $column = array($column);
             }
             $this->indexes = array_merge($this->indexes, array(array('name' => Index::instance()->getName($column, $options), 'keys' => '`' . implode('`,`', $column) . '`')));
         } else {
             $options['id'] = $column;
             $options['type'] = $method;
             $this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase($options)));
         }
     } else {
         if ($method === 'timestamps') {
             $this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase(array('id' => 'created_at', 'type' => 'datetime'))));
             $this->columns = array_merge($this->columns, array(Column::instance()->parseToDatabase(array('id' => 'updated_at', 'type' => 'datetime'))));
         } else {
             throw new UndefinedMethodException($method, __CLASS__);
         }
     }
 }
 /**
  * @param int $cursor
  */
 private function doQuery($cursor = null)
 {
     if ($cursor !== null) {
         $this->params['cursor'] = $cursor;
     }
     $this->answer = $this->index->browseFrom($this->query, $this->params, $cursor);
 }
Example #26
0
 /**
  * Runs the CLI process
  *
  * @param array $args CLI arguments
  *
  * @return mixed
  */
 public function run(array $args)
 {
     if (count($args) < 3) {
         Index::error('Not enough arguments.', 'Usage: eve job random-mail subject=hi&body=hello...');
     }
     $data = array();
     if (strpos($args[2], '?') === 0) {
         parse_str(substr($args[2], 1), $data);
     } else {
         $data = json_decode($args[2], true);
     }
     $namespace = 'Eve';
     if (file_exists($this->cwd . '/composer.json')) {
         $json = $this('file', $this->cwd . '/composer.json')->getContent();
         $json = json_decode($json, true);
         if (isset($json['autoload']['psr-4']) && is_array($json['autoload']['psr-4'])) {
             foreach ($json['autoload']['psr-4'] as $namespace => $path) {
                 if (strlen($path) === 0) {
                     $namespace = substr($namespace, 0, -1);
                     break;
                 }
             }
         }
     }
     \Eve\Framework\Index::i($this->cwd, $namespace)->defaultPaths()->defaultDatabases()->job($args[1])->setData($data)->run();
     Index::success('`' . $args[1] . '` job has been successfully executed.');
 }
Example #27
0
 /**
  * Runs the CLI process
  *
  * @param array $args CLI arguments
  *
  * @return mixed
  */
 public function run(array $args)
 {
     Index::info('Usage: `cradle package <vendor/package> <command>`  - Runs a package event');
     Index::info('Usage: `cradle <vendor/package> <command>`          - Runs a package event');
     Index::info('Usage: `cradle event <event name> <json|query>`     - Runs an event');
     Index::info('Usage: `cradle <event name> <json|query>`           - Runs an event');
 }
 public function getLists()
 {
     $lists['slesar'] = Index::getLists('slesar');
     $lists['kuzov'] = Index::getLists('kuzov');
     $lists['uslugi'] = Index::getLists('uslugi');
     return $lists;
 }
Example #29
0
 function __construct()
 {
     $url = isset($_GET['url']) ? $_GET['url'] : "index";
     $url = rtrim($url, '/');
     $url = explode('/', $url);
     if (empty($url[0])) {
         require 'controllers/index.php';
         $controller = new Index();
         $controller->index();
         return false;
     }
     $file = 'controllers/' . $url[0] . '.php';
     if (file_exists($file)) {
         require 'controllers/' . $url[0] . '.php';
     } else {
         $this->error("Bunday File topilmadi");
         return false;
     }
     $controller = new $url[0]();
     $path = './models/' . $url[0] . '_model.php';
     if (file_exists($path)) {
         $controller->loadModel($url[0]);
     }
     if (isset($url[2]) != null) {
         if (method_exists($controller, $url[1])) {
             if (isset($url[3])) {
                 $controller->{$url[1]}($url[2], $url[3]);
             } else {
                 $controller->{$url[1]}($url[2]);
             }
         } else {
             $this->error("Bunday Method mavjud emas");
             return false;
         }
     } else {
         if (isset($url[1])) {
             if (method_exists($controller, $url[1])) {
                 $controller->{$url[1]}();
             } else {
                 $this->error("Bunday Method mavjud emas");
                 return false;
             }
         } else {
             $controller->index();
         }
     }
 }
Example #30
0
 /**
  * Is used as error handler
  *
  * @param int			$level	Error level
  * @param null|string	$string	Error message
  */
 function trigger($level, $string = null)
 {
     if (!$this->error) {
         return;
     }
     $string = xap($string);
     $dump = 'null';
     $debug_backtrace = debug_backtrace();
     if (isset($debug_backtrace[0]['file'], $debug_backtrace[0]['file'])) {
         $file = $debug_backtrace[0]['file'];
         $line = $debug_backtrace[0]['line'];
     } else {
         $file = $debug_backtrace[1]['file'];
         $line = $debug_backtrace[1]['line'];
     }
     if (DEBUG) {
         $dump = _json_encode($debug_backtrace);
     }
     unset($debug_backtrace);
     $log_file = LOGS . '/' . date('d-m-Y') . '_' . strtr(date_default_timezone_get(), '/', '_');
     $time = date('d-m-Y h:i:s') . ' [' . microtime(true) . ']';
     switch ($level) {
         case E_USER_ERROR:
         case E_ERROR:
             ++$this->num;
             file_put_contents($log_file, "E {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "E {$time} {$string} Occurred: {$file}:{$line}";
             error_code(500);
             /**
              * If Index instance exists - execution will be stopped there, otherwise in Page instance
              */
             Index::instance(true)->__finish();
             Page::instance()->error();
             break;
         case E_USER_WARNING:
         case E_WARNING:
             ++$this->num;
             file_put_contents($log_file, "W {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "W {$time} {$string} Occurred: {$file}:{$line}";
             break;
         default:
             file_put_contents($log_file, "N {$time} {$string} Occurred: {$file}:{$line} Dump: {$dump}\n", LOCK_EX | FILE_APPEND);
             unset($dump);
             $this->errors_list[] = "N {$time} {$string} Occurred: {$file}:{$line}";
             break;
     }
     /**
      * If too many non-critical errors - also stop execution
      */
     if ($this->num >= 100) {
         /**
          * If Index instance exists - execution will be stopped there, otherwise in Page instance
          */
         Index::instance(true)->__finish();
         Page::instance()->error();
     }
 }