예제 #1
11
 function html_purify($dirty_html, $config = FALSE)
 {
     require_once APPPATH . 'third_party/htmlpurifier-4.6.0-standalone/HTMLPurifier.standalone.php';
     if (is_array($dirty_html)) {
         foreach ($dirty_html as $key => $val) {
             $clean_html[$key] = html_purify($val, $config);
         }
     } else {
         $ci =& get_instance();
         switch ($config) {
             //settings for rhe WYSIWYG
             case 'comment':
                 $config = HTMLPurifier_Config::createDefault();
                 $config->set('Core.Encoding', $ci->config->item('charset'));
                 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
                 $config->set('HTML.Allowed', 'a[href|title],img[title|src|alt],em,strong,cite,blockquote,code,ul,ol,li,dl,dt,dd,p,br,h1,h2,h3,h4,h5,h6,span,*[style]');
                 $config->set('AutoFormat.AutoParagraph', TRUE);
                 $config->set('AutoFormat.Linkify', TRUE);
                 $config->set('AutoFormat.RemoveEmpty', TRUE);
                 break;
             case FALSE:
                 $config = HTMLPurifier_Config::createDefault();
                 $config->set('Core.Encoding', $ci->config->item('charset'));
                 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
                 break;
             default:
                 show_error('The HTMLPurifier configuration labeled "' . htmlentities($config, ENT_QUOTES, 'UTF-8') . '" could not be found.');
         }
         $purifier = new HTMLPurifier($config);
         $clean_html = $purifier->purify($dirty_html);
     }
     return $clean_html;
 }
예제 #2
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);
 }
예제 #3
2
 function __construct()
 {
     parent::__construct();
     if (!$this->require_min_level(9)) {
         show_error('You do not have access to view this resource', '403');
     }
 }
예제 #4
1
 protected function _render_query()
 {
     if (empty($this->_config)) {
         show_error("No están definidas las configuraciones para el elemento select_fk: {$this->_name}");
     }
     //            array(
     //            * "table_fk" => La tabla de donde tomar los datos
     //            * "value_field" => El campo que se usará para el option.value [default = 'id_{table}']
     //            * "text_field" => El campo que se usará para option.text [default = 'nombre']
     //            * "where" => Los filtros que se usarán en $this->db->where($where)
     //            * "query" => Un query SQL por si es una query más compleja
     //            * y no alcanzan con los parámetros anteriores para especificar
     //            * los resultados.
     //            * )
     $array_to_render = "<?php " . PHP_EOL;
     $array_to_render .= "\$config_{$this->_name} = array(" . PHP_EOL;
     if (!empty($this->_config["query"])) {
         $query = str_ireplace("'", '"', $this->_config["query"]);
         $array_to_render .= "'query' => '{$query}'," . PHP_EOL;
     } else {
         $where = str_ireplace("'", '"', $this->_config["where"]);
         $array_to_render .= "'table' => '{$this->_config["table_fk"]}'," . PHP_EOL;
         $array_to_render .= "'value_field' => '{$this->_config["value_field"]}'," . PHP_EOL;
         $array_to_render .= "'text_field' => '{$this->_config["text_field"]}'," . PHP_EOL;
         $array_to_render .= "'where' => '{$where}'," . PHP_EOL;
     }
     $array_to_render .= ");" . PHP_EOL;
     $array_to_render .= '$rows = options_select_fk($config_' . $this->_name . ');' . PHP_EOL;
     $array_to_render .= "?>" . PHP_EOL;
     return $array_to_render;
 }
예제 #5
1
 function index()
 {
     $usersListQuery = $this->usersModel->getLastXUsers(6);
     $footerWidebarData['usersListArr'] = $usersListQuery;
     $contactStatus['contactStatus'] = false;
     if ($this->input->post('submit')) {
         $name = (string) $this->input->post('name', TRUE);
         $email = (string) $this->input->post('email', TRUE);
         $subject = (string) $this->input->post('subject', TRUE);
         $message = (string) $this->input->post('message', TRUE);
         if (empty($name) or empty($email) or empty($subject) or empty($message)) {
             show_error("Toate campurile sunt obligatorii. Te rog sa completezi toate campurile si sa incerci din nou.");
         }
         if (!valid_email($email)) {
             show_error("Adresa de mail nu este valida.");
         }
         $config['protocol'] = 'sendmail';
         $this->email->initialize($config);
         $this->email->from($email, $name);
         $this->email->to('*****@*****.**');
         $this->email->subject('NoiseStats Contact - ' . $subject);
         $this->email->message($message);
         $this->email->send();
         $contactStatus['contactStatus'] = true;
         $this->load->view('header');
         $this->load->view('contact', $contactStatus);
         $this->load->view('footer_widebar', $footerWidebarData);
         $this->load->view('footer');
     } else {
         $this->load->view('header');
         $this->load->view('contact', $contactStatus);
         $this->load->view('footer_widebar', $footerWidebarData);
         $this->load->view('footer');
     }
 }
