コード例 #1
0
 private function __update_module()
 {
     $bypass = '';
     $query = $this->db->select('password')->from(cms_table_name('main_user'))->where('user_id', 1)->get();
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $bypass = $row->password;
     }
     if ($bypass != '') {
         $module_list = $this->cms_get_module_list();
         foreach ($module_list as $module) {
             $module_path = $module['module_path'];
             $module_name = $module['module_name'];
             $old_version = $module['old_version'];
             $current_version = $module['current_version'];
             $active = $module['active'];
             $upgrade_link = $module['upgrade_link'];
             if ($active && $old_version != $current_version) {
                 $url = str_replace(site_url(), '', $upgrade_link);
                 $url = trim($url, '/');
                 $response = @Modules::run($url, $bypass);
             }
         }
     }
 }
コード例 #2
0
ファイル: cms_helper.php プロジェクト: andrinda/simpeg
function cms_module_table_prefix($module_directory, $new_prefix = NULL)
{
    $module_table_prefix = cms_module_config($module_directory, 'module_table_prefix', $new_prefix);
    if ($module_table_prefix == '') {
        return cms_table_prefix();
    } else {
        return cms_table_name($module_table_prefix);
    }
}
コード例 #3
0
ファイル: Ajax.php プロジェクト: ishawge/No-CMS
 public function privileges($keyword = '')
 {
     $query = $this->db->select('privilege_id, privilege_name')->from(cms_table_name('main_privilege'))->like('privilege_name', $keyword)->limit(20)->get();
     $result = array();
     foreach ($query->result() as $row) {
         $result[] = array('value' => $row->privilege_id, 'caption' => $row->privilege_name);
     }
     echo json_encode($result);
 }
コード例 #4
0
ファイル: Subsite_model.php プロジェクト: hjd919/No-CMS
 public function get_subsite_config_table_name($subsite_name){
     $cms_config_file = APPPATH.'config/site-'.$subsite_name.'/cms_config.php';
     if(file_exists($cms_config_file)){
         $config = array();
         include $cms_config_file;
         if(array_key_exists('__cms_table_prefix', $config)){
             $table_prefix = $config['__cms_table_prefix'];    
         }else if(array_key_exists('cms_table_prefix', $config)){
             $table_prefix = $config['cms_table_prefix'];
         }else{
             $table_prefix = 'site_'.$subsite_name;
         }           
         $config_table_name = $table_prefix.'_main_config';
     }else{
         $config_table_name = cms_table_name('site_'.$subsite_name.'_main_config');
     }
     return $config_table_name;
 }
コード例 #5
0
ファイル: Info.php プロジェクト: Drunkenpilot/No-CMS
 public function do_upgrade($old_version)
 {
     $module_path = $this->cms_module_path();
     // table : blog article
     $table_name = $this->t('message');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('read' => array('type' => 'INT', 'constraint' => 20, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0));
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     $version_part = explode('.', $old_version);
     $major = $version_part[0];
     $minor = $version_part[1];
     $build = $version_part[2];
     if ($major == 0 && $minor == 0 && $build <= 1) {
         $this->db->update(cms_table_name('main_navigation'), array('notif_url' => $this->cms_module_path() . '/notif/new_message'), array('navigation_name' => $this->n('index')));
         $this->db->update(cms_table_name('main_navigation'), array('notif_url' => $this->cms_module_path() . '/notif/new_message'), array('navigation_name' => $this->n('manage_message')));
     }
 }
コード例 #6
0
ファイル: install.php プロジェクト: kevinmel2000/ci_webblog
 protected function do_upgrade($old_version)
 {
     // table : blog article
     $table_name = $this->cms_complete_table_name('article');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('keyword' => $this->TYPE_VARCHAR_100_NULL, 'description' => $this->TYPE_TEXT);
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     // table : blog comment
     $table_name = $this->cms_complete_table_name('comment');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('parent_comment_id' => $this->TYPE_INT_UNSIGNED_NULL, 'read' => array('type' => 'INT', 'constraint' => 20, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0));
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     // navigation: blog_index
     $table_name = cms_table_name('main_navigation');
     $navigation_name = $this->cms_complete_navigation_name('index');
     $this->db->update($table_name, array('notif_url' => $this->cms_module_path($this->NAME) . '/notif/new_comment'), array('navigation_name' => $navigation_name));
     // navigation: blog_article
     $navigation_name = $this->cms_complete_navigation_name('manage_article');
     $this->db->update($table_name, array('notif_url' => $this->cms_module_path($this->NAME) . '/notif/new_comment'), array('navigation_name' => $navigation_name));
     // add widget archive
     $query = $this->db->select('widget_name')->from(cms_table_name('main_widget'))->where('widget_name', $this->cms_complete_navigation_name('archive'))->get();
     if ($query->num_rows() > 0) {
         $this->add_widget($this->cms_complete_navigation_name('archive'), 'Archive', $this->PRIV_EVERYONE, $module_path . '/blog_widget/archive', 'sidebar');
     }
 }
コード例 #7
0
 private function __update_to_1_0_4()
 {
     // Last time, I forgot to add authorization_id for all generated privileges, so here is
     $this->db->update(cms_table_name('main_privilege'), array('authorization_id' => 4), array('privilege_id >=' => 0));
 }
コード例 #8
0
 public function _callback_column_translations($value, $row)
 {
     $module_path = $this->cms_module_path();
     $query = $this->db->select('detail_language_id, key, translation')->from(cms_table_name('main_detail_language'))->where('id_language', $row->language_id)->get();
     $num_row = $query->num_rows();
     // show how many records
     if ($num_row > 1) {
         return $num_row . ' Translations';
     } else {
         if ($num_row > 0) {
             return $num_row . ' Translation';
         } else {
             return 'No Translation';
         }
     }
 }
コード例 #9
0
 protected final function remove_quicklink($navigation_name)
 {
     $SQL = "SELECT navigation_id FROM " . cms_table_name('main_navigation') . " WHERE navigation_name ='" . addslashes($navigation_name) . "'";
     $query = $this->db->query($SQL);
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $navigation_id = $row->navigation_id;
         // delete
         $where = array("navigation_id" => $navigation_id);
         $this->db->delete(cms_table_name('main_quicklink'), $where);
     }
 }
コード例 #10
0
ファイル: Main.php プロジェクト: engirocha/No-CMS
 public function route()
 {
     $this->cms_guard_page('main_route_management');
     $crud = $this->new_crud();
     $crud->unset_jquery();
     $crud->set_table(cms_table_name('main_route'));
     $crud->set_subject('Route');
     $crud->required_fields('key', 'value');
     $crud->unique_fields('key');
     $crud->unset_read();
     $crud->columns('key', 'value', 'description');
     $crud->edit_fields('key', 'value', 'description');
     $crud->add_fields('key', 'value', 'description');
     $crud->display_as('key', 'Key')->display_as('value', 'Value')->display_as('description', 'Description');
     $crud->unset_texteditor('key');
     $crud->unset_texteditor('value');
     $crud->unset_texteditor('description');
     $crud->callback_after_insert(array($this, '_after_insert_route'));
     $crud->callback_after_delete(array($this, '_after_delete_route'));
     $crud->callback_after_update(array($this, '_after_update_route'));
     $crud->set_language($this->cms_language());
     $output = $crud->render();
     // prepare css & js, add them to config
     $config = array();
     $asset = new Cms_asset();
     foreach ($output->css_files as $file) {
         $asset->add_css($file);
     }
     $config['css'] = $asset->compile_css();
     foreach ($output->js_files as $file) {
         $asset->add_js($file);
     }
     $config['js'] = $asset->compile_js();
     // show the view
     $this->view('main/main_route', $output, 'main_route_management', $config);
 }
