Example #1
0
 public function __construct(BaseController $controller)
 {
     // 配置文件中检测安装设置
     $this->controller = $controller;
     $this->installed = $controller->getAppConfig()->get('appinit', false);
     $this->dbType = $controller->getDbType();
 }
Example #2
0
 public static function raise($exception)
 {
     getLogger()->warn($exception->getMessage());
     $class = get_class($exception);
     $baseController = new BaseController();
     switch ($class) {
         case 'OPAuthorizationException':
         case 'OPAuthorizationSessionException':
             if (isset($_GET['__route__']) && substr($_GET['__route__'], -5) == '.json') {
                 echo json_encode($baseController->forbidden('You do not have sufficient permissions to access this page.'));
             } else {
                 getRoute()->run('/error/403', EpiRoute::httpGet);
             }
             die;
             break;
         case 'OPAuthorizationOAuthException':
             echo json_encode($baseController->forbidden($exception->getMessage()));
             die;
             break;
         default:
             getLogger()->warn(sprintf('Uncaught exception (%s:%s): %s', $exception->getFile(), $exception->getLine(), $exception->getMessage()));
             throw $exception;
             break;
     }
 }
Example #3
0
 public function getPostPage()
 {
     $obj = new BaseController();
     $campusid = $this->getDevice();
     if ($campusid == 0) {
         $countryname = $obj->getCountryName();
         if ($countryname == 'NONE') {
             return Redirect::route('selectcampus-get');
         } else {
             //check whether the country name exists inthe db
             $locationcountry = Country::where('name', '=', $countryname);
             if ($locationcountry->count()) {
                 $locationcountrycode = $locationcountry->first()->code;
                 $locationcountrycode = strtolower($locationcountrycode);
                 return Redirect::route('selectcountryid', $locationcountrycode);
             } else {
                 return Redirect::route('selectcampus-get');
             }
         }
     }
     $college = Institution::whereHas('Branch', function ($query) use($campusid) {
         $query->where('id', '=', $campusid);
     })->first();
     View::share('college', $college);
     $mycampus = Branch::where('id', '=', $campusid)->first();
     View::share('mycampus', $mycampus);
     if (Auth::user()) {
         return View::make('member.post');
     }
     return View::make('guest.post');
 }
 /**
  * @notice Not using hierachical inheriting [extends] classes, but using DI via constructor.
  * Building tree-like sytems will lead to Diamond Problems @see https://en.wikipedia.org/wiki/Multiple_inheritance
  * Besides invoking via extends re-instances the parent objects, whild DI keeps intact.
  * DI is also not perfect, but a better way.
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  * @param App\BaseController $baseController
  */
 public function __construct($request, $baseController)
 {
     $this->request = $request;
     $this->base = $baseController;
     $authService = $this->base->getAuthorizationService();
     $this->isGranted = $authService->isGranted($this->request->get("user"));
 }
Example #5
0
 public static function dispatch(&$request)
 {
     session_start();
     if (isset($request["page"])) {
         switch ($request["page"]) {
             case "login":
                 $controller = new BaseController();
                 $controller->handle_input($request);
                 break;
             case "cliente":
                 $controller = new ClienteController();
                 if (isset($_SESSION[BaseController::role]) && $_SESSION[BaseController::role] != User::Cliente) {
                     self::write403();
                 }
                 $controller->handle_input($request);
                 break;
             case "admin":
                 $controller = new AdminController();
                 if (isset($_SESSION[BaseController::role]) && $_SESSION[BaseController::role] != User::Admin) {
                     self::write403();
                 }
                 $controller->handle_input($request);
                 break;
             default:
                 self::write404();
                 break;
         }
     } else {
         self::write404();
     }
     //        include 'php/view/master.php';
 }
Example #6
0
 public function __construct(BaseController $controller)
 {
     $this->dbType = $controller->getDbType();
     $this->tablePre = $controller->getTablePre();
     if ($this->dbType == BaseController::DB_MYSQL) {
         $this->conn = $controller->getConn();
     } elseif ($this->dbType == BaseController::DB_REDIS) {
         $this->redis = $controller->getRedis();
     }
 }
