Example #1
0
 /**
  * @brief Display license messages
  */
 function dispInstallIntroduce()
 {
     $install_config_file = FileHandler::getRealPath('./config/install.config.php');
     if (file_exists($install_config_file)) {
         include $install_config_file;
         if (is_array($install_config)) {
             foreach ($install_config as $k => $v) {
                 $v = $k == 'db_table_prefix' ? $v . '_' : $v;
                 Context::set($k, $v, true);
             }
             unset($GLOBALS['__DB__']);
             Context::set('install_config', true, true);
             $oInstallController = getController('install');
             $output = $oInstallController->procInstall();
             if (!$output->toBool()) {
                 return $output;
             }
             header("location: ./");
             Context::close();
             exit;
         }
     }
     Context::set('l', Context::getLangType());
     $this->setTemplateFile('introduce');
 }
 function dispNcenterliteAdminConfig()
 {
     $oModuleModel = getModel('module');
     $oNcenterliteModel = getModel('ncenterlite');
     $oLayoutModel = getModel('layout');
     $config = $oNcenterliteModel->getConfig();
     Context::set('config', $config);
     $layout_list = $oLayoutModel->getLayoutList();
     Context::set('layout_list', $layout_list);
     $mobile_layout_list = $oLayoutModel->getLayoutList(0, 'M');
     Context::set('mlayout_list', $mobile_layout_list);
     $skin_list = $oModuleModel->getSkins($this->module_path);
     Context::set('skin_list', $skin_list);
     $mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
     Context::set('mskin_list', $mskin_list);
     if (!$skin_list[$config->skin]) {
         $config->skin = 'default';
     }
     Context::set('colorset_list', $skin_list[$config->skin]->colorset);
     if (!$mskin_list[$config->mskin]) {
         $config->mskin = 'default';
     }
     Context::set('mcolorset_list', $mskin_list[$config->mskin]->colorset);
     $security = new Security();
     $security->encodeHTML('config..');
     $security->encodeHTML('skin_list..title');
     $security->encodeHTML('colorset_list..name', 'colorset_list..title');
     $mid_list = $oModuleModel->getMidList(null, array('module_srl', 'mid', 'browser_title', 'module'));
     Context::set('mid_list', $mid_list);
     // 사용환경정보 전송 확인
     $ncenterlite_module_info = $oModuleModel->getModuleInfoXml('ncenterlite');
     $agreement_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/ncenterlite/ncenterlite-', $ncenterlite_module_info->version));
     $agreement_ver_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/ncenterlite/ncenterlite_ver-', $ncenterlite_module_info->version));
     if (file_exists($agreement_file)) {
         $agreement = FileHandler::readFile($agreement_file);
         Context::set('_ncenterlite_env_agreement', $agreement);
         $agreement_ver = FileHandler::readFile($agreement_ver_file);
         if ($agreement == 'Y') {
             $_ncenterlite_iframe_url = 'http://sosifam.com/index.php?mid=ncenterlite_iframe';
             if (!$agreement_ver) {
                 $_host_info = urlencode($_SERVER['HTTP_HOST']) . '-NC' . $ncenterlite_module_info->version . '-PHP' . phpversion() . '-XE' . __XE_VERSION__;
             }
             Context::set('_ncenterlite_iframe_url', $_ncenterlite_iframe_url . '&_host=' . $_host_info);
             Context::set('ncenterlite_module_info', $ncenterlite_module_info);
         }
         FileHandler::writeFile($agreement_ver_file, 'Y');
     } else {
         Context::set('_ncenterlite_env_agreement', 'NULL');
     }
 }
 /**
  * Check whether the passing filename exists or not. Detect the file type, too.
  * @return void
  */
 function procImporterAdminCheckXmlFile()
 {
     global $lang;
     $filename = Context::get('filename');
     $isExists = 'false';
     if (strncasecmp('http://', $filename, 7) === 0) {
         if (ini_get('allow_url_fopen')) {
             $fp = @fopen($filename, "r");
             if ($fp) {
                 $str = fgets($fp, 100);
                 if (strlen($str) > 0) {
                     $isExists = 'true';
                     $type = 'XML';
                     if (stristr($str, 'tattertools')) {
                         $type = 'TTXML';
                     }
                     $this->add('type', $type);
                 }
                 fclose($fp);
                 $resultMessage = $lang->found_xml_file;
             } else {
                 $resultMessage = $lang->cannot_url_file;
             }
         } else {
             $resultMessage = $lang->cannot_allow_fopen_in_phpini;
         }
         $this->add('exists', $isExists);
     } else {
         $realPath = FileHandler::getRealPath($filename);
         if (file_exists($realPath) && is_file($realPath)) {
             $isExists = 'true';
         }
         $this->add('exists', $isExists);
         if ($isExists == 'true') {
             $type = 'XML';
             $fp = fopen($realPath, "r");
             $str = fgets($fp, 100);
             if (stristr($str, 'tattertools')) {
                 $type = 'TTXML';
             }
             fclose($fp);
             $this->add('type', $type);
             $resultMessage = $lang->found_xml_file;
         } else {
             $resultMessage = $lang->not_found_xml_file;
         }
     }
     $this->add('result_message', $resultMessage);
 }
Example #4
0
 /**
  * @brief Display license messages
  */
 function dispInstallIntroduce()
 {
     $install_config_file = FileHandler::getRealPath('./config/install.config.php');
     if (file_exists($install_config_file)) {
         /**
         * If './config/install.config.php' file created  and write array shown in the example below, XE installed using config file.
         * ex )
          $install_config = array(
          'db_type' =>'mysqli_innodb',
          'db_port' =>'3306',
          'db_hostname' =>'localhost',
          'db_userid' =>'root',
          'db_password' =>'root',
          'db_database' =>'rx_database',
          'db_table_prefix' =>'rx',
          'user_rewrite' =>'N',
          'time_zone' =>'0000',
          'email_address' =>'*****@*****.**',
          'password' =>'pass',
          'password2' =>'pass',
          'nick_name' =>'admin',
          'user_id' =>'admin',
          'lang_type' =>'ko',	// en, jp, ...
          );
         */
         include $install_config_file;
         if (is_array($install_config)) {
             foreach ($install_config as $k => $v) {
                 $v = $k == 'db_table_prefix' ? $v . '_' : $v;
                 Context::set($k, $v, true);
             }
             unset($GLOBALS['__DB__']);
             Context::set('install_config', true, true);
             $oInstallController = getController('install');
             $output = $oInstallController->procInstall();
             if (!$output->toBool()) {
                 return $output;
             }
             header("location: ./");
             Context::close();
             exit;
         }
     }
     Context::set('l', Context::getLangType());
     return $this->dispInstallLicenseAgreement();
     //$this->setTemplateFile('introduce');
 }
Example #5
0
 public function checkAdminMenu()
 {
     // for admin menu
     if (Context::isInstalled()) {
         $oMenuAdminModel = getAdminModel('menu');
         $output = $oMenuAdminModel->getMenuByTitle($this->adminMenuName);
         if (!$output->menu_srl) {
             $this->createXeAdminMenu();
             $output = $oMenuAdminModel->getMenuByTitle($this->adminMenuName);
         } else {
             if (!is_readable(FileHandler::getRealPath($output->php_file))) {
                 $oMenuAdminController = getAdminController('menu');
                 $oMenuAdminController->makeXmlFile($output->menu_srl);
             }
             Context::set('admin_menu_srl', $output->menu_srl);
         }
         $this->_oldAdminmenuDelete();
         $returnObj = new stdClass();
         $returnObj->menu_srl = $output->menu_srl;
         $returnObj->php_file = FileHandler::getRealPath($output->php_file);
         return $returnObj;
     }
 }
