Example #1
0
 /**
  * check easy install
  * @return void
  */
 function checkEasyinstall()
 {
     $lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile);
     if ($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30) {
         return;
     }
     $oAutoinstallModel = getModel('autoinstall');
     $params = array();
     $params["act"] = "getResourceapiLastupdate";
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     $xml_lUpdate = new XmlParser();
     $lUpdateDoc = $xml_lUpdate->parse($buff);
     $updateDate = $lUpdateDoc->response->updatedate->body;
     if (!$updateDate) {
         $this->_markingCheckEasyinstall();
         return;
     }
     $item = $oAutoinstallModel->getLatestPackage();
     if (!$item || $item->updatedate < $updateDate) {
         $oController = getAdminController('autoinstall');
         $oController->_updateinfo();
     }
     $this->_markingCheckEasyinstall();
 }
Example #2
0
 /**
  * Request data to server and returns result
  *
  * @param array $params Request data
  * @return object
  */
 function getXmlDoc(&$params)
 {
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     if (!$buff) {
         return;
     }
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     return $xmlDoc;
 }
 function emitEvent($args = array())
 {
     $oAjaxboardModel = getModel('ajaxboard');
     $module_config = $oAjaxboardModel->getConfig();
     $fields = array_merge($args, array('token' => $module_config->token, 'private_key' => $module_config->private_key));
     $request_config = array('ssl_verify_peer' => false);
     $request_url = $module_config->server_url;
     $timeout = $module_config->timeout / 1000;
     $buff = FileHandler::getRemoteResource($request_url, NULL, $timeout, 'POST', 'application/x-www-form-urlencoded', array(), array(), $fields, $request_config);
     return $buff;
 }
