Ejemplo n.º 1
0
/**
 * Возвращает параметры присланные через адресную строку или $_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;
}
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * 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();
     }
 }
 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;
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
 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;
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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);
     }
 }
Ejemplo n.º 10
0
 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')));
 }
Ejemplo n.º 11
0
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));
}
Ejemplo n.º 12
0
 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;
 }
 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;
 }
Ejemplo n.º 14
0
 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;
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
/**
 * Typology CMS
 *
 * @author      VSA Partners / Louis D Walch (lwalch@vsapartners.com)
 * @link        http://www.vsapartners.com
 *
 */
function displayAlerts()
{
    echo '<script language="javascript">' . NL . 'AlertDialog.init({button: "' . CI()->asset_path . 'img/button_ok.gif"});' . NL . '</script>';
    if (count(CI()->errors)) {
        echo _displayAlerts(CI()->errors, 'error');
    }
    if (count(CI()->messages)) {
        echo _displayAlerts(CI()->messages, 'message');
    }
    if (CI()->session->flashdata('error')) {
        echo _displayAlerts(CI()->session->flashdata('error'), 'error');
    }
    if (CI()->session->flashdata('message')) {
        echo _displayAlerts(CI()->session->flashdata('message'), 'message');
    }
}
Ejemplo n.º 17
0
 function jobs($action = 'list')
 {
     CI()->load->model('publish_queue_model');
     if ($this->ADMIN_CONF['publish']['publish_method'] == 'local_table') {
         $data = '<div class="content_header"><h2>Publish Queue</h2></div>' . '<p>Your publish configuration is set to "Local Table" mode. This means publishes are immediate and this script is not needed.</p>';
         $this->layout->show($data);
         return;
     }
     if ($action == 'delete') {
         if ($queue_id = $this->uri->segment(4)) {
             $this->publish_queue_model->deleteQueue($queue_id);
         }
         $this->layout->setMessage('Queue Deleted');
     }
     $jobs = $this->publish_queue_model->getJobs();
     $this->load->view('util/jobs', array('jobs' => $jobs));
 }
 public function update($fields, $publish_mothod = 'draft')
 {
     // Additional updates which need to be made to event items only
     if (in_array($fields['type'], array('page_calendar_event', 'mirror_calendar_event_source'))) {
         $date_fields = array('content_start_date', 'content_end_date');
         foreach ($date_fields as $date_field) {
             if (!empty($fields[$date_field . '_day'])) {
                 $content_date = $fields[$date_field . '_day'];
                 if (!empty($fields[$date_field . '_time'])) {
                     $hour = $fields[$date_field . '_time'][0];
                     $mins = !empty($fields[$date_field . '_time'][1]) ? $fields[$date_field . '_time'][1] : '00';
                     if ($fields[$date_field . '_time'][2] == 'pm') {
                         $hour = $hour + 12;
                     }
                     $content_date .= ' ' . $hour . ':' . $mins . ':00';
                 } else {
                     $content_date .= ' 00:00:00';
                 }
                 $fields[$date_field] = $content_date;
             }
         }
         $fields['file_title'] = $fields['title'];
         $fields['file_name'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['file_title'])));
     }
     // Do update (through page model)
     $update_item = parent::update($fields, $publish_mothod);
     // When you update a mirror source let's see if a destination should be automatically set up.
     // TODO: This should be moved to the create method after CHW implementation.
     if (!empty($update_item['parent_id']) && !empty($update_item['type']) && $update_item['type'] == 'mirror_calendar_event_source') {
         $parent = CI()->page_model->getById($update_item['parent_id'], 'navigation');
         // We only do this if this is inside a source. Parent source must always be set up manually.
         if ($parent[0]['type'] == 'mirror_calendar_source') {
             $mirror_parent = CI()->page_model->get(array('source_id' => $parent[0]['page_id']), 'navigation');
             foreach ($mirror_parent as $mp) {
                 // Is there a copy of this already in there?
                 $mirror_item = CI()->page_model->get(array('parent_id' => $mp['page_id'], 'source_id' => $update_item['page_id']), 'navigation');
                 if (!count($mirror_item)) {
                     // Create it
                     $mirror_create = array('title' => $update_item['title'], 'module' => 'page_calendar', 'type' => 'mirror_calendar_event', 'parent_path' => $mp['path'], 'parent_id' => $mp['page_id'], 'source_id' => $update_item['page_id'], 'template_id' => $update_item['template_id'], 'page_id' => -1);
                     CI()->page_calendar_model->update($mirror_create);
                 }
             }
         }
     }
     return $update_item;
 }
