Пример #1
1
<?php

session_start();
include_once 'saestorage.class.php';
?>

<html>

	<body>
		<form action="index.php" method="post" enctype="multipart/form-data">
			<input type = "file" name="myfile" size="100" /><br>
			<input type = "submit" value= "upload" / >
		</form>
	</body>
</html>

<?php 
$domain = "itemsimage";
$file_name = $_FILES["myfile"]["name"];
$temp_arr = explode(".", $file_name);
$file_ext = array_pop($temp_arr);
$file_ext = trim($file_ext);
$file_ext = strtolower($file_ext);
$new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
$s = new SaeStorage();
//$s->upload( 'imagefile',$_FILES["myfile"]["name"],$_FILES["myfile"]["name"]);
echo $aimage = $s->upload('itemsimage', $new_file_name, $_FILES["myfile"]["tmp_name"]);
echo md5("123456");
Пример #2
0
 static function upradio($radio)
 {
     $s = new SaeStorage();
     $mname = $_FILES[$radio]['name'];
     $msize = $_FILES[$radio]['size'];
     if ($mname != "") {
         if ($msize > 10240000) {
             echo '图片大小不能超过10M';
             exit;
         }
         $type = strstr($mname, '.');
         if ($type != ".mp3") {
             echo '对不起!只支持mp3格式,如果是这几种格式请去掉处文件标识符以外的点"."';
             exit;
         }
         if (!$_FILES[$radio]['name']) {
             die('没有选择文件!');
         }
         //上传文件校验,可以添加文件类型等检验、此处简略处理
         $file_name = "m_" . time() . rand(100, 999);
         //定义保存的文件名称
         $m_path = $file_name . $type;
         //要保存的文件路径+文件名,此处保存在根目录下
         $link = $s->upload('upcon', $m_path, $_FILES[$radio]['tmp_name']);
         if ($link) {
             $out_radio = array('m_name' => $file_name, 'm_url' => $link);
             echo json_encode($out_radio);
         } else {
             $emsg = $s->errmsg();
             $this->writelog_debug($emsg);
             die('上传零时文件失败!');
         }
     }
 }
Пример #3
0
 public function actionImageManager()
 {
     $path = "data/editor/image/" . Ibos::app()->user->uid;
     $action = EnvUtil::getRequest("action");
     if ($action == "get") {
         if (!defined("SAE_TMP_PATH")) {
             $files = $this->getfiles($path);
             if (!$files) {
                 return null;
             }
             rsort($files, SORT_STRING);
             $str = "";
             foreach ($files as $file) {
                 $str .= "../../../../../../" . $file . "ue_separate_ue";
             }
             echo $str;
         } else {
             $st = new SaeStorage();
             $num = 0;
             while ($ret = $st->getList("data", $path, 100, $num)) {
                 foreach ($ret as $file) {
                     if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) {
                         echo $st->getUrl("data", $file) . "ue_separate_ue";
                     }
                     $num++;
                 }
             }
         }
     }
 }
