Пример #1
0
 function s_get_dir_file_info($filepath)
 {
     $_s = new SaeStorage();
     //初始化Storage对象
     $_f = _s_get_path($filepath);
     $_f['filename'] = rtrim($_f['filename'], '/');
     return $_s->getListByPath($_f['domain'], $_f['filename']);
 }
Пример #2
0
function getSaeFiles($domain, $path, $allowFiles, &$files = array())
{
    $stor = new SaeStorage();
    $res = $stor->getListByPath($domain, $path, 1000, 0, false);
    foreach ($res as $val) {
        $url = $stor->getUrl($domain, $val['fullName']);
        $files[] = array('url' => $url, 'mtime' => $val['uploadTime']);
    }
    return $files;
}
Пример #3
0
 /**
  * 
  * {@inheritDoc}
  * @see \Illuminate\Contracts\Filesystem\Filesystem::directories()
  */
 public function directories($directory = null, $recursive = false)
 {
     list($domain, $path) = $this->parser($directory);
     $list = array();
     $offset = 0;
     do {
         $result = $this->storage->getListByPath($domain, $path, 1000, $offset, !$recursive);
         foreach ($result['dirs'] as $item) {
             $list[] = $domain . '/' . $item['fullName'];
         }
         $size = sizeof($result['dirNum'] + $result['fileNum']);
         $offset += $size;
     } while ($size >= 1000);
     return $list;
 }
Пример #4
0
 public function photo()
 {
     $photo = M('photo');
     $s = new SaeStorage();
     $path = $photo->where('id=' . $_GET['id'])->getField('path');
     $list = $s->getListByPath('imgdomain', $path);
     $files = $list["files"];
     $imgUrlList = array();
     foreach ($files as $imageFile) {
         $imgUrl = $s->getUrl("imgdomain", $path . "/" . $imageFile['Name']);
         array_push($imgUrlList, $imgUrl);
     }
     $this->assign('list', $imgUrlList);
     $this->display();
 }
