Example #1
2
 /**
  * Replace the default $this->load->view() method
  * with our own, so we can use Smarty!
  *
  * This method works identically to CI's default method,
  * in that you should pass parameters to it in the same way.
  *
  * @access	public
  * @param	string	The template path name.
  * @param	array	An array of data to convert to variables.
  * @param	bool	Set to TRUE to return the loaded template as a string.
  * @return	mixed	If $return is TRUE, returns string. If not, returns void.
  */
 public function view($template, $data = array(), $return = false)
 {
     // Get the CI super object, load related library.
     $CI =& get_instance();
     $CI->load->library('smartytpl');
     // Add extension to the filename if it's not there.
     $ext = '.' . $CI->config->item('smarty_template_ext');
     if (substr($template, -strlen($ext)) !== $ext) {
         $template .= $ext;
     }
     // Make sure the file exists first.
     if (!$CI->smartytpl->templateExists($template)) {
         show_error('Unable to load the template file: ' . $template);
     }
     // Assign any variables from the $data array.
     $CI->smartytpl->assign_variables($data);
     // Assign CI instance to be available in templates as $ci
     $CI->smartytpl->assignByRef('ci', $CI);
     /*
     	Smarty has two built-in functions to rendering templates: display() 
     	and fetch(). We're going to	use only fetch(), since we want to take
     	the template contents and either return them or add them to
     	CodeIgniter's output class. This lets us optionally take advantage
     	of some of CI's built-in output features.
     */
     $output = $CI->smartytpl->fetch($template);
     // Return the output if the return value is TRUE.
     if ($return === true) {
         return $output;
     }
     // Otherwise append to output just like a view.
     $CI->output->append_output($output);
 }
Example #2
1
 public function not_loggedin()
 {
     $CI =& get_instance();
     if (!$CI->session->is_loggedin) {
         redirect('/index');
     }
 }
 public function __construct()
 {
     //error_reporting(E_ALL);
     log_message('debug', "Weixinapi Class Initialized.");
     $this->CI =& get_instance();
     $this->valid();
 }
Example #4
1
 function __construct()
 {
     parent::__construct();
     $this->_table = 'reff_jamkesmas';
     //get instance
     $this->CI = get_instance();
 }
Example #5
0
 /**
  * Responsible for sending final output to browser
  */
 function output()
 {
     $CI =& get_instance();
     $buffer = $CI->output->get_output();
     $re = '%            # Collapse ws everywhere but in blacklisted elements.
         (?>             # Match all whitespans other than single space.
           [^\\S ]\\s*     # Either one [\\t\\r\\n\\f\\v] and zero or more ws,
         | \\s{2,}        # or two or more consecutive-any-whitespace.
         ) # Note: The remaining regex consumes no text at all...
         (?=             # Ensure we are not in a blacklist tag.
           (?:           # Begin (unnecessary) group.
             (?:         # Zero or more of...
               [^<]++    # Either one or more non-"<"
             | <         # or a < starting a non-blacklist tag.
               (?!/?(?:textarea|pre)\\b)
             )*+         # (This could be "unroll-the-loop"ified.)
           )             # End (unnecessary) group.
           (?:           # Begin alternation group.
             <           # Either a blacklist start tag.
             (?>textarea|pre)\\b
           | \\z          # or end of file.
           )             # End alternation group.
         )  # If we made it here, we are not in a blacklist tag.
         %ix';
     $buffer = preg_replace($re, " ", $buffer);
     $CI->output->set_output($buffer);
     $CI->output->_display();
 }
Example #6
0
 /**
  * Initialize file-based cache
  *
  * @return    void
  */
 public function __construct()
 {
     $CI =& get_instance();
     $CI->load->helper('file');
     $path = $CI->config->item('cache_path');
     $this->_cache_path = $path === '' ? APPPATH . 'cache/' : $path;
 }