Пример #4
0
 public function index()
 {
     if ($_GET['fp'] != 1 && $_COOKIE['tennis-club'] != null) {
         $this->redirect('Index:index_' . $_COOKIE['tennis-club']);
     }
     $s = new SaeStorage();
     $waiting = "";
     $city_id = $_GET['cityId'];
     // 设置数组
     $currentProvince = array();
     $provinceList = array();
     $cityList = array();
     $clubList = array();
     // 定义数据库查询变量
     $PROVINCE = M('province');
     $CITY = M('city');
     $CLUB = M('club');
     // 查询省市列表
     $provinceList = $PROVINCE->getField("province_id, province_id, province_name");
     if ($city_id == null) {
         // 获取打开页面者所在城市
         $city = $this->getIPCity();
         // 查询数据库获取城市列表
         $province = $CITY->where("city_name like '%" . $city . "%'")->join("INNER JOIN province ON province.province_id=city.province_id")->getField('city_id, city_id, city_name, city.province_id, province_name');
         $currentProvince = current($province);
         $cityList = $CITY->where('province_id=' . $currentProvince['province_id'])->getField('city_id, city_id, city_name');
         // 查询俱乐部列表
         $clubList = $CLUB->where("city_id=" . $currentProvince['city_id'])->getField("id, id, name");
         if ($clubList != null) {
             foreach ($clubList as $key => $value) {
                 $clubList[$key]['portrait'] = $s->getUrl("imgdomain", 'club_portrait/club' . $value['id'] . '.jpg');
             }
         } else {
             $waiting = "等待当地俱乐部入驻。。。";
         }
     } else {
         $province = $CITY->where("city_id=" . $city_id)->join("INNER JOIN province ON province.province_id=city.province_id")->getField('city_id, city_id, city_name, city.province_id, province_name');
         $currentProvince = current($province);
         $cityList = $CITY->where('province_id=' . $currentProvince['province_id'])->getField('city_id, city_id, city_name');
         // 查询俱乐部列表
         $clubList = $CLUB->where("city_id=" . $currentProvince['city_id'])->getField("id, id, name");
         if ($clubList != null) {
             foreach ($clubList as $key => $value) {
                 $clubList[$key]['portrait'] = $s->getUrl("imgdomain", 'club_portrait/club' . $value['id'] . '.jpg');
             }
         } else {
             $waiting = "等待当地俱乐部入驻。。。";
         }
     }
     $this->assign("currentProvinceId", $currentProvince['province_id']);
     $this->assign("currentProvinceName", $currentProvince['province_name']);
     $this->assign("currentCityId", $currentProvince['city_id']);
     $this->assign("currentCityName", $currentProvince['city_name']);
     $this->assign("provinceList", $provinceList);
     $this->assign("cityList", $cityList);
     $this->assign("clubList", $clubList);
     $this->assign("waiting", $waiting);
     $this->display();
 }
Пример #5
0
function saeup($date, $filename)
{
    $storage = new SaeStorage();
    $domain = 'img';
    $destFileName = $filename . 'jpg';
    $srcFileName = $_FILES['tmp_name'];
    $result = $storage->upload($domain, $destFileName, $date["tmp_name"]);
    return $result;
}
Пример #6
0
/**
 * @param $upload
 * @return null
 */
function Storage_Return_Url($upload)
{
    global $zbp, $domainname;
    $file = new Upload();
    $file = $zbp->GetUploadByID($upload->ID);
    $s = new SaeStorage();
    $url = $s->getUrl($domainname, $file->Metas->Storage_URL);
    return $url;
}
 public static function putFileContent($filename, $content)
 {
     if (OpenConfig::SAE_MODE) {
         $s = new SaeStorage();
         $s->write(OpenConfig::SAE_DOMAIN, $filename, $content);
     } else {
         $data = file_put_contents($filename, $content);
     }
 }
Пример #8
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;
}
Пример #9
0
function delete_mp3($fileName)
{
    $stor = new SaeStorage();
    $stor->delete(SAE_DOMAIN, $fileName);
    if ($errmsg == 0) {
        $result['success'] = 1;
    } else {
        $result['success'] = -1;
    }
    return $result;
}
Пример #10
0
function readModule($fileName)
{
    if ($fileName !== null) {
        $fileName = basename($fileName);
        $s = new SaeStorage();
        $content = $s->fileExists(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . $fileName) ? $s->read(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . $fileName) . "\n" : "Module File Not Found!";
        return htmlspecialchars($content, ENT_QUOTES);
    } else {
        return "Module File Not Found!";
    }
}
Пример #11
0
 function s_file_exists($path)
 {
     if (IS_SAE) {
         $ret = file_exists($path);
         if (!$ret) {
             $_s = new SaeStorage();
             $path = str_replace(FCPATH, '', $path);
             $_f = _s_get_path($path);
             return $_s->fileExists($_f['domain'], $_f['filename']);
         }
     } else {
         return file_exists($path);
     }
 }
Пример #12
0
 public function __construct($ACCESS_TOKEN)
 {
     if (isset($_SERVER["HTTP_APPNAME"])) {
         $storage = new SaeStorage();
         $domain = "xycn";
         $filename = "menu.json";
         $this->menu = $storage->read($domain, $filename);
     } else {
         //LOCAL
         $this->menu = file_get_contents("menu.json");
     }
     $this->MENU_CREATE_URL = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $ACCESS_TOKEN;
     $this->MENU_GET_URL = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=" . $ACCESS_TOKEN;
     $this->MENU_DELETE_URL = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=" . $ACCESS_TOKEN;
 }
Пример #13
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();
 }
