예제 #1
0
 public static function render($params = [])
 {
     isset($_POST['idStructure']) ? $idStructure = $_POST['idStructure'] : ($idStructure = '');
     isset($_POST['structure']) ? $structure = $_POST['structure'] : ($structure = '');
     isset($_POST['translationToC']) ? $translationToC = $_POST['translationToC'] : ($translationToC = '');
     isset($_POST['translationToJava']) ? $translationToJava = $_POST['translationToJava'] : ($translationToJava = '');
     isset($_POST['translationToJavascript']) ? $translationToJavascript = $_POST['translationToJavascript'] : ($translationToJavascript = '');
     isset($_POST['translationToPython']) ? $translationToPython = $_POST['translationToPython'] : ($translationToPython = '');
     isset($_POST['translationToPhp']) ? $translationToPhp = $_POST['translationToPhp'] : ($translationToPhp = '');
     isset($_POST['pseudoCodeToTest']) ? $pseudoCodeToTest = $_POST['pseudoCodeToTest'] : ($pseudoCodeToTest = '');
     isset($_POST['test']) ? $hadToTranslate = true : ($hadToTranslate = false);
     $user = AppController::getUser();
     if (!$user) {
         AppController::setMsg("warning", "Vous devez être connecté pour avoir accès à cette partie du site");
         AppController::redirect('index');
     }
     if (isset($_POST['erase'])) {
         unset($_POST['erase']);
         self::erase();
         die;
     }
     if (isset($_POST['save'])) {
         unset($_POST['save']);
         self::save(['idStructure' => $idStructure]);
         die;
     }
     parent::render(['idStructure' => $idStructure, 'structure' => $structure, 'pseudoCodeToTest' => $pseudoCodeToTest, 'translationToC' => $translationToC, 'translationToJava' => $translationToJava, 'translationToJavascript' => $translationToJavascript, 'translationToPhp' => $translationToPhp, 'translationToPython' => $translationToPython, 'hadToTranslate' => $hadToTranslate]);
 }
예제 #2
0
 /**
  * リダイレクト処理を行う
  * @param string $type	$this->redirectUrlのキーまたはURLを指定する
  * @param string $flashMessage リダイレクト先で表示したいメッセージ
  * @param boolean $forceRedirect 強制リダイレクトフラグ
  * @access private
  */
 function _redirect($type, $flashMessage = null, $forceRedirect = false)
 {
     $redirectFlag = $this->redirect;
     if ($redirectFlag === false && $forceRedirect === true) {
         $redirectFlag = true;
     }
     if ($redirectFlag) {
         $url = $type;
         if (isset($this->redirectUrl[$type])) {
             $url = $this->redirectUrl[$type];
             if (is_null($url)) {
                 return null;
             }
         }
         if (!is_null($flashMessage)) {
             $this->Session->setFlash($flashMessage);
         }
         $this->_controller->redirect($url);
     }
     if ($forceRedirect) {
         if (!is_null($flashMessage)) {
             $this->Session->setFlash($flashMessage);
         }
         $this->_controller->redirect($type);
     }
 }
예제 #3
0
 /**
  * Fonction de rendu par défaut
  * @param type $params
  */
 public static function render($params = [])
 {
     $user = AppController::getUser();
     if (!$user) {
         AppController::setMsg("warning", "Vous devez être connecté pour avoir accès à cette zone.");
         AppController::redirect("index");
     }
     if (isset($_POST['action'])) {
         self::update();
         $user = AppController::getUser();
     }
     parent::render(['id' => $user->getId(), 'name' => $user->getName(), 'email' => $user->getEmail(), 'avatar' => $user->getAvatar()]);
 }