Example #7
0
 /**
  * Constructor
  *
  * Accepts an associative array as input, containing preferences
  *
  * @access	public
  * @param	array	config preferences
  * @return	void
  */
 public function __construct()
 {
     $this->CI =& get_instance();
     if (isset($this->CI->dpi)) {
         $this->dpi =& $this->CI->dpi;
     }
 }
 function United_parcel_service()
 {
     $this->CI =& get_instance();
     $this->CI->lang->load('ups');
     // standard services
     $this->ups_services = array('01' => 'UPS Next Day Air', '02' => 'UPS Second Day Air', '03' => 'UPS Ground', '07' => 'UPS Worldwide Express', '08' => 'UPS Worldwide Expedited', '11' => 'UPS Standard', '12' => 'UPS Three-Day Select', '13' => 'UPS Next Day Air Saver', '14' => 'UPS Next Day Air Early AM', '54' => 'UPS Worldwide Express Plus', '59' => 'UPS Second Day Air AM', '65' => 'UPS Saver');
 }
 function __construct()
 {
     //When the class is constructed get an instance of codeigniter so we can access it locally
     $this->_ci =& get_instance();
     //Include the piso_model so we can use it
     $this->_ci->load->model("Piso_Model");
 }
Example #10
0
 function form_open($action = '', $attributes = array(), $hidden = array())
 {
     $CI =& get_instance();
     // If no action is provided then set to the current url
     if (!$action) {
         $action = current_url($action);
     } elseif (strpos($action, '://') === FALSE) {
         $action = if_secure_site_url($action);
     }
     $attributes = _attributes_to_string($attributes);
     if (stripos($attributes, 'method=') === FALSE) {
         $attributes .= ' method="post"';
     }
     if (stripos($attributes, 'accept-charset=') === FALSE) {
         $attributes .= ' accept-charset="' . strtolower(config_item('charset')) . '"';
     }
     $form = '<form action="' . $action . '"' . $attributes . ">\n";
     // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
     if ($CI->config->item('csrf_protection') === TRUE && strpos($action, if_secure_base_url()) !== FALSE && !stripos($form, 'method="get"')) {
         $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
     }
     // Add MY CSRF token if MY CSRF library is loaded
     if ($CI->load->is_loaded('tokens') && strpos($action, if_secure_base_url()) !== FALSE && !stripos($form, 'method="get"')) {
         $hidden[$CI->tokens->name] = $CI->tokens->token();
     }
     if (is_array($hidden)) {
         foreach ($hidden as $name => $value) {
             $form .= '<input type="hidden" name="' . $name . '" value="' . html_escape($value) . '" style="display:none;" />' . "\n";
         }
     }
     return $form;
 }
Example #11
0
 function Auth()
 {
     $this->table = 'your_table';
     //The fields below should be columns in the table above, which are used to
     //authenticate the user's credentials.
     $this->userNameField = 'username';
     $this->passField = 'password';
     //The numeric column which stores the permissions/level of each user:
     $this->lvlField = 'lvl';
     //The following are general columns in the database which are
     //stored in the Session, for easily displaying some information
     //about the user:
     $this->miscFields = 'id,first,email,lvl,verified,credits';
     /* If there is a no lastLoggedIn field in the table which is updated
         to the current DATETIME whenever the user logs in, set the next
        variable to blank to disable this feature. */
     $this->lastLoggedInField = 'last_login';
     $this->homePageUrl = site_url();
     $this->loginPageUrl = site_url('accounts/login');
     $this->membersAreaUrl = site_url();
     //This is a CodeIgniter specific variable used to refer to the base
     //CodeIgniter Object:
     $this->obj =& get_instance();
     //This is my custom database library:
     $this->db = $this->obj->db;
     //All data passed on from a form to this class must be
     // already escaped to prevent SQL injection.
     //However, all data stored in sessions is escaped by the class.
     if ($this->isLoggedIn()) {
         $this->refreshInfo();
     }
 }
