Exemplo n.º 1
0
 public function get($usuario)
 {
     //$this->load->model('permisos/permisos_model');
     $this->usuario = getInstance("Usuario");
     //
     try {
         $condicion = "";
         if (isset($usuario['id_usuario'])) {
             $condicion = " u.id_usuario = " . (int) $usuario['id_usuario'];
         } elseif (isset($usuario['email'])) {
             $condicion = " u.email = " . $this->db->escape($usuario['email']);
         } else {
             //return NULL;
         }
         $query = $this->db->query("SELECT u.*,r.key as 'rol_key',r.descripcion as 'rol_descripcion',r.id_rol FROM usuarios u INNER JOIN roles r USING (id_rol) WHERE " . $condicion);
         unset($usuario);
         $usuario = $query->row_array();
         $this->usuario->init($usuario);
         if (!isset($usuario)) {
             return NULL;
         }
         return $this->usuario;
     } catch (Exception $e) {
         return null;
     }
 }
Exemplo n.º 2
0
 public function _404()
 {
     $this->request();
     $cogear = getInstance();
     $cogear->response->header('Status', '404 ' . Response::$codes[404]);
     error(t('Page you are looking for was not found on the server.'), t('Page not found'));
 }
Exemplo n.º 3
0
 public function __construct($vars = null)
 {
     if (isset($vars)) {
         $this->init($vars, __CLASS__);
     }
     $this->localizacion = getInstance('Localizacion');
 }
Exemplo n.º 4
0
 /**
  * Построение ссылки
  *
  * @param	string	$url
  * @param	boolean	$absolute_flag
  * @param	string	$protocol
  * @return	string
  */
 public static function link($url = '', $absolute_flag = FALSE, $protocol = 'http')
 {
     $link = '';
     $cogear = getInstance();
     if (!$url) {
         return $protocol . '://' . SITE_URL . '/';
     } else {
         if (TRUE === $url) {
             return l() . cogear()->router->getUri();
         }
     }
     $url = parse_url($url);
     if ($absolute_flag) {
         $link .= $protocol . '://';
         $link .= SITE_URL;
     } elseif (defined('FOLDER')) {
         $link .= '/' . FOLDER;
     }
     isset($url['host']) && ($link = $protocol . '://' . $url['host']);
     isset($url['path']) && ($link .= '/' . ltrim($url['path'], '/'));
     isset($url['query']) && ($link .= '?' . $url['query']);
     isset($url['fragment']) && ($link .= '#' . $url['fragment']);
     event('link', $link);
     if (cogear()->input->get('splash') === '') {
         $link .= e();
     }
     return $link;
 }
Exemplo n.º 5
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $cogear = getInstance();
     Form::$types['file'] = 'Upload_Ajax_Form_File';
     Form::$types['image'] = 'Upload_Ajax_Form_Image';
 }
Exemplo n.º 6
0
 /**
  * Constructor
  */
 public function __contsruct()
 {
     parent::__construct();
     $cogear = getInstance();
     $this->mcrypt_cipher = $cogear->get('secure.mcrypt_cipher', MCRYPT_BLOWFISH);
     $this->mcrypt_mode = $cogear->get('secure.mcrypt_mode', MCRYPT_MODE_ECB);
 }
Exemplo n.º 7
0
 public function render()
 {
     $cogear = getInstance();
     $template = new Template('Benchmark.results');
     $template->data = Benchmark_Gear::humanize($cogear->benchmark->measurePoint('system'));
     return $template->render();
 }
Exemplo n.º 8
0
 public function getPdo()
 {
     if (!isset(self::$instance)) {
         getInstance();
     }
     return $this->pdo;
 }
Exemplo n.º 9
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     $this->view = getInstance('Init\\View');
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
Exemplo n.º 10
0
 /**
  * Magic __call method
  * 
  * @param   string  $name
  * @param   array   $array
  */
 public function __call($name, $args = array())
 {
     $cogear = getInstance();
     if (method_exists($cogear, $name)) {
         return call_user_func_array(array($cogear, $name), $args);
     }
     return NULL;
 }
Exemplo n.º 11
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $cogear = getInstance();
     $this->api = new Loginza_API();
     hook('form.user-login.result.before', array($this, 'hookUserForm'));
     hook('form.user-register.result.before', array($this, 'hookUserForm'));
     hook('form.user-profile.init', array($this, 'hookUserProfile'));
 }
 public function __construct()
 {
     $CI = getInstance();
     if (!isset($CI->hotelavail)) {
         throw new SiteminderErrors('Processing exception', '12');
     }
     $this->hotelavail_model = $CI->hotelavail;
     unset($CI);
 }
