/**
  * @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;
 }
 function deleteMenu($menu_srl)
 {
     // 캐시 파일 삭제
     $cache_list = FileHandler::readDir("./files/cache/menu", "", false, true);
     if (count($cache_list)) {
         foreach ($cache_list as $cache_file) {
             $pos = strpos($cache_file, $menu_srl . '_');
             if ($pos > 0) {
                 FileHandler::removeFile($cache_file);
             }
         }
     }
     // 이미지 버튼 모두 삭제
     $image_path = sprintf('./files/attach/menu_button/%s', $menu_srl);
     FileHandler::removeDir($image_path);
     $args->menu_srl = $menu_srl;
     // 메뉴 메뉴 삭제
     $output = executeQuery("menu.deleteMenuItems", $args);
     if (!$output->toBool()) {
         return $output;
     }
     // 메뉴 삭제
     $output = executeQuery("menu.deleteMenu", $args);
     if (!$output->toBool()) {
         return $output;
     }
     return new Object(0, 'success_deleted');
 }
Esempio n. 3
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);
 }
Esempio n. 4
0
 /**
  * Regenerate all cache files
  * @return void
  */
 function procAdminRecompileCacheFile()
 {
     // rename cache dir
     $temp_cache_dir = './files/cache_' . $_SERVER['REQUEST_TIME'];
     FileHandler::rename('./files/cache', $temp_cache_dir);
     FileHandler::makeDir('./files/cache');
     // remove debug files
     FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php');
     FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php');
     FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php');
     $oModuleModel = getModel('module');
     $module_list = $oModuleModel->getModuleList();
     // call recompileCache for each module
     foreach ($module_list as $module) {
         $oModule = NULL;
         $oModule = getClass($module->module);
         if (method_exists($oModule, 'recompileCache')) {
             $oModule->recompileCache();
         }
     }
     // remove cache
     $truncated = array();
     $oObjectCacheHandler = CacheHandler::getInstance('object');
     $oTemplateCacheHandler = CacheHandler::getInstance('template');
     if ($oObjectCacheHandler->isSupport()) {
         $truncated[] = $oObjectCacheHandler->truncate();
     }
     if ($oTemplateCacheHandler->isSupport()) {
         $truncated[] = $oTemplateCacheHandler->truncate();
     }
     if (count($truncated) && in_array(FALSE, $truncated)) {
         return new Object(-1, 'msg_self_restart_cache_engine');
     }
     // remove cache dir
     $tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/');
     if ($tmp_cache_list) {
         foreach ($tmp_cache_list as $tmp_dir) {
             if ($tmp_dir) {
                 FileHandler::removeDir('./files/' . $tmp_dir);
             }
         }
     }
     // remove duplicate indexes (only for CUBRID)
     $db_type = Context::getDBType();
     if ($db_type == 'cubrid') {
         $db = DB::getInstance();
         $db->deleteDuplicateIndexes();
     }
     // check autoinstall packages
     $oAutoinstallAdminController = getAdminController('autoinstall');
     $oAutoinstallAdminController->checkInstalled();
     $this->setMessage('success_updated');
 }
 function procTranslationAdminDeleteTranslation()
 {
     $module_srl = Context::get('module_srl');
     if (!$module_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     $obj->module_srl = $module_srl;
     $output = executeQuery('translation.deleteProjectsByModule', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     $output = executeQuery('translation.deleteFileByModule', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     $output = executeQuery('translation.deleteContentByModule', $obj);
     if (!$output->toBool()) {
         return $output;
     }
     // delete module folder
     $file_folder = './files/translation_files/' . $module_srl;
     FileHandler::removeDir($file_folder);
     // delete cache folder
     $cache_folder = './files/cache/translation/' . $module_srl;
     FileHandler::removeDir($cache_folder);
     $oModuleController =& getController('module');
     $output = $oModuleController->deleteModule($module_srl);
     if (!$output->toBool()) {
         return $output;
     }
     $this->add('module', 'translation');
     $this->add('page', Context::get('page'));
     $this->setMessage('success_deleted');
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'module_srl', $output->get('module_srl'), 'act', 'dispTranslationAdminContent');
         header('location:' . $returnUrl);
         return;
     }
 }
 /**
  * Delete the attachment of a particular module
  *
  * @param int $module_srl Sequence of module to delete files
  * @return Object
  */
 function deleteModuleFiles($module_srl)
 {
     // Get a full list of attachments
     $args = new stdClass();
     $args->module_srl = $module_srl;
     $columnList = array('file_srl', 'uploaded_filename');
     $output = executeQueryArray('file.getModuleFiles', $args, $columnList);
     if (!$output) {
         return $output;
     }
     $files = $output->data;
     // Remove from the DB
     $args->module_srl = $module_srl;
     $output = executeQuery('file.deleteModuleFiles', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // Remove the file
     FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl));
     FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl));
     // Remove the file list obtained from the 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'];
         }
     }
     // Remove a file directory of the document
     for ($i = 0; $i < count($path); $i++) {
         FileHandler::removeBlankDir($path[$i]);
     }
     return $output;
 }
 /**
  * Migrate data after completing xml file extraction
  * @return void
  */
 function procImporterAdminImport()
 {
     // Variable setting
     $type = Context::get('type');
     $total = Context::get('total');
     $cur = Context::get('cur');
     $key = Context::get('key');
     $user_id = Context::get('user_id');
     $target_module = Context::get('target_module');
     $guestbook_target_module = Context::get('guestbook_target_module');
     $this->unit_count = Context::get('unit_count');
     // Check if an index file exists
     $index_file = './files/cache/importer/' . $key . '/index';
     if (!file_exists($index_file)) {
         return new Object(-1, 'msg_invalid_xml_file');
     }
     switch ($type) {
         case 'ttxml':
             if (!$target_module) {
                 return new Object(-1, 'msg_invalid_request');
             }
             $oModuleModel = getModel('module');
             $columnList = array('module_srl', 'module');
             $target_module_info = $oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList);
             $ttimporter = FileHandler::exists(_XE_PATH_ . 'modules/importer/ttimport.class.php');
             if ($ttimporter) {
                 require_once $ttimporter;
             }
             $oTT = new ttimport();
             $cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module);
             break;
         case 'message':
             $cur = $this->importMessage($key, $cur, $index_file);
             break;
         case 'member':
             $cur = $this->importMember($key, $cur, $index_file);
             break;
         case 'module':
             // Check if the target module exists
             if (!$target_module) {
                 return new Object(-1, 'msg_invalid_request');
             }
             $cur = $this->importModule($key, $cur, $index_file, $target_module);
             break;
     }
     // Notify that all data completely extracted
     $this->add('type', $type);
     $this->add('total', $total);
     $this->add('cur', $cur);
     $this->add('key', $key);
     $this->add('target_module', $target_module);
     // When completing, success message appears and remove the cache files
     if ($total <= $cur) {
         $this->setMessage(sprintf(Context::getLang('msg_import_finished'), $cur, $total));
         FileHandler::removeDir('./files/cache/importer/' . $key);
     } else {
         $this->setMessage(sprintf(Context::getLang('msg_importing'), $total, $cur));
     }
 }
