當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CI函數代碼示例

本文整理匯總了PHP中CI函數的典型用法代碼示例。如果您正苦於以下問題:PHP CI函數的具體用法?PHP CI怎麽用?PHP CI使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CI函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: param

/**
 * Возвращает параметры присланные через адресную строку или $_POST
 *
 * @param  string $name
 * @param bool	$clean		флаг очистки от XSS
 * @param bool	$clean_html	флаг очистки от html кода
 * @param bool	$rparam     флаг реверсивного параметра 100.html это html=>100
 * @return mixed
 */
function param($name, $xss = TRUE, $clean_html = TRUE, $rparam = FALSE)
{
    list($name, $type) = explode('|', $name);
    if (is_array($name)) {
        return CI()->params($name, $xss, $clean_html, $rparam);
    }
    $value = '';
    $value = CI()->input->post($name, $xss);
    if (empty($value) and isset($_GET[$name])) {
        $value = CI()->security->xss_clean($_GET[$name]);
    }
    // если нужно экранировать html
    if (!empty($value) and $clean_html and is_string($value)) {
        $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
    }
    if (empty($value)) {
        $value = '';
    }
    if (isset($type) and $type == 'int') {
        $value = intval($value);
    }
    if (isset($type) and $type == 'float') {
        $value = floatval($value);
    }
    if (isset($type) and $value === 0) {
        $value = NULL;
    }
    return $value;
}
開發者ID:ak826843,項目名稱:bmf,代碼行數:38,代碼來源:input_helper.php