Пример #14
0
 private function upFile($base64)
 {
     if ("base64" == $base64) {
         $content = $_POST[$this->fileField];
         $this->base64ToImage($content);
         return null;
     }
     $file = $this->file = $_FILES[$this->fileField];
     if (!$file) {
         $this->stateInfo = $this->getStateInfo("POST");
         return null;
     }
     if ($this->file["error"]) {
         $this->stateInfo = $this->getStateInfo($file["error"]);
         return null;
     }
     if (!is_uploaded_file($file["tmp_name"])) {
         $this->stateInfo = $this->getStateInfo("UNKNOWN");
         return null;
     }
     $this->oriName = $file["name"];
     $this->fileSize = $file["size"];
     $this->fileType = $this->getFileExt();
     if (!$this->checkSize()) {
         $this->stateInfo = $this->getStateInfo("SIZE");
         return null;
     }
     if (!$this->checkType()) {
         $this->stateInfo = $this->getStateInfo("TYPE");
         return null;
     }
     $this->fullName = $this->getFolder() . "/" . $this->getName();
     if ($this->stateInfo == $this->stateMap[0]) {
         if (!defined("SAE_TMP_PATH")) {
             if (!move_uploaded_file($file["tmp_name"], $this->fullName)) {
                 $this->stateInfo = $this->getStateInfo("MOVE");
             }
         } else {
             $st = new SaeStorage();
             $url = $st->upload("data", $this->fullName, $file["tmp_name"]);
             if (!$url) {
                 $this->stateInfo = $this->getStateInfo("MOVE");
             } else {
                 $this->fullName = $url;
             }
         }
     }
 }
Пример #15
0
 /**
  * 保存指定文件
  * @param  array   $file    保存的文件信息
  * @param  boolean $replace 同名文件是否覆盖
  * @return boolean          保存状态,true-成功,false-失败
  */
 public function save($file, $replace = true)
 {
     $filename = ltrim($this->rootPath . '/' . $file['savepath'] . $file['savename'], '/');
     $st = new \SaeStorage();
     /* 不覆盖同名文件 */
     if (!$replace && $st->fileExists($this->domain, $filename)) {
         $this->error = '存在同名文件' . $file['savename'];
         return false;
     }
     /* 移动文件 */
     if (!$st->upload($this->domain, $filename, $file['tmp_name'])) {
         $this->error = '文件上传保存错误![' . $st->errno() . ']:' . $st->errmsg();
         return false;
     }
     return true;
 }
Пример #16
0
 public function Delete($fileName)
 {
     $res = array('result' => false, 'reason' => '');
     $file_path = SAE_MODULES . '/' . $fileName;
     $s = new SaeStorage();
     if ($s->fileExists(SAE_STORAGE_DOMAIN, $file_path)) {
         if ($s->delete(SAE_STORAGE_DOMAIN, $file_path)) {
             $res['result'] = true;
             $res['reason'] = $fileName;
         } else {
             $res['reason'] = $this->messages['6'];
         }
     } else {
         $res['reason'] = $this->messages['4'];
     }
 }
