function rmdirDFS($dirPath) { $dir = opendir($dirPath); while ($content = readdir($dir)) { if ($content != '.' && $content != '..') { $tgtPath = $dirPath . '/' . $content; if (is_file($tgtPath)) { unlink($tgtPath); } elseif (is_dir($tgtPath)) { rmdirDFS($tgtPath); } } } rmdir($dirPath); }
if (!isset($_POST['config'])) { $config = false; } elseif ($config === null) { srkSend((object) array('error' => 'Illegal config file ')); } if ($config) { $config->author = $_SESSION['userId']; } $updRes = penUpdate($penId, $config, $content); srkSend($updRes); } elseif ($srkEnv->reqURL[3] == 'remove') { $penId = $_POST['penId']; $penPath = $srkEnv->penPath . "/" . $penId; if (is_dir($penPath)) { srkLog($penPath); rmdirDFS($penPath); penListGenerate(); srkSend((object) array('error' => false)); } else { srkSend((object) array('error' => 'No such pen')); } } elseif ($srkEnv->reqURLLength == 4 && $srkEnv->reqURL[3] == 'content') { $penId = $srkEnv->reqURL[4]; $penPath = $srkEnv->penPath . '/' . $penId; $res = (object) array(); $res->content = getFileContent($penPath . '/content.md'); if ($res->content == -1) { $res->content = ''; } $res->config = getFileContent($penPath . '/config.json'); if ($res->config == -1) {