Example #4
0
 /**
  * Request data to server and returns result
  *
  * @param array $params Request data
  * @return object
  */
 function getXmlDoc(&$params)
 {
     $body = XmlGenerater::generate($params);
     $request_config = array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml", array(), array(), array(), $request_config);
     if (!$buff) {
         return;
     }
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     return $xmlDoc;
 }
 function _getContent($method, $user_id = null, $params = null)
 {
     $url = $this->api_url . $this->_getPath($method, $user_id);
     $auth = base64_encode($this->user_id . ':' . $this->_getAuthKey());
     $arr_content = array();
     if (is_array($params) && count($params)) {
         foreach ($params as $key => $val) {
             $arr_content[] = sprintf('%s=%s', $key, urlencode($val));
         }
         $body = implode('&', $arr_content);
     }
     $buff = FileHandler::getRemoteResource($url, $body, 3, 'GET', 'application/x-www-form-urlencoded', array('me2_application_key' => $this->application_key, 'Authorization' => 'Basic ' . $auth));
     return $buff;
 }
 /**
  * Update easy install information
  *
  * @return void
  */
 function _updateinfo()
 {
     $oModel =& getModel('autoinstall');
     $item = $oModel->getLatestPackage();
     if ($item) {
         $params["updatedate"] = $item->updatedate;
     }
     $params["act"] = "getResourceapiUpdate";
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     $this->updateCategory($xmlDoc);
     $this->updatePackages($xmlDoc);
     $this->checkInstalled();
 }
 /**
  * Update easy install information
  *
  * @return void
  */
 function _updateinfo()
 {
     $oModel = getModel('autoinstall');
     $item = $oModel->getLatestPackage();
     if ($item) {
         $params["updatedate"] = $item->updatedate;
     }
     $params["act"] = "getResourceapiUpdate";
     $body = XmlGenerater::generate($params);
     $request_config = array('ssl_verify_peer' => FALSE, 'ssl_verify_host' => FALSE);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml", array(), array(), array(), $request_config);
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     $this->updateCategory($xmlDoc);
     $this->updatePackages($xmlDoc);
     $this->checkInstalled();
     $oAdminController = getAdminController('admin');
     $output = $oAdminController->cleanFavorite();
 }
 /**
  * @brief 대상 사이트에 요청을 보냄
  * @deprecated
  */
 private function _send($type, $target_domain, $params = array(), $timeout = 30)
 {
     if (!in_array($type, $this->api_methods)) {
         throw new Exception('Invalid Method');
         return NULL;
     }
     // 기본적으로 전송되어야 할 json data
     $params['module'] = 'alliance';
     $params['act'] = 'procAllianceAPI';
     $params['type'] = $type;
     $params['domain'] = $this->current_url;
     foreach ($params as $key => $val) {
         $param[] = $key . '=' . $val;
     }
     $params_str = implode('&', $param);
     $header['User-Agent'] = AXE_USER_AGENT;
     $url = $this->arrangeDomain($target_domain);
     // XE에 내장된 FileHandler::getRemoteResource()를 이용함
     return FileHandler::getRemoteResource($url, $params_str, $timeout, 'POST', AXE_CONTENT_TYPE, $header);
 }
 function soo_search()
 {
     $soo_display_set = trim($this->soo_display);
     $q_sort = urlencode(trim(Context::get('q_sort')));
     $query = urlencode(trim(Context::get('query')));
     $soo_result_start = urlencode(Context::get('soo_result_start'));
     if (!$soo_display_set) {
         $soo_display_set = '20';
     }
     if (!$soo_result_start) {
         $soo_result_start = '1';
     }
     $uri = sprintf('http://gdata.youtube.com/feeds/api/videos?q=%s&start-index=%s&max-results=%s&orderby=%s&v=2&alt=rss', $query, $soo_result_start, $soo_display_set, $q_sort);
     $rss = '';
     $rss = FileHandler::getRemoteResource($uri, null, 3, 'GET', 'application/xml');
     $rss = preg_replace("/<\\?xml([.^>]*)\\?>/i", "", $rss);
     $oXmlParser = new XmlParser();
     $xml_doc = $oXmlParser->parse($rss);
     $error_code = trim($xml_doc->errors->error->code->body);
     $error_message = trim($xml_doc->errors->error->internalreason->body);
     if ($error_message) {
         return new Object(-1, '::Youtube API Error::' . "\n" . $error_code . "\n" . $error_message);
     }
     $total_result_no = trim($xml_doc->rss->channel->{'opensearch:totalresults'}->body);
     $soo_result_start = trim($xml_doc->rss->channel->{'opensearch:startindex'}->body);
     $soo_search_display = trim($xml_doc->rss->channel->{'opensearch:itemsperpage'}->body);
     if ($total_result_no >= $soo_result_start + $soo_search_display) {
         $soo_next_page = $soo_result_start + $soo_display_set;
     } else {
         $soo_next_page = "1";
     }
     if ($soo_result_start != '1') {
         $soo_before_page = $soo_result_start - $soo_display_set;
     } else {
         $soo_before_page = "1";
     }
     $soo_results = $xml_doc->rss->channel->item;
     if (!is_array($soo_results)) {
         $soo_results = array($soo_results);
     }
     $soo_results_count = count($soo_results);
     $soo_result_start_end = trim($soo_result_start . ' - ' . ($soo_result_start + $soo_results_count - 1));
     $soo_list = array();
     for ($i = 0; $i < $soo_results_count; $i++) {
         $item = $soo_results[$i];
         $item_images = $item->{'media:group'}->{'media:thumbnail'};
         if (!is_array($item_images)) {
             $item_images = array($item_images);
         }
         $item_published = explode('T', $item->{'media:group'}->{'yt:uploaded'}->body);
         $item_updated = explode('T', $item->{'atom:updated'}->body);
         $item_second = $item->{'media:group'}->{'yt:duration'}->attrs->seconds % 60;
         $item_minute = intval($item->{'media:group'}->{'yt:duration'}->attrs->seconds / 60) % 60;
         $item_hour = intval(intval($item->{'media:group'}->{'yt:duration'}->attrs->seconds / 60) / 60);
         if (!is_array($item->{'media:group'}->{'media:content'})) {
             $item->{'media:group'}->{'media:content'} = array($item->{'media:group'}->{'media:content'});
         }
         $soo_list[] = sprintf("%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s,[[soo]],%s", trim($item->title->body), trim($item->author->body), trim($item->{'media:group'}->{'media:content'}[0]->attrs->url), trim($item_images[1]->attrs->url), trim($item_published[0]), trim($item_updated[0]), trim($item_hour), trim($item_minute), trim($item_second), trim($item->{'yt:statistics'}->attrs->viewcount), trim($item->link->body), cut_str(trim($item->title->body), 20));
     }
     $this->add("total_result_no", $total_result_no);
     $this->add("total", htmlspecialchars($rss));
     $this->add("soo_result_start", $soo_result_start);
     $this->add("soo_result_start_end", $soo_result_start_end);
     $this->add("result_list_bfpage", $soo_before_page);
     $this->add("result_list_nextpage", $soo_next_page);
     $this->add("result_list", implode("\n", $soo_list));
 }
