Пример #1
0
 public function validate_advanced_search()
 {
     $this->load->module('filter');
     $this->load->module('forms');
     $form = $this->filter->create_filter_form($_POST['use_cfcm_group']);
     if ($form) {
         if ($form->isValid()) {
             $data = $form->getData();
             $data['category'] = $_POST['category'];
             $data['search_text'] = $_POST['search_text'];
             $data['use_cfcm_group'] = $_POST['use_cfcm_group'];
             $url = http_build_query($data, '', '/');
             updateDiv('page', site_url('admin/admin_search/do_advanced_search/' . $url));
         } else {
             showMessage($form->_validation_errors(), false, 'r');
         }
     } else {
         $data = $_POST;
         $url = http_build_query($data, '', '/');
         updateDiv('page', site_url('admin/admin_search/do_advanced_search/' . $url));
     }
 }
Пример #2
0
 public function send_email()
 {
     // Load form validation class
     $this->load->library('form_validation');
     $this->form_validation->set_rules('subject', lang("Theme", 'group_mailer'), 'required|trim');
     $this->form_validation->set_rules('name', lang("Your name", 'group_mailer'), 'required|trim');
     $this->form_validation->set_rules('email', lang("Your e-mail", 'group_mailer'), 'required|trim|valid_email');
     $this->form_validation->set_rules('message', lang("Message", 'group_mailer'), 'required|trim');
     if ($this->form_validation->run($this) == FALSE) {
         showMessage(validation_errors(), false, 'r');
     } else {
         $this->load->helper('typography');
         $this->load->library('email');
         // Init email config
         $config['wordwrap'] = TRUE;
         $config['charset'] = 'UTF-8';
         $config['mailtype'] = $_POST['mailtype'];
         $this->email->initialize($config);
         if (count($_POST['roles']) > 0) {
             foreach ($_POST['roles'] as $k => $v) {
                 $this->db->or_where('role_id', $v);
             }
         }
         // Get users array
         $users = $this->db->get('users');
         if ($users->num_rows() > 0) {
             $message = $_POST['message'];
             if ($_POST['mailtype'] == 'html') {
                 $message = "<html><body>" . nl2br_except_pre($message) . "</body></html>";
             }
             $counter = array('true' => 0, 'all' => 0);
             foreach ($users->result_array() as $user) {
                 // Replace {username}
                 $tmp_msg = str_replace('%username%', $user['username'], $message);
                 $this->email->from($_POST['email'], $_POST['name']);
                 $this->email->to($user['email']);
                 $this->email->reply_to($_POST['email'], $_POST['name']);
                 $this->email->subject($_POST['subject']);
                 $this->email->message($tmp_msg);
                 $counter['all']++;
                 if ($this->email->send()) {
                     $counter['true']++;
                 }
             }
             $this->load->library('lib_admin');
             $this->lib_admin->log(lang("Sent", 'group_mailer') . ' (' . $counter['true'] . '/' . $counter['all'] . ') ' . lang("users e-mail with a subject", 'group_mailer') . ' - ' . $_POST['subject']);
             $class = 'b';
             if ($counter['true'] == $counter['all']) {
                 $class = 'g';
             } else {
                 if ($counter['true'] == 0) {
                     $class = 'r';
                 }
             }
             if ($class !== 'r') {
                 showMessage(lang("Message has been sent.", 'group_mailer') . ' ' . lang("Number of e-mails sent", 'group_mailer') . ' ' . $counter['all'] . ' ' . lang('pcs.', 'group_mailer'), false, $class);
             } else {
                 showMessage(lang("None of the messages", 'group_mailer') . $counter['all'] . lang("Number not", 'group_mailer'), false, $class);
             }
             updateDiv('page', site_url('admin/components/cp/group_mailer/index'));
         }
     }
 }
