Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/assetradar.outerorbittech.com/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: functions.php

Path: /home2/outerorb/assetradar.outerorbittech.com/functions.php

Size: 1.66 KB

Permissions: 0666

<?php
// functions.php - commonly used helpers
require_once 'config.php';

function notify_user($user_id, $message, $ticket_id = null) {
    global $mysqli;
    if ($ticket_id) {
        $stmt = $mysqli->prepare('INSERT INTO notifications (user_id,message,ticket_id,is_read,created_at) VALUES (?,?,?,0,NOW())');
        $stmt->bind_param('isi', $user_id, $message, $ticket_id);
    } else {
        $stmt = $mysqli->prepare('INSERT INTO notifications (user_id,message,is_read,created_at) VALUES (?,?,0,NOW())');
        $stmt->bind_param('is', $user_id, $message);
    }
    $stmt->execute();
}

function notify_team_and_admins($agent_id, $team_id, $message, $exclude_ids = [], $ticket_id = null) {
    global $mysqli;
    // If team_id is not provided, get it from agent
    if (!$team_id && $agent_id) {
        $res = $mysqli->query('SELECT team_id FROM users WHERE id=' . (int)$agent_id);
        $row = $res ? $res->fetch_assoc() : null;
        $team_id = $row ? (int)$row['team_id'] : 0;
    }
    // Notify TL for the team
    if ($team_id) {
        $tl_res = $mysqli->query('SELECT id FROM users WHERE role_slug="tl" AND team_id=' . (int)$team_id);
        while($tl = $tl_res->fetch_assoc()) {
            if (!in_array($tl['id'], $exclude_ids)) notify_user($tl['id'], $message, $ticket_id);
        }
    }
    // Notify all admins
    $admins = $mysqli->query('SELECT id FROM users WHERE role_slug="admin"');
    while($a = $admins->fetch_assoc()) {
        if (!in_array($a['id'], $exclude_ids)) notify_user($a['id'], $message, $ticket_id);
    }
    // Optionally notify agent
    if ($agent_id && !in_array($agent_id, $exclude_ids)) notify_user($agent_id, $message, $ticket_id);
}
?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager