/**
  * Setup the config based on either the Configure::read() values
  * or the PaypalIpnConfig in config/paypal_ipn_config.php
  *
  * Will attempt to read configuration in the following order:
  *   Configure::read('PaypalIpn')
  *   App::import() of config/paypal_ipn_config.php
  *   App::import() of plugin's config/paypal_ipn_config.php
  */
 function __construct()
 {
     $this->config = Configure::read('PaypalIpn');
     if (empty($this->config)) {
         $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
         if (!class_exists('PaypalIpnConfig')) {
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             // Import from paypal plugin configuration
             $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
         }
         if (!PHP5) {
             $config =& new PaypalIpnConfig();
         } else {
             $config = new PaypalIpnConfig();
         }
         $vars = get_object_vars($config);
         foreach ($vars as $property => $configuration) {
             if (strpos($property, 'encryption_') === 0) {
                 $name = substr($property, 11);
                 $this->encryption[$name] = $configuration;
             } else {
                 $this->config[$property] = $configuration;
             }
         }
     }
     parent::__construct();
 }
Example #2
0
 /**
  * Function which actially fetch the data from the database
  * @param object $options
  * @return nested array of menu nodes.
  */
 private function _fetch($options = array())
 {
     App::import('Model', 'Cakemenu.Menu');
     $menu = new Menu();
     if (isset($options['subtree'])) {
         $parent = true;
         if (isset($options['subtree']['parent'])) {
             $parent = $options['subtree']['parent'];
             unset($options['subtree']['parent']);
         }
         $subtree = $menu->find('first', array('conditions' => $options['subtree']));
         if ($subtree != false) {
             if ($parent == true) {
                 $conditions = array('Menu.lft >=' => $subtree['Menu']['lft'], 'Menu.rght <=' => $subtree['Menu']['rght']);
             } else {
                 $conditions = array('Menu.lft >' => $subtree['Menu']['lft'], 'Menu.rght <' => $subtree['Menu']['rght']);
             }
             if (isset($options['conditions'])) {
                 $options['conditions'] = am($options['conditions'], $conditions);
             } else {
                 $options['conditions'] = $conditions;
             }
         }
         unset($options['subtree']);
     }
     $nodes = $menu->find('threaded', am(array('order' => 'Menu.lft ASC'), $options));
     return $nodes;
 }
Example #3
0
 function uninstall()
 {
     App::import('Model', 'Module');
     $this->Module =& new Module();
     // Delete the module record
     $module = $this->Module->findByAlias('coupons');
     $this->Module->delete($module['Module']['id']);
     // Deletes the tables
     $uninstall_query = "DROP TABLE `module_coupons`;";
     $this->Module->execute($uninstall_query);
     // Delete any associated events.
     App::import('Model', 'Event');
     $this->Event =& new Event();
     $handlers = $this->Event->EventHandler->find('all', array('conditions' => array('EventHandler.originator' => 'CouponsModule')));
     foreach ($handlers as $value) {
         $this->Event->EventHandler->delete($value['EventHandler']['id']);
     }
     // Delete the core page
     App::import('Model', 'Content');
     $this->Content =& new Content();
     $core_page = $this->Content->find(array('Content.parent_id' => '-1', 'alias' => 'coupon-details'));
     $this->Content->delete($core_page['Content']['id'], true);
     $this->Session->setFlash(__('Module Uninstalled', true));
     $this->redirect('/modules/admin/');
 }
Example #4
0
 /**
  * initialize method
  *
  * Merge settings and set Config.language to a valid locale
  *
  * @return void
  * @access public
  */
 function initialize(&$Controller, $config = array())
 {
     App::import('Vendor', 'Mi.MiCache');
     $lang = MiCache::setting('Site.lang');
     if (!$lang) {
         if (!defined('DEFAULT_LANGUAGE')) {
             return;
         }
         $lang = DEFAULT_LANGUAGE;
     } elseif (!defined('DEFAULT_LANGUAGE')) {
         define('DEFAULT_LANGUAGE', $lang);
     }
     Configure::write('Config.language', $lang);
     App::import('Core', 'I18n');
     $I18n =& I18n::getInstance();
     $I18n->domain = 'default_' . $lang;
     $I18n->__lang = $lang;
     $I18n->l10n->get($lang);
     if (!empty($Controller->plugin)) {
         $config['plugins'][] = Inflector::underscore($Controller->plugin);
     }
     if (!empty($config['plugins'])) {
         $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']);
         $Inst = App::getInstance();
         foreach ($plugins as $path => $name) {
             $Inst->locales[] = $path . DS . 'locale' . DS;
         }
     }
 }
 /**
  * Configuration method.
  *
  * In addition to configuring the settings (see $__defaults above for settings explanation),
  * this function also loops through the installed plugins and 'registers' those that have a
  * PluginNameCallback class.
  *
  * @param object $controller    Controller object
  * @param array $settings       Component settings
  * @access public
  * @return void
  */
 public function initialize(&$controller, $settings = array())
 {
     $this->__controller =& $controller;
     $this->settings = array_merge($this->__defaults, $settings);
     if (empty($this->settings['priority'])) {
         $this->settings['priority'] = Configure::listobjects('plugin');
     } else {
         foreach (Configure::listobjects('plugin') as $plugin) {
             if (!in_array($plugin, $this->settings['priority'])) {
                 array_push($this->settings['priority'], $plugin);
             }
         }
     }
     foreach ($this->settings['priority'] as $plugin) {
         $file = Inflector::underscore($plugin) . '_callback';
         $className = $plugin . 'Callback';
         if (App::import('File', $className, true, array(APP . 'plugins' . DS . Inflector::underscore($plugin)), $file . '.php')) {
             if (class_exists($className)) {
                 $class = new $className();
                 ClassRegistry::addObject($className, $class);
                 $this->__registered[] = $className;
             }
         }
     }
     /**
      * Called before the controller's beforeFilter method.
      */
     $this->executeCallbacks('initialize');
 }
 function pick($layout_scheme)
 {
     App::import('Config', 'Typographer.' . $layout_scheme . '_config');
     $c_layout_scheme = Inflector::camelize($layout_scheme);
     //carrega os instrumentos e as configurações deste layout específico/
     $tools = Configure::read('Typographer.' . $c_layout_scheme . '.tools');
     $used_automatic_classes = Configure::read('Typographer.' . $c_layout_scheme . '.used_automatic_classes');
     foreach ($this->controller->helpers as $helper => $params) {
         if (is_array($params)) {
             if (isset($params['receive_tools'])) {
                 $this->controller->helpers[$helper]['tools'] = $tools;
                 unset($params['receive_tools']);
             }
             if (isset($params['receive_automatic_classes'])) {
                 $this->controller->helpers[$helper]['used_automatic_classes'] = $used_automatic_classes;
                 unset($params['used_automatic_classes']);
             }
         }
     }
     if (!isset($this->controller->view) || $this->controller->view == 'View') {
         $this->controller->view = 'Typographer.Type';
     }
     $this->controller->set('used_automatic_classes', $used_automatic_classes);
     $this->controller->set($tools);
     $this->controller->set('layout_scheme', $layout_scheme);
 }
Example #7
0
 public function beforeFind($queryData)
 {
     $this->basePath = Configure::read('Filemanager.base_path');
     if (empty($this->basePath)) {
         $this->validationErrors[] = array('field' => 'basePath', 'message' => __('Base path does not exist'));
         return false;
     }
     $this->path = $this->basePath;
     if (isset($queryData['conditions']['path'])) {
         $this->path = $this->basePath . $queryData['conditions']['path'];
     }
     App::import('Folder');
     App::import('File');
     $Folder = new Folder($this->path);
     if (empty($Folder->path)) {
         $this->validationErrors[] = array('field' => 'path', 'message' => __('Path does not exist'));
         return false;
     }
     $this->fileList = $Folder->read();
     unset($this->fileList[1]);
     if (!empty($queryData['order'])) {
         $this->__order($queryData['order']);
     }
     return true;
 }
 function getWebsiteMenus()
 {
     App::import('Model', 'Page');
     $this->Page = new Page();
     $pages = $this->Page->find('all', array('conditions' => array('Page.menu' => '1'), 'order' => 'Page.order ASC'));
     return $pages;
 }
function smarty_function_language_box($params, $template)
{
    // Cache the output.
    $cache_name = 'vam_language_box_output' . (isset($params['template']) ? '_' . $params['template'] : '') . '_' . $_SESSION['Customer']['language_id'];
    $language_box_output = Cache::read($cache_name);
    if ($language_box_output === false) {
        ob_start();
        global $content;
        App::import('Component', 'Smarty');
        $Smarty =& new SmartyComponent();
        App::import('Model', 'Language');
        $Language =& new Language();
        $languages = $Language->find('all', array('conditions' => array('active' => '1')));
        if (count($languages) == 1) {
            return;
        }
        $keyed_languages = array();
        foreach ($languages as $language) {
            $language['Language']['url'] = BASE . '/languages/pick_language/' . $language['Language']['id'];
            $language['Language']['image'] = BASE . '/img/flags/' . $language['Language']['iso_code_2'] . '.png';
            $keyed_languages[] = $language['Language'];
        }
        $vars = array('languages' => $keyed_languages);
        $display_template = $Smarty->load_template($params, 'language_box');
        $Smarty->display($display_template, $vars);
        // Write the output to cache and echo them
        $language_box_output = @ob_get_contents();
        ob_end_clean();
        Cache::write($cache_name, $language_box_output);
    }
    echo $language_box_output;
}
 public function buildBookStatReportExcel($books)
 {
     App::import("Vendor", "phpexcel/PHPExcel");
     App::import("Vendor", "phpexcel/PHPExcel/Writer/Excel5");
     $r['path'] = TMP . 'tests' . DS;
     $r['file'] = 'tmp_books_stat_' . $this->Session->read('user_id');
     $file = $r['path'] . $r['file'];
     $excel = new PHPExcel();
     $excel->setActiveSheetIndex(0);
     $excel->getActiveSheet()->setTitle('Books');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, '級別');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, '書籍名稱');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(2, 1, '作者');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(3, 1, 'ISBN');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(4, 1, '索書號');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(5, 1, '出借分校');
     $excel->getActiveSheet()->setCellValueByColumnAndRow(6, 1, '出借次數');
     $i = 1;
     foreach ($books as $book) {
         $i++;
         $excel->getActiveSheet()->setCellValueExplicitByColumnAndRow(0, $i, $book['books']['cate_id'], PHPExcel_Cell_DataType::TYPE_STRING);
         $excel->getActiveSheet()->setCellValueByColumnAndRow(1, $i, $book['books']['book_name']);
         $excel->getActiveSheet()->setCellValueByColumnAndRow(2, $i, $book['books']['book_author']);
         $excel->getActiveSheet()->setCellValueExplicitByColumnAndRow(3, $i, $book['books']['isbn'], PHPExcel_Cell_DataType::TYPE_STRING);
         $excel->getActiveSheet()->setCellValueExplicitByColumnAndRow(4, $i, $book['books']['book_search_code'], PHPExcel_Cell_DataType::TYPE_STRING);
         $excel->getActiveSheet()->setCellValueByColumnAndRow(5, $i, $book['system_locations']['location_name']);
         $excel->getActiveSheet()->setCellValueByColumnAndRow(6, $i, $book[0]['cnt']);
     }
     $objWriter = new PHPExcel_Writer_Excel5($excel);
     $objWriter->save($file);
     return $r;
 }
Example #11
0
 function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
 {
     if ($text_reason) {
         $this->reason = sprintf(__('have signed the %s waiver', true), $this->waiver);
     } else {
         App::import('Helper', 'Html');
         $html = new HtmlHelper();
         $url = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
         if ($absolute_url) {
             $url = $html->url($url, true);
         } else {
             $url['return'] = true;
         }
         $this->reason = $html->link(sprintf(__('have signed the %s waiver', true), $this->waiver), $url);
     }
     $this->redirect = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
     if (!$strict) {
         $this->invariant = true;
         return true;
     }
     if (is_array($params) && array_key_exists('Waiver', $params)) {
         $matches = array_intersect($this->config, Set::extract("/Waiver/WaiversPerson[valid_from<={$this->date}][valid_until>={$this->date}]/waiver_id", $params));
         if (!empty($matches)) {
             $this->invariant = true;
             return true;
         }
     }
     return false;
 }
Example #12
0
 function createComment(&$model, $id, $data = array())
 {
     if (!empty($data[$this->__settings[$model->alias]['class']])) {
         unset($data[$model->alias]);
         $model->Comment->validate = array($this->__settings[$model->alias]['column_author'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_content'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_email'] => array('notempty' => array('rule' => array('notempty')), 'email' => array('rule' => array('email'), 'message' => 'Please enter a valid email address')), $this->__settings[$model->alias]['column_class'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_foreign_id'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_status'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_points'] => array('notempty' => array('rule' => array('notempty')), 'numeric' => array('rule' => array('numeric'))));
         $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_class']] = $model->alias;
         $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_foreign_id']] = $id;
         $data[$this->__settings[$model->alias]['class']] = $this->_rateComment($model, $data['Comment']);
         if ($data[$this->__settings[$model->alias]['class']]['status'] == 'spam') {
             $data[$this->__settings[$model->alias]['class']]['active'] == 0;
         } else {
             if (Configure::read('Comments.auto_moderate') === true && $data[$this->__settings[$model->alias]['class']]['status'] != 'spam') {
                 $data[$this->__settings[$model->alias]['class']]['active'] == 1;
             }
         }
         if ($this->__settings[$model->alias]['sanitize']) {
             App::import('Sanitize');
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']] = Sanitize::clean($data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']]);
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']] = Sanitize::clean($data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']]);
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']] = Sanitize::clean($data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']]);
         } else {
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']] = $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']];
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']] = $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']];
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']] = $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']];
         }
         if ($this->_checkForEmptyVal($data[$this->__settings[$model->alias]['class']]) == false) {
             $model->Comment->create();
             if ($model->Comment->save($data)) {
                 return true;
             }
         }
     }
     return false;
 }
Example #13
0
 /**
  * PwdShell::hash()
  *
  * @return void
  */
 public function hash()
 {
     $components = array('Tools.AuthExt', 'Auth');
     $class = null;
     foreach ($components as $component) {
         if (App::import('Component', $component)) {
             $component .= 'Component';
             list($plugin, $class) = pluginSplit($component);
             break;
         }
     }
     if (!$class || !method_exists($class, 'password')) {
         return $this->error(__('No Auth Component found'));
     }
     $this->out('Using: ' . $class);
     while (empty($pwToHash) || mb_strlen($pwToHash) < 2) {
         $pwToHash = $this->in(__('Password to Hash (2 characters at least)'));
     }
     if ($authType = Configure::read('Passwordable.authType')) {
         list($plugin, $authType) = pluginSplit($authType, true);
         $className = $authType . 'PasswordHasher';
         App::uses($className, $plugin . 'Controller/Component/Auth');
         $passwordHasher = new $className();
         $pw = $passwordHasher->hash($pwToHash);
     } else {
         $class = new $class(new ComponentCollection());
         $pw = $class->password($pwToHash);
     }
     $this->hr();
     $this->out($pw);
 }