Example #10
0
 function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array())
 {
     requirePear();
     require_once 'HTTP/Request.php';
     $parsed_url = parse_url(__PROXY_SERVER__);
     if ($parsed_url["host"]) {
         $oRequest = new HTTP_Request(__PROXY_SERVER__);
         $oRequest->setMethod('POST');
         $oRequest->_timeout = $timeout;
         $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data)));
     } else {
         $oRequest = new HTTP_Request($url);
         if (count($headers)) {
             foreach ($headers as $key => $val) {
                 $oRequest->addHeader($key, $val);
             }
         }
         if ($cookies[$host]) {
             foreach ($cookies[$host] as $key => $val) {
                 $oRequest->addCookie($key, $val);
             }
         }
         if (count($post_data)) {
             foreach ($post_data as $key => $val) {
                 $oRequest->addPostData($key, $val);
             }
         }
         if (!$content_type) {
             $oRequest->addHeader('Content-Type', 'text/html');
         } else {
             $oRequest->addHeader('Content-Type', $content_type);
         }
         $oRequest->setMethod($method);
         if ($body) {
             $oRequest->setBody($body);
         }
         $oRequest->_timeout = $timeout;
     }
     $oResponse = $oRequest->sendRequest();
     $code = $oRequest->getResponseCode();
     $header = $oRequest->getResponseHeader();
     $response = $oRequest->getResponseBody();
     if ($c = $oRequest->getResponseCookies()) {
         foreach ($c as $k => $v) {
             $cookies[$host][$v['name']] = $v['value'];
         }
     }
     if ($code > 300 && $code < 399 && $header['location']) {
         return FileHandler::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
     }
     return $response;
 }
 function getSyndicationStatusNaver($site_url)
 {
     $status_url = trim($this->statuses['Naver']);
     $xml = FileHandler::getRemoteResource(sprintf($status_url, $site_url), null, 3, 'GET', 'application/xml');
     $oXmlParser = new XmlParser();
     $oXml = $oXmlParser->parse($xml);
     $oStatus = $oXml->syndication_status;
     if ($oStatus->error->body != 0) {
         return new Object(-1, $oStatus->message->body);
     }
     $result = new stdClass();
     $result->site_name = $oStatus->site_name->body;
     $result->first_update = $oStatus->first_update->body;
     $result->last_update = $oStatus->last_update->body;
     $result->visit_ok_count = $oStatus->visit_ok_count->body;
     $result->visit_fail_count = $oStatus->visit_fail_count->body;
     $result->status = $oStatus->status->body;
     if (!$oStatus->sync || !$oStatus->sync->article) {
         $oArticleList = array();
     } else {
         $oArticleList = $oStatus->sync->article;
         if (!is_array($oArticleList)) {
             $oArticleList = array($oArticleList);
         }
     }
     if (count($oArticleList) > 0) {
         $article_count = array();
         foreach ($oArticleList as $article) {
             $article_count[$article->attrs->date] = $article->body;
         }
         $result->article_count = $article_count;
         $result->max_article_count = max($result->article_count);
     }
     Context::set('result', $result);
     $oTemplateHandler =& TemplateHandler::getInstance();
     $html = $oTemplateHandler->compile($this->module_path . 'tpl', 'naver_result');
     $output = new Object();
     $output->add('result_status', $html);
     return $output;
 }
 /**
  * @brief 원격파일을 다운받아서 특정 위치에 저장
  **/
 function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array())
 {
     $body = FileHandler::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers);
     if (!$body) {
         return;
     }
     $target_filename = FileHandler::getRealPath($target_filename);
     FileHandler::writeFile($target_filename, $body);
     return true;
 }
Example #13
0
 function httpRequest($url, $mode = 'GET')
 {
     if ($mode == 'POST') {
         $url_info = parse_url($url);
         $url = $url_info['scheme'] . '://' . $url_info['host'];
         if (!$url_info['port'] || $url_info['port'] == '80') {
             $url .= $url_info['path'];
         } else {
             $url .= ':' . $url_info['port'] . $url_info['path'];
         }
         $body = $url_info['query'];
     }
     $headers = array('User-Agent' => "SocialXE ClientBot Ver. {$this->version}");
     $output = FileHandler::getRemoteResource($url, $body, 30, $mode, 'application/json', $headers);
     return $output;
 }
Example #14
0
 /**
  * Find XE installed path on ftp
  */
 function getAdminFTPPath()
 {
     Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang');
     @set_time_limit(5);
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(1, 'msg_ftp_invalid_auth_info');
     }
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = '127.0.0.1';
     }
     if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) {
         $ftp_info->ftp_port = '21';
     }
     if ($ftp_info->sftp == 'Y') {
         if (!function_exists('ssh2_sftp')) {
             return new Object(-1, 'disable_sftp_support');
         }
         return $this->getSFTPPath();
     }
     if ($ftp_info->ftp_pasv == 'N') {
         if (function_exists('ftp_connect')) {
             return $this->getFTPPath();
         }
         $ftp_info->ftp_pasv = "Y";
     }
     $oFTP = new ftp();
     if (!$oFTP->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
         return new Object(1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host));
     }
     if (!$oFTP->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
         return new Object(1, 'msg_ftp_invalid_auth_info');
     }
     // create temp file
     $pin = $_SERVER['REQUEST_TIME'];
     FileHandler::writeFile('./files/cache/ftp_check', $pin);
     // create path candidate
     $xe_path = _XE_PATH_;
     $path_info = array_reverse(explode('/', _XE_PATH_));
     array_pop($path_info);
     // remove last '/'
     $path_candidate = array();
     $temp = '';
     foreach ($path_info as $path) {
         $temp = '/' . $path . $temp;
         $path_candidate[] = $temp;
     }
     // try
     foreach ($path_candidate as $path) {
         // upload check file
         if (!$oFTP->ftp_put($path . 'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check'))) {
             continue;
         }
         // get check file
         $result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
         // delete temp check file
         $oFTP->ftp_delete($path . 'ftp_check.html');
         // found
         if ($result == $pin) {
             $found_path = $path;
             break;
         }
     }
     FileHandler::removeFile('./files/cache/ftp_check', $pin);
     if ($found_path) {
         $this->add('found_path', $found_path);
     }
 }