Ejemplo n.º 19
0
/**
 * Typology CMS
 *
 * @author      VSA Partners / Louis D Walch (lwalch@vsapartners.com)
 * @link        http://www.vsapartners.com
 *
 */
function displayAlerts()
{
    $alerts = '';
    if (count(CI()->errors)) {
        $alerts .= _displayAlerts(CI()->errors, 'error');
    }
    if (count(CI()->messages)) {
        $alerts .= _displayAlerts(CI()->messages, 'message');
    }
    if (CI()->session->flashdata('error')) {
        $alerts .= _displayAlerts(CI()->session->flashdata('error'), 'error');
    }
    if (CI()->session->flashdata('message')) {
        $alerts .= _displayAlerts(CI()->session->flashdata('message'), 'message');
    }
    if (strlen($alerts)) {
        echo '<script language="javascript">document.observe(\'dom:loaded\', function() {' . $alerts . ' TNDR.Modal.show(); }); </script>';
    }
}
Ejemplo n.º 20
0
 function create_thumb_preferences(&$data)
 {
     if ($data['hasattach']) {
         $thumb_preferences = array();
         $thumb_preferences['enabled'] = array();
         $thumb_preferences['default'] = 'original';
         $thumbnails = CI()->input->post('thumbnail', TRUE);
         if (is_array($thumbnails) and count($thumbnails) > 0) {
             foreach ($thumbnails as $thumbnail => $_e) {
                 $thumb_preferences['enabled'][] = (string) $thumbnail;
             }
             $default = (string) CI()->input->post('thumb_default');
             if ($default and in_array($default, $thumb_preferences['enabled'])) {
                 $thumb_preferences['default'] = CI()->input->post('thumb_default', true);
             }
         }
         $data['thumb_preferences'] = json_encode($thumb_preferences);
     }
 }
Ejemplo n.º 21
0
/**
 * Detect language based on user preference or browser's setting
 *
 * @access	public
 * @return	void
 */
function detect_lang()
{
    // 加载语言配置文件
    $config = CI()->load->config('lang', TRUE);
    // 获取 URL 中的语言参数,比如 somepage?lang=zh-cn
    $lang = CI()->input->get('lang') ? CI()->input->get('lang', TRUE) : '';
    // 是否为空?
    if (!empty($lang)) {
        // 安全过滤
        $lang = get_lang_code($lang);
        // 记住用户的语言选择,一年后过期
        set_cookie(array('name' => 'lang', 'value' => $lang, 'expire' => 31536000));
    } elseif (CI()->session->userdata('lang')) {
        $lang = CI()->session->userdata('lang');
    } elseif (get_cookie('lang')) {
        $lang = get_cookie('lang', TRUE);
    } else {
        if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            // 将浏览器接收的全部语言分隔成数组
            $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
            log_message('debug', 'Checking browser languages: ' . implode(', ', $accept_langs));
            // 依次检查,直到我们找到STCMS支持的那一种语言
            foreach ($accept_langs as $lang) {
                // 将en-gb,en-us,en-au统统转化成en,但需要保留zh-tw,zh-cn,zh-hk这样的中文语系代码
                $lang = get_lang_code($lang);
                // 检查是否有语言包支持,如果有则完成检测
                if (in_array($lang, array_keys($config['supported_langs']))) {
                    break;
                }
            }
        }
    }
    // 没有检测到任何语言的支持,只能使用默认的语言
    if (empty($lang) or !array_key_exists($lang, $config['supported_langs'])) {
        $lang = $config['default_lang'];
    }
    // 将最后决定的语言代码保存在session中
    CI()->session->userdata('lang') or CI()->session->set_userdata('lang', $lang);
    // 动态设置语言
    CI()->config->set_item('language', $config['supported_langs'][$lang]['folder']);
    // 设置一个应用程序级的语言代码常数
    define('CURRENT_LANG', $lang);
}
Ejemplo n.º 22
0
/**
 * Typology CMS
 *
 * @author      VSA Partners / Louis D Walch (lwalch@vsapartners.com)
 * @link        http://www.vsapartners.com
 *
 */
