예제 #1
0
파일: toolkit.php 프로젝트: laekov/shiruku
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);
}
예제 #2
0
파일: admin.php 프로젝트: laekov/shiruku
     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) {