예제 #6
0
 /**
  * Load Extension
  *
  * This function loads the specified extension.
  *
  * @access	public
  * @param	array	$extensions	specified extension
  * @return	void
  */
 public function extension($extensions = array())
 {
     if (!is_array($extensions)) {
         $extensions = array($extensions);
     }
     foreach ($extensions as $extension) {
         $plugin = strtolower(str_replace('.php', '', $extension));
         // If the extension is already loaded, continue on.
         if (isset($this->_ci_extensions[$extension])) {
             continue;
         }
         // Attempt to load the extension.
         if (file_exists($extension_path = sprintf(APPPATH . 'extend/%s/main.php', $extension))) {
             include $extension_path;
         } else {
             if (file_exists($extension_path = sprintf(BASEPATH . 'extend/%s/main.php', $extension))) {
                 include $extension_path;
             } else {
                 show_error(sprintf('Unable to load the requested file: extend/%s/main.php', $extension));
             }
         }
         // Initialize the plugin and log it.
         $this->_ci_extensions[$extension] = new $plugin();
         log_message('debug', sprintf('Extension loaded: %s', $plugin));
     }
 }
예제 #7
0
	/**
	 * Load the EE config file and set the initial values
	 *
	 * @access	private
	 * @return	void
	 */
	function _initialize()
	{
		// Fetch the config file
		if ( ! @include($this->config_path))
		{
			show_error('Unable to locate your config file (expressionengine/config/config.php)');
		}

		// Prior to 2.0 the config array was named $conf.  This has changed to $config for 2.0
		if (isset($conf))
		{
			$config = $conf;
		}
		
		// Is the config file blank?  If not, we bail out since EE hasn't been installed
		if ( ! isset($config) OR count($config) == 0)
		{
			return FALSE;
		}

		// Add the EE config data to the master CI config array
		foreach ($config as $key => $val)
		{
			$this->set_item($key, $val);
		}
		unset($config);

		// Set any config overrides.  These are the items that used to be in 
		// the path.php file, which are now located in the main index file
		$this->_set_overrides($this->config);
		
		// Set the default_ini data, used by the sites feature
		$this->default_ini = $this->config;
	}
예제 #8
0
 public static function get_pages($lang = FALSE)
 {
     if ($lang == FALSE) {
         $lang = Settings::get_lang();
     }
     $pages = self::$ci->page_model->get_lang_list(false, $lang);
     // Should never be displayed : no pages are set.
     if (empty($pages)) {
         show_error('Internal error : <b>No pages found.</b><br/>Solution: <b>Create at least one online page.</b>', 500);
         exit;
     }
     /* Spread authorizations from parents pages to chidrens.
      * This adds the group ID to the childrens pages of a protected page
      * If you don't want this, just uncomment this line.
      */
     if (Connect()->logged_in()) {
         self::$user = Connect()->get_current_user();
     }
     self::$ci->page_model->spread_authorizations($pages);
     // Filter pages regarding the authorizations
     $pages = array_values(array_filter($pages, array(__CLASS__, '_filter_pages_authorization')));
     // Set all abolute URLs one time, for perf.
     self::init_absolute_urls($pages, $lang);
     return $pages;
 }
예제 #9
0
파일: Email.php 프로젝트: vigm/advancedMD
 public function __construct()
 {
     parent::__construct();
     if (!ee()->cp->allowed_group('can_access_comm')) {
         show_error(lang('unauthorized_access'));
     }
 }
