Changeset 21734 for branches/version-2_12-dev/data/class/api
- Timestamp:
- 2012/04/11 02:58:27 (14 years ago)
- Location:
- branches/version-2_12-dev/data/class/api
- Files:
-
- 3 edited
-
SC_Api_Abstract.php (modified) (1 diff)
-
SC_Api_Operation.php (modified) (12 diffs)
-
SC_Api_Utils.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/api/SC_Api_Abstract.php
r21713 r21734 106 106 $this->objFormParam->convParam(); 107 107 $this->arrErr = $this->objFormParam->checkError(false); 108 $this->arrErr = array_merge( (array)$this->arrErr, (array)$this->checkErrorExtended($arrParam));108 $this->arrErr = array_merge((array)$this->arrErr, (array)$this->checkErrorExtended($arrParam)); 109 109 return $this->objFormParam->getHashArray(); 110 110 } -
branches/version-2_12-dev/data/class/api/SC_Api_Operation.php
r21722 r21734 98 98 protected function checkReferer() { 99 99 $ret = false; 100 if (!SC_Utils_Ex::isBlank($_SERVER['HTTP_REFERER'])) {100 if (!SC_Utils_Ex::isBlank($_SERVER['HTTP_REFERER'])) { 101 101 $domain = SC_Utils_Ex::sfIsHTTPS() ? HTTPS_URL : HTTP_URL; 102 102 $pattern = sprintf('|^%s.*|', $domain); … … 144 144 // Refer: https://images-na.ssl-images-amazon.com/images/G/09/associates/paapi/dg/index.html?Query_QueryAuth.html 145 145 $check_str = ''; 146 foreach ($arrParam as $key => $val) {146 foreach ($arrParam as $key => $val) { 147 147 switch ($key) { 148 148 case 'Signature': … … 159 159 . $check_str; 160 160 $signature = base64_encode(hash_hmac('sha256', $check_str, $secret_key, true)); 161 if ($signature === $arrParam['Signature']) {161 if ($signature === $arrParam['Signature']) { 162 162 return true; 163 163 } … … 206 206 return false; 207 207 } 208 $arrAuthTypes = explode( "|", $arrApiConfig['auth_types']);208 $arrAuthTypes = explode('|', $arrApiConfig['auth_types']); 209 209 $result = false; 210 210 foreach ($arrAuthTypes as $auth_type) { … … 249 249 break; 250 250 } 251 if ($ret === true) {251 if ($ret === true) { 252 252 $result = true; 253 } else{253 } else { 254 254 $result = false; 255 255 break; // 1つでもfalseがあれば,その時点で終了 … … 277 277 * 278 278 * @param array $arrPost リクエストパラメーター 279 * @return array( string レスポンス名, array レスポンス配列)279 * @return array(string レスポンス名, array レスポンス配列) 280 280 */ 281 281 public function doApiAction($arrPost) { … … 313 313 314 314 // オペレーション結果処理 315 if ($operation_result) {315 if ($operation_result) { 316 316 $arrOperationRequestValid = $objApiOperation->getRequestValidate(); 317 317 $arrResponseBody = $objApiOperation->getResponseArray(); 318 318 $response_group_name = $objApiOperation->getResponseGroupName(); 319 } else{319 } else { 320 320 $arrErr = $objApiOperation->getErrorArray(); 321 321 } 322 } else{322 } else { 323 323 $arrErr['ECCUBE.Operation.NoLoad'] = 'オペレーションをロード出来ませんでした。'; 324 324 } 325 } else{325 } else { 326 326 $arrErr['ECCUBE.Authority.NoAuthority'] = 'オペレーションの実行権限がありません。'; 327 327 } … … 330 330 if (count($arrErr) == 0) { 331 331 // 実行成功 332 $arrResponseValidSection = array( 'Request' => array(332 $arrResponseValidSection = array('Request' => array( 333 333 'IsValid' => 'True', 334 334 $operation_name . 'Request' => $arrOperationRequestValid … … 343 343 $arrResponseErrorSection[] = array('Code' => $error_code, 'Message' => $error_msg); 344 344 } 345 $arrResponseValidSection = array( 'Request' => array(345 $arrResponseValidSection = array('Request' => array( 346 346 'IsValid' => 'False', 347 347 'Errors' => array('Error' => $arrResponseErrorSection) … … 350 350 if (is_object($objApiOperation)) { 351 351 $response_outer = $operation_name . 'Response'; 352 } else{352 } else { 353 353 $response_outer = 'ECCUBEApiCommonResponse'; 354 354 } … … 381 381 'Arguments' => array(), 382 382 ); 383 foreach ($arrParam as $key => $val) {383 foreach ($arrParam as $key => $val) { 384 384 $arrRet['Arguments'][] = array('_attributes' => array('Name' => htmlentities($key, ENT_NOQUOTES, 'UTF-8'), 'Value' => htmlentities($val, ENT_NOQUOTES, 'UTF-8'))); 385 385 } … … 390 390 // TODO: ここらへんは SC_Displayに持って行きたい所だが・・ 391 391 public function sendApiResponse($type, $response_outer_name, &$arrResponse) { 392 switch ($type) {392 switch ($type) { 393 393 case 'xml': 394 394 SC_Api_Utils_Ex::sendResponseXml($response_outer_name, $arrResponse); -
branches/version-2_12-dev/data/class/api/SC_Api_Utils.php
r21722 r21734 29 29 * @version $Id$ 30 30 */ 31 define('API_UPLOAD_REALDIR', DATA_REALDIR . "downloads/api/");32 define('API_CLASS_EX_REALDIR', CLASS_EX_REALDIR . "api_extends/operations/");33 define('API_CLASS_REALDIR', CLASS_REALDIR . "api/operations/");31 define('API_UPLOAD_REALDIR', DATA_REALDIR . 'downloads/api/'); 32 define('API_CLASS_EX_REALDIR', CLASS_EX_REALDIR . 'api_extends/operations/'); 33 define('API_CLASS_REALDIR', CLASS_REALDIR . 'api/operations/'); 34 34 35 35 class SC_Api_Utils { … … 159 159 // Core API ディレクトリ 160 160 if (is_dir(API_CLASS_EX_REALDIR)) { 161 if ($dh = opendir(API_CLASS_EX_REALDIR)) {161 if ($dh = opendir(API_CLASS_EX_REALDIR)) { 162 162 while (($file_name = readdir($dh)) !== false) { 163 163 if ($file_name != '.' && $file_name != '..' && substr($file_name, -4) == '.php') { … … 171 171 // downaloads APIディレクトリ (for Plugin) 172 172 if (is_dir(API_UPLOAD_REALDIR)) { 173 if ($dh = opendir(API_UPLOAD_REALDIR)) {173 if ($dh = opendir(API_UPLOAD_REALDIR)) { 174 174 while (($file_name = readdir($dh)) !== false) { 175 175 if ($file_name != '.' && $file_name != '..' && substr($file_name, -4) == '.php') { … … 206 206 'encoding' => 'UTF-8', 207 207 'rootName' => $response_outer_name, 208 'rootAttributes' => array( 'xmlns' => self::API_XMLNS . ECCUBE_VERSION,208 'rootAttributes' => array('xmlns' => self::API_XMLNS . ECCUBE_VERSION, 209 209 'xml:lang' => self::API_XML_LANG), 210 210 'defaultTagName' => 'Response',
Note: See TracChangeset
for help on using the changeset viewer.