Esempio n. 8
0
 /**
  * Remove directory
  * @param string $path Path to remove
  * @return Object
  */
 function _removeDir_real($path)
 {
     if (substr($path, 0, 2) == "./") {
         $path = substr($path, 2);
     }
     $target_path = FileHandler::getRealPath($path);
     FileHandler::removeDir($target_path);
     return new Object();
 }
Esempio n. 9
0
 /**
  * @brief 지정된 디렉토리 이하 모두 파일을 삭제
  **/
 function removeDir($path)
 {
     $path = FileHandler::getRealPath($path);
     if (!is_dir($path)) {
         return;
     }
     $directory = dir($path);
     while ($entry = $directory->read()) {
         if ($entry != "." && $entry != "..") {
             if (is_dir($path . "/" . $entry)) {
                 FileHandler::removeDir($path . "/" . $entry);
             } else {
                 @unlink($path . "/" . $entry);
             }
         }
     }
     $directory->close();
     @rmdir($path);
 }
Esempio n. 10
0
                 }
                 $fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
                 $uploaded_filename = $fileOutput->get('uploaded_filename');
                 $source_filename = $fileOutput->get('source_filename');
                 $obj->content = str_replace($uploaded_target_path . $source_filename, sprintf('/files/attach/images/%s/%s%s', $this->module_srl, getNumberingPath($document_srl, 3), $uploaded_filename), $obj->content);
             }
             $obj->uploaded_count += $file_count;
         }
     }
     $oDocumentController =& getController('document');
     $output = $oDocumentController->updateDocument($oDocument, $obj);
     if (!$output->toBool()) {
         $content = getXmlRpcFailure(1, $output->getMessage());
     } else {
         $content = getXmlRpcResponse(true);
         FileHandler::removeDir($tmp_uploaded_path);
     }
     printContent($content);
     break;
     // Delete the post
 // Delete the post
 case 'blogger.deletePost':
     $tmp_val = $params[0]->value->string->body;
     $tmp_arr = explode('/', $tmp_val);
     $document_srl = array_pop($tmp_arr);
     // Get a document
     $oDocumentModel =& getModel('document');
     $oDocument = $oDocumentModel->getDocument($document_srl);
     // If the document exists
     if (!$oDocument->isExists()) {
         $content = getXmlRpcFailure(1, 'not exists');
 function initTextyle($site_srl)
 {
     $oCounterController =& getController('counter');
     $oDocumentController =& getController('document');
     $oCommentController =& getController('comment');
     $oTagController =& getController('tag');
     $oAddonController =& getController('addon');
     $oEditorController =& getController('editor');
     $oTrackbackController =& getController('trackback');
     $oModuleModel =& getModel('module');
     $oTextyleModel =& getModel('textyle');
     $oMemberModel =& getModel('member');
     $site_info = $oModuleModel->getSiteInfo($site_srl);
     $module_srl = $site_info->index_module_srl;
     $args->site_srl = $site_srl;
     $oTextyle = new TextyleInfo($module_srl);
     if ($oTextyle->module_srl != $module_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oCounterController->deleteSiteCounterLogs($args->site_srl);
     $oAddonController->removeAddonConfig($args->site_srl);
     $args->module_srl = $module_srl;
     $output = executeQuery('textyle.deleteTextyleFavorites', $args);
     $output = executeQuery('textyle.deleteTextyleTags', $args);
     $output = executeQuery('textyle.deleteTextyleVoteLogs', $args);
     $output = executeQuery('textyle.deleteTextyleMemos', $args);
     $output = executeQuery('textyle.deleteTextyleReferer', $args);
     $output = executeQuery('textyle.deleteTextyleApis', $args);
     $output = executeQuery('textyle.deleteTextyleGuestbook', $args);
     $output = executeQuery('textyle.deleteTextyleSupporters', $args);
     $output = executeQuery('textyle.deletePublishLogs', $args);
     FileHandler::removeFile(sprintf("./files/cache/textyle/textyle_deny/%d.php", $module_srl));
     FileHandler::removeDir($oTextyleModel->getTextylePath($module_srl));
     // delete document comment tag
     $output = $oDocumentController->triggerDeleteModuleDocuments($args);
     $output = $oCommentController->triggerDeleteModuleComments($args);
     $output = $oTagController->triggerDeleteModuleTags($args);
     $output = $oTrackbackController->triggerDeleteModuleTrackbacks($args);
     $args->module_srl = $args->module_srl * -1;
     $output = $oDocumentController->triggerDeleteModuleDocuments($args);
     $output = $oCommentController->triggerDeleteModuleComments($args);
     $output = $oTagController->triggerDeleteModuleTags($args);
     $args->module_srl = $args->module_srl * -1;
     // set category
     $obj->module_srl = $module_srl;
     $obj->title = Context::getLang('init_category_title');
     $oDocumentController->insertCategory($obj);
     FileHandler::copyDir($this->module_path . 'skins/' . $this->skin, $oTextyleModel->getTextylePath($module_srl));
     $langType = Context::getLangType();
     $file = sprintf('%ssample/%s.html', $this->module_path, $langType);
     if (!file_exists(FileHandler::getRealPath($file))) {
         $file = sprintf('%ssample/ko.html', $this->module_path);
     }
     $member_info = $oMemberModel->getMemberInfoByEmailAddress($oTextyle->getUserId());
     $doc->module_srl = $module_srl;
     $doc->title = Context::getLang('sample_title');
     $doc->tags = Context::getLang('sample_tags');
     $doc->content = FileHandler::readFile($file);
     $doc->member_srl = $member_info->member_srl;
     $doc->user_id = $member_info->user_id;
     $doc->user_name = $member_info->user_name;
     $doc->nick_name = $member_info->nick_name;
     $doc->email_address = $member_info->email_address;
     $doc->homepage = $member_info->homepage;
     $output = $oDocumentController->insertDocument($doc, true);
     return new Object(1, 'success_textyle_init');
 }
Esempio n. 12
0
 /**
  * export user layout
  * @return void
  */
 function procLayoutAdminUserLayoutExport()
 {
     $layout_srl = Context::get('layout_srl');
     if (!$layout_srl) {
         return new Object('-1', 'msg_invalid_request');
     }
     require_once _XE_PATH_ . 'libs/tar.class.php';
     $oLayoutModel = getModel('layout');
     // Copy files to temp path
     $file_path = $oLayoutModel->getUserLayoutPath($layout_srl);
     $target_path = $oLayoutModel->getUserLayoutPath(0);
     FileHandler::copyDir($file_path, $target_path);
     // replace path and ini config
     $ini_config = $oLayoutModel->getUserLayoutIniConfig(0);
     $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl);
     unset($file_list[2]);
     foreach ($file_list as $file) {
         if (strncasecmp('images', $file, 6) === 0) {
             continue;
         }
         // replace path
         $file = $target_path . $file;
         $content = FileHandler::readFile($file);
         $pattern = '/(http:\\/\\/[^ ]+)?(\\.\\/)?' . str_replace('/', '\\/', str_replace('./', '', $file_path)) . '/';
         if (basename($file) == 'faceoff.css' || basename($file) == 'layout.css') {
             $content = preg_replace($pattern, '../', $content);
         } else {
             $content = preg_replace($pattern, './', $content);
         }
         // replace ini config
         foreach ($ini_config as $key => $value) {
             $content = str_replace('{$layout_info->faceoff_ini_config[\'' . $key . '\']}', $value, $content);
         }
         FileHandler::writeFile($file, $content);
     }
     // make info.xml
     $info_file = $target_path . 'conf/info.xml';
     FileHandler::copyFile('./modules/layout/faceoff/conf/info.xml', $info_file);
     $content = FileHandler::readFile($info_file);
     $content = str_replace('type="faceoff"', '', $content);
     FileHandler::writeFile($info_file, $content);
     $file_list[] = 'conf/info.xml';
     // make css file
     $css_file = $target_path . 'css/layout.css';
     FileHandler::copyFile('./modules/layout/faceoff/css/layout.css', $css_file);
     $content = FileHandler::readFile('./modules/layout/tpl/css/widget.css');
     FileHandler::writeFile($css_file, "\n" . $content, 'a');
     $content = FileHandler::readFile($target_path . 'faceoff.css');
     FileHandler::writeFile($css_file, "\n" . $content, 'a');
     $content = FileHandler::readFile($target_path . 'layout.css');
     FileHandler::writeFile($css_file, "\n" . $content, 'a');
     // css load
     $content = FileHandler::readFile($target_path . 'layout.html');
     $content = "<load target=\"css/layout.css\" />\n" . $content;
     FileHandler::writeFile($target_path . 'layout.html', $content);
     unset($file_list[3]);
     unset($file_list[1]);
     $file_list[] = 'css/layout.css';
     // Compress the files
     $tar = new tar();
     $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath(0));
     chdir($user_layout_path);
     foreach ($file_list as $key => $file) {
         $tar->addFile($file);
     }
     $stream = $tar->toTarStream();
     $filename = 'faceoff_' . date('YmdHis') . '.tar';
     header("Cache-Control: ");
     header("Pragma: ");
     header("Content-Type: application/x-compressed");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     //            header("Content-Length: " .strlen($stream)); ?? why??
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     header("Content-Transfer-Encoding: binary\n");
     echo $stream;
     // Close Context and then exit
     Context::close();
     // delete temp path
     FileHandler::removeDir($target_path);
     exit;
 }
 function deleteLayout($layout_srl)
 {
     $oLayoutModel =& getModel('layout');
     $path = $oLayoutModel->getUserLayoutPath($layout_srl);
     FileHandler::removeDir($path);
     $layout_file = $oLayoutModel->getUserLayoutHtml($layout_srl);
     if (file_exists($layout_file)) {
         FileHandler::removeFile($layout_file);
     }
     // 레이아웃 삭제
     $args->layout_srl = $layout_srl;
     $output = executeQuery("layout.deleteLayout", $args);
     if (!$output->toBool()) {
         return $output;
     }
     return new Object(0, 'success_deleted');
 }