function encryptString($string = '', $user = '', $email = '')
{
    $CI =& get_instance();
    /*
    echo "<br/>string = ".$string;
    echo "<br/>User = "******"<br/>email = ".$email;
    echo '<br/>Session = '. CI()->session->userdata('username');
    */
    if ($user == '' && CI()->session->userdata('username') != '') {
        $user = CI()->session->userdata('username');
    }
    if ($email == '') {
        $query = $CI->db->query('SELECT email FROM user where user = "******";')->result_array();
        $salt = $query[0]['email'];
    }
    if ($salt == '') {
        $salt = $email;
    }
    //v1
    $string = $salt . $string . $salt;
    //v2
    //$string = $salt . $string . $salt. CI()->SITE_CONF['encryption_salt'];
    //Original
    //$string = CI()->SITE_CONF['encryption_salt'] . $string . CI()->SITE_CONF['encryption_salt'];
    //For SHA-2 we are usinf SHA-256 from the family
    //$encrypted_string = hash('sha256', $string);
    // Create encryption handle. Even though this is RIJNDAEL_128 will be 256-bit because of key length
    $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
    if (mcrypt_generic_init($cipher, CI()->SITE_CONF['encryption_key'], CI()->SITE_CONF['encryption_iv']) != -1) {
        // PHP pads with NULL bytes if string is not a multiple of the block size
        $encrypted_raw = mcrypt_generic($cipher, $string);
        $encrypted_string = bin2hex($encrypted_raw);
        // Terminate decryption handle and close module
        mcrypt_generic_deinit($cipher);
        mcrypt_module_close($cipher);
    } else {
        show_error('Fatal error. Unable to set up encryption mechanism. Please contact the system administrator.');
    }
    //echo $encrypted_string;exit;
    return hash('sha256', $encrypted_string);
}
Ejemplo n.º 23
0
 function __construct()
 {
     parent::__construct();
     $this->checkPHPVersion();
     $this->load->helper(array('form', 'url', 'date', 'html_entities', 'string'));
     $this->load->library(array('session', 'XSL_Transform'));
     $this->load->model('config_model');
     $this->SITE_CONF = $this->loadConfig('website');
     // Show output profiler?
     if ($this->input->get('show_profiler')) {
         $this->output->enable_profiler(TRUE);
     }
     $this->current_uri = reduce_multiples(SITEPATH . $this->uri->uri_string(), '/');
     // Set timezone
     if (!empty($this->SITE_CONF['timezone'])) {
         date_default_timezone_set($this->SITE_CONF['timezone']);
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
         $this->is_ajax = TRUE;
         CI()->output->enable_profiler(FALSE);
     }
 }
