args) == 0) return ''; $args = explode(' ', $r->args); if ($args[0] == 'ls') { return $this->ls($args); } else if ($args[0] == 'cat') { return $this->cat($args); } return '不明なコマンドです。: '.$args[0]; } public function ls ($args) { $opt = ''; $pwd = ''; for ($i = 1; $i < count($args); $i++) { if (mb_substr($args[$i], 0, 1, 'utf-8')) $opt = $args[$i]; } if (str_contains($opt, 'l')) { $ps = null; $pg = null; if (str_contains($opt, 't')) { $pg = DB::table('blg_content')->select('publish_date')->where('isPost', 0)->orderBy('title', 'asc')->first(); $ps = DB::table('blg_content')->select('publish_date')->where('isPost', 1)->orderBy('title', 'asc')->first(); } else { $pg = DB::table('blg_content')->select('publish_date')->where('isPost', 0)->orderBy('publish_date', 'desc')->first(); $ps = DB::table('blg_content')->select('publish_date')->where('isPost', 1)->orderBy('publish_date', 'desc')->first(); } return "合計 2
drwxr-xr-x 2 suwako suwako ".(str_contains($opt, 'h') ? '4.0K' : '4096')." ".date('m', $ps->publish_date)."月 ".date('d', $ps->publish_date)." ".date('H:i', $ps->publish_date)." post
drwxr-xr-x 2 suwako suwako ".(str_contains($opt, 'h') ? '4.0K' : '4096')." ".date('m', $pg->publish_date)."月 ".date('d', $pg->publish_date)." ".date('H:i', $pg->publish_date)." page"; } return 'post page'; } public function cat ($args) { if (isset($args[1])) { $cat = explode('/', $args[1]); $txt = null; $mode = 0; $slug = ''; for ($i = 1; $i < count($cat); $i++) { if (str_contains($cat[$i], 'post')) $mode = 1; $slug = $cat[$i]; } $txt = DB::table('blg_content')->select('title', 'message')->where('slug', $slug)->where('isPost', $mode)->first(); if ($txt) { return ">>".$txt->title."<<

".$txt->message; } } return ''; } }