Esempio n. 14
0
 /**
  * Install module.
  *
  * Download file and install module
  *
  * @return Object
  */
 function install()
 {
     $this->_download();
     $file_list = $this->_unPack();
     $output = $this->_copyDir($file_list);
     if (!$output->toBool()) {
         FileHandler::removeDir($this->temp_dir);
         return $output;
     }
     $this->installModule();
     FileHandler::removeDir($this->temp_dir);
     return new Object();
 }
Esempio n. 15
0
 /**
  * Move the doc into the trash
  * @param object $obj
  * @return object
  */
 function moveDocumentToTrash($obj)
 {
     $logged_info = Context::get('logged_info');
     $trash_args = new stdClass();
     // Get trash_srl if a given trash_srl doesn't exist
     if (!$obj->trash_srl) {
         $trash_args->trash_srl = getNextSequence();
     } else {
         $trash_args->trash_srl = $obj->trash_srl;
     }
     // Get its module_srl which the document belongs to
     $oDocumentModel = getModel('document');
     $oDocument = $oDocumentModel->getDocument($obj->document_srl);
     $oMemberModel = getModel('member');
     $member_info = $oMemberModel->getMemberInfoByMemberSrl($oDocument->get('member_srl'));
     if ($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y') {
         return new Object(-1, 'msg_admin_document_no_move_to_trash');
     }
     $trash_args->module_srl = $oDocument->get('module_srl');
     $obj->module_srl = $oDocument->get('module_srl');
     // Cannot throw data from the trash to the trash
     if ($trash_args->module_srl == 0) {
         return false;
     }
     // Data setting
     $trash_args->document_srl = $obj->document_srl;
     $trash_args->description = $obj->description;
     // Insert member's information only if the member is logged-in and not manually registered.
     if (Context::get('is_logged')) {
         $logged_info = Context::get('logged_info');
         $trash_args->member_srl = $logged_info->member_srl;
         // user_id, user_name and nick_name already encoded
         $trash_args->user_id = htmlspecialchars_decode($logged_info->user_id);
         $trash_args->user_name = htmlspecialchars_decode($logged_info->user_name);
         $trash_args->nick_name = htmlspecialchars_decode($logged_info->nick_name);
     }
     // Date setting for updating documents
     $document_args = new stdClass();
     $document_args->module_srl = 0;
     $document_args->document_srl = $obj->document_srl;
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     /*$output = executeQuery('document.insertTrash', $trash_args);
       if (!$output->toBool()) {
       $oDB->rollback();
       return $output;
       }*/
     // new trash module
     require_once _XE_PATH_ . 'modules/trash/model/TrashVO.php';
     $oTrashVO = new TrashVO();
     $oTrashVO->setTrashSrl(getNextSequence());
     $oTrashVO->setTitle($oDocument->variables['title']);
     $oTrashVO->setOriginModule('document');
     $oTrashVO->setSerializedObject(serialize($oDocument->variables));
     $oTrashVO->setDescription($obj->description);
     $oTrashAdminController = getAdminController('trash');
     $output = $oTrashAdminController->insertTrash($oTrashVO);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $output = executeQuery('document.deleteDocument', $trash_args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     /*$output = executeQuery('document.updateDocument', $document_args);
       if (!$output->toBool()) {
       $oDB->rollback();
       return $output;
       }*/
     // update category
     if ($oDocument->get('category_srl')) {
         $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
     }
     // remove thumbnails
     FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
     // Set the attachment to be invalid state
     if ($oDocument->hasUploadedFiles()) {
         $args = new stdClass();
         $args->upload_target_srl = $oDocument->document_srl;
         $args->isvalid = 'N';
         executeQuery('file.updateFileValid', $args);
     }
     // Call a trigger (after)
     ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
     // commit
     $oDB->commit();
     // Clear cache
     Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl);
     return $output;
 }
 /**
  * Clean download file
  *
  * @param object $obj
  * @return void
  */
 function _cleanDownloaded($obj)
 {
     FileHandler::removeDir($obj->download_path);
 }
 function procTranslationDeleteProject()
 {
     $obj = Context::getRequestVars();
     if ($obj->translation_project_srl) {
         $output = executeQuery('translation.deleteProjects', $obj);
         if (!$output->toBool()) {
             return $output;
         }
         $output = executeQuery('translation.deleteFileByProject', $obj);
         if (!$output->toBool()) {
             return $output;
         }
         $output = executeQuery('translation.deleteContentByProject', $obj);
         if (!$output->toBool()) {
             return $output;
         }
         // delete project folder
         $file_folder = './files/translation_files/' . $this->module_info->module_srl . '/' . $obj->translation_project_srl;
         FileHandler::removeDir($file_folder);
         // delete cache folder
         $cache_folder = './files/cache/translation/' . $this->module_info->module_srl . '/' . $obj->translation_project_srl;
         FileHandler::removeDir($cache_folder);
     }
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', $this->module_info->mid, 'act', 'dispTranslationProjectList', 'scope', $obj->scope);
         header('location:' . $returnUrl);
         return;
     }
 }
