mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
add back to top
This commit is contained in:
@@ -2,8 +2,55 @@
|
||||
require "../include/bittorrent.php";
|
||||
dbconn();
|
||||
loggedinorreturn();
|
||||
if (get_user_class() < UC_SYSOP)
|
||||
if (get_user_class() < UC_SYSOP) {
|
||||
stderr("Sorry", "Access denied.");
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$sender_id = ($_POST['sender'] == 'system' ? 0 : (int)$CURUSER['id']);
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
$msg = trim($_POST['msg']);
|
||||
$amount = $_POST['amount'];
|
||||
if (!$msg || !$amount)
|
||||
stderr("Error","Don't leave any fields blank.");
|
||||
if(!is_numeric($amount))
|
||||
stderr("Error","amount must be numeric");
|
||||
$updateset = $_POST['clases'];
|
||||
if (is_array($updateset)) {
|
||||
foreach ($updateset as $class) {
|
||||
if (!is_valid_id($class) && $class != 0)
|
||||
stderr("Error","Invalid Class");
|
||||
}
|
||||
}else{
|
||||
if (!is_valid_id($updateset) && $updateset != 0)
|
||||
stderr("Error","Invalid Class");
|
||||
}
|
||||
$subject = trim($_POST['subject']);
|
||||
$page = 1;
|
||||
$size = 10000;
|
||||
while (true) {
|
||||
$messages = [];
|
||||
$userIdArr = [];
|
||||
$users = \App\Models\User::query()->whereIn('class', $updateset)->forPage($page, $size)->get(['id']);
|
||||
if ($users->isEmpty()) {
|
||||
break;
|
||||
}
|
||||
foreach ($users as $user) {
|
||||
$userIdArr[] = $user->id;
|
||||
$messages[] = [
|
||||
'sender' => $sender_id,
|
||||
'receiver' => $user->id,
|
||||
'added' => $dt,
|
||||
'subject' => $subject,
|
||||
'msg' => $msg,
|
||||
];
|
||||
}
|
||||
\App\Models\User::query()->whereIn('id', $userIdArr)->increment('attendance_card', $amount);
|
||||
\App\Models\Message::query()->insert($messages);
|
||||
$page++;
|
||||
}
|
||||
header(sprintf("Refresh: 0; url=%s?sent=1", $_SERVER['PHP_SELF']));
|
||||
}
|
||||
|
||||
stdhead("Add Attendance card", false);
|
||||
$allClass = array_chunk(\App\Models\User::$classes, 4, true);
|
||||
?>
|
||||
@@ -24,7 +71,7 @@ $allClass = array_chunk(\App\Models\User::$classes, 4, true);
|
||||
<?php
|
||||
if (isset($_GET["sent"]) && $_GET["sent"] == 1) {
|
||||
?>
|
||||
<tr><td colspan=2 class="text" align="center"><font color=red><b>Upload amount has been added and inform message has been sent.</font></b></tr></td>
|
||||
<tr><td colspan=2 class="text" align="center"><font color=red><b>Attendance card has been added and inform message has been sent.</font></b></tr></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user