private function _setLanguage()
 {
     $session_lang = $this->Session->read('lang') ? $this->Session->read('lang') : null;
     if ($session_lang == null) {
         $session_lang = Configure::read('DEF_LANG');
         Configure::load('rus_config');
     } else {
         if (!in_array($session_lang, Configure::read('VALID_LANGS'))) {
             $session_lang = Configure::read('DEF_LANG');
             Configure::load('rus_config');
         }
     }
     $this->Session->write('lang', $session_lang);
     $c = 0;
     foreach (Configure::read('VALID_LANGS') as $lang) {
         if ($lang == $session_lang) {
             $key = $c;
         }
         $c++;
     }
     $locale = Configure::read('VALID_LANG_LOCALES')[$key];
     //запись в конфиг локали
     Configure::write('Config.language', $locale);
     Configure::load($locale . '_config');
     $this->Session->write('lang_locale', $locale);
     $lang_prefix = 'name_' . lang_prefix();
     $this->set('lang_prefix', $lang_prefix);
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     Configure::config('configini', new IniReader());
     Configure::load('config.ini', 'configini');
     /*
      * "Auth" logic
      * Generate and test the security key
      */
     $api = json_decode($this->Setting->getOption('api'));
     if (empty($api) || empty($api->enabled) || !$api->enabled) {
         return $this->api401(__('API is disabled'));
     }
     // No key, refuse connexion
     if (empty($this->request->params['named']) || empty($this->request->params['named']['key'])) {
         return $this->api401(__('Security key is missing'));
     }
     // Get the key and remote it from the params
     $theirSecurityKey = $this->request->params['named']['key'];
     unset($this->request->params['named']['key']);
     // generate the security key
     $paramsUrl = '/' . $this->request->params['controller'] . '/' . $this->request->params['action'];
     $paramsUrl .= $this->Tools->paramsToUrl($this->request->params['named']);
     $securityKey = hash_hmac('sha1', $paramsUrl, $api->privateKey);
     if ($theirSecurityKey != $securityKey) {
         return $this->api401(__('Wrong security key'));
     }
 }
Beispiel #3
0
 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $this->_loadModels();
     $x = App::objects('Queue.Task');
     //'Console/Command/Task'
     //$x = App::path('Task', 'Queue');
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $this->tasks = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
     }
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     //Config can be overwritten via local app config.
     Configure::load('Queue.queue');
     $conf = (array) Configure::read('Queue');
     //merge with default configuration vars.
     Configure::write('Queue', array_merge(['maxruntime' => DAY, 'cleanuptimeout' => MONTH], $conf));
 }
Beispiel #4
0
 function HfacebookHelper()
 {
     Configure::load('facebook');
     $this->appId = Configure::read('facebook.appId');
     $this->apiKey = Configure::read('facebook.apiKey');
     $this->apiSecret = Configure::read('facebook.apiSecret');
 }
