本文整理汇总了PHP中FileUtil::fileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::fileExists方法的具体用法?PHP FileUtil::fileExists怎么用?PHP FileUtil::fileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::fileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: water
public static function water($source, $water, $saveName = null, $pos = 0, $alpha = 80, $quality = 100)
{
if (!FileUtil::fileExists($source) || !FileUtil::fileExists($water)) {
return false;
}
$sInfo = self::getImageInfo($source);
$wInfo = self::getImageInfo($water);
if ($sInfo["width"] < $wInfo["width"] || $sInfo["height"] < $wInfo["height"]) {
return false;
}
$sCreateFunction = "imagecreatefrom" . $sInfo["type"];
$sImage = $sCreateFunction($source);
$wCreateFunction = "imagecreatefrom" . $wInfo["type"];
$wImage = $wCreateFunction($water);
imagealphablending($wImage, true);
list($posX, $posY) = self::getPos($sInfo, $wInfo, $pos);
if ($wInfo["type"] == "png") {
imagecopy($sImage, $wImage, $posX, $posY, 0, 0, $wInfo["width"], $wInfo["height"]);
} else {
imagealphablending($wImage, true);
imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo["width"], $wInfo["height"], $alpha);
}
$imageFun = "image" . $sInfo["type"];
if (!$saveName) {
$saveName = $source;
@unlink($source);
}
if ($sInfo["mime"] == "image/jpeg") {
$imageFun($sImage, $saveName, $quality);
} else {
$imageFun($sImage, $saveName);
}
imagedestroy($sImage);
return true;
}
示例2: getThumbImageUrl
public static function getThumbImageUrl($attach, $width, $height)
{
$attachUrl = FileUtil::getAttachUrl();
$thumbName = self::getThumbName($attach, $width, $height);
$thumbUrl = FileUtil::fileName($thumbName);
if (FileUtil::fileExists($thumbUrl)) {
return $thumbName;
} else {
$attachment = $attach["attachment"];
$file = $attachUrl . "/" . $attachment;
$imgext = AttachUtil::getCommonImgExt();
if (FileUtil::fileExists($file)) {
$info = ImageUtil::getImageInfo(FileUtil::fileName($file));
$infoCorrect = is_array($info) && in_array($info["type"], $imgext);
$sizeCorrect = $infoCorrect && ($width < $info["width"] || $height < $info["height"]);
if ($infoCorrect && $sizeCorrect) {
$returnUrl = self::makeThumb($attach, $width, $height);
} else {
$returnUrl = $attachUrl . "/" . $attachment;
}
} else {
$returnUrl = FileUtil::fileName($file);
}
return $returnUrl;
}
}
示例3: checkAvatar
protected function checkAvatar($users)
{
$avatar = UserUtil::getAvatar($users["uid"]);
if (FileUtil::fileExists("data/avatar/" . $avatar)) {
return true;
} else {
return false;
}
}
示例4: generate
public function generate(Entity $entity)
{
$className = "{$entity->getName()}Service";
$destination = "src/impl/service/{$className}.php";
if (FileUtil::fileExists($destination)) {
return;
}
$content = "<?php\nclass {$className} extends {$className}Base {\n\n}\n?>";
FileUtil::storeFileContents($destination, $content);
}
示例5: moveTempFile
public static function moveTempFile($file, $path)
{
if (FileUtil::fileExists($file)) {
$copySucceed = FileUtil::copyToDir($file, $path);
if (!$copySucceed) {
throw new EnvException(Ibos::lang("Move file failed", "error", array("file" => $file, "path" => $path)));
}
return basename($file);
}
}
示例6: generate
public function generate($entities)
{
PrintUtil::log("Generating sql scripts... ");
$sql = "";
foreach ($entities as $entity) {
$sql .= $this->generateSql($entity) . "\n\n";
}
foreach (Singleton::create("ServiceBuilder")->getManyToManyMappingTables() as $table => $props) {
$sql .= $this->generateMappingTable($table, $props);
}
FileUtil::storeFileContents("src/sql/tables.sql", $sql);
$data = FileUtil::fileExists("src/sql/data.sql") ? FileUtil::getFileContents("src/sql/data.sql") : "";
FileUtil::storeFileContents("src/sql/all.sql", $sql . $data);
PrintUtil::logln("SQL scripts generated.");
}
示例7: deleteByIds
public function deleteByIds($ids)
{
$id = $files = array();
foreach ($ids as $removeId) {
$record = $this->fetchByPk($removeId);
if (!empty($record["image"])) {
$files[] = $record["image"];
}
$id[] = $record["id"];
}
$this->deleteByPk($id);
foreach ($files as $file) {
if (FileUtil::fileExists(self::BG_PATH . $file)) {
FileUtil::deleteFile(self::BG_PATH . $file);
}
}
}
示例8: actionIndex
public function actionIndex()
{
$formSubmit = EnvUtil::submitCheck("stampSubmit");
$stampPath = Stamp::STAMP_PATH;
if ($formSubmit) {
if (isset($_POST["stamps"])) {
foreach ($_POST["stamps"] as $id => $stamp) {
if (FileUtil::fileExists($stamp["stamp"])) {
Stamp::model()->delImg($id, "stamp");
$stamp["stamp"] = DashboardUtil::moveTempFile($stamp["stamp"], $stampPath);
}
if (FileUtil::fileExists($stamp["icon"])) {
Stamp::model()->delImg($id, "icon");
$stamp["icon"] = DashboardUtil::moveTempFile($stamp["icon"], $stampPath);
}
Stamp::model()->modify($id, $stamp);
}
}
if (isset($_POST["newstamps"])) {
foreach ($_POST["newstamps"] as $value) {
if (!empty($value["stamp"])) {
$value["stamp"] = DashboardUtil::moveTempFile($value["stamp"], $stampPath);
}
if (!empty($value["icon"])) {
$value["icon"] = DashboardUtil::moveTempFile($value["icon"], $stampPath);
}
Stamp::model()->add($value);
}
}
if (!empty($_POST["removeId"])) {
$removeIds = explode(",", trim($_POST["removeId"], ","));
Stamp::model()->deleteByIds($removeIds);
}
clearstatcache();
$this->success(Ibos::lang("Save succeed", "message"));
} else {
if (EnvUtil::getRequest("op") === "upload") {
$fakeUrl = $this->imgUpload("stamp");
$realUrl = FileUtil::fileName($fakeUrl);
return $this->ajaxReturn(array("fakeUrl" => $fakeUrl, "url" => $realUrl));
}
$data = array("stampUrl" => $stampPath, "list" => Stamp::model()->fetchAll(), "maxSort" => Stamp::model()->getMaxSort());
$this->render("index", $data);
}
}
示例9: actionIndex
public function actionIndex()
{
$formSubmit = EnvUtil::submitCheck("loginSubmit");
$bgPath = LoginTemplate::BG_PATH;
if ($formSubmit) {
if (isset($_POST["bgs"])) {
foreach ($_POST["bgs"] as $id => $bg) {
if (FileUtil::fileExists($bg["image"])) {
LoginTemplate::model()->delImg($id);
$bg["image"] = DashboardUtil::moveTempFile($bg["image"], $bgPath);
}
$bg["disabled"] = isset($bg["disabled"]) ? 0 : 1;
LoginTemplate::model()->modify($id, $bg);
}
}
if (isset($_POST["newbgs"])) {
foreach ($_POST["newbgs"] as $value) {
if (!empty($value["image"])) {
$value["image"] = DashboardUtil::moveTempFile($value["image"], $bgPath);
}
LoginTemplate::model()->add($value);
}
}
if (!empty($_POST["removeId"])) {
$removeIds = explode(",", trim($_POST["removeId"], ","));
LoginTemplate::model()->deleteByIds($removeIds, $bgPath);
}
clearstatcache();
$this->success(Ibos::lang("Save succeed", "message"));
} else {
if (EnvUtil::getRequest("op") === "upload") {
$fakeUrl = $this->imgUpload("bg");
$realUrl = FileUtil::fileName($fakeUrl);
return $this->ajaxReturn(array("fakeUrl" => $fakeUrl, "url" => $realUrl));
}
$data = array("list" => LoginTemplate::model()->fetchAll(), "bgpath" => $bgPath);
$this->render("index", $data);
}
}
示例10: open
public function open($imgname)
{
if (LOCAL && !FileUtil::fileExists($imgname)) {
throw new Exception("不存在的图像文件:" . $imgname);
}
$info = FileUtil::imageSize(FileUtil::fileName($imgname));
if (false === $info || IMAGETYPE_GIF === $info[2] && empty($info["bits"])) {
throw new Exception("非法图像文件");
}
$this->info = array("width" => $info[0], "height" => $info[1], "type" => image_type_to_extension($info[2], false), "mime" => $info["mime"]);
empty($this->img) || imagedestroy($this->img);
if ("gif" == $this->info["type"]) {
require_once "GIF.class.php";
$this->gif = new GIF($imgname);
$this->img = imagecreatefromstring($this->gif->image());
} else {
if (!LOCAL) {
$imgname = Ibos::engine()->IO()->file()->fetchTemp(FileUtil::fileName($imgname), $this->info["type"]);
}
$fun = "imagecreatefrom{$this->info["type"]}";
$this->img = $fun($imgname);
}
}
示例11: handleInitOrg
public function handleInitOrg($event)
{
if (!FileUtil::fileExists("data/org.js")) {
OrgUtil::update();
}
}
示例12: copyToDir
public static function copyToDir($file, $copyToPath)
{
if (FileUtil::fileExists($file)) {
$name = basename($file);
if (LOCAL) {
$state = @copy($file, $copyToPath . $name);
} else {
$state = Ibos::engine()->IO()->file()->moveFile($file, $copyToPath . $name);
}
return $state;
}
}
示例13: delAttach
public static function delAttach($aid)
{
$count = 0;
$aid = is_array($aid) ? implode(",", $aid) : trim($aid, ",");
$attachUrl = FileUtil::getAttachUrl() . "/";
$records = Attachment::model()->fetchAll(array("select" => array("aid", "tableid"), "condition" => "FIND_IN_SET(aid,'{$aid}')"));
foreach ($records as $value) {
$record = AttachmentN::model()->fetch($value["tableid"], $value["aid"]);
if (!empty($record)) {
if (FileUtil::fileExists($attachUrl . $record["attachment"])) {
FileUtil::deleteFile($attachUrl . $record["attachment"]);
$count++;
}
AttachmentN::model()->deleteByPk($value["tableid"], $value["aid"]);
}
}
if ($count) {
Attachment::model()->deleteAll("FIND_IN_SET(aid,'{$aid}')");
}
return $count;
}
示例14: checkTplIsExist
protected function checkTplIsExist($tpl)
{
$file = FileUtil::fileName($this->_tplPath . $tpl . $this->_suffix);
$ret = FileUtil::fileExists($file);
if (!$ret) {
$this->error(Ibos::lang("Template not fount", "", array("{file}" => $tpl . $this->_suffix)));
}
}
示例15: getTempByHex
protected function getTempByHex($hex)
{
$res = false;
$allTemp = array("#E47E61" => "red.png", "#F09816" => "orange.png", "#D29A63" => "yellow.png", "#7BBF00" => "green.png", "#3497DB" => "blue.png", "#82939E" => "gray.png", "#8EABCD" => "inky.png", "#AD85CC" => "purple.png", "#58585C" => "black.png");
if (in_array($hex, array_keys($allTemp))) {
$file = FileUtil::fileName($this->_iconTempPath . $allTemp[$hex]);
if (FileUtil::fileExists($file)) {
$res = $file;
}
}
return $res;
}