Exemplo n.º 13
0
 public function getInstance()
 {
     $arguments = func_get_args();
     if (is_callable($this->staticObject)) {
         return call_user_func_array($this->staticObject, $arguments);
     }
     $class = $this->staticObject;
     return \getInstance($class, $arguments);
 }
Exemplo n.º 14
0
function getdatas($id)
{
    $pdo = getInstance();
    $query = $pdo->prepare("SELECT * FROM joueur JOIN classement ON classement.idJoueur = joueur.id WHERE id = :id");
    $query->bindValue(":id", $id);
    $query->execute();
    $datas = $query->fetch();
    return $datas;
}
Exemplo n.º 15
0
 /**
  * Render theme
  */
 public function render()
 {
     if ($this->is_rendered) {
         return;
     }
     $cogear = getInstance();
     $this->template = new Template($this->theme . '.' . $this->layout);
     $cogear->response->append($this->template->render());
     $this->is_rendered = TRUE;
 }
Exemplo n.º 16
0
 /**
  * Add final point and show calculations for system benchmark
  */
 public function finalPoint()
 {
     $this->addPoint('system.end');
     if (access('development')) {
         $cogear = getInstance();
         $template = new Template('Dev.results');
         $template->data = Dev_Gear::humanize($cogear->dev->measurePoint('system'));
         append('footer', $template->render());
         js($this->folder . '/js/inline/debug.js');
     }
 }
Exemplo n.º 17
0
 /**
  * Factory
  *
  * @param string $name
  * @param array $options
  */
 public static function factory($name, $data = NULL)
 {
     $cogear = getInstance();
     if (class_exists($name)) {
         $widget = new $name($data);
         if ($widget instanceof self) {
             return $widget;
         } else {
             unset($widget);
         }
     }
 }
Exemplo n.º 18
0
 /**
  * Process elements value from request
  *
  * @return
  */
 public function result()
 {
     $cogear = getInstance();
     $file = new Upload_File($this->name, $this->getAttributes(), $this->validators->findByValue('Required'));
     if ($value = $file->upload()) {
         $this->is_fetched = TRUE;
         $this->value = $value;
     } else {
         $this->errors = $file->errors;
     }
     return $this->value;
 }
Exemplo n.º 19
0
 private function setPlugin()
 {
     if (isset($this->match['params']['Plugin']) && isset($this->match['params']['app_type'])) {
         $app_type = ucfirst($this->match['params']['app_type']);
         $Plugin = $this->removeSlash(ucfirst($this->match['params']['Plugin']));
         $this->plugin = $app_type . '\\' . $Plugin;
         $plugin_view = BASE_PATH . 'lib/' . $app_type . '/' . $Plugin . '/View/';
         getInstance('Hu\\Core\\View\\View')->prependPath($plugin_view, $Plugin);
         $_ENV['page']['plugin_base_url'] = $_ENV['page']['base_url'] . 'lib/' . $app_type . '/' . $Plugin . '/';
         $_ENV['page']['plugin_assets_url'] = $_ENV['page']['plugin_base_url'] . 'Assets/';
     }
     return $this;
 }
Exemplo n.º 20
0
 public function urltesting()
 {
     $urlconfig = $GLOBALS['url'];
     foreach ($urlconfig as $key => $value) {
         foreach ($value as $k => $v) {
             if ($this->url == $k) {
                 $arr = explode("/", $v);
                 $d = getInstance(APP_NAME . '\\Controller\\' . $arr[0] . 'Controller');
                 $d->{$arr}[1]();
             }
         }
     }
 }
Exemplo n.º 21
0
 /**
  * Init
  */
 public function init()
 {
     $cogear = getInstance();
     if (!($menu = $cogear->system_cache->get('menu/' . $this->name))) {
         foreach ($cogear->gears as $gear) {
             if (method_exists($gear, 'menu')) {
                 call_user_func_array(array($gear, 'menu'), array($this->name, &$this));
             }
         }
         $cogear->system_cache->set('menu/' . $this->name, $this->toArray());
     } else {
         $this->exchangeArray((array) $menu);
     }
 }