Example #6
0
 /**
  * Find XE installed path on ftp
  */
 function getAdminFTPPath()
 {
     Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang');
     @set_time_limit(5);
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(1, 'msg_ftp_invalid_auth_info');
     }
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = '127.0.0.1';
     }
     if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) {
         $ftp_info->ftp_port = '21';
     }
     if ($ftp_info->sftp == 'Y') {
         if (!function_exists('ssh2_sftp')) {
             return new Object(-1, 'disable_sftp_support');
         }
         return $this->getSFTPPath();
     }
     if ($ftp_info->ftp_pasv == 'N') {
         if (function_exists('ftp_connect')) {
             return $this->getFTPPath();
         }
         $ftp_info->ftp_pasv = "Y";
     }
     $oFTP = new ftp();
     if (!$oFTP->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
         return new Object(1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host));
     }
     if (!$oFTP->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
         return new Object(1, 'msg_ftp_invalid_auth_info');
     }
     // create temp file
     $pin = $_SERVER['REQUEST_TIME'];
     FileHandler::writeFile('./files/cache/ftp_check', $pin);
     // create path candidate
     $xe_path = _XE_PATH_;
     $path_info = array_reverse(explode('/', _XE_PATH_));
     array_pop($path_info);
     // remove last '/'
     $path_candidate = array();
     $temp = '';
     foreach ($path_info as $path) {
         $temp = '/' . $path . $temp;
         $path_candidate[] = $temp;
     }
     // try
     foreach ($path_candidate as $path) {
         // upload check file
         if (!$oFTP->ftp_put($path . 'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check'))) {
             continue;
         }
         // get check file
         $result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
         // delete temp check file
         $oFTP->ftp_delete($path . 'ftp_check.html');
         // found
         if ($result == $pin) {
             $found_path = $path;
             break;
         }
     }
     FileHandler::removeFile('./files/cache/ftp_check', $pin);
     if ($found_path) {
         $this->add('found_path', $found_path);
     }
 }
 function dispAttendanceAdminList()
 {
     /*attendance model 객체 생성*/
     $oAttendanceModel = getModel('attendance');
     Context::set('Model', $oAttendanceModel);
     $selected_date = Context::get('selected_date');
     //선택한 날짜 받아오기
     $type = Context::get('type');
     /*attendance admin model 객체 생성*/
     $oAttendanceAdminModel = getAdminModel('attendance');
     Context::set('oAttendanceAdminModel', $oAttendanceAdminModel);
     if ($type != 'config' && $type != 'time') {
         $user_data = $oAttendanceAdminModel->getAttendanceMemberList(20, $type);
         Context::set('user_data', $user_data);
     }
     // 멤버모델 객체 생성
     $oMemberModel = getModel('member');
     $group_list = $oMemberModel->getGroups();
     Context::set('group_list', $group_list);
     /*날짜 관련*/
     if (!$selected_date) {
         $selected_date = zDate(date('YmdHis'), "Ymd");
     }
     $year = substr($selected_date, 0, 4);
     $month = substr($selected_date, 4, 2);
     $day = substr($selected_date, 6, 2);
     $end_day = date('t', mktime(0, 0, 0, $month, 1, $year));
     $oMemberModel = getModel('member');
     Context::set('end_day', $end_day);
     Context::set('year', $year);
     Context::set('selected', $selected_date);
     Context::set('month', $month);
     Context::set('day', $day);
     Context::set('ipaddress', $_SERVER['REMOTE_ADDR']);
     Context::set('oMemberModel', $oMemberModel);
     //module의 설정값 가져오기
     $oModuleModel = getModel('module');
     $config = $oModuleModel->getModuleConfig('attendance');
     $oModuleAdminModel = getAdminModel('module');
     Context::set('config', $config);
     $start_time = new stdClass();
     $start_time->hour = substr($config->start_time, 0, 2);
     $start_time->min = substr($config->start_time, 2, 2);
     $end_time = new stdClass();
     $end_time->hour = substr($config->end_time, 0, 2);
     $end_time->min = substr($config->end_time, 2, 2);
     Context::set('start_time', $start_time);
     Context::set('end_time', $end_time);
     // 스킨 목록을 구해옴
     $oModuleModel = getModel('module');
     $module_info = $oModuleModel->getModuleInfoByMid('attendance');
     $skin_list = $oModuleModel->getSkins($this->module_path);
     Context::set('skin_list', $skin_list);
     $mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
     Context::set('mskin_list', $mskin_list);
     // 레이아웃 목록을 구해옴
     $oLayoutModel = getModel('layout');
     $layout_list = $oLayoutModel->getLayoutList();
     Context::set('layout_list', $layout_list);
     $mobile_layout_list = $oLayoutModel->getLayoutList(0, "M");
     Context::set('mlayout_list', $mobile_layout_list);
     // 모듈 카테고리 목록을 구함
     $module_category = $oModuleModel->getModuleCategories();
     Context::set('module_category', $module_category);
     // 공통 모듈 권한 설정 페이지 호출
     $skin_content = $oModuleAdminModel->getModuleSkinHTML($module_info->module_srl);
     Context::set('skin_content', $skin_content);
     Context::set('module_info', $module_info);
     Context::set('module_srl', $module_info->module_srl);
     // 사용환경정보 전송 확인
     $attendance_module_info = $oModuleModel->getModuleInfoXml('attendance');
     $agreement_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/cache/attendance/attendance-', $attendance_module_info->version));
     if (file_exists($agreement_file)) {
         $agreement = FileHandler::readFile($agreement_file);
         Context::set('_attendance_env_agreement', $agreement);
         if ($agreement == 'Y') {
             $_attendance_iframe_url = 'http://sosifam.com/index.php?mid=attendance_iframe';
             $_host_info = urlencode($_SERVER['HTTP_HOST']) . '-NC' . $attendance_module_info->version . '-PHP' . phpversion() . '-XE' . __XE_VERSION__;
             Context::set('_attendance_iframe_url', $_attendance_iframe_url . '&_host=' . $_host_info);
             Context::set('attendance_module_info', $attendance_module_info);
         }
     } else {
         Context::set('_attendance_env_agreement', 'NULL');
     }
     /*템플릿 설정*/
     $this->setTemplatePath($this->module_path . 'tpl');
     $this->setTemplateFile('index');
 }