Example #15
0
 /**
  * Display uninstall package
  *
  * @return Object
  */
 function dispAutoinstallAdminUninstall()
 {
     $package_srl = Context::get('package_srl');
     if (!$package_srl) {
         return $this->dispAutoinstallAdminIndex();
     }
     $oModel =& getModel('autoinstall');
     $installedPackage = $oModel->getInstalledPackage($package_srl);
     if (!$installedPackage) {
         return $this->dispAutoinstallAdminInstalledPackages();
     }
     if (!$_SESSION['ftp_password']) {
         Context::set('need_password', true);
     }
     $installedPackage = $oModel->getPackage($package_srl);
     $path = $installedPackage->path;
     $type = $oModel->getTypeFromPath($path);
     if (!$type || $type == "core") {
         return $this->stop("msg_invalid_request");
     }
     $config_file = $oModel->getConfigFilePath($type);
     if (!$config_file) {
         return $this->stop("msg_invalid_request");
     }
     $params["act"] = "getResourceapiPackages";
     $params["package_srls"] = $package_srl;
     $body = XmlGenerater::generate($params);
     $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
     $xml_lUpdate = new XmlParser();
     $xmlDoc = $xml_lUpdate->parse($buff);
     if ($xmlDoc && $xmlDoc->response->packagelist->item) {
         $item_list = $this->rearranges($xmlDoc->response->packagelist->item);
         $installedPackage->title = $item_list[$package_srl]->title;
         $installedPackage->type = $item_list[$package_srl]->category;
         $installedPackage->avail_remove = $item_list[$package_srl]->avail_remove;
         $installedPackage->deps = $item_list[$package_srl]->deps;
         Context::set('package', $installedPackage);
         $this->setTemplateFile('uninstall');
         Context::addJsFilter($this->module_path . 'tpl/filter', 'uninstall_package.xml');
         $security = new Security();
         $security->encodeHTML('package.');
         $this->setTemplateFile('uninstall');
     } else {
         return $this->stop('msg_connection_fail');
     }
 }
Example #16
0
 /**
  * Download file from server
  *
  * @return void
  */
 function _download()
 {
     if ($this->package->path == ".") {
         $this->download_file = $this->temp_dir . "xe.tar";
         $this->target_path = "";
         $this->download_path = $this->temp_dir;
     } else {
         $subpath = substr($this->package->path, 2);
         $this->download_file = $this->temp_dir . $subpath . ".tar";
         $subpatharr = explode("/", $subpath);
         array_pop($subpatharr);
         $this->download_path = $this->temp_dir . implode("/", $subpatharr);
         $this->target_path = implode("/", $subpatharr);
     }
     $postdata = array();
     $postdata["path"] = $this->package->path;
     $postdata["module"] = "resourceapi";
     $postdata["act"] = "procResourceapiDownload";
     $buff = FileHandler::getRemoteResource($this->base_url, NULL, 3, "POST", "application/x-www-form-urlencoded", array(), array(), $postdata);
     FileHandler::writeFile($this->download_file, $buff);
 }
 /**
  * Get the public IPv4 address of the current server.
  */
 public function getServerIP()
 {
     if (isset($_SESSION['advanced_mailer_ip_cache']) && $_SESSION['advanced_mailer_ip_cache'][1] > time() - 3600) {
         return $_SESSION['advanced_mailer_ip_cache'][0];
     } else {
         $ip = trim(FileHandler::getRemoteResource('http://icanhazip.com/'));
         $ip = preg_match('/^[0-9]+(\\.[0-9]+){3}$/', $ip) ? $ip : false;
         $_SESSION['advanced_mailer_ip_cache'] = array($ip, time());
         return $ip;
     }
 }
