add proxy to connection
This commit is contained in:
parent
e3ec8b18fa
commit
ee2e67f490
@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||||
|
* using proxy, add this variable in config.php
|
||||||
|
* $http_proxy = '127.0.0.1:3128';
|
||||||
|
* if proxy using authentication, use this parameter
|
||||||
|
* $http_proxyauth = 'user:password';
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class Http
|
class Http
|
||||||
{
|
{
|
||||||
public static function getData($url, $headers = [])
|
public static function getData($url, $headers = [])
|
||||||
{
|
{
|
||||||
|
global $http_proxy,$http_proxyauth;
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_POST, 0);
|
curl_setopt($ch, CURLOPT_POST, 0);
|
||||||
@ -15,13 +20,23 @@ class Http
|
|||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
if(!empty($http_proxy)){
|
||||||
|
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
|
||||||
|
if(!empty($http_proxyauth)){
|
||||||
|
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth);
|
||||||
|
}
|
||||||
|
}
|
||||||
$server_output = curl_exec($ch);
|
$server_output = curl_exec($ch);
|
||||||
|
if (curl_errno($ch)) {
|
||||||
|
$error_msg = curl_error($ch);
|
||||||
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return $server_output;
|
return ($server_output) ? $server_output : $error_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function postJsonData($url, $array_post, $headers = [], $basic = null)
|
public static function postJsonData($url, $array_post, $headers = [], $basic = null)
|
||||||
{
|
{
|
||||||
|
global $http_proxy,$http_proxyauth;
|
||||||
$headers[] = 'Content-Type: application/json';
|
$headers[] = 'Content-Type: application/json';
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@ -30,6 +45,12 @@ class Http
|
|||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||||
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
||||||
|
if(!empty($http_proxy)){
|
||||||
|
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
|
||||||
|
if(!empty($http_proxyauth)){
|
||||||
|
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth);
|
||||||
|
}
|
||||||
|
}
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array_post));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array_post));
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
if (!empty($basic)) {
|
if (!empty($basic)) {
|
||||||
@ -37,13 +58,17 @@ class Http
|
|||||||
}
|
}
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$server_output = curl_exec($ch);
|
$server_output = curl_exec($ch);
|
||||||
|
if (curl_errno($ch)) {
|
||||||
|
$error_msg = curl_error($ch);
|
||||||
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return $server_output;
|
return ($server_output) ? $server_output : $error_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function postData($url, $array_post, $headers = [], $basic = null)
|
public static function postData($url, $array_post, $headers = [], $basic = null)
|
||||||
{
|
{
|
||||||
|
global $http_proxy,$http_proxyauth;
|
||||||
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@ -52,6 +77,12 @@ class Http
|
|||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||||
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
||||||
|
if(!empty($http_proxy)){
|
||||||
|
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
|
||||||
|
if(!empty($http_proxyauth)){
|
||||||
|
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $http_proxyauth);
|
||||||
|
}
|
||||||
|
}
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_post));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_post));
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
if (!empty($basic)) {
|
if (!empty($basic)) {
|
||||||
@ -59,7 +90,10 @@ class Http
|
|||||||
}
|
}
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$server_output = curl_exec($ch);
|
$server_output = curl_exec($ch);
|
||||||
|
if (curl_errno($ch)) {
|
||||||
|
$error_msg = curl_error($ch);
|
||||||
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return $server_output;
|
return ($server_output) ? $server_output : $error_msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,13 @@ foreach ($result as $value) {
|
|||||||
date_default_timezone_set($config['timezone']);
|
date_default_timezone_set($config['timezone']);
|
||||||
$_c = $config;
|
$_c = $config;
|
||||||
|
|
||||||
|
// check if proxy setup in database
|
||||||
|
if(empty($http_proxy) && !empty($config['http_proxy'])){
|
||||||
|
$http_proxy = $config['http_proxy'];
|
||||||
|
if(empty($http_proxyauth) && !empty($config['http_proxyauth'])){
|
||||||
|
$http_proxyauth = $config['http_proxyauth'];
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($config['radius_mode']) {
|
if ($config['radius_mode']) {
|
||||||
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
|
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
|
||||||
ORM::configure('username', $radius_user, 'radius');
|
ORM::configure('username', $radius_user, 'radius');
|
||||||
|
@ -231,6 +231,8 @@ switch ($action) {
|
|||||||
$user_notification_payment = _post('user_notification_payment');
|
$user_notification_payment = _post('user_notification_payment');
|
||||||
$address = _post('address');
|
$address = _post('address');
|
||||||
$tawkto = _post('tawkto');
|
$tawkto = _post('tawkto');
|
||||||
|
$http_proxy = _post('http_proxy');
|
||||||
|
$http_proxyauth = _post('http_proxyauth');
|
||||||
$radius_mode = _post('radius_mode') * 1;
|
$radius_mode = _post('radius_mode') * 1;
|
||||||
run_hook('save_settings'); #HOOK
|
run_hook('save_settings'); #HOOK
|
||||||
|
|
||||||
@ -257,6 +259,28 @@ switch ($action) {
|
|||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
|
|
||||||
|
$d = ORM::for_table('tbl_appconfig')->where('setting', 'http_proxy')->find_one();
|
||||||
|
if ($d) {
|
||||||
|
$d->value = $http_proxy;
|
||||||
|
$d->save();
|
||||||
|
} else {
|
||||||
|
$d = ORM::for_table('tbl_appconfig')->create();
|
||||||
|
$d->setting = 'http_proxy';
|
||||||
|
$d->value = $http_proxy;
|
||||||
|
$d->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = ORM::for_table('tbl_appconfig')->where('setting', 'http_proxyauth')->find_one();
|
||||||
|
if ($d) {
|
||||||
|
$d->value = $http_proxyauth;
|
||||||
|
$d->save();
|
||||||
|
} else {
|
||||||
|
$d = ORM::for_table('tbl_appconfig')->create();
|
||||||
|
$d->setting = 'http_proxyauth';
|
||||||
|
$d->value = $http_proxyauth;
|
||||||
|
$d->save();
|
||||||
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'CompanyFooter')->find_one();
|
$d = ORM::for_table('tbl_appconfig')->where('setting', 'CompanyFooter')->find_one();
|
||||||
if ($d) {
|
if ($d) {
|
||||||
$d->value = $footer;
|
$d->value = $footer;
|
||||||
|
@ -387,3 +387,6 @@ $_L['Minimum_Transfer'] = 'Minimum Transfer';
|
|||||||
$_L['Company_Logo'] = 'Company Logo';
|
$_L['Company_Logo'] = 'Company Logo';
|
||||||
$_L['Expired_IP_Pool'] = 'Expired IP Pool';
|
$_L['Expired_IP_Pool'] = 'Expired IP Pool';
|
||||||
$_L['Expired_IP_Pool'] = 'Expired IP Pool';
|
$_L['Expired_IP_Pool'] = 'Expired IP Pool';
|
||||||
|
$_L['Proxy'] = 'Proxy';
|
||||||
|
$_L['Proxy_Server'] = 'Proxy Server';
|
||||||
|
$_L['Proxy_Server_Login'] = 'Proxy Server Login';
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
<label class="col-md-2 control-label">{Lang::T('Company Logo')}</label>
|
<label class="col-md-2 control-label">{Lang::T('Company Logo')}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input type="file" class="form-control" id="logo" name="logo" accept="image/*">
|
<input type="file" class="form-control" id="logo" name="logo" accept="image/*">
|
||||||
<span class="help-block">For PDF Reports | Best size 1078 x 200 | uploaded image will be autosize</span>
|
<span class="help-block">For PDF Reports | Best size 1078 x 200 | uploaded image will be
|
||||||
|
autosize</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block col-md-4">
|
<span class="help-block col-md-4">
|
||||||
<a href="./{$logo}" target="_blank"><img src="./{$logo}" height="48" alt="logo for PDF"></a>
|
<a href="./{$logo}" target="_blank"><img src="./{$logo}" height="48" alt="logo for PDF"></a>
|
||||||
@ -135,7 +136,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">Telegram Bot Token</label>
|
<label class="col-md-2 control-label">Telegram Bot Token</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input type="text" class="form-control" id="telegram_bot" name="telegram_bot"
|
<input type="password" class="form-control" id="telegram_bot" name="telegram_bot" onmouseleave="this.type = 'password'"
|
||||||
|
onmouseenter="this.type = 'text'"
|
||||||
value="{$_c['telegram_bot']}" placeholder="123456:asdasgdkuasghddlashdashldhalskdklasd">
|
value="{$_c['telegram_bot']}" placeholder="123456:asdasgdkuasghddlashdashldhalskdklasd">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -270,7 +272,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{Lang::T('Invoice')}
|
{Lang::T('Invoice')}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-heading"></div>
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">{Lang::T('Invoice Footer')}</label>
|
<label class="col-md-2 control-label">{Lang::T('Invoice Footer')}</label>
|
||||||
@ -281,6 +282,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="btn-group pull-right">
|
||||||
|
<button class="btn btn-primary btn-xs" title="save" type="submit"><span
|
||||||
|
class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></button>
|
||||||
|
</div>
|
||||||
|
{Lang::T('Proxy')}
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label">{Lang::T('Proxy Server')}</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<input type="text" class="form-control" id="http_proxy" name="http_proxy"
|
||||||
|
value="{$_c['http_proxy']}" placeholder="127.0.0.1:3128">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label">{Lang::T('Proxy Server Login')}</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<input type="password" class="form-control" id="http_proxyauth" name="http_proxyauth" autocomplete="off"
|
||||||
|
value="{$_c['http_proxyauth']}" placeholder="username:password" onmouseleave="this.type = 'password'"
|
||||||
|
onmouseenter="this.type = 'text'">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user