Пример #17
0
 /**
  * 保存上传文件
  *
  * 需要设置存放SAE的domain,可修改 Upload::$default_directory = 'newdomain';
  *
  * @param array $file
  * @param string $filename
  * @param string $directory
  * @param int $chmod
  */
 public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     if (!isset($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
         // Ignore corrupted uploads
         return false;
     }
     if ($filename === null) {
         // Use the default filename, with a timestamp pre-pended
         $filename = uniqid() . $file['name'];
     }
     if (Upload::$remove_spaces === true) {
         // Remove spaces from the filename
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     $obj = new SaeStorage();
     return $obj->upload(Upload::$default_directory, $filename, $file['tmp_name']);
 }
Пример #18
0
 /**
  * 用flash添加照片
  */
 function add_photo()
 {
     if ($_FILES) {
         global $php;
         $php->upload->thumb_width = 136;
         $php->upload->thumb_height = 136;
         $php->upload->max_width = 500;
         $php->upload->max_height = 500;
         $php->upload->thumb_qulitity = 100;
         if (class_exists('SaeStorage', false)) {
             $s = new SaeStorage();
             $file_id = uniqid('pic_', false) . mt_rand(1, 100);
             $tmp_file = SAE_TMP_PATH . '/thum_' . $file_id . '.jpg';
             Image::thumbnail($_FILES['Filedata']['tmp_name'], $tmp_file, $php->upload->thumb_width, $php->upload->thumb_height, $php->upload->thumb_qulitity, false);
             $pic = '/uploads/' . $file_id . ".jpg";
             $ret = $s->upload('static', $pic, $_FILES['Filedata']['tmp_name']);
             if ($ret) {
                 $data['picture'] = $s->getUrl('static', $pic);
             } else {
                 echo $s->errmsg() . ' : ' . $s->errno();
                 return;
             }
             $thum_pic = '/uploads/thum_' . $file_id . '.jpg';
             $ret = $s->upload('static', $thum_pic, $tmp_file);
             if ($ret) {
                 $data['imagep'] = $s->getUrl('static', $thum_pic);
             } else {
                 echo $s->errmsg() . ' : ' . $s->errno();
                 return;
             }
         } else {
             $php->upload->sub_dir = 'user_images';
             $up_pic = Swoole::$php->upload->save('Filedata');
             if (empty($up_pic)) {
                 return '上传失败,请重新上传! Error:' . $php->upload->error_msg;
             }
             $data['picture'] = $up_pic['name'];
             $data['imagep'] = $up_pic['thumb'];
         }
         $data['uid'] = $_POST['uid'];
         $up_pic['photo_id'] = $this->swoole->model->UserPhoto->put($data);
         /* if(isset($_POST['post']))
            {
            	Api::feed('photo', $data['uid'], 0, $up_pic['photo_id']);
            } */
         return json_encode($up_pic);
     } else {
         $this->swoole->tpl->display('myphoto_add_photo.html');
     }
 }
Пример #19
0
function handleFiles($typeId, $tmpNames, $names)
{
    global $IS_SAE;
    $result = array("success" => true, "details" => array());
    $ext_arr = array();
    for ($i = 0; $i < count($names); $i++) {
        $tmp = explode(".", $names[$i]);
        $tmp = $tmp[count($tmp) - 1];
        array_push($ext_arr, $tmp);
    }
    // when name the folder, here we wipe the parameter $type.
    $directory = "../resources/chart/{$typeId}/";
    if ($IS_SAE) {
        $st = new SaeStorage();
        $attr = array('encoding' => 'gzip');
        for ($i = 0; $i < count($names); $i++) {
            $tName = $tmpNames[$i];
            $oName = $names[$i];
            $file_new_name = date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT) . "." . $ext_arr[$i];
            $uploadRes = $st->upload($_SERVER['HTTP_APPNAME'], $file_new_name, $_FILES['photo']['tmp_name'][$i], $attr, true);
            if ($uploadRes === false) {
                array_push($result["details"], array("success" => false, "msg" => "图片'{$oName}'上传失败!error:" . $st->errno() . ' ' . $st->errmsg(), "file" => '', "original_file_name" => $oName));
            } else {
                array_push($result["details"], array("success" => true, "msg" => "图片'{$oName}'上传成功!重命名为'{$file_new_name}'。", "file" => $uploadRes, "original_file_name" => $oName));
            }
        }
    } else {
        if (!file_exists($directory)) {
            if (!mkdir($directory)) {
                throw new Exception("文件夹创建失败!" . $directory);
            }
        }
        for ($i = 0; $i < count($names); $i++) {
            $tName = $tmpNames[$i];
            $oName = $names[$i];
            $file_new_name = date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT) . "." . $ext_arr[$i];
            if (move_uploaded_file($tName, $directory . $file_new_name)) {
                array_push($result["details"], array("success" => true, "msg" => "图片'{$oName}'上传成功!重命名为'{$file_new_name}'。", "file" => $directory . $file_new_name, "original_file_name" => $oName));
            } else {
                array_push($result["details"], array("success" => false, "msg" => "图片'{$oName}'上传失败!", "file" => '', "original_file_name" => $oName));
            }
        }
    }
    return $result;
}
Пример #20
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;
    }
}
Пример #21
0
 function delete()
 {
     if (!$this->has_privilege()) {
         $this->json->output(array('success' => false, 'm' => '您没有使用该功能的权限'));
     }
     $fileid = $this->input->get('fileid');
     if (!$this->utility->chk_id($fileid)) {
         $this->json->output(array('success' => false, 'm' => '输入的记录编号错误'));
     }
     $file = $this->Proj_model->get_upload_by_id($fileid);
     if (!empty($file)) {
         $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY);
         if ($s->delete('upload', $file[0]->filename)) {
             // remove from upload table
             $this->Proj_model->delete_upload($fileid);
             $this->json->output(array('success' => true));
         }
     }
     $this->json->output(array('success' => false));
 }