Example #7
0
 /**
  * @param                $viewName
  * @param BaseController $controller
  *
  * @throws \Exception
  */
 public function __construct($viewName, BaseController $controller)
 {
     $viewDir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
     $layoutPath = $viewDir . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . 'layout.php';
     $viewPath = $viewDir . DIRECTORY_SEPARATOR . $controller->className() . DIRECTORY_SEPARATOR . $viewName . '.php';
     if (!file_exists($layoutPath)) {
         throw new \Exception('Layout file not found!');
     }
     $this->layoutFileName = $layoutPath;
     if (!file_exists($viewPath)) {
         throw new \Exception('View file "' . $viewName . '" not found!');
     }
     $this->viewFileName = $viewPath;
 }
 public function postSelectPackage()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Package' => 'required'));
     if ($validator->fails()) {
         return Redirect::route('advanced_squeeb-get')->withInput()->with('global', 'Please select a package.');
     } else {
         $package = Input::get('Package');
         View::share('package', $package);
         //check for the world package
         if ($package == 'pkg1') {
             $countries = Country::all();
             View::share('countries', $countries);
             $obj = new BaseController();
             $countryid = 0;
             $countryname = $obj->getCountryName();
             if ($countryname != 'NONE') {
                 $locationcountry = Country::where('name', '=', $countryname);
                 if ($locationcountry->count()) {
                     $countryid = $locationcountry->first()->id;
                     $colleges = Institution::where('country_id', '=', $countryid)->get();
                     View::share('colleges', $colleges);
                 }
             }
             View::share('countryid', $countryid);
             return View::make('guest.advancedselectcollege');
         } else {
             if ($package == 'pkg2') {
                 $countries = Country::all();
                 View::share('countries', $countries);
                 $obj = new BaseController();
                 $countryid = 0;
                 $countryname = $obj->getCountryName();
                 if ($countryname != 'NONE') {
                     $locationcountry = Country::where('name', '=', $countryname);
                     if ($locationcountry->count()) {
                         $countryid = $locationcountry->first()->id;
                     }
                 }
                 View::share('countryid', $countryid);
                 return View::make('guest.advancedpostcountry')->with('msg', 'Country Squeeb Package');
             }
         }
         if ($package == 'pkg3') {
             return View::make('guest.advancedpost')->with('msg', 'World Squeeb Package');
         }
     }
 }
Example #9
0
 public function __construct()
 {
     parent::__construct();
     $this->check_session();
     $this->controllerName = "PuntosVenta";
     $this->load->model('common_model');
 }
Example #10
0
 /**
  * Call the parent constructor
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->theme->setTheme();
     // defaults
     $this->user = new User();
 }
Example #11
0
 public function __construct($action, $urlValues)
 {
     parent::__construct($action, $urlValues);
     //create the model object
     require "models/home.php";
     $this->model = new HomeModel();
 }
Example #12
0
 public function __construct()
 {
     parent::__construct();
     if (!BEUsersHelper::isAdmin()) {
         Redirect::to('/');
     }
 }
Example #13
0
 /**
  * FlightsController constructor.
  */
 public function __construct()
 {
     parent::__construct('Flight');
     /* Template & Navbar par default */
     $this->dsp->template = 'layouts.templates.manager';
     return true;
 }
Example #14
0
 public function __construct()
 {
     parent::__construct();
     \View::composer('*', function ($view) {
         $view->with('angular_template_base_path', '/angular/templates?tmp=');
     });
 }
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $date = date('Y-m-d');
     $number = 1;
     $last_migration = $this->getLastMigrationParsedId();
     if ($last_migration) {
         if ($date == $last_migration['date']) {
             $number = $last_migration['number'] + 1;
         }
     }
     $migration_filename = sprintf('%s-%s', $date, str_pad($number, 3, '0', STR_PAD_LEFT));
     $words = $this->app->parameters['_words_'];
     $name = false;
     if (isset($words[2])) {
         $name = $words[2];
     }
     if ($name !== false) {
         $name = preg_replace('/[^\\w]/', '-', $name);
         $migration_filename .= '-' . $name;
     }
     $migration_filename .= '.' . $this->app->parameters['migration-file-extention'];
     $migration_fullname = $this->app->parameters['pwd'] . $this->app->parameters['migrations'][0] . $migration_filename;
     if (file_put_contents($migration_fullname, '') !== false) {
         echo "Created empty migration file {$migration_filename}\n";
     } else {
         throw new \Exception('Can\'t create new migration file');
     }
 }
Example #16
0
 public function common()
 {
     // Get the generic stuff from parent
     parent::common();
     // Add my own things
     $this->view->headTitle($this->getPageTitle());
 }
 public function __construct(Registry $registry)
 {
     parent::__construct($registry, 'A_Publishers');
     $this->_template->publisherTitles = ['Publishers', 'New Publisher', 'Publisher Details', 'Update Publisher'];
     if (isset($this->_urlBits[1]) && $this->_urlBits[1] == 'publishers') {
         if (isset($this->_urlBits[2]) && $this->_urlBits[2] == 'create') {
             $this->createNewPublisher();
         } elseif (isset($this->_urlBits[2]) && isset($this->_urlBits[3])) {
             $publisherId = filter_var($this->_urlBits[3], FILTER_VALIDATE_INT);
             switch ($this->_urlBits[2]) {
                 case 'view':
                     $this->viewPublisher($publisherId);
                     break;
                 case 'update':
                     $this->updatePublisher($publisherId);
                     break;
                 default:
                     $this->showAuthors();
                     break;
             }
         } else {
             $this->showPublishers();
         }
     } else {
         $this->_registry->redirectTo();
     }
 }
Example #18
0
 public function beforeAction($action)
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect('/');
     }
     return parent::beforeAction($action);
 }
Example #19
0
 public function __construct(ImageTransformer $transformer, PaginatorTransformer $paginatorTransformer)
 {
     parent::__construct();
     $this->transformer = $transformer;
     $this->paginatorTransformer = $paginatorTransformer;
     $this->validateOwnership(new Image());
 }
