/** * @param string $image_ * * @return \Components\Uri */ public static function uriForPath($image_) { $extension = Io::fileExtension($image_); $key = md5($image_); Cache::set($key, $image_); return Environment::uriComponents('ui', 'image', "{$key}.{$extension}"); }
/** * Scans default locations for a mongodb server socket. * * @return string */ public static function lookupSocket() { /* @var $path Io_Path */ foreach (Io::tmpPathSystem() as $path) { if (preg_match('/mongo[-\\D.sock]/', $path->getPath())) { return $path->getPath(); } } return null; }
/** * @param string $tmpFile_ * * @return \Components\Memory_Shared_Shm_Temporary */ public static function create($file_ = null) { if (false === static::isSupported()) { throw new Exception_NotSupported('memory/shared/shm', 'Shared memory with \'shm\' is not supported. Compile PHP with \'--enable-sysvshm\'.'); } // FIXME Resolve dependency to i/o component. if (null === $file_) { $file_ = Io::tmpFileName('shm'); } return new static(ftok($file_, 'a'), $file_); }
public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_) { $params = $uri_->getPathParams(); $storeName = array_shift($params); $categoryName = array_shift($params); $file = Io::fileUpload(); $store = Media::store($storeName); $store->add($file, $file->getName(), $categoryName); // TODO JSON echo $store->uri($file->getName(), $categoryName); }
/** * 删除CSV * */ public function action_del() { $id = (int) $this->getQuery('sid'); $info = DB::select('uid', 'src_file')->from('imgup_movestore')->where('id', '=', $id)->fetch_row(); if (!empty($info)) { $file = Io::strip(DOCROOT . 'src_csv/' . $info['uid'] . '/' . $info['src_file']); @unlink($file); DB::delete('imgup_movestore')->where('id', '=', $id)->execute(); DB::delete('store_imgs')->where('sid', '=', $id)->where('uid', '=', $info['uid'])->execute(); } $this->request->redirect('/admin/csvfile'); $this->auto_render = false; }
/** * @return bool */ protected function _validateData() { $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); $resultDir = $this->_ioObject->getResultFileDirectory($resultClassName); if (!$this->definedClasses->isClassLoadable($sourceClassName)) { $this->_addError('Source class ' . $sourceClassName . ' doesn\'t exist.'); return false; } elseif (!$this->_ioObject->makeResultFileDirectory($resultClassName) && !$this->_ioObject->fileExists($resultDir)) { $this->_addError('Can\'t create directory ' . $resultDir . '.'); return false; } return true; }
/** * 下载文件 * * @param integer $fileId * @throws EGP_Exception */ public function action_download() { $this->checkLogin(); $id = (int) $this->getQuery('id'); $app = trim($this->getQuery('app')); $info = DB::select()->from('imgup_movestore')->where('id', '=', $id)->where('uid', '=', $this->auth['uid'])->execute()->current(); $filename = ''; if ($app == 'source') { $filename = $info['src_file']; $savaname = Io::strip(DOCROOT . 'src_csv/' . $this->auth['uid'] . '/' . $filename); } else { $filename = $info['dest_file']; $savaname = Io::strip(DOCROOT . 'dest_csv/' . $this->auth['uid'] . '/' . $filename); } if (empty($info) || !is_readable($savaname)) { throw new Exception('指定的文件不存在或者已经被删除'); } header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($savaname)); header('Content-Disposition: attachment; filename=' . basename($info['csv_file'])); readfile($savaname); }
/** * {@inheritdoc} */ public function unreference(Io $io) { $id = (int) $io->getResource(); if (isset($this->sockets[$id]) && $io === $this->sockets[$id]) { $this->unreferenced[$id] = $io; } }
/** * @see \Components\Io_Archive_Zip::close() \Components\Io_Archive_Zip::close() */ public function close() { $properties = $this->properties->toArray(); $properties[$this->getStyle()] = $this->getFields(); $pass = Io::tmpFile(); $pass->setContent(json_encode($properties)); $this->add($pass, self::FILE_PASS); $manifest = Io::tmpFile(); $manifest->setContent(json_encode($this->m_files)); parent::add($manifest, self::FILE_MANIFEST); parent::close(); $manifest->delete(); $pass->delete(); return $this; }
/** * 编辑图片 */ public function action_picedit() { $this->checklogin(); $this->template->pid = $pid = (int) $this->getRequest('pid'); $this->template->zoom = $zoom = trim($this->getQuery('zoom')); $this->template->info = $info = ORM::factory('img')->where('imgs.userid', '=', (int) $this->auth['uid'])->where('imgs.id', '=', $pid)->find(); if (empty($info->picname)) { $this->show_message('非法访问', 0, array(), true); } $url = "http://" . $info->disk_id . '.wal8.com/'; $picname = $info->disk_name . '/' . $info->picname; $thumb = new Thumb(); if ($zoom == 'medium') { $picname = $thumb->create($picname, 640, 640, 's'); } elseif ($zoom == 'thumb') { $picname = $thumb->create($picname, 130, 130); } $this->template->picname = $url . $picname; if ($this->isPost()) { $editName = trim($this->getPost('name')); $pid = (int) $this->getPost('pid'); $set['custom_name'] = $editName; if (!empty($_FILES['newfile']['name'])) { $disks = ORM::factory('img_disk')->where('is_use', '=', 1)->find(); $save_dir = ORM::factory('user', (int) $this->auth['uid'])->save_dir; $savePath = DOCROOT . '' . $disks->disk_name . '/' . $save_dir . '/'; $upload = new Upload(array('size' => 2024)); try { $upload->set_path($savePath); $result = $upload->save($_FILES['newfile']); //$set['picname'] = $result['saveName']; $set['filename'] = $result['name']; $set['custom_name'] = $result['name']; $set['filesize'] = $result['size']; $picPath = pathinfo($info->disk_name . '/' . $info->picname); $img_dir = '/s/'; $img_dir2 = '/thumbnails/'; if (!empty($this->img_size)) { foreach ($this->img_size as $key => $v) { //标准图路径 $zoomPath = $picPath['dirname'] . $img_dir . $picPath['filename'] . $v; @unlink(Io::strip(DOCROOT . $zoomPath . $picPath['extension'])); @unlink(Io::strip(DOCROOT . $zoomPath . 'jpg')); //缩略图路径 $thumbPath = $info->disk_name . $img_dir2 . $picPath['filename'] . $v; @unlink(Io::strip(DOCROOT . $thumbPath . $picPath['extension'])); @unlink(Io::strip(DOCROOT . $thumbPath . 'jpg')); @unlink(Io::strip(DOCROOT . $thumbPath . 'gif')); } @unlink(Io::strip(DOCROOT . $info->disk_name . '/' . $info->picname)); $saveName = $disks->disk_name . '/' . $save_dir . '/' . $result['saveName']; rename($saveName, DOCROOT . $info->disk_name . '/' . $info->picname); $saveName = $disks->disk_name . '/' . $save_dir . '/' . $info->picname; $url = 'http://' . $info->disk_id . '.wal8.com/'; $data = array('img_url' => $url . $this->thumb->create($saveName, 130, 130), 'add_time' => time(), 'uid' => $this->auth['uid']); $this->squid_img($data); $data['img_url'] = $url . $this->thumb->create($saveName, 640, 640, 's'); $this->squid_img($data); $data['img_url'] = $url . $this->thumb->create($saveName, 120, 120); $this->squid_img($data); $data['img_url'] = $url . $saveName; $this->squid_img($data); } } catch (Exception $e) { $this->show_message($e->getMessage(), 0, array(), true); } } DB::update('imgs')->set($set)->where('id', '=', $pid)->execute(); $sum = DB::select(DB::expr("sum(filesize) as sums"))->from('imgs')->where('userid', '=', $this->auth['uid'])->execute()->get('sums'); DB::update('users')->set(array('use_space' => $sum))->where('uid', '=', $this->auth['uid'])->execute(); ORM::factory('user')->upcache($this->auth['uid']); $links[] = array('text' => '重载图片编辑', 'href' => '/pic/picedit?pid=' . $pid); $this->show_message('修改图片处理成功', 1, $links, true); } }
/** * @return \Components\Io_Path */ private static function pathTranslationCommon() { if (null === self::$m_pathTranslationCommon) { self::$m_pathTranslationCommon = Io::pathComponentsResource('i18n', 'resource', 'i18n', 'translation', 'common'); } return self::$m_pathTranslationCommon; }
/** * @param string $path_ * * @return \Components\Io_Image */ public static function createBlank() { // TODO See todo above - support virtual/memory-mapped io/file. $path = Io::tmpFileName(); return static::createForBase64("{$path}.gif", self::IMAGE_BLANK); }
public function getRelativePath(Io_Path $path_) { if ($this->isFile()) { $directory = $this->getParent(); } else { $directory = $this; } if ($directory->isParentOf($path_)) { return Io::path(ltrim(String::replace($path_->m_path, str_pad($directory->m_path, 1, '/', STR_PAD_RIGHT), ''), '/')); } $level = 1; $segments = explode('/', $directory->m_path); $path = $path_->m_path; while (array_pop($segments)) { if (!($current = implode('/', $segments))) { $current = '/'; } if (0 === mb_strpos($path, $current)) { if ('/' === $current) { $subPath = $path; } else { $subPath = String::replace($path, $current, ''); } return str_repeat('../', $level) . ltrim($subPath, '/'); } $level++; } return $file_->getPath(); }
private function accessFlagsForMask($mask_) { if (null !== $this->m_accessFlags) { return $this->m_accessFlags; } $flag = Io::systemIsWindows() ? 'b' : ''; if (0 < ($mask_ & self::TRUNCATE)) { return $this->m_accessFlags = "{$flag}w+"; } if (0 < ($mask_ & self::APPEND)) { return $this->m_accessFlags = "{$flag}a+"; } if (0 < ($mask_ & self::CREATE)) { return $this->m_accessFlags = "{$flag}c+"; } if (0 < ($mask_ & self::WRITE)) { return $this->m_accessFlags = "{$flag}r+"; } return $this->m_accessFlags = "{$flag}r"; }
/** * 清空回收站 */ public function action_clear() { $rows = DB::select()->from('imgs')->where('userid', '=', (int) $this->auth['uid'])->where('recycle', '=', 1)->fetch_all(); if (!empty($rows)) { $rows = new Arrayobj($rows); foreach ($rows as $row) { if ($row->userid == (int) $this->auth['uid']) { // 添加图片到删除缓存表中 $url = 'http://' . $row->disk_id . '.wal8.com/'; $img_path = $row->disk_name . '/' . $row->picname; $thumb_130 = $this->thumb->create2($img_path, 130, 130); $data = array('img_url' => $url . $thumb_130, 'add_time' => time(), 'uid' => $this->auth['uid']); @unlink(Io::strip(DOCROOT . $thumb_130)); $this->squid_img($data); /*$thumb_120 = $thumb->create2($img_path, 120, 120); $data['img_url'] = $url . $thumb_120; $this->squid_img($data); @unlink(Io::strip(DOCROOT. $thumb_120));*/ $thumb_65 = $this->thumb->create2($img_path, 65, 65); $data['img_url'] = $url . $thumb_65; $this->squid_img($data); @unlink(Io::strip(DOCROOT . $thumb_65)); $thumb_640 = $this->thumb->create2($img_path, 640, 640, 's'); $data['img_url'] = $url . $thumb_640; $this->squid_img($data); @unlink(Io::strip(DOCROOT . $thumb_640)); $data['img_url'] = $url . $img_path; $this->squid_img($data); // 删除评论 DB::delete('comments')->where('item_id', '=', $row->id)->where('app', '=', 'img')->execute(); // 删除图片记录 DB::delete('imgs')->where('id', '=', $row->id)->execute(); @unlink(Io::strip(DOCROOT . $row->disk_name . '/' . $row->picname)); // 删除标签 $tag = new tags(); $tag->del($row->id, 'app'); } } } echo 'success'; //$this->request->redirect('/category/list?recycle=1'); $this->auto_render = false; }
/** * 自动远程保存图片 * */ public function action_saveimg() { $source = $this->getQuery('src'); if (!URL::ping($source)) { echo $source; die; } $savePath = "books_img/" . $this->auth['uid'] . '/'; Io::mkdir(DOCROOT . $savePath); $data = @file_get_contents($source); $filename = basename($source); $extension = strtolower(strtolower(substr(strrchr($filename, '.'), 1))); $saveName = str_replace('.', '', microtime(true)) . '.' . $extension; // 保存的文件名 $filename = $savePath . $saveName; $filesize = @file_put_contents(DOCROOT . $filename, $data); //保存文件,返回文件的size if ($filesize == 0) { //保存失败 @unlink($savefile); throw new Exception('文件保存到本地目录时失败'); } list($w, $h, $t) = getimagesize(DOCROOT . $filename); $filetype = image_type_to_mime_type($t); if (!preg_match('/^image\\/.+/i', $filetype)) { throw new Exception('转存文件并非有效的图片文件'); } $filename = $this->thumb->create($filename, 640, 640); echo URL::domain() . $filename; $this->auto_render = false; }
function createDocs($title = false) { $this->parse_start_time = time(); global $_phpDocumentor_setting; if (!$this->render) { $this->render = new phpDocumentor_IntermediateParser($title); } // setup ignore list $this->ignore_files = array(); if (isset($_phpDocumentor_setting['ignore'])) { $this->setIgnore($_phpDocumentor_setting['ignore']); } $this->parse->subscribe("*", $this->render); // parse the directory if (!empty($this->files)) { $files = explode(",", $this->files); foreach ($files as $file) { $file = trim($file); $test = $this->setup->getAllFiles($file); if ($test) { foreach ($test as $file) { $file = trim($file); $dir = realpath(dirname($file)); $dir = strtr($dir, "\\", "/"); $dir = str_replace('//', '/', $dir); // strip trailing directory seperator if (substr($dir, -1) == "/" || substr($dir, -1) == "\\") { $dir = substr($dir, 0, -1); } $file = strtr(realpath($file), "\\", "/"); $file = str_replace('//', '/', $file); if (!$this->setup->checkIgnore(basename($file), dirname($file), $this->ignore_files, true, $this->ignoresymlinks)) { $filelist[] = str_replace('\\', '/', $file); } else { phpDocumentor_out("File {$file} Ignored\n"); flush(); } } } else { $dir = dirname(realpath($file)); $dir = strtr($dir, "\\", "/"); $dir = str_replace('//', '/', $dir); // strip trailing directory seperator if (substr($dir, -1) == "/" || substr($dir, -1) == "\\") { $dir = substr($dir, 0, -1); } $base = count(explode("/", $dir)); $file = strtr(realpath($file), "\\", "/"); $file = str_replace('//', '/', $file); flush(); if (!$this->setup->checkIgnore(basename($file), dirname($file), $this->ignore_files, true, $this->ignoresymlinks)) { $filelist[] = str_replace('\\', '/', $file); } else { phpDocumentor_out("File {$file} Ignored\n"); flush(); } } } } if (!empty($this->dirs)) { $dirs = explode(",", $this->dirs); foreach ($dirs as $dir) { $olddir = $dir; $dir = realpath($dir); if (!$dir) { phpDocumentor_out('ERROR: "' . $olddir . '" does not exist, skipping'); continue; } $dir = trim($dir); $dir = strtr($dir, "\\", "/"); $dir = str_replace('//', '/', $dir); // strip trailing directory seperator if (substr($dir, -1) == "/" || substr($dir, -1) == "\\") { $dir = substr($dir, 0, -1); } $files = $this->setup->dirList($dir, $this->hidden, $this->ignoresymlinks); if (is_array($files)) { foreach ($files as $file) { $file = strtr($file, '\\', '/'); // file's subpath, relative to $dir $file_subpath = str_replace('\\', '/', realpath(dirname($file))); $file_subpath = preg_replace('[\\/]', DIRECTORY_SEPARATOR, $file_subpath); $file_subpath = preg_replace('~^' . preg_quote($dir, '~') . '~', '', $file_subpath); if (!$this->setup->checkIgnore(basename($file), $file_subpath, $this->ignore_files, true, $this->ignoresymlinks)) { $filelist[] = $file; } else { phpDocumentor_out("File {$file} Ignored\n"); flush(); } } } } } if (isset($filelist)) { if (PHPDOCUMENTOR_WINDOWS) { // case insensitive array_unique usort($filelist, 'strnatcasecmp'); reset($filelist); $newarray = array(); $i = 0; $element = current($filelist); for ($n = 0; $n < sizeof($filelist); $n++) { if (strtolower(next($filelist)) != strtolower($element)) { $newarray[$i] = $element; $element = current($filelist); $i++; } } $filelist = $newarray; } else { $filelist = array_unique($filelist); } $base = count(explode("/", $source_base = $this->setup->getBase($filelist))); define("PHPDOCUMENTOR_BASE", $source_base); list($filelist, $ric) = $this->setup->getReadmeInstallChangelog($source_base, $filelist); phpDocumentor_out("\n\nGrabbing README/INSTALL/CHANGELOG\n"); flush(); foreach ($ric as $file) { phpDocumentor_out(basename($file) . '...'); flush(); $fp = fopen($file, 'r'); $contents = fread($fp, filesize($file)); $this->render->HandleEvent(PHPDOCUMENTOR_EVENT_README_INSTALL_CHANGELOG, array(basename($file), $contents)); fclose($fp); } phpDocumentor_out("\ndone\n"); flush(); list($filelist, $tutorials) = $this->setup->getTutorials($filelist); phpDocumentor_out("\n\nTutorial/Extended Documentation Parsing Stage\n\n"); flush(); if (count($tutorials)) { $tuteparser = new XMLPackagePageParser(); $tuteparser->subscribe('*', $this->render); foreach ($tutorials as $tutorial) { switch ($tutorial['tutetype']) { case 'pkg': case 'cls': case 'proc': switch ($tutorial['tutetype']) { case 'pkg': $ptext = 'Package-level Docs '; if (!empty($tutorial['subpackage'])) { $ptext = 'Sub-Package Docs '; } break; case 'cls': $ptext = 'Class-level Docs '; break; case 'proc': $ptext = 'Procedural-level Docs '; break; } $fp = @fopen($tutorial['path'], "r"); if ($fp) { $ret = fread($fp, filesize($tutorial['path'])); // fix 1151650 if (stristr($ret, "utf-8") !== "") { $ret = utf8_decode($ret); } fclose($fp); unset($fp); phpDocumentor_out('Parsing ' . $ptext . $tutorial['path'] . '...'); flush(); $tuteparser->parse($ret, $tutorial); phpDocumentor_out("done\n"); flush(); } else { phpDocumentor_out('Error ' . $ptext . $tutorial['path'] . ' doesn\'t exist' . "\n"); flush(); } default: break; } } } phpDocumentor_out("done\n"); flush(); phpDocumentor_out("\n\nGeneral Parsing Stage\n\n"); flush(); foreach ($filelist as $file) { phpDocumentor_out("Reading file {$file}"); flush(); $this->parse->parse($a = $this->setup->readPhpFile($file, $this->render->quietMode), $file, $base, $this->packages); } $b = time() - $this->parse_start_time; phpDocumentor_out("done\n"); flush(); // render output phpDocumentor_out("\nConverting From Abstract Parsed Data\n"); flush(); $this->render->output(); $a = time() - $this->parse_start_time; $c = $a - $b; phpDocumentor_out("\nParsing time: {$b} seconds\n"); phpDocumentor_out("\nConversion time: {$c} seconds\n"); phpDocumentor_out("\nTotal Documentation Time: {$a} seconds\n"); phpDocumentor_out("done\n"); flush(); } else { print "\nERROR: nothing parsed\n"; exit; } }
protected function createReportPath() { if (false === Io::directoryCreate($this->m_reportPath)) { throw new Exception_IllegalArgument('test/unit/result/handler', sprintf('Unable to create report path [path: %1$s].', $this->m_reportPath)); } return $this->m_reportPath; }
/** * @see \Components\Media_Storage::copyCategory() \Components\Media_Storage::copyCategory() */ public function copyCategory($categorySource_, $categoryTarget_) { $source = Io::path(Environment::pathResource("{$this->store->path}/{$categorySource_}")); if (false === $source->exists()) { return false; } $source->copy(Io::path(Environment::pathResource("{$this->store->path}/{$categoryTarget_}"))); return true; }
/** * 自动远程保存图片 * */ public function action_saveimg() { $source = $this->getQuery('src'); if (!URL::ping($source)) { echo $source; die; } $title = trim($this->getQuery('title')); $data = @file_get_contents($source); $filename = basename($source); $extension = strtolower(strtolower(substr(strrchr($filename, '.'), 1))); $saveName = str_replace('.', '', microtime(true)); // 保存的文件名 $disk = ORM::factory('img_disk')->where('is_use', '=', 1)->find(); $save_dir = ORM::factory('user', $this->auth['uid'])->save_dir; $savefile = Io::strip(Io::mkdir(DOCROOT . $disk->disk_name . '/' . $save_dir) . '/' . $saveName . ".{$extension}"); $filesize = @file_put_contents($savefile, $data); //保存文件,返回文件的size if ($filesize == 0) { //保存失败 @unlink($savefile); throw new Exception('文件保存到本地目录时失败'); } list($w, $h, $t, ) = getimagesize($savefile); $filetype = image_type_to_mime_type($t); if (!preg_match('/^image\\/.+/i', $filetype)) { throw new Exception('转存文件并非有效的图片文件'); } $category = ORM::factory('img_category')->where('cate_name', '=', '产品搬家')->where('uid', '=', $this->auth['uid'])->find(); $cate = new Category(); if (empty($category->cate_name)) { $cate_id = $cate->add(array('cate_name' => '产品搬家', 'uid' => $this->auth['uid'])); } else { $cate_id = $category->cate_id; } $movehomeSession = Session::instance()->get('movehome_id', false); if (!empty($title)) { if (empty($movehomeSession)) { $cate_id = $cate->add(array('cate_name' => $title, 'uid' => $this->auth['uid'], 'parent_id' => $cate_id)); Session::instance()->set('movehome_id', $cate_id); } else { $cate_id = $movehomeSession; } } $img = ORM::factory('img'); $img->picname = $saveName . ".{$extension}"; $img->filename = $filename; $img->filesize = $filesize; $img->userid = $this->auth['uid']; $img->cate_id = $cate_id; $img->disk_id = $disk->disk_domain; $img->disk_name = $disk->disk_name . '/' . $save_dir; $img->custom_name = $saveName; $img->save(); $url = "http://" . $disk->disk_domain . '.wal8.com/' . $disk->disk_name . '/' . $save_dir . '/' . $saveName . ".{$extension}"; // 统计数据 $num = $img->where('userid', '=', $this->auth['uid'])->where('cate_id', '=', $cate_id)->count_all(); DB::update('img_categories')->set(array('img_num' => $num))->where('uid', '=', $this->auth['uid'])->where('cate_id', '=', $cate_id)->execute(); $rows = DB::select(array('sum("filesize")', 'total_size'), array('count("userid")', 'total_num'))->from('imgs')->where('userid', '=', $this->auth['uid'])->execute()->current(); DB::update('users')->set(array('use_space' => $rows['total_size'], 'count_img' => $rows['total_num']))->where('uid', '=', $this->auth['uid'])->execute(); $result = array('status' => true, 'source' => $source, 'url' => $url); echo $url; $this->auto_render = false; }
public function send($message) { $this->io->write(msgpack_pack($message)); }
/** * Initializes / prepares unit test execution. */ protected function initialize() { $this->addClass(__DIR__ . '/../../assertion.php'); $this->addResultHandler(new Test_Unit_Result_Handler(Io::path($this->getBuildPath())->test->unit)); }
/** * @see \Components\I18n_Location::initialized() \Components\I18n_Location::initialized() * * @return \Components\I18n_Country */ protected function initialized() { if (null === $this->m_data) { $name = strtolower($this->m_name); if (false === ($this->m_data = Cache::get("i18n/country/{$name}"))) { $this->m_data['children'] = []; $path = Io::pathComponentsResource('i18n', 'resource', 'i18n', 'location', $name); if ($path->exists()) { foreach ($path as $pathRegion) { $pathRegionAsString = $pathRegion->getPath(); if (false === is_file($pathRegionAsString)) { continue; } $region = basename($pathRegionAsString); $region = strtolower(substr($region, 0, strrpos($region, '.'))); $this->m_data['children'][$region] = null; } } Cache::set("i18n/country/{$name}", $this->m_data); } } return $this; }
/** * @return \Components\Io_Path */ public function getTempPath() { return Io::path($this->getBuildPath())->tmp; }
$cvsadd_directory = realpath('.'); /** * Comma-separated list of files and directories to ignore * * This uses wildcards * and ? to remove extra files/directories that are * not part of the package or release * @global string $ignore */ $ignore = array('CVS/'); /****************************************************************************** * Don't change anything below here unless you're adventuresome * *******************************************************************************/ /** * @global Io $files */ $files = new Io(); $allfiles = $files->dirList($cvsadd_directory); /**#@+ * Sorting functions for the file list * @param string * @param string */ function sortfiles($a, $b) { return strnatcasecmp($a['file'], $b['file']); } function mystrucsort($a, $b) { if (is_numeric($a) && is_string($b)) { return 1; }
public function send($message) { $this->io->write(json_encode($message) . "\n"); }
public static function run() { $cli = Test_Cli::get(); $cli->attach(Io::stdin(), Io::stdout(), Io::stderr()); $cli->run(); }
$info = DB::select()->from('imgup_movestore')->where('status', '=', 5)->order_by('id', 'DESC')->limit(1)->execute()->current(); # 获取config信息 $config = DB::select('id', 'disk_domain', 'disk_name')->from('img_disks')->where('is_use', '=', 1)->execute()->current(); $disk_id = $config['disk_domain']; $disk_name = $config['disk_name']; if (!empty($info)) { $info['id'] = (int) $info['id']; $info['uid'] = (int) $info['uid']; $save_dir = ORM::factory('user', $info['uid'])->save_dir; $csvFile = 'src_csv/' . $info['uid'] . '/' . $info['src_file']; $url = 'http://' . $disk_id . '.wal8.com/' . $disk_name . '/' . $save_dir . '/'; $savePath = 'dest_csv/' . $info['uid'] . '/'; $saveFilename = time() . '_' . rand() . '.csv'; # 创建目录 Io::mkdir('../' . $savePath); Io::mkdir('../' . $disk_name . '/' . $movestore['uid'] . '/'); $content = changeCharacter('../' . $csvFile); #搬家完毕的图片 $list = DB::select('m.url', array('imgs.disk_id', 'disk_domain'), 'imgs.userid', 'imgs.picname', array('imgs.disk_name', 'img_dir'))->from(array('store_imgs', 'm'))->join('imgs')->on('imgs.id', '=', 'm.img_id')->where('m.status', '=', '1')->where('m.sid', '=', $info['id'])->execute()->as_array(); # 存在搬家完毕的图片生成新的CSV文件,不然就改变状态为3即该文件不存在图片或者该文件的图片不能访问 if (!empty($list)) { foreach ($list as $item) { $url = "http://" . $item['disk_domain'] . '.wal8.com/' . $item['img_dir'] . '/' . $item['picname']; $content = str_replace($item['url'], $url, $content); #DB::delete('store_imgs')->where('sid', '=', $completeStore['id'])->where('status', '=', '1') # ->where('img_id', '=', $item['id']); } $content = iconv("utf-8", "UCS-2LE", $content); @file_put_contents('../' . $savePath . $saveFilename, $content); //file_put_contents('../'. $savePath . $saveFilename, "\xFF\xFE" . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8')); DB::update('imgup_movestore')->set(array('status' => 1, 'finish_time' => date('Y-m-d H:i:s'), 'dest_file' => $saveFilename))->where('id', '=', $info['id'])->execute();
/** * @param string $path_ * @param integer $width_ * @param integer $height_ * * @return string */ public static function imagePath($route_, Io_Path $path_, $width_ = null, $height_ = null) { $file = \str\encodeBase64Url(json_encode([(string) Io::path(Environment::pathWeb())->getRelativePath($path_), $width_, $height_])) . '.' . Io::fileExtension($path_); return Http_Router::path($route_) . "/{$file}"; }
static function upload() { $failed = []; foreach ($_FILES as $key => $file) { try { Io::fileUpload($key, self::temporaryUploadPath()); } catch (Io_Exception $e) { // FIXME Use exception message. $failed[$file['name']] = $file['error']; } } return $failed; }