Example #14
0
 function getAdresses($options = array())
 {
     $defaultOptions = array('aro' => null);
     $options = array_merge($defaultOptions, $options);
     if (empty($options['aro'])) {
         $aroProvider = Configure::read('Shop.address.ACL.aroProvider');
         //debug($aroProvider);
         if (isset($aroProvider['component']) && isset($aroProvider['component'])) {
             $aro = $this->ShopFunct->callExternalfunction($aroProvider);
         }
         if (empty($aro)) {
             $aro = Configure::read('Shop.address.ACL.defaultAro');
         }
     } else {
         $aro = $options['aro'];
     }
     if (!$this->ShopAddress) {
         App::import('ShopAddress', 'Shop.ShopAddress');
         $this->ShopAddress = new ShopAddress();
     }
     //!!!!!!! Méthode trop lente quand il y a beaucoup d'élémemts. !!!!!!!
     $this->ShopAddress->recursive = -1;
     $allAdresses = $this->ShopAddress->find('all', array('conditions' => array('active' => 1)));
     if (count($allAdresses) > 250) {
         trigger_error(__d('shop', "Too many entries for the current analysing method. May be slow.", true), E_USER_NOTICE);
     }
     $adresses = true();
     foreach ($allAdresses as $adress) {
         if (!$this->Acl->check($aro, array('model' => $this->ShopAddress->alias, 'foreign_key' => $adress['ShopAddress']['id']))) {
             $adresses[] = $adress;
         }
     }
     return $adresses;
 }
 function index()
 {
     if (!empty($this->data) && !empty($_POST['submit'])) {
         $string = explode(",", trim($this->data['EbayenglishListing']['all_item']));
         $prsku = $string[0];
         if (!empty($string[1])) {
             $prname = $string[1];
         }
         if (!empty($prsku) && !empty($prname)) {
             $conditions = array('EbayenglishListing.title LIKE' => '%' . $prname . '%', 'EbayenglishListing.title LIKE' => '%' . $prsku . '%');
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'EbayenglishListing.sku  id', 'conditions' => $conditions);
         }
         if (!empty($prsku)) {
             $conditions = array('OR' => array('EbayenglishListing.title LIKE' => "%{$prsku}%", 'EbayenglishListing.sku LIKE' => "%{$prsku}%"));
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'EbayenglishListing.id  ASC', 'conditions' => $conditions);
         }
         $this->set('ebayenglishlistings', $this->paginate());
     } else {
         if (!empty($_POST['checkid']) && !empty($_POST['exports'])) {
             $checkboxid = $_POST['checkid'];
             App::import("Vendor", "parsecsv");
             $csv = new parseCSV();
             $filepath = "C:\\Users\\Administrator\\Downloads" . "ebayenglishlistings.csv";
             $csv->auto($filepath);
             $this->set('ebayenglishlistings', $this->EbayenglishListing->find('all', array('conditions' => array('EbayenglishListing.id' => $checkboxid))));
             $this->layout = null;
             $this->autoLayout = false;
             Configure::write('debug', '2');
         } else {
             $this->EbayenglishListing->recursive = 1;
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'EbayenglishListing.id  ASC');
             $this->set('ebayenglishlistings', $this->paginate());
         }
     }
 }
Example #16
0
 function export_report_all_format($file_type, $filename, $html)
 {
     if ($file_type == 'pdf') {
         App::import('Vendor', 'dompdf', array('file' => 'dompdf' . DS . 'dompdf_config.inc.php'));
         $this->dompdf = new DOMPDF();
         $papersize = "a4";
         $orientation = 'portrait';
         $this->dompdf->load_html($html);
         $this->dompdf->set_paper($papersize, $orientation);
         $this->dompdf->render();
         $this->dompdf->stream("Proforma_Invoice_" . $filename . ".pdf");
         echo $this->dompdf->output();
         // $output = $this->dompdf->output();
         //file_put_contents($filename.'.pdf', $output);
         die;
     } else {
         if ($file_type == 'xls') {
             $file = $filename . ".xls";
             header('Content-Type: text/html');
             header("Content-type: application/x-msexcel");
             //tried adding  charset='utf-8' into header
             header("Content-Disposition: attachment; filename={$file}");
             echo $html;
         } else {
             if ($file_type == 'doc') {
                 $file = $filename . ".doc";
                 header("Content-type: application/vnd.ms-word");
                 header("Content-Disposition: attachment;Filename={$file}");
                 echo $html;
             }
         }
     }
 }
 function buildSchema($id)
 {
     $notInput = array('fieldset', 'textonly');
     App::import('Model', 'Cforms.Cform');
     $this->Cform = new Cform();
     $cform = $this->Cform->find('first', array('conditions' => array('Cform.id' => $id), 'contain' => array('FormField', 'FormField.ValidationRule')));
     $schema = array();
     $validate = array();
     foreach ($cform['FormField'] as &$field) {
         if (!in_array($field['type'], $notInput)) {
             $schema[$field['name']] = array('type' => 'string', 'length' => $field['length'], 'null' => null, 'default' => $field['default']);
             if (!empty($field['ValidationRule'])) {
                 foreach ($field['ValidationRule'] as $rule) {
                     $validate[$field['name']][$rule['rule']] = array('rule' => $rule['rule'], 'message' => $rule['message'], 'allowEmpty' => $field['required'] ? false : true);
                 }
             } elseif ($field['required']) {
                 $validate[$field['name']] = array('notBlank');
             }
             if (!empty($field['depends_on']) && !empty($field['depends_value'])) {
                 $dependsOn[$field['name']] = array('field' => $field['depends_on'], 'value' => $field['depends_value']);
             }
             $field['options'] = str_replace(', ', ',', $field['options']);
             $options = explode(',', $field['options']);
             $field['options'] = array_combine($options, $options);
         }
     }
     $this->validate = $validate;
     $this->_schema = $schema;
     $this->dependsOn = isset($dependsOn) ? $dependsOn : array();
     return $cform;
 }
