/** * 获取多选文件信息,包含子文件夹数量,文件数量,总大小,父目录权限 */ function path_info_muti($list, $time_type) { if (count($list) == 1) { if ($list[0]['type'] == "folder") { return path_info($list[0]['path'], $time_type); } else { return file_info($list[0]['path'], $time_type); } } $pathinfo = array('file_num' => 0, 'folder_num' => 0, 'size' => 0, 'size_friendly' => '', 'father_name' => '', 'mod' => ''); foreach ($list as $val) { if ($val['type'] == 'folder') { $pathinfo['folder_num']++; $temp = path_info($val['path']); $pathinfo['folder_num'] += $temp['folder_num']; $pathinfo['file_num'] += $temp['file_num']; $pathinfo['size'] += $temp['size']; } else { $pathinfo['file_num']++; $pathinfo['size'] += get_filesize($val['path']); } } $pathinfo['size_friendly'] = size_format($pathinfo['size']); $father_name = get_path_father($list[0]['path']); $pathinfo['mode'] = get_mode($father_name); return $pathinfo; }
public function testSugarChmod() { return true; $this->assertTrue(sugar_chmod($this->_filename)); $this->assertEquals($this->_getTestFilePermissions(), decoct(get_mode())); }
/** * sugar_chmod * Attempts to change the permission of the specified filename to the mode value specified in the * default_permissions configuration; otherwise, it will use the mode value. * * @param string filename - Path to the file * @param int $mode The integer value of the permissions mode to set the created directory to * @return boolean Returns TRUE on success or FALSE on failure. */ function sugar_chmod($filename, $mode = null) { if (!is_int($mode)) { $mode = (int) $mode; } if (!is_windows()) { if (!isset($mode)) { $mode = get_mode('file_mode', $mode); } if (isset($mode) && $mode > 0) { return @chmod($filename, $mode); } else { return false; } } return true; }
<?php /** * Common configuration */ // Init application mode $config['app']['mode'] = get_mode(array('localhost', '127.0.0.1')); // cookies $config['app']['cookies.encrypt'] = true; $config['app']['cookies.secret_key'] = 'BG?zm@A1t~6;|{euS,cA[)#gK~,<$p@0P$T~~I$,QRw&(5 BT4<,g w9}!3-}+/F'; $config['app']['cookies.cipher'] = MCRYPT_RIJNDAEL_256; $config['app']['cookies.cipher_mode'] = MCRYPT_MODE_CBC; // DB $config['db'] = array('prefix' => 'cms', 'driver' => 'mysql', 'dbpath' => 'localhost', 'dbname' => 'default', 'username' => 'root', 'password' => ''); $config['db']['dsn'] = sprintf('%s:dbname=%s;host:%s;', $config['db']['driver'], $config['db']['dbname'], $config['db']['dbpath']); //uploads $config['upload'] = array('folder' => 'public/data/uploads/', "maxsize" => 30000000, "allowed" => array('application/pdf', 'image/jpeg', 'image/jpg', 'image/png'), "hash" => true, "override" => true); // View $config['app']['view'] = new Slim\Views\Twig(); // Cache TTL in seconds $config['app']['cache.ttl'] = 60; // Max requests per hour $config['app']['rate.limit'] = 1000; // Logger $config['app']['log.writer'] = new \Slim\Extras\Log\DateTimeFileWriter(array('path' => __ROOT__ . 'public/data/logs', 'name_format' => 'Y-m-d', 'message_format' => '%label% - %date% - %message%')); function get_mode($whitelist) { $isapi = (bool) preg_match('|/api/v.*$|', $_SERVER['REQUEST_URI']); if ($isapi == 1) { return 'api'; }