Пример #3
0
 public function make_upgrade()
 {
     //cp_check_perm('cp_autoupdate');
     if (!function_exists('ftp_connect')) {
         showMessage(lang("FTP_connect function is not available", "admin"), false, 'r');
         exit;
     }
     $this->load->library('ftp');
     $this->load->helper('string');
     $this->load->helper('file');
     $status = $this->_check_status();
     if ($status['is_update'] == TRUE and $status['upgrade_file'] != '') {
         $upgrade_file = $status['upgrade_file'];
     } else {
         showMessage(lang("You are using the latest version", "admin"), lang("Congratulations!", "admin"), 'g');
         exit;
     }
     $path_to_index_php = $_POST['root_folder'];
     $config['hostname'] = $_POST['host'];
     $config['username'] = $_POST['login'];
     $config['password'] = $_POST['password'];
     $config['port'] = $_POST['port'];
     $config['passive'] = FALSE;
     $config['debug'] = FALSE;
     if ($this->ftp->connect($config) == FALSE) {
         showMessage(lang("Server connection error:Check username and password"), false, 'r');
         exit;
     }
     $root = '/' . trim_slashes($path_to_index_php) . '/';
     if ($root == '//') {
         $root = '/';
     }
     // Try to find self.
     $list = $this->ftp->list_files($root . 'application/modules/core/');
     $error = TRUE;
     foreach ($list as $k => $v) {
         if ($v == 'core' . EXT) {
             $error = FALSE;
         }
     }
     if ($error == TRUE) {
         $this->ftp->close();
         showMessage(lang("Error: Wrong path to the root directory."), false, 'r');
         exit;
     } else {
         // download zip archive
         $file = $this->upgrade_server . $upgrade_file;
         if (($fh = fopen($file, 'r')) == FALSE) {
             $this->ftp->close();
             showMessage(lang("Error downloading update file", "admin"), false, 'r');
             exit;
         } else {
             $contents = stream_get_contents($fh);
             $tmp_folder = BASEPATH . 'cache/' . time() . '/';
             // Save file
             $tmp_file = BASEPATH . 'cache/cms_upgrade.zip';
             if (file_exists($tmp_file)) {
                 @unlink($tmp_file);
             }
             write_file($tmp_file, $contents);
             if (!file_exists($tmp_folder)) {
                 mkdir($tmp_folder);
             }
             $this->load->library('pclzip', $tmp_file);
             if (($zip_result = $this->pclzip->extract(PCLZIP_OPT_PATH, $tmp_folder)) == 0) {
                 $this->ftp->close();
                 delete_files($tmp_folder, TRUE);
                 @rmdir($tmp_folder);
                 @unlink($tmp_file);
                 showMessage(lang("Exploding error", "admin"), false, 'r');
                 exit;
             }
             // Update DB
             if (file_exists($tmp_folder . 'migrations.php')) {
                 include $tmp_folder . 'migrations.php';
                 if (function_exists('run_db_upgrade')) {
                     run_db_upgrade();
                 }
                 @unlink($tmp_folder . 'migrations.php');
             }
             $this->ftp->mirror($tmp_folder, $root);
             delete_files($tmp_folder, TRUE);
             @rmdir($tmp_folder);
             @unlink($tmp_file);
             $this->ftp->close();
             // Clear system cache
             $this->load->library('cache');
             $this->cache->delete_all();
             // Rebuild sys hooks
             $this->load->library('cms_hooks');
             $this->cms_hooks->build_hooks();
             showMessage(lang("Updating has been completed", "admin"), false, 'g');
             updateDiv('page', site_url('admin/dashboard/index'));
         }
     }
 }
Пример #4
0
 /**
  * Delete page
  *
  * @access public
  */
 function delete($page_id, $show_messages = TRUE)
 {
     //cp_check_perm('page_delete');
     $settings = $this->cms_admin->get_settings();
     if ($settings['main_page_id'] == $page_id and $settings['main_type'] == 'page') {
         jsCode("alertBox.alert(" . lang("Error: Generic page can not be deleted.") . ");");
         return FALSE;
     }
     $this->db->where('id', $page_id);
     $query = $this->db->get('content', 1);
     $page = $query->row_array();
     if ($page['lang_alias'] == 0) {
         $this->db->where('id', $page['id']);
         $this->db->delete('content');
         $this->db->where('lang_alias', $page['id']);
         $this->db->delete('content');
         $this->on_page_delete($page['id']);
         if ($show_messages == TRUE) {
             showMessage(lang("Page has been deleted.", "admin"));
             updateDiv('page', site_url('admin/pages/GetPagesByCategory/' . $page['category']));
         }
         return TRUE;
     }
     $root_page = $this->cms_admin->get_page($page['lang_alias']);
     ($hook = get_hook('admin_page_delete')) ? eval($hook) : NULL;
     // delete page
     $this->db->where('id', $page['id']);
     $this->db->delete('content');
     $this->on_page_delete($page_id);
     if ($show_messages == TRUE) {
         showMessage(lang("Page has been deleted.", "admin"));
         updateDiv('page', site_url('admin/pages/edit/' . $root_page['id'] . '/' . $root_page['lang']));
     }
 }