Esempio n. 18
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::removeDir($path);
         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::removeDir($path);
             FileHandler::writeFile($path . $mainVersion, '1');
             unset($_SESSION['enviroment_gather']);
         }
     }
 }
Esempio n. 19
0
        public function procShopToolUserSkinImport(){
            if(!$this->module_srl) exit();

            // check upload
            if(!Context::isUploaded()) exit();
            $file = Context::get('file');
            if(!is_uploaded_file($file['tmp_name'])) exit();
            if(!preg_match('/\.(tar)$/i', $file['name'])) exit();

            $oShopModel = $this->model;
            $skin_path = FileHandler::getRealPath($oShopModel->getShopPath($this->module_srl));

            $tar_file = $skin_path . 'shop_skin.tar';

            FileHandler::removeDir($skin_path);
            FileHandler::makeDir($skin_path);

            if(!move_uploaded_file($file['tmp_name'], $tar_file)) exit();

            require_once(_XE_PATH_.'libs/tar.class.php');

            $tar = new tar();
            $tar->openTAR($tar_file);

            if(!$tar->getFile('shop.html')) return;

            $replace_path = getNumberingPath($this->module_srl,3);
            foreach($tar->files as $key => $info) {
                FileHandler::writeFile($skin_path . $info['name'],str_replace('__SHOP_SKIN_PATH__',$replace_path,$info['file']));
            }

            FileHandler::removeFile($tar_file);
        }
 function procGgmailingAdminMemberInsert()
 {
     // 기본 정보를 받음
     $args = Context::getRequestVars();
     @mkdir('files/ggmailing/');
     @chmod('files/ggmailing/', 0755);
     @mkdir('files/ggmailing/uploads/');
     @chmod('files/ggmailing/uploads/', 0755);
     $target_path = 'files/ggmailing/uploads/';
     // 파일이 없으면 되돌려 보냄
     if (!$_FILES['uploadedfile']['tmp_name']) {
         $returnUrl = getNotEncodedUrl('', 'module', 'admin', 'act', 'dispGgmailingAdminInsertmembers');
         //$this->setRedirectUrl($returnUrl);
         header("Location:" . $returnUrl);
         return;
     }
     //파일 업데이트시 기존의 파일을 싹 날림
     FileHandler::removeDir('files/ggmailing/uploads/tmp/');
     @mkdir($target_path . 'tmp/');
     $file_tmp_name = $_FILES['uploadedfile']['tmp_name'];
     $file_name = basename($_FILES['uploadedfile']['name']);
     $file_name = sha1($file_name) . ".xls";
     $file_path = $target_path . 'tmp/' . $file_name;
     @move_uploaded_file($file_tmp_name, $file_path);
     @chmod($file_path, 0755);
     /** PHPExcel_IOFactory */
     include 'modules/ggmailing/classes/PHPExcel/IOFactory.php';
     $inputFileName = $file_path;
     //echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
     $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
     $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     //엑셀파일 행렬 값을 배열화
     //회원가입프로세스
     for ($i = 1; $sheetData[$i]; $i++) {
         $args->ggmailing_nickname = str_replace(',', '.', $sheetData[$i][A]);
         $args->ggmailing_email = str_replace(',', '.', $sheetData[$i][B]);
         $args->ggmailing_group = str_replace(',', '.', $sheetData[$i][C]);
         // remove whitespace
         $checkInfos = array('ggmailing_nickname', 'ggmailing_email', 'ggmailing_group');
         $replaceStr = array("\r\n", "\r", "\n", " ", "\t", "­");
         foreach ($checkInfos as $val) {
             if (isset($args->{$val})) {
                 $args->{$val} = str_replace($replaceStr, '', $args->{$val});
             }
         }
         //멤버추가
         $output = executeQueryArray('ggmailing.getGgmailingAdminMember', $args);
         if ($output->data) {
             foreach ($ggoutput->data[0] as $key => $val) {
                 if ($val->ggmailing_group != $args->ggmailing_group || $val->ggmailing_email != $args->ggmailing_email && $val->ggmailing_group == $args->ggmailing_group) {
                     executeQuery('ggmailing.insertGgmailingAdminMember', $args);
                 }
             }
             //end foreach
         } else {
             executeQuery('ggmailing.insertGgmailingAdminMember', $args);
         }
     }
     //end for
     // URL 재지정
     $returnUrl = getNotEncodedUrl('', 'module', 'admin', 'act', 'dispGgmailingAdminInsertmembers');
     //$this->setRedirectUrl($returnUrl);
     header("Location:" . $returnUrl);
 }
