当前位置: 首页>>代码示例>>PHP>>正文


PHP PostToRemoteFileAndGetResponse函数代码示例

本文整理汇总了PHP中PostToRemoteFileAndGetResponse函数的典型用法代码示例。如果您正苦于以下问题:PHP PostToRemoteFileAndGetResponse函数的具体用法?PHP PostToRemoteFileAndGetResponse怎么用?PHP PostToRemoteFileAndGetResponse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PostToRemoteFileAndGetResponse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: FetchExchangeRate

		public function FetchExchangeRate($fromCode, $toCode)
		{
			// Can make a SOAP request but a REST (POST or GET) request is quicker
			// The fields to post
			$postFields = "FromCurrency=" . urlencode(strtoupper($fromCode)) . "&ToCurrency=" . urlencode(strtoupper($toCode));

			$rtn = PostToRemoteFileAndGetResponse($this->GetTargetURL(), $postFields);

			// If we have failed then there is nothing really useful you can tell the client other than this service is temporarly unavailable
			if (!$rtn) {
				$this->SetError(GetLang("CurrencyProviderRequestUnavailable"));
				return false;
			}

			// Now we parse the return XML. Its not a big XML result and we only need one value out of it so we don't need anything heavy to read it.
			// If the parsing failed or if we didn't receive a value then we wern't given a valid XML due to the code(s) being incorrect
			$xml = @simplexml_load_string($rtn);
			if(!is_object($xml)) {
				$this->SetError(GetLang("CurrencyProviderRequestInvalidCode"));
				return false;
			}

			if (empty($xml)) {
				return (double)$xml;
			} else {
				return (double)$xml[0];
			}
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:28,代码来源:module.webservicex.php

示例2: callServer

	/**
	* Actually connect to the server and call the requested methods, parsing the result
	* You should never have to call this public function manually
	*
	* This is an override of the MCAPI callServer method to use ISC's network code. Since it's now using ISC, the error codes produced may not match MCAPI documents.
	*
	* @param string $method
	* @param array $params
	* @param int $timeout
	* @return string|bool resulting response body on success, or false on failure
	*/
	public function callServer($method, $params, $timeout = self::MCAPI_TIMEOUT)
	{
		$dc = "us1";
		if (strstr($this->api_key,"-")){
			list($key, $dc) = explode("-",$this->api_key,2);
			if (!$dc) $dc = "us1";
		}
		$host = $dc.".".$this->apiUrl["host"];
		$params["apikey"] = $this->api_key;

		$this->errorMessage = "";
		$this->errorCode = "";

		$url = 'http';
		if ($this->secure) {
			$url .= 's';
		}
		$url .= '://' . $host . $this->apiUrl['path'] . '?' . $this->apiUrl['query'] . '&method=' . $method;

		$requestOptions = new Interspire_Http_RequestOptions;
		$requestOptions->userAgent = 'MCAPI/' . $this->version . ' (BigCommerce)';

		$response = PostToRemoteFileAndGetResponse($url, http_build_query($params), $timeout, $errno, $requestOptions);

		if (!$response) {
			$this->errorMessage = "Could not connect (" . $errno . ": " . GetLang('ISC_REMOTEFILE_ERROR_' . $errno) . ")";
			$this->errorCode = $errno;
			Interspire_Event::trigger('Interspire_EmailIntegration_MailChimp/error', array(
				'method' => $method,
				'params' => $params,
				'api' => $this,
			));
			return false;
		}

		if (ini_get("magic_quotes_runtime")) {
			$response = stripslashes($response);
		}

		$serial = unserialize($response);
		if($response && $serial === false) {
			$response = array("error" => "Bad Response.  Got This: " . $response, "code" => "-99");
		} else {
			$response = $serial;
		}
		if(is_array($response) && isset($response["error"])) {
			$this->errorMessage = $response["error"];
			$this->errorCode = $response["code"];
			Interspire_Event::trigger('Interspire_EmailIntegration_MailChimp/error', array(
				'method' => $method,
				'params' => $params,
				'api' => $this,
			));
			return false;
		}

		return $response;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:69,代码来源:MailChimp.php

示例3: GetVideoWalkthroughs

	/**
	 * Generate the list of video walkthroughs.
	 */
	public function GetVideoWalkthroughs()
	{
		$expires = 86400; // 24 hr

		$cacheFile = ISC_BASE_PATH.'/cache/feeds/dashboard-videos.xml';
		if(file_exists($cacheFile) && filemtime($cacheFile) > time() - $expires) {
			$videoContents = file_get_contents($cacheFile);
			$modified = filemtime($cacheFile);
		}
		else {
			$videoContents = PostToRemoteFileAndGetResponse(GetConfig('VideoWalkthroughFeed'));
			if($videoContents) {
				@file_put_contents($cacheFile, $videoContents);
			}
			$modified = time();
		}

		if(!$videoContents) {
			exit;
		}

		$xml = @simplexml_load_string($videoContents);
		if(!is_object($xml)) {
			exit;
		}

		$output = '';
		$this->template->Assign('Width', (int)$xml->width);
		$this->template->Assign('Height', (int)$xml->height);
		foreach($xml->video as $video) {
			$this->template->Assign('Title', isc_html_escape($video->title));
			$this->template->Assign('URL', isc_html_escape($video->url));
			if($_SERVER['HTTPS'] == 'on') {
				$video->preview = str_replace('http://', 'https://', $video->preview);
			}
			$this->template->Assign('Preview', isc_html_escape($video->preview));
			$output .= $this->template->render('Snippets/DashboardVideoWalkthroughItem.html');
		}

		header("Last-Modified: " . gmdate("r", $modified));
		header("Pragma: public");
		header("Cache-control: public,maxage=" . $expires);
		header("Expires: " . gmdate("r", $modified + $expires));

		echo $output;
		exit;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:50,代码来源:class.remote.dashboard.php

示例4: GetHashes

 /**
  * Get the list of hashes from the remote file
  *
  * @return void
  **/
 private function GetHashes()
 {
     if (!file_exists($this->cacheFile)) {
         $result = PostToRemoteFileAndGetResponse($this->hashUrl);
         if (strpos($result, 'init.php') === false) {
             return;
         }
         file_put_contents($this->cacheFile, $result);
         unset($result);
     }
     $lines = file($this->cacheFile);
     reset($lines);
     while (list($key, $line) = each($lines)) {
         list($hash, $file) = preg_split('#\\s+#', $line, 2, PREG_SPLIT_NO_EMPTY);
         $file = preg_replace('#^\\./#', ISC_BASE_PATH . '/', trim($file));
         $this->hashes[$file][] = $hash;
         unset($lines[$key]);
     }
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:24,代码来源:addon.verifyfiles.php

示例5: SendNotification

 /**
  * Send the order notification SMS text message
  */
 public function SendNotification()
 {
     // Load up the variables for the SMS gateway
     $this->_username = $this->GetValue("username");
     $this->_password = $this->GetValue("password");
     $this->_cellnumber = $this->GetValue("cellnumber");
     $this->_message = $this->BuildSmsMessage();
     $sms_url = sprintf("http://www.smsglobal.com.au/http-api.php?action=sendsms&user=%s&password=%s&from=%s&to=%s&clientcharset=UTF-8&text=%s", $this->_username, $this->_password, $this->_cellnumber, $this->_cellnumber, urlencode($this->_message));
     // Let's try to send the message
     $result = PostToRemoteFileAndGetResponse($sms_url);
     if (is_numeric(isc_strpos($result, "OK"))) {
         $result = array("outcome" => "success", "message" => sprintf(GetLang('SMSNotificationSentNumber'), $this->_cellnumber));
     } else {
         // The message couldn't be sent. Do they have enough credit?
         $low_balance = false;
         $bal_url = sprintf("http://www.smsglobal.com.au/http-api.php?action=balancesms&user=%s&password=%s", $this->_username, $this->_password);
         $bal_result = PostToRemoteFileAndGetResponse($bal_url);
         // SMSGlobal returns the balance in the format: BALANCE: 0.0999999; USER: johndoe
         $bal_data = explode(";", $bal_result);
         if (is_array($bal_data) && count($bal_data) > 1) {
             $bal_data_1 = explode(":", $bal_data[0]);
             if (is_array($bal_data_1)) {
                 $balance = floor((int) trim($bal_data_1[1]));
                 if ($balance == 0) {
                     $low_balance = true;
                 }
             }
         }
         if ($low_balance) {
             $error_message = GetLang('SMSZeroBalance');
         } else {
             $error_message = $bal_result;
         }
         $result = array("outcome" => "fail", "message" => $error_message);
     }
     return $result;
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:40,代码来源:module.sms.php

示例6: GetQuote

 private function GetQuote()
 {
     // The following array will be returned to the calling function.
     // It will contain at least one ISC_SHIPPING_QUOTE object if
     // the shipping quote was successful.
     $fx_quote = array();
     // Connect to FedEx to retrieve a live shipping quote
     $items = "";
     $result = "";
     $valid_quote = false;
     $fx_url = "https://gateway.fedex.com/GatewayDC";
     $weight = number_format(max(ConvertWeight($this->_weight, 'lbs'), 0.1), 1);
     // If we're shipping from US or Canada, originstate is required
     if (GetConfig('CompanyCountry') == "United States" || GetConfig('CompanyCountry') == "Canada") {
         $this->_originstate = GetStateISO2ByName(GetConfig('CompanyState'));
     }
     // If we're shipping to the US or Canada, deststate is required, otherwise it isn't - based off post codes
     if ($this->_destcountry != "US" && $this->_destcountry != "CA") {
         $this->_deststate = '';
     }
     if ($this->_ratetype == "account") {
         $listRate = "false";
     } else {
         $listRate = "true";
     }
     $fx_xml = sprintf("<" . "?" . "xml version=\"1.0\" encoding=\"UTF-8\" " . "?" . ">\n\t\t\t\t<FDXRateRequest xmlns:api=\"http://www.fedex.com/fsmapi\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FDXRateRequest.xsd\">\n\t\t\t\t\t<RequestHeader>\n\t\t\t\t\t\t<CustomerTransactionIdentifier>Express Rate</CustomerTransactionIdentifier>\n\t\t\t\t\t\t<AccountNumber>%s</AccountNumber>\n\t\t\t\t\t\t<MeterNumber>%s</MeterNumber>\n\t\t\t\t\t\t<CarrierCode>%s</CarrierCode>\n\t\t\t\t\t</RequestHeader>\n\t\t\t\t\t<DropoffType>%s</DropoffType>\n\t\t\t\t\t<Service>%s</Service>\n\t\t\t\t\t<Packaging>%s</Packaging>\n\t\t\t\t\t<WeightUnits>LBS</WeightUnits>\n\t\t\t\t\t<Weight>%s</Weight>\n\t\t\t\t\t<OriginAddress>\n\t\t\t\t\t\t<StateOrProvinceCode>%s</StateOrProvinceCode>\n\t\t\t\t\t\t<PostalCode>%s</PostalCode>\n\t\t\t\t\t\t<CountryCode>%s</CountryCode>\n\t\t\t\t\t</OriginAddress>\n\t\t\t\t\t<DestinationAddress>\n\t\t\t\t\t\t<StateOrProvinceCode>%s</StateOrProvinceCode>\n\t\t\t\t\t\t<PostalCode>%s</PostalCode>\n\t\t\t\t\t\t<CountryCode>%s</CountryCode>\n\t\t\t\t\t</DestinationAddress>\n\t\t\t\t\t<Payment>\n\t\t\t\t\t\t<PayorType>SENDER</PayorType>\n\t\t\t\t\t</Payment>\n\t\t\t\t\t<PackageCount>1</PackageCount>\n\t\t\t\t\t<ListRate>%s</ListRate>\n\t\t\t\t</FDXRateRequest>\n\t\t\t", $this->_accountno, $this->_meterno, $this->_carriercode, $this->_dropofftype, $this->_service, $this->_packagingtype, $weight, $this->_originstate, $this->_originzip, $this->_origincountry, $this->_deststate, $this->_destzip, $this->_destcountry, $listRate);
     $result = PostToRemoteFileAndGetResponse($fx_url, $fx_xml);
     if ($result === false) {
         $valid_quote = false;
     } else {
         $valid_quote = true;
         $xml = @simplexml_load_string($result);
     }
     if (!$valid_quote || !is_object($xml)) {
         $this->SetError(GetLang('FedExBadResponse') . ' ' . isc_html_escape(print_r($result, true)));
         return false;
     }
     $netCharge = 0;
     if ($this->_ratetype == "list" && isset($xml->EstimatedCharges->ListCharges->NetCharge)) {
         $netCharge = $xml->EstimatedCharges->ListCharges->NetCharge;
     } elseif ($this->_ratetype == "account" && isset($xml->EstimatedCharges->DiscountedCharges->NetCharge)) {
         $netCharge = $xml->EstimatedCharges->DiscountedCharges->NetCharge;
     }
     if ($netCharge != 0) {
         $serviceType = $this->_deliverytypes[$this->_deliverytype] . ", " . $this->_servicetypes[$this->_service];
         $quote = new ISC_SHIPPING_QUOTE($this->GetId(), $this->GetDisplayName(), (double) $netCharge, $serviceType);
         return $quote;
     } else {
         $Error = true;
         if (isset($xml->Error->Message)) {
             $this->SetError((string) $xml->Error->Message);
             return false;
         } else {
             $this->SetError(GetLang('FedExBadResponse') . ' ' . print_r($result, true));
             return false;
         }
     }
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:58,代码来源:module.fedex.php

示例7: VerifyOrderPayment

	public function VerifyOrderPayment()
	{
		if (empty($_POST['AccessPaymentCode'])) {
			return false;
		}

		$accessPaymentCode = $_POST['AccessPaymentCode'];

		$data = array(
			'CustomerID'		=> $this->GetValue('customerid'),
			'UserName'			=> $this->GetValue('username'),
			'AccessPaymentCode'	=> $accessPaymentCode,
		);

		$verifyUrl = $this->_ewayURL . 'Result?';
		$verifyUrl .= http_build_query($data);

		$response = PostToRemoteFileAndGetResponse($verifyUrl);

		if (empty($response)) {
			$this->logInvalidResponse($response);
			return false;
		}

		try {
			$xml = new SimpleXMLElement($response);
		}
		catch (Exception $ex) {
			$this->logInvalidResponse($response);
			return false;
		}

		$amount = (string)$xml->ReturnAmount;
		$orderId = (string)$xml->MerchantReference;
		$responseCode = (string)$xml->ResponseCode;
		$transactionId = (string)$xml->TrxnNumber;
		$transactionMessage = (string)$xml->TrxnResponseMessage;
		$transactionStatus = (string)$xml->TrxnStatus;
		$errorMessage = (string)$xml->ErrorMessage;

		$expectedAmount = number_format($this->GetGatewayAmount(), '2');

		$transactionLogDetails = array(
			'responseCode'		=> $responseCode,
			'transactionNumber'	=> $transactionId,
			'transactionMessage'=> $transactionMessage,
			'errorMessage'		=> $errorMessage,
		);

		// transaction failed or payment details don't match
		if ($transactionStatus == 'false' || $orderId != $this->GetCombinedOrderId() || $amount != $expectedAmount) {
			$GLOBALS['ISC_CLASS_LOG']->LogSystemError(
				array('payment', $this->GetName()),
				GetLang('EwayFailure', array('orderId' => $this->GetCombinedOrderId())),
				GetLang('EwayTransactionDetailsFailure', $transactionLogDetails)
			);

			$this->SetPaymentStatus(PAYMENT_STATUS_DECLINED);
			return false;
		}

		// set the payment status
		$updatedOrder = array(
			'ordpayproviderid' => $transactionId
		);

		$this->UpdateOrders($updatedOrder);

		$GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(
			array('payment', $this->GetName()),
			GetLang('EwaySuccess', array('orderId' => $this->GetCombinedOrderId())),
			GetLang('EwayTransactionDetailsSuccess', $transactionLogDetails)
		);
		$this->SetPaymentStatus(PAYMENT_STATUS_PAID);

		return true;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:77,代码来源:class.eway.hosted.php

示例8: SaveUpdatedMailSettings

 private function SaveUpdatedMailSettings()
 {
     $messages = array();
     if (isset($_POST['MailXMLPath']) && isset($_POST['MailXMLToken']) && isset($_POST['MailUsername'])) {
         $xml_path = $_POST['MailXMLPath'];
         $xml_token = $_POST['MailXMLToken'];
         $api_user = $_POST['MailUsername'];
         $xml = "<xmlrequest>\n\t\t\t\t\t\t\t<username>" . $api_user . "</username>\n\t\t\t\t\t\t\t<usertoken>" . $xml_token . "</usertoken>\n\t\t\t\t\t\t\t<requesttype>authentication</requesttype>\n\t\t\t\t\t\t\t<requestmethod>xmlapitest</requestmethod>\n\t\t\t\t\t\t\t<details>\n\t\t\t\t\t\t\t</details>\n\t\t\t\t\t\t</xmlrequest>";
         $xml = urlencode($xml);
         // Let's make sure the path is valid before enabling the XML API
         $result = PostToRemoteFileAndGetResponse($xml_path, "xml=" . $xml);
         $response = @simplexml_load_string($result);
         if (!is_object($response)) {
             $GLOBALS['MailXMLAPIValid'] = 0;
         }
         // We expect the response to contain SUCCESS - no point using XML to validate when we can do a string comparison
         if (is_numeric(isc_strpos(isc_strtoupper($result), "<STATUS>SUCCESS</STATUS>"))) {
             $GLOBALS['ISC_NEW_CFG']['MailXMLAPIValid'] = "1";
             $GLOBALS['ISC_NEW_CFG']['MailXMLPath'] = $_POST['MailXMLPath'];
             $GLOBALS['ISC_NEW_CFG']['MailXMLToken'] = $_POST['MailXMLToken'];
             $GLOBALS['ISC_NEW_CFG']['MailUsername'] = $_POST['MailUsername'];
         } else {
             $GLOBALS['ISC_NEW_CFG']['MailXMLAPIValid'] = "0";
             $GLOBALS['ISC_NEW_CFG']['MailXMLPath'] = "";
             $GLOBALS['ISC_NEW_CFG']['MailXMLToken'] = "";
             $GLOBALS['ISC_NEW_CFG']['MailUsername'] = "";
             $GLOBALS['ISC_NEW_CFG']['MailAutomaticallyTickNewsletterBox'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailAutomaticallyTickOrderBox'] = 0;
             // Was an error message returned?
             if (isset($response->errormessage)) {
                 $message = strval($response->errormessage);
                 if (isc_strtolower(trim($message)) != "invalid details") {
                     $messages[$message] = MSG_ERROR;
                 }
             }
         }
         // Are we capturing subscribers from the newsletter form?
         if (isset($_POST['UseMailAPIForNewsletters'])) {
             $GLOBALS['ISC_NEW_CFG']['UseMailerForNewsletter'] = 1;
             $GLOBALS['ISC_NEW_CFG']['MailNewsletterList'] = (int) $_POST['MailNewsletterList'];
             $GLOBALS['ISC_NEW_CFG']['MailNewsletterCustomField'] = (int) @$_POST['MailNewsletterCustomField'];
         } else {
             $GLOBALS['ISC_NEW_CFG']['UseMailerForNewsletter'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailNewsletterList'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailNewsletterCustomField'] = 0;
         }
         // Are we capturing subscribers for customers?
         if (isset($_POST['UseMailAPIForOrders'])) {
             $GLOBALS['ISC_NEW_CFG']['UseMailerForOrders'] = 1;
             $GLOBALS['ISC_NEW_CFG']['MailOrderList'] = (int) $_POST['MailOrderList'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderFirstName'] = (int) @$_POST['MailOrderFirstName'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderLastName'] = (int) @$_POST['MailOrderLastName'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderFullName'] = (int) @$_POST['MailOrderFullName'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderZip'] = (int) @$_POST['MailOrderZip'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderCountry'] = (int) @$_POST['MailOrderCountry'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderTotal'] = (int) @$_POST['MailOrderTotal'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderPaymentMethod'] = (int) @$_POST['MailOrderPaymentMethod'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderShippingMethod'] = (int) @$_POST['MailOrderShippingMethod'];
             $GLOBALS['ISC_NEW_CFG']['MailOrderListAutoSubscribe'] = (int) @$_POST['MailOrderListAutoSubscribe'];
         } else {
             $GLOBALS['ISC_NEW_CFG']['UseMailerForOrders'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderList'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderFirstName'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderLastName'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderFullName'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderZip'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderCountry'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderTotal'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderPaymentMethod'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderShippingMethod'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailOrderListAutoSubscribe'] = 0;
         }
         // Are we showing product updates?
         if (isset($_POST['UseMailAPIForUpdates'])) {
             $GLOBALS['ISC_NEW_CFG']['UseMailAPIForUpdates'] = 1;
             $GLOBALS['ISC_NEW_CFG']['MailProductUpdatesListType'] = $_POST['MailProductUpdatesListType'];
         } else {
             $GLOBALS['ISC_NEW_CFG']['UseMailAPIForUpdates'] = 0;
             $GLOBALS['ISC_NEW_CFG']['MailProductUpdatesListType'] = "";
         }
         // Update the settings
         if ($this->CommitSettings($messages)) {
             if (GetConfig('MailXMLAPIValid')) {
                 if ($GLOBALS['CurrentTab'] == 0) {
                     $success_var = "MailAPIInitSuccess";
                 } else {
                     $success_var = "MailAPIIntegrationSuccess";
                 }
                 // Log this action
                 $GLOBALS['ISC_CLASS_LOG']->LogAdminAction();
                 $messages = array_merge(array(GetLang($success_var) => MSG_SUCCESS), $messages);
                 foreach ($messages as $message => $type) {
                     FlashMessage($message, $type);
                 }
                 header("Location: index.php?ToDo=viewMailSettings");
                 exit;
             } else {
                 $GLOBALS['ISC_NEW_CFG']['MailXMLPath'] = $_POST['MailXMLPath'];
                 $GLOBALS['ISC_NEW_CFG']['MailXMLToken'] = $_POST['MailXMLToken'];
                 $GLOBALS['ISC_NEW_CFG']['MailUsername'] = $_POST['MailUsername'];
//.........这里部分代码省略.........
开发者ID:nirvana-info,项目名称:old_bak,代码行数:101,代码来源:class.settings_nov25.php

示例9: _LoadFeed

		/**
		*	Load up an RSS feed, parse its contents and return it.
		*/
		public function _LoadFeed($FeedURL, $NumEntries=0, $CacheTime=0, $FeedId="", $RSSFeedSnippet="", $helpLinks = false)
		{
			$reload = true;
			if($CacheTime > 0) {
				if($FeedId != "") {
					$FeedID = md5($FeedURL);
				}
				$reload = false;
				if(!is_dir(ISC_BASE_PATH."/cache/feeds")) {
					isc_mkdir(ISC_BASE_PATH."/cache/feeds/");
				}
				// Using a cached version that hasn't expired yet
				if(file_exists(ISC_BASE_PATH."/cache/feeds/".$FeedId) && filemtime(ISC_BASE_PATH."/cache/feeds/".$FeedId) > time()-$CacheTime) {
					$contents = file_get_contents(ISC_BASE_PATH."/cache/feeds/".$FeedId);
					// Cache was bad, recreate
					if(!$contents) {
						$reload = true;
					}
				}
				else {
					$reload = true;
				}
			}

			if ($reload === true) {
				$contents = PostToRemoteFileAndGetResponse($FeedURL);
				// Do we need to cache this version?
				if ($CacheTime > 0 && $contents != "") {
					@file_put_contents(ISC_BASE_PATH."/cache/feeds/".$FeedId, $contents);
				}
			}

			$output = "";
			$count = 0;

			// Could not load the feed, return an error
			if(!$contents) {
				return false;
			}


			// Silence errors to not polute out logs with peoples invalid XML feeds
			if($xml = @simplexml_load_string($contents)) {
				require_once(ISC_BASE_PATH . "/lib/xml.php");

				$rss = new ISC_XML();
				$entries = $rss->ParseRSS($xml);

				foreach($entries as $entry) {
					$GLOBALS['RSSTitle'] = $entry['title'];
					$GLOBALS['RSSDescription'] = $entry['description'];
					$GLOBALS['RSSLink'] = $entry['link'];

					if ($RSSFeedSnippet != "") {
						if ($helpLinks) {
							preg_match('#/questions/([0-9]+)/#si', $entry['link'], $matches);
							if (!empty($matches)) {
								$GLOBALS['RSSLink'] = $matches[1];
							}
						}
						if(defined('ISC_ADMIN_CP')) {
							$output .= Interspire_Template::getInstance('admin')->render('Snippets/'.$RSSFeedSnippet.'.html');
						}
						else {
							$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($RSSFeedSnippet);
						}
					} else {
						if(defined('ISC_ADMIN_CP')) {
							$output .= Interspire_Template::getInstance('admin')->render('Snippets/PageRSSItem.html');
						}
						else {
							$output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("PageRSSItem");
						}
					}

					if($NumEntries > 0 && ++$count >= $NumEntries) {
						break;
					}
				}

				return $output;
			}
			else {
				return false;
			}
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:89,代码来源:class.page.php

示例10: DownloadAddonZip

 /**
  * DownloadAddonZip
  * Download the zip file for the license and extract it
  *
  * @return Void
  */
 private function DownloadAddonZip()
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('addons');
     if (!isset($_REQUEST['key']) && !isset($_REQUEST['prodId'])) {
         exit;
     }
     if (isset($_REQUEST['prodId'])) {
         $url = GetConfig('AddonStreamURL') . '?prodId=' . (int) $_REQUEST['prodId'];
     } else {
         $key = $_REQUEST['key'];
         $url = GetConfig('AddonStreamURL') . '?key=' . str_replace("+", "%2B", urlencode($key)) . '&h=' . base64_encode(urlencode($_SERVER['HTTP_HOST']));
     }
     $zip = PostToRemoteFileAndGetResponse($url);
     if (strlen($zip) > 0) {
         // Save the zip file to a temporary file in the cache folder which is writable
         $cache_path = realpath(ISC_BASE_PATH . "/cache/");
         if (is_writable($cache_path)) {
             $temp_file = $cache_path . "/addon_" . rand(1, 100000) . ".zip";
             if ($fp = fopen($temp_file, "wb")) {
                 if (fwrite($fp, $zip)) {
                     fclose($fp);
                     // Is the addons folder writable?
                     $addon_path = realpath(ISC_BASE_PATH . "/addons/");
                     if (is_writable($addon_path)) {
                         // Try to extract the zip to the addons folder
                         Getlib('class.zip');
                         $archive = new PclZip($temp_file);
                         if ($archive->extract(PCLZIP_OPT_PATH, $addon_path) == 0) {
                             // The unzipping failed
                             echo GetLang("AddonUnzipFailed");
                         } else {
                             // The unzip was successful
                             echo "success";
                             $GLOBALS['ISC_CLASS_LOG']->LogAdminAction();
                         }
                         // Remove the temporary zip file
                         unlink($temp_file);
                     } else {
                         echo GetLang("AddonFolderNotWritable");
                     }
                 } else {
                     echo GetLang("AddonTempFolderNotWritable");
                 }
             } else {
                 echo GetLang("AddonTempFolderNotWritable");
             }
         } else {
             echo GetLang("AddonTempFolderNotWritable");
         }
     } else {
         echo GetLang("AddonDownloadZipFailed");
     }
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:59,代码来源:class.remote_dec04.php

示例11: PostToRemoteFileAndGetResponse

/**
 * XML API Example: Make sure the user has access to the API
 * Returns the user's ID if successful
 */
$xml = "<xmlrequest>\n\t\t<username>fred</username>\n\t\t<usertoken>9baa79a5871a2bdaac7b437a5b7275a8daff88d9</usertoken>\n\t\t<requesttype>authentication</requesttype>\n\t\t<requestmethod>xmlapitest</requestmethod>\n\t\t<details>\n\t\t</details>\n\t</xmlrequest>";
/**
 * XML API Example: Get a list of completed orders
 * where any field contains interspire.com
 */
$xml = "<xmlrequest>\n\t\t<username>fred</username>\n\t\t<usertoken>9baa79a5871a2bdaac7b437a5b7275a8daff88d9</usertoken>\n\t\t<requesttype>orders</requesttype>\n\t\t<requestmethod>GetOrders</requestmethod>\n\t\t<details>\n\t\t\t<searchQuery>@interspire.com</searchQuery>\n\t\t</details>\n\t</xmlrequest>";
/**
 * XML API Example: Get a list of completed orders
 * that were placed in the last week where the total
 * amount of the order is $200 or more and any field
 * contains the search phrase "seinfield"
 */
$xml = "<xmlrequest>\n\t\t<username>john</username>\n\t\t<usertoken>9baa79a5871a2bdaac7b437a5b7275a8daff88d9</usertoken>\n\t\t<requesttype>orders</requesttype>\n\t\t<requestmethod>GetOrders</requestmethod>\n\t\t<details>\n\t\t\t<dateRange>week</dateRange>\n\t\t\t<totalFrom>200</totalFrom>\n\t\t\t<searchQuery>seinfield</searchQuery>\n\t\t</details>\n\t</xmlrequest>";
/**
 * XML API Example: Get a list of customers from America where
 * any field contains "@interspire.com". Countries are defined
 * along with their numeric ID's in the countries table
 */
$xml = "<xmlrequest>\n\t\t<username>fred</username>\n\t\t<usertoken>9baa79a5871a2bdaac7b437a5b7275a8daff88d9</usertoken>\n\t\t<requesttype>customers</requesttype>\n\t\t<requestmethod>GetCustomers</requestmethod>\n\t\t<details>\n\t\t\t\t<searchQuery>@interspire.com</searchQuery>\n\t\t\t\t<country>226</country>\n\t\t</details>\n\t</xmlrequest>";
/**
 * XML API Example: Get a list of products where the product name contains the
 * word "laserjet" and the price is under $1,000
 */
$xml = "<xmlrequest>\n\t\t<username>admin</username>\n\t\t<usertoken>a6e1efb0f8b737dc92801e9cbe0b355482af1c94</usertoken>\n\t\t<requesttype>products</requesttype>\n\t\t<requestmethod>GetProducts</requestmethod>\n\t\t<details>\n\t\t\t<priceTo>1000</priceTo>\n\t\t</details>\n\t</xmlrequest>";
//header("Content-Type:text/xml");
echo PostToRemoteFileAndGetResponse("http://127.0.0.1/xml.php", $xml);
开发者ID:nirvana-info,项目名称:old_bak,代码行数:30,代码来源:example.php

示例12: GetTrialLicenseKey

 /**
  * Retrieve a license key for a trial installation of Interspire Shopping Cart.
  *
  * @return string The license key.
  */
 private function GetTrialLicenseKey()
 {
     // Already tried to install, no need to fetch the license key again
     if (isset($_SESSION['LK' . md5(strtolower($_POST['ShopPath']))])) {
         return $_SESSION['LK' . md5(strtolower($_POST['ShopPath']))];
     }
     // First we need to fetch the license key from Interspire
     $licenseRequest = array('licenserequest' => array('product' => 'isc', 'customer' => array('name' => $_POST['FullName'], 'email' => $_POST['UserEmail'], 'url' => $_POST['ShopPath'], 'phone' => $_POST['PhoneNumber'], 'country' => GetCSVCountryNameById($_POST['StoreCountryLocationId'])), 'aps' => 'true'));
     // Send the XML request off to the remote server
     $licenseUrl = 'http://partner.interspire.com/gettriallicense.php';
     // Send the XML request off to the remote server
     $response = PostToRemoteFileAndGetResponse($licenseUrl, $this->BuildXMLFromArray($licenseRequest));
     $xml = @simplexml_load_string($response);
     if ($response === false || !is_object($xml)) {
         $this->ShowInstallErrors('There was a problem communicating with the Interspire licensing server. Please try again in a few moments.', $errors, false, false);
         exit;
     }
     // Got a valid license key
     if ($xml->status == "OK") {
         $_SESSION['LK' . md5(strtolower($_POST['ShopPath']))] = (string) $xml->licensekey;
         return (string) $xml->licensekey;
     } else {
         $this->ShowInstallErrors('There was a problem retrieving your license key. Please try again in a few moments. (Error: ' . $xml->error . ')', $errors, false, false);
         exit;
     }
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:31,代码来源:class.install.php

示例13: GetQuote

		private function GetQuote()
		{

			// The following array will be returned to the calling function.
			// It will contain at least one ISC_SHIPPING_QUOTE object if
			// the shipping quote was successful.

			$cp_quote = array();

			// Connect to Canada Post to retrieve a live shipping quote
			$items = "";
			$result = "";
			$valid_quote = false;
			$cp_url = "http://sellonline.canadapost.ca:30000?";
			$readytoship = '';
			if($this->_readytoship == 'yes') {
				$readytoship = "<readyToShip/>";
			}

			foreach($this->_products as $product) {
				$items .= sprintf("<item>
								<quantity>%d</quantity>
								<weight>%s</weight>
								<length>%s</length>
								<width>%s</width>
								<height>%s</height>
								<description><![CDATA[%s]]></description>
								%s
						</item>",
						$product->getquantity(),
						ConvertWeight($product->GetWeight(), 'kgs'),
						ConvertLength($product->getlength(), "cm"),
						ConvertLength($product->getwidth(), "cm"),
						ConvertLength($product->getheight(), "cm"),
						$product->getdesc(),
						$readytoship
						);
			}

			$cp_xml = sprintf("<" . "?" . "xml version=\"1.0\" ?" . ">
				<eparcel>
						<language>en</language>
						<ratesAndServicesRequest>
								<merchantCPCID>%s</merchantCPCID>
								<fromPostalCode>%s</fromPostalCode>
								<lineItems>
									%s
							   </lineItems>
								<city></city>
								<provOrState>%s</provOrState>
								<country>%s</country>
								<postalCode>%s</postalCode>
						</ratesAndServicesRequest>
				</eparcel>
			", $this->_merchantid, $this->_origin_zip, $items, $this->_deststate, isc_strtoupper($this->_destcountry), $this->_destzip);

			$post_vars = implode("&",
			array("XMLRequest=$cp_xml"
				)
			);

			$result = PostToRemoteFileAndGetResponse($cp_url, $post_vars);
			if($result) {
				$valid_quote = true;
			}

			if(!$valid_quote) {
				$this->SetError(GetLang('CanadaPostOpenError'));
				return false;
			}
			$xml = @simplexml_load_string($result);

			if(!is_object($xml)) {
				$this->SetError(GetLang('CanadaPostBadResponse'));
				return false;
			}

			if(isset($xml->error)) {
				$this->SetError((string)$xml->error->statusMessage);
				return false;
			}

			if(isset($xml->ratesAndServicesResponse)) {
				foreach($xml->ratesAndServicesResponse->product as $ship_method) {
					// Calculate the transit time
					$transit_time = -1;

					$today = $ship_method->shippingDate;
					$arr_today = explode("-", $today);
					$today_stamp = mktime(0, 0, 0, $arr_today[1], $arr_today[2], $arr_today[0]);

					$delivered = $ship_method->deliveryDate;
					$arr_delivered = explode("-", $delivered);

					if(count($arr_delivered) == 3) {
						$delivered_stamp = mktime(0, 0, 0, $arr_delivered[1], $arr_delivered[2], $arr_delivered[0]);
						$transit_time = $delivered_stamp - $today_stamp;

						// Convert transit time to days
						$transit_time = floor($transit_time/60/60/24);
//.........这里部分代码省略.........
开发者ID:hungnv0789,项目名称:vhtm,代码行数:101,代码来源:module.canadapost.php

示例14: GetDownloadableAddons

    /**
     * GetDownloadableAddons
     * Query Interspire.com for a list of available addons
     *
     * @param Array $ExistingAddons An array of addons which have already been installed
     * @return String
     */
    public function GetDownloadableAddons($ExistingAddons)
    {
        $result = PostToRemoteFileAndGetResponse(GetConfig('AddonXMLFile'));
        $xml = new SimpleXMLElement($result);
        $output = "";
        foreach ($xml->addon as $addon) {
            // Have they already downloaded this addon?
            if (!in_array(str_replace("isc_", "", $addon->prodCode), $ExistingAddons)) {
                if ((int) $addon->prodPrice == 0) {
                    $button_text = GetLang("DownloadAddonFree");
                } else {
                    $button_text = sprintf(GetLang("DownloadAddonPaid"), number_format($addon->prodPrice));
                }
                $output .= sprintf('<div style="text-align: center; float:left; margin-right:10px">
									<a href="%s" target="_blank"><img src="%s" width="200" height="92" border="0" /></a>
									<div style="padding-top:10px; width:250px">
										%s (<a target="_blank" href="%s">%s</a>)<br /><br />
										<input type="button" value="%s" onclick="tb_show(\'\', \'index.php?ToDo=purchaseDownloadAddons&prodId=%d&prodPrice=%s&width=300&height=255\')" /><br />
									</div>
								</div>', $addon->prodAddonLink, $addon->prodAddonLogo, $addon->prodAddonSummary, $addon->prodAddonLink, GetLang("AddonMoreInfo"), $button_text, $addon->pk_prodId, $addon->prodPrice);
            }
        }
        return $output;
    }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:31,代码来源:class.downloadaddons.php

示例15: retriveInstallScripts

	/**
	* Retrive the GWO Scripts from Google and save in an array
	*
	* @param string $path, the Google install script path
	* @param string $errorMessage
	*
	* return array
	*/
	private function retriveInstallScripts($path, &$errorMessage)
	{
		$resultXml = PostToRemoteFileAndGetResponse($path);
		if(!$resultXml) {
			$errorMessage = GetLang('ProblemRetrivingScript');
			return array();
		}
		$result = @simplexml_load_string($resultXml);
		$result = (array) $result;

		$scripts = array();
		if(isset($result['install-scripts'])) {
			foreach($result['install-scripts'] as $scriptName => $script) {
				//if it's a shared ssl, it's a cross domain tracking
				if(GetConfig('UseSSL') == 2) {
					switch($scriptName) {
						case 'control-script':
							$script = '<script>_udn = "none";</script>'.$script;
							break;
						case 'test-tracking-script':
						case 'goal-tracking-script':
							$replaceString = 'gwoTracker._setDomainName("none");
gwoTracker._setAllowLinker(true);
gwoTracker._trackPageview';

							$script = str_replace('gwoTracker._trackPageview', $replaceString, $script);
							break;
					}
				}
				$scripts[$scriptName] = trim((string)$script);
			}
		}

		// check if the scripts we need are saved in the array,
		if(empty($scripts)) {
			$errorMessage = GetLang('ProblemRetrivingScript');
			return array();
		}
		return $scripts;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:48,代码来源:class.remote.optimizer.php


注:本文中的PostToRemoteFileAndGetResponse函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。