예제 #4
0
 /**
  * コンストラクタ
  *
  * @return	void
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     $db = ConnectionManager::getDataSource('baser');
     if (isset($db->config['datasource'])) {
         if ($db->config['datasource'] != '') {
             parent::__construct($id, $table, $ds);
         } elseif ($db->config['login'] == 'dummy' && $db->config['password'] == 'dummy' && $db->config['database'] == 'dummy' && Configure::read('BcRequest.pureUrl') == '') {
             // データベース設定がインストール段階の状態でトップページへのアクセスの場合、
             // 初期化ページにリダイレクトする
             $AppController = new AppController();
             session_start();
             $_SESSION['Message']['flash'] = array('message' => 'インストールに失敗している可能性があります。<br />インストールを最初からやり直すにはbaserCMSを初期化してください。', 'layout' => 'default');
             $AppController->redirect(BC_BASE_URL . 'installations/reset');
         }
     }
 }
예제 #5
0
 public static function render($params = [])
 {
     $user = AppController::getUser();
     if (!$user) {
         AppController::setMsg('warning', "La zone demandée n'est pas autorisé pour les personnes non inscrites.");
         AppController::redirect('index');
     }
     $algorithms = \Root\Src\Model\AlgorithmModel::loadFunctionByUser($user->getId());
     $structures = \Root\Src\Model\StructureModel::loadStructureByUser($user->getId());
     $translationOfC = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('c');
     $translationOfJava = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('java');
     $translationOfJavascript = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('javascript');
     $translationOfPhp = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('php');
     $translationOfPython = \Root\Src\Model\TranslationModel::loadTranslationByLanguage('python');
     parent::getHeader();
     self::call('Render', ['algorithms' => $algorithms, 'structures' => $structures, 'translations' => ['c' => $translationOfC, 'java' => $translationOfJava, 'javascript' => $translationOfJavascript, 'php' => $translationOfPhp, 'python' => $translationOfPython]]);
     parent::getFooter();
 }
예제 #6
0
 /**
  * redirect Twitter authorize page
  *
  * @see Twitter-API-Plugin TwitterAuthComponent::connect()
  */
 public function connect()
 {
     $dataSource = $authorize = false;
     if (!empty($this->controller->params['named']['datasource'])) {
         $dataSource = $this->controller->params['named']['datasource'];
     }
     if (!empty($this->controller->params['named']['authorize'])) {
         $authorize = $this->controller->params['named']['authorize'];
     }
     if ($dataSource !== false) {
         $this->setTwitterSource($dataSource);
     }
     if ($authorize) {
         $this->controller->redirect($this->getAuthorizeUrl());
     } else {
         $this->controller->redirect($this->getAuthenticateUrl());
     }
 }
예제 #7
0
 /**
  * コンストラクタ
  *
  * @return	void
  * @access	private
  */
 function __construct($id = false, $table = null, $ds = null)
 {
     if ($this->useDbConfig && ($this->name || !empty($id['name']))) {
         // DBの設定がない場合、存在しないURLをリクエストすると、エラーが繰り返されてしまい
         // Cakeの正常なエラーページが表示されないので、設定がある場合のみ親のコンストラクタを呼び出す。
         $cm =& ConnectionManager::getInstance();
         if (isset($cm->config->baser['driver'])) {
             if ($cm->config->baser['driver'] != '') {
                 parent::__construct($id, $table, $ds);
             } elseif ($cm->config->baser['login'] == 'dummy' && $cm->config->baser['password'] == 'dummy' && $cm->config->baser['database'] == 'dummy' && Configure::read('Baser.urlParam') == '') {
                 // データベース設定がインストール段階の状態でトップページへのアクセスの場合、
                 // 初期化ページにリダイレクトする
                 App::import('Controller', 'App');
                 $AppController = new AppController();
                 session_start();
                 $_SESSION['Message']['flash'] = array('message' => 'インストールに失敗している可能性があります。<br />インストールを最初からやり直すにはbaserCMSを初期化してください。', 'layout' => 'default');
                 $AppController->redirect(baseUrl() . 'installations/reset');
             }
         }
     }
 }