Example #8
0
 /**
  * @brief Create a cache file in order to include if it is an internal file
  */
 function executeFile($target_file, $caching_interval, $cache_file)
 {
     // Cancel if the file doesn't exist
     if (!file_exists(FileHandler::getRealPath($target_file))) {
         return;
     }
     // Get a path and filename
     $tmp_path = explode('/', $cache_file);
     $filename = $tmp_path[count($tmp_path) - 1];
     $filepath = preg_replace('/' . $filename . "\$/i", "", $cache_file);
     $cache_file = FileHandler::getRealPath($cache_file);
     // Verify cache
     if ($caching_interval < 1 || !file_exists($cache_file) || filemtime($cache_file) + $caching_interval * 60 <= $_SERVER['REQUEST_TIME'] || filemtime($cache_file) < filemtime($target_file)) {
         if (file_exists($cache_file)) {
             FileHandler::removeFile($cache_file);
         }
         // Read a target file and get content
         ob_start();
         include FileHandler::getRealPath($target_file);
         $content = ob_get_clean();
         // Replace relative path to the absolute path
         $this->path = str_replace('\\', '/', realpath(dirname($target_file))) . '/';
         $content = preg_replace_callback('/(target=|src=|href=|url\\()("|\')?([^"\'\\)]+)("|\'\\))?/is', array($this, '_replacePath'), $content);
         $content = preg_replace_callback('/(<!--%import\\()(\\")([^"]+)(\\")/is', array($this, '_replacePath'), $content);
         FileHandler::writeFile($cache_file, $content);
         // Include and then Return the result
         if (!file_exists($cache_file)) {
             return;
         }
         // Attempt to compile
         $oTemplate =& TemplateHandler::getInstance();
         $script = $oTemplate->compileDirect($filepath, $filename);
         FileHandler::writeFile($cache_file, $script);
     }
     $__Context =& $GLOBALS['__Context__'];
     $__Context->tpl_path = $filepath;
     ob_start();
     include $cache_file;
     $content = ob_get_clean();
     return $content;
 }
Example #9
0
 /**
  * It creates a module instance
  * @param string $module module name
  * @param string $type instance type, (e.g., view, controller, model)
  * @param string $kind admin or svc
  * @return ModuleObject module instance (if failed it returns null)
  * @remarks if there exists a module instance created before, returns it.
  **/
 function &getModuleInstance($module, $type = 'view', $kind = '')
 {
     if (__DEBUG__ == 3) {
         $start_time = getMicroTime();
     }
     $kind = strtolower($kind);
     $type = strtolower($type);
     $kinds = array('svc' => 1, 'admin' => 1);
     if (!isset($kinds[$kind])) {
         $kind = 'svc';
     }
     $key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
     if (is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__'])) {
         $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
     }
     // if there is no instance of the module in global variable, create a new one
     if (!isset($GLOBALS['_loaded_module'][$module][$type][$kind])) {
         $parent_module = $module;
         $class_path = ModuleHandler::getModulePath($module);
         if (!is_dir(FileHandler::getRealPath($class_path))) {
             return NULL;
         }
         // Get base class name and load the file contains it
         if (!class_exists($module)) {
             $high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
             if (!file_exists($high_class_file)) {
                 return NULL;
             }
             require_once $high_class_file;
         }
         // Get the object's name
         $types = explode(' ', 'view controller model api wap mobile class');
         if (!in_array($type, $types)) {
             $type = $types[0];
         }
         if ($type == 'class') {
             $instance_name = '%s';
             $class_file = '%s%s.%s.php';
         } elseif ($kind == 'admin' && array_search($type, $types) < 3) {
             $instance_name = '%sAdmin%s';
             $class_file = '%s%s.admin.%s.php';
         } else {
             $instance_name = '%s%s';
             $class_file = '%s%s.%s.php';
         }
         $instance_name = sprintf($instance_name, $module, ucfirst($type));
         $class_file = sprintf($class_file, $class_path, $module, $type);
         $class_file = FileHandler::getRealPath($class_file);
         // Get the name of the class file
         if (!is_readable($class_file)) {
             return NULL;
         }
         // Create an instance with eval function
         require_once $class_file;
         if (!class_exists($instance_name)) {
             return NULL;
         }
         $tmp_fn = create_function('', "return new {$instance_name}();");
         $oModule = $tmp_fn();
         if (!is_object($oModule)) {
             return NULL;
         }
         // Load language files for the class
         Context::loadLang($class_path . 'lang');
         if ($extend_module) {
             Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
         }
         // Set variables to the instance
         $oModule->setModule($module);
         $oModule->setModulePath($class_path);
         // If the module has a constructor, run it.
         if (!isset($GLOBALS['_called_constructor'][$instance_name])) {
             $GLOBALS['_called_constructor'][$instance_name] = true;
             if (@method_exists($oModule, $instance_name)) {
                 $oModule->{$instance_name}();
             }
         }
         // Store the created instance into GLOBALS variable
         $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
     }
     if (__DEBUG__ == 3) {
         $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
     }
     // return the instance
     return $GLOBALS['_loaded_module'][$module][$type][$kind];
 }
 function _getModuleFilePath($module, $type, $kind, &$classPath, &$highClassFile, &$classFile, &$instanceName)
 {
     $classPath = ModuleHandler::getModulePath($module);
     $highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_, $classPath, $module);
     $highClassFile = FileHandler::getRealPath($highClassFile);
     $types = array('view', 'controller', 'model', 'api', 'wap', 'mobile', 'class');
     if (!in_array($type, $types)) {
         $type = $types[0];
     }
     if ($type == 'class') {
         $instanceName = '%s';
         $classFile = '%s%s.%s.php';
     } elseif ($kind == 'admin' && array_search($type, $types) < 3) {
         $instanceName = '%sAdmin%s';
         $classFile = '%s%s.admin.%s.php';
     } else {
         $instanceName = '%s%s';
         $classFile = '%s%s.%s.php';
     }
     $instanceName = sprintf($instanceName, $module, ucfirst($type));
     $classFile = FileHandler::getRealPath(sprintf($classFile, $classPath, $module, $type));
 }