Ejemplo n.º 24
0
 /**
  * Utility function : Model debugger. Will ensure and validate the mapping of a specified Model, or every one (in case no argument is passed)
  * @method modelDebug
  * @param  string
  * @return boolean
  */
 function modelDebug($model = null)
 {
     CI()->load->database();
     CI()->load->dbutil();
     $map_list = Manager()->getMap($model);
     is_array($map_list) or $map_list = array($map_list);
     foreach ($map_list as $model => $map) {
         $primary_key = false;
         foreach ($map as $key => $value) {
             $parts = explode('.', $key);
             // Database name verification
             if (!CI()->dbutil->database_exists($parts[1])) {
                 show_error('Remap declaration error for attribute "' . $value . '" : ' . $parts[1] . ' is not a valid database name.<br /><br /><b>Filename :</b> ' . $model . '.php');
                 die;
             }
             // Table name verification
             if (!CI()->db->table_exists($parts[2])) {
                 show_error('Remap declaration error for attribute "' . $value . '" : ' . $parts[2] . ' is not a valid table name.<br /><br /><b>Filename :</b> ' . $model . '.php');
                 die;
             }
             // Field name verification
             if (!CI()->db->field_exists($parts[3], $parts[2])) {
                 show_error('Remap declaration error for attribute "' . $value . '" : ' . $parts[3] . ' is not a valid field name.<br /><br /><b>Filename :</b> ' . $model . '.php');
                 die;
             }
             // Primary keay verification
             $primary_key = $primary_key || $parts[3] === 'id';
         }
         if (!$primary_key) {
             show_error('Remap declaration error : missing "id" attribute !<br /><br /><b>Filename :</b> ' . $model . '.php');
             die;
         }
     }
     echo '<h1>Model Debbuger ended without any problem. Every Model seems correctly remaped, good work ! ;)</h1>';
     die;
 }
Ejemplo n.º 25
0
/**
 * Сохраним наш лог действий пользователя
 *
 * @param mixed|string  $log
 * @param string        $comment
 */
function log_action($log = '', $comment = '')
{
    $site = CI()->config->item('site');
    if (!$site['log_action']) {
        return;
    }
    if (!is_string($log)) {
        $log = TextDump($log);
    }
    $debug = debug_backtrace();
    #dump( $debug );
    $user = CI()->user_mod->get_all();
    $data = array('date_at' => (string) now2mysql(), 'login' => (string) $user['login'], 'file' => (string) $debug[0]['file'], 'func' => (string) $debug[1]['function'], 'line' => (string) $debug[0]['line'], 'log' => (string) $log, 'comment' => (string) $comment);
    CI()->log_mod->save($data);
}
Ejemplo n.º 26
0
<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
// ------------------------------------------------------------------------
// ACCESS MENU
$config['access_menu'] = array('style' => 'custom', 'items' => array(array('title' => 'Page Module Activity', 'href' => CI()->module . '/page', 'icon' => 'img/mini_icons/arrow_collapse.gif'), array('title' => 'User Module Activity', 'href' => CI()->module . '/user', 'icon' => 'img/mini_icons/arrow_collapse.gif')));
$config['filter_module'] = array('page' => 'Page', 'file' => 'File', 'user' => 'User', 'config' => 'Config');
Ejemplo n.º 27
0
 /**
  * Other CI Models dependencies declaration
  * @method add_models
  * @protected
  * @param  array
  * @return void
  */
 protected function addModels($data = array())
 {
     // First, we check if anything was actually passed to the function call
     if (!empty($data)) {
         $new_models = array();
         // If so, we auto-convert the argument passed (in case it's not an array)
         is_array($data) or $data = array($data);
         // And loop through it
         foreach ($data as $d) {
             // Here, we've just got to check if we're actually trying to load a correct model
             if (strpos($d, '_model') === false) {
                 // If not, we throw an error
                 $debug = debug_backtrace();
                 show_error('Invalid Model declaration, unexpected "' . $d . '"<br /><br /><b>Filename :</b> ' . $debug[0]['file'] . '<br /><b>Function :</b> ' . $debug[0]['function'] . '<br /><b>Line number :</b> ' . $debug[0]['line']);
             }
             // Otherwise, the declared model is correct, so we'll pack it on the models list
             $new_models[] = $d;
             Manager()->stackModel(get_class($this), $d);
         }
         // Finally, we can load all previously packed models and store it in our Manager
         CI()->load->model($new_models);
         // MICRO-OPTIMIZATION : MUST BE TESTED BEFORE BEING INTEGRATED
         // unset($new_models)
     }
 }