Пример #22
0
 public function file($path)
 {
     if (!IS_SAE) {
         return;
     }
     $this->load->helper('url');
     $file = uri_string();
     if (substr($file, 0, 1) == '/') {
         $file = substr($file, 1);
     }
     $storage = new SaeStorage();
     $s_index = strpos($file, '/');
     $_f = array('domain' => substr($file, 0, $s_index), 'filename' => substr($file, $s_index + 1));
     if ($storage->fileExists($_f['domain'], $_f['filename'])) {
         header('Content-Type:image/jpeg');
         echo $storage->read($_f['domain'], $_f['filename']);
     } else {
         set_status_header(404);
     }
 }
Пример #23
0
 /**
  * 收到图片消息时触发,回复由收到的图片组成的图文消息
  *
  * @return voi
  */
 protected function onImage()
 {
     $picurl = $this->getRequest('PicUrl');
     $saveurl = time() . '.png';
     $s = new SaeStorage();
     $img = file_get_contents($picurl);
     //括号中的为远程"\"#FF0000\"">图片地址
     $storage_url = $s->write('pictures', $saveurl, $img);
     $BackMsg = "感谢您提供的图片。";
     $this->mysql->saveIntoPic($this->getRequest('ToUserName'), $this->getRequest('FromUserName'), $this->getRequest('CreateTime'), $this->getRequest('MsgType'), $this->getRequest('PicUrl'), $this->getRequest('MediaId'), $this->getRequest('MsgId'), $storage_url, $BackMsg);
     $this->responseText("感谢您提供的图片。");
 }
Пример #24
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Article'])) {
         $model->attributes = $_POST['Article'];
         $model->imgurl = CUploadedFile::getInstance($model, 'imgurl');
         if ($model->imgurl) {
             $newimg = 'article_' . time() . '_' . rand(1, 9999) . '.' . $model->imgurl->extensionName;
             $uploadimage = new SaeStorage();
             $uploadimage->upload('upload', $newimg, $model->imgurl->tempName);
             $model->imgurl = $newimg;
         } else {
             $model->imgurl = $_POST['imgpath2'];
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model));
 }
Пример #25
0
function printTestCases($pid, $OJ_DATA)
{
    if (strstr($OJ_DATA, "saestor:")) {
        // echo "<debug>$pid</debug>";
        $store = new SaeStorage();
        $ret = $store->getList("data", "{$pid}", 100, 0);
        foreach ($ret as $file) {
            //          echo "<debug>$file</debug>";
            if (!strstr($file, "sae-dir-tag")) {
                $pinfo = pathinfo($file);
                if (isset($pinfo['extension']) && $pinfo['extension'] == "in" && $pinfo['basename'] != "sample.in") {
                    $f = basename($pinfo['basename'], "." . $pinfo['extension']);
                    $outfile = "{$pid}/" . $f . ".out";
                    $infile = "{$pid}/" . $f . ".in";
                    if ($store->fileExists("data", $infile)) {
                        echo "<test_input><![CDATA[" . $store->read("data", $infile) . "]]></test_input>\n";
                    }
                    if ($store->fileExists("data", $outfile)) {
                        echo "<test_output><![CDATA[" . $store->read("data", $outfile) . "]]></test_output>\n";
                    }
                    //			break;
                }
            }
        }
    } else {
        $ret = "";
        $pdir = opendir("{$OJ_DATA}/{$pid}/");
        while ($file = readdir($pdir)) {
            $pinfo = pathinfo($file);
            if (isset($pinfo['extension']) && $pinfo['extension'] == "in" && $pinfo['basename'] != "sample.in") {
                $ret = basename($pinfo['basename'], "." . $pinfo['extension']);
                $outfile = "{$OJ_DATA}/{$pid}/" . $ret . ".out";
                $infile = "{$OJ_DATA}/{$pid}/" . $ret . ".in";
                if (file_exists($infile)) {
                    echo "<test_input><![CDATA[" . file_get_contents($infile) . "]]></test_input>\n";
                }
                if (file_exists($outfile)) {
                    echo "<test_output><![CDATA[" . file_get_contents($outfile) . "]]></test_output>\n";
                }
                //			break;
            }
        }
        closedir($pdir);
        return $ret;
    }
}
Пример #26
0
<?php

// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: luofei614 <weibo.com/luofei614>
// +----------------------------------------------------------------------
/**
 * SAE模式惯例配置文件
 * 该文件请不要修改,如果要覆盖惯例配置的值,可在应用配置文件中设定和惯例不符的配置项
 * 配置名称大小写任意,系统会统一转换成小写
 * 所有配置参数都可以在生效前动态改变
 */
defined('THINK_PATH') or exit;
$st = new SaeStorage();
return array('DB_TYPE' => 'mysql', 'DB_DEPLOY_TYPE' => 1, 'DB_RW_SEPARATE' => true, 'DB_HOST' => SAE_MYSQL_HOST_M . ',' . SAE_MYSQL_HOST_S, 'DB_NAME' => SAE_MYSQL_DB, 'DB_USER' => SAE_MYSQL_USER, 'DB_PWD' => SAE_MYSQL_PASS, 'DB_PORT' => SAE_MYSQL_PORT, 'TMPL_PARSE_STRING' => array('/Public/upload' => $st->getUrl('uploads', 'image')), 'LOG_TYPE' => 'Sae', 'DATA_CACHE_TYPE' => 'Memcachesae', 'CHECK_APP_DIR' => false, 'FILE_UPLOAD_TYPE' => 'Sae');
Пример #27
0
<?php

defined('THINK_PATH') or exit;
$st = new SaeStorage();
return array('DB_TYPE' => 'mysqli', 'DB_DEPLOY_TYPE' => 1, 'DB_RW_SEPARATE' => true, 'DB_HOST' => SAE_MYSQL_HOST_M . ',' . SAE_MYSQL_HOST_S, 'DB_NAME' => SAE_MYSQL_DB, 'DB_USER' => SAE_MYSQL_USER, 'DB_PWD' => SAE_MYSQL_PASS, 'DB_PORT' => SAE_MYSQL_PORT, 'TMPL_PARSE_STRING' => array('./Public/upload' => $st->getUrl('public', 'upload'), '__PUBLIC__' => SCRIPT_DIR . '/Public', '__STATIC__' => SCRIPT_DIR . '/Public/static'), 'LOG_TYPE' => 'Sae', 'DATA_CACHE_TYPE' => 'Memcachesae', 'CHECK_APP_DIR' => false, 'FILE_UPLOAD_TYPE' => 'Sae');
Пример #28
0
 $url_1 = $storage->getUrl($domain, $propertyimagename1);
 //move_uploaded_file($propertytmpname,$propertyimagelocation);
 $propertyimagename2 = $_FILES["propertymyfile_2"]["name"];
 $propertytmpname2 = $_FILES["propertymyfile_2"]["tmp_name"];
 $propertyimagelocation2 = "{$propertyimagename2}";
 $storage = new SaeStorage();
 $domain = "upload";
 //storage名
 $storage->upload($domain, $propertyimagename2, $propertytmpname2);
 //上传
 $url_2 = $storage->getUrl($domain, $propertyimagename2);
 //move_uploaded_file($propertytmpname,$propertyimagelocation);
 $propertyimagename3 = $_FILES["propertymyfile_3"]["name"];
 $propertytmpname3 = $_FILES["propertymyfile_3"]["tmp_name"];
 $propertyimagelocation3 = "{$propertyimagename3}";
 $storage = new SaeStorage();
 $domain = "upload";
 //storage名
 $storage->upload($domain, $propertyimagename3, $propertytmpname3);
 //上传
 $url_3 = $storage->getUrl($domain, $propertyimagename3);
 //move_uploaded_file($propertytmpname,$propertyimagelocation);
 $insert = $pdo->prepare("UPDATE propertytable SET Property_Name= :propertyname, Property_Address= :propertyaddress, Property_ZipCode=:propertyzipcode, Contact_Name=:contactname, Contact_Number=:contactnumber, Property_Type=:propertytype, Property_Description=:propertydescription, \n                               Property_ImageLocation_1=:propertyimagelocation1, Property_ImageLocation_2=:propertyimagelocation2, Property_ImageLocation_3=:propertyimagelocation3, bedroom_num=:bedroom_num, bathroom_num=:bathroom_num, price= :price, member_email=:member_email where Property_ID=:id");
 $insert->bindValue(':propertyname', $propertyname);
 $insert->bindValue(':propertyaddress', $propertyaddress);
 $insert->bindValue(':propertyzipcode', $propertyzipcode);
 $insert->bindValue(':contactname', $contactname);
 $insert->bindValue(':contactnumber', $contactnumber);
 $insert->bindValue(':propertytype', $propertytype);
 $insert->bindValue(':propertydescription', $propertydescription);
 $insert->bindValue(':propertyimagelocation1', $propertyimagelocation1);
