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j '  'P$a ( `D$Na L?u80e J,K˷NI'0eݷ(NI'؀ 2ipIIKp`:O'`ʤxB8Ѥx Ѥx $ $P6 :vRNb 'p,>NB 'P]-->P T+*^h& p '‰a ‰ (ĵt#u33;Nt̵'ޯ; [3W ~]0KH1q@8]O2]3*̧7# *p>us p _6]/}-4|t'|Smx= DoʾM×M_8!)6lq':l7!|4} '\ne t!=hnLn (~Dn\+‰_4k)0e@OhZ`F `.m1} 'vp{F`ON7Srx 'D˸nV`><;yMx!IS钦OM)Ե٥x 'DSD6bS8!" ODz#R >S8!7ّxEh0m$MIPHi$IvS8IN$I p$O8I,sk&I)$IN$Hi$I^Ah.p$MIN$IR8I·N "IF9Ah0m$MIN$IR8IN$I 3jIU;kO$ɳN$+ q.x* tEXtComment

Viewing File: /home/u423589436/domains/stratagemportfolios.com/public_html/user/tickets_new.php

<?php
include 'header.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    try {
        // Validate required fields
        if (empty($_POST['title'])) {
            throw new Exception("Subject is required");
        }
        
        if (empty($_POST['message'])) {
            throw new Exception("Message is required");
        }

        // File upload handling
        $uploadDir = '../uploads/tickets/';
        if (!file_exists($uploadDir)) {
            mkdir($uploadDir, 0777, true);
        }

        $allowedTypes = [
            'image/jpeg', 'image/png', 'image/gif', 
            'application/pdf', 
            'application/msword', 
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
        ];
        $maxSize = 5 * 1024 * 1024; // 5MB

        // Process file uploads if any
        $attachments = [];
        if (!empty($_FILES['attachments']['name'][0])) {
            foreach ($_FILES['attachments']['tmp_name'] as $key => $tmpName) {
                $fileName = $_FILES['attachments']['name'][$key];
                $fileType = $_FILES['attachments']['type'][$key];
                $fileSize = $_FILES['attachments']['size'][$key];
                
                // Validate file type
                if (!in_array($fileType, $allowedTypes)) {
                    throw new Exception("Invalid file type: $fileName. Only images, PDFs and Word docs allowed");
                }
                
                // Validate file size
                if ($fileSize > $maxSize) {
                    throw new Exception("File too large: $fileName. Max 5MB allowed");
                }
                
                // Generate unique filename
                $ext = pathinfo($fileName, PATHINFO_EXTENSION);
                $newFilename = $user_id . '_' . time() . '_' . bin2hex(random_bytes(4)) . '.' . $ext;
                $destination = $uploadDir . $newFilename;
                
                if (!move_uploaded_file($tmpName, $destination)) {
                    throw new Exception("Failed to upload $fileName");
                }
                
                $attachments[] = [
                    'original_name' => $fileName,
                    'saved_name' => $newFilename,
                    'file_path' => $destination
                ];
            }
        }

        // Insert everything into tickets table
        $conn->begin_transaction();

        try {
            // Insert ticket with attachments as JSON
            $ticketSql = "INSERT INTO tickets 
                         (user_id, email, fullname, title, message, attachments, status, created_at) 
                         VALUES (?, ?, ?, ?, ?, ?, 'open', NOW())";
            
            $attachmentsJson = !empty($attachments) ? json_encode($attachments) : null;
            
            $stmt = $conn->prepare($ticketSql);
            $stmt->bind_param("isssss",  // Changed to 6 's' for 6 parameters
                $user_id, 
                $email,
                $first_name,
                $_POST['title'], 
                $_POST['message'],
                $attachmentsJson
            );
            $stmt->execute();
            
            if ($stmt->affected_rows === 0) {
                throw new Exception("No rows were inserted");
            }
            
            $conn->commit();

            // Success alert and redirect
            echo "<script>
                alert('Ticket submitted successfully!');
                window.location.href = 'tickets.php';
            </script>";
            exit();

        } catch (Exception $e) {
            $conn->rollback();
            // Clean up uploaded files if any
            foreach ($attachments as $attachment) {
                if (file_exists($attachment['file_path'])) {
                    unlink($attachment['file_path']);
                }
            }
            throw new Exception("Failed to create ticket: " . $e->getMessage());
        }

    } catch (Exception $e) {
        echo "<script>
            alert('Error: " . addslashes($e->getMessage()) . "');
            window.history.back();
        </script>";
        exit();
    }
}
?> 
    <div class="pt-28 md:pt-0 mt-0 md:mt-36 w-full md:w-4/5" id="general-content">
        <div class="w-full md:w-10/12 md:ml-64 2xl:ml-1/5" id="general-content-section">

            
            <div class="w-full py-5">
    <div class="w-full flex justify-center">
        <div class="w-11/12 rounded-md bg-[#0e1726] p-2 md:p-4">
            <div class="flex justify-between items-center">
                <div>
                    
                    <h2 class="bg-transparent text-[#ebedf2] font-medium capitalize">
                        New Support Ticket
                    </h2>
                </div>

                <div>
                    <a href="#" class="flex justify-start items-center space-x-1 text-xs md:text-sm text-[#d1d5db] text-center px-5 py-2 my-2 bg-[#1b2e4b] hover:bg-gray-700 rounded-md">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                            <path stroke-linecap="round" stroke-linejoin="round" d="M11 17l-5-5m0 0l5-5m-5 5h12" />
                        </svg>
                        <span>Cancel</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
            

            
            <div id="preloader" class="action-preloader">
    <div id="loading-bar-spinner" class="spinner">
        <div class="spinner-icon"></div>
    </div>