Example #11
0
 /**
  * Save the category in a cache file
  * @param int $module_srl
  * @return string
  */
 function makeCategoryFile($module_srl)
 {
     // Return if there is no information you need for creating a cache file
     if (!$module_srl) {
         return false;
     }
     // Get module information (to obtain mid)
     $oModuleModel = getModel('module');
     $columnList = array('module_srl', 'mid', 'site_srl');
     $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
     $mid = $module_info->mid;
     if (!is_dir('./files/cache/document_category')) {
         FileHandler::makeDir('./files/cache/document_category');
     }
     // Cache file's name
     $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
     $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
     // Get a category list
     $args = new stdClass();
     $args->module_srl = $module_srl;
     $args->sort_index = 'list_order';
     $output = executeQueryArray('document.getCategoryList', $args);
     $category_list = $output->data;
     if (!is_array($category_list)) {
         $category_list = array($category_list);
     }
     $category_count = count($category_list);
     for ($i = 0; $i < $category_count; $i++) {
         $category_srl = $category_list[$i]->category_srl;
         if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) {
             $category_list[$i]->group_srls = '';
         }
         $list[$category_srl] = $category_list[$i];
     }
     // Create the xml file without node data if no data is obtained
     if (!$list) {
         $xml_buff = "<root />";
         FileHandler::writeFile($xml_file, $xml_buff);
         FileHandler::writeFile($php_file, '<?php if(!defined("__XE__")) exit(); ?>');
         return $xml_file;
     }
     // Change to an array if only a single data is obtained
     if (!is_array($list)) {
         $list = array($list);
     }
     // Create a tree for loop
     foreach ($list as $category_srl => $node) {
         $node->mid = $mid;
         $parent_srl = (int) $node->parent_srl;
         $tree[$parent_srl][$category_srl] = $node;
     }
     // A common header to set permissions and groups of the cache file
     $header_script = '$lang_type = Context::getLangType(); ' . '$is_logged = Context::get(\'is_logged\'); ' . '$logged_info = Context::get(\'logged_info\'); ' . 'if($is_logged) {' . 'if($logged_info->is_admin=="Y") $is_admin = true; ' . 'else $is_admin = false; ' . '$group_srls = array_keys($logged_info->group_list); ' . '} else { ' . '$is_admin = false; ' . '$group_srsl = array(); ' . '} ' . "\n";
     // Create the xml cache file (a separate session is needed for xml cache)
     $xml_header_buff = '';
     $xml_body_buff = $this->getXmlTree($tree[0], $tree, $module_info->site_srl, $xml_header_buff);
     $xml_buff = sprintf('<?php ' . 'define(\'__XE__\', true); ' . 'require_once(\'' . FileHandler::getRealPath('./config/config.inc.php') . '\'); ' . '$oContext = &Context::getInstance(); ' . '$oContext->init(); ' . 'header("Content-Type: text/xml; charset=UTF-8"); ' . 'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); ' . 'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); ' . 'header("Cache-Control: no-store, no-cache, must-revalidate"); ' . 'header("Cache-Control: post-check=0, pre-check=0", false); ' . 'header("Pragma: no-cache"); ' . '%s' . '%s ' . '$oContext->close();' . '?>' . '<root>%s</root>', $header_script, $xml_header_buff, $xml_body_buff);
     // Create php cache file
     $php_header_buff = '$_titles = array();';
     $php_header_buff .= '$_descriptions = array();';
     $php_output = $this->getPhpCacheCode($tree[0], $tree, $module_info->site_srl, $php_header_buff);
     $php_buff = sprintf('<?php ' . 'if(!defined("__XE__")) exit(); ' . '%s' . '%s' . '$menu = new stdClass;' . '$menu->list = array(%s); ', $header_script, $php_header_buff, $php_output['buff']);
     // Save File
     FileHandler::writeFile($xml_file, $xml_buff);
     FileHandler::writeFile($php_file, $php_buff);
     return $xml_file;
 }
 /**
  * Get file information
  *
  * @param string $fileName The file name
  * @param string $targetIe Target IE of file
  * @param string $media Media of file
  * @param bool $forceMinify Whether this file should be minified
  * @return stdClass The file information
  */
 private function getFileInfo($fileName, $targetIe = '', $media = 'all', $forceMinify = false)
 {
     static $existsInfo = array();
     if (self::$minify === null) {
         self::$minify = Context::getDBInfo()->minify_scripts ?: 'common';
     }
     if (isset($existsInfo[$existsKey])) {
         return $existsInfo[$existsKey];
     }
     $pathInfo = pathinfo($fileName);
     $file = new stdClass();
     $file->fileName = $pathInfo['basename'];
     $file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
     $file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']);
     $file->fileExtension = strtolower($pathInfo['extension']);
     if (preg_match('/^(.+)\\.min$/', $pathInfo['filename'], $matches)) {
         $file->fileNameNoExt = $matches[1];
         $file->isMinified = true;
     } else {
         $file->fileNameNoExt = $pathInfo['filename'];
         $file->isMinified = false;
     }
     $file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false;
     $file->isCachedScript = !$file->isExternalURL && strpos($file->filePath, 'files/cache/') !== false;
     $file->keyName = $file->fileNameNoExt . '.' . $file->fileExtension;
     $file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']);
     $originalFilePath = $file->fileRealPath . '/' . $pathInfo['basename'];
     // Fix incorrectly minified URL
     if ($file->isMinified && !$file->isExternalURL && (!file_exists($originalFilePath) || is_link($originalFilePath) || filesize($originalFilePath) < 32 && trim(file_get_contents($originalFilePath)) === $file->keyName)) {
         if (file_exists($file->fileRealPath . '/' . $file->fileNameNoExt . '.' . $file->fileExtension)) {
             $file->fileName = $file->fileNameNoExt . '.' . $file->fileExtension;
             $file->isMinified = false;
             $originalFilePath = $file->fileRealPath . '/' . $file->fileNameNoExt . '.' . $file->fileExtension;
         }
     }
     // Decide whether to minify this file
     if (self::$minify === 'all') {
         $minify_enabled = true;
     } elseif (self::$minify === 'none') {
         $minify_enabled = false;
     } else {
         $minify_enabled = $forceMinify;
     }
     // Minify file
     if ($minify_enabled && !$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && strpos($file->filePath, 'common/js/plugins') === false) {
         if (($file->fileExtension === 'css' || $file->fileExtension === 'js') && file_exists($originalFilePath)) {
             $minifiedFileName = $file->fileNameNoExt . '.min.' . $file->fileExtension;
             $minifiedFileHash = ltrim(str_replace(array('/', '\\'), '.', $pathInfo['dirname']), '.');
             $minifiedFilePath = _XE_PATH_ . 'files/cache/minify/' . $minifiedFileHash . '.' . $minifiedFileName;
             if (!file_exists($minifiedFilePath) || filemtime($minifiedFilePath) < filemtime($originalFilePath)) {
                 if ($file->fileExtension === 'css') {
                     $minifier = new MatthiasMullie\Minify\CSS($originalFilePath);
                     $content = $minifier->execute($minifiedFilePath);
                 } else {
                     $minifier = new MatthiasMullie\Minify\JS($originalFilePath);
                     $content = $minifier->execute($minifiedFilePath);
                 }
                 FileHandler::writeFile($minifiedFilePath, $content);
             }
             $file->fileName = $minifiedFileHash . '.' . $minifiedFileName;
             $file->filePath = $this->_getAbsFileUrl('./files/cache/minify');
             $file->fileRealPath = _XE_PATH_ . 'files/cache/minify';
             $file->keyName = $minifiedFileHash . '.' . $file->fileNameNoExt . '.' . $file->fileExtension;
             $file->cdnPath = $this->_normalizeFilePath('./files/cache/minify');
             $file->isMinified = true;
         }
     }
     // Process targetIe and media attributes
     $file->targetIe = $targetIe;
     if ($file->fileExtension == 'css') {
         $file->media = $media;
         if (!$file->media) {
             $file->media = 'all';
         }
         $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media;
     } else {
         if ($file->fileExtension == 'js') {
             $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe;
         }
     }
     return $file;
 }
 /**
  * @brief Install with received information
  */
 function procInstall()
 {
     // Check if it is already installed
     if (Context::isInstalled()) {
         return new Object(-1, 'msg_already_installed');
     }
     // Assign a temporary administrator when installing
     $logged_info = new stdClass();
     $logged_info->is_admin = 'Y';
     Context::set('logged_info', $logged_info);
     // check install config
     if (Context::get('install_config')) {
         $db_info = $this->_makeDbInfoByInstallConfig();
     } else {
         if (FileHandler::exists($this->db_tmp_config_file)) {
             include $this->db_tmp_config_file;
         }
         if (FileHandler::exists($this->etc_tmp_config_file)) {
             include $this->etc_tmp_config_file;
         }
     }
     // Set DB type and information
     Context::setDBInfo($db_info);
     // Create DB Instance
     $oDB =& DB::getInstance();
     // Check if available to connect to the DB
     if (!$oDB->isConnected()) {
         return $oDB->getError();
     }
     // Install all the modules
     try {
         $oDB->begin();
         $this->installDownloadedModule();
         $oDB->commit();
     } catch (Exception $e) {
         $oDB->rollback();
         return new Object(-1, $e->getMessage());
     }
     // Create a config file
     if (!$this->makeConfigFile()) {
         return new Object(-1, 'msg_install_failed');
     }
     // load script
     $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\\.php)$/');
     if (count($scripts) > 0) {
         sort($scripts);
         foreach ($scripts as $script) {
             $script_path = FileHandler::getRealPath('./modules/install/script/');
             $output = (include $script_path . $script);
         }
     }
     // save selected lang info
     $oInstallAdminController = getAdminController('install');
     $oInstallAdminController->saveLangSelected(array(Context::getLangType()));
     // Display a message that installation is completed
     $this->setMessage('msg_install_completed');
     unset($_SESSION['use_rewrite']);
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('');
         header('location:' . $returnUrl);
         return new Object();
     }
 }