コード例 #11
0
 private function __update_to_0_7_7()
 {
     // make route for 404_override
     $pattern = array();
     $pattern[] = '/(\\$route\\[(\'|")404_override(\'|")\\] *= *")(.*?)(";)/si';
     $pattern[] = "/(" . '\\$' . "route\\[('|\")404_override('|\")\\] *= *')(.*?)(';)/si";
     if (CMS_SUBSITE == '') {
         $file_name = APPPATH . 'config/main/routes.php';
     } else {
         $file_name = APPPATH . 'config/site-' . CMS_SUBSITE . '/routes.php';
     }
     $str = file_get_contents($file_name);
     $replacement = '${1}main/not_found${5}';
     $found = FALSE;
     foreach ($pattern as $single_pattern) {
         if (preg_match($single_pattern, $str)) {
             $found = TRUE;
             break;
         }
     }
     if (!$found) {
         $str .= PHP_EOL . '$route[\'404_override\'] = \'not_found\';';
     } else {
         $str = preg_replace($pattern, $replacement, $str);
     }
     @chmod($file_name, 0777);
     if (strpos($str, '<?php') !== FALSE && strpos($str, '$route') !== FALSE) {
         @file_put_contents($file_name, $str);
         @chmod($file_name, 0555);
     }
     // make register default-one-column
     $this->db->update(cms_table_name('main_navigation'), array('default_layout' => 'default-one-column'), array('navigation_name' => 'main_register'));
     // add 404 navigation
     $this->cms_add_navigation('main_404', '404 Not Found', 'not_found', 1, NULL, 9, '404 Not found page', NULL, NULL, 'default-one-column', NULL, 1, '<h1>404 Page not found</h1><p>Sorry, the page does not exists.<br /><a class="btn btn-primary" href="{{ site_url }}">Please go back <i class="glyphicon glyphicon-home"></i></a></p>');
 }
コード例 #12
0
ファイル: article_model.php プロジェクト: heruprambadi/simpeg
 public function get_comments($article_id)
 {
     $search = array('<', '>');
     $replace = array('&lt;', '&gt;');
     $SQL = "SELECT comment_id, date, author_user_id, name, email, website, content\n        FROM " . $this->cms_complete_table_name('comment') . "\n        WHERE article_id = '{$article_id}' ORDER BY `date` asc";
     $query = $this->db->query($SQL);
     $data = array();
     foreach ($query->result() as $row) {
         $user_id = $row->author_user_id;
         if (isset($user_id) && $user_id > 0) {
             $query_user = $this->db->select('real_name, user_name')->from(cms_table_name('main_user'))->where('user_id', $user_id)->get();
             $row_user = $query_user->row();
             $name = trim($row_user->real_name) == '' ? $row_user->user_name : $row_user->real_name;
         } else {
             $name = $row->name;
         }
         $this->load->helper('url');
         $result = array("date" => date('Y-m-d'), "content" => str_replace($search, $replace, $row->content), "name" => $name, "website" => prep_url($row->website));
         $data[] = $result;
     }
     return $data;
 }
コード例 #13
0
ファイル: Article_model.php プロジェクト: nonconforme/No-CMS
 private function preprocess_comment($row)
 {
     $search = array('<', '>');
     $replace = array('&lt;', '&gt;');
     $user_id = $row->author_user_id;
     if (isset($user_id) && $user_id > 0) {
         $query_user = $this->db->select('real_name, user_name, email')->from(cms_table_name('main_user'))->where('user_id', $user_id)->get();
         $row_user = $query_user->row();
         $name = trim($row_user->real_name) == '' ? $row_user->user_name : $row_user->real_name;
         $email = $row_user->email;
     } else {
         $name = $row->name;
         $email = $row->email;
     }
     $email = $email === NULL ? '' : $email;
     $website = $row->website === NULL ? '' : $row->website;
     $this->load->helper('url');
     $result = array("comment_id" => $row->comment_id, "date" => date('Y-m-d'), "content" => str_replace($search, $replace, $row->content), "name" => $name, "website" => prep_url($website), "email" => $email, "gravatar_url" => 'http://www.gravatar.com/avatar/' . md5($email) . '?s=32&r=pg&d=identicon');
     return $result;
 }
コード例 #14
0
ファイル: CMS_Module.php プロジェクト: rajuyohannan/No-CMS
    private final function child_module()
    {
        $SQL = 'SELECT module_id FROM ' . cms_table_name('main_module') . " WHERE module_name='" . addslashes($this->NAME) . "'";
        $query = $this->db->query($SQL);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            $parent_id = $row->module_id;
            $SQL = '
	            SELECT module_name, module_path
	            FROM
	                ' . cms_table_name('main_module_dependency') . ',
	                ' . cms_table_name('main_module') . '
	            WHERE
	                ' . cms_table_name('main_module') . '.module_id = ' . cms_table_name('main_module_dependency') . '.module_id AND
	                parent_id=' . $parent_id;
            $query = $this->db->query($SQL);
            $result = array();
            foreach ($query->result() as $row) {
                $result[] = array('module_name' => $row->module_name, 'module_path' => $row->module_name);
            }
            return $result;
        } else {
            return array();
        }
    }
コード例 #15
0
ファイル: CMS_Model.php プロジェクト: engirocha/No-CMS
 public function cms_assign_widget($widget_name, $group_name)
 {
     $query = $this->db->select('group_id')->from(cms_table_name('main_group'))->where('group_name', $group_name)->get();
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $group_id = $row->group_id;
         $query = $this->db->select('widget_id')->from(cms_table_name('main_widget'))->where('widget_name', $widget_name)->get();
         if ($query->num_rows() > 0) {
             $row = $query->row();
             $widget_id = $row->widget_id;
             $query = $this->db->select('group_id')->from(cms_table_name('main_group_widget'))->where('widget_id', $widget_id)->where('group_id', $group_id)->get();
             if ($query->num_rows() == 0) {
                 $this->db->insert(cms_table_name('main_group_widget'), array('widget_id' => $widget_id, 'group_id' => $group_id));
             }
         }
     }
 }