Exemplo n.º 22
0
 /**
  * Prepare menues
  */
 public function prepare(){
     $cogear = getInstance();
     $menu = new Menu('admin.sidebar');
     $root = Url::gear('admin');
     $menu->{$root} = icon('dashboard','fugue').t('Dashboard');
     $menu->{$root.'gears'} = icon('gear','fugue').t('Gears');
     $menu->{$root.'theme'} = icon('layout').t('Theme');
     $menu->{$root.'site'} = icon('toolbox','fugue').t('Site');
     $menu->{$root.'site/clear_cache'} = icon('bin').t('Clear cache');
     prepend('sidebar',$menu->render('Admin_Menu.sidebar_menu'));
     css($this->folder.'/css/menu.css');
     $menu = new Menu('admin.top');
     Template::bindGlobal('top_menu',$menu);
 }
Exemplo n.º 23
0
 /**
  * Get template
  *
  * @return  string
  */
 protected function getTemplate()
 {
     $cogear = getInstance();
     if (!($this->code = $cogear->cache->read('templates/' . $this->name))) {
         if ($template = $cogear->db->where('name', $this->name)->order('last_update', 'DESC')->get('templates')->row()) {
             $cogear->cache->write('templates/' . $this->name, $this->code);
         } else {
             $this->code = file_get_contents($this->path);
             $cogear->db->insert('templates', array('name' => $this->name, 'code' => $this->code, 'last_update' => date('Y-m-d H:i:s')));
             $cogear->cache->write('templates/' . $this->name, $this->code);
         }
     }
     return $this->code;
 }
Exemplo n.º 24
0
 /**
  * Send headers
  */
 public function sendHeaders()
 {
     if (!$this->headers_sent) {
         $cogear = getInstance();
         if (!($protocol = $cogear->request->get('SERVER_PROTOCOL'))) {
             $protocol = 'HTTP/1.1';
         }
         @header($protocol . ' ' . $this->status . ' ' . $this->codes[$this->status]);
         foreach ($this->headers as $name => $value) {
             @header($name . ': ' . $value, TRUE);
         }
         $this->headers_sent = TRUE;
     }
 }
function generatePaymentToken()
{
    global $userinfo, $cart;
    $instance = getInstance();
    $payment_cc_data = cko_config();
    $config = array();
    $productsLoad = $cart['products'];
    $scretKey = $payment_cc_data['param02'];
    $amountCents = (int) (100 * $cart['total_cost']);
    $config['authorization'] = $scretKey;
    $config['mode'] = $payment_cc_data['param01'];
    $config['timeout'] = $payment_cc_data['param08'];
    if ($payment_cc_data['param06'] == 'Authorize and Capture') {
        $config = array_merge($instance->_captureConfig(), $config);
    } else {
        $config = array_merge($instance->_authorizeConfig(), $config);
    }
    $products = array();
    foreach ($productsLoad as $item) {
        $products[] = array('name' => $item['product'], 'sku' => $item['productcode'], 'price' => $item['price'], 'quantity' => $item['amount']);
    }
    $billPhoneLength = strlen($userinfo['b_phone']);
    $billingAddressConfig = array('addressLine1' => $userinfo['b_address'], 'addressLine2' => $userinfo['b_address_2'], 'postcode' => $userinfo['b_zipcode'], 'country' => $userinfo['b_country'], 'state' => $userinfo['b_statename'], 'city' => $userinfo['b_city']);
    if ($billPhoneLength > 6) {
        $bilPhoneArray = array('phone' => array('number' => $userinfo['b_phone']));
        $billingAddressConfig = array_merge_recursive($billingAddressConfig, $bilPhoneArray);
    }
    $shipPhoneLength = strlen($userinfo['s_phone']);
    $shippingAddressConfig = array('addressLine1' => $userinfo['s_address'], 'addressLine2' => $userinfo['s_address_2'], 'postcode' => $userinfo['s_zipcode'], 'country' => $userinfo['s_country'], 'state' => $userinfo['s_statename'], 'city' => $userinfo['s_city']);
    if ($shipPhoneLength > 6) {
        $shipPhoneArray = array('phone' => array('number' => $userinfo['s_phone']));
        $shippingAddressConfig = array_merge_recursive($shippingAddressConfig, $shipPhoneArray);
    }
    $config['postedParam'] = array_merge_recursive($config['postedParam'], array('email' => $userinfo['email'], 'value' => $amountCents, 'currency' => $payment_cc_data['param09'], 'shippingDetails' => $shippingAddressConfig, 'products' => $products, 'billingDetails' => $billingAddressConfig));
    $Api = CheckoutApi_Api::getApi(array('mode' => $payment_cc_data['param01']));
    $paymentTokenCharge = $Api->getPaymentToken($config);
    $paymentTokenArray = array('message' => '', 'success' => '', 'eventId' => '', 'token' => '');
    if ($paymentTokenCharge->isValid()) {
        $paymentTokenArray['token'] = $paymentTokenCharge->getId();
        $paymentTokenArray['success'] = true;
    } else {
        $paymentTokenArray['message'] = $paymentTokenCharge->getExceptionState()->getErrorMessage();
        $paymentTokenArray['success'] = false;
        $paymentTokenArray['eventId'] = $paymentTokenCharge->getEventId();
    }
    return $paymentTokenArray;
}
Exemplo n.º 26
0
function checkCache($cacheActionUrl)
{
    $base = getInstance();
    $Controller = $base->Controller;
    foreach ($Controller->cacheAction as $action => $timeout) {
        // convert wildcards to regex
        if (strpos($action, ':') !== false) {
            $action = str_replace(':any', '(.*)', str_replace(':num', '([0-9]+)', $action));
        }
        // does the regex match?
        if (preg_match('#^' . $action . '$#', $cacheActionUrl)) {
            $url = str_replace('/', '_', $base->controllerName . '/' . $cacheActionUrl);
            return array('alias' => $url, 'timeout' => $timeout);
        }
    }
    return false;
}
Exemplo n.º 27
0
 /**
  * Constructor
  *
  * @param   string  $name
  * @param   string  $handler
  */
 public function __construct($name, $handler = NULL)
 {
     if (!self::$handler) {
         $cogear = getInstance();
         self::$handler = $cogear->get('template.handler', self::FILE);
     }
     $this->name = $name;
     event('template.' . $name, $this);
     $handler or $handler = self::$handler;
     switch ($handler) {
         case self::DB:
             $this->adapter = new Template_Db($this->name);
             break;
         case self::FILE:
         default:
             $this->adapter = new Template_File($this->name);
     }
 }
