diff --git a/cron/sendmessage.php b/cron/sendmessage.php new file mode 100644 index 0000000..612c21e --- /dev/null +++ b/cron/sendmessage.php @@ -0,0 +1,29 @@ +id, $info['text'], null, 'HTML'); + unset($userid[0]); + $userid = array_values($userid); + $count +=1; +} +file_put_contents('users.json',json_encode($userid,true)); \ No newline at end of file diff --git a/functions.php b/functions.php index 797d2c4..a87df9a 100644 --- a/functions.php +++ b/functions.php @@ -327,6 +327,7 @@ function DirectPayment($order_id){ if ($affiliatescommission['status_commission'] == "oncommission" &&($Balance_id['affiliates'] !== null || $Balance_id['affiliates'] != 0)) { $result = ($get_invoice['price_product'] * $affiliatescommission['affiliatespercentage']) / 100; $user_Balance = select("user", "*", "id", $Balance_id['affiliates'],"select"); + if(isset($user_Balance)){ $Balance_prim = $user_Balance['Balance'] + $result; update("user","Balance",$Balance_prim, "id",$Balance_id['affiliates']); $result = number_format($result); @@ -334,6 +335,7 @@ function DirectPayment($order_id){ مبلغ $result تومان به حساب شما از طرف زیر مجموعه تان به کیف پول شما واریز گردید"; sendmessage($Balance_id['affiliates'], $textadd, null, 'HTML'); + } } $Balance_prims = $Balance_id['Balance'] - $get_invoice['price_product']; if($Balance_prims <= 0) $Balance_prims = 0; @@ -393,3 +395,17 @@ function DirectPayment($order_id){ 🛒 کد پیگیری شما: {$Payment_report['id_order']}", null, 'HTML'); } } +function savedata($type,$namefiled,$valuefiled){ + global $from_id; + if($type == "clear"){ + $datauser = []; + $datauser[$namefiled] = $valuefiled; + $data = json_encode($datauser); + update("user","Processing_value",$data,"id",$from_id); + }elseif($type == "save"){ + $userdata = select("user","*","id",$from_id,"select"); + $dataperevieos = json_decode($userdata['Processing_value'],true); + $dataperevieos[$namefiled] = $valuefiled; + update("user","Processing_value",json_encode($dataperevieos),"id",$from_id); + } +} \ No newline at end of file diff --git a/index.php b/index.php index 497009a..094941f 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ prepare("SELECT id FROM user"); - $stmt->execute(); - if ($result) { - $ids = array(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $ids[] = $row['id']; - } - $idsText = implode("\n", $ids); - file_put_contents($filename, $idsText); - } - $file = fopen($filename, 'r'); - if ($file) { - while (($line = fgets($file)) !== false) { - $line = trim($line); - sendmessage($line, $text, null, 'HTML'); - usleep(1000000); + $userdata = json_decode($user['Processing_value'],true); + if($text == "تایید"){ + step('home', $from_id); + $result = select("user","id","User_Status","Active","fetchAll"); + $Respuseronse = json_encode([ + 'inline_keyboard' => [ + [ + ['text' => "لغو ارسال", 'callback_data' => 'cancel_sendmessage'], + ], + ] + ]); + file_put_contents('cron/users.json',json_encode($result)); + file_put_contents('cron/info',$user['Processing_value']); + sendmessage($from_id, "📌 پیام شما در صف ارسال قرار گرفت پس از ارسال پیام تایید برای شما ارسال می شود ( ارسال پیام ممکن است حداکثر 8 ساعت زمان ببرد بدلیل محدودیت های تلگرام )", $Respuseronse, 'HTML'); } - sendmessage($from_id, "✅ پیام به تمامی کاربران ارسال شد", $keyboardadmin, 'HTML'); - fclose($file); - } - unlink($filename); +}elseif($datain == "cancel_sendmessage"){ + unlink('cron/users.json'); + unlink('cron/info'); + deletemessage($from_id, $message_id); + sendmessage($from_id, "📌 ارسال پیام لغو گردید.", null, 'HTML'); } elseif ($text == "📤 فوروارد همگانی") { sendmessage($from_id, $textbotlang['Admin']['ManageUser']['ForwardGetext'], $backadmin, 'HTML'); step('gettextforwardMessage', $from_id); diff --git a/table.php b/table.php index 3478e1f..8b9d100 100644 --- a/table.php +++ b/table.php @@ -784,4 +784,5 @@ } } catch (Exception $e) { file_put_contents('error_log',$e->getMessage()); -} \ No newline at end of file +} +$connect->query("ALTER TABLE `user` CHANGE `Processing_value` `Processing_value` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;"); \ No newline at end of file