forked from kevinowino869/mitrobill
Expired date at Internet plan
This commit is contained in:
@ -64,20 +64,12 @@ class Package
|
||||
}
|
||||
}
|
||||
|
||||
if ($p['validity_unit'] == 'Period') {
|
||||
$day_exp = User::getAttribute("Expired Date", $c['id']); //ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one();
|
||||
if (!$day_exp) {
|
||||
$day_exp = 20;
|
||||
// $day_exp = date('d', strtotime($c['created_at']));
|
||||
// if (empty($day_exp) || $day_exp > 28) {
|
||||
// $day_exp = 1;
|
||||
// }
|
||||
$f = ORM::for_table('tbl_customers_fields')->create();
|
||||
$f->customer_id = $c['id'];
|
||||
$f->field_name = 'Expired Date';
|
||||
$f->field_value = $day_exp;
|
||||
$f->save();
|
||||
}
|
||||
$day_exp = 20;
|
||||
if ($p['prepaid'] == 'no') {
|
||||
$day_exp = $p['expired_date'];
|
||||
}
|
||||
if(empty($day_exp)){
|
||||
$day_exp = 20;
|
||||
}
|
||||
|
||||
if ($router_name == 'balance') {
|
||||
|
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
_admin();
|
||||
$ui->assign('_title', 'CodeCanyon.net');
|
||||
$ui->assign('_system_menu', 'settings');
|
||||
|
||||
$plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/repository.json';
|
||||
|
||||
$action = $routes['1'];
|
||||
$ui->assign('_admin', $admin);
|
||||
$cache = File::pathFixer($CACHE_PATH . '/codecanyon.json');
|
||||
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
if (empty($config['envato_token'])) {
|
||||
r2(U . 'settings/app', 'w', '<a href="' . U . 'settings/app#envato' . '">Envato Personal Access Token</a> is not set');
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case 'install':
|
||||
if (!is_writeable(File::pathFixer($CACHE_PATH . '/'))) {
|
||||
r2(U . "codecanyon", 'e', 'Folder system/cache/ is not writable');
|
||||
}
|
||||
if (!is_writeable($PLUGIN_PATH)) {
|
||||
r2(U . "codecanyon", 'e', 'Folder plugin/ is not writable');
|
||||
}
|
||||
if (!is_writeable($PAYMENTGATEWAY_PATH)) {
|
||||
r2(U . "codecanyon", 'e', 'Folder paymentgateway/ is not writable');
|
||||
}
|
||||
set_time_limit(-1);
|
||||
$item_id = $routes['2'];
|
||||
$tipe = $routes['3'];
|
||||
$result = Http::getData('https://api.envato.com/v3/market/buyer/download?item_id=' . $item_id, ['Authorization: Bearer ' . $config['envato_token']]);
|
||||
$json = json_decode($result, true);
|
||||
if (!isset($json['download_url'])) {
|
||||
r2(U . 'codecanyon', 'e', 'Failed to get download url. ' . $json['description']);
|
||||
}
|
||||
$file = File::pathFixer($CACHE_PATH . '/codecanyon/');
|
||||
if (!file_exists($file)) {
|
||||
mkdir($file);
|
||||
}
|
||||
$file .= $item_id . '.zip';
|
||||
if (file_exists($file))
|
||||
unlink($file);
|
||||
//download
|
||||
$fp = fopen($file, 'w+');
|
||||
$ch = curl_init($json['download_url']);
|
||||
curl_setopt($ch, CURLOPT_POST, 0);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
fclose($fp);
|
||||
//extract
|
||||
$target = File::pathFixer($CACHE_PATH . '/codecanyon/' . $item_id . '/');
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($file);
|
||||
$zip->extractTo($target);
|
||||
$zip->close();
|
||||
//moving
|
||||
if (file_exists($target . 'plugin')) {
|
||||
File::copyFolder($target . 'plugin', $PLUGIN_PATH . DIRECTORY_SEPARATOR);
|
||||
} else if (file_exists($target . 'paymentgateway')) {
|
||||
File::copyFolder($target . 'paymentgateway', $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR);
|
||||
} else if (file_exists($target . 'theme')) {
|
||||
File::copyFolder($target . 'theme', File::pathFixer('ui/themes/'));
|
||||
}
|
||||
//Cleaning
|
||||
File::deleteFolder($target);
|
||||
unlink($file);
|
||||
r2(U . "codecanyon", 's', 'Installation success');
|
||||
case 'reload':
|
||||
if (file_exists($cache))
|
||||
unlink($cache);
|
||||
default:
|
||||
if (class_exists('ZipArchive')) {
|
||||
$zipExt = true;
|
||||
} else {
|
||||
$zipExt = false;
|
||||
}
|
||||
$ui->assign('zipExt', $zipExt);
|
||||
|
||||
if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
|
||||
$txt = file_get_contents($cache);
|
||||
$plugins = json_decode($txt, true);
|
||||
$ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache) + (24 * 60 * 60)));
|
||||
if (count($plugins) == 0) {
|
||||
unlink($cache);
|
||||
r2(U . 'codecanyon');
|
||||
}
|
||||
} else {
|
||||
$plugins = [];
|
||||
$page = _get('page', 1);
|
||||
back:
|
||||
$result = Http::getData('https://api.envato.com/v3/market/buyer/list-purchases?&page=' . $page, ['Authorization: Bearer ' . $config['envato_token']]);
|
||||
$items = json_decode($result, true);
|
||||
if ($items && count($items['results']) > 0) {
|
||||
foreach ($items['results'] as $item) {
|
||||
$name = strtolower($item['item']['name']);
|
||||
if (strpos($name, 'phpnuxbill') !== false) {
|
||||
$plugins[] = $item;
|
||||
}
|
||||
}
|
||||
$page++;
|
||||
goto back;
|
||||
}
|
||||
if (count($plugins) > 0) {
|
||||
file_put_contents($cache, json_encode($plugins));
|
||||
if (file_exists($cache)) {
|
||||
$ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache) + (24 * 60 * 60)));
|
||||
}
|
||||
}
|
||||
}
|
||||
$ui->assign('plugins', $plugins);
|
||||
$ui->display('codecanyon.tpl');
|
||||
}
|
@ -159,6 +159,7 @@ switch ($action) {
|
||||
$device = _post('device');
|
||||
$enabled = _post('enabled');
|
||||
$prepaid = _post('prepaid');
|
||||
$expired_date = _post('expired_date');
|
||||
|
||||
$msg = '';
|
||||
if (Validator::UnsignedNumber($validity) == false) {
|
||||
@ -209,6 +210,14 @@ switch ($action) {
|
||||
$d->enabled = $enabled;
|
||||
$d->prepaid = $prepaid;
|
||||
$d->device = $device;
|
||||
if($prepaid == 'no'){
|
||||
if($expired_date>28 && $expired_date < 1){
|
||||
$expired_date = 20;
|
||||
}
|
||||
$d->expired_date = $expired_date;
|
||||
}else{
|
||||
$d->expired_date = 0;
|
||||
}
|
||||
$d->save();
|
||||
|
||||
$dvc = Package::getDevice($d);
|
||||
@ -246,6 +255,7 @@ switch ($action) {
|
||||
$enabled = _post('enabled');
|
||||
$prepaid = _post('prepaid');
|
||||
$routers = _post('routers');
|
||||
$expired_date = _post('expired_date');
|
||||
$msg = '';
|
||||
if (Validator::UnsignedNumber($validity) == false) {
|
||||
$msg .= 'The validity must be a number' . '<br>';
|
||||
@ -301,6 +311,14 @@ switch ($action) {
|
||||
$d->enabled = $enabled;
|
||||
$d->prepaid = $prepaid;
|
||||
$d->device = $device;
|
||||
if($prepaid == 'no'){
|
||||
if($expired_date>28 && $expired_date < 1){
|
||||
$expired_date = 20;
|
||||
}
|
||||
$d->expired_date = $expired_date;
|
||||
}else{
|
||||
$d->expired_date = 0;
|
||||
}
|
||||
$d->save();
|
||||
|
||||
$dvc = Package::getDevice($d);
|
||||
@ -433,6 +451,7 @@ switch ($action) {
|
||||
$pool = _post('pool_name');
|
||||
$enabled = _post('enabled');
|
||||
$prepaid = _post('prepaid');
|
||||
$expired_date = _post('expired_date');
|
||||
|
||||
|
||||
$msg = '';
|
||||
@ -491,6 +510,14 @@ switch ($action) {
|
||||
$d->is_radius = 0;
|
||||
$d->routers = $routers;
|
||||
}
|
||||
if($prepaid == 'no'){
|
||||
if($expired_date>28 && $expired_date < 1){
|
||||
$expired_date = 20;
|
||||
}
|
||||
$d->expired_date = $expired_date;
|
||||
}else{
|
||||
$d->expired_date = 0;
|
||||
}
|
||||
$d->enabled = $enabled;
|
||||
$d->prepaid = $prepaid;
|
||||
$d->device = $device;
|
||||
@ -524,6 +551,7 @@ switch ($action) {
|
||||
$plan_expired = _post('plan_expired');
|
||||
$enabled = _post('enabled');
|
||||
$prepaid = _post('prepaid');
|
||||
$expired_date = _post('expired_date');
|
||||
|
||||
$msg = '';
|
||||
if (Validator::UnsignedNumber($validity) == false) {
|
||||
@ -575,6 +603,14 @@ switch ($action) {
|
||||
$d->enabled = $enabled;
|
||||
$d->prepaid = $prepaid;
|
||||
$d->device = $device;
|
||||
if($prepaid == 'no'){
|
||||
if($expired_date>28 && $expired_date < 1){
|
||||
$expired_date = 20;
|
||||
}
|
||||
$d->expired_date = $expired_date;
|
||||
}else{
|
||||
$d->expired_date = 0;
|
||||
}
|
||||
$d->save();
|
||||
|
||||
$dvc = Package::getDevice($d);
|
||||
|
@ -636,5 +636,11 @@
|
||||
"Device": "Device",
|
||||
"Expired_Internet_Plan": "Expired Internet Plan",
|
||||
"When_Expired__customer_will_be_move_to_selected_internet_plan": "When Expired, customer will be move to selected internet plan",
|
||||
"Plugin_Installer": "Plugin Installer"
|
||||
"Plugin_Installer": "Plugin Installer",
|
||||
"Expired_Date": "Expired Date",
|
||||
"Expired": "Expired",
|
||||
"Time": "Time",
|
||||
"Data": "Data",
|
||||
"Category": "Category",
|
||||
"later": "later"
|
||||
}
|
Reference in New Issue
Block a user