コード例 #16
0
ファイル: Setting.php プロジェクト: yahyafakhroji/No-CMS
 public function index()
 {
     $this->theme = $this->cms_get_config('site_theme');
     // third party authentication setting
     $third_party_variables = array('auth_enable_facebook', 'auth_facebook_app_id', 'auth_facebook_app_secret', 'auth_enable_twitter', 'auth_twitter_app_key', 'auth_twitter_app_secret', 'auth_enable_google', 'auth_google_app_id', 'auth_google_app_secret', 'auth_enable_yahoo', 'auth_yahoo_app_id', 'auth_yahoo_app_secret', 'auth_enable_linkedin', 'auth_linkedin_app_key', 'auth_linkedin_app_secret', 'auth_enable_myspace', 'auth_myspace_app_key', 'auth_myspace_app_secret', 'auth_enable_foursquare', 'auth_foursquare_app_id', 'auth_foursquare_app_secret', 'auth_enable_windows_live', 'auth_windows_live_app_id', 'auth_windows_live_app_secret', 'auth_enable_open_id', 'auth_enable_aol');
     if (CMS_SUBSITE == '') {
         $hybridauth_config_file = APPPATH . '/config/main/hybridauthlib.php';
     } else {
         $hybridauth_config_file = APPPATH . '/config/site-' . CMS_SUBSITE . '/hybridauthlib.php';
     }
     // save the uploaded files
     if (isset($_FILES['site_logo'])) {
         try {
             $site_logo = $_FILES['site_logo'];
             if (isset($site_logo['tmp_name']) && $site_logo['tmp_name'] != '' && getimagesize($site_logo['tmp_name']) !== FALSE) {
                 $file_name = FCPATH . 'assets/nocms/images/custom_logo/' . CMS_SUBSITE . $site_logo['name'];
                 move_uploaded_file($site_logo['tmp_name'], $file_name);
                 $this->cms_resize_image($file_name, 800, 125);
                 $this->cms_set_config('site_logo', '{{ base_url }}assets/nocms/images/custom_logo/' . CMS_SUBSITE . $site_logo['name']);
             }
         } catch (Exception $e) {
             // do nothing
         }
     }
     if (isset($_FILES['site_favicon'])) {
         try {
             $site_favicon = $_FILES['site_favicon'];
             if (isset($site_favicon['tmp_name']) && $site_favicon['tmp_name'] != '' && getimagesize($site_favicon['tmp_name']) !== FALSE) {
                 $file_name = FCPATH . 'assets/nocms/images/custom_favicon/' . CMS_SUBSITE . $site_favicon['name'];
                 move_uploaded_file($site_favicon['tmp_name'], $file_name);
                 $this->cms_resize_image($file_name, 64, 64);
                 $this->cms_set_config('site_favicon', '{{ base_url }}assets/nocms/images/custom_favicon/' . CMS_SUBSITE . $site_favicon['name']);
             }
         } catch (Exception $e) {
             // do nothing
         }
     }
     if ($this->input->post('remove_background_image') == 1) {
         $this->cms_set_config('site_background_image', '');
     } else {
         if (isset($_FILES['site_background_image'])) {
             try {
                 $site_background_image = $_FILES['site_background_image'];
                 if (isset($site_background_image['tmp_name']) && $site_background_image['tmp_name'] != '' && getimagesize($site_background_image['tmp_name']) !== FALSE) {
                     $file_name = FCPATH . 'assets/nocms/images/custom_background/' . CMS_SUBSITE . $site_background_image['name'];
                     move_uploaded_file($site_background_image['tmp_name'], $file_name);
                     $this->cms_set_config('site_background_image', '{{ base_url }}assets/nocms/images/custom_background/' . CMS_SUBSITE . $site_background_image['name']);
                 }
             } catch (Exception $e) {
                 // do nothing
             }
         }
     }
     if (count($_POST) > 0) {
         // save the section widgets
         $this->update_static_content('section_custom_style', $this->input->post('section_custom_style'));
         $this->update_static_content('section_custom_script', $this->input->post('section_custom_script'));
         $this->update_static_content('section_top_fix', $this->input->post('section_top_fix'));
         $this->update_static_content('section_banner', $this->input->post('section_banner'));
         $this->update_static_content('section_left', $this->input->post('section_left'));
         $this->update_static_content('section_right', $this->input->post('section_right'));
         $this->update_static_content('section_bottom', $this->input->post('section_bottom'));
         $this->update_static_content('navigation_right_partial', $this->input->post('navigation_right_partial'));
         // save configurations
         $configuration_list = array('site_name', 'site_layout', 'site_slogan', 'site_footer', 'site_language', 'site_background_color', 'site_background_position', 'site_background_size', 'site_background_repeat', 'site_background_origin', 'site_background_clip', 'site_background_attachment', 'site_background_blur', 'site_text_color', 'site_show_benchmark', 'cms_signup_activation', 'cms_email_protocol', 'cms_email_reply_address', 'cms_email_reply_name', 'cms_email_forgot_subject', 'cms_email_forgot_message', 'cms_email_signup_subject', 'cms_email_signup_message', 'cms_email_useragent', 'cms_email_mailpath', 'cms_email_smtp_host', 'cms_email_smtp_user', 'cms_email_smtp_pass', 'cms_email_smtp_port', 'cms_email_smtp_timeout', 'cms_google_analytic_property_id', 'cms_internet_connectivity', 'cms_subsite_configs', 'cms_subsite_modules');
         // only for non-subsite
         if (CMS_SUBSITE == '' && $this->cms_is_module_active('gofrendi.noCMS.multisite')) {
             $configuration_list[] = 'cms_add_subsite_on_register';
             $configuration_list[] = 'cms_subsite_use_subdomain';
             $configuration_list[] = 'cms_subsite_home_content';
             $configuration_list[] = 'cms_subsite_configs';
             $configuration_list[] = 'cms_subsite_modules';
         }
         foreach ($configuration_list as $configuration) {
             $value = $this->input->post($configuration);
             if ($configuration == 'cms_email_smtp_pass') {
                 if ($value == '[PASSWORD SET]') {
                     continue;
                 }
                 $value = cms_encode($value);
             }
             // Don't update configuration if there is no change
             if ($this->cms_get_config($configuration, TRUE) == $value) {
                 continue;
             }
             $this->cms_set_config($configuration, $value);
         }
         // save language
         $this->cms_language($this->input->post('site_language'));
         // save default_controller
         $this->cms_set_default_controller($this->input->post('default_controller'));
         // save third party authentication
         $str = file_get_contents($hybridauth_config_file);
         foreach ($third_party_variables as $var) {
             $value = $this->input->post($var);
             // for auth_enable type, just put a boolean value, else add quotes
             if (substr($var, 0, 11) == 'auth_enable') {
                 $value = $value == 0 ? 'FALSE' : 'TRUE';
             } else {
                 $value = "'" . addslashes($value) . "'";
             }
             $pattern = '/(\\$' . $var . ' *= *)(.*?)(;)/si';
             $replacement = '${1}' . $value . '${3}';
             $str = preg_replace($pattern, $replacement, $str);
         }
         @chmod($hybridauth_config_file, 0777);
         file_put_contents($hybridauth_config_file, $str);
         @chmod($hybridauth_config_file, 0755);
     }
     // widgets
     $query = $this->db->select('widget_id, widget_name, static_content')->from(cms_table_name('main_widget'))->get();
     $widget_list = $query->result_array();
     $normal_widget_list = array();
     $section_widget_list = array();
     foreach ($widget_list as $widget) {
         if (substr($widget['widget_name'], 0, 8) == 'section_' || $widget['widget_name'] == 'navigation_right_partial') {
             $section_widget_list[$widget['widget_name']] = $widget;
         } else {
             $normal_widget_list[] = $widget;
         }
     }
     // languages
     $language_list = $this->cms_language_list();
     // config
     $query = $this->db->select('config_name, value')->from(cms_table_name('main_config'))->get();
     $config_list = array();
     foreach ($query->result_array() as $row) {
         $value = $row['value'];
         if ($row['config_name'] == 'cms_email_smtp_pass') {
             //$value = cms_decode($value);
             if ($value != '') {
                 $value = '[PASSWORD SET]';
             }
         }
         $config_list[$row['config_name']] = $value;
     }
     // layout
     $layout_list = array();
     $site_theme = $config_list['site_theme'];
     $this->load->helper('directory');
     $files = directory_map('themes/' . $site_theme . '/views/layouts/', 1);
     sort($files);
     foreach ($files as $file) {
         if (is_dir('themes/' . $site_theme . '/views/layouts/' . $file)) {
             continue;
         }
         $file = str_ireplace('.php', '', $file);
         if ($file == $config_list['site_layout']) {
             continue;
         }
         $layout_list[] = $file;
     }
     // get third_party_configurations
     include $hybridauth_config_file;
     $third_party_config = array();
     foreach ($third_party_variables as $var) {
         eval('$third_party_config["' . $var . '"] = $' . $var . ';');
     }
     // update route
     if ($this->cms_is_module_active('gofrendi.noCMS.multisite')) {
         $module_path = $this->cms_module_path('gofrendi.noCMS.multisite');
         if (strtoupper($this->cms_get_config('cms_add_subsite_on_register')) == 'TRUE') {
             $this->cms_add_route('main/register', $module_path . '/multisite/register');
         } else {
             $this->cms_remove_route('main/register');
         }
     }
     $default_controller = $this->cms_get_default_controller();
     // send to the view
     $data['normal_widget_list'] = $normal_widget_list;
     $data['section_widget_list'] = $section_widget_list;
     $data['language_list'] = $language_list;
     $data['config_list'] = $config_list;
     $data['layout_list'] = $layout_list;
     $data['current_language'] = $this->cms_get_config('site_language', True);
     $data['default_controller'] = $default_controller;
     $data['multisite_active'] = $this->cms_is_module_active('gofrendi.noCMS.multisite');
     $data['third_party_config'] = $third_party_config;
     $data['changed'] = count($_POST) > 0;
     $this->view('setting_index', $data, 'main_setting');
 }