Example #14
0
 /**
  * Copy directory
  *
  * @param array $file_list File list to copy
  * @return Object
  */
 function _copyDir(&$file_list)
 {
     $output = $this->_connect();
     if (!$output->toBool()) {
         return $output;
     }
     $target_dir = $this->target_path;
     if (is_array($file_list)) {
         foreach ($file_list as $k => $file) {
             $org_file = $file;
             if ($this->package->path == ".") {
                 $file = substr($file, 3);
             }
             $path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
             $path_list = explode('/', dirname($this->target_path . "/" . $file));
             $real_path = "./";
             for ($i = 0; $i < count($path_list); $i++) {
                 if ($path_list == "") {
                     continue;
                 }
                 $real_path .= $path_list[$i] . "/";
                 if (!file_exists(FileHandler::getRealPath($real_path))) {
                     FileHandler::makeDir($real_path);
                 }
             }
             FileHandler::copyFile(FileHandler::getRealPath($this->download_path . "/" . $org_file), FileHandler::getRealPath("./" . $target_dir . '/' . $file));
         }
     }
     $this->_close();
     return new Object();
 }
Example #15
0
 /**
  * Preview a layout
  * @return void|Object (void : success, Object : fail)
  */
 function dispLayoutPreview()
 {
     // admin check
     // this act is admin view but in normal view because do not load admin css/js files
     $logged_info = Context::get('logged_info');
     if ($logged_info->is_admin != 'Y') {
         return $this->stop('msg_invalid_request');
     }
     $layout_srl = Context::get('layout_srl');
     $code = Context::get('code');
     $code_css = Context::get('code_css');
     if (!$layout_srl || !$code) {
         return new Object(-1, 'msg_invalid_request');
     }
     // Get the layout information
     $oLayoutModel = getModel('layout');
     $layout_info = $oLayoutModel->getLayout($layout_srl);
     if (!$layout_info) {
         return new Object(-1, 'msg_invalid_request');
     }
     // Separately handle the layout if its type is faceoff
     if ($layout_info && $layout_info->type == 'faceoff') {
         $oLayoutModel->doActivateFaceOff($layout_info);
     }
     // Apply CSS directly
     Context::addHtmlHeader("<style type=\"text/css\" charset=\"UTF-8\">" . $code_css . "</style>");
     // Set names and values of extra_vars to $layout_info
     if ($layout_info->extra_var_count) {
         foreach ($layout_info->extra_var as $var_id => $val) {
             $layout_info->{$var_id} = $val->value;
         }
     }
     // menu in layout information becomes an argument for Context:: set
     if ($layout_info->menu_count) {
         foreach ($layout_info->menu as $menu_id => $menu) {
             $menu->php_file = FileHandler::getRealPath($menu->php_file);
             if (FileHandler::exists($menu->php_file)) {
                 include $menu->php_file;
             }
             Context::set($menu_id, $menu);
         }
     }
     Context::set('layout_info', $layout_info);
     Context::set('content', Context::getLang('layout_preview_content'));
     // Temporary save the codes
     $edited_layout_file = _XE_PATH_ . 'files/cache/layout/tmp.tpl';
     FileHandler::writeFile($edited_layout_file, $code);
     // Compile
     $oTemplate =& TemplateHandler::getInstance();
     $layout_path = $layout_info->path;
     $layout_file = 'layout';
     $layout_tpl = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
     Context::set('layout', 'none');
     // Convert widgets and others
     $oContext =& Context::getInstance();
     Context::set('layout_tpl', $layout_tpl);
     // Delete Temporary Files
     FileHandler::removeFile($edited_layout_file);
     $this->setTemplateFile('layout_preview');
 }
Example #16
0
 /**
  * @brief Return ruleset cache file path
  * @param module, act
  */
 function getValidatorFilePath($module, $ruleset, $mid = null)
 {
     // load dynamic ruleset xml file
     if (strpos($ruleset, '@') !== false) {
         $rulsetFile = str_replace('@', '', $ruleset);
         $xml_file = sprintf('./files/ruleset/%s.xml', $rulsetFile);
         return FileHandler::getRealPath($xml_file);
     } else {
         if (strpos($ruleset, '#') !== false) {
             $rulsetFile = str_replace('#', '', $ruleset) . '.' . $mid;
             $xml_file = sprintf('./files/ruleset/%s.xml', $rulsetFile);
             if (is_readable($xml_file)) {
                 return FileHandler::getRealPath($xml_file);
             } else {
                 $ruleset = str_replace('#', '', $ruleset);
             }
         }
     }
     // Get a path of the requested module. Return if not exists.
     $class_path = ModuleHandler::getModulePath($module);
     if (!$class_path) {
         return;
     }
     // Check if module.xml exists in the path. Return if not exist
     $xml_file = sprintf("%sruleset/%s.xml", $class_path, $ruleset);
     if (!file_exists($xml_file)) {
         return;
     }
     return $xml_file;
 }
