Example #1
0
 /**
  * Upload attachments in the editor
  *
  * Determine the upload target srl from editor_sequence and uploadTargetSrl variables.
  * Create and return the UploadTargetSrl if not exists so that UI can use the value
  * for sync.
  *
  * @return void
  */
 function procFileUpload()
 {
     Context::setRequestMethod('JSON');
     $file_info = $_FILES['Filedata'];
     // An error appears if not a normally uploaded file
     if (!is_uploaded_file($file_info['tmp_name'])) {
         exit;
     }
     // Basic variables setting
     $oFileModel = getModel('file');
     $editor_sequence = Context::get('editor_sequence');
     $upload_target_srl = intval(Context::get('uploadTargetSrl'));
     if (!$upload_target_srl) {
         $upload_target_srl = intval(Context::get('upload_target_srl'));
     }
     $module_srl = $this->module_srl;
     // Exit a session if there is neither upload permission nor information
     if (!$_SESSION['upload_info'][$editor_sequence]->enabled) {
         exit;
     }
     // Extract from session information if upload_target_srl is not specified
     if (!$upload_target_srl) {
         $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
     }
     // Create if upload_target_srl is not defined in the session information
     if (!$upload_target_srl) {
         $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
     }
     $output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
     Context::setResponseMethod('JSON');
     if ($output->error != '0') {
         $this->stop($output->message);
     }
 }
Example #2
0
 /**
  * @brief Page information
  */
 function dispPageIndex(&$oModule)
 {
     $page_content = Context::get('page_content');
     $oWidgetController = getController('widget');
     $requestMethod = Context::getRequestMethod();
     Context::setResponseMethod('HTML');
     $oWidgetController->triggerWidgetCompile($page_content);
     Context::setResponseMethod($requestMethod);
     $oModule->add('page_content', $page_content);
 }
Example #3
0
 public function testRequsetResponseMethod()
 {
     $this->assertEquals(Context::getRequestMethod(), 'GET');
     $_SERVER['REQUEST_METHOD'] = 'POST';
     Context::setRequestMethod();
     $this->assertEquals(Context::getRequestMethod(), 'POST');
     $GLOBALS['HTTP_RAW_POST_DATA'] = 'abcde';
     Context::setRequestMethod();
     $this->assertEquals(Context::getRequestMethod(), 'XMLRPC');
     $_SERVER['CONTENT_TYPE'] = 'application/json';
     Context::setRequestMethod();
     $this->assertEquals(Context::getRequestMethod(), 'JSON');
     Context::setRequestMethod('POST');
     $this->assertEquals(Context::getRequestMethod(), 'POST');
     $this->assertEquals(Context::getResponseMethod(), 'HTML');
     Context::setRequestMethod('JSON');
     $this->assertEquals(Context::getResponseMethod(), 'JSON');
     Context::setResponseMethod('WRONG_TYPE');
     $this->assertEquals(Context::getResponseMethod(), 'HTML');
     Context::setResponseMethod('XMLRPC');
     $this->assertEquals(Context::getResponseMethod(), 'XMLRPC');
     Context::setResponseMethod('HTML');
     $this->assertEquals(Context::getResponseMethod(), 'HTML');
 }
Example #4
0
 function dispLivexeMyFeedsOPML()
 {
     if (Context::get('is_logged')) {
         $logged_info = Context::get('logged_info');
         Context::set('myname', $logged_info->nick_name);
         $rss_args->module_srl = $this->module_srl;
         $rss_args->member_srl = $logged_info->member_srl;
         $output = executeQueryArray('livexe.getRssListWithoutNav', $rss_args);
         Context::set('my_feed_list', $output->data);
     } else {
         return $this->dispLivexeContent();
     }
     $this->setTemplatePath($this->module_path . 'tpl/');
     $this->setTemplateFile('opml');
     Context::setResponseMethod("XMLRPC");
 }