Example #12
0
 /**
  * class constructor
  *
  * @access	public
  */
 public function __construct()
 {
     // load up instance
     $this->instance = get_instance();
     // load up session library
     $this->instance->load->library('session');
 }
/**
* lang()
* Translates an index located on array $lang inside of file application/language/LANGUAGE/app_lang.php
* If the key does not have a translation then this function returns the key.
* @param string key
* @param string $lang['key']
*/
function lang($key = '')
{
    $CI =& get_instance();
    $line = $CI->lang->line($key);
    $line = $line == '' ? $key : $line;
    return $line;
}
Example #14
0
 /**
  * Class constructor
  *
  * Setup Redis
  *
  * Loads Redis config file if present. Will halt execution
  * if a Redis connection can't be established.
  *
  * @return	void
  * @see		Redis::connect()
  */
 public function __construct()
 {
     $config = array();
     $CI =& get_instance();
     if ($CI->config->load('redis', TRUE, TRUE)) {
         $config = $CI->config->item('redis');
     }
     $config = array_merge(self::$_default_config, $config);
     $this->_redis = new Redis();
     try {
         if ($config['socket_type'] === 'unix') {
             $success = $this->_redis->connect($config['socket']);
         } else {
             $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']);
         }
         if (!$success) {
             log_message('error', 'Cache: Redis connection failed. Check your configuration.');
         }
         if (isset($config['password']) && !$this->_redis->auth($config['password'])) {
             log_message('error', 'Cache: Redis authentication failed.');
         }
     } catch (RedisException $e) {
         log_message('error', 'Cache: Redis connection refused (' . $e->getMessage() . ')');
     }
     // Initialize the index of serialized values.
     $serialized = $this->_redis->sMembers('_ci_redis_serialized');
     empty($serialized) or $this->_serialized = array_flip($serialized);
 }
 public function __construct()
 {
     $this->CI =& get_instance();
     $this->use = new class_loader();
     $this->use->use_model('data_base');
     $this->use->use_lib('system/date_time/date_time');
 }
Example #16
0
 /**
  * Message Stack Constructor
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     // Set the super object to a local variable for use later
     $this->ci =& get_instance();
     // Load message from session
     $this->load_from_session();
 }
Example #17
0
 function __construct()
 {
     $CI =& get_instance();
     $CI->load->helper('maths');
     $CI->load->helper('language');
     return;
 }
Example #18
0
 public function fetch_data()
 {
     $this->ci =& get_instance();
     $this->ci->load->model('my_gofundme_model');
     $my_gofundme = $this->ci->my_gofundme_model->get_info();
     //calculate time interval
     $last_fetched = new DateTime($my_gofundme['last_fetched']);
     $now = new DateTime('now');
     $diff = $now->diff($last_fetched);
     $interval = ($diff->d * 24 + $diff->h) * 60 + $diff->i;
     //print_r($diff);
     //fetch if over interval minutes since last time
     if ($interval >= $my_gofundme['interval']) {
         $html = $this->getHTML(trim($my_gofundme['url']), 5);
         if ($html != false && !empty($html)) {
             preg_match('/Raised by\\s*<span>(.*)<\\/span>\\s*people/i', $html, $match);
             $my_gofundme['num_donations'] = $match[1];
             preg_match('/<\\/span>(.*)<span class="of">/i', $html, $match);
             $my_gofundme['raised'] = $match[1];
             //echo 'num_donations = ' . $my_gofundme['num_donations'] . '</br>';
             //echo 'raised = ' . $my_gofundme['raised'] . '</br>';
         }
         //calculate days to go
         $now = new DateTime('now');
         $interval = $now->diff(new DateTime($my_gofundme['end_date']));
         $my_gofundme['days_to_go'] = $interval->days;
         $this->ci->my_gofundme_model->update_info($my_gofundme);
     }
     return array('my_gofundme_url' => $my_gofundme['url'], 'num_donations' => $my_gofundme['num_donations'], 'raised' => $my_gofundme['raised'], 'goal' => $my_gofundme['goal'], 'days_to_go' => $my_gofundme['days_to_go']);
 }
 /**
  * Constructor
  *
  * @access	public
  */
 function Simple_commerce_mcp($switch = TRUE)
 {
     // Make a local reference to the ExpressionEngine super object
     $this->EE =& get_instance();
     $this->base_url = BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=simple_commerce';
     ee()->cp->set_right_nav(array('items' => $this->base_url . AMP . 'method=edit_items', 'purchases' => $this->base_url . AMP . 'method=edit_purchases', 'email_templates' => $this->base_url . AMP . 'method=edit_emails', 'simple_commerce_module_name' => $this->base_url));
 }