예제 #10
0
function read_config($file, $fail_gracefully=TRUE) 
{
	$file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
	
	if ( ! file_exists(APPPATH.'config/'.$file.EXT))
	{
		if ($fail_gracefully === TRUE)
		{
			return FALSE;
		}
		show_error('The configuration file '.$file.EXT.' does not exist.');
	}
	
	include(APPPATH.'config/'.$file.EXT);

	if ( ! isset($config) OR ! is_array($config))
	{
		if ($fail_gracefully === TRUE)
		{
			return FALSE;
		}
		show_error('Your '.$file.EXT.' file does not appear to contain a valid configuration array.');
	}
	
	return $config;
}
예제 #11
0
 /**
  * Constructor
  */
 function __construct()
 {
     log_message('debug', 'Amazon SES Class Initialized');
     $this->_ci =& get_instance();
     // Load all config items
     $this->_ci->load->config('amazon_ses');
     $this->_access_key = $this->_ci->config->item('amazon_ses_access_key');
     $this->_secret_key = $this->_ci->config->item('amazon_ses_secret_key');
     $this->_cert_path = $this->_ci->config->item('amazon_ses_cert_path');
     $this->from = $this->_ci->config->item('amazon_ses_from');
     $this->from_name = $this->_ci->config->item('amazon_ses_from_name');
     $this->charset = $this->_ci->config->item('amazon_ses_charset');
     $this->_mime_boundary = $this->_ci->config->item('amazon_ses_mime_boundary');
     $this->crlf = "\n";
     // Check whether reply_to is not set
     if ($this->_ci->config->item('amazon_ses_reply_to') === FALSE) {
         $this->reply_to = $this->_ci->config->item('amazon_ses_from');
     } else {
         $this->reply_to = $this->_ci->config->item('amazon_ses_reply_to');
     }
     // Is our certificate path valid?
     if (!file_exists($this->_cert_path)) {
         show_error('CA root certificates not found. Please <a href="http://curl.haxx.se/ca/cacert.pem">download</a> a bundle of public root certificates and/or specify its location in config/amazon_ses.php');
     }
     // Load Phil's cURL library as a Spark or the normal way
     if (method_exists($this->_ci->load, 'spark')) {
         $this->_ci->load->spark('curl/1.0.0');
     }
     $this->_ci->load->library('curl');
 }
예제 #12
0
 private function checkAuth($method)
 {
     $auth = "";
     if ($this->input->server('HTTP_X_AUTHORIZATION')) {
         $auth = $this->input->server('HTTP_X_AUTHORIZATION');
     }
     $request_date = "";
     if ($this->input->server('HTTP_DATE')) {
         $request_date = $this->input->server('HTTP_DATE');
     }
     $query_string = "";
     if ($this->input->server('QUERY_STRING')) {
         $query_string = $this->input->server('QUERY_STRING');
     }
     if (empty($request_date) || !$this->checkDate($request_date)) {
         $error_code = "403";
         $error_message = $error_code . " Date is invalid";
         show_error($error_message, $error_code);
         exit;
     }
     if (empty($auth) || !isAuthorized($auth, $request_date, $method, $query_string)) {
         $error_code = "401";
         $error_message = $error_code . " Unauthorized";
         show_error($error_message, $error_code);
         exit;
     }
 }
예제 #13
0
파일: form.php 프로젝트: josev814/hero
 function submit()
 {
     $form_id = $this->input->post('form_id');
     if (empty($form_id)) {
         die(show_error('You did not specify a "form_id" in your form post.'));
     }
     $this->load->model('forms/form_model');
     $form = $this->form_model->get_form($form_id);
     if (empty($form)) {
         die(show_error('This form is invalid.'));
     }
     // do they have permissions?
     if (!$this->user_model->in_group($form['privileges'])) {
         die(show_error('Invalid permissions'));
     }
     // form validation and processing
     $this->load->library('custom_fields/form_builder');
     $this->form_builder->build_form_from_group($form['custom_field_group_id']);
     $recaptchaUserResponse = $this->CI->input->post('g-recaptcha-response');
     $this->CI->load->model('recaptcha_model');
     $recaptchaValidation = $this->recaptcha_model->recaptchaValidation($recaptchaUserResponse);
     if ($this->form_builder->validate_post() === FALSE || $recaptchaValidation == false) {
         $this->session->set_flashdata('validation_errors', $this->form_builder->validation_errors());
         $values = query_value_encode(serialize($this->form_builder->post_to_array($form['custom_field_group_id'])));
         return redirect($form['url_path'] . '?errors=true&values=' . $values);
     }
     // we validated!  let's make the post
     $custom_fields = $this->form_builder->post_to_array($form['custom_field_group_id']);
     $this->form_model->new_response($form['id'], $this->user_model->logged_in() ? $this->user_model->get('id') : 0, $custom_fields);
     redirect($form['redirect']);
 }
 public function __construct()
 {
     parent::__construct();
     if (!$this->auth->is_allowed_to('manage_categories', 'all')) {
         show_error('You do not have permission to view this part of the website.');
     }
 }
