public function admin_index() { $logDir = LOGS; $Folder = new Folder($logDir, false); $logfiles = $Folder->find('.*.log(\\.[0-9])?', true); $files = array(); foreach ($logfiles as $logfile) { $F = new File($logDir . $logfile); $file = array('name' => $logfile, 'dir' => $logDir, 'size' => $F->size(), 'last_modified' => $F->lastChange(), 'last_access' => $F->lastAccess()); array_push($files, $file); } $this->set(compact('files')); }
/** * testLastAccess method * * @return void */ public function testLastAccess() { $someFile = new File(TMP . 'some_file.txt', false); $this->assertFalse($someFile->lastAccess()); $this->assertTrue($someFile->open()); $this->assertWithinMargin($someFile->lastAccess(), time(), 2); $someFile->close(); $someFile->delete(); }
private function __advancedFileFind($conditions) { if (empty($this->fileList[1])) { $this->return = array(); return true; } $i = 0; foreach ($this->fileList[1] as $file) { if (in_array($file, $this->ignore)) { continue; } if ($this->recursive > -2) { $Folder = new Folder($this->path); $this->return[$i]['File']['path'] = $Folder->path . DS . $file; $this->return[$i]['File']['relative'] = $this->__relativePath($this->return[$i]['File']['path']); $stat = stat($this->return[$i]['File']['path']); $this->__fileStatus($i, $stat); if ($this->recursive > -1) { $this->return[$i]['File']['accessed'] = date('Y-m-d H:i:s', $stat['atime']); $this->return[$i]['File']['modified'] = date('Y-m-d H:i:s', $stat['mtime']); $this->return[$i]['File']['created'] = date('Y-m-d H:i:s', $stat['ctime']); $File = new File($this->return[$i]['File']['path']); $info = $File->info(); $this->return[$i]['File']['dirname'] = $info['dirname']; $this->return[$i]['File']['name'] = $info['basename']; $this->return[$i]['File']['extension'] = isset($info['extension']) ? $info['extension'] : null; $this->return[$i]['File']['filename'] = $info['filename']; $this->return[$i]['File']['writable'] = $File->writable(); if ($this->recursive > 0) { $this->return[$i]['File']['size'] = $File->size(); $this->return[$i]['File']['owner'] = $File->owner(); $this->return[$i]['File']['group'] = $File->group(); $this->return[$i]['File']['accessed'] = $File->lastAccess(); $this->return[$i]['File']['modidfied'] = $File->lastChange(); $this->return[$i]['File']['charmod'] = $File->perms(); if ($this->recursive > 1) { $this->return[$i]['File']['type'] = filetype($this->return[$i]['File']['path']); $this->return[$i]['File']['md5'] = $File->md5(); $this->return[$i]['File']['Extended'] = stat($this->return[$i]['File']['path']); $i++; continue; } $i++; } $i++; } $i++; } $i++; } return true; }