コード例 #17
0
ファイル: Manage_article.php プロジェクト: nonconforme/No-CMS
 public function callback_field_comments($value, $primary_key)
 {
     $module_path = $this->cms_module_path();
     $this->config->load('grocery_crud');
     $date_format = $this->config->item('grocery_crud_date_format');
     if (!isset($primary_key)) {
         $primary_key = -1;
     }
     $query = $this->db->select('comment_id, date, author_user_id, name, email, website, content')->from($this->cms_complete_table_name('comment'))->where('article_id', $primary_key)->get();
     $result = $query->result_array();
     // change the comment status into read
     $data = array('read' => 1);
     $where = array('article_id' => $primary_key);
     $this->db->update($this->cms_complete_table_name('comment'), $data, $where);
     $search = array('<', '>');
     $replace = array('&lt;', '&gt;');
     for ($i = 0; $i < count($result); $i++) {
         $row = $result[$i];
         $user_id = $row['author_user_id'];
         if ($user_id > 0) {
             $query_user = $this->db->select('real_name, email')->from(cms_table_name('main_user'))->where('user_id', $user_id)->get();
             $row_user = $query_user->row();
             $result[$i]['name'] = $row_user->real_name;
             $result[$i]['email'] = $row_user->email;
         }
         $result[$i]['content'] = str_replace($search, $replace, $result[$i]['content']);
         $result[$i]['website'] = prep_url($result[$i]['website']);
     }
     // get options
     $options = array();
     $data = array('result' => $result, 'options' => $options, 'date_format' => $date_format);
     return $this->load->view($this->cms_module_path() . '/field_article_comments', $data, TRUE);
 }
コード例 #18
0
ファイル: Info.php プロジェクト: jeremywong1992/No-CMS
 public function do_upgrade($old_version)
 {
     $module_path = $this->cms_module_path();
     // table : blog article
     $table_name = $this->cms_complete_table_name('article');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('keyword' => $this->TYPE_VARCHAR_100_NULL, 'description' => $this->TYPE_TEXT, 'status' => array('type' => 'enum', 'constraint' => array('draft', 'published', 'scheduled'), 'default' => 'draft', 'null' => FALSE), 'publish_date' => $this->TYPE_DATETIME_NULL);
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     // table : blog comment
     $table_name = $this->cms_complete_table_name('comment');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('parent_comment_id' => $this->TYPE_INT_UNSIGNED_NULL, 'read' => array('type' => 'INT', 'constraint' => 20, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0));
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     // navigation: blog_index
     $table_name = cms_table_name('main_navigation');
     $navigation_name = $this->cms_complete_navigation_name('index');
     $this->db->update($table_name, array('notif_url' => $this->cms_module_path($this->NAME) . '/notif/new_comment'), array('navigation_name' => $navigation_name));
     // navigation: blog_article
     $navigation_name = $this->cms_complete_navigation_name('manage_article');
     $this->db->update($table_name, array('notif_url' => $this->cms_module_path($this->NAME) . '/notif/new_comment'), array('navigation_name' => $navigation_name));
     // add widget archive
     $query = $this->db->select('widget_name')->from(cms_table_name('main_widget'))->where('widget_name', $this->cms_complete_navigation_name('archive'))->get();
     if ($query->num_rows() > 0) {
         $this->cms_add_widget($this->cms_complete_navigation_name('archive'), 'Archive', $this->PRIV_EVERYONE, $this->cms_module_path() . '/blog_widget/archive', 'sidebar');
     }
     // add widget blog
     $query = $this->db->select('widget_name')->from(cms_table_name('main_widget'))->where('widget_name', 'blog_content')->get();
     if ($query->num_rows() == 0) {
         $this->cms_add_widget($this->cms_complete_navigation_name('content'), 'Blog Content', $this->PRIV_EVERYONE, $this->cms_module_path());
     }
     $version_part = explode('.', $old_version);
     $major = $version_part[0];
     $minor = $version_part[1];
     $build = $version_part[2];
     if ($major == 0 && $minor == 0 && $build <= 4) {
         $this->db->update($this->cms_complete_table_name('article'), array('status' => 'published'), array('status' => 'draft'));
         $this->cms_add_group('Blog Editor', 'Can Add, Edit, Delete & Publish other\'s articles');
         $this->cms_add_group('Blog Author', 'Can Add, Edit, Delete & Publish his/her own articles');
         $this->cms_add_group('Blog Contributor', 'Can Add, Edit, and Delete his/her own articles');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_article'), 'Blog Editor');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_article'), 'Blog Author');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_article'), 'Blog Contributor');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_category'), 'Blog Editor');
     }
     if ($major == 0 && $minor == 0 && $build <= 5) {
         $fields = array('publish_date' => $this->TYPE_DATETIME_NULL);
         $table_name = $this->cms_complete_table_name('article');
         $this->dbforge->modify_column($table_name, $fields);
     }
     if ($major == 0 && $minor == 0 && $build <= 6) {
         $fields = array('article_id' => $this->TYPE_INT_UNSIGNED_AUTO_INCREMENT, 'article_title' => $this->TYPE_TEXT, 'article_url' => $this->TYPE_TEXT);
         $table_name = $this->cms_complete_table_name('article');
         $this->dbforge->modify_column($table_name, $fields);
         $fields = array('url' => $this->TYPE_TEXT);
         $table_name = $this->cms_complete_table_name('photo');
         $this->dbforge->modify_column($table_name, $fields);
     }
     if ($major == 0 && $minor == 0 && $build <= 7) {
         $fields = array('visited' => $this->TYPE_INT_UNSIGNED_NULL, 'featured' => $this->TYPE_INT_UNSIGNED_NULL);
         $table_name = $this->cms_complete_table_name('article');
         $this->dbforge->add_column($table_name, $fields);
         // add popular and featured articles widgets
         $this->cms_add_widget($this->cms_complete_navigation_name('popular_article'), 'Popular Articles', $this->PRIV_EVERYONE, $module_path . '/blog_widget/popular', 'sidebar');
         $this->cms_add_widget($this->cms_complete_navigation_name('featured_article'), 'Featured Articles', $this->PRIV_EVERYONE, $module_path . '/blog_widget/featured', 'sidebar');
     }
     if ($major == 0 && $minor == 0 && $build <= 8) {
         $this->cms_add_navigation($this->cms_complete_navigation_name('setting'), 'Setting', $module_path . '/setting', $this->PRIV_AUTHORIZED, $this->cms_complete_navigation_name('index'), NULL, 'Blog Setting', NULL, NULL, 'default-one-column');
         // add configuration
         $this->cms_add_config($this->cms_complete_navigation_name('moderation'), 'FALSE', 'Is comment in blog need moderation?');
         // publication status
         $fields = array('status' => $this->TYPE_VARCHAR_50_NULL);
         $this->dbforge->add_field($fields);
         $this->dbforge->add_key('status', TRUE);
         $this->dbforge->create_table($this->cms_complete_table_name('publication_status'));
         $table_name = $this->cms_complete_table_name('publication_status');
         $data = array('status' => 'draft');
         $this->db->insert($table_name, $data);
         $data = array('status' => 'published');
         $this->db->insert($table_name, $data);
         $data = array('status' => 'scheduled');
         $this->db->insert($table_name, $data);
         // comment
         $fields = array('approved' => array('type' => 'INT', 'constraint' => 20, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0));
         $table_name = $this->cms_complete_table_name('comment');
         $this->dbforge->add_column($table_name, $fields);
         $this->db->update($this->cms_complete_table_name('comment'), array('approved' => 1));
         // photo
         $fields = array('index' => array('type' => 'INT', 'constraint' => 20, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0), 'caption' => $this->TYPE_TEXT);
         $table_name = $this->cms_complete_table_name('photo');
         $this->dbforge->add_column($table_name, $fields);
         $query = $this->db->select('article_id')->from($this->cms_complete_table_name('article'))->get();
         foreach ($query->result() as $row) {
             $article_id = $row->article_id;
             $query_photo = $this->db->select('photo_id')->from($this->cms_complete_table_name('photo'))->where('article_id', $article_id)->get();
             $index = 1;
             foreach ($query_photo->result() as $row_photo) {
                 $photo_id = $row_photo->photo_id;
                 $this->db->update($this->cms_complete_table_name('photo'), array('index' => $index), array('photo_id' => $photo_id));
                 $index++;
             }
         }
         // route
         if ($module_path == 'blog') {
             $controller_path = 'blog';
         } else {
             $controller_path = $module_path . '/blog';
         }
         $this->cms_add_route($controller_path . '/(:any)\\.html', $controller_path . '/index/$1', 'Route to blog\'s article');
         $this->cms_add_route($controller_path . '/category/(:any)', $controller_path . '/index//$1', 'Route to blog\'s category');
         $this->cms_add_route($controller_path . '/archive/(:any)', $controller_path . '/index///$1', 'Route to blog\'s archive');
         $this->cms_add_route($controller_path . '/category', $controller_path . '/index/', 'Route to blog\'s category');
         $this->cms_add_route($controller_path . '/archive', $controller_path . '/index/', 'Route to blog\'s archive');
     }
 }