Example #18
0
 /**
  * @brief uri에 해당되는 xml파일을 파싱한다
  * @param $uri 파싱할 xml 파일
  * @param $headers HTTP 프로토콜 헤더(default = null)
  * @return 파싱된 데이터
  **/
 function xmlAPIRequest($uri, $headers = null)
 {
     $xml = '';
     $xml = FileHandler::getRemoteResource($uri, null, 3, 'GET', 'application/xml', $headers);
     $xml = preg_replace("/<\\?xml([.^>]*)\\?>/i", "", $xml);
     $oXmlParser = new XmlParser();
     $xml_doc = $oXmlParser->parse($xml);
     return $xml_doc;
 }
 function dispLoginxeclientOAuthFinish()
 {
     $oMemberModel = getModel('member');
     $config = $oMemberModel->getMemberConfig();
     Context::set('member_config', $config);
     $skin = $config->skin;
     if (!$skin) {
         $skin = 'default';
         $template_path = sprintf('./modules/member/skins/%s', $skin);
     } else {
         //check theme
         $config_parse = explode('|@|', $skin);
         if (count($config_parse) > 1) {
             $template_path = sprintf('./themes/%s/modules/member/', $config_parse[0]);
         } else {
             $template_path = sprintf('./modules/member/skins/%s', $skin);
         }
     }
     Context::set('memberskin', $template_path);
     $oMemberController = getController('member');
     $oLoginXEServerModel = getModel('loginxeclient');
     $module_config = $oLoginXEServerModel->getConfig();
     //use_sessiondata가 true면 로그인 서버에 다시 요청하지 않음(key 만료로 인한 오류 방지)
     if (Context::get('use_sessiondata') == 'true') {
         return;
     }
     if (Context::get('token') == '') {
         return new Object(-1, 'No token given.');
     }
     $token = rawurldecode(Context::get('token'));
     if ($token == '') {
         return new Object(-1, 'No token given.');
     }
     $state = Context::get('state');
     $service = Context::get('provider');
     //SSL 미지원시 리턴
     if (!$this->checkOpenSSLSupport()) {
         return new Object(-1, 'loginxecli_need_openssl');
     }
     //state가 다르면 리턴(CSRF 방지)
     if ($state != $_SESSION['loginxecli_state']) {
         return new Object(-1, 'msg_invalid_request');
     }
     //활성화된 서비스가 아닐경우 오류 출력
     if (!in_array($service, $module_config->loginxe_provider)) {
         return new Object(-1, sprintf(Context::getLang('loginxecli_not_enabled_provider'), Context::getLang('loginxe_' . $service . '_provider')));
     }
     if ($service == 'naver') {
         //받아온 인증키로 바로 회원 정보를 얻어옴
         $ping_url = 'https://apis.naver.com/nidlogin/nid/getUserProfile.xml';
         $ping_header = array();
         $ping_header['Host'] = 'apis.naver.com';
         $ping_header['Pragma'] = 'no-cache';
         $ping_header['Accept'] = '*/*';
         $ping_header['Authorization'] = sprintf("Bearer %s", $token);
         $request_config = array();
         $request_config['ssl_verify_peer'] = false;
         $buff = FileHandler::getRemoteResource($ping_url, null, 10, 'GET', 'application/x-www-form-urlencoded', $ping_header, array(), array(), $request_config);
         //받아온 결과 파싱(XML)
         $xml = new XmlParser();
         $xmlDoc = $xml->parse($buff);
         if ($xmlDoc->data->result->resultcode->body != '00') {
             //연결도 못했다
             if (!$buff) {
                 return new Object(-1, 'Socket connection error. Check your Server Environment.');
             } else {
                 return new Object(-1, $xmlDoc->data->result->message->body);
             }
         }
         //이후 처리는 2가지로 분기함
         if (Context::get('is_logged')) {
             //로그인되어 있으면 현재 로그인된 회원의 srl과 provider로 enc_id 검색
             //있으면 바로 리턴
             //없으면 연동처리만 해줌
             //srl과 type로 회원 조회
             $cond = new stdClass();
             $cond->srl = Context::get('logged_info')->member_srl;
             $cond->type = 'naver';
             $output = executeQuery('loginxeclient.getLoginxeclientMemberbySrl', $cond);
             if (isset($output->data->enc_id)) {
                 //리턴
                 return new Object(-1, 'loginxecli_already_registered');
             } else {
                 //연동시킴
                 $naver_member = new stdClass();
                 $naver_member->srl = Context::get('logged_info')->member_srl;
                 $naver_member->enc_id = $xmlDoc->data->response->enc_id->body;
                 $naver_member->type = 'naver';
                 $output = executeQuery('loginxeclient.insertLoginxeclientMember', $naver_member);
                 if (!$output->toBool()) {
                     return new Object(-1, $output->message);
                 }
                 //$this->redirect_Url = getUrl('');
                 return new Object(-1, 'loginxecli_linksuccess');
             }
         } else {
             //로그인이 안되어 있다면 enc_id로 가입 여부 체크
             $cond = new stdClass();
             $cond->enc_id = $xmlDoc->data->response->enc_id->body;
             $cond->type = $service;
             $output = executeQuery('loginxeclient.getLoginxeclientbyEncID', $cond);
             //srl이 있다면(로그인 시도)
             if (isset($output->data->srl)) {
                 $member_Info = $oMemberModel->getMemberInfoByMemberSrl($output->data->srl);
                 if ($config->identifier == 'email_address') {
                     $oMemberController->doLogin($member_Info->email_address, '', false);
                 } else {
                     $oMemberController->doLogin($member_Info->user_id, '', false);
                 }
                 //회원정보 변경시 비밀번호 입력 없이 변경 가능하도록 수정
                 $_SESSION['rechecked_password_step'] = 'INPUT_DATA';
                 if ($config->after_login_url) {
                     $this->redirect_Url = $config->after_login_url;
                 }
                 $this->redirect_Url = getUrl('');
             } else {
                 /*
                  * $func_arg
                  * child
                  *  - email $xmlDoc->data->response->email->body;
                  *  - nick_name $xmlDoc->data->response->nickname->body;
                  *  - state $state
                  *  - enc_id $xmlDoc->data->response->enc_id->body;
                  *  - type $service
                  *  - profile $xmlDoc->data->response->profile_image->body
                  */
                 $funcarg = new stdClass();
                 $funcarg->email = $xmlDoc->data->response->email->body;
                 $funcarg->nick_name = $xmlDoc->data->response->nickname->body;
                 $funcarg->state = $state;
                 $funcarg->enc_id = $xmlDoc->data->response->enc_id->body;
                 $funcarg->type = $service;
                 $funcarg->profile = $xmlDoc->data->response->profile_image->body;
                 $_SESSION['loginxetemp_joindata'] = $funcarg;
                 return;
             }
         }
     } elseif ($service == 'github') {
         //받아온 인증키로 바로 회원 정보를 얻어옴
         $ping_url = 'https://api.github.com/user';
         $ping_header = array();
         $ping_header['Host'] = 'api.github.com';
         $ping_header['Pragma'] = 'no-cache';
         $ping_header['Accept'] = 'application/json';
         $ping_header['Authorization'] = sprintf("token %s", $token);
         $request_config = array();
         $request_config['ssl_verify_peer'] = false;
         $buff = FileHandler::getRemoteResource($ping_url, null, 10, 'GET', 'application/x-www-form-urlencoded', $ping_header, array(), array(), $request_config);
         //받아온 결과 파싱(JSON)
         $xmlDoc = json_decode($buff);
         if (!isset($xmlDoc->login)) {
             //연결도 못했다
             if (!$buff) {
                 return new Object(-1, 'Socket connection error. Check your Server Environment.');
             } else {
                 return new Object(-1, 'Error');
             }
         }
         //이후 처리는 2가지로 분기함
         if (Context::get('is_logged')) {
             //로그인되어 있으면 현재 로그인된 회원의 srl과 provider로 enc_id 검색
             //있으면 바로 리턴
             //없으면 연동처리만 해줌
             //srl과 type로 회원 조회
             $cond = new stdClass();
             $cond->srl = Context::get('logged_info')->member_srl;
             $cond->type = $service;
             $output = executeQuery('loginxeclient.getLoginxeclientMemberbySrl', $cond);
             if (isset($output->data->enc_id)) {
                 //리턴
                 return new Object(-1, 'loginxecli_already_registered');
             } else {
                 //연동시킴
                 $naver_member = new stdClass();
                 $naver_member->srl = Context::get('logged_info')->member_srl;
                 $naver_member->enc_id = md5($xmlDoc->id);
                 $naver_member->type = $service;
                 $output = executeQuery('loginxeclient.insertLoginxeclientMember', $naver_member);
                 if (!$output->toBool()) {
                     return new Object(-1, $output->message);
                 }
                 //$this->redirect_Url = getUrl('');
                 return new Object(-1, 'loginxecli_linksuccess');
             }
         } else {
             //로그인이 안되어 있다면 enc_id로 가입 여부 체크
             $cond = new stdClass();
             $cond->enc_id = md5($xmlDoc->id);
             $cond->type = $service;
             $output = executeQuery('loginxeclient.getLoginxeclientbyEncID', $cond);
             $config = $oMemberModel->getMemberConfig();
             //srl이 있다면(로그인 시도)
             if (isset($output->data->srl)) {
                 $member_Info = $oMemberModel->getMemberInfoByMemberSrl($output->data->srl);
                 if ($config->identifier == 'email_address') {
                     $oMemberController->doLogin($member_Info->email_address, '', false);
                 } else {
                     $oMemberController->doLogin($member_Info->user_id, '', false);
                 }
                 //회원정보 변경시 비밀번호 입력 없이 변경 가능하도록 수정
                 $_SESSION['rechecked_password_step'] = 'INPUT_DATA';
                 if ($config->after_login_url) {
                     $this->redirect_Url = $config->after_login_url;
                 }
                 $this->redirect_Url = getUrl('');
             } else {
                 /*
                  * $func_arg
                  * child
                  *  - email = $xmlDoc->email;
                  *  - nick_name = $xmlDoc->login;
                  *  - state $state
                  *  - enc_id md5($xmlDoc->id);
                  *  - type $service
                  *  - profile $xmlDoc->avatar_url
                  */
                 $funcarg = new stdClass();
                 $funcarg->email = $xmlDoc->email;
                 $funcarg->nick_name = $xmlDoc->login;
                 $funcarg->state = $state;
                 $funcarg->enc_id = md5($xmlDoc->id);
                 $funcarg->type = $service;
                 $funcarg->profile = $xmlDoc->avatar_url;
                 $_SESSION['loginxetemp_joindata'] = $funcarg;
                 return;
             }
         }
     } elseif ($service == 'xe') {
         return new Object(-1, sprintf(Context::getLang('loginxecli_not_supported_provider'), Context::getLang('loginxe_' . $service . '_provider')));
     } else {
         return new Object(-1, sprintf(Context::getLang('loginxecli_not_supported_provider'), Context::getLang('loginxe_unknown_provider')));
     }
     Context::set('url', $this->redirect_Url);
 }
 /**
  * @brief rss_url 의 정보를 구해서 return
  * title, homepage, rss_url
  **/
 function procLivexeGet()
 {
     $rss_url = Context::get('rss_url');
     if (!$rss_url) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (strpos($rss_url, '://') === false) {
         $rss_url = 'http://' . $rss_url;
     }
     $body = Context::convertEncodingStr(FileHandler::getRemoteResource($rss_url, null, 3, 'GET', 'application/xml', array('User-Agent' => 'liveXE ( ' . Context::getRequestUri() . ' )')));
     $body = $this->_checkAndCorrectEncodingInPI($body);
     $oXml = new XmlParser();
     $doc = $oXml->parse($body);
     if ($doc->rss->attrs->version == '2.0') {
         $this->add('title', $doc->rss->channel->title->body);
         $this->add('homepage', $doc->rss->channel->link->body);
         $this->add('rss_url', $rss_url);
     } elseif (preg_match('/atom/i', $doc->feed->attrs->xmlns)) {
         $this->add('title', $doc->feed->title->body);
         if (is_array($doc->feed->link)) {
             $this->add('homepage', $doc->feed->link[0]->attrs->href);
         } else {
             $this->add('homepage', $doc->feed->link->attrs->href);
         }
         $this->add('rss_url', $rss_url);
     } else {
         return new Object(-1, 'msg_not_supported_rss');
     }
 }