Example #18
0
 /**
  * construct method
  *
  * @param array $options array()
  * @return void
  * @access private
  */
 public function __construct($options = array())
 {
     if (App::import('Helper', 'MiAsset.Asset')) {
         $this->helpers[] = 'MiAsset.Asset';
     }
     parent::__construct();
 }
 /**
  * Initialization method. Triggered before the controller's `beforeFilfer`
  * method but after the model instantiation.
  *
  * @param Controller $controller
  * @param array $settings
  * @return null
  * @access public
  */
 public function initialize(Controller $controller)
 {
     // Handle loading our library firstly...
     App::build(array('Vendor' => array(APP . 'Vendor' . DS . 'vexxhost' . DS . 'cloud-flare-api')));
     App::import('Vendor', 'cloudflare_api', array('file' => 'vexxhost' . DS . 'cloud-flare-api' . DS . 'class_cloudflare.php'));
     $this->Cf = new cloudflare_api(Configure::read('CloudFlareApi.email'), Configure::read('CloudFlareApi.apiKey'));
 }
 /**
  * contact index method
  * 
  * @return void
  */
 public function index()
 {
     if ($this->request->is('post')) {
         if (!isset($this->Captcha)) {
             //if Component was not loaded throug $components array()
             App::import('Component', 'Captcha');
             //load it
             $this->Captcha = new CaptchaComponent();
             //make instance
             $this->Captcha->startup($this);
             //and do some manually calling
         }
         $this->Contact->setCaptcha($this->Captcha->getVerCode());
         $this->Contact->create($this->data);
         // There is no save(), so we need to validate manually.
         if ($this->Contact->validates()) {
             $this->Email->smtpOptions = array('port' => '587', 'timeout' => '30', 'host' => 'smtp.sendgrid.net', 'username' => 'lakmalj', 'password' => '510662', 'client' => 'eloeel.com');
             $this->Email->delivery = 'smtp';
             $this->Email->from = $this->data['Contact']['name'] . ' <' . $this->data['Contact']['email'] . '>';
             $this->Email->to = array('sampath@flipit.lk');
             $this->Email->cc = array('lakmal@flipit.lk');
             $this->Email->subject = 'Eloeel.com - Contact Form: ' . $this->data['Contact']['subject'];
             $this->Email->replyTo = $this->data['Contact']['email'];
             $this->Email->sendAs = 'both';
             if ($this->Email->send($this->data['Contact']['message'])) {
                 $this->Session->setFlash('Thank you for contacting us');
             } else {
                 $this->Session->setFlash('Mail Not Sent');
             }
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash('Please Correct Errors');
         }
     }
 }
Example #21
0
 /**
  * beforeSave callback
  * 
  * Used to process the text in textile format.
  * 
  * @access public
  * @return Always true so it doesnt avoid saving
  */
 function beforeSave()
 {
     App::import('Vendor', 'Textile');
     $Textile = new Textile();
     $this->data[$this->alias]['processed_text'] = $Textile->textileThis($this->data[$this->alias]['text']);
     return true;
 }
Example #22
0
 /**
  * Import the Markdownify vendor files and instantiate the object.
  */
 public function __construct()
 {
     /**
      * Import the Markdownify vendor files.
      */
     App::import('Vendor', 'markdown/markdown');
 }