Example #17
0
 /**
  * Rearrage all item
  *
  * <pre>
  * $items:
  * Array
  * (
  *	[0] => stdClass Object
  *		(
  *			[category_srl] => stdClass Object
  *				(
  *					[body] => xxx
  *				)
  *			[package_srl] => stdClass Object
  *				(
  *					[body] => xxx
  *				)
  *			...
  *			[depfrom] => stdClass Object
  *				(
  *					[body] => xxx
  *				)
  *		)
  *	[1] => stdClass Object
  *		(
  *			...
  *		)
  *	...
  * )
  *
  * $packages:
  * Array
  * (
  *	[<i>package_srl</i>] => stdClass Object
  *		(
  *			[current_version] => xxx
  *			[need_update] => xxx
  *			[path] => xxx
  *			...
  *		)
  *	...
  * )
  *
  * return:
  * Array
  * (
  *	[<i>package_srl</i>] => stdClass Object
  *		(
  *			[category_srl] => xxx
  *			[package_srl] => xxx
  *			...
  *			[category] => xxx
  *			[current_version] => xxx
  *			[type] => xxx
  *			[need_update] => xxx
  *			[avail_remove] => xxx
  *			[deps] => Array
  *				(
  *					[0] => xxx
  *					...
  *				)
  *		)
  *	...
  * )
  * </pre>
  *
  * @param object $items Recived data from server
  * @param object $packages Local data
  * @return object
  */
 function rearranges($items, $packages = null)
 {
     if (!is_array($items)) {
         $items = array($items);
     }
     $item_list = array();
     $targets = array('category_srl', 'package_srl', 'item_screenshot_url', 'package_voted', 'package_voter', 'package_description', 'package_downloaded', 'item_regdate', 'title', 'item_version', 'package_star', 'depfrom');
     $targetpackages = array();
     foreach ($items as $item) {
         $targetpackages[$item->package_srl->body] = 0;
     }
     $oModel =& getModel('autoinstall');
     if ($package == null) {
         $packages = $oModel->getInstalledPackages(array_keys($targetpackages));
     }
     $depto = array();
     foreach ($items as $item) {
         $v = $this->rearrange($item, $targets);
         $v->category = $this->categories[$v->category_srl]->title;
         if ($packages[$v->package_srl]) {
             $v->current_version = $packages[$v->package_srl]->current_version;
             $v->need_update = $packages[$v->package_srl]->need_update;
             $v->type = $oModel->getTypeFromPath($packages[$v->package_srl]->path);
             if ($this->ftp_set && $v->depfrom) {
                 $depfrom = explode(",", $v->depfrom);
                 foreach ($depfrom as $package_srl) {
                     $depto[$package_srl][] = $v->package_srl;
                 }
             }
             if ($v->type == "core") {
                 $v->avail_remove = false;
             } else {
                 if ($v->type == "module") {
                     $v->avail_remove = $oModel->checkRemovable($packages[$v->package_srl]->path);
                 } else {
                     $v->avail_remove = true;
                 }
             }
         }
         $item_list[$v->package_srl] = $v;
     }
     if (count($depto) > 0) {
         $installed = $oModel->getInstalledPackages(implode(",", array_keys($depto)));
         foreach ($installed as $key => $val) {
             $path = $val->path;
             $type = $oModel->getTypeFromPath($path);
             if (!$type || $type == "core") {
                 continue;
             }
             $config_file = $oModel->getConfigFilePath($type);
             if (!$config_file) {
                 continue;
             }
             $xml = new XmlParser();
             $xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($path) . $config_file);
             if (!$xmlDoc) {
                 continue;
             }
             if ($type == "drcomponent") {
                 $type = "component";
             }
             if ($type == "style" || $type == "m.skin") {
                 $type = "skin";
             }
             if ($type == "m.layout") {
                 $type = "layout";
             }
             $title = $xmlDoc->{$type}->title->body;
             $installed[$key]->title = $title;
         }
         Context::set('installed', $installed);
         foreach ($installed as $key => $val) {
             foreach ($depto[$key] as $package_srl) {
                 $item_list[$package_srl]->avail_remove = false;
                 $item_list[$package_srl]->deps[] = $key;
             }
         }
     }
     return $item_list;
 }
 /**
  * @brief tpl_file이 컴파일이 되어 있는 것이 있는지 체크
  **/
 function _compile($tpl_file, $compiled_tpl_file)
 {
     if (!file_exists($compiled_tpl_file)) {
         return $this->_compileTplFile($tpl_file, $compiled_tpl_file);
     }
     $source_ftime = filemtime(FileHandler::getRealPath($tpl_file));
     $target_ftime = filemtime($compiled_tpl_file);
     if ($source_ftime > $target_ftime || $target_ftime < filemtime(_XE_PATH_ . 'classes/template/TemplateHandler.class.php')) {
         return $this->_compileTplFile($tpl_file, $compiled_tpl_file);
     }
 }
 function _writeAttachment($file)
 {
     $content[] = '<attachment mime="%s" size="%s" width="%s" height="%s">';
     $content[] = '<name>%s</name>';
     $content[] = '<label>%s</label>';
     $content[] = '<enclosure>0</enclosure>';
     $content[] = '<attached>%s</attached>';
     $content[] = '<downloads>%s</downloads>';
     $content[] = '<content>';
     $content = join("\r\n", $content);
     $real_file = FileHandler::getRealPath($file->uploaded_filename);
     $fileext = strtolower(substr($file->uploaded_filename, strrpos($file->uploaded_filename, ".") + 1));
     if (in_array($fileext, array('gif', 'png', 'jpg', 'jpeg'))) {
         list($width, $height) = getImageSize($real_file);
     } else {
         $width = 0;
         $height = 0;
     }
     $this->_write(sprintf($content, $this->_getMimeType($file->uploaded_filename), $file->file_size, $width, $height, $file->sid . '.' . $fileext, $file->source_filename, $this->_getTime($file->regdate), $file->download_count));
     $fp = fopen($real_file, 'r');
     $this->_write(base64_encode(fread($fp, $file->file_size)));
     fclose($fp);
     $this->_write("</content>\r\n");
     $this->_write("</attachment>\r\n");
 }
 /**
  * When copy a menu, button copied also.
  * @param $args menuItemInfo with button values
  */
 private function _copyButton($insertedMenuItemSrl, $insertedMenuSrl, &$menuItemInfo)
 {
     $copied_info = array("normal_btn" => "", "hover_btn" => "", "active_btn" => "");
     //normal_btn
     if ($menuItemInfo->normal_btn) {
         $originFile = FileHandler::getRealPath($menuItemInfo->normal_btn);
         $targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->normal_btn, $insertedMenuSrl, $insertedMenuItemSrl, 'normal');
         FileHandler::copyFile($originFile, $targetFile);
         $copied_info['normal_btn'] = $targetFile;
     }
     //hover_btn
     if ($menuItemInfo->hover_btn) {
         $originFile = FileHandler::getRealPath($menuItemInfo->hover_btn);
         $targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->hover_btn, $insertedMenuSrl, $insertedMenuItemSrl, 'hover');
         FileHandler::copyFile($originFile, $targetFile);
         $copied_info['hover_btn'] = $targetFile;
     }
     //active_btn
     if ($menuItemInfo->active_btn) {
         $originFile = FileHandler::getRealPath($menuItemInfo->active_btn);
         $targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->active_btn, $insertedMenuSrl, $insertedMenuItemSrl, 'active');
         FileHandler::copyFile($originFile, $targetFile);
         $copied_info['active_btn'] = $targetFile;
     }
     return $copied_info;
 }
 /**
  * import layout
  * @param int $layout_srl
  * @param string $source_file path of imported file
  * @return void
  */
 function importLayout($layout_srl, $source_file)
 {
     $oLayoutModel = getModel('layout');
     $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl));
     $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl);
     foreach ($file_list as $key => $file) {
         FileHandler::removeFile($user_layout_path . $file);
     }
     require_once _XE_PATH_ . 'libs/tar.class.php';
     $image_path = $oLayoutModel->getUserLayoutImagePath($layout_srl);
     FileHandler::makeDir($image_path);
     $tar = new tar();
     $tar->openTAR($source_file);
     // If layout.ini file does not exist
     if (!$tar->getFile('layout.ini')) {
         return;
     }
     $replace_path = getNumberingPath($layout_srl, 3);
     foreach ($tar->files as $key => $info) {
         FileHandler::writeFile($user_layout_path . $info['name'], str_replace('__LAYOUT_PATH__', $replace_path, $info['file']));
     }
     // Remove uploaded file
     FileHandler::removeFile($source_file);
 }