</div>

            
            
            
                        

            
                        

            
            <div class="w-full py-5">
    <div class="w-full flex justify-center">
        <div class="w-11/12 rounded-md bg-[#0e1726] p-2 md:p-4">
            <form class="pt-2 md:pt-4" action="" method="POST" enctype="multipart/form-data">
                <input type="hidden" name="_token" value="ZNnXKYQyOx5JKtsRY5o4lDzBTDBUkLI4TgOrtZa4">
                <div class="mt-5 text-[#bfc9d4] text-xs md:text-sm">
                    <div class="w-full flex items-baseline space-x-1">
                        <input class="cred-hyip-theme1-text-input pl-5" type="text" name="title" id="title" placeholder="Subject" required value="">
                    </div>
                    <span class="p-1 text-red-600">
                                            </span>
                </div>

                <div class="text-[#bfc9d4] text-xs md:text-sm">
                    
                    <div class="text-[#bfc9d4] text-xs md:text-sm">
                        <div class="w-full">
                            <textarea class="cred-hyip-theme1-textarea p-8" name="message" id="message" required cols="30" rows="5" placeholder="Add a message..."></textarea>
                        </div>
                        <span class="p-1 text-red-600">
                                                    </span>
                    </div>
                </div>
                
                <div class="text-[#bfc9d4] text-xs md:text-sm">
                    <div class="w-full flex items-center space-x-2">
                        <div>
                            <label title="click to add attachments" class="font-medium py-1 px-3 flex flex-grow justify-center items-center space-x-2 border rounded-md border-slate-800 hover:border-slate-600 cursor-pointer" for="attachments">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
                                </svg>
                                <h5>Add attachment(s)</h5>
                            </label>
                            <input class="hidden attachment-input" type="file" name="attachments[]" id="attachments" multiple>
                        </div>

                        <div class="attachment-list">

                        </div>
                    </div>
                    <span class="p-1 text-red-600">
                                            </span>
                </div>

                <div class="w-full my-5 px-5">
                    <button type="submit" class="w-full text-xs md:text-sm text-[#d1d5db] text-center px-5 py-3 my-5 bg-[#1b2e4b] hover:bg-gray-700 rounded-md" href="https://demo-trade.credcrypto.net/user/id/upload">
                        Submit Ticket
                    </button>
                </div>
            </form>

        </div>
    </div>
</div>
            

        </div>
    </div>
    
</div>


<?php include 'footer.php'; ?>
Back to Directory=ceiIENDB`