Beispiel #5
0
 function subjects()
 {
     $user = $this->Session->read("Auth.User");
     Configure::load('feedback');
     //load the max_sub_num variable
     //$subjects=$this->Subject->query("SELECT * FROM subjects WHERE class = '".$user['class']."'  AND id NOT IN ( SELECT subject_id FROM subject_memberships WHERE student_id = ".$user['id']." AND form_a_submitted = ".Configure::read('max_sub_num').")");//To get the subject names correctly
     $teacher1 = null;
     //set to stop errors
     $teacher2 = null;
     $subjects = $this->Subject->query("SELECT * FROM subjects where id IN ( SELECT subject_id FROM subject_memberships WHERE student_id =" . $user['id'] . ")");
     $submitted = $this->Subject->query("SELECT max(`submission_number`) as subnum FROM form_a_records WHERE student=" . $user['id']);
     //$teacher2 = null;no more teacher2
     //to get teacher names
     if (empty($subjects)) {
         $this->Session->setFlash("You don't need to submit any feedback right now", 'default', array('class' => 'message info'));
     }
     //             if(empty($allSubjects)){
     //             	$this->Session->setFlash("don't need to submit any feedback right now", 'default',array('class'=>'message info'));
     //             }
     for ($i = 0; $i < count($subjects); $i++) {
         $t1 = $subjects[$i]["subjects"]["teacher1"];
         $teacher1[$i] = $this->Subject->query("SELECT name from users where id= {$t1}");
         /*$t2=$subjects[$i]["subjects"]["teacher2"];
           $teacher2[$i]=($t2==NULL)?NULL:$this->Subject->query("SELECT name from users where id= $t2");no more teacher2*/
     }
     $this->set('submitted', $submitted);
     // $this->set('allSubjects',$allSubjects);
     $this->set('subjects', $subjects);
     $this->set('teacher1', $teacher1);
     $this->set('max_sub_num', Configure::read('max_sub_num'));
     // $this->set('teacher2',$teacher2);
     //$this->set('teacher2',$teacher2);no more teacher2
 }
 protected function loadTwitter()
 {
     if (isset($this->Twitter)) {
         if ($this->Twitter) {
             return $this->Twitter;
         }
     }
     if (!class_exists('Endroid\\Twitter\\Twitter')) {
         App::uses('endroid/twitter/src/endroid/twitter', 'Vendor');
     }
     if (!class_exists('Endroid\\Twitter\\Twitter')) {
         return false;
     }
     if (!is_file(APP . DS . 'Config' . DS . 'twitter.php')) {
         return false;
     }
     if (!Configure::load('twitter')) {
         return false;
     }
     if (!Configure::check('Twitter')) {
         return false;
     }
     $settings = Configure::read('Twitter');
     if (empty($settings)) {
         return false;
     }
     extract($settings);
     $this->controller->Twitter = new Endroid\Twitter\Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
     return $this->controller->Twitter ?: !$this->log(array("InitializeComponent->twitter" => array('request->here' => $this->controller->request->here, 'request->params' => $this->controller->request->params) + compact('settings')), 'debug');
 }
Beispiel #7
0
 public function beforeFilter()
 {
     $this->Cookie->httpOnly = true;
     /*Configure Path*/
     App::build(array('Model' => array(CAKE_CORE_INCLUDE_PATH . '/Model/Base/', CAKE_CORE_INCLUDE_PATH . '/Model/', APP_DIR . '/Model/', CAKE_CORE_INCLUDE_PATH . '/Model/Form/'), 'Lib' => array(CAKE_CORE_INCLUDE_PATH . '/Lib/'), 'Vendor' => array(CAKE_CORE_INCLUDE_PATH . '/Vendor/')));
     /*Autoload Model*/
     App::import('Model', array('CommonTable'));
     /*Autoload Lib*/
     App::uses('myTools', 'Lib');
     App::uses('myMailer', 'Lib');
     App::uses('myError', 'Lib');
     /*Autoload table class*/
     spl_autoload_register(function ($class) {
         $classFile1 = CAKE_CORE_INCLUDE_PATH . '/Model/' . $class . '.php';
         $classFile2 = CAKE_CORE_INCLUDE_PATH . '/Model/Form/' . $class . '.php';
         if (is_file($classFile1)) {
             require_once $classFile1;
         }
         if (is_file($classFile2)) {
             require_once $classFile2;
         }
     });
     /*Autoload Lib*/
     Configure::load('my');
     Configure::load('const');
 }
 /**
  * Controller construct (loads config file)
  * 
  * @return null
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     Configure::load('Twitter.twitter', 'default', false);
     $this->consumerKey = Configure::read('Twitter.consumerKey');
     $this->consumerSecret = Configure::read('Twitter.consumerSecret');
 }
Beispiel #9
0
 function beforeFilter()
 {
     Configure::load('vars');
     /*
     
      if ( !isset($this->params['lang']) && !$this->Session->check('langSes') ) {
     
      $this->params['lang'] = $defaultLang;
      $this->Session->write('langSes',$defaultLang);
     
      } elseif ( !isset($this->params['lang']) && $this->Session->check('langSes') ) {
      $this->params['lang'] = $this->Session->read('langSes');
      }
     
      Configure::write('Config.language', $this->params['lang']);
      $this->Session->write('langSes',$this->params['lang']);
     */
     if (isset($this->Auth)) {
         if ($this->viewPath == 'pages' && $this->params['action'] != 'admin_index') {
             $this->Auth->allow('*');
         } else {
             $this->Auth->authorize = 'controller';
             if (in_array(low($this->params['controller']), $this->publicControllers)) {
                 //$this->Auth->allow('*');
                 $this->Auth->deny('pages/admin_index');
             }
         }
         //$this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
     }
 }
