Example #1
1
 /**
  * @brief Get the points
  */
 function getPoint($member_srl, $from_db = false)
 {
     $member_srl = abs($member_srl);
     // Get from instance memory
     if (!$from_db && $this->pointList[$member_srl]) {
         return $this->pointList[$member_srl];
     }
     // Get from file cache
     $path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
     $cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
     if (!$from_db && file_exists($cache_filename)) {
         return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
     }
     // Get from the DB
     $args = new stdClass();
     $args->member_srl = $member_srl;
     $output = executeQuery('point.getPoint', $args);
     if (isset($output->data->member_srl)) {
         $point = (int) $output->data->point;
         $this->pointList[$member_srl] = $point;
         if (!is_dir($path)) {
             FileHandler::makeDir($path);
         }
         FileHandler::writeFile($cache_filename, $point);
         return $point;
     }
     return 0;
 }
Example #2
0
 public function testHandleError()
 {
     $extra = ['mode' => 'application mode'];
     $record = ['message' => $this->message, 'level' => $this->recordLevel, 'extra' => $extra];
     $this->fileHandler->setLevel($this->handlerLevel);
     $result = $this->fileHandler->handle($record);
     $this->assertFalse($result);
 }
 public function convert($to, $from)
 {
     $fileHandler = new FileHandler('fiat/bitcoinindex/' . strtolower($to) . '_' . strtolower($from) . '.json');
     if ($GLOBALS['cached'] == false || $fileHandler->lastTimeModified() >= 3600) {
         // updates every 1 minute
         $data = array();
         $data = curlCall($this->_url . '/v0.1/conversions/' . strtolower($from) . '/' . strtolower($to));
         // /v0.1/conversions/:from/:to
         $fileHandler->write(json_encode($data));
         return $data;
     }
     return json_decode($fileHandler->read(), true);
 }
Example #4
0
 /**
  * @brief 캐시 파일 재생성
  **/
 function recompileCache()
 {
     // widget 정보를 담은 캐시 파일 삭제
     FileHandler::removeFilesInDir("./files/cache/widget");
     // widget 생성 캐시 파일 삭제
     FileHandler::removeFilesInDir("./files/cache/widget_cache");
 }
Example #5
0
 /**
  * @brief Implement if additional tasks are necessary when installing
  */
 function moduleInstall()
 {
     // Register action forward (to use in administrator mode)
     $oModuleController = getController('module');
     // Add the default editor component
     $oEditorController = getAdminController('editor');
     $oEditorController->insertComponent('colorpicker_text', true);
     $oEditorController->insertComponent('colorpicker_bg', true);
     $oEditorController->insertComponent('emoticon', true);
     $oEditorController->insertComponent('url_link', true);
     $oEditorController->insertComponent('image_link', true);
     $oEditorController->insertComponent('multimedia_link', true);
     $oEditorController->insertComponent('quotation', true);
     $oEditorController->insertComponent('table_maker', true);
     $oEditorController->insertComponent('poll_maker', true);
     $oEditorController->insertComponent('image_gallery', true);
     // Create a directory to use in the editor module
     FileHandler::makeDir('./files/cache/editor');
     // 2007. 10. 17 Add a trigger to delete automatically saved document whenever the document(insert or update) is modified
     $oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after');
     $oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after');
     // 2007. 10. 23 Add an editor trigger on the module addition setup
     $oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before');
     // 2009. 04. 14 Add a trigger from compiled codes of the editor component
     $oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before');
     return new Object();
 }
Example #6
0
 /**
  * Implement if additional tasks are necessary when installing
  *
  * @return Object
  */
 function moduleInstall()
 {
     // Register action forward (to use in administrator mode)
     $oModuleController = getController('module');
     // Save the default settings for attachments
     $config = new stdClass();
     $config->allowed_filesize = '2';
     $config->allowed_attach_size = '2';
     $config->allowed_filetypes = '*.*';
     $oModuleController->insertModuleConfig('file', $config);
     // Generate a directory for the file module
     FileHandler::makeDir('./files/attach/images');
     FileHandler::makeDir('./files/attach/binaries');
     // 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
     $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
     $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
     $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
     $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
     $oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after');
     $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
     $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
     $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
     $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
     $oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after');
     // 2009. 6. 9 Delete all the attachements when auto-saved document is deleted
     $oModuleController->insertTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after');
     // 2007. 10. 17 Create a trigger to delete all the attachements when the module is deleted
     $oModuleController->insertTrigger('module.deleteModule', 'file', 'controller', 'triggerDeleteModuleFiles', 'after');
     // 2007. 10. 19 Call a trigger to set up the file permissions before displaying
     $oModuleController->insertTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before');
     return new Object();
 }
