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(); }
/** * 用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'); } }
function s_get_url($filepath) { $_s = new SaeStorage(); //初始化Storage对象 $_f = _s_get_path($filepath); return $_s->getUrl($_f['domain'], $_f['filename']); }
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++; } } } } }
/** * @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; }
function upload_mp3($filePath, $fileName) { $stor = new SaeStorage(); $stor->upload(SAE_DOMAIN, $fileName, $filePath); $errmsg = $stor->errmsg(); //var_export($errmsg); if ($errmsg == 0) { $result['success'] = 1; $result['url'] = $stor->getUrl(SAE_DOMAIN, $fileName); } else { $result['success'] = -1; } return $result; }
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(); }
$this->rootPath = $rootpath; $st = new \SaeStorage(); if (false === $st->getDomainCapacity($this->domain)) { $this->error = '您好像没有建立Storage的domain[' . $this->domain . ']'; return false; } return true; } /** * 检测上传目录 * @param string $savepath 上传目录 * @return boolean 检测结果,true-通过,false-失败 */ public function checkSavePath($savepath) { return true; } /** * 保存指定文件
public function storage() { $s = new SaeStorage(); $s->write('Public', 'example/thebook', 'bookcontent'); //写入文件 $ret = $s->read('Public', 'example/thebook'); //读取文件 dump($ret); $ret = $s->getUrl('Public', 'example/thebook'); //获得地址 dump($ret); }
<?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('public', 'upload')), 'LOG_TYPE' => 'Sae', 'DATA_CACHE_TYPE' => 'Memcachesae', 'CHECK_APP_DIR' => false, 'FILE_UPLOAD_TYPE' => 'Sae', 'PICTURE_UPLOAD_DRIVER' => 'Sae', 'UPLOAD_SAE_CONFIG' => array('rootPath' => 'http://' . $_SERVER['HTTP_APPNAME'] . '-uploads.stor.sinaapp.com/Editor/', 'domain' => 'uploads'), 'EDITOR_UPLOAD' => array('rootPath' => 'http://' . $_SERVER['HTTP_APPNAME'] . '-uploads.stor.sinaapp.com/Editor/', 'domain' => 'uploads'));
public function SerialMatch_detail() { // 获取系列赛id $id = $_GET['id']; $players = array(); $scale_html = ""; if ($id == null || $id == '') { $this->error('无有效参数!'); } $s = new SaeStorage(); // 获取基本情况 $ACTIVITY = M('activity'); $activity0 = $ACTIVITY->where('id=' . $id)->getField('title, content, start_time, end_time, headcount, cover, scale_num, result, champion_id'); $activity = current($activity0); if ($activity['cover'] != 1 || $s->fileExists("imgdomain", 'post/' . $id . '.jpg') == FALSE) { $activity['cover'] = "__IMG__/activity.jpg"; } else { $activity['cover'] = $s->getUrl("imgdomain", 'post/' . $id . '.jpg'); } // 获取积分榜数据 $ACTIVITY_USER = M('activity_user'); $activity_user = $ACTIVITY_USER->join('INNER JOIN serial_match_user ON serial_match_user.serial_match_id=activity_user.activity_id and serial_match_user.user_id=activity_user.user_id and activity_user.activity_id=' . $id . ' and serial_match_user.round=1 and type=0')->join('INNER JOIN user ON user.id=activity_user.user_id')->order('serial_match_user.group,score desc,win desc,activity_user.offset desc')->getField('truename,activity_user.round,win,lost,offset,activity_user.score,group,no'); $score_list = null; if ($activity_user != null) { $this->assign('exist1', 1); $index = -1; $subIndex = 0; $group = ''; foreach ($activity_user as $key => $value) { if ($group != $value['group']) { $index++; $subIndex = 0; $group = $value['group']; $score_list[$index]['group'] = $group; } $score_list[$index]['player'][$subIndex]['index'] = $subIndex + 1; $score_list[$index]['player'][$subIndex]['truename'] = $value['truename']; $score_list[$index]['player'][$subIndex]['win'] = $value['win']; $score_list[$index]['player'][$subIndex]['lost'] = $value['lost']; $score_list[$index]['player'][$subIndex]['offset'] = $value['offset']; $score_list[$index]['player'][$subIndex]['score'] = $value['score']; $score_list[$index]['player'][$subIndex]['round'] = $value['round']; $score_list[$index]['player'][$subIndex]['no'] = $group . $value['no']; $subIndex++; } } // 获取小组赛对阵 $BASE_MATCH = M('base_match'); $base_match = $BASE_MATCH->join(' INNER JOIN serial_base_match ON serial_base_match.serial_match_id=' . $id . ' and serial_base_match.base_match_id=base_match.id and serial_base_match.type=0 and serial_base_match.serial_match_id=' . $id)->join(' INNER JOIN serial_match_user ON serial_match_user.serial_match_id=' . $id . ' and serial_base_match.player1_id = serial_match_user.user_id and serial_match_user.type=0')->order('serial_match_user.group, state desc,start_date')->getField('base_match.id, group, state, score, start_date, end_date, player1_id, player2_id, round1, round2'); $SERIAL_MATCH_USER = M('serial_match_user'); $user_no = $SERIAL_MATCH_USER->where('serial_match_id=' . $id . ' and round=1 and type=0')->join('INNER JOIN user ON user.id=serial_match_user.user_id')->getField('user_id, truename, no'); $group_list = null; if ($base_match != null) { $this->assign('exist2', 1); $index = -1; $subIndex = 0; $group = ''; foreach ($base_match as $key => $value) { if ($group != $value['group']) { $index++; $subIndex = 0; $group = $value['group']; $group_list[$index]['group'] = $group; } if ($value['state'] == 0) { $group_list[$index]['players'][$subIndex]['state'] = '未开始'; } else { $group_list[$index]['players'][$subIndex]['state'] = '已结束'; } $group_list[$index]['players'][$subIndex]['start_date'] = $value['start_date']; $group_list[$index]['players'][$subIndex]['end_date'] = $value['end_date']; $group_list[$index]['players'][$subIndex]['vs'] = $user_no[$value['player1_id']]['truename'] . '【' . $value['score'] . '】' . $user_no[$value['player2_id']]['truename']; $group_list[$index]['players'][$subIndex]['round'] = '[' . $value['round1'] . ',' . $value['round2'] . ']'; $group_list[$index]['players'][$subIndex]['no1'] = $user_no[$value['player1_id']]['no']; $group_list[$index]['players'][$subIndex]['no2'] = $user_no[$value['player2_id']]['no']; $subIndex++; } } // 获得淘汰赛对阵 $SERIAL_MATCH_USER1 = M('serial_match_user'); $user_name = $SERIAL_MATCH_USER1->where('serial_match_id=' . $id . ' and round=1 and type=1')->join('INNER JOIN user ON user.id=serial_match_user.user_id')->getField('user_id, truename, no'); $base_match = $BASE_MATCH->join(' INNER JOIN serial_base_match ON serial_base_match.base_match_id=base_match.id and serial_base_match.type=1 and serial_base_match.serial_match_id=' . $id)->order('state desc,start_date')->getField('base_match.id, state, score, start_date, end_date, player1_id, player2_id, round1, round2,group1,group2,no1,no2'); foreach ($base_match as $key => $value) { // 人员信息设置 if ($value['player1_id'] > 0) { $player1 = $user_name[$value['player1_id']]['truename']; } else { if ($value['player1_id'] == 0) { $player1 = "轮空"; } else { $player1 = "待出线"; } } if ($value['player2_id'] > 0) { $player2 = $user_name[$value['player2_id']]['truename']; } else { if ($value['player2_id'] == 0) { $player2 = "轮空"; } else { $player2 = "待出线"; } } $group1 = $value['group1']; $group2 = $value['group2']; $no1 = $value['no1']; $no2 = $value['no2']; $round1 = $value['round1']; $round2 = $value['round2']; $index1 = ''; $index2 = ''; if ($round1 == '1') { $index1 = $group1 . $no1; } else { $index1 = $group1 . $round1 . $no1; } $players[$index1] = $player1; if ($round2 == '1') { $index2 = $group2 . $no2; } else { $index2 = $group2 . $round2 . $no2; } $players[$index2] = $player2; // 比赛信息设置 $players['M' . $group1 . $round1 . $no2 / 2] = $value['score']; // 设置冠军 $players['W'] = $user_name[$activity['champion_id']]['truename']; } $elimination_list = null; $index = -1; $subIndex = 0; $round = 0; $title = ''; // 设定1/8,1/4,1/2,决赛列表 $base_match = $BASE_MATCH->join(' INNER JOIN serial_base_match ON serial_base_match.base_match_id=base_match.id and serial_base_match.group1="S" and serial_base_match.type=1 and serial_base_match.serial_match_id=' . $id)->order('state desc,start_date')->getField('base_match.id, state, score, start_date, end_date, player1_id, player2_id, round1, round2,group1,group2,no1,no2'); if ($base_match != null) { $this->assign('exist3', 1); // 判断淘汰赛显示阵型 switch ($activity['scale_num']) { case 8: $players = scale8Compute($base_match, $user_name); $scale_html = "Match:scale8"; break; case 16: $scale_html = "Match:scale16"; break; case 32: $players = scale32Compute($base_match, $user_name); $scale_html = "Match:scale32"; break; case 64: $players = scale64Compute($base_match, $user_name); $scale_html = "Match:scale64"; break; case 128: $players = scale128Compute($base_match, $user_name); $scale_html = "Match:scale128"; break; case 256: $players = scale256Compute($base_match, $user_name); $scale_html = "Match:scale256"; break; default: break; } foreach ($base_match as $key => $value) { if ($round != $value['round1']) { $index++; $round = $value['round1']; $subIndex = 0; } if ($value['state'] == 0) { $elimination_list[$index]['players'][$subIndex]['state'] = '未开始'; } else { $elimination_list[$index]['players'][$subIndex]['state'] = '已结束'; } if ($value['score'] == '') { $value['score'] = '0:0'; } $elimination_list[$index]['players'][$subIndex]['start_date'] = $value['start_date']; $elimination_list[$index]['players'][$subIndex]['end_date'] = $value['end_date']; $elimination_list[$index]['players'][$subIndex]['vs'] = $user_name[$value['player1_id']]['truename'] . '【' . $value['score'] . '】' . $user_name[$value['player2_id']]['truename']; $elimination_list[$index]['players'][$subIndex]['round'] = '[' . $value['round1'] . ',' . $value['round2'] . ']'; $elimination_list[$index]['players'][$subIndex]['no1'] = $value['no1']; $elimination_list[$index]['players'][$subIndex]['no2'] = $value['no2']; $subIndex++; if ($index >= 0) { switch ($subIndex) { case 8: $elimination_list[$index]['title'] = '1/8决赛'; break; case 4: $elimination_list[$index]['title'] = '1/4决赛'; break; case 2: $elimination_list[$index]['title'] = '半决赛'; break; case 1: $elimination_list[$index]['title'] = '决赛'; break; default: break; } } } $elimination_list[$index]['title'] = '决赛'; } // 获取参赛人员 $USER = M('user'); $userList = $USER->join(' INNER JOIN activity_user ON activity_user.user_id = user.id and activity_user.activity_id=' . $id . ' and activity_user.sign=1')->getField('user.id,truename, telephone, ntrp, portrait'); if ($userList != null) { $this->assign('exist4', 1); foreach ($userList as $key => $value) { $userList[$key]['ntrp'] = number_format($value['ntrp'], 1); // 设置封面 if ($value['portrait'] == 1) { $userList[$key]['portrait'] = $s->getUrl("imgdomain", 'portrait/' . $value['id'] . '.jpg'); } else { $userList[$key]['portrait'] = '__IMG__/portrait.jpg'; } } } $this->assign('activity', $activity); $this->assign('score_list', $score_list); $this->assign('group_list', $group_list); $this->assign('elimination_list', $elimination_list); $this->assign('players_list', $userList); $this->assign('scale_html', $scale_html); $players['enable'] = 0; $this->assign('players', $players); $this->display(); }
<?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('public', 'upload'), '/Public/AUSrc' => $st->getUrl('public', 'AUSrc'), '/Public/general' => $st->getUrl('public', 'general'), '/Public/NewsSrc' => $st->getUrl('public', 'NewsSrc'), '/Public/FAQSrc' => $st->getUrl('public', 'FAQSrc'), '/Public/js' => $st->getUrl('public', 'js'), '/Public/OtherSrc' => $st->getUrl('public', 'OtherSrc')), 'LOG_TYPE' => 'Sae', 'DATA_CACHE_TYPE' => 'Memcachesae', 'CHECK_APP_DIR' => false, 'FILE_UPLOAD_TYPE' => 'Sae');
public function action_thumb($attachmentId = false) { if (!($attachment = $this->getAttachment($attachmentId))) { return; } $model = ET::getInstance("attachmentModel"); //$path = $model->path().$attachmentId.$attachment["secret"]; $path = $model->path() . $attachmentId . '_' . $attachment["filename"]; //$thumb = $path."_thumb"; $thumb = $model->path() . 'thumb_' . $attachmentId . '_' . $attachment["filename"]; $thumb_encode = $model->path() . urlencode('thumb_' . $attachmentId . '_' . $attachment["filename"]); if (!file_exists(PATH_SAESTOR . $thumb)) { try { $uploader = ET::uploader(); $thumb = $uploader->saveAsImage(PATH_SAESTOR . $path, $thumb, 400, 300, "max"); //$newThumb = substr($thumb, 0, strrpos($thumb, ".")); //rename($thumb, $newThumb); //$thumb = $newThumb; } catch (Exception $e) { return; } } //in SAE $s = new SaeStorage(); if ($s->fileExists(SAESTOR_DOMAIN, $thumb)) { $url = $s->getUrl(SAESTOR_DOMAIN, $thumb_encode); redirect($url); } else { $this->render404(T("message.attachmentNotFound"), true); return false; } //header('Content-Type: '.$model->mime($attachment["filename"])); //echo file_get_contents($thumb); }
<?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');
function file_domain($domain = '') { if (!IS_SAE) { return ''; } $s = new SaeStorage(); return rtrim($s->getUrl($domain, ''), '/'); }
public function serialMatch_release_presubmit() { // 检查提交的比赛是否符合提交条件 if ($_POST['ensureArrange'] == 1) { for ($i = 1; $i <= $groupNum; $i++) { // 循环组 for ($j = 1; $j < $eachGroupAmount;) { // 组内循环成员 if ($_POST[$groupArray[$i] . $j] == null || $_POST[$groupArray[$i] . $j] == '') { $this->error('有部分球员未安排赛事,请重新安排!'); } } } } // 获取系列赛id $id0 = $_GET['id']; $groupNum = $_POST['groupNum']; $type = $_GET['type']; if ($id0 == null || $id0 == '') { $this->error('无有效参数!'); } $s = new SaeStorage(); // 获取基本情况 $ACTIVITY = M('activity'); $activity0 = $ACTIVITY->where('id=' . $id0)->getField('id, title, content, start_time, end_time, headcount, cover, scale_num, state, result, champion_id'); $activity = current($activity0); if ($activity['cover'] != 1 || $s->fileExists("imgdomain", 'post/' . $id0 . '.jpg') == FALSE) { $activity['cover'] = "__IMG__/activity.jpg"; } else { $activity['cover'] = $s->getUrl("imgdomain", 'post/' . $id0 . '.jpg'); } // 赛事安排类型 $matchArrangeType = 0; // 0表示小组赛,1表示淘汰赛,2表示超出系统安排范围 // 参赛总人数 $ACTIVITY = M('activity'); $headcount = $ACTIVITY->where('id=' . $_GET['id'])->GetField('headcount'); // 如果是淘汰赛,计算系统预设的分组数、每组人数和轮空数 $groupNum = 0; $eachGroupAmount = 0; $groupVoidArray = array(); // 轮空数组 $groupArray = array("1" => "A", "2" => "B", "3" => "C", "4" => "D", "5" => "E", "6" => "F", "7" => "G", "8" => "H"); $groupRoundNum = 0; // 淘汰赛 if ($type == 1) { $matchArrangeType = 1; if ($headcount <= 8) { $groupNum = 2; $diff = 8 - $headcount; // 轮空数 $eachGroupAmount = 4; $groupRoundNum = 2; $scaleNum = 8; } else { if ($headcount <= 16) { $groupNum = 2; $diff = 16 - $headcount; // 轮空数 $eachGroupAmount = 8; $groupRoundNum = 3; $scaleNum = 16; } else { if ($headcount <= 32) { $groupNum = 4; $diff = 32 - $headcount; // 轮空数 $eachGroupAmount = 8; $groupRoundNum = 3; $scaleNum = 32; } else { if ($headcount <= 64) { $groupNum = 4; $diff = 64 - $headcount; // 轮空数 $eachGroupAmount = 16; $groupRoundNum = 4; $scaleNum = 64; } else { if ($headcount <= 128) { $groupNum = 8; $diff = 128 - $headcount; // 轮空数 $eachGroupAmount = 16; $groupRoundNum = 4; $scaleNum = 128; } else { if ($headcount <= 256) { $groupNum = 8; $diff = 256 - $headcount; // 轮空数 $eachGroupAmount = 32; $groupRoundNum = 5; $scaleNum = 256; } else { $matchArrangeType = 2; } } } } } } // 计算每组轮空数 if ($matchArrangeType != 2) { $j = 1; $round = 1; for ($i = 1; $i <= $diff; $i++) { $groupVoidArray[$j][$round * 2] = 1; $j++; if ($j > $groupNum) { $round++; $j = 1; } } } } else { $matchArrangeType = 0; $groupNum = $_POST['groupNum']; $eachGroupAmount = floor($headcount / $groupNum); $offset = $groupNum - $headcount % $groupNum; if ($offset > 0) { $eachGroupAmount++; } // 计算每组轮空情况 $j = $groupNum; for ($i = 1; $i <= $offset; $i++) { $groupVoidArray[$j][$eachGroupAmount] = 1; $j--; } } // --------------确认安排赛事--------------- if ($_POST['ensureArrange'] == 1) { // 更新activity $ACTIVITY = M('activity'); $ACTIVITY->id = $id0; $ACTIVITY->scale_num = $scaleNum; $ACTIVITY->group_num = $groupNum; $SERIAL_MATCH_USER = M('serial_match_user'); $SERIAL_BASE_MATCH = M('serial_base_match'); $BASE_MATCH = M('base_match'); // serialMatchUser表提交数据变量 $serialMatchUserItemArray = array(); $serialMatchUserItemArray['serial_match_id'] = $id0; $serialMatchUserItemArray['round'] = 1; $serialMatchUserItemArray['type'] = $type; $serialMatchUserArray = array(); // serialBaseMatch表提交数据变量 $serialBaseMatchItemArray = array(); $serialBaseMatchItemArray['serial_match_id'] = $id0; $serialBaseMatchItemArray['type'] = $type; $serialBaseMatchArray = array(); // baseMatch表提交数据变量 $baseMatchArray = array(); $baseMatchArray['serial_match_id'] = $id0; $baseMatchArray['state'] = 0; $baseMatchArray['update_user'] = $_SESSION['tennis-user']['id']; $d = date('Y-m-d H:i:s'); $baseMatchArray['update_date'] = $d; $baseMatchArray['start_date'] = $activity['start_time']; $baseMatchArray['end_date'] = $activity['end_time']; $sIndex = 0; // 存储到serial_match_user变量中 for ($i = 1; $i <= $groupNum; $i++) { for ($j = 1; $j <= $eachGroupAmount; $j++) { if ($_POST[$groupArray[$i] . $j] != 0) { $serialMatchUserItemArray['user_id'] = $_POST[$groupArray[$i] . $j]; $serialMatchUserItemArray['group'] = $groupArray[$i]; $serialMatchUserItemArray['no'] = $j; $serialMatchUserArray[$sIndex] = $serialMatchUserItemArray; $sIndex++; } } } // 更新serial_match_user表 $result = $SERIAL_MATCH_USER->addAll($serialMatchUserArray); if ($result === false) { $this->error("保存serial_match_user出问题了,请联系管理员!"); } $sIndex = 0; // 分类型更新base_match,serial_base_match // 小组赛 if ($type == 0) { for ($i = 1; $i <= $groupNum; $i++) { // 循环组 for ($j = 1; $j < $eachGroupAmount; $j++) { // 组内循环成员 for ($k = $j + 1; $k <= $eachGroupAmount; $k++) { // 组内成员全排列 if ($_POST[$groupArray[$i] . $j] != 0 && $_POST[$groupArray[$i] . $k] != 0) { $tmp_id = $BASE_MATCH->data($baseMatchArray)->add(); if ($tmp_id === false) { $this->error("保存base_match出问题了,请联系管理员!"); } else { // 存储到serial_base_match变量中 $serialBaseMatchItemArray['base_match_id'] = $tmp_id; $serialBaseMatchItemArray['player1_id'] = $_POST[$groupArray[$i] . $j]; $serialBaseMatchItemArray['player2_id'] = $_POST[$groupArray[$i] . $k]; $serialBaseMatchItemArray['group1'] = $groupArray[$i]; $serialBaseMatchItemArray['group2'] = $groupArray[$i]; $serialBaseMatchItemArray['no1'] = $j; $serialBaseMatchItemArray['no2'] = $k; $serialBaseMatchArray[$sIndex] = $serialBaseMatchItemArray; $sIndex++; } } } } } // 更新serial_base_match $result = $SERIAL_BASE_MATCH->addAll($serialBaseMatchArray); if ($result === false) { $this->error("保存serial_base_match出问题了,请联系管理员!"); } } else { if ($type == 1) { // 排列小组内淘汰赛 $tmp_each_group_amount = $eachGroupAmount; $r = 1; for (; $r <= $groupRoundNum; $r++) { for ($i = 1; $i <= $groupNum; $i++) { // 循环组 for ($j = 1; $j < $tmp_each_group_amount;) { // 组内循环成员 $tmp_id = $BASE_MATCH->data($baseMatchArray)->add(); if ($tmp_id === false) { $this->error("保存base_match出问题了,请联系管理员!"); } else { // 存储到serial_base_match变量中 $serialBaseMatchItemArray['base_match_id'] = $tmp_id; if ($r == 1) { $serialBaseMatchItemArray['player1_id'] = $_POST[$groupArray[$i] . $j]; $serialBaseMatchItemArray['player2_id'] = $_POST[$groupArray[$i] . ($j + 1)]; } else { $serialBaseMatchItemArray['player1_id'] = -1; $serialBaseMatchItemArray['player2_id'] = -1; } $serialBaseMatchItemArray['group1'] = $groupArray[$i]; $serialBaseMatchItemArray['group2'] = $groupArray[$i]; $serialBaseMatchItemArray['round1'] = $r; $serialBaseMatchItemArray['round2'] = $r; $serialBaseMatchItemArray['no1'] = $j; $serialBaseMatchItemArray['no2'] = $j + 1; $serialBaseMatchArray[$sIndex] = $serialBaseMatchItemArray; $sIndex++; } $j += 2; } } $tmp_each_group_amount /= 2; } // 排列小组出线后淘汰赛 $tmp_each_group_amount *= $groupNum; while ($tmp_each_group_amount >= 1) { $j = 1; while ($j < $tmp_each_group_amount) { // 组内循环成员 $tmp_id = $BASE_MATCH->data($baseMatchArray)->add(); if ($tmp_id === false) { $this->error("保存base_match出问题了,请联系管理员!"); } else { // 存储到serial_base_match变量中 $serialBaseMatchItemArray['base_match_id'] = $tmp_id; $serialBaseMatchItemArray['player1_id'] = -1; $serialBaseMatchItemArray['player2_id'] = -1; $serialBaseMatchItemArray['group1'] = 'S'; $serialBaseMatchItemArray['group2'] = 'S'; $serialBaseMatchItemArray['round1'] = $r; $serialBaseMatchItemArray['round2'] = $r; $serialBaseMatchItemArray['no1'] = $j; $serialBaseMatchItemArray['no2'] = $j + 1; $serialBaseMatchArray[$sIndex] = $serialBaseMatchItemArray; $sIndex++; } $j += 2; } $r++; $tmp_each_group_amount /= 2; } // 更新serial_base_match $result = $SERIAL_BASE_MATCH->addAll($serialBaseMatchArray); if ($result === false) { $this->error("保存serial_base_match出问题了,请联系管理员!"); } } } // 完成安排,跳转到赛事页面 $this->success('安排成功!', '__APP__/Admin/Match/serialMatch_update_detail?id=' . $id0); } // 获取参赛选手列表 $playerList = array(); $all_players_id = array(); $ACTIVITY_USER = M('activity_user'); $player = $ACTIVITY_USER->where('activity_id=' . $_GET['id'])->join('INNER JOIN user ON user.id=activity_user.user_id')->getField('user.id, user_id, truename'); foreach ($player as $key => $value) { $firstChar = getFirstChar($value['truename']); $user_name = $value['truename']; $user_id = $value['user_id']; $playerList[$user_id]['id'] = $user_id; $playerList[$user_id]['name'] = $user_name; $playerList[$user_id]['letter'] = $firstChar; array_push($all_players_id, $value['user_id']); } // 获取已安排参赛选手及对应位置 // 已安排选手列表 $has_set_players = array(); // 等待随机插入的选手列表 $rand_players = array(); // 安排好用于返回的选手 $players = array(); // 获取已安排选手列表 for ($i = 1; $i <= $groupNum; $i++) { for ($j = 1; $j <= $eachGroupAmount; $j++) { $index = $groupArray[$i] . $j; if ($_POST[$index] > 0) { // 已安排 array_push($has_set_players, $_POST[$index]); } } } // 获取未安排选手列表 $rand_players = array_diff($all_players_id, $has_set_players); shuffle($rand_players); // 安排这些未安排选手 for ($i = 1; $i <= $groupNum; $i++) { for ($j = 1; $j <= $eachGroupAmount; $j++) { $index = $groupArray[$i] . $j; if ($_POST[$index] == null || $_POST[$index] == '') { // 待安排 $tmp_id = array_shift($rand_players); if ($tmp_id == null || $tmp_id == '') { break; } $players[$groupArray[$i]][$j][id] = $tmp_id; $players[$groupArray[$i]][$j][name] = $playerList[$tmp_id]['name']; $players[$groupArray[$i]][$j][letter] = $playerList[$tmp_id]['letter']; } else { if ($_POST[$index] > 0) { $tmp_id = $_POST[$index]; $players[$groupArray[$i]][$j][id] = $tmp_id; $players[$groupArray[$i]][$j][name] = $playerList[$tmp_id]['name']; $players[$groupArray[$i]][$j][letter] = $playerList[$tmp_id]['letter']; } } } } // 字母列表 $letterList = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); // 返回参数 $this->assign("id", $_GET['id']); $this->assign("matchArrangeType", $matchArrangeType); $this->assign("groupVoidArray", $groupVoidArray); $this->assign("groupNum", $groupNum); $this->assign("eachGroupAmount", $eachGroupAmount); $this->assign("groupArray", $groupArray); $this->assign("activity", $activity); $this->assign("players", $players); $this->assign("letterList", $letterList); $this->assign("hasSetPlayer", 1); $this->assign("groupNum", $groupNum); $this->display(); }
$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; } function get_extension($file_name) { $ext = explode('.', $file_name); $ext = array_pop($ext); return strtolower($ext);
function getThumbImage($filename, $width = 100, $height = 'auto', $type = 0, $replace = false) { $UPLOAD_URL = ''; $UPLOAD_PATH = ''; $filename = str_ireplace($UPLOAD_URL, '', $filename); //将URL转化为本地地址 $info = pathinfo($filename); $oldFile = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename'] . '.' . $info['extension']; $thumbFile = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename'] . '_' . $width . '_' . $height . '.' . $info['extension']; $oldFile = str_replace('\\', '/', $oldFile); $thumbFile = str_replace('\\', '/', $thumbFile); $filename = ltrim($filename, '/'); $oldFile = ltrim($oldFile, '/'); $thumbFile = ltrim($thumbFile, '/'); //兼容SAE的中心裁剪缩略 if (strtolower(C('PICTURE_UPLOAD_DRIVER')) == 'sae') { $storage = new SaeStorage(); $thumbFilePath = str_replace(C('UPLOAD_SAE_CONFIG.rootPath'), '', $thumbFile); if (!$storage->fileExists(C('UPLOAD_SAE_CONFIG.domain'), $thumbFilePath)) { $f = new SaeFetchurl(); $img_data = $f->fetch($oldFile); $img = new SaeImage(); $img->setData($img_data); $info_img = $img->getImageAttr(); if ($height == "auto") { $height = $info_img[1] * $height / $info_img[0]; } $w = $info_img[0]; $h = $info_img[1]; /* 居中裁剪 */ //计算缩放比例 $w_scale = $width / $w; if ($w_scale > 1) { $w_scale = 1 / $w_scale; } $h_scale = $height / $h; if ($h_scale > $w_scale) { //按照高来放缩 $x1 = (1 - 1.0 * $width * $h / $w / $height) / 2; $x2 = 1 - $x1; $img->crop($x1, $x2, 0, 1); $img_temp = $img->exec(); $img1 = new SaeImage(); $img1->setData($img_temp); $img1->resizeRatio($h_scale); } else { $y1 = (1 - 1 * 1.0 / ($width * $h / $w / $height)) / 2; $y2 = 1 - $y1; $img->crop(0, 1, $y1, $y2); $img_temp = $img->exec(); $img1 = new SaeImage(); $img1->setData($img_temp); $img1->resizeRatio($w_scale); } $img1->improve(); $new_data = $img1->exec(); // 执行处理并返回处理后的二进制数据 if ($new_data === false) { return $oldFile; } // 或者可以直接输出 $thumbed = $storage->write(C('UPLOAD_SAE_CONFIG.domain'), $thumbFilePath, $new_data); $info['width'] = $width; $info['height'] = $height; $info['src'] = $thumbed; //图片处理失败时输出错误码和错误信息 } else { $info['width'] = $width; $info['height'] = $height; $info['src'] = $storage->getUrl(C('UPLOAD_SAE_CONFIG.domain'), $thumbFilePath); } return $info; } //原图不存在直接返回 if (!file_exists($UPLOAD_PATH . $oldFile)) { @unlink($UPLOAD_PATH . $thumbFile); $info['src'] = $oldFile; $info['width'] = intval($width); $info['height'] = intval($height); return $info; //缩图已存在并且 replace替换为false } elseif (file_exists($UPLOAD_PATH . $thumbFile) && !$replace) { $imageinfo = getimagesize($UPLOAD_PATH . $thumbFile); $info['src'] = $thumbFile; $info['width'] = intval($imageinfo[0]); $info['height'] = intval($imageinfo[1]); return $info; //执行缩图操作 } else { $oldimageinfo = getimagesize($UPLOAD_PATH . $oldFile); $old_image_width = intval($oldimageinfo[0]); $old_image_height = intval($oldimageinfo[1]); if ($old_image_width <= $width && $old_image_height <= $height) { @unlink($UPLOAD_PATH . $thumbFile); @copy($UPLOAD_PATH . $oldFile, $UPLOAD_PATH . $thumbFile); $info['src'] = $thumbFile; $info['width'] = $old_image_width; $info['height'] = $old_image_height; return $info; } else { if ($height == "auto") { $height = $old_image_height * $width / $old_image_width; } if ($width == "auto") { $width = $old_image_width * $width / $old_image_height; } if (intval($height) == 0 || intval($width) == 0) { return 0; } require_once 'ThinkPHP/Library/Vendor/phpthumb/PhpThumbFactory.class.php'; $thumb = PhpThumbFactory::create($UPLOAD_PATH . $filename); if ($type == 0) { $thumb->adaptiveResize($width, $height); } else { $thumb->resize($width, $height); } $res = $thumb->save($UPLOAD_PATH . $thumbFile); $info['src'] = $UPLOAD_PATH . $thumbFile; $info['width'] = $old_image_width; $info['height'] = $old_image_height; return $info; //内置库缩略 /* $image = new \Think\Image(); $image->open($UPLOAD_PATH . $filename); //dump($image);exit; $image->thumb($width, $height, $type); $image->save($UPLOAD_PATH . $thumbFile); //缩图失败 if (!$image) { $thumbFile = $oldFile; } $info['width'] = $width; $info['height'] = $height; $info['src'] = $thumbFile; return $info;*/ } } }
/** * @function imageManager */ public function imageManager() { header("Content-Type: text/html; charset=utf-8"); //需要遍历的目录列表,最好使用缩略图地址,否则当网速慢时可能会造成严重的延时 $paths = array(Upload_PATH, 'upload1/'); // $action = htmlspecialchars($_POST["action"]); $action = htmlspecialchars($_REQUEST["action"]); if ($action == "get") { if (!defined('SAE_TMP_PATH')) { $files = array(); foreach ($paths as $path) { //$dir = new Dir(); //$tmp = $dir->getfiles($path); $tmp = File::getFiles($path); if ($tmp) { $files = array_merge($files, $tmp); } } if (!count($files)) { return; } rsort($files, SORT_STRING); $str = ""; foreach ($files as $file) { $str .= __ROOT__ . '/' . $file . "ue_separate_ue"; } echo $str; } else { // SAE环境下 $st = new \SaeStorage(); // 实例化 /* * getList:获取指定domain下的文件名列表 * return: 执行成功时返回文件列表数组,否则返回false * 参数:存储域,路径前缀,返回条数,起始条数 */ $num = 0; while ($ret = $st->getList(get_opinion('SaeStorage'), null, 100, $num)) { foreach ($ret as $file) { if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) { echo $st->getUrl('upload', $file) . "ue_separate_ue"; } $num++; } } } } }
/* Uploadify Copyright (c) 2012 Reactive Apps, Ronnie Garcia Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */ $domain = "uploads"; // Define a destination $targetFolder = '/upload/uploads'; // Relative to the root //$verifyToken = md5('unique_salt' . $_POST['timestamp']); //$_SESSION['DATA'] = "123"; //if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetFile = rtrim($targetPath, '/') . '/' . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); $tar = "/uploads" . '/' . md5(time()) . $_FILES['Filedata']['name']; if (in_array($fileParts['extension'], $fileTypes)) { $s = new SaeStorage(); $s->upload($domain, $tar, $tempFile); $file_url = $s->getUrl($domain, $tar); echo $file_url; //$file_url = $s->getUrl( $domain , $new_file_name); //move_uploaded_file($tempFile,$targetFile); } else { echo 'Invalid file type.'; } //}
<?php $stor = new SaeStorage(); if ($_GET['type'] == 'apk') { echo $stor->getUrl('course', 'coursehelper.apk'); }
/** * 将图片资源保存到storage * @returns string storage中图片的URL */ public function save() { //给文件名添加随机的后缀,防止重复 $random = mt_rand(); $filename = substr(str_replace("/", "", parse_url($this->url, PHP_URL_PATH)), -10) . $random . ".jpg"; //just for test //$stor = new SaeStorage("n353jmy031","zwwkm3wjxmmkxkhwzlyjhxz3lh2xkyj3zhx014lh"); /* imagepng这样的函数不支持wrapper,用临时文件解决 imageX 第二个参数指定filename,将文件保存到一个地址而不是输出到浏览器 使用sae storage的wrapper来保存图片 file_put_contents("saestor://n/test.txt", "haha"); 保存为临时文件 $bool = imagejpeg($img, SAE_TMP_PATH . $filename); imagedestroy($img); $this-log("保存的文件名:" . $filename); 从临时文件里取出,保存到storage里 file_put_contents("saestor://wechatimg/$filename", file_get_contents(SAE_TMP_PATH . $filename));*/ /* * 新的文件保存方法 用缓存来实现,这个方法应该会快很多,因为减少了两个特别慢的函数 */ $domain = "wechatimg"; $stor = new SaeStorage(); ob_start(); imagejpeg($this->img); $imgstr = ob_get_contents(); $bool = $stor->write($domain, $filename, $imgstr); ob_end_clean(); imagedestroy($this->img); if (!$bool) { $this->log("保存文件失败"); } $this->newUrl = $stor->getUrl($domain, $filename); return $this->newUrl; }
} .c{ padding-left:34px; margin-bottom:19px; } body { padding:34px; } </style> </head> <body> <div> <a class="dl" href="<?php $stor = new SaeStorage(); echo $stor->getUrl('course', 'StartWIFI.exe'); ?> ">下载StartWIFI</a> <div class="ht" align="center"><h2>欢迎使用StartWIFI</h2></div> </div> <div class="h">StartWIFI</div> <div class="c"> <p> 这是一个利用WIN7/8内置虚拟WIFI模组实现的开启共享WIFI的软件,由于是操作系统自身内置,所以它更节省PC资源。 </p> </div> <div class="h">首次使用StartWIFI</div> <div class="c"> <p>
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2013 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('public', 'upload'), '__CSS__' => __ROOT__ . '/Public/Css', '__JS__' => __ROOT__ . '/Public/Js', '__PLUGIN__' => __ROOT__ . '/Public/Plugin', '__IMAGE__' => __ROOT__ . '/Public/Image'), 'LOG_TYPE' => 'Sae', 'DATA_CACHE_TYPE' => 'Memcachesae', 'CHECK_APP_DIR' => false);
<?php $kv = new SaeKV(); // 初始化SaeKV对象 $ret = $kv->init(); $ret = $kv->get('THINKCMF_DYNAMIC_CONFIG'); $runtime_config = $ret ? unserialize($ret) : array(); $_msaestorage = new SaeStorage(); $sae = array('DB_TYPE' => 'mysql', 'DB_DEPLOY_TYPE' => 1, 'DB_RW_SEPARATE' => true, 'DB_HOST' => SAE_MYSQL_HOST_M, 'DB_NAME' => SAE_MYSQL_DB, 'DB_USER' => SAE_MYSQL_USER, 'DB_PWD' => SAE_MYSQL_PASS, 'DB_PORT' => SAE_MYSQL_PORT, 'DB_PREFIX' => 'sp_', "COOKIE_PREFIX" => 'U49dZ1_', 'FILE_UPLOAD_TYPE' => 'Sae', 'TMPL_PARSE_STRING' => array('__UPLOAD__' => $_msaestorage->getUrl('data', 'upload') . "/")); //print_r($runtime_config); die; return array_merge($sae, $runtime_config);
public function invite_more_comment() { $pageId = $_GET['pageId']; $user_id = $_GET['user_id']; $pageId1 = 0; $pageId2 = 0; $s = new SaeStorage(); $User = M('User'); // 获取评论 $comment = M('invitation_comment'); $commentList = $comment->where('invitation_id=' . $_GET['id'])->order('time desc')->page($_GET['pageId'] + 1, 30)->getField('id, user_id, comment, time'); $num = $comment->where('invitation_id=' . $_GET['id'])->count("id"); $list1 = array(); // 设置分页Id $maxPageId = 0; if ($commentList != null) { $offset = $num % 30; if ($offset != 0) { $maxPageId = ($num - $offset) / 30; $maxPageId++; } else { $maxPageId = $num / 30; } if ($_GET['pageId'] == 0) { $pageId1 = 0; } else { $pageId1 = $_GET['pageId'] - 1; } if ($_GET['pageId'] < $maxPageId - 1) { $pageId2 = $_GET['pageId'] + 1; } else { $pageId2 = $maxPageId - 1; } } else { $pageId = -1; $pageId1 = -1; $pageId2 = -1; } foreach ($commentList as $key => $value) { $userList = $User->where('id=' . $value['user_id'])->getField('id,username,level, portrait'); if ($userList != null) { if ($userList[$value['user_id']]['portrait'] == 1) { $list1[$key]['img'] = $s->getUrl('imgdomain', 'portrait/' . $value['user_id'] . '.jpg'); } else { $list1[$key]['img'] = "__IMG__/portrait.jpg"; } $list1[$key]['info'] = $userList[$value['user_id']]['username'] . "(" . $userList[$value['user_id']]['level'] . ") " . $value['time']; $list1[$key]['comment'] = $value['comment']; $list1[$key]['user_id'] = $value['user_id']; $list1[$key]['reply_id'] = $value['id']; } } $this->assign('commentList', $list1); $this->assign('num', $num); $this->assign("page", $pageId + 1 . '/' . $maxPageId); $this->assign('user_id', $user_id); $this->assign("title", $_GET['title']); $this->assign("type", $_GET['type']); $this->assign("id", $_GET['id']); $this->assign("pageId", $pageId); $this->assign("pageId1", $pageId1); $this->assign("pageId2", $pageId2); $this->display(); }
$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); $insert->bindValue(':propertyimagelocation2', $propertyimagelocation2); $insert->bindValue(':propertyimagelocation3', $propertyimagelocation3); $insert->bindValue(':price', $price); $insert->bindValue(':bedroom_num', $bedroom_num); $insert->bindValue(':bathroom_num', $bathroom_num);
/** * 获取实际文件绝对访问路径 * * @access public * @param array $content 文件相关信息 * @return string */ public static function attachmentHandle(array $content) { $stor = new SaeStorage(); $options = Typecho_Widget::widget('Widget_Options'); $SaeStorageDomain = $options->plugin('SaeUpload')->saestoragedomain; return $stor->getUrl($SaeStorageDomain, $content['attachment']->path); }
<?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');
<?php //sae专项配置 $st = new SaeStorage(); return array('WECHAT_CONFIG' => array('WECHAT_TOKEN' => 'RRev06fPAoHGxbf3folYSSo7iRkW', 'WECHAT_APPID' => 'wxebeae596240e2741', 'WECHAT_APPSECRET' => '3c6f98d82721172c34a00027853659f6', 'WECHAT_ENCODING_AES_KEY' => '0z584GLdpHlqRRev06fPAoHGxbf3folYSSo7iRkWZhV', 'WECHAT_ACCESS_TOKEN_KEY' => 'wechat_access_token_key'), 'FILE_UPLOAD_TYPE' => 'Sae', 'UPLOAD_ROOT_PATH' => './public/', 'TMPL_PARSE_STRING' => array('__CSS__' => $st->getUrl('public', 'css'), '__JS__' => $st->getUrl('public', 'js'), '__ASSETS__' => $st->getUrl('public', 'assets'), '__IMAGE__' => $st->getUrl('public', 'image'), '__HOME__' => APP_URL . '/Home', '__UPLOAD__' => $st->getUrl('public', 'upload')));