本文整理汇总了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;
}
示例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;
}
示例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;
}
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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')));
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}