/** * 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); } }
/** * @brief API 실행 */ protected function _procAPI($type) { // 결과 출력을 JSON으로 지정 Context::setRequestMethod('JSON'); // 요청받은 값 $args = Context::getRequestVars(); // API 종류에 따른 처리 if (in_array($type, $this->api_methods)) { $output = $this->{$type}($args); } else { return new Object(-1, 'invalid_api'); } $this->setError($output->getError()); $this->setMessage($output->getMessage()); $this->adds($output->getObjectVars()); return $this; }
/** * Return list of module skin package */ function getAutoinstallAdminSkinPackageList() { Context::setRequestMethod('JSON'); $search_keyword = Context::get('search_keyword'); $order_target = Context::get('order_target'); $order_type = Context::get('order_type'); $page = Context::get('page'); $parent_program = Context::get('parent_program'); $type_array = array('M' => 1, 'P' => 1); $type = Context::get('type'); if (!isset($type_array[$type])) { $type = 'P'; } if ($type == 'P') { $category_srl = $this->module_skin_category_srl; } else { $category_srl = $this->module_mobile_skin_category_srl; } $this->preProcParam($order_target, $order_type, $page); $this->getPackageList('skin', $order_target, $order_type, $page, $search_keyword, $category_srl, $parent_program); }
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'); }
/** * @brief AJAX API */ function getAllianceAPI() { // 결과 출력을 XMLRPC로 지정 Context::setRequestMethod('JSON'); // 요청받은 API type을 구함 $getType = Context::get('gettype'); switch ($getType) { // 사이트 목록 case 'site_list': $this->site_list(); break; // 댓글 목록 // 댓글 목록 case 'comments': $this->comments(); break; default: return new Object(-1, 'invalid_api'); } }
/** * @brief Add and update a file into the file box **/ function procModuleFileBoxAdd() { $ajax = Context::get('ajax'); if ($ajax) { Context::setRequestMethod('JSON'); } $logged_info = Context::get('logged_info'); if ($logged_info->is_admin != 'Y' && !$logged_info->is_site_admin) { return new Object(-1, 'msg_not_permitted'); } $vars = Context::gets('addfile', 'filter'); $attributes = Context::getRequestVars(); foreach ($attributes as $key => $value) { if (!(strpos($key, 'attribute_name') === false)) { $vars->comment = $vars->comment . ';' . $value; } if (!(strpos($key, 'attribute_value') === false)) { $vars->comment = $vars->comment . ':' . $value; } } $vars->comment = substr($vars->comment, 1); $module_filebox_srl = Context::get('module_filebox_srl'); $ext = strtolower(substr(strrchr($vars->addfile['name'], '.'), 1)); $vars->ext = $ext; if ($vars->filter) { $filter = explode(',', $vars->filter); } else { $filter = array('jpg', 'jpeg', 'gif', 'png'); } if (!in_array($ext, $filter)) { return new Object(-1, 'msg_error_occured'); } $vars->member_srl = $logged_info->member_srl; // update if ($module_filebox_srl > 0) { $vars->module_filebox_srl = $module_filebox_srl; $output = $this->updateModuleFileBox($vars); // insert } else { if (!Context::isUploaded()) { return new Object(-1, 'msg_error_occured'); } $addfile = Context::get('addfile'); if (!is_uploaded_file($addfile['tmp_name'])) { return new Object(-1, 'msg_error_occured'); } if ($vars->addfile['error'] != 0) { return new Object(-1, 'msg_error_occured'); } $output = $this->insertModuleFileBox($vars); } $this->setTemplatePath($this->module_path . 'tpl'); if (!$ajax) { $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispModuleAdminFileBox'); $this->setRedirectUrl($returnUrl); return; } else { $this->add('save_filename', $output->get('save_filename')); } }
function dispSocialxeLogout() { $use_js = Context::get('js'); // JS 사용 여부 $widget_skin = Context::get('skin'); // 위젯의 스킨명 $query = urldecode(Context::get('query')); // 로그아웃 후 돌아갈 페이지 쿼리 $provider = Context::get('provider'); // 서비스 $info = Context::get('info'); // SocialXE info 위젯 여부 $oSocialxeController =& getController('socialxe'); // 아무 것도 없는 레이아웃 적용 $template_path = sprintf("%stpl/", $this->module_path); $this->setLayoutPath($template_path); $this->setLayoutFile("popup_layout"); if ($provider == 'xe') { return $this->stop('msg_invalid_request'); } $output = $this->providerManager->doLogout($provider); if (!$output->toBool()) { return $output; } // 로그인되어 있지 않고, 로그인되어 있다면 소셜 정보 통합 기능을 사용하지 않을 때만 세션을 전송한다. $is_logged = Context::get('is_logged'); if (!$is_logged || $is_logged && $this->config->use_social_info != 'Y') { $this->communicator->sendSession(); } // 댓글 권한을 초기화한다... unset($_SESSION['own_comment']); // JS 사용이면 XMLRPC 응답 if ($use_js) { Context::setRequestMethod('XMLRPC'); // info 위젯이면 info 컴파일 if ($info) { $output = $oSocialxeController->_compileInfo(); } else { $output = $oSocialxeController->_compileInput(); } $this->add('skin', $widget_skin); $this->add('output', $output); } else { $this->returnPage($query); } }
/** * @brief Add and update a file into the file box */ function procModuleFileBoxAdd() { $ajax = Context::get('ajax'); if ($ajax) { Context::setRequestMethod('JSON'); } $logged_info = Context::get('logged_info'); if ($logged_info->is_admin != 'Y' && !$logged_info->is_site_admin) { return new Object(-1, 'msg_not_permitted'); } $vars = Context::gets('addfile', 'filter'); $attributeNames = Context::get('attribute_name'); $attributeValues = Context::get('attribute_value'); if (is_array($attributeNames) && is_array($attributeValues) && count($attributeNames) == count($attributeValues)) { $attributes = array(); foreach ($attributeNames as $no => $name) { if (empty($name)) { continue; } $attributes[] = sprintf('%s:%s', $name, $attributeValues[$no]); } $attributes = implode(';', $attributes); } $vars->comment = $attributes; $module_filebox_srl = Context::get('module_filebox_srl'); $ext = strtolower(substr(strrchr($vars->addfile['name'], '.'), 1)); $vars->ext = $ext; if ($vars->filter) { $filter = array_map('trim', explode(',', $vars->filter)); if (!in_array($ext, $filter)) { return new Object(-1, 'msg_error_occured'); } } $vars->member_srl = $logged_info->member_srl; // update if ($module_filebox_srl > 0) { $vars->module_filebox_srl = $module_filebox_srl; $output = $this->updateModuleFileBox($vars); } else { if (!Context::isUploaded()) { return new Object(-1, 'msg_error_occured'); } $addfile = Context::get('addfile'); if (!is_uploaded_file($addfile['tmp_name'])) { return new Object(-1, 'msg_error_occured'); } if ($vars->addfile['error'] != 0) { return new Object(-1, 'msg_error_occured'); } $output = $this->insertModuleFileBox($vars); } $this->setTemplatePath($this->module_path . 'tpl'); if (!$ajax) { $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispModuleAdminFileBox'); $this->setRedirectUrl($returnUrl); return; } else { if ($output) { $this->add('save_filename', $output->get('save_filename')); } else { $this->add('save_filename', ''); } } }
function send() { // 응답 형식은 JSON로 Context::setRequestMethod('JSON'); //debug :@kakikaki debugPrint('send 진입'); //debug end // 클라이언트 버전이 0.9.1보다 낮으면 우선 요청 데이터 처리를 호출해준다. if ($this->client_ver < '0.9.1') { $name_list = array('comment', 'master_provider', 'logged_provider_list', 'reply_provider_list', 'client', 'uselang', 'twitter', 'me2day', 'facebook', 'yozm'); $this->getRequestData($name_list); } if ($this->client_ver < '0.9.1') { $comment = unserialize(urldecode($this->request_data['comment'])); // 댓글 정보 $master_provider = $this->request_data['master_provider']; // 대표 계정 $logged_provider_list = unserialize($this->request_data['logged_provider_list']); // 로그인한 서비스 목록 $reply_provider_list = unserialize($this->request_data['reply_provider_list']); // 리플 서비스 목록 $client_token = $this->request_data['client']; // 클라이언트 키 $uselang = $this->request_data['uselang']; // 언어 } else { $comment = $this->request_data['comment']; // 댓글 정보 $master_provider = $this->request_data['master_provider']; // 대표 계정 $logged_provider_list = $this->request_data['logged_provider_list']; // 로그인한 서비스 목록 $reply_provider_list = $this->request_data['reply_provider_list']; // 리플 서비스 목록 $client_token = $this->request_data['client']; // 클라이언트 키 $uselang = $this->request_data['uselang']; // 언어 } // 원본 주소를 저장해 둔다. $content_link = $comment->content_link; // 소셜 서비스 액세스 정보 준비 foreach ($logged_provider_list as $provider) { if ($this->client_ver < '0.9.1') { $access[$provider] = unserialize($this->request_data[$provider]); } else { $access[$provider] = $this->request_data[$provider]; } } // 해당 클라이언트의 사용 도메인인지 확인 $referer_info = parse_url($comment->content_link); $referer_domain = str_replace('www.', '', $referer_info['host']); $output = $this->_checkClientDomain($request_info->client_srl, $referer_domain); //debug :@kakikaki debugPrint('$output 검증 : $output->toBool() : ' . $output->toBool()); //debug end if (!$output->toBool()) { return $output; } // 태그 준비 if (!$comment->hashtag) { $comment->hashtag = 'socialxe'; } // 로그인한 서비스에 댓글을 전송한다. unset($output); $send_result = array(); $reply = false; // 링크 주소 if ($comment->short_link) { $comment->content_link = $comment->short_link; } else { $bitly = new bitly_SocialXE($this->config->bitly_username, $this->config->bitly_api_key); $comment->content_link = $bitly->shorten(urlencode($this->_getCommentUrl($content_link, $comment->parent->comment_srl))); } // 댓글이면 모두 등록 if (!$comment->parent) { foreach ($logged_provider_list as $provider) { $output = $this->providerManager->send($provider, $comment, $access[$provider], $uselang); $send_result[$provider] = $output->get('result'); } } else { if (in_array($comment->parent->provider, $logged_provider_list)) { // 근데 페이스북은 제외 if ($comment->parent->provider != 'facebook') { $output = $this->providerManager->send($comment->parent->provider, $comment, $access[$comment->parent->provider], $uselang); $send_result[$comment->parent->provider] = $output->get('result'); $reply = true; } } } // 대댓글인데 리플 처리가 안 됐으면 소셜XE 계정을 이용하여 리플을 보낸다. if ($comment->parent && !$reply) { $output = $this->providerManager->send($comment->parent->provider, $comment, $this->access[$comment->parent->provider], $uselang, true); $send_result[$comment->parent->provider] = $output->get('result'); } // 리플 리스트 중 보내지 않은 서비스가 있으면 보낸다. if (!is_array($send_result)) { $send_result = array(); } $sended_provider_list = array_keys($send_result); foreach ($reply_provider_list as $provider) { if (in_array($provider, $sended_provider_list)) { continue; } // 먼저 사용자의 계정으로 등록을 시도 if (in_array($provider, $logged_provider_list)) { $output = $this->providerManager->send($provider, $comment, $access[$provider], $uselang); $send_result[$comment->parent->provider] = $output->get('result'); } else { $output = $this->providerManager->send($provider, $comment, $this->access[$provider], $uselang, true); $send_result[$comment->parent->provider] = $output->get('result'); } } $result = new Object(); $result->add('result', $send_result); return $result; }
/** * @brief 엮인글 입력 **/ function trackback() { // 출력을 XMLRPC로 설정 Context::setRequestMethod("XMLRPC"); // 엮인글 받을때 필요한 변수를 구함 $obj = Context::gets('document_srl', 'blog_name', 'url', 'title', 'excerpt'); if (!$obj->document_srl || !$obj->url || !$obj->title || !$obj->excerpt) { return $this->stop('fail'); } // 올바른 trackback url인지 검사 $given_key = Context::get('key'); $oTrackbackModel =& getModel('trackback'); $key = $oTrackbackModel->getTrackbackKey($obj->document_srl); if ($key != $given_key) { return $this->stop('fail'); } // 엮인글 모듈의 기본 설정을 받음 $module_srl = Context::get('module_srl'); $oModuleModel =& getModel('module'); $config = $oModuleModel->getModulePartConfig('trackback', $module_srl); $enable_trackback = $config->enable_trackback; if (!$enable_trackback) { $config = $oModuleModel->getModuleConfig('trackback'); $enable_trackback = $config->enable_trackback; } // 관리자가 금지하였을 경우에는 엮인글을 받지 않음 if ($enable_trackback == 'N') { return $this->stop('fail'); } return $this->insertTrackback($obj); }
/** * Trackback inserted * @return Object */ function trackback() { // Output is set to XMLRPC Context::setRequestMethod("XMLRPC"); // When receiving the necessary variables yeokingeul Wanted $obj = Context::gets('document_srl', 'blog_name', 'url', 'title', 'excerpt'); if (!$obj->document_srl || !$obj->url || !$obj->title || !$obj->excerpt) { return $this->stop('fail'); } // Checks for correct trackback url $given_key = Context::get('key'); $oTrackbackModel =& getModel('trackback'); $key = $oTrackbackModel->getTrackbackKey($obj->document_srl); if ($key != $given_key) { return $this->stop('fail'); } // Yeokingeul module out of the default settings $module_srl = Context::get('module_srl'); $oModuleModel =& getModel('module'); $config = $oModuleModel->getModulePartConfig('trackback', $module_srl); $enable_trackback = $config->enable_trackback; if (!$enable_trackback) { $config = $oModuleModel->getModuleConfig('trackback'); $enable_trackback = $config->enable_trackback; } // If managers were banned does not Trackbacks if ($enable_trackback == 'N') { return $this->stop('fail'); } return $this->insertTrackback($obj); }
/** * 주소록 업데이트 */ function procPurplebookUpdateList() { // 강제적으로 요청을 JSON으로 한다. Context::setRequestMethod("JSON"); $logged_info = Context::get('logged_info'); if (!$logged_info) { return new Object(-1, 'msg_invalid_request'); } $vars = Context::getRequestVars(); for ($i = 1; $i <= $vars->list_count; $i++) { $node_id = "node_id_" . $i; $node_name = "node_name_" . $i; $phone_num = "phone_num_" . $i; $memo1 = "memo1_" . $i; $memo2 = "memo2_" . $i; $memo3 = "memo3_" . $i; $args->node_id = $vars->{$node_id}; $args->node_name = $vars->{$node_name}; $args->phone_num = $vars->{$phone_num}; $args->memo1 = $vars->{$memo1} . ""; $args->memo2 = $vars->{$memo2} . ""; $args->memo3 = $vars->{$memo3} . ""; $output = executeQuery('purplebook.updatePurplebook', $args); if (!$output->toBool()) { return $output; } } }