Example #5
0
 /**
  * Feed output.
  * When trying to directly print out the RSS, the results variable can be directly specified through $oRssView->rss($document_list)
  *
  * @param Object $document_list Document list 
  * @param string $rss_title Rss title
  * @param string $add_description Add description
  */
 function rss($document_list = null, $rss_title = null, $add_description = null)
 {
     $oDocumentModel = getModel('document');
     $oModuleModel = getModel('module');
     $oModuleController = getController('module');
     // Get the content and information for the current requested module if the method is not called from another module
     if (!$document_list) {
         $site_module_info = Context::get('site_module_info');
         $site_srl = $site_module_info->site_srl;
         $mid = Context::get('mid');
         // The target module id, if absent, then all
         $start_date = (int) Context::get('start_date');
         $end_date = (int) Context::get('end_date');
         $module_srls = array();
         $rss_config = array();
         $total_config = '';
         $total_config = $oModuleModel->getModuleConfig('rss');
         // If one is specified, extract only for this mid
         if ($mid) {
             $module_srl = $this->module_info->module_srl;
             $config = $oModuleModel->getModulePartConfig('rss', $module_srl);
             if ($config->open_rss && $config->open_rss != 'N') {
                 $module_srls[] = $module_srl;
                 $open_rss_config[$module_srl] = $config->open_rss;
             }
             // If mid is not selected, then get all
         } else {
             if ($total_config->use_total_feed != 'N') {
                 $rss_config = $oModuleModel->getModulePartConfigs('rss', $site_srl);
                 if ($rss_config) {
                     foreach ($rss_config as $module_srl => $config) {
                         if ($config && $config->open_rss != 'N' && $config->open_total_feed != 'T_N') {
                             $module_srls[] = $module_srl;
                             $open_rss_config[$module_srl] = $config->open_rss;
                         }
                     }
                 }
             }
         }
         if (!count($module_srls) && !$add_description) {
             return $this->dispError();
         }
         $info = new stdClass();
         $args = new stdClass();
         if ($module_srls) {
             $args->module_srl = implode(',', $module_srls);
             //$module_list = $oModuleModel->getMidList($args);	//perhaps module_list varialbles not use
             $args->search_target = 'is_secret';
             $args->search_keyword = 'N';
             $args->page = (int) Context::get('page');
             $args->list_count = 15;
             if ($total_config->feed_document_count) {
                 $args->list_count = $total_config->feed_document_count;
             }
             if (!$args->page || $args->page < 1) {
                 $args->page = 1;
             }
             if ($start_date || $start_date != 0) {
                 $args->start_date = $start_date;
             }
             if ($end_date || $end_date != 0) {
                 $args->end_date = $end_date;
             }
             if ($start_date == 0) {
                 unset($start_date);
             }
             if ($end_date == 0) {
                 unset($end_date);
             }
             $args->sort_index = 'list_order';
             $args->order_type = 'asc';
             $output = $oDocumentModel->getDocumentList($args);
             $document_list = $output->data;
             // Extract the feed title and information with Context::getBrowserTitle
             if ($mid) {
                 $info->title = Context::getBrowserTitle();
                 $oModuleController->replaceDefinedLangCode($info->title);
                 $info->title = str_replace('\'', '&apos;', $info->title);
                 if ($config->feed_description) {
                     $info->description = str_replace('\'', '&apos;', htmlspecialchars($config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                 } else {
                     $info->description = str_replace('\'', '&apos;', htmlspecialchars($this->module_info->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                 }
                 $info->link = getUrl('', 'mid', $mid);
                 $info->feed_copyright = str_replace('\'', '&apos;', htmlspecialchars($feed_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                 if (!$info->feed_copyright) {
                     $info->feed_copyright = str_replace('\'', '&apos;', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                 }
             }
         }
     }
     if (!$info->title) {
         if ($rss_title) {
             $info->title = $rss_title;
         } else {
             if ($total_config->feed_title) {
                 $info->title = $total_config->feed_title;
             } else {
                 $site_module_info = Context::get('site_module_info');
                 $info->title = $site_module_info->browser_title;
             }
         }
         $oModuleController->replaceDefinedLangCode($info->title);
         $info->title = str_replace('\'', '&apos;', htmlspecialchars($info->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
         $info->description = str_replace('\'', '&apos;', htmlspecialchars($total_config->feed_description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
         $info->link = Context::getRequestUri();
         $info->feed_copyright = str_replace('\'', '&apos;', htmlspecialchars($total_config->feed_copyright, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
     }
     if ($add_description) {
         $info->description .= "\r\n" . $add_description;
     }
     if ($total_config->image) {
         $info->image = Context::getRequestUri() . str_replace('\'', '&apos;', htmlspecialchars($total_config->image, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
     }
     switch (Context::get('format')) {
         case 'atom':
             $info->date = date('Y-m-d\\TH:i:sP');
             if ($mid) {
                 $info->id = getUrl('', 'mid', $mid, 'act', 'atom', 'page', Context::get('page'), 'start_date', Context::get('start_date'), 'end_date', Context::get('end_date'));
             } else {
                 $info->id = getUrl('', 'module', 'rss', 'act', 'atom', 'page', Context::get('page'), 'start_date', Context::get('start_date'), 'end_date', Context::get('end_date'));
             }
             break;
         case 'rss1.0':
             $info->date = date('Y-m-d\\TH:i:sP');
             break;
         default:
             $info->date = date("D, d M Y H:i:s") . ' ' . $GLOBALS['_time_zone'];
             break;
     }
     if ($_SERVER['HTTPS'] == 'on') {
         $proctcl = 'https://';
     } else {
         $proctcl = 'http://';
     }
     $temp_link = explode('/', $info->link);
     if ($temp_link[0] == '' && $info->link) {
         $info->link = $proctcl . $_SERVER['HTTP_HOST'] . $info->link;
     }
     $temp_id = explode('/', $info->id);
     if ($temp_id[0] == '' && $info->id) {
         $info->id = $proctcl . $_SERVER['HTTP_HOST'] . $info->id;
     }
     $info->language = str_replace('jp', 'ja', Context::getLangType());
     // Set the variables used in the RSS output
     Context::set('info', $info);
     Context::set('feed_config', $config);
     Context::set('open_rss_config', $open_rss_config);
     Context::set('document_list', $document_list);
     // Force the result output to be of XMLRPC
     Context::setResponseMethod("XMLRPC");
     // Perform the preprocessing function of the editor component as the results are obtained
     $path = $this->module_path . 'tpl/';
     //if($args->start_date || $args->end_date) $file = 'xe_rss';
     //else $file = 'rss20';
     switch (Context::get('format')) {
         case 'xe':
             $file = 'xe_rss';
             break;
         case 'atom':
             $file = 'atom10';
             break;
         case 'rss1.0':
             $file = 'rss10';
             break;
         default:
             $file = 'rss20';
             break;
     }
     $oTemplate = new TemplateHandler();
     $content = $oTemplate->compile($path, $file);
     Context::set('content', $content);
     // Set the template file
     $this->setTemplatePath($path);
     $this->setTemplateFile('display');
 }
 function getSyndicationList()
 {
     $oModuleModel = getModel('module');
     $config = $oModuleModel->getModuleConfig('syndication');
     if (!$config->year || !$config->site_url || !$config->syndication_token) {
         return new Object(-1, 'msg_check_syndication_config');
     }
     $id = Context::get('id');
     $type = Context::get('type');
     $startTime = Context::get('start-time');
     $endTime = Context::get('end-time');
     $page = Context::get('page');
     if (!$page) {
         $page = 1;
     }
     if (!$id || !$type) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!preg_match('/^tag:([^,]+),([0-9]+):(site|channel|article)(.*)$/i', $id, $matches)) {
         return new Object(-1, 'msg_invalid_request');
     }
     if ($config->syndication_password != Context::get('syndication_password')) {
         return new Object(-1, 'msg_invalid_request');
     }
     $url = $matches[1];
     $year = $matches[2];
     $target = $matches[3];
     $id = $matches[4];
     if ($id && $id[0] == ':') {
         $id = substr($id, 1);
     }
     $module_srl = null;
     $document_srl = null;
     if ($id && strpos($id, '-') !== false) {
         list($module_srl, $document_srl) = explode('-', $id);
     } elseif ($id) {
         $module_srl = $id;
     }
     if (!$url || !$year || !$target) {
         return new Object(-1, 'msg_invalid_request');
     }
     $time_zone = substr($GLOBALS['_time_zone'], 0, 3) . ':' . substr($GLOBALS['_time_zone'], 3);
     Context::set('time_zone', $time_zone);
     $site_module_info = Context::get('site_module_info');
     if ($target == 'channel' && !$module_srl) {
         $target = 'site';
     }
     if ($module_srl) {
         $args = new stdClass();
         $args->module_srls = $module_srl;
         $output = executeQuery('syndication.getModules', $args);
         $module_info = $output->data;
     }
     if ($target == 'channel' && $module_srl) {
         if ($module_info) {
             $args->module_srl = $module_srl;
             $output = executeQuery('syndication.getExceptModules', $args);
             if ($output->data->count) {
                 $error = 'target is not founded';
             }
         } else {
             $error = 'target is not founded';
         }
         unset($args);
     }
     if (!$error) {
         Context::set('target', $target);
         Context::set('type', $type);
         switch ($target) {
             case 'site':
                 $site_info = new stdClass();
                 $site_info->id = $this->getID('site');
                 $site_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
                 $site_info->title = $site_info->site_title;
                 if ($module_srl) {
                     $args->module_srl = $module_srl;
                     $site_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl);
                     if (!$site_info->title) {
                         $site_info->title = $site_info->site_title;
                     }
                 } else {
                     $except_module_output = executeQueryArray('syndication.getExceptModuleSrls');
                     if (is_array($except_module_output->data)) {
                         $except_module_srls = array();
                         foreach ($except_module_output->data as $val) {
                             $except_module_srls[] = $val->module_srl;
                         }
                         $args->except_modules = implode(',', $except_module_srls);
                     }
                 }
                 $output = executeQuery('syndication.getSiteUpdatedTime', $args);
                 if ($output->data) {
                     $site_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)) . $time_zone;
                 }
                 $site_info->self_href = $this->getSelfHref($site_info->id, $type);
                 Context::set('site_info', $site_info);
                 $this->setTemplateFile('site');
                 switch ($type) {
                     case 'article':
                         // 문서 전체를 신디케이션에 추가
                         Context::set('articles', $this->getArticles($module_srl, $page, $startTime, $endTime, 'article', $site_info->id));
                         $next_url = Context::get('articles')->next_url;
                         break;
                     case 'deleted':
                         // 문서 전체를 신디케이션에서 삭제
                         Context::set('deleted', $this->getArticles($module_srl, $page, $startTime, $endTime, 'deleted', $site_info->id));
                         $next_url = Context::get('deleted')->next_url;
                         break;
                     default:
                         $this->setTemplateFile('site.info');
                         break;
                 }
                 // 다음 페이지가 있다면 다시 신디케이션 호출
                 if ($next_url) {
                     $oSyndicationController = getController('syndication');
                     $oSyndicationController->ping(Context::get('id'), Context::get('type'), ++$page);
                 }
                 break;
             case 'channel':
                 $channel_info = new stdClass();
                 $channel_info->id = $this->getID('channel', $module_info->module_srl);
                 $channel_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
                 $channel_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl);
                 $channel_info->updated = date("Y-m-d\\TH:i:s") . $time_zone;
                 $channel_info->self_href = $this->getSelfHref($channel_info->id, $type);
                 $channel_info->alternative_href = $this->getAlternativeHref($module_info);
                 $channel_info->summary = $module_info->description;
                 if ($module_info->module == "textyle") {
                     $channel_info->type = "blog";
                     $channel_info->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss');
                 } else {
                     $channel_info->type = "web";
                 }
                 $except_module_srls = $this->getExceptModuleSrls();
                 if ($except_module_srls) {
                     $args->except_modules = implode(',', $except_module_srls);
                 }
                 $output = executeQuery('syndication.getSiteUpdatedTime', $args);
                 if ($output->data) {
                     $channel_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)) . $time_zone;
                 }
                 Context::set('channel_info', $channel_info);
                 $this->setTemplateFile('channel');
                 switch ($type) {
                     case 'article':
                         Context::set('articles', $this->getArticles($module_srl, $page, $startTime, $endTime, 'article', $channel_info->id));
                         break;
                     case 'deleted':
                         Context::set('deleted', $this->getDeleted($module_srl, $page, $startTime, $endTime, 'deleted', $channel_info->id));
                         break;
                     default:
                         $this->setTemplateFile('channel.info');
                         break;
                 }
                 break;
             case 'article':
                 $channel_info = new stdClass();
                 $channel_info->id = $this->getID('channel', $module_info->module_srl);
                 $channel_info->site_title = $this->handleLang($site_module_info->browser_title, $site_module_info->site_srl);
                 $channel_info->title = $this->handleLang($module_info->browser_title, $module_info->site_srl);
                 $channel_info->updated = date("Y-m-d\\TH:i:s") . $time_zone;
                 $channel_info->self_href = $this->getSelfHref($channel_info->id, $type);
                 $channel_info->alternative_href = $this->getAlternativeHref($module_info);
                 $channel_info->summary = $module_info->description;
                 if ($module_info->module == "textyle") {
                     $channel_info->type = "blog";
                     $channel_info->rss_href = getFullSiteUrl($module_info->domain, '', 'mid', $module_info->mid, 'act', 'rss');
                 } else {
                     $channel_info->type = "web";
                 }
                 $except_module_srls = $this->getExceptModuleSrls();
                 if ($except_module_srls) {
                     $args->except_modules = implode(',', $except_module_srls);
                 }
                 $output = executeQuery('syndication.getSiteUpdatedTime', $args);
                 if ($output->data) {
                     $channel_info->updated = date("Y-m-d\\TH:i:s", ztime($output->data->last_update)) . $time_zone;
                 }
                 Context::set('channel_info', $channel_info);
                 $this->setTemplateFile('channel');
                 switch ($type) {
                     case "article":
                         $articles = new stdClass();
                         $articles->list = array($this->getArticle($document_srl));
                         Context::set('articles', $articles);
                         break;
                     case "deleted":
                         $deleted = new stdClass();
                         $deleted->list = $this->getDeletedByDocumentSrl($document_srl);
                         Context::set('deleted', $deleted);
                         break;
                 }
                 break;
         }
     } else {
         Context::set('message', $error);
         $this->setTemplateFile('error');
     }
     $this->setTemplatePath($this->module_path . 'tpl');
     Context::setResponseMethod('XMLRPC');
 }
 /**
  * @brief SMS를 받는다
  *
  **/
 function procPlanetInsertSMS()
 {
     $phone_number = Context::get('phone_number');
     $message = Context::get('message');
     $message = Context::convertEncodingStr($message);
     //@골뱅이를 빼자
     if (substr($message, 0, 1) == '@') {
         $message = substr($message, 1);
     }
     $args->phone_number = $phone_number;
     $oPlanetModel =& getModel('planet');
     $output = $oPlanetModel->getSMSUser($args);
     // SMS 사용자가 있으면 해당 planet에 등록
     if ($output->data) {
         $args->content = $message;
         $args->module_srl = $output->data->module_srl;
         $args->member_srl = $output->data->member_srl;
         $oMemberModel =& getModel('member');
         $output = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
         $args->user_id = $output->user_id;
         $args->user_name = $output->user_name;
         $args->nick_name = $output->nick_name;
         $args->email_address = $output->email_address;
         $args->homepage = $output->homepage;
         $module_info = $oPlanetModel->getPlanetConfig();
         $args->tags = join(',', $module_info->smstag);
         $manual_inserted = true;
         $output = $this->insertContent($args, $manual_inserted);
     } else {
         // SMS 사용자가 아니라면 planet_sms_resv에 쌓는다
         $output = $this->insertSMSRecv($phone_number, $message);
     }
     if ($output->toBool()) {
         header("X-SMSMORESPONSE:0");
     } else {
         header("X-SMSMORESPONSE:1");
     }
     // response를 XMLRPC로 변환
     Context::setResponseMethod('XMLRPC');
     return $output;
 }