Example #22
0
 /**
  * Display Super Admin Dashboard
  * @return void
  */
 function dispAdminIndex()
 {
     $db_info = Context::getDBInfo();
     Context::set('db_info', $db_info);
     // Get statistics
     $args = new stdClass();
     $args->date = date("Ymd000000", $_SERVER['REQUEST_TIME'] - 60 * 60 * 24);
     $today = date("Ymd");
     // Member Status
     $oMemberAdminModel = getAdminModel('member');
     $status = new stdClass();
     $status->member = new stdClass();
     $status->member->todayCount = $oMemberAdminModel->getMemberCountByDate($today);
     $status->member->totalCount = $oMemberAdminModel->getMemberCountByDate();
     // Document Status
     $oDocumentAdminModel = getAdminModel('document');
     $statusList = array('PUBLIC', 'SECRET');
     $status->document = new stdClass();
     $status->document->todayCount = $oDocumentAdminModel->getDocumentCountByDate($today, array(), $statusList);
     $status->document->totalCount = $oDocumentAdminModel->getDocumentCountByDate('', array(), $statusList);
     Context::set('status', $status);
     // Latest Document
     $oDocumentModel = getModel('document');
     $columnList = array('document_srl', 'module_srl', 'category_srl', 'title', 'nick_name', 'member_srl');
     $args->list_count = 5;
     $output = $oDocumentModel->getDocumentList($args, FALSE, FALSE, $columnList);
     Context::set('latestDocumentList', $output->data);
     unset($args, $output, $columnList);
     // Latest Comment
     $oCommentModel = getModel('comment');
     $columnList = array('comment_srl', 'module_srl', 'document_srl', 'content', 'nick_name', 'member_srl');
     $args = new stdClass();
     $args->list_count = 5;
     $output = $oCommentModel->getNewestCommentList($args, $columnList);
     if (is_array($output)) {
         foreach ($output as $key => $value) {
             $value->content = strip_tags($value->content);
         }
     }
     Context::set('latestCommentList', $output);
     unset($args, $output, $columnList);
     // Get list of modules
     $oModuleModel = getModel('module');
     $module_list = $oModuleModel->getModuleList();
     if (is_array($module_list)) {
         $needUpdate = FALSE;
         $addTables = FALSE;
         foreach ($module_list as $key => $value) {
             if ($value->need_install) {
                 $addTables = TRUE;
             }
             if ($value->need_update) {
                 $needUpdate = TRUE;
             }
         }
     }
     // Get need update from easy install
     $oAutoinstallAdminModel = getAdminModel('autoinstall');
     $needUpdateList = $oAutoinstallAdminModel->getNeedUpdateList();
     if (is_array($needUpdateList)) {
         foreach ($needUpdateList as $key => $value) {
             $helpUrl = './admin/help/index.html#';
             switch ($value->type) {
                 case 'addon':
                     $helpUrl .= 'UMAN_terminology_addon';
                     break;
                 case 'layout':
                 case 'm.layout':
                     $helpUrl .= 'UMAN_terminology_layout';
                     break;
                 case 'module':
                     $helpUrl .= 'UMAN_terminology_module';
                     break;
                 case 'widget':
                     $helpUrl .= 'UMAN_terminology_widget';
                     break;
                 case 'widgetstyle':
                     $helpUrl .= 'UMAN_terminology_widgetstyle';
                     break;
                 default:
                     $helpUrl = '';
             }
             $needUpdateList[$key]->helpUrl = $helpUrl;
         }
     }
     $site_module_info = Context::get('site_module_info');
     $oAddonAdminModel = getAdminModel('addon');
     $counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter', $site_module_info->site_srl);
     if (!$counterAddonActivated) {
         $columnList = array('member_srl', 'nick_name', 'user_name', 'user_id', 'email_address');
         $args = new stdClass();
         $args->page = 1;
         $args->list_count = 5;
         $output = executeQuery('member.getMemberList', $args, $columnList);
         Context::set('latestMemberList', $output->data);
         unset($args, $output, $columnList);
     }
     Context::set('module_list', $module_list);
     Context::set('needUpdate', $isUpdated);
     Context::set('addTables', $addTables);
     Context::set('needUpdate', $needUpdate);
     Context::set('newVersionList', $needUpdateList);
     Context::set('counterAddonActivated', $counterAddonActivated);
     $oSecurity = new Security();
     $oSecurity->encodeHTML('module_list..', 'module_list..author..', 'newVersionList..');
     // license agreement check
     $isLicenseAgreement = FALSE;
     $path = FileHandler::getRealPath('./files/env/license_agreement');
     $isLicenseAgreement = FALSE;
     if (file_exists($path)) {
         $isLicenseAgreement = TRUE;
     }
     Context::set('isLicenseAgreement', $isLicenseAgreement);
     Context::set('layout', 'none');
     $this->setTemplateFile('index');
 }
Example #23
0
 /**
  * Copy directory
  *
  * @param array $file_list File list to copy
  * @return Object
  */
 function _copyDir(&$file_list)
 {
     if (!$this->ftp_password) {
         return new Object(-1, 'msg_ftp_password_input');
     }
     $output = $this->_connect();
     if (!$output->toBool()) {
         return $output;
     }
     $oFtp =& $this->oFtp;
     $target_dir = $this->ftp_info->ftp_root_path . $this->target_path;
     if (is_array($file_list)) {
         foreach ($file_list as $k => $file) {
             $org_file = $file;
             if ($this->package->path == ".") {
                 $file = substr($file, 3);
             }
             $path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
             $path_list = explode('/', dirname($this->target_path . "/" . $file));
             $real_path = "./";
             $ftp_path = $this->ftp_info->ftp_root_path;
             for ($i = 0; $i < count($path_list); $i++) {
                 if ($path_list == "") {
                     continue;
                 }
                 $real_path .= $path_list[$i] . "/";
                 $ftp_path .= $path_list[$i] . "/";
                 if (!file_exists(FileHandler::getRealPath($real_path))) {
                     $oFtp->ftp_mkdir($ftp_path);
                     $oFtp->ftp_site("CHMOD 755 " . $ftp_path);
                 }
             }
             $oFtp->ftp_put($target_dir . '/' . $file, FileHandler::getRealPath($this->download_path . "/" . $org_file));
         }
     }
     $this->_close();
     return new Object();
 }
 /**
  * @brief ini 파일을 읽는다
  **/
 function readIniFile($filename)
 {
     $filename = FileHandler::getRealPath($filename);
     if (!file_exists($filename)) {
         return false;
     }
     $arr = parse_ini_file($filename, true);
     if (is_array($arr) && count($arr) > 0) {
         return $arr;
     } else {
         return array();
     }
 }
