public function add($file, $name, $data, $item) { $data['__item'] = $item; $dir = $this->dir_path($item, null, $name, $data); $new_filename = $this->real_uploaded_filename($name, $data, basename($file)); IO_FS::mkdir($dir, null, true); return IO_FS::cp($file, $dir . '/' . $new_filename); }
public function on_execute(DB_Cursor $cursor) { self::$cnt++; if ($cursor->execution_time < self::$time_filter) { return; } if (!self::check_filters()) { return; } $dir = IO_FS::Path(self::$log_file)->dirname; IO_FS::mkdir($dir); $fh = fopen(self::$log_file, 'a'); fwrite($fh, $this->create_string($cursor) . "\n"); fclose($fh); CMS::chmod_file(self::$log_file); }
/** */ public function generate() { foreach (new Dev_Source_LibraryDirIterator($this->path_to_library) as $module_name => $module) { if (Core_Strings::contains($module_name, '.')) { $file_place = $this->path_to_html . "/" . Core_Regexps::replace('{/\\w+$}', '', Core_Strings::replace($module_name, '.', '/')); if (!IO_FS::exists($file_place)) { IO_FS::mkdir($file_place, 0775, true); } } try { $module_generator = new Dev_Source_Doc_ModuleGenerator($module, $this->path_to_html . "/" . Core_Strings::replace($module_name, '.', '/')); $module_generator->write(); $module_generator->write_diagram(); $this->add_to_toc($module_generator); } catch (Dev_Source_InvalidSourceException $e) { } } $this->write_css(); $this->write_toc(); $this->write_index(); }
protected function write($path, $content) { $os_path = './' . ltrim($path, '\\/.'); $os_dir = dirname($os_path); if (!IO_FS::exists($dir)) { IO_FS::mkdir($os_dir); } IO_FS::File($os_path)->update($content); //IO_FS::chmod($path, IO_FS::option('file_mod')); return $this; }
/** * @return Log_FileHandler */ public function init() { if (!IO_FS::exists($dir = IO_FS::File($this->path)->dir_name)) { IO_FS::mkdir($dir, null, true); } $this->stream = IO_FS::FileStream($this->path, 'a'); return $this; }
protected function dir($file = '') { $dir = Templates_HTML_Assets_Join::option('dir'); $ext = pathinfo($file, PATHINFO_EXTENSION); $paths = Templates_HTML::option('paths'); if (!empty($ext) && isset($paths[$ext])) { $dir = '/' . trim($paths[$ext] . '/' . trim($dir, PATH_SEPARATOR), '/'); } if (!is_dir('.' . $dir)) { IO_FS::mkdir('.' . $dir, IO_FS::option('dir_mod'), true); } return "{$dir}/{$file}"; }
public function preprocess($file, $data) { $suffix = '.scss'; $content = null; if (Core_Strings::ends_with($file, $suffix)) { $this->load(); if (!$this->server) { return array($file, $content); } // TODO: move to function $file = Templates_HTML::css_path($file, false); $file_name = ltrim($file, '/\\.'); $scss_file = './' . ltrim($file, '/'); $css_file = str_replace('.scss', '.css', $file_name); $css_file = str_replace('styles/', '', $css_file); $css_file = './' . self::option('scss_output_dir') . '/' . $css_file; $css_file = str_replace('//', '/', $css_file); $dir = dirname($css_file); if (!IO_FS::exists($dir)) { IO_FS::mkdir($dir); } if ($this->server->needsCompile($scss_file, $css_file, $etag = '')) { $this->server->compile($scss_file, $css_file); } return array('/' . ltrim($css_file, '\\/.'), $content); } return array($file, $content); }
/** * @return boolean */ private function make_storage_dir() { return IO_FS::mkdir($this->full_path, File_Assets::option('dir_permissions'), true); }
/** * @return boolean */ protected function make_storage() { return IO_FS::mkdir($this->path, 0777, true); }
public function __construct() { $this->cache = Cache::connect(Templates_HTML_Preprocess::option('less_cache_dns')); $output = Templates_HTML_Preprocess::option('less_output_dir'); IO_FS::mkdir($output, null, true); }
/** * Возвращает путь к файлу, в котором храниться значение с ключом $key * * @param string $key * * @return string */ public function path($key) { $key = str_replace(DIRECTORY_SEPARATOR, '_', $key); $key = str_replace('.', '_', $key); if (Core_Strings::contains($key, ':') && preg_match('{(.*)\\:([^:]+)$}', $key, $m)) { $dir = $this->path . DIRECTORY_SEPARATOR . trim(str_replace(':', DIRECTORY_SEPARATOR, $m[1]), DIRECTORY_SEPARATOR . ' '); if (!IO_FS::exists($dir)) { IO_FS::mkdir($dir, null, true); } $key = $m[2]; } else { $dir = $this->path; } return $dir . DIRECTORY_SEPARATOR . $key; }
public function files_data($name, $data, $item) { $fdata = array(); if (is_object($item)) { $i_id = $item->id(); if (empty($i_id)) { return $fdata; } } $key = $name . '-' . $i_id; if (isset($this->files_data[$key])) { return $this->files_data[$key]; } $file = IO_FS::File($this->files_data_path($name, $data, $item)); if ($file->exists()) { $fdata = unserialize($file->load()); } else { $dir = $file->dir_name; if (!IO_FS::exists($dir)) { IO_FS::mkdir($dir, null, true); } $files = $this->read_dir($file->dir_name); $fdata = array(); foreach ($files as $path) { $fdata['files'][] = array('name' => pathinfo($path, PATHINFO_BASENAME)); } $file->update(serialize($fdata)); $file->set_permission(); } if (isset($fdata['files']) && !empty($fdata['files']) && !empty($this->filters)) { $fdata['files'] = array_filter($fdata['files'], array($this, 'filter_callback')); } return $this->files_data[$key] = $fdata; }
protected function compile($less_fname, $css_fname) { self::load(); $options = self::option('options'); // generate source map if (self::option('sourse_map')) { $map_file = str_replace('styles/', '', $css_fname); $map_file = trim(str_replace('.less.css', '.map', $map_file), '/.'); $map_dir = './styles/less-maps/'; $map_path = "{$map_dir}{$map_file}"; IO_FS::mkdir(dirname($map_path)); $options = array_merge($options, array('sourceMap' => true, 'sourceMapWriteTo' => $map_path, 'sourceMapURL' => trim($map_path, '.'))); // if is out of docroot if ($less_fname[0] == '/' || Core_Strings::starts_with($less_fname, '..') || Core_Strings::starts_with($less_fname, './..')) { $less_fname = "file://{$less_fname}"; $less_fname = '.' . Templates_HTML::extern_filepath($less_fname); } } $options['import_dirs'] = self::option('less_import_dirs'); $dir = dirname($css_fname); $url = 'http://' . WS::env()->request->host . '/'; $args = array(array($less_fname => $url), $options); $css_file_name = Core::invoke(self::option('less_callback'), $args); $cached_file = rtrim($options['cache_dir'], '/') . '/' . $css_file_name; if (is_file($cached_file) && !(WS::env()->request['less_compile'] && self::option('debug'))) { $less_ftime = filemtime($cached_file); $css_ftime = false; if (IO_FS::exists($css_fname)) { $css_ftime = filemtime($css_fname); } if ($css_ftime && $css_ftime >= $less_ftime) { return false; } } $css = file_get_contents($cached_file); IO_FS::File($css_fname)->update($css); }
/** * Формирует файлы с заголовками и параметрами * */ protected function heads() { IO_FS::mkdir(Mail_List::option('root') . '/recipients'); foreach ($this->list as $k => $v) { $this->head($v, $k); } return $this; }
public function create() { return IO_FS::mkdir($this->path, null, true); }
static function modified_image($path, $mods) { if (is_string($mods)) { $mods = self::parse_modifiers($mods); } $ext = false; $name = false; if ($m = Core_Regexps::match_with_results('{(.+)\\.(jpe?g|gif|png|bmp)$}i', $path)) { $name = $m[1]; $ext = strtolower($m[2]); } if (!$ext || !IO_FS::exists($path)) { $path = '../tao/files/images/admin.gif'; $ext = 'gif'; $name = 'error'; } $name = preg_replace('{^\\.\\./}', 'up/', $name); $name = ltrim($name, '.'); $name = ltrim($name, '/'); $stat = IO_FS::Stat($path); $mtime = $stat->mtime->timestamp; $name .= "-{$stat->size}-{$mtime}-"; $name .= md5(serialize($mods)); $cache = self::$cache_dir . "/{$name}.{$ext}"; if (IO_FS::exists('./' . $cache)) { return '/' . $cache; } $dir = preg_replace('{/([^/]+)$}', '', $cache); if (!IO_FS::exists($dir)) { IO_FS::mkdir($dir); } $image = self::Image($path); $image->modify($mods); $image->save('./' . $cache); CMS::chmod_file('./' . $cache); return '/' . $cache; }
protected function mods_process($path) { IO_FS::mkdir($path, null, true)->set_permission(); Core::load('CMS.Images'); foreach ($this->filelist() as $f) { $name = pathinfo($f, PATHINFO_BASENAME); if (isset($this->to_remake[$name])) { $image = CMS_Images::Image($f); $image->modify($this->mods); $file = "{$path}/{$name}"; $image->save("{$path}/{$name}"); IO_FS::File($file)->set_permission(); } } $this->to_remake = array(); }
protected function onpage_to_file($type = 'js') { $enable = $this->use_onpage_to_file[$type]; if ($enable) { $content = $this[$type]; $request = WS::env()->request; $path = 'onpage' . '/' . trim($request->path, '/.'); $method = "{$type}_path"; $dir = '.' . Templates_HTML::$method($path); $name = md5($content); // $name = md5($request->query); $file = $dir . '/' . $name . '.' . $type; if (!is_file($file)) { IO_FS::rm($dir); IO_FS::mkdir($dir); file_put_contents($file, $content); } $this->use_file(array('name' => trim($file, '.'), 'weight' => 100000)); $this[$type] = ''; } return $this; }