function index() { $this->load->helper('file'); $tmpdir = '../../tmp'; echo 'upload dir:' . $this->config->item('upload_directory') . '<br />'; echo octal_permissions(fileperms($this->config->item('upload_directory'))) . '<br />'; echo 'tmp dir:' . $tmpdir . '<br />'; echo octal_permissions(fileperms($tmpdir)) . '<br />'; if (opendir($this->config->item('upload_directory'))) { echo 'sucessfully opened upload dir<br />'; } else { echo 'failed to open upload dir<br />'; } if (write_file($this->config->item('upload_directory') . '/test.txt', 'success')) { echo 'successfully wrote to upload dir'; } if (opendir($tmpdir)) { echo 'sucessfully opened tmp dir<br />'; } else { echo 'failed to open upload dir<br />'; } if (write_file($this->config->item('../../tmp') . '/test.txt', 'success')) { echo 'successfully wrote to tmp dir'; } phpinfo(); }
function index() { $cache_chomd = octal_permissions(fileperms(APPPATH . 'cache')); $this->reload_all_cache(); //更新全局菜单缓存,可以去掉这行 $this->view('index', array('date' => date('Y-m-d H:i:s'), 'cache_chomd' => $cache_chomd)); }
public function test() { //$this->load->helper('file'); //返回和index.php在同一个目录下的test.txt文件的内容,使用的是原生的php函数 echo file_get_contents('test.txt'); $this->load->helper('file'); $data = 'Some file data<br/>'; //write_file方法会覆盖文件中已有的内容 if (!write_file('test.txt', $data)) { echo 'Unable to write the file<br/>'; } else { echo 'File written!<br/>'; } // if (delete_files('zcyytest/')) { // echo '删除成功!<br/>'; // } else { // echo '删除失败!<br/>'; // } //连这个目录下的文件夹一起删除 // if (delete_files('zcyytest/', TRUE)) { // echo '删除成功!<br/>'; // } else { // echo '删除失败!<br/>'; // } echo APPPATH . '<br/>'; $controllers = get_filenames(APPPATH . '../' . 'zcyytest/'); print_r($controllers); echo '<br/>'; $models_info = get_dir_file_info(APPPATH . '../' . 'zcyytest/'); print_r($models_info); echo '<br/>'; print_r(get_file_info(APPPATH . '../' . 'zcyytest/1.txt')); echo '<br/>'; //将文件权限的数字格式(例如 fileperms() 函数的返回值)转换为标准的符号格式。 echo symbolic_permissions(fileperms('test.txt')); echo '<br/>'; //将文件权限的数字格式(例如 fileperms() 函数的返回值)转换为三个字符的八进制表示格式。 echo octal_permissions(fileperms('test.txt')); echo '<br/>'; }
public function index() { $this->Purview_model->checkPurview($this->tablefunc); $folder = $this->input->post('folder'); if (!$folder) { $folder = $this->defaultfolder; } $listarr = directory_map($folder, 1); $folderlist = array(); $phplist = array(); $csslist = array(); $jslist = array(); foreach ($listarr as $list) { $thispath = $folder . '/' . $list; $newlist = get_file_info($thispath); $newlist['permissions'] = octal_permissions(fileperms($thispath)); $newlist['name'] = $list; if (is_dir($thispath)) { $folderlist[] = $newlist; } else { $newlist['size'] = byte_format($newlist['size']); $ext = get_suffix($thispath); switch ($ext) { case 'php': $phplist[] = $newlist; break; case 'css': $csslist[] = $newlist; break; case 'js': $jslist[] = $newlist; break; default: break; } } } $res = array('tpl' => 'list', 'tablefunc' => $this->tablefunc, 'folderlist' => $folderlist, 'phplist' => $phplist, 'csslist' => $csslist, 'jslist' => $jslist, 'defaultfolder' => $this->defaultfolder, 'folder' => $folder); $this->load->view($this->tablefunc, $res); }
public function del() { $filename = $this->input->get('filename'); if (!$filename) { $filename = $this->input->post('filename'); if (!$filename) { $this->outJson(-1); } } if (is_string($filename)) { $filename = array($filename); } $noauth = array(); foreach ($filename as $k => $v) { $file = get_file_info($this->path . $v); if ($file) { $auth = octal_permissions(fileperms($this->path . $v)); $number = substr($auth, -1); if ($number != 7) { $noauth[] = $v; } else { if (is_file($file['server_path'])) { unlink($file['server_path']); } if (is_dir($file['server_path'])) { rmdir($file['server_path']); } } } } if (!$noauth) { $this->outJson(0); } else { $this->outJson(1, '', implode(',', $noauth) . '没有权限删除!'); } }
function index() { $status = true; if (!file_exists(INTALL_UPLOAD_TEMP_PATH)) { $status = dir_create(INTALL_UPLOAD_TEMP_PATH); } $install_uploaded_chomd = $status ? octal_permissions(fileperms(INTALL_UPLOAD_TEMP_PATH)) : 0; $install_config_chomd = $status ? @octal_permissions(fileperms(APPPATH . 'config' . DIRECTORY_SEPARATOR . 'aci.php')) : 0; $error = array('uploadChomd' => $install_uploaded_chomd, 'configChomd' => $install_config_chomd, 'supportZip' => class_exists('ZipArchive')); $this->view('index', $error); }
public function file_helper() { $this->load->helper('file'); $string = read_file('./path/to/file.php'); $data = 'Some file data'; if (!write_file('./path/to/file.php', $data)) { echo 'Unable to write the file'; echo "<br>"; } else { echo 'File written!'; echo "<br>"; } write_file('./path/to/file.php', $data, 'r+'); echo "<br>"; delete_files('./path/to/directory/'); echo "<br>"; delete_files('./path/to/directory/', TRUE); echo "<br>"; $controllers = get_filenames(APPPATH . 'controllers/'); echo "<br>"; $models_info = get_dir_file_info(APPPATH . 'models/'); echo "<br>"; $file = 'somefile.png'; echo $file . ' is has a mime type of ' . get_mime_by_extension($file); echo "<br>"; echo symbolic_permissions(fileperms('./index.php')); // -rw-r--r-- echo "<br>"; echo octal_permissions(fileperms('./index.php')); // 644 echo "<br>"; }
public function test_octal_permissions() { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)->lastModified(time() - 86400)->at($this->_test_dir); $this->assertEquals('777', octal_permissions($file->getPermissions())); }