Example #7
0
function getNewsFromAgency()
{
    //Retrieve recent news and set them into context
    $newest_news_url = sprintf("http://www.xeshoppingmall.com/?module=newsagency&act=getNewsagencyArticle&inst=notice&top=6&loc=%s", _XE_LOCATION_);
    $cache_file = sprintf("%sfiles/cache/nstore_news.%s.cache.php", _XE_PATH_, _XE_LOCATION_);
    if (!file_exists($cache_file) || filemtime($cache_file) + 60 * 60 < time()) {
        // Considering if data cannot be retrieved due to network problem, modify filemtime to prevent trying to reload again when refreshing textmessageistration page
        // Ensure to access the textmessageistration page even though news cannot be displayed
        FileHandler::writeFile($cache_file, '');
        FileHandler::getRemoteFile($newest_news_url, $cache_file, null, 1, 'GET', 'text/html', array('REQUESTURL' => getFullUrl('')));
    }
    if (file_exists($cache_file)) {
        $oXml = new XmlParser();
        $buff = $oXml->parse(FileHandler::readFile($cache_file));
        $item = $buff->zbxe_news->item;
        if ($item) {
            if (!is_array($item)) {
                $item = array($item);
            }
            foreach ($item as $key => $val) {
                $obj = null;
                $obj->title = $val->body;
                $obj->date = $val->attrs->date;
                $obj->url = $val->attrs->url;
                $news[] = $obj;
            }
            return $news;
        }
    }
}
Example #8
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 procAuthenticationAdminConfig()
 {
     $args = Context::getRequestVars();
     if (!trim(strip_tags($args->agreement))) {
         $agreement_file = _XE_PATH_ . 'files/authentication/agreement_' . Context::get('lang_type') . '.txt';
         FileHandler::removeFile($agreement_file);
         $args->agreement = NULL;
     }
     // check agreement value exist
     if ($args->agreement) {
         $agreement_file = _XE_PATH_ . 'files/authentication/agreement_' . Context::get('lang_type') . '.txt';
         $output = FileHandler::writeFile($agreement_file, $args->agreement);
         unset($args->agreement);
     }
     if (!$args->sender_no) {
         $args->sender_no = NULL;
     }
     if (!$args->message_content) {
         $args->message_content = NULL;
     }
     if (!$args->list) {
         $args->list = NULL;
     }
     if (!$args->cellphone_fieldname) {
         $args->cellphone_fieldname = NULL;
     }
     // save module configuration.
     $oModuleController = getController('module');
     $output = $oModuleController->updateModuleConfig('authentication', $args);
     $this->setMessage('success_saved');
     $redirectUrl = getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAuthenticationAdminConfig');
     $this->setRedirectUrl($redirectUrl);
 }