예제 #8
0
 /**
  * コンストラクタ
  *
  * @return	void
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     $db = ConnectionManager::getDataSource('default');
     $request = new CakeRequest();
     if (isset($db->config['datasource'])) {
         if ($db->config['datasource'] != '') {
             // @deprecated 5.0.0 since 4.0.0
             if ($this->useDbConfig == 'plugin') {
                 $this->useDbConfig = 'default';
                 $this->log('モデル:' . $this->name . ' BcPluginAppModelの 継承は、バージョン 4.0.0 より非推奨となりました。バージョン 5.0.0 で BcPluginAppModel は削除される予定です。プラグインは AppModel を直接継承してください。', LOG_ALERT);
             }
             parent::__construct($id, $table, $ds);
         } elseif ($db->config['login'] == 'dummy' && $db->config['password'] == 'dummy' && $db->config['database'] == 'dummy' && $request->url === false) {
             // データベース設定がインストール段階の状態でトップページへのアクセスの場合、
             // 初期化ページにリダイレクトする
             $AppController = new AppController();
             session_start();
             $_SESSION['Message']['flash'] = ['message' => 'インストールに失敗している可能性があります。<br />インストールを最初からやり直すにはbaserCMSを初期化してください。', 'layout' => 'default'];
             $AppController->redirect(BC_BASE_URL . 'installations/reset');
         }
     }
 }
예제 #9
0
 /**
  * Methode de connexion
  */
 public static function connect()
 {
     if (AppController::getUser() != Null) {
         AppController::setMsg("warning", "Vous êtes déjà connecté. Veuillez vous déconnecter pour changer de compte.");
     } else {
         $login = '';
         $password = '';
         if (isset($_POST['login']) && isset($_POST['password'])) {
             $login = $_POST['login'];
             $password = $_POST['password'];
         }
         $user = new \Root\Src\Model\UserModel($login, $password);
         $user = $user->exist();
         if ($user) {
             AppController::setUser($user);
             AppController::setMsg("success", "Vous avez bien été connecté.");
             parent::redirect('index');
         } else {
             AppController::setMsg("warning", "Le mot de passe ou l'identifiant est incorrect.");
             self::render();
         }
     }
 }
예제 #10
0
 /**
  * Override the redirect function; if it's a view and there's only one division, view the league instead
  */
 function redirect($url = null, $next = null)
 {
     if (isset($url['action']) && $url['action'] == 'view' && isset($url['controller']) && $url['controller'] == 'divisions') {
         $league = $this->Division->league($url['division']);
         $division_count = $this->requestAction(array('controller' => 'leagues', 'action' => 'division_count'), array('named' => compact('league')));
         if ($division_count == 1) {
             parent::redirect(array('controller' => 'leagues', 'action' => $url['action'], 'league' => $league), $next);
         }
     }
     parent::redirect($url, $next);
 }
예제 #11
0
 public function resetPassword()
 {
     $this->view = new HTMLView();
     if ($this->request->isPOST()) {
         $post = $this->request->postData();
         $user = new UserModel();
         if ($this->request->isQueryArgSet('token')) {
             if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
                 $user->password = @$post['password'];
                 if ($user->save()) {
                     $user->deletePasswordResetTokens();
                     $alert = new Alert(Alert::SUCCESS);
                     $alert->addMessage('Password Set, Please Login');
                 } else {
                     $alert = new Alert(Alert::ERROR);
                     $alert->addMessageArray($user->getErrors());
                 }
                 $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             } else {
                 AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
             }
         } else {
             if ($post['email'] && $user->find($post['email'], 'email')) {
                 $token = $user->getPasswordResetTokenData();
                 if ($token['last_email_timestamp'] <= Carbon::now()->subMinutes(pow(2, $token['email_attempts']))) {
                     $user->incrementPasswordResetEmailCount();
                     $link = addQueryParams(RouteController::fqURL('resetPassword'), ['token' => $token['token']]);
                     // Send Email
                     $mailer = new Mailer();
                     $mailer->setSubject('Password Reset Token');
                     $mailer->addAddress($user->email);
                     $mailer->includeHTMLTemplate('email.reset-password', ['link' => $link]);
                     $mailer->send();
                     // errors handled within
                     // Show Message
                     $alert = new Alert(Alert::SUCCESS);
                     $alert->addMessage('Email Sent');
                 } else {
                     $alert = new Alert(Alert::ERROR);
                     $alert->addMessage('Too Many Attempts, Please Try Again Later');
                 }
                 $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             } else {
                 $alert = new Alert(Alert::ERROR);
                 $alert->addMessage('Email is Invalid/Non-Existent');
                 $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]);
             }
         }
     } else {
         if ($this->request->isQueryArgSet('token')) {
             $user = new UserModel();
             if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) {
                 $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name')]);
             } else {
                 AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']);
             }
         } else {
             if ($this->request->isQueryArgSet('status') && $this->request->queryArgValue('status') == 'token-expired') {
                 $alert = new Alert(Alert::ERROR);
                 $alert->addMessage('Token is Invalid/Expired, Please Request a New One');
             }
             $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => isset($alert) ? $alert : null]);
         }
     }
     $this->view->render(true);
 }
