本文整理汇总了PHP中SaeStorage::fileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP SaeStorage::fileExists方法的具体用法?PHP SaeStorage::fileExists怎么用?PHP SaeStorage::fileExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaeStorage
的用法示例。
在下文中一共展示了SaeStorage::fileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaeStorageExist
function SaeStorageExist($FilePath)
{
$storage = new SaeStorage();
$domain = Sae_Storage_Domain_Name;
$result = $storage->fileExists($domain, $FilePath);
return $result;
}
示例2: SaeStorage
function s_file_exists($filepath)
{
$_s = new SaeStorage();
//初始化Storage对象
$_f = _s_get_path($filepath);
return $_s->fileExists($_f['domain'], $_f['filename']);
}
示例3: printTestCases
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;
}
}
示例4: readModule
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!";
}
}
示例5: photo_list
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();
}
示例6: SaeStorage
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);
}
}
示例7: save
/**
* 保存指定文件
* @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;
}
示例8: Delete
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'];
}
}
示例9: save
}
/**
* 保存指定文件
* @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();
示例10: file
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);
}
}
示例11: SerialMatch_detail
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 = "待出线";
//.........这里部分代码省略.........
示例12: serialMatch_release_presubmit
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;
}
}
}
}
//.........这里部分代码省略.........
示例13: SaeStorage
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
示例14: opendir
$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 />
示例15: getThumbImage
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 {
//.........这里部分代码省略.........