Example #10
0
 /**
  * @brief 일반 요청시 출력
  **/
 function dispPageIndex()
 {
     // 템플릿에서 사용할 변수를 Context::set()
     if ($this->module_srl) {
         Context::set('module_srl', $this->module_srl);
     }
     // 캐시 파일 지정
     $cache_file = sprintf("%sfiles/cache/page/%d.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
     $interval = (int) $this->module_info->page_caching_interval;
     if ($interval > 0) {
         if (!file_exists($cache_file)) {
             $mtime = 0;
         } else {
             $mtime = filemtime($cache_file);
         }
         if ($mtime + $interval * 60 > time()) {
             $page_content = FileHandler::readFile($cache_file);
         } else {
             $oWidgetController =& getController('widget');
             $page_content = $oWidgetController->transWidgetCode($this->module_info->content);
             FileHandler::writeFile($cache_file, $page_content);
         }
     } else {
         if (file_exists($cache_file)) {
             FileHandler::removeFile($cache_file);
         }
         $page_content = $this->module_info->content;
     }
     Context::set('module_info', $this->module_info);
     Context::set('page_content', $page_content);
     $this->setTemplateFile('content');
 }
 /**
  * @brief 특정 모두의 첨부파일 모두 삭제
  **/
 function deleteModuleFiles($module_srl)
 {
     // 전체 첨부파일 목록을 구함
     $args->module_srl = $module_srl;
     $output = executeQueryArray('file.getModuleFiles', $args);
     if (!$output) {
         return $output;
     }
     $files = $output->data;
     // DB에서 삭제
     $args->module_srl = $module_srl;
     $output = executeQuery('file.deleteModuleFiles', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // 실제 파일 삭제 (일단 약속에 따라서 한번에 삭제)
     FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl));
     FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl));
     // DB에서 구한 파일 목록을 삭제
     $path = array();
     $cnt = count($files);
     for ($i = 0; $i < $cnt; $i++) {
         $uploaded_filename = $files[$i]->uploaded_filename;
         FileHandler::removeFile($uploaded_filename);
         $path_info = pathinfo($uploaded_filename);
         if (!in_array($path_info['dirname'], $path)) {
             $path[] = $path_info['dirname'];
         }
     }
     // 해당 글의 첨부파일 디렉토리 삭제
     for ($i = 0; $i < count($path); $i++) {
         FileHandler::removeBlankDir($path[$i]);
     }
     return $output;
 }
Example #12
0
 /**
  * Returns the path to the thumbnail image
  *
  * If a thumbnail does not already exist, it is generated,
  * written to disk and then the new path is returned
  *
  * @param int    $width
  * @param int    $height
  * @param string $thumbnail_type
  * @return mixed|string
  */
 public function getThumbnailPath($width = 80, $height = 0, $thumbnail_type = '')
 {
     // If signiture height setting is omitted, create a square
     if (!$height) {
         $height = $width;
     }
     // get thumbail generation info on the doc module configuration.
     if (!in_array($thumbnail_type, array('crop', 'ratio'))) {
         $thumbnail_type = 'ratio';
     }
     // Define thumbnail information
     $thumbnail_path = sprintf('files/cache/thumbnails/%s', getNumberingPath($this->unique_identifier, 3));
     $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
     // If thumbnail was already created, return path to it
     if (is_file($thumbnail_file)) {
         return $thumbnail_file;
     }
     // Retrieve info about original image: path and extension
     $source_file = $this->full_image_path;
     $ext = pathinfo($source_file, PATHINFO_EXTENSION);
     // Create thumbnail
     $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, $ext, $thumbnail_type);
     if ($output) {
         return $thumbnail_file;
     } else {
         return '';
     }
 }
 /**
  * @brief 업데이트 실행
  **/
 function moduleUpdate()
 {
     if (!is_dir("./files/member_extra_info/new_message_flags")) {
         FileHandler::makeDir('./files/member_extra_info/new_message_flags');
     }
     return new Object(0, 'success_updated');
 }
Example #14
0
 function _getWidgetContent()
 {
     // Arrange a widget ryeolro
     if ($this->module_info->mcontent) {
         $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
         $interval = (int) $this->module_info->page_caching_interval;
         if ($interval > 0) {
             if (!file_exists($cache_file) || filesize($cache_file) < 1) {
                 $mtime = 0;
             } else {
                 $mtime = filemtime($cache_file);
             }
             if ($mtime + $interval * 60 > $_SERVER['REQUEST_TIME']) {
                 $page_content = FileHandler::readFile($cache_file);
                 $page_content = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $page_content);
             } else {
                 $oWidgetController = getController('widget');
                 $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
                 FileHandler::writeFile($cache_file, $page_content);
             }
         } else {
             if (file_exists($cache_file)) {
                 FileHandler::removeFile($cache_file);
             }
             $page_content = $this->module_info->mcontent;
         }
     } else {
         $page_content = $this->module_info->content;
     }
     return $page_content;
 }