Example #23
0
 public static function instance()
 {
     if (is_null(self::$instance)) {
         App::import('Vendor', 'Smarty', array('file' => 'autoload.php'));
         $smarty = new Smarty();
         $smarty->template_dir = APP . 'View' . DS;
         //plugins dir(s) must be set by array
         $smarty->plugins_dir = array(APP . 'View' . DS . 'SmartyPlugins', VENDORS . 'smarty' . DS . 'smarty' . DS . 'distribution' . DS . 'libs' . DS . 'plugins');
         $smarty->config_dir = APP . 'View' . DS . 'SmartyConfigs' . DS;
         $smarty->compile_dir = TMP . 'smarty' . DS . 'compile' . DS;
         $smarty->cache_dir = TMP . 'smarty' . DS . 'cache' . DS;
         $smarty->error_reporting = 'E_ALL & ~E_NOTICE';
         $smarty->default_modifiers = array('escape:"html"');
         $smarty->caching = true;
         $smarty->compile_check = true;
         $smarty->cache_lifetime = 3600;
         $smarty->cache_modified_check = false;
         $smarty->force_compile = Configure::read('debug') > 0 ? true : false;
         /*
          $smarty->autoload_filters = array(
          'pre' => array('hoge'),
          'output' => array('escape')
          );
          $smarty->left_delimiter = '{';
          $smarty->right_delimiter = '}';
          //for development
          $smarty->debugging = (Configure::read('debug') == 0) ? false : true;
         */
         self::$instance = $smarty;
     }
     return self::$instance;
 }
 /**
  * @return object
  */
 public static function get($type, $name)
 {
     $name = Inflector::camelize($name);
     $registry = GummRegistry::getRegistry();
     $regKey = $type . '_' . $name;
     if (isset($registry[$regKey])) {
         return $registry[$regKey];
     }
     App::import($type, $name);
     $objName = false;
     switch (strtolower($type)) {
         case 'model':
             $objName = $name . 'Model';
             break;
         case 'controller':
             $objName = $name . 'Controller';
             break;
         case 'helper':
             $objName = $name . 'Helper';
             break;
         case 'widget':
             $objName = $name;
             break;
         case 'component':
             $objName = $name . 'Component';
             break;
         case 'editor':
             $objName = $name . 'Editor';
             break;
     }
     $obj = new $objName();
     GummRegistry::updateRegistry($regKey, $obj);
     return $obj;
 }
 public function buildCss()
 {
     App::import('Vendor', 'AssetMinify.JSMinPlus');
     // Ouverture des fichiers de config
     $dir = new Folder(Configure::read('App.www_root') . 'css' . DS . 'minified');
     if ($dir->path !== null) {
         foreach ($dir->find('config_.*.ini') as $file) {
             preg_match('`^config_(.*)\\.ini$`', $file, $grep);
             $file = new File($dir->pwd() . DS . $file);
             $ini = parse_ini_file($file->path, true);
             $fileFull = new File($dir->path . DS . 'full_' . $grep[1] . '.css', true, 0644);
             $fileGz = new File($dir->path . DS . 'gz_' . $grep[1] . '.css', true, 0644);
             $contentFull = '';
             foreach ($ini as $data) {
                 // On a pas de version minifié
                 if (!($fileMin = $dir->find('file_' . md5($data['url'] . $data['md5']) . '.css'))) {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css', true, 0644);
                     $this->out("Compression de " . $data['file'] . ' ... ', 0);
                     $fileMin->write(MinifyUtils::compressCss(MinifyUtils::cssAbsoluteUrl($data['url'], file_get_contents($data['file']))));
                     $this->out('OK');
                 } else {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css');
                 }
                 $contentFull .= $fileMin->read() . PHP_EOL;
             }
             // version full
             $fileFull->write($contentFull);
             $fileFull->close();
             // compression
             $fileGz->write(gzencode($contentFull, 6));
         }
     }
 }
 function asignar_cotizacion($id_equipo, $placa_inventario)
 {
     App::import('Vendor', 'upload', array('file' => 'class.upload.php'));
     $this->autoLayout = false;
     $this->autoRender = false;
     $datos_json = array('resultado' => false, 'id' => '', 'nombre_archivo' => '');
     if (!empty($_FILES) && !empty($id_equipo) && !empty($placa_inventario)) {
         if (!empty($_FILES['cotizacion']['name'])) {
             $handle = new Upload($_FILES['cotizacion']);
             if ($handle->uploaded) {
                 $handle->file_overwrite = true;
                 $handle->file_safe_name = false;
                 $handle->file_auto_rename = false;
                 $handle->file_new_name_body = 'cotizacion(' . $this->Cotizacion->getNextAutoIncrement() . ')_' . $placa_inventario;
                 $handle->Process('equipos/cotizaciones');
                 if ($handle->processed) {
                     $this->data['Cotizacion']['nombre_archivo'] = $handle->file_dst_name;
                     $this->data['Cotizacion']['id_equipo'] = $id_equipo;
                     $this->data['Cotizacion']['placa_inventario'] = $placa_inventario;
                     if ($this->Cotizacion->save($this->data)) {
                         $datos_json['resultado'] = true;
                         $datos_json['id'] = $this->Cotizacion->id;
                         $datos_json['nombre_archivo'] = $this->data['Cotizacion']['nombre_archivo'];
                     }
                 }
                 $handle->Clean();
             }
         }
     }
     return json_encode($datos_json);
 }