예제 #12
0
 public function redirect($url, $status = 302)
 {
     return parent::redirect(AutoxpRouter::url($url), $status);
 }
예제 #13
0
 /**
  * Overload Redirect.  Many actions are invoked via Xhr, most of these
  * require a list of current favorites to be returned.
  *
  * @param string $url
  * @param unknown $code
  * @param boolean $exit
  * @return void
  */
 public function redirect($url, $code = null, $exit = true)
 {
     if ($code == -999) {
         parent::redirect($url, null, $exit);
     }
     if (!empty($this->viewVars['authMessage']) && !empty($this->request->params['isJson'])) {
         $this->RequestHandler->renderAs($this, 'json');
         $this->set('message', $this->viewVars['authMessage']);
         $this->set('status', 'error');
         echo $this->render('add');
         $this->_stop();
     }
     if (!empty($this->request->params['isAjax']) || !empty($this->request->params['isJson'])) {
         return $this->setAction('short_list', $this->Favorite->model);
     } else {
         if (isset($this->viewVars['status']) && isset($this->viewVars['message'])) {
             $this->Session->setFlash($this->viewVars['message'], 'default', array(), $this->viewVars['status']);
         } elseif (!empty($this->viewVars['authMessage'])) {
             $this->Session->setFlash($this->viewVars['authMessage']);
         }
     }
     parent::redirect($url, $code, $exit);
 }
예제 #14
0
 /**
  * Override the redirect function; if it's a view and there's only one division, view the league instead
  */
 function redirect($url = null, $next = null)
 {
     if (is_array($url) && in_array($url['action'], array('edit', 'view')) && (!array_key_exists('controller', $url) || $url['controller'] == 'divisions')) {
         $league = $this->Division->league($url['division']);
         $division_count = $this->requestAction(array('controller' => 'leagues', 'action' => 'division_count'), array('named' => compact('league')));
         if ($division_count == 1) {
             parent::redirect(array('controller' => 'leagues', 'action' => $url['action'], 'league' => $league), $next);
         }
     }
     parent::redirect($url, $next);
 }
예제 #15
0
 function redirect($url, $status = null, $exit = true)
 {
     return parent::redirect($this->__redirect_url($url), $status, $exit);
 }
예제 #16
0
 /**
  * undocumented function
  *
  * @return void
  */
 function redirect($url = array(), $status = null, $exit = true)
 {
     if (is_array($url)) {
         if (!empty($this->params['project'])) {
             $url = array_merge(array('project' => $this->params['project']), $url);
         }
         if (!empty($this->params['fork'])) {
             $url = array_merge(array('fork' => $this->params['fork']), $url);
         }
         $username = null;
         if (!empty($this->params['project']) && empty($this->params['fork'])) {
             $url = array_merge(array('username' => $this->params['username']), $url);
         }
     }
     parent::redirect($url, $status, $exit);
 }
예제 #17
0
 private function getCustomer(UserModel $user)
 {
     // Redirect to Start... (not a customer)
     if (!$user->isStripeCustomer()) {
         AppController::redirect(RouteController::fqURL('subscription.manage'));
     }
     try {
         \Stripe\Stripe::setApiKey(AppConfig::getValue('stripe_secret_api_key'));
         // Attempt to Fetch Customer...
         $customer = \Stripe\Customer::retrieve($user->getStripeData()->customer_id);
         // Exisitng, Deleted?
         if ($customer->deleted) {
             $user->stripe_customer_id = null;
             $user->setStripeData(null);
             $user->save();
             // Redirect to Start...
             AppController::redirect(RouteController::fqURL('subscription.manage'));
         } else {
             return $customer;
         }
     } catch (\Stripe\Error\Card $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\InvalidRequest $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\Authentication $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\ApiConnection $exception) {
         $this->logStripeException($exception, $customer->id);
     } catch (\Stripe\Error\Base $exception) {
         $this->logStripeException($exception, $customer->id);
     }
 }
 function redirect($url, $status = null, $die = true)
 {
     if ($this->RequestHandler->isAjax()) {
         $data = $this->requestAction($url, array("return"));
         $this->set("data", $data);
         $this->viewPath = '_generic';
         $this->render('ajax_redirect');
     } else {
         parent::redirect($url, $status);
     }
     if ($die) {
         die;
     } else {
         return false;
     }
 }