Beispiel #10
0
 public function initialize(&$controller, $settings = array())
 {
     $this->controller = $controller;
     //do not care pre defined ajax action
     if (0 === strpos($controller->params['action'], 'ajax_')) {
         return;
     }
     Configure::load('redirectacl');
     $acl = Configure::read('redirectacl');
     //spider
     if (!$this->controller->UaAcl->check($acl['spider'])) {
         $this->controller->spider = true;
         //this is a cheat for spider to access default page when spider visit '/'
         if ('forum' === $controller->params['controller'] && 'front' === $controller->params['action']) {
             $controller->params['action'] = 'index';
         }
         return;
     }
     //normal
     $r = $this->isRedirect();
     $ajax = $controller->RequestHandler->isAjax();
     //should redirect but no ajax,go front
     if ($r && !$ajax) {
         $this->front();
     }
     //should not redirect but stop,
     if (!$r && $ajax) {
         $controller->_stop();
     }
 }
Beispiel #11
0
 function allclients()
 {
     if (!empty($this->data)) {
         if ($this->Mail->save($this->data)) {
             $this->loadModel('Client');
             $emailsofclients = $this->Client->find('list', array('fields' => array('email'), 'conditions' => array('Client.visible >' => 0)));
             $nbr_sent = $nbr_unsent = $nbr_client = 0;
             foreach ($emailsofclients as $emailofclient) {
                 if (!empty($emailofclient)) {
                     Configure::load('email');
                     $this->Email->from = Configure::read('Email.senderName') . ' <' . Configure::read('Email.senderEmail') . '>';
                     $this->Email->to = $emailofclient;
                     $this->Email->subject = $this->data['Mail']['subject'];
                     $this->Email->send($this->data['Mail']['textarea']);
                     $nbr_sent++;
                     $this->Email->reset();
                 } else {
                     $nbr_unsent++;
                 }
                 $nbr_client++;
             }
             $this->flash($nbr_sent . ' emails ont &eacute;t&eacute; envoy&eacute;s (soit ' . $nbr_sent . '/' . $nbr_client . ' clients)', $this->Session->read('App.redirect_to'));
         }
     }
 }
 /**
  * Loads HttpSocket class
  *
  * @param array $config
  * @param HttpSocket $Http
  */
 public function __construct($config, $Http = null)
 {
     if (!isset($this->config['database'])) {
         $this->config['database'] = '';
     }
     // Store the API configuration map
     $name = pluginSplit($config['datasource']);
     if (!($this->map = Configure::read('Apis.' . $name[1]))) {
         Configure::load($name[0] . '.' . $name[1]);
         $this->map = Configure::read('Apis.' . $name[1]);
     }
     // Store the HttpSocket reference
     if (!$Http) {
         if (!empty($this->map['oauth']['version'])) {
             if ($this->map['oauth']['version'][0] == 2) {
                 $config['method'] = 'OAuthV2';
             } else {
                 $config['method'] = 'OAuth';
             }
             App::uses('HttpSocketOauth', 'HttpSocketOauth.Lib');
             $Http = new HttpSocketOauth();
         } else {
             App::uses('HttpSocket', 'Network/Http');
             $Http = new HttpSocket();
         }
     }
     $this->Http = $Http;
     parent::__construct($config);
 }
 function initialize(&$controller)
 {
     $this->__controller =& $controller;
     $this->settingsFile = ROOT . DS . APP_DIR . DS . 'config' . DS . 'settings.php';
     Configure::load($this->_settingsName);
     $this->_settings = Configure::read($this->_settingsName);
 }
 protected function _load_app_config()
 {
     /* Carga project/Config/Sistema/config.php */
     Configure::load('App/config');
     $this->config = Configure::read('app');
     $this->set('config', $this->config);
 }
