|
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/user/ | |
|
Path: /home2/outerorb/assetradar.outerorbittech.com/user/report_general_issue.php
Size: 3.37 KB
Permissions: 0666
<?php
// Log all errors and exceptions
set_error_handler(function($errno, $errstr, $errfile, $errline) {
error_log(date('Y-m-d H:i:s') . " - ERROR [$errno] $errstr in $errfile on line $errline\n", 3, __DIR__ . '/../error.log');
return false;
});
set_exception_handler(function($ex) {
error_log(date('Y-m-d H:i:s') . ' - EXCEPTION: ' . $ex->getMessage() . "\n", 3, __DIR__ . '/../error.log');
});
require_once __DIR__ . '/../inc/auth.php';
require_once __DIR__ . '/../functions.php';
require_login();
$u = current_user();
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verify_csrf();
$issue_type = $_POST['issue_type'];
$desc = $_POST['description'];
$status = 'Pending';
$screenshot_path = null;
if (!empty($_FILES['screenshot']['name'])) {
$target_dir = __DIR__ . '/../assets/screenshots/';
if (!is_dir($target_dir)) mkdir($target_dir, 0777, true);
$filename = uniqid('ss_') . '_' . basename($_FILES['screenshot']['name']);
$target_file = $target_dir . $filename;
if (move_uploaded_file($_FILES['screenshot']['tmp_name'], $target_file)) {
$screenshot_path = 'assets/screenshots/' . $filename;
} else {
$error = 'Screenshot upload failed.';
}
}
if (!$error) {
$stmt = $mysqli->prepare('INSERT INTO tickets (item_id, user_id, item_name, issue_type, description, status, created_at, screenshot_path) VALUES (NULL,?,?,?,?,?,?,?)');
$general_name = '[General Issue]';
$screenshot_param = $screenshot_path ?? '';
$created_param = date('Y-m-d H:i:s');
$stmt->bind_param('issssss', $_SESSION['user_id'], $general_name, $issue_type, $desc, $status, $created_param, $screenshot_param);
if ($stmt->execute()) {
$ticket_id = $stmt->insert_id;
// Notify admins
$admins = $mysqli->query('SELECT id FROM users WHERE role_slug="admin"');
while($a = $admins->fetch_assoc()) notify_user($a['id'], 'New general ticket #' . $ticket_id . ' reported by ' . esc($u['name']), $ticket_id);
$_SESSION['issue_reported'] = true;
header('Location: dashboard.php?success=1');
exit;
} else {
$error = $stmt->error;
}
}
}
include __DIR__ . '/../inc/header.php';
include __DIR__ . '/user_menu.php';
?>
<div class="card p-3 card-hero">
<h5>Report General Issue (Not Related to Asset)</h5>
<?php if (!empty($error)): ?><div class="alert alert-danger"><?php echo esc($error); ?></div><?php endif; ?>
<form method="post" enctype="multipart/form-data">
<?php echo csrf_field(); ?>
<div class="mb-3"><label>Issue Type</label>
<select name="issue_type" class="form-control" required>
<option>Email Not Working</option>
<option>Internet Slow/Not Working</option>
<option>Software Problem</option>
<option>Other</option>
</select>
</div>
<div class="mb-3"><label>Description</label><textarea class="form-control" name="description" required></textarea></div>
<div class="mb-3"><label>Screenshot (optional)</label><input type="file" name="screenshot" accept="image/*" class="form-control"></div>
<button class="btn btn-success">Submit</button>
</form>
<!-- Future: Add search/filter for general issues if listing -->
</div>
<?php include __DIR__ . '/../inc/footer.php'; ?>