Esempio n. 21
0
                     $replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl);
                 } else {
                     $replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename');
                 }
                 $obj->content = str_replace($mediaUrlPath . $temp_filename, $replace_url, $obj->content);
             }
             $obj->uploaded_count += $file_count;
         }
     }
     $oDocumentController = getController('document');
     $output = $oDocumentController->updateDocument($oDocument, $obj, TRUE);
     if (!$output->toBool()) {
         $content = getXmlRpcFailure(1, $output->getMessage());
     } else {
         $content = getXmlRpcResponse(true);
         FileHandler::removeDir($mediaAbsPath);
     }
     printContent($content);
     break;
     // Delete the post
 // Delete the post
 case 'blogger.deletePost':
     $tmp_val = (string) $params[1]->value->string;
     $tmp_arr = explode('/', $tmp_val);
     $document_srl = array_pop($tmp_arr);
     // Get a document
     $oDocumentModel = getModel('document');
     $oDocument = $oDocumentModel->getDocument($document_srl);
     // If the document exists
     if (!$oDocument->isExists()) {
         $content = getXmlRpcFailure(1, 'not exists');
 function procTextyleToolUserSkinImport()
 {
     if (!$this->module_srl) {
         exit;
     }
     // check upload
     if (!Context::isUploaded()) {
         exit;
     }
     $file = Context::get('file');
     if (!is_uploaded_file($file['tmp_name'])) {
         exit;
     }
     if (!preg_match('/\\.(tar)$/i', $file['name'])) {
         exit;
     }
     $oTextyleModel =& getModel('textyle');
     $skin_path = FileHandler::getRealPath($oTextyleModel->getTextylePath($this->module_srl));
     $tar_file = $skin_path . 'textyle_skin.tar';
     FileHandler::removeDir($skin_path);
     FileHandler::makeDir($skin_path);
     if (!move_uploaded_file($file['tmp_name'], $tar_file)) {
         exit;
     }
     require_once _XE_PATH_ . 'libs/tar.class.php';
     $tar = new tar();
     $tar->openTAR($tar_file);
     if (!$tar->getFile('textyle.html')) {
         return;
     }
     $replace_path = getNumberingPath($this->module_srl, 3);
     foreach ($tar->files as $key => $info) {
         FileHandler::writeFile($skin_path . $info['name'], str_replace('__TEXTYLE_SKIN_PATH__', $replace_path, $info['file']));
     }
     FileHandler::removeFile($tar_file);
 }
Esempio n. 23
0
 /**
  * @brief Apply member points saved by file to units of 5,000 people
  */
 function procPointAdminApplyPoint()
 {
     $position = (int) Context::get('position');
     $total = (int) Context::get('total');
     if (!file_exists('./files/cache/pointRecal.txt')) {
         return new Object(-1, 'msg_invalid_request');
     }
     $idx = 0;
     $f = fopen("./files/cache/pointRecal.txt", "r");
     while (!feof($f)) {
         $str = trim(fgets($f, 1024));
         $idx++;
         if ($idx > $position) {
             list($member_srl, $point) = explode(',', $str);
             $args = new stdClass();
             $args->member_srl = $member_srl;
             $args->point = $point;
             $output = executeQuery('point.insertPoint', $args);
             if ($idx % 5000 == 0) {
                 break;
             }
         }
     }
     if (feof($f)) {
         FileHandler::removeFile('./files/cache/pointRecal.txt');
         $idx = $total;
         FileHandler::rename('./files/member_extra_info/point', './files/member_extra_info/point.old');
         FileHandler::removeDir('./files/member_extra_info/point.old');
     }
     fclose($f);
     $this->add('total', $total);
     $this->add('position', $idx);
     $this->setMessage(sprintf(Context::getLang('point_recal_message'), $idx, $total));
 }
Esempio n. 24
0
 /**
  * Delete menu
  * Delete menu_item and xml cache files
  * @return Object
  */
 function deleteMenu($menu_srl)
 {
     $oDB = DB::getInstance();
     $oDB->begin();
     $args = new stdClass();
     $args->menu_srl = $menu_srl;
     $oMenuAdminModel = getAdminModel('menu');
     $menuInfo = $oMenuAdminModel->getMenu($args->menu_srl);
     // Delete modules
     $output = executeQueryArray('menu.getMenuItems', $args);
     if (!$output->toBool()) {
         return $output;
     }
     $oModuleController = getController('module');
     $oModuleModel = getModel('module');
     foreach ($output->data as $itemInfo) {
         if ($itemInfo->is_shortcut != 'Y' && strncasecmp('http', $itemInfo->url, 4) !== 0) {
             $moduleInfo = $oModuleModel->getModuleInfoByMid($itemInfo->url, $menuInfo->site_srl);
             if ($moduleInfo->module_srl) {
                 $output = $oModuleController->onlyDeleteModule($moduleInfo->module_srl);
                 if (!$output->toBool()) {
                     $oDB->rollback();
                     return $output;
                 }
             }
         }
     }
     // Delete menu items
     $output = executeQuery("menu.deleteMenuItems", $args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // Delete the menu
     $output = executeQuery("menu.deleteMenu", $args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     // Delete cache files
     $cache_list = FileHandler::readDir("./files/cache/menu", "", false, true);
     if (count($cache_list)) {
         foreach ($cache_list as $cache_file) {
             $pos = strpos($cache_file, $menu_srl . '.');
             if ($pos > 0) {
                 FileHandler::removeFile($cache_file);
             }
         }
     }
     // Delete images of menu buttons
     $image_path = sprintf('./files/attach/menu_button/%s', $menu_srl);
     FileHandler::removeDir($image_path);
     $oDB->commit();
     return new Object(0, 'success_deleted');
 }
Esempio n. 25
0
 /**
  * delete plugin info. (it will be deleted in the future)
  */
 function procEpayAdminDeletePlugin()
 {
     $plugin_srl = Context::get('plugin_srl');
     if (!$plugin_srl) {
         return new Object(-1, 'msg_invalid_request');
     }
     $args->plugin_srl = $plugin_srl;
     $output = executeQuery('epay.deletePlugin', $args);
     if (!$output->toBool()) {
         return $output;
     }
     FileHandler::removeDir(sprintf(_XE_PATH_ . "files/epay/%s", $plugin_srl));
     $this->setMessage('success_deleted');
     if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) {
         $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', Context::get('module'), 'act', 'dispEpayAdminPluginList', 'module_srl', Context::get('module_srl'));
         $this->setRedirectUrl($returnUrl);
         return;
     }
 }
Esempio n. 26
0
 /**
  * @brief 캐시 파일 재생성
  **/
 function recompileCache()
 {
     // 모듈 정보 캐시 파일 모두 삭제
     FileHandler::removeFilesInDir("./files/cache/module_info");
     // 트리거 정보가 있는 파일 모두 삭제
     FileHandler::removeFilesInDir("./files/cache/triggers");
     // DB캐시 파일을 모두 삭제
     FileHandler::removeFilesInDir("./files/cache/db");
     // 기타 캐시 삭제
     FileHandler::removeDir("./files/cache/tmp");
 }
 /**
  * Delete product images
  * @param Product $product
  * @return bool
  * @throws ShopException
  */
 public function deleteProductImages(Product &$product)
 {
     if (!$product->product_srl) {
         throw new ShopException("Invalid arguments! Please provide product_srl for delete attributes.");
     }
     $args = new stdClass();
     $args->product_srl = $product->product_srl;
     $output = executeQuery('shop.deleteProductImages', $args);
     if (!$output->toBool()) {
         throw new ShopException($output->getMessage(), $output->getError());
     }
     $path = sprintf('./files/attach/images/shop/%d/product-images/%d/', $product->module_srl, $product->product_srl);
     FileHandler::removeDir($path);
     return TRUE;
 }
Esempio n. 28
0
 /**
  * Save item
  * @return void
  */
 function saveItems()
 {
     FileHandler::removeDir($this->cache_path . $this->key);
     $this->index = 0;
     while (!$this->isFinished()) {
         $this->getItem();
     }
 }
Esempio n. 29
0
 /**
  * Move the doc into the trash
  * @param object $obj
  * @return object
  */
 function moveDocumentToTrash($obj)
 {
     // Get trash_srl if a given trash_srl doesn't exist
     if (!$obj->trash_srl) {
         $trash_args->trash_srl = getNextSequence();
     } else {
         $trash_args->trash_srl = $obj->trash_srl;
     }
     // Get its module_srl which the document belongs to
     $oDocumentModel =& getModel('document');
     $oDocument = $oDocumentModel->getDocument($obj->document_srl);
     $trash_args->module_srl = $oDocument->get('module_srl');
     $obj->module_srl = $oDocument->get('module_srl');
     // Cannot throw data from the trash to the trash
     if ($trash_args->module_srl == 0) {
         return false;
     }
     // Data setting
     $trash_args->document_srl = $obj->document_srl;
     $trash_args->description = $obj->description;
     // Insert member's information only if the member is logged-in and not manually registered.
     if (Context::get('is_logged') && !$manual_inserted) {
         $logged_info = Context::get('logged_info');
         $trash_args->member_srl = $logged_info->member_srl;
         $trash_args->user_id = $logged_info->user_id;
         $trash_args->user_name = $logged_info->user_name;
         $trash_args->nick_name = $logged_info->nick_name;
     }
     // Date setting for updating documents
     $document_args->module_srl = 0;
     $document_args->document_srl = $obj->document_srl;
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     /*$output = executeQuery('document.insertTrash', $trash_args);
     		if (!$output->toBool()) {
     			$oDB->rollback();
     			return $output;
     		}*/
     // new trash module
     require_once _XE_PATH_ . 'modules/trash/model/TrashVO.php';
     $oTrashVO = new TrashVO();
     $oTrashVO->setTrashSrl(getNextSequence());
     $oTrashVO->setTitle($oDocument->variables['title']);
     $oTrashVO->setOriginModule('document');
     $oTrashVO->setSerializedObject(serialize($oDocument->variables));
     $oTrashVO->setDescription($obj->description);
     $oTrashAdminController =& getAdminController('trash');
     $output = $oTrashAdminController->insertTrash($oTrashVO);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $output = executeQuery('document.deleteDocument', $trash_args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     /*$output = executeQuery('document.updateDocument', $document_args);
     		if (!$output->toBool()) {
     			$oDB->rollback();
     			return $output;
     		}*/
     // update category
     if ($oDocument->get('category_srl')) {
         $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
     }
     // remove thumbnails
     FileHandler::removeDir(sprintf('files/cache/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
     // Set the attachment to be invalid state
     if ($oDocument->hasUploadedFiles()) {
         $args->upload_target_srl = $oDocument->document_srl;
         $args->isvalid = 'N';
         executeQuery('file.updateFileValid', $args);
     }
     // Call a trigger (after)
     if ($output->toBool()) {
         $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // commit
     $oDB->commit();
     // Clear cache
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $oCacheHandler->invalidateGroupKey('documentList');
     }
     return $output;
 }
Esempio n. 30
0
 /**
  * @brief 문서 삭제
  **/
 function deleteDocument($document_srl, $is_admin = false)
 {
     // trigger 호출 (before)
     $trigger_obj->document_srl = $document_srl;
     $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
     if (!$output->toBool()) {
         return $output;
     }
     // begin transaction
     $oDB =& DB::getInstance();
     $oDB->begin();
     // document의 model 객체 생성
     $oDocumentModel =& getModel('document');
     // 기존 문서가 있는지 확인
     $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
     if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) {
         return new Object(-1, 'msg_invalid_document');
     }
     // 권한이 있는지 확인
     if (!$oDocument->isGranted()) {
         return new Object(-1, 'msg_not_permitted');
     }
     // 글 삭제
     $args->document_srl = $document_srl;
     $output = executeQuery('document.deleteDocument', $args);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $this->deleteDocumentAliasByDocument($document_srl);
     $this->deleteDocumentHistory(null, $document_srl, null);
     // 카테고리가 있으면 카테고리 정보 변경
     if ($oDocument->get('category_srl')) {
         $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
     }
     // 신고 삭제
     executeQuery('document.deleteDeclared', $args);
     // 확장 변수 삭제
     $this->deleteDocumentExtraVars($oDocument->get('module_srl'), $oDocument->document_srl);
     // trigger 호출 (after)
     if ($output->toBool()) {
         $trigger_obj = $oDocument->getObjectVars();
         $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj);
         if (!$trigger_output->toBool()) {
             $oDB->rollback();
             return $trigger_output;
         }
     }
     // 썸네일 파일 제거
     FileHandler::removeDir(sprintf('files/cache/thumbnails/%s', getNumberingPath($document_srl, 3)));
     // commit
     $oDB->commit();
     return $output;
 }