Example #25
0
 /**
  * Produce HTML compliant content given a module object.\n
  * @param ModuleObject $oModule the module object
  * @return string compiled template string
  */
 function toDoc(&$oModule)
 {
     $oTemplate = TemplateHandler::getInstance();
     // compile module tpl
     // deprecated themes skin
     $template_path = $oModule->getTemplatePath();
     if (!is_dir($template_path)) {
         if ($oModule->module_info->module == $oModule->module) {
             $skin = $oModule->origin_module_info->skin;
         } else {
             $skin = $oModule->module_config->skin;
         }
         if (Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') === false) {
             if ($skin && is_string($skin)) {
                 $theme_skin = explode('|@|', $skin);
                 $template_path = $oModule->getTemplatePath();
                 if (count($theme_skin) == 2) {
                     $theme_path = sprintf('./themes/%s', $theme_skin[0]);
                     // FIXME $theme_path $theme_path $theme_path ??
                     if (substr($theme_path, 0, strlen($theme_path)) != $theme_path) {
                         $template_path = sprintf('%s/modules/%s/', $theme_path, $theme_skin[1]);
                     }
                 }
             } else {
                 $template_path = $oModule->getTemplatePath();
             }
         } else {
             $template_path = $oModule->getTemplatePath();
         }
     }
     $tpl_file = $oModule->getTemplateFile();
     $output = $oTemplate->compile($template_path, $tpl_file);
     // add .x div for adminitration pages
     if (Context::getResponseMethod() == 'HTML') {
         if (Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') > 0 && Context::get('act') != 'dispPageAdminContentModify' && Context::get('act') != 'dispPageAdminMobileContentModify') {
             $output = '<div class="x">' . $output . '</div>';
         }
         if (Context::get('layout') != 'none') {
             if (__DEBUG__ == 3) {
                 $start = getMicroTime();
             }
             Context::set('content', $output, false);
             $layout_path = $oModule->getLayoutPath();
             $layout_file = $oModule->getLayoutFile();
             $edited_layout_file = $oModule->getEditedLayoutFile();
             // get the layout information currently requested
             $oLayoutModel = getModel('layout');
             $layout_info = Context::get('layout_info');
             $layout_srl = $layout_info->layout_srl;
             // compile if connected to the layout
             if ($layout_srl > 0) {
                 // handle separately if the layout is faceoff
                 if ($layout_info && $layout_info->type == 'faceoff') {
                     $oLayoutModel->doActivateFaceOff($layout_info);
                     Context::set('layout_info', $layout_info);
                 }
                 // search if the changes CSS exists in the admin layout edit window
                 $edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
                 if (FileHandler::exists($edited_layout_css)) {
                     Context::loadFile(array($edited_layout_css, 'all', '', 100));
                 }
             }
             if (!$layout_path) {
                 $layout_path = './common/tpl';
             }
             if (!$layout_file) {
                 $layout_file = 'default_layout';
             }
             $output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
             // if popup_layout, remove admin bar.
             $realLayoutPath = FileHandler::getRealPath($layout_path);
             if (substr_compare($realLayoutPath, '/', -1) !== 0) {
                 $realLayoutPath .= '/';
             }
             $pathInfo = pathinfo($layout_file);
             $onlyLayoutFile = $pathInfo['filename'];
             if ($realLayoutPath === _XE_PATH_ . 'common/tpl/' && $onlyLayoutFile === 'popup_layout') {
                 Context::set('admin_bar', 'false');
             }
             // DISABLE ADMIN BAR
             Context::set('admin_bar', 'false');
             if (__DEBUG__ == 3) {
                 $GLOBALS['__layout_compile_elapsed__'] = getMicroTime() - $start;
             }
             if (stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always')) {
                 Context::addHtmlFooter('<iframe id="xeTmpIframe" name="xeTmpIframe" style="width:1px;height:1px;position:absolute;top:-2px;left:-2px;"></iframe>');
             }
         }
     }
     return $output;
 }
Example #26
0
 /**
  * Process the images from body content. This functions is used if Mailer is set as mail not as SMTP
  *
  * @return void
  */
 function procCidAttachments()
 {
     if (count($this->cidAttachments) > 0) {
         $this->body = $this->header . $this->body;
         $boundary = '----==' . uniqid(rand(), TRUE);
         $this->header = "Content-Type: multipart/relative;" . $this->eol . "\ttype=\"multipart/alternative\";" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol;
         $this->body = "--" . $boundary . $this->eol . $this->body . $this->eol . $this->eol;
         $res = array();
         $res[] = $this->body;
         foreach ($this->cidAttachments as $cid => $attachment) {
             $filename = basename($attachment);
             $type = $this->returnMIMEType(FileHandler::getRealPath($attachment));
             $file_str = FileHandler::readFile($attachment);
             $chunks = chunk_split(base64_encode($file_str));
             $tempBody = sprintf("--" . $boundary . $this->eol . "Content-Type: %s;" . $this->eol . "\tname=\"%s\"" . $this->eol . "Content-Transfer-Encoding: base64" . $this->eol . "Content-ID: <%s>" . $this->eol . "Content-Description: %s" . $this->eol . "Content-Location: %s" . $this->eol . $this->eol . "%s" . $this->eol . $this->eol, $type, $filename, $cid, $filename, $filename, $chunks);
             $res[] = $tempBody;
         }
         $this->body = implode("", $res);
         $this->body .= "--" . $boundary . "--";
     }
 }
Example #27
0
 /**
  * Cunstructor
  *
  * @return void
  */
 private function __construct()
 {
     $this->oFrontEndFileHandler = new FrontEndFileHandler();
     $this->get_vars = new stdClass();
     self::$_user_vars = new stdClass();
     // include ssl action cache file
     $this->sslActionCacheFile = FileHandler::getRealPath($this->sslActionCacheFile);
     if (is_readable($this->sslActionCacheFile)) {
         require $this->sslActionCacheFile;
         if (isset($sslActions)) {
             $this->ssl_actions = $sslActions;
         }
     }
 }
Example #28
0
 /**
  * Enviroment information send to XE collect server
  * @return void
  */
 function showSendEnv()
 {
     if (Context::getResponseMethod() != 'HTML') {
         return;
     }
     $server = 'http://collect.xpressengine.com/env/img.php?';
     $path = './files/env/';
     $install_env = $path . 'install';
     $mainVersion = join('.', array_slice(explode('.', __XE_VERSION__), 0, 2));
     if (file_exists(FileHandler::getRealPath($install_env))) {
         $oAdminAdminModel = getAdminModel('admin');
         $params = $oAdminAdminModel->getEnv('INSTALL');
         $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params);
         Context::addHtmlFooter($img);
         FileHandler::writeFile($path . $mainVersion, '1');
     } else {
         if (isset($_SESSION['enviroment_gather']) && !file_exists(FileHandler::getRealPath($path . $mainVersion))) {
             if ($_SESSION['enviroment_gather'] == 'Y') {
                 $oAdminAdminModel = getAdminModel('admin');
                 $params = $oAdminAdminModel->getEnv();
                 $img = sprintf('<img src="%s" alt="" style="height:0px;width:0px" />', $server . $params);
                 Context::addHtmlFooter($img);
             }
             FileHandler::writeFile($path . $mainVersion, '1');
             unset($_SESSION['enviroment_gather']);
         }
     }
 }
Example #29
0
 /**
  * user layout ini
  * @param int $layout_srl
  * @return string
  */
 function getUserLayoutIni($layout_srl)
 {
     $src = $this->getUserLayoutPath($layout_srl) . 'layout.ini';
     if ($this->useUserLayoutTemp == 'temp') {
         $temp = $this->getUserLayoutTempIni($layout_srl);
         if (!file_exists(FileHandler::getRealPath($temp))) {
             FileHandler::copyFile($src, $temp);
         }
         return $temp;
     }
     return $src;
 }
 function procNcenterliteAdminEnviromentGatheringAgreement()
 {
     $vars = Context::getRequestVars();
     $oModuleModel = getModel('module');
     $ncenterlite_module_info = $oModuleModel->getModuleInfoXml('ncenterlite');
     $agreement_file = FileHandler::getRealPath(sprintf('%s%s.txt', './files/ncenterlite/ncenterlite-', $ncenterlite_module_info->version));
     FileHandler::writeFile($agreement_file, $vars->is_agree);
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispNcenterliteAdminConfig');
         header('location: ' . $returnUrl);
         return;
     }
 }