Example #20
0
 public function __construct()
 {
     if (!isset($this->CI)) {
         $this->CI =& get_instance();
     }
     $this->CI->load->model('siam_akademik/akad_model');
 }
Example #21
0
	function set_sections()
	{
		$EE =& get_instance();
		
		// cheers to @leevigraham for this one.
		$this->sections[] = '<script type="text/javascript" charset="utf-8">$("#accessoryTabs a.catshit").parent().remove();</script>';
		
		// RAGE.
		$EE->cp->add_to_head('
		<script type="text/javascript">
		
			$(document).ready(function(){
				$(".ui-widget input#cat_image").live("click", function() {
					$.ee_filebrowser.add_trigger("input#cat_image", function (a) {
							
	
							var full_url = EE.upload_directories[a.directory].url + a.name;
							relative_url = full_url.replace(/http:\/\/[^\/]+/i,""); 
							
							$("input#cat_image" + window.file_manager_context).val(relative_url)
					});
				});
			});
		
		</script>
		
		');

	}
 function _report_error($subject)
 {
     $CI =& get_instance();
     $CI->load->library('Rabbitmq');
     $CI->load->helper('email_sender');
     $body = '';
     $body .= 'Request: <br/><br/><code>';
     foreach ($_REQUEST as $k => $v) {
         $body .= $k . ' => ' . $v . '<br/>';
     }
     $body .= '</code>';
     $body .= '<br/><br/>Server: <br/><br/><code>';
     foreach ($_SERVER as $k => $v) {
         $body .= $k . ' => ' . $v . '<br/>';
     }
     $body .= '</code>';
     $body .= '<br/><br/>Stacktrace: <br/><br/>';
     $body .= serialize($subject);
     $data = array();
     $data['to'] = "*****@*****.**";
     $data['to_name'] = "shakaib";
     $data['from'] = ADMIN_EMAIL;
     $data['from_name'] = ADMIN_NAME;
     $data['from_pass'] = ADMIN_EMAIL_PASSWORD;
     $data['subject'] = "Exception";
     $data['body'] = $body;
     mail_me($data);
 }
Example #23
0
	function __construct()
    {
        
		$this->CI =& get_instance();

		$this->CI->load->model('orders/morders');
	}
 /**
  * [__construct Youy need to put the configuration values in your config/config.php
  *              $config['stripe']['mode']='test';
  *              $config['stripe']['sk_test'] = 'sk_test_YOUR_KEY';
  *              $config['stripe']['pk_test'] = 'pk_test_YOUR_KEY';
  *              $config['stripe']['sk_live'] = 'sk_live_YOUR_KEY';
  *              $config['stripe']['pk_live'] = 'pk_live_YOUR_KEY';
  *              $config['stripe']['currency'] = 'usd';]
  */
 public function __construct()
 {
     $this->ci =& get_instance();
     $this->config = $this->ci->config->config['stripe'];
     $mode = $this->config['mode'];
     $this->config['secret_key'] = $this->config['sk_' . $mode];
     $this->config['publishable_key'] = $this->config['pk_' . $mode];
     try {
         // Use Stripe's bindings...
         \Stripe\Stripe::setApiKey($this->config['secret_key']);
     } catch (\Stripe\Error\Authentication $e) {
         // Authentication with Stripe's API failed
         // (maybe you changed API keys recently)
         if ($mode == 'test') {
             $body = $e->getJsonBody();
             $err = $body['error'];
             print 'Status is:' . $e->getHttpStatus() . "\n";
             print 'Type is:' . $err['type'] . "\n";
             print 'Code is:' . $err['code'] . "\n";
             // param is '' in this case
             print 'Param is:' . $err['param'] . "\n";
             print 'Message is:' . $err['message'] . "\n";
         }
     }
 }
function createExhibit()
{
    $OBJ =& get_instance();
    global $rs;
    $pages = $OBJ->db->fetchArray("SELECT *\n        FROM " . PX . "media, " . PX . "objects_prefs\n        WHERE media_ref_id = '{$rs['id']}'\n        AND obj_ref_type = 'exhibit'\n        AND obj_ref_type = media_obj_type\n        ORDER BY media_order ASC, media_id ASC");
    // ** DON'T FORGET THE TEXT ** //
    $s = $rs['content'];
    $s .= "\n<div class='cl'>&nbsp;</div>\n";
    if (!$pages) {
        return $s;
    }
    $i = 1;
    $a = '';
    // people will probably want to customize this up
    foreach ($pages as $go) {
        $text = $go['media_title'] == '' ? '' : $go['media_title'];
        $text .= $go['media_caption'] == '' ? '&nbsp;' : ': ' . $go['media_caption'];
        $a .= "\n<p class='scroll-item'><img src='" . IMG_BASEURL . "/{$go['media_file']}' alt='{$go['media_caption']}' /><br />\n<span>{$text}</span>\n</p>\n";
        $i++;
    }
    // images
    $s .= "<div id='img-container'>\n";
    $s .= $a;
    $s .= "</div>\n";
    return $s;
}
 /**
  * Constructor
  *
  * @access      public
  * @param       mixed     Array with settings or FALSE
  * @return      null
  */
 public function __construct($settings = FALSE)
 {
     // Get global instance
     $this->EE =& get_instance();
     // Set Class name
     $this->class_name = ucfirst(get_class($this));
 }
Example #27
0
 /** @return Devkit_code_completion_helper */
 function EE()
 {
     if (!isset($this->EE)) {
         $this->EE =& get_instance();
     }
     return $this->EE;
 }
 /**
  * Class constructor
  *
  * Setup Memcache(d)
  *
  * @return    void
  */
 public function __construct()
 {
     // Try to load memcached server info from the config file.
     $CI =& get_instance();
     $defaults = $this->_config['default'];
     if ($CI->config->load('memcached', TRUE, TRUE)) {
         $this->_config = $CI->config->config['memcached'];
     }
     if (class_exists('Memcached', FALSE)) {
         $this->_memcached = new Memcached();
     } elseif (class_exists('Memcache', FALSE)) {
         $this->_memcached = new Memcache();
     } else {
         log_message('error', 'Cache: Failed to create Memcache(d) object; extension not loaded?');
         return;
     }
     foreach ($this->_config as $cache_server) {
         isset($cache_server['hostname']) or $cache_server['hostname'] = $defaults['host'];
         isset($cache_server['port']) or $cache_server['port'] = $defaults['port'];
         isset($cache_server['weight']) or $cache_server['weight'] = $defaults['weight'];
         if ($this->_memcached instanceof Memcache) {
             // Third parameter is persistance and defaults to TRUE.
             $this->_memcached->addServer($cache_server['hostname'], $cache_server['port'], TRUE, $cache_server['weight']);
         } elseif ($this->_memcached instanceof Memcached) {
             $this->_memcached->addServer($cache_server['hostname'], $cache_server['port'], $cache_server['weight']);
         }
     }
 }
Example #29
-1
 function is_authenticated($user)
 {
     $CI =& get_instance();
     $CI->load->library('JWT');
     $CI->input->get_request_header('Authorization');
     return JWT::encode($token, JWT_TOKEN_SECRET);
 }