コード例 #19
0
ファイル: main.php プロジェクト: kevinmel2000/ci_webblog
 public function widget_online_user_ajax()
 {
     $query = $this->db->select('user_name')->from(cms_table_name('main_user'))->where('login', 1)->where('last_active >=', microtime(true) - 70)->get();
     $user_name_list = array();
     foreach ($query->result() as $row) {
         $user_name_list[] = $row->user_name;
     }
     if (count($user_name_list) > 0) {
         echo implode(', ', $user_name_list);
     } else {
         echo 'No user online';
     }
 }
コード例 #20
0
ファイル: Info.php プロジェクト: nonconforme/No-CMS
 public function do_upgrade($old_version)
 {
     $module_path = $this->cms_module_path();
     // table : blog article
     $table_name = $this->cms_complete_table_name('article');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('keyword' => $this->TYPE_VARCHAR_100_NULL, 'description' => $this->TYPE_TEXT, 'status' => array('type' => 'ENUM("draft","published","scheduled")', 'default' => 'draft', 'null' => FALSE), 'publish_date' => $this->TYPE_DATETIME_NULL);
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     // table : blog comment
     $table_name = $this->cms_complete_table_name('comment');
     $field_list = $this->db->list_fields($table_name);
     $missing_fields = array('parent_comment_id' => $this->TYPE_INT_UNSIGNED_NULL, 'read' => array('type' => 'INT', 'constraint' => 20, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0));
     $fields = array();
     foreach ($missing_fields as $key => $value) {
         if (!in_array($key, $field_list)) {
             $fields[$key] = $value;
         }
     }
     $this->dbforge->add_column($table_name, $fields);
     // navigation: blog_index
     $table_name = cms_table_name('main_navigation');
     $navigation_name = $this->cms_complete_navigation_name('index');
     $this->db->update($table_name, array('notif_url' => $this->cms_module_path($this->NAME) . '/notif/new_comment'), array('navigation_name' => $navigation_name));
     // navigation: blog_article
     $navigation_name = $this->cms_complete_navigation_name('manage_article');
     $this->db->update($table_name, array('notif_url' => $this->cms_module_path($this->NAME) . '/notif/new_comment'), array('navigation_name' => $navigation_name));
     // add widget archive
     $query = $this->db->select('widget_name')->from(cms_table_name('main_widget'))->where('widget_name', $this->cms_complete_navigation_name('archive'))->get();
     if ($query->num_rows() > 0) {
         $this->cms_add_widget($this->cms_complete_navigation_name('archive'), 'Archive', $this->PRIV_EVERYONE, $this->cms_module_path() . '/blog_widget/archive', 'sidebar');
     }
     // add widget blog
     $query = $this->db->select('widget_name')->from(cms_table_name('main_widget'))->where('widget_name', 'blog_content')->get();
     if ($query->num_rows() == 0) {
         $this->cms_add_widget($this->cms_complete_navigation_name('content'), 'Blog Content', $this->PRIV_EVERYONE, $this->cms_module_path());
     }
     $version_part = explode('.', $old_version);
     $major = $version_part[0];
     $minor = $version_part[1];
     $build = $version_part[2];
     if ($major == 0 && $minor == 0 && $build <= 4) {
         $this->db->update($this->cms_complete_table_name('article'), array('status' => 'published'), array('status' => 'draft'));
         $this->cms_add_group('Blog Editor', 'Can Add, Edit, Delete & Publish other\'s articles');
         $this->cms_add_group('Blog Author', 'Can Add, Edit, Delete & Publish his/her own articles');
         $this->cms_add_group('Blog Contributor', 'Can Add, Edit, and Delete his/her own articles');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_article'), 'Blog Editor');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_article'), 'Blog Author');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_article'), 'Blog Contributor');
         $this->cms_assign_navigation($this->cms_complete_navigation_name('manage_category'), 'Blog Editor');
     }
     if ($major == 0 && $minor == 0 && $build <= 5) {
         $fields = array('publish_date' => $this->TYPE_DATETIME_NULL);
         $table_name = $this->cms_complete_table_name('article');
         $this->dbforge->modify_column($table_name, $fields);
     }
     if ($major == 0 && $minor == 0 && $build <= 6) {
         $fields = array('article_id' => $this->TYPE_INT_UNSIGNED_AUTO_INCREMENT, 'article_title' => $this->TYPE_TEXT, 'article_url' => $this->TYPE_TEXT);
         $table_name = $this->cms_complete_table_name('article');
         $this->dbforge->modify_column($table_name, $fields);
         $fields = array('url' => $this->TYPE_TEXT);
         $table_name = $this->cms_complete_table_name('photo');
         $this->dbforge->modify_column($table_name, $fields);
     }
     if ($major == 0 && $minor == 0 && $build <= 7) {
         $fields = array('visited' => $this->TYPE_INT_UNSIGNED_NULL, 'featured' => $this->TYPE_INT_UNSIGNED_NULL);
         $table_name = $this->cms_complete_table_name('article');
         $this->dbforge->add_column($table_name, $fields);
         // add popular and featured articles widgets
         $this->cms_add_widget($this->cms_complete_navigation_name('popular_article'), 'Popular Articles', $this->PRIV_EVERYONE, $module_path . '/blog_widget/popular', 'sidebar');
         $this->cms_add_widget($this->cms_complete_navigation_name('featured_article'), 'Featured Articles', $this->PRIV_EVERYONE, $module_path . '/blog_widget/featured', 'sidebar');
     }
 }