Example #21
0
 /**
 * Get the results from a bit.ly service interaction.
 *
 * @param string  $url    The URL to interact with, the action of the interaction
 *                        will be contained within the URL.
 * @param boolean $errors Passed by the errors() function and forces this function
 *						            to use json as the format.
 *
 * @return boolean True if everything has worked, otherwise false.
 */
 function getResult($bitlyurl, $errors = false)
 {
     if ($errors) {
         $tmpFormat = $this->format;
         $this->format = 'json';
     }
     if ($this->format == 'json') {
         $content = FileHandler::getRemoteResource($bitlyurl);
         $json = new Services_JSON_SocialXE();
         $results = $json->decode($content);
         // array로
         $results = $this->objectToArray($results);
     }
     if ($errors) {
         $this->format = $tmpFormat;
     }
     if ($results['statusCode'] != 'OK') {
         $this->errors = $results;
         return false;
     }
     if ($errors) {
         // Save everything in the results array
         $this->results = $results['results'];
     } else {
         // Save the first item in the results array
         $this->results = current($results['results']);
     }
     return true;
 }
 function ping($id, $type)
 {
     $oModuleModel = getModel('module');
     $config = $oModuleModel->getModuleConfig('syndication');
     if (!count($config->target_services)) {
         return;
     }
     if (substr($config->site_url, -1) != '/') {
         $config->site_url .= '/';
     }
     foreach ($config->target_services as $key => $val) {
         $ping_url = trim($this->services[$val]);
         if (!$ping_url) {
             continue;
         }
         $ping_body = sprintf('http://%s?module=syndication&act=getSyndicationList&id=%s&type=%s', $config->site_url, $id, $type);
         FileHandler::getRemoteResource($ping_url, null, 3, 'POST', 'application/x-www-form-urlencoded', array(), array(), array('link' => $ping_body));
     }
 }
Example #23
0
 /**
  * @brief rss 주소로 부터 내용을 받아오는 함수
  * tistory 의 경우 원본 주소가 location 헤더를 뿜는다. (내용은 없음)이를 해결하기 위한 수정 - rss_reader 위젯과 방식 동일
  **/
 function requestFeedContents($rss_url)
 {
     $rss_url = str_replace('&amp;', '&', Context::convertEncodingStr($rss_url));
     return FileHandler::getRemoteResource($rss_url, null, 3, 'GET', 'application/xml');
 }
Example #24
0
 /**
  * @brief 우체국 우편번호 API 검색 결과 반환
  * @param string $query
  * @return object
  */
 function getEpostapiSearch($query = '')
 {
     /**
      * @brief 문자열 인코딩 변환
      * @note 우체국 우편번호 API는 검색어를 EUC-KR로 넘겨주어야 함
      */
     $encoding = strtoupper(mb_detect_encoding($query));
     if ($encoding !== 'EUC-KR') {
         $query = iconv($encoding, 'EUC-KR', $query);
     }
     $module_config = $this->getConfig();
     $regkey = $module_config->epostapi_regkey;
     $fields = array('target' => 'postRoad', 'regkey' => $regkey, 'query' => $query);
     $headers = array('accept-language' => 'ko');
     $request_config = array('ssl_verify_peer' => FALSE);
     $buff = FileHandler::getRemoteResource(self::$epostapi_host, NULL, 30, 'POST', 'application/x-www-form-urlencoded', $headers, array(), $fields, $request_config);
     $oXmlParser = new XmlParser();
     $result = $oXmlParser->parse($buff);
     if ($result->error) {
         $err_msg = trim($result->error->message->body);
         if (!$err_msg) {
             $err_code = intval(str_replace('ERR-', '', $result->error->error_code->body));
             switch ($err_code) {
                 case 1:
                     $err_msg = 'msg_krzip_is_maintenance';
                     break;
                 case 2:
                     $err_msg = 'msg_krzip_wrong_regkey';
                     break;
                 case 3:
                     $err_msg = 'msg_krzip_no_result';
                     break;
                 default:
                     $err_msg = 'msg_krzip_riddling_wrong';
                     break;
             }
         }
         return new Object(-1, $err_msg);
     }
     if (!$result->post) {
         return new Object(-1, 'msg_krzip_riddling_wrong');
     }
     $item_list = $result->post->itemlist->item;
     if (!is_array($item_list)) {
         $item_list = array($item_list);
     }
     if (!$item_list) {
         return new Object(-1, 'msg_krzip_no_result');
     }
     $addr_list = array();
     foreach ($item_list as $key => $val) {
         $postcode = substr($val->postcd->body, 0, 3) . '-' . substr($val->postcd->body, 3, 3);
         $road_addr = $val->lnmaddress->body;
         $jibun_addr = $val->rnaddress->body;
         $addr_list[] = $this->getMigratedPostcode('(' . $postcode . ') (' . $jibun_addr . ') ' . $road_addr);
     }
     $output = new Object();
     $output->add('address_list', $addr_list);
     return $output;
 }
 /**
  * check this server can use rewrite module
  * make a file to files/config and check url approach by ".htaccess" rules
  *
  * @return bool
  */
 function checkRewriteUsable()
 {
     $checkString = "isApproached";
     $checkFilePath = 'files/config/tmpRewriteCheck.txt';
     FileHandler::writeFile(_XE_PATH_ . $checkFilePath, trim($checkString));
     $scheme = $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
     $hostname = $_SERVER['SERVER_NAME'];
     $port = $_SERVER['SERVER_PORT'];
     $str_port = '';
     if ($port) {
         $str_port = ':' . $port;
     }
     $tmpPath = $_SERVER['DOCUMENT_ROOT'];
     //if DIRECTORY_SEPARATOR is not /(IIS)
     if (DIRECTORY_SEPARATOR !== '/') {
         //change to slash for compare
         $tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']);
     }
     $query = "/JUST/CHECK/REWRITE/" . $checkFilePath;
     $currentPath = str_replace($tmpPath, "", _XE_PATH_);
     if ($currentPath != "") {
         $query = $currentPath . $query;
     }
     $requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query);
     $requestConfig = array();
     $requestConfig['ssl_verify_peer'] = false;
     $buff = FileHandler::getRemoteResource($requestUrl, null, 3, 'GET', null, array(), array(), array(), $requestConfig);
     FileHandler::removeFile(_XE_PATH_ . $checkFilePath);
     return trim($buff) == $checkString;
 }
 function ping($id, $type, $page = 1)
 {
     $this->ping_message = '';
     $oSyndicationModel = getModel('syndication');
     $oModuleModel = getModel('module');
     $config = $oModuleModel->getModuleConfig('syndication');
     if (!$config->syndication_token) {
         $this->ping_message = 'Syndication Token empty';
         $oSyndicationModel->setResentPingLog($this->ping_message);
         return false;
     }
     if (!$this->checkOpenSSLSupport()) {
         $lang = Context::get('lang');
         $this->ping_message = $lang->msg_need_openssl_support;
         $oSyndicationModel->setResentPingLog($this->ping_message);
         return false;
     }
     if (substr($config->site_url, -1) != '/') {
         $config->site_url .= '/';
     }
     $ping_url = 'https://apis.naver.com/crawl/nsyndi/v2';
     $ping_header = array();
     $ping_header['Host'] = 'apis.naver.com';
     $ping_header['Pragma'] = 'no-cache';
     $ping_header['Accept'] = '*/*';
     $ping_header['Authorization'] = sprintf("Bearer %s", $config->syndication_token);
     $request_config = array();
     $request_config['ssl_verify_peer'] = false;
     $ping_body = getNotEncodedFullUrl('', 'module', 'syndication', 'act', 'getSyndicationList', 'id', $id, 'type', $type, 'page', $page, 'syndication_password', $config->syndication_password);
     $buff = FileHandler::getRemoteResource($ping_url, null, 10, 'POST', 'application/x-www-form-urlencoded', $ping_header, array(), array('ping_url' => $ping_body), $request_config);
     $xml = new XmlParser();
     $xmlDoc = $xml->parse($buff);
     if ($xmlDoc->result->error_code->body != '000') {
         if (!$buff) {
             $this->ping_message = 'Socket connection error. Check your Server Environment.';
         } else {
             $this->ping_message = $xmlDoc->result->message->body;
         }
         $oSyndicationModel->setResentPingLog($this->ping_message);
         return false;
     }
     return true;
 }