示例2: update

 public function update($fields)
 {
     $fields['template_title'] = trim($fields['template_title']);
     if (!empty($fields['template_title'])) {
         $this->load->helper('url');
         $fields['template_file_name'] = strtolower(url_title($fields['template_title']));
     }
     // options: Create JSON string from post array
     if (!empty($fields['template_options']) && is_array($fields['template_options'])) {
         $fields['template_options'] = json_encode($fields['template_options']);
     }
     $update_item = parent::update($fields);
     // Clear page cache for linked pages
     // Update child sort if method changed
     if (!empty($fields['orig_sort_method']) && !empty($fields['template_options']['child_sort_method']) && $fields['orig_sort_method'] != $fields['template_options']['child_sort_method']) {
         $this->load->model('page_model');
         $pages = CI()->page_model->get(array($this->id_field => $update_item[$this->id_field]));
         foreach ($pages as $page) {
             if ($page['type'] != 'section') {
                 continue;
             }
             CI()->page_model->_updateSort(array('parent_id' => $page['page_id']));
         }
     }
     return $update_item;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:26,代碼來源:template_model.php

示例3: add

 public function add($type = '', $path = '', $group = null)
 {
     if (!in_array($type, $this->allowed_types)) {
         show_error('"' . $type . '" is not in the list of allowed asset types.');
     }
     if (is_null($group)) {
         $group = $type == 'css' ? 'screen' : 'default';
     }
     if (is_array($path)) {
         foreach ($path as $add) {
             $this->add($type, $add, $group);
         }
     } else {
         if (strlen($path)) {
             if (strpos($path, 'ttp://') && !strpos($path, $_SERVER['HTTP_HOST'])) {
                 // This is an externally hosted JS. It should not be compressed
                 $group = '_raw';
             } else {
                 $path = is_bool($this->add_app_path) && $this->add_app_path ? CI()->asset_path . '/' . $path : SITEPATH . $path;
                 $path = reduce_multiples($path, '/');
                 // Make sure it exists first, otherwise we don't need this asset
                 if (!file_exists(DOCROOT . $path)) {
                     pr($path, 'No Exist!');
                     return FALSE;
                 }
             }
             $this->_assets[$type][$group][] = $path;
         }
     }
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:30,代碼來源:LayoutAssets.php

示例4: is_allowed_filetype

 /**
  * Verify that the filetype is allowed
  *
  * @access	public
  * @return	bool
  */
 function is_allowed_filetype()
 {
     if (count($this->allowed_types) == 0 or !is_array($this->allowed_types)) {
         $this->set_error('upload_no_file_types');
         return FALSE;
     }
     // Fix for 'application/octet-stream' problem in SWFUpload
     if ($this->file_type == 'application/octet-stream') {
         $mime = $this->mimes_types(trim($this->file_ext, '.'));
         $this->file_type = is_array($mime) ? $mime[0] : $mime;
     }
     // Match the mime with the actual extension
     $this->file_ext = strtolower($this->file_ext);
     if (CI()->CONF['match_mime_to_ext']) {
         // This will require that the extension of the file uploaded matches against only the extention's mimes
         if (in_array(trim($this->file_ext, '.'), $this->allowed_types)) {
             $mime = $this->mimes_types(trim($this->file_ext, '.'));
             if (is_array($mime) && in_array($this->file_type, $mime, TRUE)) {
                 return TRUE;
             } else {
                 if ($mime == $this->file_type) {
                     return TRUE;
                 }
             }
         }
         return FALSE;
     } else {
         return parent::is_allowed_filetype();
     }
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:36,代碼來源:MY_Upload.php

示例5: update

 public function update($fields)
 {
     $update_item = parent::update($fields);
     // Everytime you update a value, let's publish it.
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:8,代碼來源:page_attributevalue_model.php

示例6: show

 /**
  * Render and Show template
  *
  * @param	string	$template
  * @param	array	$data
  * @return	string
  */
 public function show($template = '', $data = array())
 {
     if (empty($data)) {
         $data =& $this->_data;
     }
     $template = not_empty($template, $this->layout);
     CI()->load->view($this->theme . $template, $data);
 }
開發者ID:ak826843,項目名稱:bmf,代碼行數:15,代碼來源:Template.php

示例7: update

 public function update($fields)
 {
     $fields['group_key'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['group_title'])));
     $update_item = parent::update($fields);
     // Everytime you update a group, let's publish it.
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:9,代碼來源:page_attributegroup_model.php

示例8: log

 function log($module = null, $module_id = null, $desc = null, $type = 'log')
 {
     // Check the table, so we can place the log calls in Application Model
     if ($module == $this->table) {
         return;
     }
     $fields = array($this->id_field => -1, 'module' => $module, 'module_id' => $module_id, 'description' => $desc, 'type' => $type, 'user_id' => CI()->authentication->get('user_id'), 'ip_address' => $_SERVER["REMOTE_ADDR"]);
     return $this->insert($fields);
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:9,代碼來源:activity_model.php

示例9: erase_session

 protected function erase_session($name)
 {
     if (is_array($name)) {
         foreach ($name as $value) {
             $this->erase_session($value);
         }
     } else {
         return CI()->session->unset_userdata(TWITTER_SESSION_PREFIX . $name);
     }
 }
開發者ID:kbjr,項目名稱:EasyOpenID,代碼行數:10,代碼來源:twitter.php

示例10: __construct

 public function __construct()
 {
     parent::__construct();
     // set default timezone for all acsess
     date_default_timezone_set('Asia/Jakarta');
     // load helper
     $this->load->helper(array('form', 'url', 'func'));
     if (ci()->controller == 'reg' || ci()->controller == 'home') {
         $this->login_lib->a_check_has_login();
     } else {
         $this->login_lib->a_check_not_login();
     }
     // for construction only
     if (CONSTRUCTION == TRUE && $this->controller != 'construction') {
         $isbeta = $this->session->userdata('_IS_BETA');
         if ($isbeta == 'true') {
         } else {
             redirect('construction');
         }
     } elseif (CONSTRUCTION == FALSE) {
         // remove beta session if needed
         $this->session->unset_userdata(SESS_BETA);
     }
     // set user id for global
     $theid = $this->session->userdata('_GLOBAL_USER');
     if (!$theid) {
         $rand = mt_rand() . time();
         $this->session->set_userdata('_GLOBAL_USER', $rand);
         $theid = $rand;
     }
     ci()->globals = new stdClass();
     ci()->globaluser = $theid;
     ci()->globals->user_global = $theid;
     // sama dengan diatas
     CI()->globals->lang = 'english';
     // template config
     $this->load->library(array('template'));
     $this->template->add_theme_location(config_item('theme_path') . '/');
     ci()->curtheme = config_item('theme_name');
     // Template configuration
     $this->template->enable_parser(false)->set('title', config_item('site_title'))->set('keyword', config_item('site_keyword'))->set('description', config_item('site_desc'))->set_theme(ci()->curtheme)->set_layout('index');
     // load model utama
     $this->load->model('home/global_model', 'gm');
     // component top sidebar
     $var['list_kat_sub'] = $this->gm->get_kat_sub();
     $var['list_katalog'] = $this->gm->get_katalog();
     $var['cats'] = $this->gm->get_menu();
     $var['more'] = $this->gm->get_menu_more();
     $this->template->append_metadata(theme_css('top-sidebar.css'))->set_partial('pg_topbar', 'top-sidebar', $var);
     // banner slider
     //$this->template->set_partial('pg_banner','slider');
     // hitung cart
     $this->template->set('count_cart', $this->gm->count_cart($theid, $this->login_lib->m_get_data('id')));
 }
開發者ID:Garybaldy,項目名稱:rotio,代碼行數:54,代碼來源:Aff_Controller.php

示例11: Bug

function Bug($Var, $msg = '')
{
    $site = CI()->config->item('site');
    if (!$site['debug']) {
        return;
    }
    if (!empty($msg)) {
        CI()->template_lib->append('debug', "<br /><hr><h2>{$msg}</h2><hr>");
    }
    CI()->template_lib->append('debug', Dump($Var, TRUE));
}
開發者ID:ReginaReality,項目名稱:AOmega.blog,代碼行數:11,代碼來源:dump_helper.php

示例12: clearTmpFiles

 public function clearTmpFiles()
 {
     $FILE_CONF = CI()->loadConfig('file');
     $directory = DOCROOT . zonepath($FILE_CONF['file_directory'] . '/' . $FILE_CONF['temp_folder'] . '/');
     if (!@is_dir($directory)) {
         show_error('Directory not found.<br/><em>Path: ' . $directory . '</em>');
     }
     $rm_result = shell_exec('rm -fv ' . $directory . '*.jpg');
     $rm_result .= shell_exec('rm -fv ' . $directory . '*.gif');
     $rm_result .= shell_exec('rm -fv ' . $directory . '*.png');
     return $rm_result;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:12,代碼來源:Site_maintenance.php

示例13: revertTo

 public function revertTo($id = null)
 {
     $this->authentication->requirePermission('global_publish');
     $version_data = $this->first()->getById($id);
     unset($version_data[$this->id_field]);
     $this->output->enable_profiler(TRUE);
     $version_data['options'] = json_decode($version_data['options'], true);
     CI()->page_model->update($version_data);
     // Record action log
     $this->activity->log('page', $version_data['page_id'], 'Reverted page to version #' . $id);
     return TRUE;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:12,代碼來源:page_versions_model.php

示例14: update

 public function update($fields)
 {
     if (!empty($fields['value']) && is_array($fields['value'])) {
         $fields['value'] = json_encode($fields['value']);
     }
     $update_fields = parent::update($fields);
     if ($this->ADMIN_CONF['publish']['publish_method'] != 'local_table') {
         // Queue template for publish
         CI()->load->model('publish_queue_model');
         CI()->publish_queue_model->publish($this->table, $update_fields[$this->id_field], $update_fields);
     }
     return $update_fields;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:13,代碼來源:config_model.php

示例15: get

 public function get($fields = array(), $return = false)
 {
     $item = parent::get($fields);
     $item_updated = array();
     if (count($item)) {
         // Make model specific updates to result array
         for ($i = 0; $i < count($item); $i++) {
             $row = $item[$i];
             if (empty($params['SELECT_SET']) || $params['SELECT_SET'] != 'basic') {
                 $row['sort_name'] = strtolower($row['title']);
                 $row['date'] = date('m-d-Y H:i', strtotime($row[$this->date_field['update']]));
                 $row['timestamp'] = date('U', strtotime($row[$this->date_field['update']]));
                 // Only perform the following if this is a file
                 if (!empty($row['type']) && $row['type'] == 'file') {
                     $var_length = (int) $this->FILE_CONF['file_dir_depth'] * 3;
                     $path_array = str_split(str_pad($row[$this->id_field], $var_length, '0', STR_PAD_LEFT), 3);
                     $upload_path = implode('/', $path_array);
                     /*
                     // To get the file's directory path. Don't need but lets keep around.		
                     unset($path_array[count($path_array)-1]);
                     $dir_path					= implode('/', $path_array);
                     $row['server_dir'] 			= DOCROOT . $this->FILE_CONF['file_location'] . $dir_path;
                     */
                     $base_view_path = $row[$this->id_field] . ($this->FILE_CONF['force_name_in_uri'] ? '/' . $row['file_name'] : '') . $row['ext'];
                     // Add file paths
                     //							$row['real_path'] 			= DOCROOT . zonepath($this->FILE_CONF['file_directory'] . '/' . $upload_path . $row['ext'], 'local');
                     $row['base_path'] = DOCROOT . zonepath($this->FILE_CONF['file_directory'] . '/' . $upload_path, 'local');
                     $row['server_path'] = $row['base_path'] . $row['ext'];
                     $row['view_path'] = reduce_multiples($this->FILE_CONF['file_website_location'] . $base_view_path, '/');
                     $row['manage_path'] = reduce_multiples(SITEPATH . $this->zone . CI()->SITE_CONF['file_uri_trigger'] . '/' . $base_view_path, '/');
                     // Add file size
                     $row['file_size'] = file_exists($row['server_path']) ? filesize($row['server_path']) : 0;
                     $row['file_size_display'] = file_exists($row['server_path']) ? $this->formatFileSize(filesize($row['server_path'])) : 0;
                 }
             }
             $item_updated[] = $row;
         }
         if (count($item_updated) > 1 && !empty($item_updated[0]['sort_name'])) {
             // Sort array
             $sort_array = array();
             foreach ($item_updated as $row) {
                 $sort_array[] = $row['sort_name'];
             }
             array_multisort($sort_array, SORT_ASC, $item_updated);
         }
     }
     return $item_updated;
 }
開發者ID:vsa-partners,項目名稱:typologycms,代碼行數:48,代碼來源:file_model.php


注:本文中的CI函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。