/** * Builds the request string * * @access private * @return string The request string */ function _buildRequest() { $separator = ini_get('arg_separator.output'); ini_set('arg_separator.output', '&'); $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; ini_set('arg_separator.output', $separator); $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; $path = $this->_url->path . $querystring; $url = $host . $port . $path; if (!strlen($url)) { $url = '/'; } $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; if (in_array($this->_method, $this->_bodyDisallowed) || (0 == strlen($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || (empty($this->_postData) && empty($this->_postFiles))))) { $this->removeHeader('Content-Type'); } else { if (empty($this->_requestHeaders['content-type'])) { // Add default content-type $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); } } // Request Headers if (!empty($this->_requestHeaders)) { foreach ($this->_requestHeaders as $name => $value) { $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); $request .= $canonicalName . ': ' . $value . "\r\n"; } } // No post data or wrong method, so simply add a final CRLF if (in_array($this->_method, $this->_bodyDisallowed) || (HTTP_REQUEST_METHOD_POST != $this->_method && 0 == strlen($this->_body))) { $request .= "\r\n"; // Post data if it's an array } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && (!empty($this->_postData) || !empty($this->_postFiles))) { // "normal" POST request if (!isset($boundary)) { $postdata = implode('&', array_map( create_function('$a', 'return $a[0] . \'=\' . $a[1];'), $this->_flattenArray('', $this->_postData) )); // multipart request, probably with file uploads } else { $postdata = ''; if (!empty($this->_postData)) { $flatData = $this->_flattenArray('', $this->_postData); foreach ($flatData as $item) { $postdata .= '--' . $boundary . "\r\n"; $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; } } foreach ($this->_postFiles as $name => $value) { if (is_array($value['name'])) { $varname = $name . ($this->_useBrackets? '[]': ''); } else { $varname = $name; $value['name'] = array($value['name']); } foreach ($value['name'] as $key => $filename) { $fp = fopen($filename, 'r'); $data = fread($fp, filesize($filename)); fclose($fp); $basename = basename($filename); $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; $postdata .= '--' . $boundary . "\r\n"; $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; $postdata .= "\r\nContent-Type: " . $type; $postdata .= "\r\n\r\n" . $data . "\r\n"; } } $postdata .= '--' . $boundary . "--\r\n"; } $request .= 'Content-Length: ' . (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) . "\r\n\r\n"; $request .= $postdata; // Explicitly set request body } elseif (0 < strlen($this->_body)) { $request .= 'Content-Length: ' . (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) . "\r\n\r\n"; $request .= $this->_body; // Terminate headers with CRLF on POST request with no body, too } else { $request .= "\r\n"; } return $request; }
/** * Send a pingback. * * @param array $data (optional) An array of pingback data. * * @access public * @see autodiscover() */ function send($data = null) { if ($data !== null) { $res = $this->setFromArray($data); if (PEAR::isError($res)) { return $res; } } // Find the whether if source and target is equal or not. if (strstr($this->_data['sourceURI'], $this->_data['targetURI'])) { return PEAR::raiseError('Target URI is equal with source URI'); } // pingback URI set if (empty($this->_data['pingbackURI'])) { $res = Services_Pingback::autodiscover($this->_data['targetURI']); if (PEAR::isError($res)) { return $res; } else { if (empty($res)) { return PEAR::raiseError('Target URI is not a pingback-enabled resource'); } } $this->_data['pingbackURI'] = $res; } // Prepare an XML-RPC Message. $eArgs = array(XML_RPC_encode($this->_data['sourceURI']), XML_RPC_encode($this->_data['targetURI'])); $msg = new XML_RPC_Message('pingback.ping', $eArgs); // Prepare full path of URI to conforms XML_RPC_Client parameter. $url = new Net_URL($this->_data['pingbackURI']); $path = $url->path; $querystring = $url->getQueryString(); if (!empty($querystring)) { $path .= '?' . $querystring; } $cli = new XML_RPC_Client($path, $url->protocol . '://' . $url->host, $url->port); $cli->setDebug((int) $this->_options['debug']); // save the current error handling in buffer for restore. $default_error_mode = $GLOBALS['_PEAR_default_error_mode']; $default_error_options = $GLOBALS['_PEAR_default_error_options']; // Set error mode to callback, since XML_RPC doesn't return error object on failure. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'XML_RPC_ErrorCallback')); $res = $cli->send($msg, (int) $this->_options['timeout']); // Cacth the error if any. if ($this->_isXML_RPC_Error()) { return $this->_XML_RPC_Error; } $val = $res->value(); if (!is_object($val) || !is_a($val, 'XML_RPC_value')) { return PEAR::raiseError('Response Error: ' . $res->faultString()); } // restore the current error handling. PEAR::setErrorHandling($default_error_mode, $default_error_options); return XML_RPC_decode($val); }
/** * Page のプロセス(モバイル). * * FIXME スパゲッティ... * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); $conn = new SC_DBConn(); $objDb = new SC_Helper_DB_Ex(); //表示件数の選択 if (isset($_REQUEST['disp_number']) && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) { $this->disp_number = $_REQUEST['disp_number']; } else { //最小表示件数を選択 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); } //表示順序の保存 $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ""; // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); // タイトル編集 $tpl_subtitle = ""; $tpl_search_mode = false; if (!isset($_GET['mode'])) { $_GET['mode'] = ""; } if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } if (!isset($_GET['name'])) { $_GET['name'] = ""; } if (!isset($_REQUEST['orderby'])) { $_REQUEST['orderby'] = ""; } if (empty($arrCategory_id)) { $arrCategory_id = array("0"); } if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; $tpl_search_mode = true; } elseif (empty($arrCategory_id)) { $tpl_subtitle = "全商品"; } else { $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; } $objQuery = new SC_Query(); $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); // 以下の条件でBEST商品を表示する // ・BEST最大数の商品が登録されている。 // ・カテゴリIDがルートIDである。 // ・検索モードでない。 if ($count >= BEST_MIN && $this->lfIsRootCategory($arrCategory_id[0]) && $_GET['mode'] != 'search') { // 商品TOPの表示処理 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); $this->BEST_ROOP_MAX = ceil((BEST_MAX - 1) / 2); } else { if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0) { // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す $arrCategory_id = array(""); } // 商品一覧の表示処理 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']); // 検索条件を画面に表示 // カテゴリー検索条件 if (strlen($_GET['category_id']) == 0) { $arrSearch['category'] = "指定なし"; } else { $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($category_id)); $arrSearch['category'] = $arrCat; } // 商品名検索条件 if ($_GET['name'] === "") { $arrSearch['name'] = "指定なし"; } else { $arrSearch['name'] = $_GET['name']; } } if ($_POST['mode'] == "cart" && $_POST['product_id'] != "") { // 値の正当性チェック if (!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true); } else { // 入力値の変換 $this->arrErr = $this->lfCheckError($_POST['product_id']); if (count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id = "classcategory_id" . $_POST['product_id']; $classcategory_id1 = $_POST[$classcategory_id . '_1']; $classcategory_id2 = $_POST[$classcategory_id . '_2']; $quantity = "quantity" . $_POST['product_id']; // 規格1が設定されていない場合 if (!$this->tpl_classcat_find1[$_POST['product_id']]) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if (!$this->tpl_classcat_find2[$_POST['product_id']]) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id())); exit; } } } // ページ送り機能用のURLを作成する。 $objURL = new Net_URL($_SERVER['PHP_SELF']); foreach ($_REQUEST as $key => $value) { if ($key == session_name() || $key == 'pageno') { continue; } $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE)); } if ($this->objNavi->now_page > 1) { $objURL->addQueryString('pageno', $this->objNavi->now_page - 1); $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString(); } if ($this->objNavi->now_page < $this->objNavi->max_page) { $objURL->addQueryString('pageno', $this->objNavi->now_page + 1); $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString(); } $this->tpl_subtitle = $tpl_subtitle; $this->tpl_search_mode = $tpl_search_mode; // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $_POST; $this->category_id = $arrCategory_id[0]; $this->arrSearch = $arrSearch; $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl"; $objView->assignobj($this); $objView->display(SITE_FRAME); }