コード例 #1
0
ファイル: upload.class.php プロジェクト: nyroDev/nyroFwk
	/**
	 * Show the file to the client
	 *
	 * @param string $prm File requested
	 */
	public static function get($prm) {
		self::init();
		$prm = self::$cfg->dir.
			str_replace(
				array(self::$cfg->webDir.'/', '/'),
				array('', DS)
				, $prm);
		if (self::$cfg->getInArray('forceDownload', file::getExt($prm)))
			response::getInstance()->sendFile($prm);
		else
			response::getInstance()->showFile($prm);
	}
コード例 #2
0
 /**
  * Create a filename to not erease existing files
  *
  * @param string $name Filename
  * @return string Filename useable
  */
 protected function safeFileName($name)
 {
     $name = strtolower(utils::urlify($name, '.'));
     $ext = file::getExt($name);
     if ($ext) {
         $ext = '.' . $ext;
     }
     $initName = substr($name, 0, -strlen($ext));
     $i = 2;
     while (file::exists($this->dir . DS . $name)) {
         $name = $initName . '-' . $i . $ext;
         $i++;
     }
     return $name;
 }
コード例 #3
0
ファイル: controller.class.php プロジェクト: nyroDev/nyroFwk
	protected function execIndex(array $prm = array()) {
		$this->prepare();
		
		$pattern = FILESROOT.$this->dir.DS.'*';
		$search = http_vars::getInstance()->get('search');
		if ($search) {
			$pattern.= strtolower($search).'*';
			$this->uri.= 'search='.$search.'&';
		}
		
		$delete = http_vars::getInstance()->get('delete');
		if ($delete) {
			$file = FILESROOT.urldecode($delete);
			if (file::exists($file)) {
				file::delete($file);
				file::multipleDelete(substr($file, 0, -strlen(file::getExt($file))-1).'_*');
				response::getInstance()->redirect($this->uri);
			}
		}
		
		$form = $this->getForm();
		
		if (request::isPost()) {
			$form->refill();
			if ($form->isValid())
				response::getInstance()->sendText('ok');
		}
		
		$files = array();
		foreach(file::search($pattern) as $f) {
			if (strpos($f, 'nyroBrowserThumb') === false) {
				$name = basename($f);
				if ($this->type == 'image' && strlen($name) > 15)
					$name = substr($name, 0, 15).'...'.file::getExt($f);
				$files[] = array(
					$f,
					request::uploadedUri(str_replace(FILESROOT, '', $f), $this->myCfg['uploadedUri']),
					$name,
					file::humanSize($f),
					utils::formatDate(filemtime($f)),
					$this->uri.'delete='.urlencode(str_replace(FILESROOT, '', $f)).'&'
				);
			}
		}
		
		$this->setViewVars(array(
			'uri'=>$this->uri,
			'form'=>$form,
			'config'=>$this->config,
			'type'=>$this->type,
			'files'=>$files,
			'searchButton'=>$this->myCfg['search'],
			'search'=>$search,
			'imgHelper'=>$this->myCfg['imgHelper'],
			'filesTitle'=>$this->myCfg['filesTitle'],
			'noFiles'=>$this->myCfg['noFiles'],
			'name'=>$this->myCfg['name'],
			'size'=>$this->myCfg['size'],
			'date'=>$this->myCfg['date'],
			'delete'=>$this->myCfg['delete'],
		));
	}
コード例 #4
0
ファイル: request.class.php プロジェクト: nyroDev/nyroFwk
	/**
	 * Analyse a request. If some element are empty, the default is replaced
	 *
	 * @param string $request The requested string
	 * @param bool $alias Indicate if alias should be used
	 * @return array Array with the key lang, module, action, param, text and out
	 */
	public static function analyseRequest($request, $alias = true) {
		if ($alias)
			$request = self::alias($request);
		else 
			$request = trim($request, self::$cfg->sep);

		$ret = array();

		$out = strtolower(file::getExt($request));
		if ($out && self::isOut($out)) {
			$ret['out'] = $out;
			$request = substr($request, 0, strlen($request) - (strlen($out) + 1));
		}

		$tmp = explode(self::$cfg->sep, $request);
		if (self::isLang($tmp[0]))
			$ret['lang'] = array_shift($tmp);

		if (($t = array_shift($tmp)) && $t != self::$cfg->empty)
			$ret['module'] = $t;

		if (($t = array_shift($tmp)) && $t != self::$cfg->empty)
			$ret['action'] = $t;

		$ret['paramA'] = array();
		if (($t = array_shift($tmp)) && $t != self::$cfg->empty) {
			$ret['param'] = $t;
			$ret['paramA'] = self::parseParam($ret['param']);
		}

		if (($t = array_shift($tmp)) && $t != self::$cfg->empty)
			$ret['text'] = $t;

		return $ret;
	}
コード例 #5
0
ファイル: image.class.php プロジェクト: nyroDev/nyroFwk
 /**
  * Make the path for a thumbnail
  *
  * @param string $file File name source
  * @param string $more To create other
  * @return string Thumbnail path
  */
 public function makePath($file, $more = null)
 {
     if (is_null($more)) {
         $more = md5($this->cfg->w . '_' . $this->cfg->h . '_' . $this->cfg->bgColor . '_' . $this->cfg->fit);
     }
     if ($more) {
         $more = '_' . $more;
     }
     if (!$this->cfg->forceExt) {
         $this->cfg->forceExt = file::getExt($file);
     }
     return preg_replace('/\\.(' . implode('|', $this->cfg->autoExt) . ')$/i', $more . '.' . $this->cfg->forceExt, $file);
 }