예제 #15
0
 public function __construct()
 {
     parent::__construct();
     if (!$this->ion_auth->logged_in()) {
         redirect('auth/login', 'refresh');
     } elseif (!$this->ion_auth->is_admin()) {
         return show_error('You must be an administrator to view this page.');
     } else {
         /* Load */
         $this->load->config('admin/dp_config');
         $this->load->library('admin/page_title');
         $this->load->library('admin/breadcrumbs');
         $this->load->model('admin/core_model');
         $this->load->helper('menu');
         $this->lang->load(['admin/main_header', 'admin/main_sidebar', 'admin/footer', 'admin/actions']);
         /* Load library function  */
         $this->breadcrumbs->unshift(0, $this->lang->line('menu_dashboard'), 'admin/dashboard');
         /* Data */
         $this->data['title'] = $this->config->item('title');
         $this->data['title_lg'] = $this->config->item('title_lg');
         $this->data['title_mini'] = $this->config->item('title_mini');
         $this->data['admin_prefs'] = $this->prefs_model->admin_prefs();
         $this->data['user_login'] = $this->prefs_model->user_info_login($this->ion_auth->user()->row()->id);
         if ($this->router->fetch_class() == 'dashboard') {
             $this->data['dashboard_alert_file_install'] = $this->core_model->get_file_install();
             $this->data['header_alert_file_install'] = NULL;
         } else {
             $this->data['dashboard_alert_file_install'] = NULL;
             $this->data['header_alert_file_install'] = NULL;
         }
     }
 }
예제 #16
0
 function Error($code, $additional_text = FALSE)
 {
     if (!$code) {
         $this->SystemError('Error code not passed to function.');
     }
     $errors = array('1000' => 'Invalid request.', '1001' => 'Unable to authenticate.', '1002' => 'Invalid request type.', '1004' => 'Required fields are missing for this request', '1005' => 'Gateway type is required.', '1006' => 'Invalid format passed.  Acceptable formats: xml, php, and json.', '1007' => 'Invalid country.', '1008' => 'Invalid email address', '1009' => 'Unspecified error in request.', '1010' => 'A secure SSL connection is required.', '1011' => 'Invalid timezone.', '1012' => 'For USA and Canada addresses, a valid 2-letter state/province abbreviation is required.', '2000' => 'Client is not authorized to create new clients.', '2001' => 'Invalid External API.', '2002' => 'Username is already in use.', '2003' => 'Password must be greater than 5 characters in length.', '2004' => 'Invalid client ID.', '2005' => 'Error contacting payment gateway.', '2006' => 'Only administrators can create new Service Provider accounts.', '2007' => 'Invalid client_type.', '3000' => 'Invalid gateway ID for this client.', '3001' => 'Gateway ID is required.', '3002' => 'Client ID is required.', '4000' => 'Invalid customer ID.', '4001' => 'Invalid charge ID.', '5000' => 'A valid Recurring ID is required.', '5001' => 'Start date cannot be in the past.', '5002' => 'End date cannot be in the past', '5003' => 'End date must be later than start date.', '5004' => 'A customer ID or cardholder name must be supplied.', '5005' => 'Error creating customer profile.', '5006' => 'Error creating customer payment profile.', '5007' => 'Dates must be valid and in YYYY-MM-DD format.', '5008' => 'Invalid credit card number', '5009' => 'Invalid amount.', '5010' => 'Recurring details are required.', '5011' => 'Invalid interval.', '5012' => 'A valid description is required.', '5014' => 'Error cancelling subscription', '5015' => 'You cannot modify the plan_id via UpdateRecurring.  You must use ChangeRecurringPlan to upgrade or downgrade a recurring charge.', '5016' => 'Recurring billings cannot be updated for this gateway. You must either (a) cancel this existing subscription and create a new one or (b) go and update the recurring transaction at your merchant control panel.', '5017' => 'Gateway is disabled.', '5018' => 'This gateway requires customer information to be processed.  Please include a customer_id of an existing customer or a customer node with new customer information in your request.', '5019' => 'This gateway requires the purchasing customer\'s IP address.  Please include a customer_ip_address node in your request.', '5020' => 'This gateway does not allow refunds via the API.', '5021' => 'Only active gateways can be updated with new credit card details.', '5022' => 'This subscription is free - updating credit card details is futile.', '5023' => 'The new gateway you have chosen requires customer information but this customer record currently doesn\'t exist.  Please use UpdateCustomer to add full customer details for this user before calling UpdateCreditCard.', '5024' => 'Only non-external gateways allow for a paid initial charge but free recurring charge.', '5025' => 'Subscriptions with a paid initial charge but free recurring charge must start immediately.', '6000' => 'A valid Charge ID is required.', '6001' => 'A valid Customer ID is required.', '6002' => 'A valid Recurring ID is required', '6003' => 'Nothing to update.', '6005' => 'Error updating Recurring details.', '6006' => 'A valid Plan ID is required.', '7000' => 'Invalid plan type.', '7001' => 'Invalid Plan ID.', '7002' => 'Invalid Free Trial amount.', '7003' => 'Invalid occurrences amount.', '8000' => 'Invalid Email Trigger.', '8001' => 'A valid Email ID is required.', '8002' => 'Email body must be encoded.');
     $error_array = array('error' => $code, 'error_text' => $errors[$code]);
     if ($additional_text != FALSE) {
         $error_array['error_text'] .= '  ' . $additional_text;
     }
     // if this isn't a control panel call, it's an API call
     // and we must report the error as such
     if (!defined("_CONTROLPANEL")) {
         return $this->FormatResponse($error_array);
     } elseif (defined("_INSTALLER")) {
         show_error($error_array['error_text']);
         die;
     } else {
         // let's format the error slightly
         $CI =& get_instance();
         $CI->navigation->PageTitle('System Error');
         $view = $CI->load->view(branded_view('cp/error.php'), $error_array, true);
         return $view;
     }
 }