コード例 #21
0
 /**
  * @author  goFrendiAsgard
  * @param   string view_url
  * @param   string data
  * @param   string navigation_name
  * @param   array config
  * @param   bool return_as_string
  * @return  string or null
  * @desc    replace $this->load->view. This method will also load header, menu etc except there is _only_content parameter via GET or POST
  */
 protected function view($view_url, $data = NULL, $navigation_name = NULL, $config = NULL, $return_as_string = FALSE)
 {
     $this->load->library('template');
     $result = NULL;
     $view_url = $this->cms_parse_keyword($view_url);
     /**
      * PREPARE PARAMETERS *********************************************************************************************
      */
     // get dynamic widget status
     // (this is necessary since sometime the function called directly without run the constructor, i.e: when using Modules::run)
     if (isset($_REQUEST['__cms_dynamic_widget'])) {
         $this->__cms_dynamic_widget = TRUE;
     }
     /**
      * PREPARE PARAMETERS *********************************************************************************************
      */
     // this method can be called as $this->view('view_path', $data, true);
     // or $this->view('view_path', $data, $navigation_name, true);
     if (is_bool($navigation_name) && count($config) == 0) {
         $return_as_string = $navigation_name;
         $navigation_name = NULL;
         $config = NULL;
     } else {
         if (is_bool($config)) {
             $return_as_string = $config;
             $config = NULL;
         }
     }
     if (!isset($return_as_string)) {
         $return_as_string = FALSE;
     }
     if (!isset($config)) {
         $config = array();
     }
     $privilege_required = isset($config['privileges']) ? $config['privileges'] : array();
     $custom_theme = isset($config['theme']) ? $config['theme'] : NULL;
     $custom_layout = isset($config['layout']) ? $config['layout'] : NULL;
     $custom_title = isset($config['title']) ? $config['title'] : NULL;
     $custom_metadata = isset($config['metadata']) ? $config['metadata'] : array();
     $custom_partial = isset($config['partials']) ? $config['partials'] : NULL;
     $custom_keyword = isset($config['keyword']) ? $config['keyword'] : NULL;
     $custom_description = isset($config['description']) ? $config['description'] : NULL;
     $custom_author = isset($config['author']) ? $config['author'] : NULL;
     $only_content = isset($config['only_content']) ? $config['only_content'] : FALSE;
     $always_allow = isset($config['always_allow']) ? $config['always_allow'] : FALSE;
     $layout_suffix = isset($config['layout_suffix']) ? $config['layout_suffix'] : '';
     $custom_css = isset($config['css']) ? $config['css'] : '';
     $custom_js = isset($config['js']) ? $config['js'] : '';
     /**
      * GUESS $navigation_name THROUGH ITS URL  ***********************************************************************
      */
     $navigation_name_provided = TRUE;
     if (!isset($navigation_name) && !$this->__cms_dynamic_widget) {
         $navigation_name = $this->cms_navigation_name();
         if (!$navigation_name) {
             $navigation_name_provided = FALSE;
         }
     }
     /**
      * CHECK IF THE CURRENT NAVIGATION IS ACCESSIBLE  *****************************************************************
      */
     if (!$always_allow) {
         $this->cms_guard_page($navigation_name, $privilege_required);
     }
     // privilege is absolute
     $this->cms_guard_page(NULL, $privilege_required);
     /**
      * CHECK IF THE PAGE IS STATIC  **********************************************************************************
      */
     $data = (array) $data;
     $row_navigation = NULL;
     if ($navigation_name != NULL) {
         $query = $this->db->select('navigation_id, title, page_title, page_keyword, description, default_theme, default_layout, only_content, is_static, static_content')->from(cms_table_name('main_navigation'))->where(array('navigation_name' => $navigation_name))->get();
         if ($query->num_rows() > 0) {
             $row_navigation = $query->row();
         }
     }
     if ($navigation_name_provided && !isset($data['_content']) && $row_navigation != NULL) {
         if ($row_navigation->is_static == 1) {
             $static_content = $row_navigation->static_content;
             // static_content should contains string
             if (!$static_content) {
                 $static_content = '';
             }
             if ($this->cms_editing_mode() && $this->cms_allow_navigate('main_navigation_management')) {
                 $static_content = '<div class="row" style="padding-top:10px; padding-bottom:10px;"><a class="btn btn-primary pull-right" href="{{ SITE_URL }}main/navigation/edit/' . $row_navigation->navigation_id . '">' . '<i class="glyphicon glyphicon-pencil"></i> Edit Page' . '</a></div>' . $static_content;
             }
             $data['cms_content'] = $static_content;
             $view_url = 'CMS_View';
         }
     }
     /**
      * SHOW THE PAGE IF IT IS ACCESSIBLE  *****************************************************************************
      */
     // GET THE THEME, TITLE & ONLY_CONTENT FROM DATABASE
     $theme = '';
     $title = '';
     $keyword = '';
     $default_theme = NULL;
     $default_layout = NULL;
     $page_title = NULL;
     $page_keyword = NULL;
     $page_description = NULL;
     $page_author = NULL;
     if ($navigation_name_provided && $row_navigation != NULL) {
         $default_theme = $row_navigation->default_theme;
         $default_layout = $row_navigation->default_layout;
         // title
         if (isset($row_navigation->page_title) && $row_navigation->page_title !== NULL && $row_navigation->page_title != '') {
             $page_title = $row_navigation->page_title;
         } else {
             if (isset($row_navigation->title) && $row_navigation->title !== NULL && $row_navigation->title != '') {
                 $page_title = $row_navigation->title;
             }
         }
         $page_title = isset($page_title) && $page_title !== NULL ? $page_title : '';
         // keyword
         $page_keyword = isset($row_navigation->page_keyword) && $row_navigation->page_keyword !== NULL ? $row_navigation->page_keyword : '';
         // keyword
         $page_description = isset($row_navigation->description) && $row_navigation->description !== NULL ? $row_navigation->description : '';
         // only content
         if (!isset($only_content)) {
             $only_content = $row_navigation->only_content == 1;
         }
     }
     // ASSIGN THEME
     if (isset($custom_theme) && $custom_theme !== NULL && $custom_theme != '') {
         $theme = $custom_theme;
     } else {
         if (isset($default_theme) && $default_theme != NULL && $default_theme != '') {
             $themes = $this->cms_get_theme_list();
             $theme_path = array();
             foreach ($themes as $theme) {
                 $theme_path[] = $theme['path'];
             }
             if (in_array($default_theme, $theme_path)) {
                 $theme = $default_theme;
             }
         } else {
             $theme = $this->cms_get_config('site_theme');
         }
     }
     // ASSIGN TITLE
     $title = '';
     if (isset($custom_title) && $custom_title !== NULL && $custom_title != '') {
         $title = $this->cms_get_config('site_name') . ' - ' . $custom_title;
     } else {
         if (isset($page_title) && $page_title !== NULL && $page_title != '') {
             $title = $this->cms_get_config('site_name') . ' - ' . $page_title;
         } else {
             $title = $this->cms_get_config('site_name');
         }
     }
     // ASSIGN KEYWORD
     if (isset($custom_keyword) && $custom_keyword != NULL && $custom_keyword != '') {
         $keyword = $custom_keyword;
     } else {
         if (isset($page_keyword) && $page_keyword !== NULL && $page_keyword != '') {
             $keyword = $page_keyword;
             if ($custom_keyword != '') {
                 $keyword .= ', ' . $custom_keyword;
             }
         } else {
             $keyword = '';
         }
     }
     // ASSIGN DESCRIPTION
     if (isset($custom_description) && $custom_description != NULL && $custom_description != '') {
         $description = $custom_description;
     } else {
         if (isset($page_description) && $page_description !== NULL && $page_description != '') {
             $description = $page_description;
             if ($custom_description != '') {
                 $description .= ', ' . $custom_description;
             }
         } else {
             $description = '';
         }
     }
     // ASSIGN AUTHOR
     if (isset($custom_author) && $custom_author != NULL && $custom_author != '') {
         $author = $custom_author;
     } else {
         $author = $this->{$this->__cms_base_model_name}->cms_get_super_admin()->real_name;
     }
     // GET THE LAYOUT
     if (isset($custom_layout)) {
         $layout = $custom_layout;
     } else {
         if (isset($default_layout) && $default_layout != '') {
             $layout = $default_layout;
         } else {
             $this->load->library('user_agent');
             $layout = $this->agent->is_mobile() ? 'mobile' : $this->cms_get_config('site_layout');
         }
     }
     // ADJUST THEME AND LAYOUT
     if (!$this->cms_layout_exists($theme, $layout)) {
         // ASSIGN LAYOUT
         if (!file_exists(FCPATH . 'themes/' . $theme) || !is_dir(FCPATH . 'themes/' . $theme)) {
             $theme = 'neutral';
         }
         if (!file_exists(FCPATH . 'themes/' . $theme . '/views/layouts/' . $layout . '.php')) {
             $layout = 'default';
             if (!file_exists(FCPATH . 'themes/' . $theme . '/views/layouts/default.php')) {
                 $theme = 'neutral';
             }
         }
     }
     // save used_theme
     $this->session->set_userdata('__cms_used_theme', $theme);
     // ADD AUTHENTICATED SUFFIX (in case of user has logged in)
     $cms_user_id = $this->cms_user_id();
     if ($layout_suffix == '' && isset($cms_user_id) && $cms_user_id) {
         $layout_suffix = 'authenticated';
     }
     if ($this->cms_layout_exists($theme, $layout . '_' . $layout_suffix)) {
         $layout = $layout . '_' . $layout_suffix;
     }
     $data['__is_bootstrap_cdn_connected'] = FALSE;
     // IT'S SHOW TIME
     if ($only_content || $this->__cms_dynamic_widget || isset($_REQUEST['_only_content']) || $this->input->is_ajax_request()) {
         $result = $this->load->view($view_url, $data, TRUE);
         $result = $custom_css . $custom_js . $result;
     } else {
         // save navigation name
         $this->cms_ci_session('__cms_navigation_name', $navigation_name);
         // set theme, layout and title
         $this->template->title($title);
         $this->template->set_theme($theme);
         $this->template->set_layout($layout);
         // set keyword metadata
         if ($keyword != '') {
             $keyword_metadata = '<meta name="keyword" content="' . $keyword . '">';
             $this->template->append_metadata($keyword_metadata);
         }
         // set description metadata
         if ($description != '') {
             $description_metadata = '<meta name="description" content="' . $description . '">';
             $this->template->append_metadata($description_metadata);
         }
         // set author metadata
         if ($author != '') {
             $author_metadata = '<meta name="author" content="' . $author . '">';
             $this->template->append_metadata($author_metadata);
         }
         // add IE compatibility
         $this->template->append_metadata('<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">');
         // add width
         $this->template->append_metadata('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
         $asset = new Cms_asset();
         $asset->add_js(base_url('assets/grocery_crud/js/jquery-1.10.2.min.js'));
         // ckeditor adjustment thing
         $asset->add_internal_js($this->cms_ck_adjust_script());
         // add javascript base_url for ckeditor
         $asset->add_internal_js('var __cms_base_url = "' . base_url() . '";');
         // check login status
         //$login_code = '<script type="text/javascript">';
         $login_code = '';
         if ($this->cms_user_id() > 0) {
             $login_code .= 'var __cms_is_login = true;';
         } else {
             $login_code .= 'var __cms_is_login = false;';
         }
         $login_code .= 'setInterval(function(){
             $.ajax({
                 url : "{{ site_url }}main/json_login_info",
                 dataType: "json",
                 success: function(response){
                     if(response.is_login != __cms_is_login){
                         window.location = $(location).attr("href");
                     }
                 }
             });
         },300000);';
         $asset->add_internal_js($login_code);
         // google analytic
         $analytic_property_id = $this->cms_get_config('cms_google_analytic_property_id');
         if (trim($analytic_property_id) != '') {
             if ($this->cms_is_connect('google-analytics.com')) {
                 // create analytic code
                 $analytic_code = '';
                 $analytic_code .= 'var _gaq = _gaq || []; ';
                 $analytic_code .= '_gaq.push([\'_setAccount\', \'' . $analytic_property_id . '\']); ';
                 $analytic_code .= '_gaq.push([\'_trackPageview\']); ';
                 $analytic_code .= '(function() { ';
                 $analytic_code .= 'var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true; ';
                 $analytic_code .= 'ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\'; ';
                 $analytic_code .= 'var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); ';
                 $analytic_code .= '})(); ';
                 $asset->add_internal_js($analytic_code);
             }
         }
         // add hack if exists
         if (!isset($_SESSION)) {
             session_start();
         }
         if (isset($_SESSION['__cms_flash_metadata'])) {
             $this->template->append_metadata($_SESSION['__cms_flash_metadata']);
             unset($_SESSION['__cms_flash_metadata']);
         }
         // config metadata
         foreach ($custom_metadata as $metadata) {
             $this->template->append_metadata($metadata);
         }
         // append custom css & js
         $this->template->append_js($asset->compile_js());
         $this->template->append_css($asset->compile_css());
         $this->template->append_js($custom_js);
         $this->template->append_css($custom_css);
         $this->load->helper('directory');
         $partial_path = BASEPATH . '../themes/' . $theme . '/views/partials/' . $layout . '/';
         if (is_dir($partial_path)) {
             $partials = directory_map($partial_path, 1);
             foreach ($partials as $partial) {
                 // if is directory or is not php, then ignore it
                 if (is_dir($partial)) {
                     continue;
                 }
                 $partial_extension = pathinfo($partial_path . $partial, PATHINFO_EXTENSION);
                 if (strtoupper($partial_extension) != 'PHP') {
                     continue;
                 }
                 // add partial to template
                 $partial_name = pathinfo($partial_path . $partial, PATHINFO_FILENAME);
                 if (isset($custom_partial[$partial_name])) {
                     $this->template->inject_partial($partial_name, $custom_partial[$partial_name]);
                 } else {
                     $this->template->set_partial($partial_name, 'partials/' . $layout . '/' . $partial, $data);
                 }
             }
         }
         $result = $this->template->build($view_url, $data, TRUE);
     }
     // parse keyword
     $result = $this->cms_parse_keyword($result);
     // parse widgets used_theme & navigation_path
     $result = $this->__cms_parse_widget_theme_path($result, $theme, $layout, $navigation_name);
     $this->load->library('cms_asset');
     $asset = new Cms_asset();
     $result = $asset->minify($result);
     if ($return_as_string) {
         return $result;
     } else {
         $this->cms_show_html($result);
     }
 }
コード例 #22
0
 public function index()
 {
     // save the uploaded files
     if (isset($_FILES['site_logo'])) {
         $site_logo = $_FILES['site_logo'];
         if (isset($site_logo['tmp_name']) && $site_logo['tmp_name'] != '') {
             move_uploaded_file($site_logo['tmp_name'], BASEPATH . '../assets/nocms/images/custom_logo/' . $site_logo['name']);
             $this->cms_set_config('site_logo', '{{ base_url }}assets/nocms/images/custom_logo/' . $site_logo['name']);
         }
     }
     if (isset($_FILES['site_favicon'])) {
         $site_favicon = $_FILES['site_favicon'];
         if (isset($site_favicon['tmp_name']) && $site_favicon['tmp_name'] != '') {
             move_uploaded_file($site_favicon['tmp_name'], BASEPATH . '../assets/nocms/images/custom_favicon/' . $site_favicon['name']);
             $this->cms_set_config('site_favicon', '{{ base_url }}assets/nocms/images/custom_favicon/' . $site_favicon['name']);
         }
     }
     if (count($_POST) > 0) {
         // save the section widgets
         $this->update_static_content('section_top_fix', $this->input->post('section_top_fix'));
         $this->update_static_content('section_banner', $this->input->post('section_banner'));
         $this->update_static_content('section_left', $this->input->post('section_left'));
         $this->update_static_content('section_right', $this->input->post('section_right'));
         $this->update_static_content('section_bottom', $this->input->post('section_bottom'));
         $this->update_static_content('navigation_right_partial', $this->input->post('navigation_right_partial'));
         // save configurations
         $this->cms_set_config('site_name', $this->input->post('site_name'));
         $this->cms_set_config('site_layout', $this->input->post('site_layout'));
         $this->cms_set_config('site_slogan', $this->input->post('site_slogan'));
         $this->cms_set_config('site_footer', $this->input->post('site_footer'));
         $this->cms_set_config('site_language', $this->input->post('site_language'));
         $this->cms_language($this->input->post('site_language'));
     }
     // redirection
     if (count($_POST) > 0 || isset($_FILES['site_logo']) || isset($_FILES['site_favicon'])) {
         redirect('main/layout/index');
     }
     // widgets
     $query = $this->db->select('widget_id, widget_name, static_content')->from(cms_table_name('main_widget'))->get();
     $widget_list = $query->result_array();
     $normal_widget_list = array();
     $section_widget_list = array();
     foreach ($widget_list as $widget) {
         if ($widget['widget_id'] < 6 || $widget['widget_name'] == 'navigation_right_partial') {
             $section_widget_list[$widget['widget_name']] = $widget;
         } else {
             $normal_widget_list[] = $widget;
         }
     }
     // languages
     $language_list = $this->cms_language_list();
     // config
     $query = $this->db->select('config_name, value')->from(cms_table_name('main_config'))->get();
     $config_list = array();
     foreach ($query->result_array() as $row) {
         $config_list[$row['config_name']] = $row['value'];
     }
     // layout
     $layout_list = array();
     $site_theme = $config_list['site_theme'];
     $this->load->helper('directory');
     $files = directory_map('themes/' . $site_theme . '/views/layouts/', 1);
     sort($files);
     foreach ($files as $file) {
         if (is_dir('themes/' . $site_theme . '/views/layouts/' . $file)) {
             continue;
         }
         $file = str_ireplace('.php', '', $file);
         if ($file == $config_list['site_layout']) {
             continue;
         }
         $layout_list[] = $file;
     }
     // send to the view
     $data['normal_widget_list'] = $normal_widget_list;
     $data['section_widget_list'] = $section_widget_list;
     $data['language_list'] = $language_list;
     $data['config_list'] = $config_list;
     $data['layout_list'] = $layout_list;
     $data['current_language'] = $this->cms_get_config('site_language', True);
     $this->view('layout_index', $data, 'main_layout');
 }
