Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiMGF2 committed Aug 15, 2024
1 parent 6b8c05d commit 440175f
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 11 deletions.
1 change: 0 additions & 1 deletion apipanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function token_panel($url_panel,$username_panel,$password_panel){
$timecurrent = time();
$start_date = new DateTime($date['time']);
$since_start = $start_date->diff(new DateTime(date('Y/m/d H:i:s',$timecurrent)));
var_dump($since_start->i);
if($since_start->i <= 10){
return $date;
}
Expand Down
47 changes: 47 additions & 0 deletions cron/cronday.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
ini_set('error_log', 'error_log');
date_default_timezone_set('Asia/Tehran');
require_once '../config.php';
require_once '../botapi.php';
require_once '../panels.php';
require_once '../functions.php';
$ManagePanel = new ManagePanel();


// buy service
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE (status = 'active' OR status = 'end_of_volume') AND name_product != 'سرویس تست' ORDER BY RAND() LIMIT 5");
$stmt->execute();
while ($line = $stmt->fetch(PDO::FETCH_ASSOC)) {
$resultss = $line;
$marzban_list_get = select("marzban_panel","*","name_panel",$resultss['Service_location'],"select");
$get_username_Check = $ManagePanel->DataUser($resultss['Service_location'],$resultss['username']);
if($get_username_Check['status'] != "Unsuccessful"){
if(in_array($get_username_Check['status'],['active','on_hold'])){
$timeservice = $get_username_Check['expire'] - time();
$day = floor($timeservice / 86400)+1;
$output = $get_username_Check['data_limit'] - $get_username_Check['used_traffic'];
$textservice = select("textbot","text","id_text","text_Purchased_services","select")['text'];
$RemainingVolume = formatBytes($output);
$Response = json_encode([
'inline_keyboard' => [
[
['text' => "💊 تمدید سرویس", 'callback_data' => 'extend_' . $resultss['username']],
],
]
]);
if ($timeservice <= "167000" && $timeservice > 0) {
$text = "با سلام خدمت شما کاربر گرامی 👋
📌 از مهلت زمانی استفاده از سرویس {$resultss['username']} فقط $day روز باقی مانده است. لطفاً در صورت تمایل برای تمدید این سرویس، از طریق بخش «{$textservice}» اقدام بفرمایین. با تشکر از همراهی شما";
sendmessage($resultss['id_user'], $text, $Response, 'HTML');
if($resultss['Status'] === "end_of_volume"){
update("invoice","Status","sendedwarn", "username",$line['username']);
}else{
update("invoice","Status","end_of_time", "username",$line['username']);
}
}
if($get_username_Check && !in_array($get_username_Check['status'],['active','on_hold'])){
update("invoice","status","disabled", "username",$line['username']);
}
}
}
}
42 changes: 42 additions & 0 deletions cron/cronvolume.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
ini_set('error_log', 'error_log');
date_default_timezone_set('Asia/Tehran');
require_once '../config.php';
require_once '../botapi.php';
require_once '../panels.php';
require_once '../functions.php';
$ManagePanel = new ManagePanel();

// buy service
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE (status = 'active' OR status = 'end_of_time') AND name_product != 'سرویس تست' ORDER BY RAND() LIMIT 5");
$stmt->execute();
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
$line = trim($result['username']);
$resultss = $result;
$marzban_list_get = select("marzban_panel","*","name_panel",$resultss['Service_location'],"select");
$get_username_Check = $ManagePanel->DataUser($resultss['Service_location'],$resultss['username']);
if($get_username_Check){
if($get_username_Check['status'] == "Unsuccessful")continue;
$output = $get_username_Check['data_limit'] - $get_username_Check['used_traffic'];
$textservice = select("textbot","text","id_text","text_Purchased_services","select")['text'];
$RemainingVolume = formatBytes($output);
$Response = json_encode([
'inline_keyboard' => [
[
['text' => "💊 تمدید سرویس", 'callback_data' => 'extend_' . $resultss['username']],
],
]
]);
$bytewarn = 1 * pow(1024, 3);
if ($output <= $bytewarn && $output > 0 && $get_username_Check['status'] == "active") {
$text = "با سلام خدمت شما کاربر گرامی 👋
🚨 از حجم سرویس $line تنها $RemainingVolume باقی مانده است. لطفاً در صورت تمایل برای خرید حجم اضافه و یا تمدید سرویستون از طریق بخش «{$textservice}» اقدام بفرمایین";
sendmessage($resultss['id_user'], $text, $Response, 'HTML');
if($resultss['Status'] === "end_of_time"){
update("invoice","Status","sendedwarn", "username",$line);
}else{
update("invoice","Status","end_of_volume", "username",$line);
}
}
}
}
58 changes: 48 additions & 10 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
ini_set('error_log', 'error_log');
$version = "4.8.7";
$version = "4.8.8";
date_default_timezone_set('Asia/Tehran');
require_once 'config.php';
require_once 'botapi.php';
Expand Down Expand Up @@ -292,7 +292,7 @@