Beispiel #15
0
 public function show($theme = null, $errors = true, $ssl = true)
 {
     if (!in_array($theme, array('red', 'white', 'blackglass', 'clean'))) {
         $theme = $this->defaultTheme;
     }
     if ($this->secure === true) {
         $server = self::API_SECURE_SERVER;
     } else {
         $server = self::API_SERVER;
     }
     Configure::load('Recaptcha.key');
     $publicKey = Configure::read('Recaptcha.Public');
     if (empty($publicKey) && !is_int($publicKey)) {
         throw new InvalidArgumentException('To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create');
     }
     $publicKey = rawurlencode($publicKey);
     $html = $this->Html->scriptBlock(sprintf('var RecaptchaOptions = {theme:"%s"};', $theme));
     $scriptUrl = sprintf('%s/challenge?k=%s', $server, $publicKey);
     $noScriptUrl = sprintf('%s/noscript?k=%s', $server, $publicKey);
     $html .= $this->Html->script($scriptUrl);
     $html .= $this->Html->tag('noscript', $this->Html->tag('iframe', null, array('src' => $noScriptUrl)) . $this->Html->tag('br') . $this->Form->textarea('recaptcha_challenge_field') . $this->Form->hidden('recaptcha_response_field', array('value' => 'manual_challenge')));
     if ($errors == true) {
         $html .= $this->error();
     }
     return $html;
 }
 function add()
 {
     $param = $this->params['pass'];
     if (!empty($this->data)) {
         $this->FormARecord->create();
         $param = $this->Session->read("params");
         $this->data['FormARecord']['subject_id'] = $param['subject_id'];
         $this->data['FormARecord']['teacher'] = $param['teacher'];
         $this->data['FormARecord']['student'] = $param['student'];
         $this->data['FormARecord']['submission_number'] = $param['sub_num'];
         if ($this->FormARecord->save($this->data)) {
             $this->Session->setFlash(__('Your feedback has been saved', true), 'default', array('class' => 'message warning'));
             $this->redirect(array('controller' => 'pages', 'action' => 'success'));
         } else {
             $this->Session->setFlash(__('Your feedback could not be saved. Please, try again.', true));
         }
     } else {
         $params['subject_id'] = $param[0];
         $params['teacher'] = $param[1];
         $params['student'] = $this->Session->read("Auth.User.id");
         Configure::load('feedback');
         $params['sub_num'] = Configure::read('max_sub_num');
         //set sub_num to next submission_number value
         $this->Session->write('params', $params);
     }
 }