Example #27
0
 /**
  * Generate authorization hash.
  *
  * @return string Hash
  * @access public
  * @static
  */
 function generateAuthKey()
 {
     if (!class_exists('String')) {
         App::import('Core', 'String');
     }
     return Security::hash(String::uuid());
 }
Example #28
0
function diebug($variables = false, $showHtml = true, $showFrom = true, $die = true)
{
    if (Configure::read() > 0) {
        if (is_array($showHtml)) {
            $showHtml = array_merge(array('showHtml' => true, 'showFrom' => true, 'die' => true), $showHtml);
            extract($showHtml);
        }
        if ($showFrom) {
            $calledFrom = debug_backtrace();
            echo '<strong>' . substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1) . '</strong>';
            echo ' (line <strong>' . $calledFrom[0]['line'] . '</strong>)<br /><br />';
        }
        if (!is_array($variables)) {
            $variables = array($variables);
        }
        if ($showHtml) {
            App::import('Vendor', 'dBug', array('file' => 'dBug.php'));
            foreach ($variables as $key => $variable) {
                new dBug($variable);
                echo '<br />';
            }
        } else {
            foreach ($variables as $variable) {
                debug($var, $showHtml, $showFrom);
                echo '<br />';
            }
        }
        if ($die) {
            die;
        }
    }
}
 /**
  * 画像作成。
  */
 public function captcha()
 {
     App::import('Vendor', 'Securimage', array('file' => 'securimage/securimage.php'));
     $securimage = new Securimage();
     $securimage->ttf_file = ROOT . '/vendors/securimage/AHGBold.ttf';
     $securimage->show();
 }
Example #30
0
 function edit($id = null)
 {
     if (!$id && empty($this->data)) {
         $this->Session->setFlash(__('Invalid User', true));
         $this->redirect(array('action' => 'index'));
     }
     if (!empty($this->data)) {
         if (!empty($this->data['User']['newpw1']) && !empty($this->data['User']['newpw2'])) {
             if ($this->data['User']['newpw1'] == $this->data['User']['newpw2']) {
                 App::import('Security');
                 $this->data['User']['password'] = $this->Auth->password($this->data['User']['newpw1']);
             } else {
                 $this->Session->setFlash('The new passwords provided did not match', true, array('class' => 'error'));
                 $this->redirect(array('action' => 'edit', $id));
             }
         }
         if ($this->User->save($this->data)) {
             $this->Session->setFlash(__('The User has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
         }
     }
     if (empty($this->data)) {
         $this->data = $this->User->read(null, $id);
         $groups = $this->User->Group->find('list');
         $this->set(compact('groups'));
         $projects = $this->User->Project->find('list');
         $this->set(compact('projects'));
     }
 }