MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/demo.imensosoftware.com/matrix/data.php
<?php
require_once 'config.php';
require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\IOFactory;

include 'header_data.php';

// ✅ Session check
if (!isset($_SESSION['user_id'])) {
    die("Unauthorized access");
}

// ✅ sanitize input
$assignment_no = $_GET['assignment_no'] ?? '';
$assignment_no = preg_replace('/[^a-zA-Z0-9_-]/', '', $assignment_no);

if (empty($assignment_no)) {
    die("Invalid assignment");
}

// ✅ safe file path
$basePath = __DIR__ . "/docs/";
$filePathXls  = $basePath . $assignment_no . "/" . $assignment_no . ".xls";
$filePathXlsx = $basePath . $assignment_no . "/" . $assignment_no . ".xlsx";

if (file_exists($filePathXls)) {
    $inputFileName = $filePathXls;
} elseif (file_exists($filePathXlsx)) {
    $inputFileName = $filePathXlsx;
} else {
    die("File not found");
}

// ✅ load excel
try {
    $spreadsheet = IOFactory::load($inputFileName);
} catch (Exception $e) {
    die("Error loading file");
}

$sheet = $spreadsheet->getActiveSheet();
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
?>

<div class="container-area">
  <div class="container-fluid h-100">
    <div class="row">

      <!-- LEFT SIDE -->
      <div class="left-side border-right">
        <ul class="list-group list-group-flush">

        <?php 
        for ($row = 1; $row <= $highestRow; $row++) {

            $rowData = $sheet->rangeToArray(
                "A{$row}:{$highestColumn}{$row}",
                null, true, false
            )[0];

            // skip header
            if ($rowData[0] == "Document ID") continue;

            $docId = trim($rowData[0] ?? '');
            if (empty($docId)) continue;

            // ✅ same logic as your original
            if (!empty($rowData[3])) {
                $check_data = "done doubt";
            } elseif (!empty($rowData[2]) || !empty($rowData[1])) {
                $check_data = "done";
            } else {
                $check_data = "default";
            }
        ?>

          <li class="list-group-item p-0 <?= $check_data ?>">
            <a href="javascript:;" 
               id="row_link"
               data-row_id="<?= $row ?>"
               data-doc_id="<?= htmlspecialchars($docId) ?>">
               <?= htmlspecialchars($docId) ?>
            </a>
          </li>

        <?php } ?>

        </ul>
      </div>

      <!-- RIGHT SIDE -->
      <div class="right-side">
        <div class="row h-100">
          <div class="col-md-12 h-100">
            <iframe id="row_iframe" src="" width="100%" class="h-100"></iframe>
          </div>
        </div>
      </div>

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

<?php include 'footer_data.php'; ?>