public function __construct()
 {
     parent::__construct();
     $modulePath = getModulePath('cmsemail');
     $this->load->model('../' . getModContDirName('cmsemail') . '/cmsemail/models/cmsemail_model');
     (new \MY_Lang())->load('cmsemail');
 }
 public function __construct()
 {
     $ci =& get_instance();
     $ci->load->library('DX_Auth');
     self::$shop_controllers_path = getModulePath('shop') . "admin/";
     self::$base_controllers_path = getModulePath('admin');
 }
Beispiel #3
0
function getModuleConfigVars($module)
{
    static $arrConfigVar=array();
    if(isset($arrConfigVar[$module])) return $arrConfigVar[$module];
    $modulePath=getModulePath($module);
    if($modulePath)
    {
        $__naanal_tmp_module=$module;
        unset($module);
        if(file_exists($modulePath."{$__naanal_tmp_module}/config.php"))
        {
            include $modulePath."{$__naanal_tmp_module}/config.php";
        }
        else if(file_exists(AUIEO_APP_PATH."module_config/{$__naanal_tmp_module}.php"))
        {
            include AUIEO_APP_PATH."module_config/{$__naanal_tmp_module}.php";
        }
        else
        {
            $arrConfigVar[$__naanal_tmp_module]=array();
            return $arrConfigVar[$__naanal_tmp_module];
        }
        unset($modulePath);
        $arrConfigVar[$__naanal_tmp_module]=get_defined_vars();
        $tmp=$arrConfigVar[$__naanal_tmp_module];
        unset($arrConfigVar[$__naanal_tmp_module]["__naanal_tmp_module"]);
        return $tmp;
    }
    $tmp=array();
    return $tmp;
}
 /**
  * Cheking if file exists in module
  * @param string $module module name
  * @param string $filePath file within module
  * @return boolean 
  */
 function moduleFileExists($module, $filePath)
 {
     if (!moduleExists($module)) {
         return false;
     }
     return file_exists(getModulePath($module), ltrim($filePath, '/'));
 }
 function getEditorStyles()
 {
     $files = scandir(getModulePath('translator') . '/assets/js/src-min');
     $styles = array();
     foreach ($files as $file) {
         if (strstr($file, 'theme-')) {
             $matches = array();
             preg_match('/theme-([a-zA-Z_]+)/', $file, $matches);
             if ($matches) {
                 $styles[] = $matches[1];
             }
         }
     }
     return $styles;
 }
 public function build_hooks()
 {
     $ci = \CI::$APP;
     $ci->load->library('lib_xml');
     $xml = '<?xml version="1.0" encoding="UTF-8"?><hooks>';
     // Get all installed modules
     $ci->db->select('name');
     $modules = $ci->db->get('components');
     if ($modules) {
         $modules = $modules->result_array();
     } else {
         show_error($ci->db->_error_message());
     }
     $modules[]['name'] = 'core';
     // Search for hooks.xml in all installed modules
     foreach ($modules as $m) {
         $xml_file = getModulePath($m['name']) . '/hooks.xml';
         if (file_exists($xml_file)) {
             $xml .= file_get_contents($xml_file);
         }
     }
     $xml .= "\n</hooks>";
     $parser = xml_parser_create();
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
     xml_parse_into_struct($parser, $xml, $vals);
     xml_parser_free($parser);
     $tmp = array();
     foreach ($vals as $k => $v) {
         if (isset($v['type']) && isset($v['value']) && isset($v['attributes'])) {
             $hookId = trim($v['attributes']['id']);
             if (empty($tmp[$hookId])) {
                 $tmp[$hookId] = '';
             }
             $hookValue = trim($v['value']);
             if ($v['type'] === 'complete' && !empty($hookValue) && !empty($hookId)) {
                 $tmp[$hookId] .= $hookValue;
             }
         }
     }
     $this->create_hooks_file($tmp);
 }
 function get_module_info($mod_name)
 {
     $info_file = getModulePath($mod_name) . 'module_info.php';
     $lang = new MY_Lang();
     $lang->load($mod_name);
     if (file_exists($info_file)) {
         include $info_file;
         return $com_info;
     } else {
         return FALSE;
     }
 }
 /**
  * Prepare po-file url
  * @param string $name - module or template name
  * @param string$type - type of po-file(modules, templates, main)
  * @param string $lang - language locale
  * @return string
  */
 public function getPoFileUrl($name, $type, $lang)
 {
     switch ($type) {
         case 'modules':
             $url = getModulePath($name) . 'language/' . $lang . '/LC_MESSAGES/' . $name . '.po';
             break;
         case 'templates':
             $url = self::TEMPLATES_PATH . $name . '/language/' . $name . '/' . $lang . '/LC_MESSAGES/' . $name . '.po';
             break;
         case 'main':
             $url = self::MAIN_PATH . $lang . '/LC_MESSAGES/' . $type . '.po';
             break;
         default:
             $url = '';
     }
     if (self::$SAAS_URL) {
         $url = str_replace('./', self::$SAAS_URL . '/', $url);
     }
     //        var_dumps($url);
     return $url;
 }
 public function edit_field($name = '')
 {
     $name = urldecode($name);
     $this->db->limit(1);
     $field = $this->db->get_where('content_fields', array('field_name' => (string) $name));
     if ($field->num_rows() == 1) {
         $field = $field->row();
         $field_data = unserialize($field->data);
         $form = $this->load->module('cfcm/cfcm_forms')->edit_field($field->type);
         $form->title = lang("Field editing", 'cfcm') . ': ' . $field->label;
         $form->action = $this->get_url('edit_field/' . $name);
         $form->setAttributes($field_data);
         $form->validation->setInitial(str_replace('required|', '', $field_data['validation']));
         if ($_POST) {
             $data = $form->getData();
             $matches = array();
             if (isset($data['required'])) {
                 $data['validation'] = 'required|' . $data['validation'];
             }
             unset($data['validation_required']);
             $this->db->where('field_name', $field->field_name);
             $this->db->update('content_fields', array('data' => serialize($data), 'type' => $data['type'], 'label' => $data['label']));
             $groups = $data['groups'];
             $data['field_name'] = end($this->uri->segment_array());
             if (count($groups)) {
                 foreach ($groups as $group) {
                     $toInsert[] = array('field_name' => $data['field_name'], 'group_id' => $group);
                 }
                 if (count($toInsert)) {
                     $this->db->delete('content_fields_groups_relations', array('field_name' => $data['field_name']));
                 }
                 $this->db->insert_batch('content_fields_groups_relations', $toInsert);
             }
             $this->lib_admin->log(lang("Field has been updated", "cfcm") . ' - ' . $name);
             showMessage(lang("Field has been updated", 'cfcm'));
             if ($this->input->post('action') == 'close') {
                 pjax('/admin/components/cp/cfcm/index#additional_fields');
             }
         } else {
             $modulePath = getModulePath('cfcm');
             $this->template->registerJsFile($modulePath . 'templates/scripts/admin.js', 'after');
             $this->template->add_array(array('form' => $form));
             $this->render('_form');
         }
     } else {
         echo lang("Field has not been found", 'cfcm');
     }
 }
 /**
  * Run module
  *
  * @access private
  * @return bool
  */
 private function is_module($n)
 {
     $segment = $this->uri->segment($n);
     $found = FALSE;
     ($hook = get_hook('core_is_seg_module')) ? eval($hook) : NULL;
     foreach ($this->modules as $k) {
         if ($k['identif'] === $segment and $k['enabled'] == 1) {
             $found = TRUE;
             $mod_name = $k['identif'];
         }
     }
     if ($found == TRUE) {
         //$mod_name = $this->modules[$this->uri->segment($n)];
         $mod_function = $this->uri->segment($n + 1);
         if ($mod_function == FALSE) {
             $mod_function = 'index';
         }
         $file = getModulePath($mod_name) . $mod_function . EXT;
         $this->core_data['module'] = $mod_name;
         if (file_exists($file)) {
             ($hook = get_hook('core_run_module_by_seg')) ? eval($hook) : NULL;
             // Run module
             $func = $this->uri->segment($n + 2);
             if ($func == FALSE) {
                 $func = 'index';
             }
             $args = $this->grab_variables($n + 3);
             $this->load->module($mod_name . '/' . $mod_function);
             if (method_exists($mod_function, $func)) {
                 echo modules::run($mod_name . '/' . $mod_function . '/' . $func, $args);
             } else {
                 $this->error_404();
             }
         } else {
             $args = $this->grab_variables($n + 2);
             $this->load->module($mod_name);
             if (method_exists($mod_name, $mod_function)) {
                 echo modules::run($mod_name . '/' . $mod_name . '/' . $mod_function, $args);
             } else {
                 // If method not found display 404 error.
                 $this->error_404();
             }
         }
         return TRUE;
     }
     return FALSE;
 }
 /**
  * Get widget info title/description/method
  */
 private function parse_widget_xml($xml_folder)
 {
     $modulePath = getModulePath($xml_folder);
     if ($this->lib_xml->load($modulePath . 'widgets')) {
         $widgets_array = $this->lib_xml->parse();
         $info = $widgets_array['widgets'][0]['widget'];
         $return = array();
         $locale = MY_Controller::defaultLocale();
         foreach ($info as $k => $v) {
             if ($v['i18n_' . $locale]) {
                 $temp = array('title' => $v['i18n_' . $locale][0]['title'][0], 'description' => $v['i18n_' . $locale][0]['description'][0], 'method' => $v['method'][0]);
                 array_push($return, $temp);
             }
         }
         if (count($return) > 0) {
             return $return;
         }
     }
     return FALSE;
 }
 /**
  * Return formated path
  * @return string
  * @access private
  * @copyright ImageCMS (c) 2013, Kaero <*****@*****.**>
  */
 private function buildTemplatePath($tpl)
 {
     if (!$this->template) {
         $this->template = \CI_Controller::get_instance()->config->item('template');
     }
     if ($path = file_exists('templates/' . $this->template . '/' . $this->getTrace() . '/' . $tpl . '.tpl')) {
         return sprintf('templates/%s/%s/%s', $this->template, $this->getTrace(), $tpl);
     } else {
         $modulePath = getModulePath($this->getTrace());
         return sprintf($modulePath . 'assets/%s', $tpl);
     }
 }
 function create_user()
 {
     if ($_POST) {
         $this->load->model('dx_auth/users', 'user2');
         $val = $this->form_validation;
         $val->set_rules('username', lang('Login', 'user_manager'), 'trim|required|xss_clean');
         $val->set_rules('password', lang('Password', 'user_manager'), 'trim|min_length[' . $this->config->item('DX_login_min_length') . ']|max_length[' . $this->config->item('DX_login_max_length') . ']|required|xss_clean');
         $val->set_rules('password_conf', lang('Confirm the password', 'user_manager'), 'matches[password]|required');
         $val->set_rules('email', lang('E-Mail', 'user_manager'), 'trim|required|xss_clean|valid_email');
         $val->set_rules('phone', lang('Phone', 'user_manager'), 'trim');
         ($hook = get_hook('users_create_set_val_rules')) ? eval($hook) : NULL;
         $user = $this->input->post('username');
         $email = $this->input->post('email');
         $role = $this->input->post('role');
         // check user mail
         if ($this->user2->check_email($email)->num_rows() > 0) {
             showMessage(lang('User with the same e-mail has been registered', 'user_manager'), '', 'r');
             exit;
         }
         if (!check_perm('user_create') and !check_perm('user_create_all_roles')) {
             //cp_check_perm('user_create');
         }
         //            if (!check_perm('user_create_all_roles')) {
         //                $role = $this->dx_auth->get_role_id();
         //            }
         $this->load->helper('string');
         if ($val->run() and $user_info = $this->dx_auth->register($val->set_value('username'), $val->set_value('password'), $val->set_value('email'), '', random_string('alnum', 5), $this->input->post('phone'), false)) {
             //set user role
             $user_info = $this->user2->get_user_by_email($user_info['email'])->row_array();
             $this->user2->set_role($user_info['id'], $role);
             $this->lib_admin->log(lang('Create a user or the username has been created', 'user_manager') . ' <a href="' . site_url('/admin/components/cp/user_manager/edit_user/' . $user_info['id']) . '">' . $val->set_value('username') . '</a>');
             showMessage(lang('Username has been created or user has been created', 'user_manager'));
             $action = $_POST['action'];
             if ($action == 'close') {
                 pjax('/admin/components/cp/user_manager/edit_user/' . $user_info['id']);
             } else {
                 pjax('/admin/components/init_window/user_manager');
             }
         } else {
             $fields = array('username', 'password', 'password_conf', 'email', 'phone');
             $script = "<script type=\"text/javascript\">";
             foreach ($fields as $field) {
                 $error = $val->error($field);
                 if (!empty($error)) {
                     $script .= "showError('{$field}','{$error}'); ";
                 }
             }
             $script .= "</script>";
             echo $script;
         }
     }
     $this->set_tpl_roles();
     if (!$this->ajaxRequest) {
         $this->template->registerJsFile('templates/administrator/js/jquery.maskedinput-1.3.min.js', 'after');
         $this->template->registerJsFile(getModulePath('user_manager') . 'templates/js/create.js', 'after');
         $this->display_tpl('create_user');
     }
 }
 public function get_license()
 {
     if (false === ($shopPath = getModulePath('shop'))) {
         echo 0;
         return;
     }
     $licenseFile = $shopPath . 'license.key';
     if (!file_exists($licenseFile)) {
         echo 0;
         return;
     }
     echo file_get_contents($licenseFile);
 }
 private static function fetchApiTpl()
 {
     $CI =& get_instance();
     $obj = $this ? $this : $CI;
     if (!$obj->input->is_ajax_request() || $obj->input->get('_pjax')) {
         $translator = $obj->db->where('name', 'translator')->get('components');
         if ($translator) {
             $translator = $translator->row_array();
             if ($translator['settings']) {
                 $translatorSettings = unserialize($translator['settings']);
                 if (isset($translatorSettings['showApiForm']) && $obj->dx_auth->is_admin()) {
                     if (!defined('ENABLE_TRANSLATION_API')) {
                         define('ENABLE_TRANSLATION_API', TRUE);
                     }
                     $lang = new MY_Lang();
                     $lang->load('translator');
                     $obj->template->registerJsFile('/templates/administrator/js/jquery-ui-1.8.23.custom.min.js');
                     if (MAINSITE) {
                         $obj->template->registerJsFile(MAINSITE . getModulePath('translator') . '/assets/js/translateSingleLang.js');
                         $obj->template->display('file:' . getModulePath('translator') . '/assets/translationApiForm');
                     } else {
                         $obj->template->registerJsFile(getModulePath('translator') . '/assets/js/translateSingleLang.js');
                         $obj->template->display('file:' . getModulePath('translator') . '/assets/translationApiForm');
                     }
                 }
             }
         }
     }
 }
 public function done()
 {
     chmod(getModulePath('install') . '/install.php', 0777);
     rename(getModulePath('install') . '/install.php', getModulePath('install') . '/_install.php');
     chmod(getModulePath('install') . '/install.php', 0755);
     $this->_display($this->load->view('done', '', TRUE));
 }
 private function bootstrapInitShop()
 {
     if (FALSE == $this->CI->config->item('is_installed') || FALSE === ($shopPath = getModulePath('shop'))) {
         return;
     }
     define('SHOP_DIR', $shopPath);
     ClassLoader::getInstance()->registerNamespacedPath(SHOP_DIR . 'models2/generated-classes')->registerClassesPath(SHOP_DIR . 'models2/generated-classes')->registerClassesPath(SHOP_DIR . 'classes')->registerNamespacedPath(SHOP_DIR . 'classes');
     ShopCore::init();
     // Diable CSRF library form web money service
     $this->CI =& get_instance();
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['result'] == 'true' && $_GET['pm'] > 0) {
         define('ICMS_DISBALE_CSRF', true);
     }
     // Support for robokassa
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['getResult'] == 'true') {
         define('ICMS_DISBALE_CSRF', true);
     }
     // Support for privat
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'order' && $this->CI->uri->segment(3) == 'view' && $_POST) {
         define('ICMS_DISBALE_CSRF', true);
     }
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['succes'] == 'true') {
         define('ICMS_DISBALE_CSRF', true);
     }
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['fail'] == 'true') {
         define('ICMS_DISBALE_CSRF', true);
     }
     if (isset($_SERVER['HTTP_REFERER']) and strpos($_SERVER['HTTP_REFERER'] . "", 'facebook.com')) {
         define('ICMS_DISBALE_CSRF', true);
     }
     // Support for privat
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'order' && $this->CI->uri->segment(3) == 'view') {
         define('ICMS_DISBALE_CSRF', true);
     }
     //new payment system
     if (preg_match("/payment_method_/i", $this->CI->uri->segment(1)) || preg_match("/payment_method_/i", $this->CI->uri->segment(2))) {
         define('ICMS_DISBALE_CSRF', true);
     }
 }
 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.
     $modulePath = getModulePath('core');
     $list = $this->ftp->list_files($modulePath);
     $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'));
         }
     }
 }