예제 #17
0
 /**
  * Unique Add
  *
  * @access	public
  * @param	string	the table name
  * @return	bool
  */
 function add_unique($table = '', $field = array())
 {
     if ($table == '') {
         show_error('A table name is required for that operation.');
     }
     foreach ($field as $v) {
         if (!is_array($v) || !array_key_exists('unique_table', $v) || !array_key_exists('field', $v)) {
             continue;
         }
         $field = $v['field'];
         $unique_table = $v['unique_table'];
         if (is_array($field)) {
             $fields = '';
             foreach ($field as $name) {
                 $fields .= "`{$name}`,";
             }
             $fields = trim($fields, ",");
             if (empty($fields)) {
                 return '';
             }
         } else {
             $fields = $field;
         }
         $sql = "ALTER TABLE " . $this->db->_protect_identifiers($table) . " ADD CONSTRAINT " . $this->db->_protect_identifiers($unique_table) . " UNIQUE " . "(" . $this->db->_protect_identifiers($fields) . ")";
         if ($this->db->query($sql) === FALSE) {
             return FALSE;
         }
     }
     return TRUE;
 }
 public function __construct($config = array())
 {
     // Only run this constructor on main library load
     if (get_parent_class($this) !== FALSE) {
         return;
     }
     foreach ($config as $key => $val) {
         $this->{'_' . $key} = $val;
     }
     log_message('debug', 'Migrations class initialized');
     // Are they trying to use migrations while it is disabled?
     if ($this->_migration_enabled !== TRUE) {
         show_error('Migrations has been loaded but is disabled or set up incorrectly.');
     }
     // If not set, set it
     $this->_migration_path == '' and $this->_migration_path = APPPATH . 'migrations/';
     // Add trailing slash if not set
     $this->_migration_path = rtrim($this->_migration_path, '/') . '/';
     // Load migration language
     $this->lang->load('migration');
     // They'll probably be using dbforge
     $this->load->dbforge();
     // If the migrations table is missing, make it
     if (!$this->db->table_exists('migrations')) {
         $this->dbforge->add_field(array('version' => array('type' => 'INT', 'constraint' => 3)));
         $this->dbforge->create_table('migrations', TRUE);
         $this->db->insert('migrations', array('version' => 0));
     }
 }
예제 #19
0
 function create()
 {
     if (isset($_POST['id'])) {
         $posted = $this->_process();
         // set publish status to no if you do not have the ability to publish
         if (!$this->fuel_auth->has_permission($this->permission, 'publish')) {
             $posted['published'] = 'no';
         }
         // reset dup id
         if ($_POST['id'] == 'dup') {
             $_POST['id'] = '';
             $_POST['location'] = '';
         } else {
             if ($id = $this->model->save($posted)) {
                 if (empty($id)) {
                     show_error('Not a valid ID returned to save layout variables');
                 }
                 $this->_process_uploads();
                 if (!$this->fuel_auth->has_permission($this->permission, 'publish')) {
                     unset($_POST['published']);
                 }
                 $this->_save_page_vars($id, $posted);
                 $data = $this->model->find_one_array(array($this->model->table_name() . '.id' => $id));
                 if (!empty($data)) {
                     $msg = lang('module_created', $this->module_name, $data[$this->display_field]);
                     redirect(fuel_uri('pages/edit/' . $id));
                 }
             }
         }
     }
     $vars = $this->_form();
     $this->_render('pages/page_create_edit', $vars);
 }
