本文整理汇总了PHP中AO::getVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP AO::getVersion方法的具体用法?PHP AO::getVersion怎么用?PHP AO::getVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AO
的用法示例。
在下文中一共展示了AO::getVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getHandle
/**
* Retrieve Resource file handle (socket, file pointer etc)
*
* @return resource
*/
protected function _getHandle()
{
if (!$this->_resourceFile) {
AO::throwException(AO::helper('downloadable')->__('Please set resource file and link type'));
}
if (is_null($this->_handle)) {
if ($this->_linkType == self::LINK_TYPE_URL) {
$port = 80;
/**
* Validate URL
*/
$urlProp = parse_url($this->_resourceFile);
if (!isset($urlProp['scheme']) || strtolower($urlProp['scheme'] != 'http')) {
AO::throwException(AO::helper('downloadable')->__('Invalid download URL scheme'));
}
if (!isset($urlProp['host'])) {
AO::throwException(AO::helper('downloadable')->__('Invalid download URL host'));
}
$hostname = $urlProp['host'];
if (isset($urlProp['port'])) {
$port = (int) $urlProp['port'];
}
$path = '/';
if (isset($urlProp['path'])) {
$path = $urlProp['path'];
}
$query = '';
if (isset($urlProp['query'])) {
$query = '?' . $urlProp['query'];
}
try {
$this->_handle = fsockopen($hostname, $port, $errno, $errstr);
} catch (Exception $e) {
throw $e;
}
if ($this->_handle === false) {
AO::throwException(AO::helper('downloadable')->__('Can\'t connect to remote host, error: %s', $errstr));
}
$headers = 'GET ' . $path . $query . ' HTTP/1.0' . "\r\n" . 'Host: ' . $hostname . "\r\n" . 'User-Agent: Magento ver/' . AO::getVersion() . "\r\n" . 'Connection: close' . "\r\n" . "\r\n";
fwrite($this->_handle, $headers);
while (!feof($this->_handle)) {
$str = fgets($this->_handle, 1024);
if ($str == "\r\n") {
break;
}
$match = array();
if (preg_match('#^([^:]+): (.*)\\s+$#', $str, $match)) {
$k = strtolower($match[1]);
if ($k == 'set-cookie') {
continue;
} else {
$this->_urlHeaders[$k] = trim($match[2]);
}
} elseif (preg_match('#^HTTP/[0-9\\.]+ (\\d+) (.*)\\s$#', $str, $match)) {
$this->_urlHeaders['code'] = $match[1];
$this->_urlHeaders['code-string'] = trim($match[2]);
}
}
if (!isset($this->_urlHeaders['code']) || $this->_urlHeaders['code'] != 200) {
AO::throwException(AO::helper('downloadable')->__('Sorry, the was an error getting requested content. Please contact store owner.'));
}
} elseif ($this->_linkType == self::LINK_TYPE_FILE) {
$this->_handle = new Varien_Io_File();
$this->_handle->open(array('path' => AO::getBaseDir('var')));
if (!$this->_handle->fileExists($this->_resourceFile, true)) {
AO::throwException(AO::helper('downloadable')->__('File does not exists'));
}
$this->_handle->streamOpen($this->_resourceFile, 'r');
} else {
AO::throwException(AO::helper('downloadable')->__('Invalid download link type'));
}
}
return $this->_handle;
}