Exemplo n.º 28
0
 function getHotelDestination(&$post)
 {
     if (!is_array($post)) {
         return FALSE;
     }
     if ($post['HotelId'] == '' or $post['HotelId'] == NULL) {
         return;
     }
     $CI =& getInstance();
     $query = 'SELECT SpCountryCode as DestCountry,SpCityCode as DestCity FROM ' . _SUPPLIERCODE . '_sitec_products' . ' WHERE SpHotelCode = "' . $post['HotelId'] . '"';
     $rs = $CI->db->query($query);
     if ($rs === FALSE) {
         return;
     }
     $data = @array_pop($rs->result_array());
     $post['DestCountry'] = $data['DestCountry'];
     $post['DestCity'] = $data['DestCity'];
 }
Exemplo n.º 29
0
 /**
  * Init
  */
 private function init()
 {
     session_id() or session_start();
     $cogear = getInstance();
     event('session.init', $this);
     isset($_SESSION['user_agent']) or $_SESSION['user_agent'] = $cogear->request->getUserAgent();
     $_SESSION['ip'] = $cogear->request->get('ip');
     $_SESSION['session_id'] = session_id();
     if ($referer = $cogear->request->get('HTTP_REFERER')) {
         if (!$this->history) {
             $this->history = new Core_ArrayObject();
         }
         $this->history->append($referer);
         if ($this->history->count() > 10) {
             $array = $this->history->toArray();
             $this->history->exchangeArray(array_slice($array, sizeof($array) - 11));
         }
     }
 }
Exemplo n.º 30
0
function sess_write($key, $value)
{
    // If the client doesn't have a session, and one isn't being created ($value), do nothing.
    if (empty($_COOKIE[session_name()]) && empty($value)) {
        return TRUE;
    }
    $Controller = getInstance()->Controller;
    $Session = new AppModel('Session');
    $result = $Session->findById($key);
    $user_id = 0;
    if (isset($Controller->User->user['id'])) {
        $user_id = $Controller->User->user['id'];
    }
    if (isset($result['Session']['id'])) {
        $Session->save(array('hostname' => $_SERVER['REMOTE_ADDR'], 'session' => $value), array('id' => $key));
    } else {
        $Session->create(array('id' => $key, 'hostname' => $_SERVER['REMOTE_ADDR'], 'session' => $value));
    }
    return TRUE;
}