예제 #20
0
 /**
  * Load a language file
  *
  * @access	public
  * @param	mixed	the name of the language file to be loaded. Can be an array
  * @param	string	the language (english, etc.)
  * @return	mixed
  */
 function load($langfile = '', $idiom = '', $return = FALSE)
 {
     $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)) . '_lang' . EXT;
     if (in_array($langfile, $this->is_loaded, TRUE)) {
         return;
     }
     if ($idiom == '') {
         $CI =& get_instance();
         $deft_lang = $CI->config->item('language');
         $idiom = $deft_lang == '' ? 'english' : $deft_lang;
     }
     // Determine where the language file is and load it
     if (file_exists(APPPATH . 'language/' . $idiom . '/' . $langfile)) {
         include APPPATH . 'language/' . $idiom . '/' . $langfile;
     } else {
         if (file_exists(BASEPATH . 'language/' . $idiom . '/' . $langfile)) {
             include BASEPATH . 'language/' . $idiom . '/' . $langfile;
         } else {
             show_error('Unable to load the requested language file: language/' . $idiom . '/' . $langfile);
         }
     }
     if (!isset($lang)) {
         log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile);
         return;
     }
     if ($return == TRUE) {
         return $lang;
     }
     $this->is_loaded[] = $langfile;
     $this->language = array_merge($this->language, $lang);
     unset($lang);
     log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
     return TRUE;
 }
예제 #21
0
 /**
  * Load Config File
  *
  * @access	public
  * @param	string	the config file name
  * @return	boolean	if the file was loaded correctly
  */
 function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 {
     $file = $file == '' ? 'config' : str_replace(EXT, '', $file);
     if (in_array($file, $this->is_loaded, TRUE)) {
         return TRUE;
     }
     if (!file_exists(APPPATH . 'config/' . $file . EXT)) {
         if ($fail_gracefully === TRUE) {
             return FALSE;
         }
         show_error('The configuration file ' . $file . EXT . ' does not exist.');
     }
     include APPPATH . 'config/' . $file . EXT;
     if (!isset($config) or !is_array($config)) {
         if ($fail_gracefully === TRUE) {
             return FALSE;
         }
         show_error('Your ' . $file . EXT . ' file does not appear to contain a valid configuration array.');
     }
     if ($use_sections === TRUE) {
         if (isset($this->config[$file])) {
             $this->config[$file] = array_merge($this->config[$file], $config);
         } else {
             $this->config[$file] = $config;
         }
     } else {
         $this->config = array_merge($this->config, $config);
     }
     $this->is_loaded[] = $file;
     unset($config);
     log_message('debug', 'Config file loaded: config/' . $file . EXT);
     return TRUE;
 }
예제 #22
0
 /**
  * @todo Document this please.
  */
 public function __construct()
 {
     parent::__construct();
     // Not logged in or not an admin and don't have permission to see files
     if (!$this->current_user or $this->current_user->group !== 'admin' and (!isset($this->permissions['files']) or !isset($this->permissions['files']['wysiwyg']))) {
         $this->load->language('files/files');
         show_error(lang('files:no_permissions'));
     }
     ci()->admin_theme = $this->theme_m->get_admin();
     // Using a bad slug? Weak
     if (empty($this->admin_theme->slug)) {
         show_error('This site has been set to use an admin theme that does not exist.');
     }
     // Make a constant as this is used in a lot of places
     defined('ADMIN_THEME') or define('ADMIN_THEME', $this->admin_theme->slug);
     // Set the location of assets
     Asset::add_path('module', APPPATH . 'modules/wysiwyg/');
     Asset::add_path('theme', $this->admin_theme->web_path . '/');
     Asset::set_path('theme');
     $this->load->library('files/files');
     $this->lang->load('files/files');
     $this->lang->load('wysiwyg');
     $this->lang->load('buttons');
     $this->template->set_theme(ADMIN_THEME)->set_layout('wysiwyg', 'admin')->enable_parser(false)->append_css('module::wysiwyg.css')->append_css('jquery/ui-lightness/jquery-ui.css')->append_js('jquery/jquery.js')->append_js('jquery/jquery-ui.min.js')->append_js('plugins.js')->append_js('module::wysiwyg.js');
 }
예제 #23
0
파일: comment.php 프로젝트: jelek92/Zebra
 /**
  * Edit a singular comment
  * 
  * @param  integer $comment_id Comment to view
  * @return void
  */
 public function edit($comment_id)
 {
     $comment = $this->comment_model->get($comment_id);
     $user_id = current_user_id();
     // Make sure the comment exists
     if ($comment) {
         // Are we an admin or have permission to edit comments?
         if (is_admin() or user_can('edit_own_comments')) {
             // Are we an admin or the owner of the comment itself?
             if (is_admin() || $comment->user_id == $user_id) {
                 // Run form validation
                 if ($this->form_validation->run('edit_comment') == FALSE) {
                     $this->data['comment'] = $comment;
                     $this->parser->parse('edit_comment', $this->data);
                 } else {
                     $update = $this->comment_model->update_comment($comment->id, $comment->story_id, $user_id, $comment->parent_id, $this->input->post('comment'));
                     $this->parser->parse('edit_comment', $this->data);
                 }
             } else {
                 show_error("You do not have permission to edit this comment.", 500);
             }
         } else {
             show_error("You do not have permission to edit this comment.", 500);
         }
     } else {
         show_error("That comment doesn't exist", 404);
     }
 }