Пример #5
0
          return false;
      } else {
          $file['url'] = $st->getUrl($this->domain, $filename);
      }
      return true;
  }
  /**
 * 文件写入
 * @param  array  $file    文件信息数组
 * @param  string  $data    文件内容
 * @param  boolean $replace 是否覆盖
 * @return boolean  保存状态,true-成功 | false-失败
 */
  public function put(&$file, $data, $replace = true)
  {
      $filename = ltrim($this->rootPath . '/' . $file['save_path'] . $file['save_name'], '/');
      $st = new \SaeStorage();
      /* 不覆盖同名文件 */
Пример #6
0
/**
 * 上传目录列表
 * @param string $path 目录名
 * @return array
 */
function file_list_upload($path)
{
    $config = C('TMPL_PARSE_STRING');
    switch (strtoupper(C('FILE_UPLOAD_TYPE'))) {
        case 'SAE':
            $path = str_replace(DS, '/', rtrim($path, DS));
            $arr = explode('/', ltrim($path, './'));
            $domain = array_shift($arr);
            $filePath = implode('/', $arr);
            $s = new SaeStorage();
            $list = $s->getListByPath($domain, $filePath);
            $res = array();
            while (isset($list['dirNum']) && $list['dirNum']) {
                $list['dirNum']--;
                array_push($res, array('type' => 'dir', 'name' => $list['dirs'][$list['dirNum']]['name'], 'path' => ltrim($list['dirs'][$list['dirNum']]['fullName'], 'upload/'), 'size' => '-', 'mtime' => '-', 'url' => '#'));
            }
            while (isset($list['fileNum']) && $list['fileNum']) {
                $list['fileNum']--;
                array_push($res, array('type' => 'file', 'name' => $list['files'][$list['fileNum']]['Name'], 'path' => ltrim($list['files'][$list['fileNum']]['fullName'], 'upload/'), 'size' => format_bytes($list['files'][$list['fileNum']]['length'], ' '), 'mtime' => date('Y-m-d H:i:s', $list['files'][$list['fileNum']]['uploadTime']), 'url' => ltrim($list['files'][$list['fileNum']]['fullName'], 'upload/')));
            }
            return $res;
            break;
        case 'FTP':
            $storage = new \Common\Plugin\Ftp();
            $list = $storage->ls($path);
            foreach ($list as &$item) {
                $item['path'] = ltrim($item['path'], UPLOAD_PATH);
                $item['url'] = str_replace('\\', '/', $item['path']);
            }
            return $list;
            break;
        default:
            $path = realpath($path);
            $path = str_replace(array('/', '\\'), DS, $path);
            $list = glob($path . DS . '*');
            $res = array();
            foreach ($list as $key => $filename) {
                array_push($res, array('type' => is_dir($filename) ? 'dir' : 'file', 'name' => basename($filename), 'path' => ltrim(str_replace(realpath(UPLOAD_PATH), '', $filename), DS), 'size' => format_bytes(filesize($filename), ' '), 'mtime' => date('Y-m-d H:i:s', filemtime($filename)), 'url' => ltrim(str_replace(array(realpath(UPLOAD_PATH), '\\'), array('', '/'), $filename), '/')));
            }
            return $res;
    }
}
Пример #7
0
 /**
 	function GetImages(){
 	// select folder to scan
 		$handle = opendir("");
 	// Read all files and store names in array
 		while($image =readdir($handle)){
 			$images[] = $image;
 		}
 		closedir($handle);
 		// Exclude all filenames where filname length<3
 		$imageArray = array();
 		foreach($images as $image){
 			if(strlen($image)>2){
 				array_push($imageArray,$image);
 			}
 		}
 		// Create <select><option>Values and return result
 		$result = $this->CreateOptionValues($imageArray);
 		return $result;
 	}
 	**/
 function GetImages()
 {
     $sae_storage = new SaeStorage();
     $domainName = "coffee";
     $listfiles = $sae_storage->getListByPath($domainName);
     $files = $listfiles["files"];
     $imageUrls = array();
     foreach ($files as $imagefile) {
         $tempName = $imagefile["Name"];
         $imageUrl = $sae_storage->getUrl($domainName, $tempName);
         echo $imageUrl;
         array_push($imageUrls, $imageUrl);
     }
     //$filename = $_FILES["file"]["name"];
     //move_uploaded_file($_FILES["file"]["tmp_name"],"images/Coffee/".$filename);
     $result = $this->CreateOptionValues($imageUrls);
     return $result;
 }
Пример #8
0
 case '1':
     include_once "./templates/s1.php";
     exit;
 case '2':
     if (phpversion() < 5) {
         die('本系统需要PHP5+MYSQL >=4.1环境,当前PHP版本为:' . phpversion());
     }
     $phpv = @phpversion();
     $err = 0;
     if ($conn) {
         $saeMysql = '<span class="correct_span">&radic;</span> 已开启';
     } else {
         $saeMysql = '<span class="correct_span error_span">&radic;</span> 未开启';
         $err++;
     }
     if (is_array($s->getListByPath('data'))) {
         $storage = '<span class="correct_span">&radic;</span> 已开启';
     } else {
         $storage = '<span class="correct_span error_span">&radic;</span> 需开启并发创建名称为data的domain';
         $err++;
     }
     if ($kv_ini) {
         $KVDB = '<span class="correct_span">&radic;</span> 已开启';
     } else {
         $KVDB = '<span class="correct_span error_span">&radic;</span> 未开启';
         $err++;
     }
     if ($mmc) {
         $Memcache = '<span class="correct_span">&radic;</span> 已开启';
     } else {
         $Memcache = '<span class="correct_span error_span">&radic;</span> 未开启';
Пример #9
0
        } else {
            if (!$s->upload($dir, $newfile, $upload['tmp_name'])) {
                $msg = '存储文件失败,请重新上传';
            } else {
                // $s->getUrl('jesse', $newfile);
                $cache[$newfile] = mb_substr($desc, 0, 30, 'UTF-8');
                file_put_contents($cachefile, json_encode($cache));
                $msg = '上传成功';
                $desc = '';
            }
        }
        '上传成功' != $msg && $is_ajax && exit('Error: ' . $msg);
    }
    // 读取文件
    $attaches = array();
    $lists = $s->getListByPath($dir);
    if (!empty($lists['files'])) {
        foreach ($lists['files'] as $l) {
            $attaches[] = array('url' => $s->getUrl($dir, $l['fullName']), 'name' => $l['fullName'], 'size' => $l['length']);
        }
    }
}
function file_ext($s)
{
    $exts = array('image/gif' => 'gif', 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/pjpeg' => 'jpg');
    $s = strtolower($s);
    return !empty($exts[$s]) ? $exts[$s] : '';
}
if (!$is_ajax) {
    ?>
<!DOCTYPE html>
Пример #10
0
function SaeStorageListByNoFoldPath($Path)
{
    $storage = new SaeStorage();
    $domain = Sae_Storage_Domain_Name;
    $result = array();
    //默认空数组
    $limit = 1000;
    //列表数量
    $offset = 0;
    //偏移量
    $fold = false;
    //不折叠目录
    while ($temp = $storage->getListByPath($domain, $Path, $limit, $offset, $fold)) {
        foreach ($temp as $file) {
            $result[] = $file;
            $num++;
        }
    }
    return $result;
}