Beispiel #17
0
 public function initialize(&$controller, $settings = array())
 {
     $this->controller = $controller;
     if (Configure::read("ipacl.on")) {
         Configure::load("ipacl");
         $this->_active = true;
     }
 }
 /**
  * Set the default datasource to the read setup in config
  *
  * {@inheritDoc}
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     if (Configure::load('database_log')) {
         $this->configs = Configure::read('DatabaseLog');
     }
     parent::__construct($id, $table, $ds);
     $this->setDataSourceRead();
 }
 public function index()
 {
     //load engines config
     Configure::load('engines', 'cloggy');
     $engines = Configure::read('Cloggy.CloggySearch.engines');
     $this->set(compact('engines'));
     $this->set('title_for_layout', __d('cloggy', 'Cloggy - Cloggy Search Management'));
 }
 function checkRecaptcha(&$model, $data, $target)
 {
     App::import('Vendor', 'RecaptchaPlugin.recaptchalib');
     Configure::load('RecaptchaPlugin.key');
     $privatekey = Configure::read('Recaptcha.Private');
     $res = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'], $model->data[$model->alias][$target], $data['recaptcha_response_field']);
     return $res->is_valid;
 }
 function __construct()
 {
     parent::__construct();
     Configure::load('vbulletin');
     $this->config = Configure::read('vb');
     $this->dbprefix = $this->config['db_prefix'];
     $this->user_columns = $this->config['user_columns'];
 }
 function beforeFilter()
 {
     if (isset($this->params['url']['shop'])) {
         parent::beforefilter();
     } else {
         Configure::load('shopify');
         $this->initLanguage();
     }
 }
Beispiel #23
0
 /**
  * Initialize shell
  */
 function initialize()
 {
     parent::initialize();
     if (Configure::load('cron_mailer') !== false) {
         $this->settings = array_merge($this->settings, Configure::read('CronMailer'));
     }
     App::import('Component', 'CronMailer.CronMailer');
     $this->CronMailer =& new CronMailerComponent();
 }
Beispiel #24
0
 function _set_defaults()
 {
     //Defaults are set in app/config/wysiwygpro.php
     if ($this->defaults == null) {
         $this->special_settings = Set::normalize($this->special_settings);
         Configure::load('wysiwygpro');
         $this->defaults = Configure::read('Wysiwygpro');
     }
 }
 private static function configureCloudinary()
 {
     try {
         Configure::load('CloudinaryPrivate');
         \Cloudinary::config(Configure::read('cloudinary'));
     } catch (Exception $e) {
         CakeLog::notice("Couldn't find Config/CloudinaryPrivate.php file");
     }
 }
Beispiel #26
0
 /**
  * Startup component
  *
  * @param object $controller Instantiating controller
  * @access public
  */
 function startup(&$controller)
 {
     $this->Controller =& $controller;
     mb_language('Japanese');
     // 設定読み出し
     Configure::load('email');
     $this->params = Configure::read('Email');
     $this->load($this->Controller->name);
 }
Beispiel #27
0
 /**
  * Constructor, initiallizes the FileUpload Component
  * and sets the default options.
  */
 function __construct(View $View, $settings = array())
 {
     if (!Configure::load('file_upload')) {
         trigger_error('Config' . DS . 'file_upload.php not found. Please copy Icing' . DS . 'Config' . DS . 'file_upload.php.default for example setings', E_WARNING);
     }
     $FileUploadSettings = Configure::read('FileUpload');
     //setup settings
     $this->settings = array_merge($FileUploadSettings, $this->options);
     return parent::__construct($View, $settings);
 }
 function index()
 {
     // force 404 if not in maintenance mode
     if (Configure::load('maintenance.settings') && !Configure::read('Server.maintenance')) {
         $this->cakeError('error404');
     }
     Configure::write('debug', 0);
     $this->header('HTTP/1.1 503 Service Temporarily Unavailable');
     $this->header('Retry-After: ' . 3600);
 }
 function beforeRender()
 {
     if (!empty($this->breakcrumb)) {
         $this->set("breakcrumb", $this->breakcrumb);
     }
     // populate active options
     Configure::load("common");
     $this->active_options = Configure::read('active_options');
     $this->set("active_options", $this->active_options);
 }
Beispiel #30
0
 /**
  * Overridden method so the heading message stops getting spit out
  *
  * @return void
  * @author Dean Sofer
  */
 function _welcome()
 {
     Configure::load('BakingPlate.submodules');
     $this->submodules = Configure::read('BakingPlate');
     Configure::load('BakingPlate.version');
     $this->Dispatch->clear();
     $this->out("\nWelcome to BakingPlate v" . Configure::read('BakingPlate.version'));
     $this->hr();
     $this->_prepGroup();
 }