#-----------Purchased services------------#
if ($text == $datatextbot['text_Purchased_services'] || $datain == "backorder") {
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND status = 'active'");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn')");
$stmt->bindParam(':id_user', $from_id);
$stmt->execute();
$invoices = $stmt->rowCount();
Expand All @@ -304,7 +304,7 @@
$page = 1;
$items_per_page = 5;
$start_index = ($page - 1) * $items_per_page;
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND status = 'active' ORDER BY username ASC LIMIT $start_index, $items_per_page");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn') ORDER BY username ASC LIMIT $start_index, $items_per_page");
$stmt->bindParam(':id_user', $from_id);
$stmt->execute();
$keyboardlists = [
Expand Down Expand Up @@ -435,7 +435,7 @@
$next_page = $page + 1;
}
$start_index = ($next_page - 1) * $items_per_page;
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND status = 'active' ORDER BY username ASC LIMIT $start_index, $items_per_page");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn') ORDER BY username ASC LIMIT $start_index, $items_per_page");
$stmt->bindParam(':id_user', $from_id);
$stmt->execute();
$keyboardlists = [
Expand Down Expand Up @@ -472,7 +472,7 @@
$next_page = $page - 1;
}
$start_index = ($next_page - 1) * $items_per_page;
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND status = 'active' ORDER BY username ASC LIMIT $start_index, $items_per_page");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE id_user = :id_user AND (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn') ORDER BY username ASC LIMIT $start_index, $items_per_page");
$stmt->bindParam(':id_user', $from_id);
$stmt->execute();
$keyboardlists = [
Expand Down Expand Up @@ -1020,7 +1020,7 @@
return;
}
}
$username_ac = generateUsername($from_id, $marzban_list_get['MethodUsername'], $user['username'], $randomString, $text);
$username_ac = strtolower(generateUsername($from_id, $marzban_list_get['MethodUsername'], $user['username'], $randomString, $text));
$DataUserOut = $ManagePanel->DataUser($marzban_list_get['name_panel'], $username_ac);
if (isset ($DataUserOut['username']) || in_array($username_ac, $usernameinvoice)) {
$random_number = random_int(1000000, 9999999);
Expand Down Expand Up @@ -1343,7 +1343,7 @@
$info_product = $stmt->fetch(PDO::FETCH_ASSOC);
$randomString = bin2hex(random_bytes(2));
$panellist = select("marzban_panel", "*", "name_panel", $user['Processing_value'], "select");
$username_ac = generateUsername($from_id, $panellist['MethodUsername'], $username, $randomString, $text);
$username_ac = strtolower(generateUsername($from_id, $panellist['MethodUsername'], $username, $randomString, $text));
$DataUserOut = $ManagePanel->DataUser($panellist['name_panel'], $username_ac);
$random_number = random_int(1000000, 9999999);
if (isset ($DataUserOut['username']) || in_array($username_ac, $usernameinvoice)) {
Expand Down Expand Up @@ -2233,20 +2233,20 @@
if ($text == "📊 آمار ربات") {
$date = jdate('Y/m/d');
$timeacc = jdate('H:i:s', time());
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE time_sell = '$date' AND status = 'active' AND name_product != 'usertest'");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE time_sell = '$date' AND (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn') AND name_product != 'usertest'");
$stmt->execute();
$dayListSell = $stmt->rowCount();
$count_usertest = select("invoice", "*", "name_product", "usertest", "count");
$stmt = $pdo->prepare("SELECT SUM(Balance) FROM user");
$stmt->execute();
$Balanceall = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt = $pdo->prepare("SELECT SUM(price_product) FROM invoice WHERE time_sell = '$date' AND status = 'active' AND name_product != 'usertest'");
$stmt = $pdo->prepare("SELECT SUM(price_product) FROM invoice WHERE time_sell = '$date' AND (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn') AND name_product != 'usertest'");
$stmt->execute();
$value = $stmt->fetchColumn();
if($value == null )$value = 0;
$suminvoiceday = number_format($value);
$statistics = select("user", "id", null, null, "count");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE status = 'active' AND name_product != 'usertest'");
$stmt = $pdo->prepare("SELECT * FROM invoice WHERE (status = 'active' OR status = 'end_of_time' OR status = 'end_of_volume' OR status = 'sendedwarn') AND name_product != 'usertest'");
$stmt->execute();
$invoice = $stmt->rowCount();
$ping = sys_getloadavg();
Expand Down Expand Up @@ -4405,4 +4405,42 @@
shell_exec('crontab /tmp/crontab.txt');
unlink('/tmp/crontab.txt');
}
if($text == "فعال شدن کرون حجم"){
sendmessage($from_id, "✅ کرون جاب فعال گردید این کرون هر 1 دقیقه اجرا می شود", null, 'HTML');
$phpFilePath = "https://$domainhosts/cron/cronvolume.php";
$cronCommand = "*/1 * * * * curl $phpFilePath";
$existingCronCommands = shell_exec('crontab -l');
if (strpos($existingCronCommands, $cronCommand) === false) {
$command = "(crontab -l ; echo '$cronCommand') | crontab -";
shell_exec($command);
}
}
if($text == "غیر فعال شدن کرون حجم"){
sendmessage($from_id, "کرون جاب غیرفعال گردید", null, 'HTML');
$currentCronJobs = shell_exec("crontab -l");
$jobToRemove = "*/1 * * * * curl https://$domainhosts/cron/cronvolume.php";
$newCronJobs = preg_replace('/'.preg_quote($jobToRemove, '/').'/', '', $currentCronJobs);
file_put_contents('/tmp/crontab.txt', $newCronJobs);
shell_exec('crontab /tmp/crontab.txt');
unlink('/tmp/crontab.txt');
}
if($text == "فعال شدن کرون زمان"){
sendmessage($from_id, "✅ کرون جاب فعال گردید این کرون هر 1 دقیقه اجرا می شود", null, 'HTML');
$phpFilePath = "https://$domainhosts/cron/cronday.php";
$cronCommand = "*/1 * * * * curl $phpFilePath";
$existingCronCommands = shell_exec('crontab -l');
if (strpos($existingCronCommands, $cronCommand) === false) {
$command = "(crontab -l ; echo '$cronCommand') | crontab -";
shell_exec($command);
}
}
if($text == "غیر فعال شدن کرون زمان"){
sendmessage($from_id, "کرون جاب غیرفعال گردید", null, 'HTML');
$currentCronJobs = shell_exec("crontab -l");
$jobToRemove = "*/1 * * * * curl https://$domainhosts/cron/cronday.php";
$newCronJobs = preg_replace('/'.preg_quote($jobToRemove, '/').'/', '', $currentCronJobs);
file_put_contents('/tmp/crontab.txt', $newCronJobs);
shell_exec('crontab /tmp/crontab.txt');
unlink('/tmp/crontab.txt');
}
$connect->close();
2 changes: 2 additions & 0 deletions keyboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@
$keyboardcronjob = json_encode([
'keyboard' => [
[['text' => 'فعال شدن کرون تست'],['text' => 'غیر فعال شدن کرون تست']],
[['text' => 'فعال شدن کرون حجم'],['text' => 'غیر فعال شدن کرون حجم']],
[['text' => 'فعال شدن کرون زمان'],['text' => 'غیر فعال شدن کرون زمان']],
[['text' => "🏠 بازگشت به منوی مدیریت"]]
],
'resize_keyboard' => true
Expand Down
Binary file added payment/.DS_Store
Binary file not shown.

0 comments on commit 440175f

Please sign in to comment.