コード例 #23
0
 private function __update_to_0_7_9()
 {
     $fields = array('description' => array('null' => TRUE));
     $this->dbforge->modify_column(cms_table_name('main_route'), $fields);
 }
コード例 #24
0
ファイル: hauth.php プロジェクト: kevinmel2000/ci_webblog
 public function login($provider)
 {
     log_message('debug', "controllers.HAuth.login({$provider}) called");
     $params = array();
     if ($provider == 'OpenID') {
         $open_id_identifier = $this->input->post('open_id_identifier');
         if (!$open_id_identifier) {
             redirect('main/hauth/open_id');
         } else {
             $params['openid_identifier'] = $open_id_identifier;
         }
     }
     try {
         log_message('debug', 'controllers.HAuth.login: loading HybridAuthLib');
         if ($this->hybridauthlib->providerEnabled($provider)) {
             log_message('debug', "controllers.HAuth.login: service {$provider} enabled, trying to authenticate.");
             $service = $this->hybridauthlib->authenticate($provider, $params);
             if ($service->isUserConnected()) {
                 // twitter doesn't provide email address, we should humbly ask to the user...
                 if ($provider == 'Twitter') {
                     // check if the user already registered in our database
                     $status = $this->cms_third_party_status();
                     $identifier = $status[$provider]['identifier'];
                     $query = $this->db->select('auth_' . $provider)->from(cms_table_name('main_user'))->where('auth_' . $provider, $identifier)->get();
                     // if it is not, let's humbly ask the user's email
                     if ($query->num_rows() == 0) {
                         redirect('main/hauth/email/' . $provider);
                     }
                 }
                 $this->cms_third_party_login($provider);
                 //$this->hybridauthlib->logoutAllProviders();
                 log_message('debug', 'controller.HAuth.login: user authenticated.');
                 redirect('', 'refresh');
             } else {
                 show_error('Cannot authenticate user');
             }
         } else {
             log_message('error', 'controllers.HAuth.login: This provider is not enabled (' . $provider . ')');
             show_404($_SERVER['REQUEST_URI']);
         }
     } catch (Exception $e) {
         $error = 'Unexpected error';
         switch ($e->getCode()) {
             case 0:
                 $error = 'Unspecified error.';
                 break;
             case 1:
                 $error = 'Hybriauth configuration error.';
                 break;
             case 2:
                 $error = 'Provider not properly configured.';
                 break;
             case 3:
                 $error = 'Unknown or disabled provider.';
                 break;
             case 4:
                 $error = 'Missing provider application credentials.';
                 break;
             case 5:
                 log_message('debug', 'controllers.HAuth.login: Authentification failed. The user has canceled the authentication or the provider refused the connection.');
                 //redirect();
                 if (isset($service)) {
                     log_message('debug', 'controllers.HAuth.login: logging out from service.');
                     $service->logout();
                 }
                 show_error('User has cancelled the authentication or the provider refused the connection.');
                 break;
             case 6:
                 $error = 'User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again.';
                 break;
             case 7:
                 $error = 'User not connected to the provider.';
                 break;
         }
         if (isset($service)) {
             $service->logout();
         }
         log_message('error', 'controllers.HAuth.login: '******'Error authenticating user.');
     }
 }
コード例 #25
0
ファイル: CMS_Module.php プロジェクト: jeremywong1992/No-CMS
 private final function child_module()
 {
     $SQL = "SELECT module_id FROM " . cms_table_name('main_module') . " WHERE module_name='" . addslashes($this->NAME) . "'";
     $query = $this->db->query($SQL);
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $parent_id = $row->module_id;
         $SQL = "\n\t            SELECT module_name, module_path\n\t            FROM\n\t                " . cms_table_name('main_module_dependency') . ",\n\t                " . cms_table_name('main_module') . "\n\t            WHERE\n\t                " . cms_table_name('main_module') . ".module_id = " . cms_table_name('main_module_dependency') . ".module_id AND\n\t                parent_id=" . $parent_id;
         $query = $this->db->query($SQL);
         $result = array();
         foreach ($query->result() as $row) {
             $result[] = array("module_name" => $row->module_name, "module_path" => $row->module_name);
         }
         return $result;
     } else {
         return array();
     }
 }
コード例 #26
0
 private function __update_to_0_8_0()
 {
     $fields = array(
             'config_name' => array(
                     'constraint' => 100,
                 ),
         );
     $this->dbforge->modify_column(cms_table_name('main_config'), $fields);
 }
コード例 #27
0
ファイル: MY_Model.php プロジェクト: heruprambadi/simpeg
 /**
  * @author goFrendiAsgard
  * @return boolean success
  * @desc login/register by using third-party provider
  */
 public function cms_third_party_login($provider)
 {
     // if provider not valid then exit
     $status = $this->cms_third_party_status();
     if (!isset($status[$provider])) {
         return FALSE;
     }
     $identifier = $status[$provider]['identifier'];
     $user_id = $this->cms_user_id();
     $user_id = !isset($user_id) || is_null($user_id) ? 0 : $user_id;
     $query = $this->db->select('user_id')->from(cms_table_name('main_user'))->where('auth_' . $provider, $identifier)->get();
     if ($query->num_rows() > 0) {
         // get user_id based on auth field
         $row = $query->row();
         $user_id = $row->user_id;
     } else {
         // no identifier match, register it to the database
         $third_party_email = $status[$provider]['email'];
         $third_party_display_name = $status[$provider]['firstName'];
         // if email match with the database, set $user_id
         if ($user_id == FALSE) {
             $query = $this->db->select('user_id')->from(cms_table_name('main_user'))->where('email', $third_party_email)->get();
             if ($query->num_rows() > 0) {
                 $row = $query->row();
                 $user_id = $row->user_id;
             }
         }
         // if $user_id set (already_login, or $status[provider]['email'] match with database)
         if ($user_id != FALSE) {
             $data = array('auth_' . $provider => $identifier);
             $where = array('user_id' => $user_id);
             $this->db->update(cms_table_name('main_user'), $data, $where);
         } else {
             // if not already login, register provider and id to the database
             $new_user_name = $third_party_display_name;
             // ensure there is no duplicate user name
             $duplicate = TRUE;
             while ($duplicate) {
                 $query = $this->db->select('user_name')->from(cms_table_name('main_user'))->where('user_name', $new_user_name)->get();
                 if ($query->num_rows() > 0) {
                     $query = $this->db->select('user_name')->from(cms_table_name('main_user'))->get();
                     $user_count = $query->num_rows();
                     $new_user_name = 'user_' . $user_count . ' (' . $new_user_name . ')';
                 } else {
                     $duplicate = FALSE;
                 }
             }
             // insert to database
             $data = array('user_name' => $new_user_name, 'email' => $third_party_email, 'auth_' . $provider => $identifier);
             $this->db->insert(cms_table_name('main_user'), $data);
             // get user_id
             $query = $this->db->select('user_id')->from(cms_table_name('main_user'))->where('email', $third_party_email)->get();
             if ($query->num_rows() > 0) {
                 $row = $query->row();
                 $user_id = $row->user_id;
             }
         }
     }
     // set cms_user_id, cms_user_name, cms_user_email, cms_user_real_name, just as when login from the normal way
     $query = $this->db->select('user_id, user_name, email, real_name')->from(cms_table_name('main_user'))->where('user_id', $user_id)->get();
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $this->cms_user_id($row->user_id);
         $this->cms_user_name($row->user_name);
         $this->cms_user_real_name($row->real_name);
         $this->cms_user_email($row->email);
         return TRUE;
     }
     return FALSE;
 }
コード例 #28
0
ファイル: main.php プロジェクト: heruprambadi/simpeg
 public function before_delete_config($primary_key)
 {
     $query = $this->db->select('config_name')->from(cms_table_name('main_config'))->where('config_id', $primary_key)->get();
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $config_name = $row->config_name;
         // delete configuration file entry
         cms_config($config_name, '', TRUE);
     }
     return TRUE;
 }