Пример #29
0
    //覆盖加入3张图片
    $logo_ten_year_img = file_get_contents('../res/images/logo_ten_year110.png');
    $logo_zfb_img = file_get_contents('../res/images/logo_zfb100.png');
    $text_bg_img = file_get_contents('../res/images/text_back350.png');
    //清空$img数据
    $img->clean();
    //设定要用于合成的三张图片(如果重叠,排在后面的图片会盖住排在前面的图片)
    $img->setData(array(array($new_data, 0, 0, 1, SAE_TOP_LEFT), array($logo_ten_year_img, -10, 10, 1, SAE_BOTTOM_RIGHT), array($logo_zfb_img, -10, -10, 1, SAE_TOP_RIGHT), array($text_bg_img, 0, -47, 1, SAE_TOP_LEFT)));
    //执行合成
    $img->composite($size[0], $size[1]);
    //输出图片
    $new_data = $img->exec('jpg');
    if ($new_data === false) {
        exit_status('error', 'p2:' . $img->errmsg());
    }
    $s = new SaeStorage();
    $result = $s->write('rank', $file_name, $new_data);
    if (!$result) {
        exit_status('fail', $result);
    }
    $url = $s->getUrl('rank', $file_name);
    exit_status('ok', $url);
} else {
    exit_status('fail', 'no file accept!');
}
// Helper functions
function exit_status($status, $data)
{
    echo json_encode(array('status' => $status, 'data' => $data));
    exit;
}
Пример #30
0
 /**
  * 用户更新头像
  *
  * 使用标准Form表单上传,头像文件名为file,只接受jpg格式的文件
  *
  * @param string token , 必填
  * @return user array 
  * @author EasyChen
  */
 public function user_update_avatar()
 {
     if ($_FILES['file']['error'] != 0) {
         return self::send_error(OP_API_UPLOAD_ERROR, 'UPLOAD ERROR ' . $_FILES['file']['error']);
     }
     $tmp_image_name = SAE_TMP_PATH . md5(time() . rand(1, 99999)) . '.tmp.jpg';
     jpeg_up($_FILES['file']['tmp_name'], $tmp_image_name);
     include_once AROOT . 'lib/thumbnail.class.php';
     $file_thumb_name = 'avatar-' . uid() . '.jpg';
     $tmp_file = SAE_TMP_PATH . $file_thumb_name;
     include_once AROOT . 'lib/icon.class.php';
     $icon = new Icon();
     $icon->path = $tmp_image_name;
     $icon->size = 100;
     $icon->dest = $tmp_file;
     $icon->createIcon();
     if (on_sae()) {
         $s = new SaeStorage();
         if (!($thumb_url = $s->write('upload', $file_thumb_name, file_get_contents($tmp_file)))) {
             return self::send_error(OP_API_STORAGE_ERROR, 'SAVE ERROR ' . $s->errmsg());
         }
     } else {
         $local_storage = AROOT . 'static' . DS . 'upload' . DS . 'avatar' . DS;
         $local_storage_url = c('site_url') . DS . 'static' . DS . 'upload' . DS . 'avatar' . DS;
         $thumb_path = $local_storage . $file_thumb_name;
         $thumb_url = $local_storage_url . $file_thumb_name;
         if (!copy($tmp_file, $thumb_path)) {
             return self::send_error(OP_API_STORAGE_ERROR, 'SAVE ERROR ');
         }
     }
     $sql = "UPDATE `user` SET `avatar_small` = '" . s($thumb_url) . "' WHERE `id` = '" . intval(uid()) . "' LIMIT 1";
     run_sql($sql);
     if (mysql_errno() != 0) {
         return self::send_error(OP_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
     } else {
         return self::send_result(get_user_info_by_id(intval(uid())));
     }
 }