예제 #24
0
 function __construct()
 {
     parent::__construct();
     //判断关闭
     if ($this->config->item('site_close') == 'off') {
         show_error($this->config->item('site_close_msg'), 500, '网站关闭');
     }
     //载入前台模板
     $this->load->set_front_theme($this->config->item('themes'));
     //判断安装
     $file = FCPATH . 'install.lock';
     if (!is_file($file)) {
         redirect(site_url('install'));
     }
     $this->load->database();
     //网站设定
     $data['items'] = $this->db->get('settings')->result_array();
     $data['settings'] = array('site_name' => $data['items'][0]['value'], 'welcome_tip' => $data['items'][1]['value'], 'short_intro' => $data['items'][2]['value'], 'show_captcha' => $data['items'][3]['value'], 'site_run' => $data['items'][4]['value'], 'site_stats' => $data['items'][5]['value'], 'site_keywords' => $data['items'][6]['value'], 'site_description' => $data['items'][7]['value'], 'money_title' => $data['items'][8]['value'], 'per_page_num' => $data['items'][9]['value'], 'logo' => $this->config->item('logo'));
     //用户相关信息
     if ($this->session->userdata('uid')) {
         $userinfo = $this->db->select('notices,messages_unread')->where('uid', $this->session->userdata('uid'))->get('users')->row_array();
         $data['myinfo'] = array('uid' => $this->session->userdata('uid'), 'username' => $this->session->userdata('username'), 'avatar' => $this->session->userdata('avatar'), 'group_type' => $this->session->userdata('group_type'), 'gid' => $this->session->userdata('gid'), 'group_name' => $this->session->userdata('group_name'), 'is_active' => $this->session->userdata('is_active'), 'favorites' => $this->session->userdata('favorites'), 'follows' => $this->session->userdata('follows'), 'credit' => $this->session->userdata('credit'), 'notices' => @$userinfo['notices'], 'messages_unread' => @$userinfo['messages_unread'], 'lastpost' => $this->session->userdata('lastpost'));
     }
     //获取二级目录
     $data['base_folder'] = $this->config->item('base_folder');
     //底部菜单(单页面)
     $this->load->model('page_m');
     $data['page_links'] = $this->page_m->get_page_menu(10, 0);
     //模板目录
     $data['themes'] = base_url('static/' . $this->config->item('themes') . '/');
     //全局输出
     $this->load->vars($data);
 }
예제 #25
0
파일: Migrate.php 프로젝트: padideIt/wall
 public function index()
 {
     $this->load->library('migration');
     if ($this->migration->current() === FALSE) {
         show_error($this->migration->error_string());
     }
 }
예제 #26
0
 function MY_Controller()
 {
     parent::Controller();
     // Make sure we have the user module
     if (!is_module('users')) {
         show_error('The user module is missing.');
     } else {
         // Load the user model and get user data
         $this->load->module_model('users', 'users_m');
         $this->load->module_library('users', 'user_lib');
         $this->data->user =& $this->user_lib->user_data;
     }
     // Work out module, controller and method and make them accessable throught the CI instance
     $this->module = str_replace(array('modules/', '/'), '', $this->matchbox->fetch_module());
     $this->controller = strtolower(get_class($this));
     $s = $this->uri->rsegment_array();
     $n = array_search($this->controller, $s);
     $this->method = $this->uri->rsegment($n + 1);
     // Get meta data for the module
     $this->module_data = $this->modules_m->getModule($this->module);
     // Make them available to all layout files
     $this->data->module_data =& $this->module_data;
     $this->data->module =& $this->module;
     $this->data->controller =& $this->controller;
     $this->data->method =& $this->method;
 }
