PHP Classes

File: commands/ls.php

Recommend this page to a friend!
  Classes of Andoitz Jordan Marmolejo   PHP Query Terminal   commands/ls.php   Download  
File: commands/ls.php
Role: Example script
Content type: text/plain
Description: Class example for command
Class: PHP Query Terminal
Run command classes from an interactive console
Author: By
Last change: Update of commands/ls.php
Date: 4 months ago
Size: 763 bytes
 

Contents

Class file image Download
<?php
Class ls extends Command{
    private
$home = "home/";
    public function
__construct(){
       
parent::__construct();
    }
    public function
init($params){
        if(
count($params)>0){
           
$this->listFiles($params);
        }
        else{
           
$r = $this->home.$_SESSION["user"]["username"];
            if(
$d=opendir($r)){
               
$this->data.="\n";
                while(
false!==($e=readdir($d))){
                    if(
$e!='.'&&($e!='..')){
                        if(
is_dir($r.'/'.$e)){
                           
$this->data.=" d [[b;#88F;]".$e."]\n";
                        }
                        else{
                           
$this->data.=" f ".$e."\n";
                        }
                    }
                }
               
closedir($d);
            }
        }
    }
    private function
listFiles($params){
       
$result = null;
       
       
$pError = $this->syntaxError($params,1);
        if(!
$pError) $result .= "";
        else
$result = $pError."\n";
       
       
$this->data = $result;
    }
}
?>