Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Swoole; use Swoole\Client\CURL; class URL { const CACHE_LIFETIME = 3..
Decoded Output download
<?php
namespace Swoole;
use Swoole\Client\CURL;
class URL
{
const CACHE_LIFETIME = 300;
const CACHE_KEY_PREFIX = 'swoole_urlcache_';
public $config;
public $info;
/**
* @var CURL
*/
protected $_curl;
function __construct($config)
{
if (empty($config) or empty($config['url']))
{
throw new \Exception("require url.");
}
if (!empty($config['cache']))
{
if (empty($config['lifetime']))
{
$config['lifetime'] = self::CACHE_LIFETIME;
}
}
$this->_curl = new CURL(!empty($config['debug']));
$this->config = $config;
if (!empty($config['setting']))
{
foreach($config['setting'] as $k => $v)
{
call_user_func_array(array($this->_curl, 'set'.ucfirst($k)), $v);
}
}
}
function get($params = null, $cache_id = '')
{
$url = $this->config['url'];
if ($params)
{
if (Tool::endchar($url) == '&')
{
$url .= http_build_query($params);
}
else
{
$url .= '?' . http_build_query($params);
}
}
if (!empty($this->config['cache']))
{
if (empty($cache_id)) $cache_id = md5($url);
$cache_key = self::CACHE_KEY_PREFIX.$cache_id;
$result = \Swoole::$php->cache->get($cache_key);
if ($result)
{
return $result;
}
}
$result = $this->_curl->get($url);
if ($result and $this->_curl->info['http_code'] == 200)
{
if (!empty($this->config['json']))
{
$result = json_decode($result, true);
}
elseif (!empty($this->config['serialize']))
{
$result = unserialize($result);
}
if (!empty($this->config['cache']))
{
\Swoole::$php->cache->set($cache_key, $result, $this->config['lifetime']);
}
}
$this->info = $this->_curl->info;
return $result;
}
function post($data)
{
$this->_curl->post($this->config['url'], $data);
}
} ?>
Did this file decode correctly?
Original Code
<?php
namespace Swoole;
use Swoole\Client\CURL;
class URL
{
const CACHE_LIFETIME = 300;
const CACHE_KEY_PREFIX = 'swoole_urlcache_';
public $config;
public $info;
/**
* @var CURL
*/
protected $_curl;
function __construct($config)
{
if (empty($config) or empty($config['url']))
{
throw new \Exception("require url.");
}
if (!empty($config['cache']))
{
if (empty($config['lifetime']))
{
$config['lifetime'] = self::CACHE_LIFETIME;
}
}
$this->_curl = new CURL(!empty($config['debug']));
$this->config = $config;
if (!empty($config['setting']))
{
foreach($config['setting'] as $k => $v)
{
call_user_func_array(array($this->_curl, 'set'.ucfirst($k)), $v);
}
}
}
function get($params = null, $cache_id = '')
{
$url = $this->config['url'];
if ($params)
{
if (Tool::endchar($url) == '&')
{
$url .= http_build_query($params);
}
else
{
$url .= '?' . http_build_query($params);
}
}
if (!empty($this->config['cache']))
{
if (empty($cache_id)) $cache_id = md5($url);
$cache_key = self::CACHE_KEY_PREFIX.$cache_id;
$result = \Swoole::$php->cache->get($cache_key);
if ($result)
{
return $result;
}
}
$result = $this->_curl->get($url);
if ($result and $this->_curl->info['http_code'] == 200)
{
if (!empty($this->config['json']))
{
$result = json_decode($result, true);
}
elseif (!empty($this->config['serialize']))
{
$result = unserialize($result);
}
if (!empty($this->config['cache']))
{
\Swoole::$php->cache->set($cache_key, $result, $this->config['lifetime']);
}
}
$this->info = $this->_curl->info;
return $result;
}
function post($data)
{
$this->_curl->post($this->config['url'], $data);
}
}
Function Calls
None |
Stats
MD5 | baca101d31c8b41efb683f67d7e1ec93 |
Eval Count | 0 |
Decode Time | 100 ms |