Example #15
0
 function _getWidgetContent()
 {
     // Arrange a widget ryeolro
     if ($this->module_info->mcontent) {
         $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
         $interval = (int) $this->module_info->page_caching_interval;
         if ($interval > 0) {
             if (!file_exists($cache_file) || filesize($cache_file) < 1) {
                 $mtime = 0;
             } else {
                 $mtime = filemtime($cache_file);
             }
             if ($mtime + $interval * 60 > time()) {
                 $page_content = FileHandler::readFile($cache_file);
                 $page_content = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $page_content);
             } else {
                 $oWidgetController =& getController('widget');
                 $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
                 FileHandler::writeFile($cache_file, $page_content);
             }
         } else {
             if (file_exists($cache_file)) {
                 FileHandler::removeFile($cache_file);
             }
             $page_content = $this->module_info->mcontent;
         }
     } else {
         preg_match_all('!(<img)([^\\>]*)(widget=)([^\\>]*?)(\\>)!is', $this->module_info->content, $matches);
         $page_content = '';
         for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
             $page_content .= preg_replace('/ style\\=\\"([^\\"]+)\\" /i', ' style="overflow:hidden;clear:both;margin:0 0 20px 0; _margin-right:10px;" ', $matches[0][$i]) . "\n\n";
         }
     }
     return $page_content;
 }
Example #16
0
 /**
  * @brief 설치시 추가 작업이 필요할시 구현
  **/
 function moduleInstall()
 {
     // action forward에 등록 (관리자 모드에서 사용하기 위함)
     $oModuleController =& getController('module');
     // 첨부파일의 기본 설정 저장
     $config->allowed_filesize = '2';
     $config->allowed_attach_size = '2';
     $config->allowed_filetypes = '*.*';
     $oModuleController->insertModuleConfig('file', $config);
     // file 모듈에서 사용할 디렉토리 생성
     FileHandler::makeDir('./files/attach/images');
     FileHandler::makeDir('./files/attach/binaries');
     // 2007. 10. 17 글/댓글의 입력/수정/삭제에 대한 trigger 등록
     $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
     $oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
     $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
     $oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
     $oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after');
     $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
     $oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
     $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
     $oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
     $oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after');
     // 2009. 6. 9 자동저장문서 삭제시 첨부 파일도 같이 삭제
     $oModuleController->insertTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after');
     // 2007. 10. 17 모듈이 삭제될때 등록된 첨부파일도 모두 삭제하는 트리거 추가
     $oModuleController->insertTrigger('module.deleteModule', 'file', 'controller', 'triggerDeleteModuleFiles', 'after');
     // 2007. 10. 19 출력하기 전에 file 권한등을 세팅하는 트리거 호출
     $oModuleController->insertTrigger('module.dispAdditionSetup', 'file', 'view', 'triggerDispFileAdditionSetup', 'before');
     return new Object();
 }
 /**
  * @brief RSS 전체피드 설정
  **/
 function procRssAdminInsertConfig()
 {
     $oModuleModel =& getModel('module');
     $total_config = $oModuleModel->getModuleConfig('rss');
     $config_vars = Context::getRequestVars();
     $config_vars->feed_document_count = (int) $config_vars->feed_document_count;
     if (!$config_vars->use_total_feed) {
         $alt_message = 'msg_invalid_request';
     }
     if (!in_array($config_vars->use_total_feed, array('Y', 'N'))) {
         $config_vars->open_rss = 'Y';
     }
     if ($config_vars->image || $config_vars->del_image) {
         $image_obj = $config_vars->image;
         $config_vars->image = $total_config->image;
         // 삭제 요청에 대한 변수를 구함
         if ($config_vars->del_image == 'Y' || $image_obj) {
             FileHandler::removeFile($config_vars->image);
             $config_vars->image = '';
             $total_config->image = '';
         }
         // 정상적으로 업로드된 파일이 아니면 무시
         if ($image_obj['tmp_name'] && is_uploaded_file($image_obj['tmp_name'])) {
             // 이미지 파일이 아니어도 무시 (swf는 패스~)
             $image_obj['name'] = Context::convertEncodingStr($image_obj['name']);
             if (!preg_match("/\\.(jpg|jpeg|gif|png)\$/i", $image_obj['name'])) {
                 $alt_message = 'msg_rss_invalid_image_format';
             } else {
                 // 경로를 정해서 업로드
                 $path = './files/attach/images/rss/';
                 // 디렉토리 생성
                 if (!FileHandler::makeDir($path)) {
                     $alt_message = 'msg_error_occured';
                 } else {
                     $filename = $path . $image_obj['name'];
                     // 파일 이동
                     if (!move_uploaded_file($image_obj['tmp_name'], $filename)) {
                         $alt_message = 'msg_error_occured';
                     } else {
                         $config_vars->image = $filename;
                     }
                 }
             }
         }
     }
     if (!$config_vars->image && $config_vars->del_image != 'Y') {
         $config_vars->image = $total_config->image;
     }
     $output = $this->setFeedConfig($config_vars);
     if (!$alt_message) {
         $alt_message = 'success_updated';
     }
     $alt_message = Context::getLang($alt_message);
     Context::set('msg', $alt_message);
     $this->setLayoutPath('./common/tpl');
     $this->setLayoutFile('default_layout.html');
     $this->setTemplatePath($this->module_path . 'tpl');
     $this->setTemplateFile("top_refresh.html");
 }
Example #18
0
 public static function save($filename, $data = array())
 {
     $base = array('version' => null, 'data' => null);
     $version = AppData::first();
     $base['version'] = array('schema' => $version->schema_version, 'data' => $version->data_version, 'seq' => $version->data_sequence_no, 'built' => date('Y-m-d H:i:s'));
     $base['data'] = $data;
     file_put_contents(FileHandler::path() . $filename . '.json', json_encode($base));
 }
Example #19
0
 /**
  * @return bool True if the step has a breakdown timeline, false otherwise
  */
 public function hasBreakdownTimeline()
 {
     $info = $this->testInfo->getInfoArray();
     if (!isset($info) || empty($info["timeline"])) {
         return false;
     }
     return $this->fileHandler->gzFileExists($this->localPaths->devtoolsFile()) || $this->fileHandler->gzFileExists($this->localPaths->devtoolsTraceFile());
 }
Example #20
0
 function pluginInstall($args)
 {
     // mkdir
     FileHandler::makeDir(sprintf(_XE_PATH_ . "files/epay/%s/log", $args->plugin_srl));
     // copy files
     FileHandler::copyFile(_XE_PATH_ . 'modules/epay/plugins/payplus6/.htaccess', sprintf(_XE_PATH_ . "files/epay/%s/.htaccess", $args->plugin_srl));
     FileHandler::copyFile(_XE_PATH_ . 'modules/epay/plugins/payplus6/readme.txt', sprintf(_XE_PATH_ . "files/epay/%s/readme.txt", $args->plugin_srl));
 }
Example #21
0
 function getLicenseFromAgency($prodid, &$has_license = TRUE, &$expiration = NULL)
 {
     $has_license = TRUE;
     $oLicenseModel =& getModel('license');
     $config = $oLicenseModel->getModuleConfig();
     if ($prodid == 'nstore') {
         $user_id = $config->user_id;
         $serial_number = $config->serial_number;
     } else {
         if ($prodid == 'nstore_digital') {
             $user_id = $config->d_user_id;
             $serial_number = $config->d_serial_number;
         } else {
             $user_id = $config->e_user_id;
             $serial_number = $config->e_serial_number;
         }
     }
     $cache_file = $this->checkLicense($prodid, $user_id, $serial_number);
     if (file_exists($cache_file)) {
         $oXml = new XmlParser();
         $buff = $oXml->parse(FileHandler::readFile($cache_file));
         // user
         $userObj = $buff->drm->user;
         if ($userObj) {
             $user = $userObj->body;
             if ($user != $user_id) {
                 $this->checkLicense($prodid, $user_id, $serial_number, TRUE);
                 return TRUE;
             }
         }
         // serial
         $serialObj = $buff->drm->serial;
         if ($serialObj) {
             $serial = $serialObj->body;
             if ($serial != $serial_number) {
                 $this->checkLicense($prodid, $user_id, $serial_number, TRUE);
                 return TRUE;
             }
         }
         // license
         $licenseObj = $buff->drm->license;
         if ($licenseObj) {
             $license = $licenseObj->body;
             if ($license == 'none') {
                 $url = getUrl('act', 'dispLicenseAdminConfig');
                 Context::set(sprintf('%s_MESSAGE_TYPE', strtoupper($prodid)), 'error');
                 Context::set(sprintf('%s_MESSAGE', strtoupper($prodid)), Context::getLang('not_registered'));
                 $has_license = FALSE;
             }
         }
         // expiration
         $expirationObj = $buff->drm->expiration;
         if ($expirationObj) {
             $expiration = $expirationObj->body;
         }
     }
     return FALSE;
 }
Example #22
0
 /**
  * Load a xml file specified by a filename and parse it to Return the resultant data object
  * @param string $filename a file path of file
  * @return array Returns a data object containing data extracted from a xml file or NULL if a specified file does not exist
  */
 function loadXmlFile($filename)
 {
     if (!file_exists($filename)) {
         return;
     }
     $buff = FileHandler::readFile($filename);
     $oXmlParser = new XmlParser();
     return $oXmlParser->parse($buff);
 }
Example #23
0
 public function __construct()
 {
     // Retrieve the FrontEndFileHandler instance from the Context class.
     $this->fefh = Context::getInstance()->oFrontEndFileHandler;
     // Create the cache directory if it does not exist.
     $this->cacheDir = _XE_PATH_ . 'files/cache/zipperupper';
     if (!file_exists($this->cacheDir)) {
         $fileHandler = new FileHandler();
         $fileHandler->makeDir($this->cacheDir);
     }
     // Find out the absolute or relative path of XE installation.
     if (strncasecmp(_XE_PATH_, $_SERVER['DOCUMENT_ROOT'], strlen($_SERVER['DOCUMENT_ROOT'])) === 0) {
         $this->urlPrefix = substr(_XE_PATH_, strlen(rtrim($_SERVER['DOCUMENT_ROOT'], '/\\')));
         $this->urlPrefix = str_replace('\\', '/', $this->urlPrefix);
     } else {
         $this->urlPrefix = '../../../';
     }
 }
Example #24
0
 public function testSerialization()
 {
     // Test Data
     $testData = [['firstname' => 'Bobby', 'surname' => 'Silver'], ['firstname' => 'Jake', 'surname' => 'Starkiller'], ['firstname' => 'Dirk', 'surname' => 'Diggler']];
     // Load up in a collection
     $humanCollection = new HumanCollection();
     foreach ($testData as $node) {
         $humanCollection->add(new Human($node['firstname'], $node['surname']));
     }
     // Save and read from a file
     $fileHandler = new FileHandler();
     $filename = 'testfile.json';
     $fileHandler->writeToFile($humanCollection, $filename);
     $col = $fileHandler->readFromFile($filename);
     unlink($filename);
     // Test is data from the file is the same
     $this->assertEquals($humanCollection->serialize(), $col->serialize());
 }
Example #25
0
 /**
  * @brief Additional tasks required to accomplish during the installation
  */
 function moduleInstall()
 {
     // Registration in action forward (for using in the administrator mode)
     $oModuleController = getController('module');
     // Create a directory to store points information
     FileHandler::makeDir('./files/member_extra_info/point');
     $oModuleController = getController('module');
     // The highest level
     $config = new stdClass();
     // default, point module is OFF
     $config->able_module = 'N';
     $config->max_level = 30;
     // Per-level score
     for ($i = 1; $i <= 30; $i++) {
         $config->level_step[$i] = pow($i, 2) * 90;
     }
     // Points for registration
     $config->signup_point = 10;
     // Login points
     $config->login_point = 5;
     // Point's name
     $config->point_name = 'point';
     // Level icon directory
     $config->level_icon = "default";
     // Prevent downloads if there are no scores
     $config->disable_download = false;
     /**
      * Define the default points per module as well as all actions (as we do not know if it is forum or blogs, specify "act")
      */
     // Insert document
     $config->insert_document = 10;
     $config->insert_document_act = 'procBoardInsertDocument';
     $config->delete_document_act = 'procBoardDeleteDocument';
     // Insert comment
     $config->insert_comment = 5;
     $config->insert_comment_act = 'procBoardInsertComment,procBlogInsertComment';
     $config->delete_comment_act = 'procBoardDeleteComment,procBlogDeleteComment';
     // Upload
     $config->upload_file = 5;
     $config->upload_file_act = 'procFileUpload';
     $config->delete_file_act = 'procFileDelete';
     // Download
     $config->download_file = -5;
     $config->download_file_act = 'procFileDownload';
     // View
     $config->read_document = 0;
     // Vote up / Vote down
     $config->voted = 0;
     $config->blamed = 0;
     // Save configurations
     $oModuleController->insertModuleConfig('point', $config);
     // Cash act list for faster execution
     $oPointController = getAdminController('point');
     $oPointController->cacheActList();
     return new Object();
 }
Example #26
0
 /**
  * @brief Implement if additional tasks are necessary when installing
  **/
 function moduleInstall()
 {
     // Create cache directory used by widget
     FileHandler::makeDir('./files/cache/widget');
     FileHandler::makeDir('./files/cache/widget_cache');
     // Add this widget compile the trigger for the display.after
     $oModuleController =& getController('module');
     $oModuleController->insertTrigger('display', 'widget', 'controller', 'triggerWidgetCompile', 'before');
     return new Object();
 }
 public function check($file)
 {
     // TODO: 기능개선후 enable
     return TRUE;
     // disable
     if (!$file || !FileHandler::exists($file)) {
         return TRUE;
     }
     return self::_check($file);
 }
Example #28
0
 public function __construct($post, $audio_only, $outfilename = False, $vformat = False)
 {
     $this->config = (require dirname(__DIR__) . '/config/config.php');
     $fh = new FileHandler();
     $this->download_path = $fh->get_downloads_folder();
     if ($this->config["log"]) {
         $this->log_path = $fh->get_logs_folder();
     }
     $this->audio_only = $audio_only;
     $this->urls = explode(",", $post);
     if (!$this->check_requirements($audio_only)) {
         return;
     }
     if ($outfilename) {
         $this->outfilename = $outfilename;
     }
     if ($vformat) {
         $this->vformat = $vformat;
     }
     foreach ($this->urls as $url) {
         if (!$this->is_valid_url($url)) {
             $this->errors[] = "\"" . $url . "\" is not a valid url !";
         }
     }
     if (isset($this->errors) && count($this->errors) > 0) {
         $_SESSION['errors'] = $this->errors;
         return;
     }
     if ($this->config["max_dl"] == 0) {
         $this->do_download();
     } elseif ($this->config["max_dl"] > 0) {
         if ($this->background_jobs() >= 0 && $this->background_jobs() < $this->config["max_dl"]) {
             $this->do_download();
         } else {
             $this->errors[] = "Simultaneous downloads limit reached !";
         }
     }
     if (isset($this->errors) && count($this->errors) > 0) {
         $_SESSION['errors'] = $this->errors;
         return;
     }
 }
 /**
  * Save image to disk
  *
  * @author Dan Dragan (dev@xpressengine.org)
  * @param $image ProductImage
  * @return boolean
  */
 public function saveImage(ProductImage &$image)
 {
     try {
         $path = sprintf('./files/attach/images/shop/%d/product-images/%d/', $image->module_srl, $image->product_srl);
         $filename = sprintf('%s%s', $path, $image->filename);
         FileHandler::copyFile($image->source_filename, $filename);
     } catch (Exception $e) {
         return new Object(-1, $e->getMessage());
     }
     return TRUE;
 }
Example #30
0
 /**
  * Prepare runtime context - tell DB class that current DB is CUBRID
  */
 protected function setUp()
 {
     $this->markTestSkipped();
     $oContext =& Context::getInstance();
     $db_info->master_db = array('db_type' => 'cubrid', 'db_port' => '33000', 'db_hostname' => '10.0.0.206', 'db_userid' => 'dba', 'db_password' => 'arniarules', 'db_database' => 'xe15QA', 'db_table_prefix' => 'xe_');
     $db_info->slave_db = array(array('db_type' => 'cubrid', 'db_port' => '33000', 'db_hostname' => '10.0.0.206', 'db_userid' => 'dba', 'db_password' => 'arniarules', 'db_database' => 'xe15QA', 'db_table_prefix' => 'xe_'));
     $oContext->setDbInfo($db_info);
     // remove cache dir
     FileHandler::removeDir(_XE_PATH_ . 'files/cache');
     DB::getParser(true);
 }