private function getFile($lang) { $path = dir_path('resources'); $file_name = $lang; $file_extension = '.php'; $file = $path . DIRECTORY_SEPARATOR . $file_name . $file_extension; return $file; }
public function run() { $faker = Faker::create(); $count = 50; $ids = Estate::lists('estate_id'); $images = read_dir(dir_path('estates')); $images = array_values(array_diff($images, ['alien.png'])); for ($i = 0; $i < $count; $i++) { Image::create(['image' => $images[$i], 'estate_id' => $faker->randomElement($ids), 'preview' => $faker->boolean(30)]); } }
function dir_list($path, $exts = '', $list = array()) { $path = dir_path($path); $files = glob($path . '*'); foreach ($files as $v) { if (!$exts || preg_match("/\\.({$exts})/i", $v)) { $list[] = retrieve($v); if (is_dir($v)) { $list = dir_list($v, $exts, $list); } } } return $list; }
function dftp($ftphost, $ftpuser, $ftppass, $ftpport = 21, $root = '/', $pasv = 0, $ssl = 0) { if ($ssl && function_exists('ftp_ssl_connect')) { $this->fp = @ftp_ssl_connect($ftphost, $ftpport); } else { if (function_exists('ftp_connect')) { $this->fp = @ftp_connect($ftphost, $ftpport); } else { return false; } } $this->connected = @ftp_login($this->fp, $ftpuser, $ftppass); @ftp_pasv($this->fp, $pasv); $this->root = dir_path($root); }
/** * ueditor在线图片管理 * * @author mrmsl <*****@*****.**> * @date 2013-07-16 21:56:18 * * @return void 无返回值 */ public function ueditorImageManagerAction() { require CORE_PATH . 'functions/dir.php'; $file_arr = list_dir(UPLOAD_PATH); $str = ''; if ($file_arr) { rsort($file_arr, SORT_STRING); foreach ($file_arr as $file) { if (preg_match('/\\.(gif|jpeg|jpg|png|bmp)$/i', $file)) { $str .= $file . 'ue_separate_ue'; } } } exit(str_replace(dir_path(UPLOAD_PATH), '', $str)); }
private function pickLanguage($lang) { $path = dir_path('resources'); $file_name = $lang; $file_extension = '.php'; $file = $path . DIRECTORY_SEPARATOR . $file_name . $file_extension; $current_texts = []; if (File::exists($file)) { include $file; $page = (string) r(); $texts = $texts[$page]; $general_texts = $general; $current_texts = array_merge($texts, $general_texts); } return $current_texts; }
/** * 创建目录 * * @param string $path 路径 * @param string $mode 属性 * @return string 如果已经存在则返回true,否则为flase * @ 致远 */ function dir_create($path, $mode = 0777) { if (is_dir($path)) { return TRUE; } $ftp_enable = 0; $path = dir_path($path); $temp = explode('/', $path); $cur_dir = ''; $max = count($temp) - 1; for ($i = 0; $i < $max; $i++) { $cur_dir .= $temp[$i] . '/'; if (@is_dir($cur_dir)) { continue; } @mkdir($cur_dir, 0777, true); @chmod($cur_dir, 0777); } return is_dir($path); }
function meta_file_path($type, $file_path) { $dir_name = 'meta'; $file_path = dir_path($file_path); return $file_path . $dir_name . '/' . $type . '.txt'; }
function delete_install($dir) { $dir = dir_path($dir); if (!is_dir($dir)) { return FALSE; } $list = glob($dir . '*'); foreach ($list as $v) { is_dir($v) ? delete_install($v) : @unlink($v); } return @rmdir($dir); }
function dir_delete($dir) { //ɾ������Ŀ¼,�谤��ɾ��Ŀ¼�µ�Ŀ¼���ļ� $dir = dir_path($dir); if (!is_dir($dir)) { return false; } $list = glob($dir . '*'); //Ѱ����*ģʽƥ��������ļ�·�� if ($list) { foreach ($list as $v) { is_dir($v) ? dir_delete($v) : @unlink($v); //ɾ�����ļ� } } return @rmdir($dir); }
/** * 设置目录下面的所有文件的访问和修改时间 * * @param string $path 路径 * @param int $mtime 修改时间 * @param int $atime 访问时间 * * @return bool */ function touch_dir($path, $mtime = START_TIME, $atime = START_TIME) { $path = dir_path($path); if (!is_dir($path)) { return false; } !is_dir($path) && touch($path, $mtime, $atime); $files = glob($path . '*'); foreach ($files as $v) { is_dir($v) ? touch_dir($v, $mtime, $atime) : touch($v, $mtime, $atime); } return true; }
function dir_list($path, $exts = '', $list = array()) { $path = dir_path($path); $files = glob($path . '*'); foreach ($files as $v) { if (!$exts || pathinfo($v, PATHINFO_EXTENSION) == $exts) { $list[] = $v; if (is_dir($v)) { $list = dir_list($v, $exts, $list); } } } return $list; }
function __buildImage($file_path) { $this->_progressStep('EncodeImage', 5, 'Encoding Image'); $ext = file_extension($file_path); $parent_dir = dir_path($file_path); $tmp_file = $file_path; $orig_dimensions = get_file_info('dimensions', $file_path); if (!$orig_dimensions) { throw new RuntimeException('Could not read image: ' . $file_path); } $cmd = ''; $target_dimensions = scale_proud($orig_dimensions, $this->_options['EncoderDimensions']); if ($target_dimensions) { $cmd .= ' -size ' . $orig_dimensions; $cmd .= ' -resize ' . $target_dimensions; } else { $target_dimensions = $this->_options['EncoderDimensions']; } $frame_path = frame_file_path($file_path, $this->_options['EncoderDimensions'], 1); $file = $frame_path . '0.' . $this->_options['EncoderExtension']; if (!safe_path($file)) { throw new RuntimeException('Could not create path: ' . $file); } if ($cmd || $this->_options['EncoderExtension'] != substr($tmp_file, -strlen($this->_options['EncoderExtension']))) { $cmd = $this->_options['PathCropper'] . $cmd . ' ' . $tmp_file; $cmd .= ' -quality ' . $this->_options['EncoderImageQuality']; $cmd .= ' -type TrueColor'; switch ($this->_options['EncoderExtension']) { case 'ping': case 'png': case 'giff': case 'gif': $cmd .= 'Matte -depth 32'; } $cmd .= ' ' . $file; $shell_result = $this->_shellExecute($cmd); if ($shell_result) { throw new RuntimeException('Could not create image: ' . $shell_result); } } else { copy($tmp_file, $file); } if (!file_exists($file)) { throw new RuntimeException('Failed to create image: ' . $file . ' ' . $cmd); } $this->_progressStep('EncodeImage', 100, 'Encoded Image'); }
function dir_delete($dir) { $dir = dir_path($dir); if (!is_dir($dir)) { return false; } $dirs = array(DT_ROOT . '/admin/', DT_ROOT . '/api/', DT_CACHE . '/', DT_ROOT . '/file/', DT_ROOT . '/include/', DT_ROOT . '/lang/', DT_ROOT . '/member/', DT_ROOT . '/module/', DT_ROOT . '/skin/', DT_ROOT . '/template/', DT_ROOT . '/mobile/'); if (substr($dir, 0, 1) == '.' || in_array($dir, $dirs)) { die("Cannot Remove System DIR {$dir} "); } $list = glob($dir . '*'); if ($list) { foreach ($list as $v) { is_dir($v) ? dir_delete($v) : @unlink($v); } } return @rmdir($dir); }
function dir_delete($dir) { $dir = dir_path($dir); if (!is_dir($dir)) { return false; } $list = glob($dir . '*'); foreach ($list as $file) { is_dir($file) ? dir_delete($file) : unlink($file); } return rmdir($dir); }
/** * 删除目录及目录下面的所有文件 * * @param string $dir 路径 * @return bool 如果成功则返回 TRUE,失败则返回 FALSE */ static function dir_delete($dir) { $dir = dir_path($dir); if (!is_dir($dir)) { return FALSE; } $list = glob($dir . '*'); foreach ($list as $v) { is_dir($v) ? self::dir_delete($v) : @unlink($v); } return @rmdir($dir); }
/** * 创建目录 * @param string $path * @param integer $mode * @return boolean */ function create_dir($path, $mode = 0777) { if (is_dir($path)) { chmod($path, $mode); return true; } // 得到目录路径 $path = dir_path($path); $dir_name = explode('/', $path); $current_dir = ''; $max = count($dir_name) - 1; for ($i = 0; $i < $max; $i++) { $current_dir .= $dir_name[$i] . '/'; if (is_dir($current_dir)) { continue; } mkdir($current_dir, $mode, true); chmod($current_dir, $mode); } return is_dir($path); }