Example #20
0
 private function _initialize()
 {
     //初始化设置
     @ini_set('memory_limit', '64M');
     @ini_set('session.cache_expire', 180);
     @ini_set('session.use_cookies', 1);
     @ini_set('session.auto_start', 0);
     @ini_set('display_errors', 1);
     @ini_set("arg_separator.output", "&");
     @ini_set('include_path', '.;' . BASE_PATH);
     //加载系统常量和函数库
     require BASE_PATH . 'base/constant.php';
     require BASE_PATH . 'base/function.php';
     //对用户传入的变量进行转义操作
     if (!get_magic_quotes_gpc()) {
         if (!empty($_GET)) {
             $_GET = addslashes_deep($_GET);
         }
         if (!empty($_POST)) {
             $_POST = addslashes_deep($_POST);
         }
         $_COOKIE = addslashes_deep($_COOKIE);
         $_REQUEST = addslashes_deep($_REQUEST);
     }
     //创建 ECSHOP 对象
     self::$ecs = new EcsEcshop(C('DB_NAME'), C('DB_PREFIX'));
     //初始化数据库类
     self::$db = new EcsMysql(C('DB_HOST'), C('DB_USER'), C('DB_PWD'), C('DB_NAME'));
     //创建错误处理对象
     self::$err = new EcsError('message.dwt');
     //载入系统参数
     C('CFG', model('Base')->load_config());
 }
Example #21
0
 function onBefore()
 {
     parent::onBefore();
     $this->db = xn("db");
     $this->collection = xn("collection");
     $this->_mongodb = $this->_mongo->selectDB($this->db);
 }
 public static function index()
 {
     self::check_logged_in();
     $ryhmemos = Memo::all_groupmemos(BaseController::get_user_logged_in());
     $memos = Memo::all(BaseController::get_user_logged_in());
     View::make('memo/index.html', array('memos' => $memos, 'ryhmemos' => $ryhmemos));
 }
 public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo)
 {
     parent::__construct();
     $this->paymentRepo = $paymentRepo;
     $this->invoiceRepo = $invoiceRepo;
     $this->accountRepo = $accountRepo;
 }
Example #24
0
 function __construct()
 {
     parent::__construct();
     $this->data['layout'] = 'adminhtml';
     $this->data['header'] = 'Data Jurnal Mahasiswa';
     //$this->helper('Data');
 }
 public function __construct()
 {
     parent::__construct();
     $this->instagramModel = new \blogg\model\instagram\InstagramModel($this->settings->getInstagramSettings());
     $this->setView(new \blogg\view\instagram\InstagramView());
     $this->numberOfImages = $this->settings->getInstagramSettings()->numberOfImages;
 }
Example #26
0
 /**
  * Constructor
  */
 public function __construct(SettingInterface $settings, RegisterForm $registerForm)
 {
     parent::__construct();
     $this->settings = $settings;
     $this->registerForm = $registerForm;
     $this->beforeFilter('checkInstalled', ['only' => ['store', 'index']]);
 }
 public function __construct($request, $response) 
 {/*{{{*/
     parent::__construct($request, $response);
     $hospitalId = $request->partnerConfig->hospitalId;
     $hospital = DAL::get()->find('hospital', $hospitalId);
     $response->hospital = $hospital;
 }/*}}}*/
Example #28
0
 public function postContent($type_id, $id = 'add')
 {
     $all = Input::all();
     if (!$all['slug']) {
         $all['slug'] = BaseController::ru2Lat($all['title']);
     }
     $rules = array('name' => 'required|min:2|max:255', 'title' => 'required|min:3|max:255', 'slug' => 'required|min:4|max:255|alpha_dash');
     $validator = Validator::make($all, $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/content/' . $type_id . '/' . $id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
     }
     if (is_numeric($id)) {
         $post = Post::find($id);
     } else {
         $post = new Post();
     }
     $post->type_id = $all['type_id'];
     $post->name = $all['name'];
     $post->title = $all['title'];
     $post->slug = $all['slug'];
     $post->text = $all['text'];
     $post->parent = $all['parent'];
     $post->status = isset($all['status']) ? true : false;
     $post->order = $all['order'];
     $post->description = $all['description'];
     $post->keywords = $all['keywords'];
     if (isset($all['image'])) {
         $post->image = AdminController::saveImage($all['image'], 'upload/image/', 250);
     }
     $post->save();
     return Redirect::to('/admin/content/' . $all['type_id'] . '/' . $id)->with('success', 'Изменения сохранены');
 }
 public function __construct()
 {
     parent::__construct();
     $this->forgetBeforeFilter('maintenance');
     $this->theme = \Theme::type('admincp')->current(\ThemeManager::getActive('admincp'))->reBoot()->layout('layouts.default');
     $this->activePage('dashboard');
 }
Example #30
0
 public function __construct(AccountRepository $accountRepo, ContactMailer $contactMailer, UserMailer $userMailer)
 {
     parent::__construct();
     $this->accountRepo = $accountRepo;
     $this->contactMailer = $contactMailer;
     $this->userMailer = $userMailer;
 }