input['dselect'])) foreach($idx->input['dselect'] as $key => $value) { if(!is_array($value)) echo strval($key).'='.strval($value).''.END; } exit; */ class browser { //input variables var $page; var $nitems; var $entry; var $sort; var $cmd_action; //output variables var $types=array(); var $names=array(); var $sizes=array(); var $times=array(); var $exts=array(); var $path; var $count; var $actual_items; var $npages; function browser() { global $idx,$std; $this->entry=$idx->input['entry']; $this->page=$idx->number('page',1,5946,1)-1; $this->nitems=$idx->number('nitems',20,2048,20); $this->sort=$idx->number('sort',0,3,0); $this->cmd_action=$idx->number('cmd_action',2,8,2); $this->path=''; $this->count=0; $this->npages=1; //check to sure that we have permision to read the dir if(!is_readable($this->entry)) { $std->print_error('The entry ['.$this->entry.'] was not found or no permission right to access it'); exit; } if(!is_dir($this->entry)) { $std->print_error('The entry ['.$this->entry.'] is not a directory'); exit; } //check the input if(isset($idx->input['bt_next'])) { $this->page++; } else if(isset($idx->input['bt_prev'])) { $this->page--; } if(isset($idx->input['bt_up'])) { $idx->input['entry']=@dirname($idx->input['entry']); $idx->input['entry']=str_replace('\\','/',$idx->input['entry']); $idx->input['entry']=str_replace('//','/',$idx->input['entry']); $idx->input['entry']=rtrim($idx->input['entry']," /\\"); $this->entry=$idx->input['entry']; $this->page=0; } } //------------------------------------------------------------------------------ function read() { global $idx,$std; //read the dir content into an array $d = dir($this->entry); @chmod($d->path,0755); $this->path=$d->path; while(false !== ($item = $d->read())) { if($item=='.'||$item=='..') continue; $path=$d->path.'/'.$item; $type=is_dir($path)?0:1; $time=filemtime($path); array_push($this->names,$item); array_push($this->sizes,($type==0)?0:filesize($path)); array_push($this->times,$time); array_push($this->types,$type); } $d->close(); //keep the count of items and number of pages $this->count=count($this->types); $this->npages=ceil($this->count/$this->nitems); if($this->npages==0) $this->npages=1; //sort the result //0->name 1->time 2->size 3->ext if($this->sort==1) array_multisort($this->types,$this->names,$this->times,$this->sizes); else if($this->sort==2) array_multisort($this->types,$this->times,$this->names,$this->sizes); else if($this->sort==3) array_multisort($this->types,$this->sizes,$this->names,$this->times); } //------------------------------------------------------------------------------ function dir_link($dir) { $url="./index.php?action=0&page=0&sort={$this->sort}&nitems={$this->nitems}&cmd_action={$this->cmd_action}&entry={$this->path}/{$dir}"; return ''.$dir.''; } //------------------------------------------------------------------------------ function file_link($file) { $url="./index.php?action=1&entry={$this->path}/{$file}"; return ''.$file.''; } //------------------------------------------------------------------------------ function content() { //validate the current page $this->page=max($this->page,0); $this->page=min($this->page,$this->npages-1); $start=$this->page*$this->nitems; $end=min($start+$this->nitems,$this->count); $ret=''; $id=0; $this->actual_items=0; for($i=$start;$i<$end;$i++) { if($this->types[$i]==0) { $ret.= '