예제 #27
0
파일: mkitem.php 프로젝트: sdoney/nas4free
function make_item($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $mkname = $GLOBALS['__POST']["mkname"];
    $mktype = $GLOBALS['__POST']["mktype"];
    $mkname = basename(stripslashes($mkname));
    if ($mkname == "") {
        show_error($GLOBALS["error_msg"]["miscnoname"]);
    }
    $new = get_abs_item($dir, $mkname);
    if (@file_exists($new)) {
        show_error($mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
    }
    if ($mktype != "file") {
        $ok = @mkdir($new, 0777);
        $err = $GLOBALS["error_msg"]["createdir"];
    } else {
        $ok = @touch($new);
        $err = $GLOBALS["error_msg"]["createfile"];
    }
    if ($ok === false) {
        show_error($err);
    }
    header("Location: " . make_link("list", $dir, NULL));
}
예제 #28
0
 function load($tpl_view, $body_view = null, $data = null)
 {
     if (!is_null($body_view)) {
         if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view)) {
             $body_view_path = $tpl_view . '/' . $body_view;
         } else {
             if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view . '.php')) {
                 $body_view_path = $tpl_view . '/' . $body_view . '.php';
             } else {
                 if (file_exists(APPPATH . 'views/' . $body_view)) {
                     $body_view_path = $body_view;
                 } else {
                     if (file_exists(APPPATH . 'views/' . $body_view . '.php')) {
                         $body_view_path = $body_view . '.php';
                     } else {
                         show_error('Unable to load the requested file: ' . $tpl_name . '/' . $view_name . '.php');
                     }
                 }
             }
         }
         $body = $this->ci->load->view($body_view_path, $data, TRUE);
         if (is_null($data)) {
             $data = array('body' => $body);
         } else {
             if (is_array($data)) {
                 $data['body'] = $body;
             } else {
                 if (is_object($data)) {
                     $data->body = $body;
                 }
             }
         }
     }
     $this->ci->load->view('templates/' . $tpl_view, $data);
 }
예제 #29
0
 private function init()
 {
     $dir = APPPATH . "libraries/api/";
     $load = array();
     // Open a known directory, and proceed to read its contents
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($file = readdir($dh)) !== false) {
                 if (!is_dir($dir . $file) and substr($file, -8) == '_api.php') {
                     $load[ucfirst(str_replace('.php', '', $file))] = $file;
                 }
             }
             closedir($dh);
         }
     } else {
         show_error('COMPLETE FAIL, REUPLOAD FILES');
     }
     if (!empty($load)) {
         foreach ($load as $class => $file) {
             $name = str_replace(array('_api', 'xu_', 'Xu_'), '', $class);
             include_once $dir . $file;
             $this->{$name} = new $class();
         }
     }
 }
예제 #30
-1
 public function _remap($method, $args = array())
 {
     //get search method and perform query based on that method
     //in each method check if the args if numeric(>0)
     //if it is perform search on id
     //else search through description,name,first name etc.
     //get results
     //after the switch see if the results returned more than one
     //if they did load the view for that table with the info
     //else load the edit page for that table with the info
     $cfg = $this->config->item('controller_table_conversion');
     $function = 'where';
     //just in case later on we want multiple parameters for the search
     $args = $args[0];
     if ($args > 0) {
         $filters = [$cfg[$method]['id'] => $args];
     } else {
         $function = 'or_like';
         $filters = [];
         if (is_array($cfg[$method]['search_fields'])) {
             foreach ($cfg[$method]['search_fields'] as $field) {
                 $filters[$field] = $args;
             }
         }
     }
     if (is_array($cfg[$method]['view_vars'])) {
         $this->load->model('modules');
         if (isset($cfg[$method]['view_vars']['select']) && is_array($cfg[$method]['view_vars']['select'])) {
             foreach ($cfg[$method]['view_vars']['select'] as $select) {
                 $result = $this->modules->make_select($method, $select['table']);
                 if ($result) {
                     //yay
                 } else {
                     //uh ohhh
                 }
             }
         }
     }
     $this->db->{$function}($filters);
     if (isset($cfg[$method]['join']) && is_array($cfg[$method]['join'])) {
         foreach ($cfg[$method]['join'] as $join) {
             $this->db->join($join['table'], $join['cond'], $join['how']);
         }
     }
     $result = $this->db->get($method);
     if ($result->num_rows() > 0 && isset($cfg[$method]['controller'])) {
         if ($result->num_rows() > 1) {
             $this->data[$cfg[$method]['controller']] = $result->result_array();
             $this->data['content'] = $this->load->view('module/' . rtrim($cfg[$method]['controller'], 's') . '/view', $this->data, true);
             $this->load->view('tpl/structure', $this->data);
         } else {
             $this->data[rtrim($cfg[$method]['controller'], 's')] = array_shift($result->result_array());
             $this->data['content'] = $this->load->view('module/' . rtrim($cfg[$method]['controller'], 's') . '/edit', $this->data, true);
             $this->load->view('tpl/structure', $this->data);
         }
     } else {
         show_error('No data found...');
     }
     //		$result
 }