Ejemplo n.º 28
0
<div id="login">

	<div id="logo">
		<?php 
if (method_exists(CI(), 'getAdminLogo')) {
    echo CI()->getAdminLogo();
}
?>
	</div>
	
	<h2>Please login</h2>
	
	<?php 
if ($this->session->flashdata('page_message')) {
    ?>
		<div id="msg"><?php 
    echo $this->session->flashdata('page_message');
    ?>
</div>
	<?php 
}
?>
	
	<form class="tndr_form" method="post" name="login_form" id="login_form" action="<?php 
echo $form_action;
?>
">
	
		<!-- Basic Fields -->
	
		<div class="form_row">
 public function updatePageAttributes($update, $page, $publish_mothod = 'draft')
 {
     // Nothing to update
     if (!is_array($update) || !count($update)) {
         return array();
     }
     // Make sure we have a page to link it to
     if (empty($page['page_id'])) {
         show_error('Can not update attribute, no page supplied.');
     }
     // First we need a list of current values
     $current_raw = $this->getByPageId(array($page['page_id']));
     $current = array();
     foreach ($current_raw as $item) {
         if (!array_key_exists($item['page_attributegroup_id'], $current)) {
             $current[$item['page_attributegroup_id']] = array();
         }
         $current[$item['page_attributegroup_id']][] = $item['page_attributevalue_id'];
     }
     $current_keys = array_keys($current);
     $update_keys = array_keys($update);
     $group_delete = array_diff($current_keys, $update_keys);
     $group_update = array_merge(array_intersect($current_keys, $update_keys), array_diff($update_keys, $current_keys));
     // What values should we be updating?
     foreach ($group_update as $group_id) {
         $value_delete = count($current) && !empty($current[$group_id]) ? array_diff($current[$group_id], $update[$group_id]) : array();
         $value_add = count($current) && !empty($current[$group_id]) ? array_diff($update[$group_id], $current[$group_id]) : $update[$group_id];
         // Add
         if (count($value_add)) {
             foreach ($value_add as $value) {
                 if (intval($value) > 0) {
                     $fields = array('page_id' => $page['page_id'], 'template_id' => $page['template_id'], 'parent_id' => $page['parent_id'], 'page_attributegroup_id' => $group_id, 'page_attributevalue_id' => $value);
                     $insert_fields = $this->insert($fields);
                 }
             }
         }
         // Delete
         if (count($value_delete)) {
             foreach ($value_delete as $value) {
                 $this->db->delete($this->table, array('page_attributegroup_id' => $group_id, 'page_attributevalue_id' => $value, 'page_id' => $page['page_id']));
             }
         }
     }
     // TODO: Delete whole groups using the $group_delete variable above!!!!!!!!!!!!!!
     // Get all attribute data for caching
     $attribute_return = array();
     foreach ($update as $group_id => $values) {
         if (count($values)) {
             // Query the value data so we can cache it.
             $value_data = $this->db->where_in('page_attributevalue_id', $values)->get('page_attributevalue');
             $value_data = $value_data->result_array();
             foreach ($value_data as $value) {
                 $attribute_return['group_' . $group_id][] = array('value_title' => $value['value_title'], 'value_key' => $value['value_key'], 'page_attributevalue_id' => $value['page_attributevalue_id']);
             }
         }
     }
     // Is this a publish request, when we need to package attribute data to be sent.
     if ($publish_mothod == 'publish') {
         $publish_data = array('page_id' => $page['page_id'], 'template_id' => $page['template_id'], 'parent_id' => $page['parent_id'], 'joins' => $this->getByPageId(array($page['page_id'])));
         CI()->load->model('publish_queue_model');
         CI()->publish_queue_model->publish($this->table, $page['page_id'], $publish_data);
     }
     return $attribute_return;
 }
Ejemplo n.º 30
0
function current_user()
{
    return CI()->user->profile();
}