本文整理汇总了PHP中StringUtil::getFileExt方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::getFileExt方法的具体用法?PHP StringUtil::getFileExt怎么用?PHP StringUtil::getFileExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::getFileExt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public final function __construct($attach, $module = "temp")
{
if (!is_array($attach) || empty($attach) || !$this->isUploadFile($attach["tmp_name"]) || trim($attach["name"]) == "" || $attach["size"] == 0) {
$this->_attach = array();
$this->_errorCode = -1;
return false;
} else {
$attach["type"] = $this->checkDirType($module);
$attach["size"] = intval($attach["size"]);
$attach["name"] = trim($attach["name"]);
$attach["thumb"] = "";
$attach["ext"] = StringUtil::getFileExt($attach["name"]);
$attach["name"] = StringUtil::ihtmlSpecialChars($attach["name"], ENT_QUOTES);
if (90 < strlen($attach["name"])) {
$attach["name"] = StringUtil::cutStr($attach["name"], 80, "") . "." . $attach["ext"];
}
$attach["isimage"] = $this->isImageExt($attach["ext"]);
$attach["attachdir"] = $this->getTargetDir($attach["type"]);
$attach["attachname"] = $this->getTargetFileName() . "." . $attach["ext"];
$attach["attachment"] = $attach["attachdir"] . $attach["attachname"];
$attach["target"] = FileUtil::getAttachUrl() . "/" . $attach["type"] . "/" . $attach["attachment"];
$this->_attach =& $attach;
$this->_errorCode = 0;
return true;
}
}
示例2: getDocFile
private function getDocFile($var)
{
if ($var["isNew"]) {
$typeId = AttachUtil::attachType($var["param"]["filetype"], "id");
$map = array(self::DOC_WORD => array("fileName" => $var["lang"]["New doc"] . ".doc", "fileUrl" => self::OFFICE_PATH . "new.doc", "typeId" => self::DOC_WORD), self::DOC_EXCEL => array("fileName" => $var["lang"]["New excel"] . ".xls", "fileUrl" => self::OFFICE_PATH . "new.doc", "typeId" => self::DOC_WORD), self::DOC_PPT => array("fileName" => $var["lang"]["New ppt"] . ".ppt", "fileUrl" => self::OFFICE_PATH . "new.ppt", "typeId" => self::DOC_WORD));
return $map[$typeId];
} else {
return array("typeId" => AttachUtil::attachType(StringUtil::getFileExt($var["attach"]["attachment"]), "id"), "fileName" => $var["attach"]["filename"], "fileUrl" => FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $var["attach"]["attachment"]));
}
}
示例3: makeThumb
public static function makeThumb($attach, $width, $height)
{
$attachUrl = FileUtil::getAttachUrl();
$file = sprintf("%s/%s", $attachUrl, $attach["attachment"]);
$fileext = StringUtil::getFileExt($file);
$thumbName = self::getThumbName($attach, $width, $height);
if (LOCAL) {
$res = ImageUtil::thumb2($file, $thumbName, "", $width, $height);
} else {
$tempFile = FileUtil::getTempPath() . "tmp." . $fileext;
$orgImgname = Ibos::engine()->IO()->file()->fetchTemp(FileUtil::fileName($file), $fileext);
ImageUtil::thumb2($orgImgname, $tempFile, "", $width, $height);
FileUtil::createFile($thumbName, file_get_contents($tempFile));
}
return $thumbName;
}
示例4: download
public function download($attach, $downloadInfo = array())
{
$file = FileUtil::getAttachUrl() . "/" . $attach["attachment"];
if (file_exists($file)) {
if (Ibos::app()->browser->name == "msie" || Ibos::app()->browser->getVersion() == "10.0" || Ibos::app()->browser->getVersion() == "11.0") {
$usingIe = true;
} else {
$usingIe = false;
}
$typeArr = array("1" => "application/octet-stream", "3" => "application/msword", "4" => "application/msexcel", "5" => "application/mspowerpoint", "7" => "application/octet-stream", "8" => "application/x-shockwave-flash", "10" => "application/pdf");
$attachType = AttachUtil::Attachtype(StringUtil::getFileExt($attach["filename"]), "id");
$content = false;
if (isset($downloadInfo["directView"])) {
if (!in_array($attachType, array("1", "7", "8", "10"))) {
$content = true;
}
$contentType = $typeArr[$attachType];
} else {
if (in_array($attachType, array("3", "4", "5")) && $usingIe) {
$contentType = $typeArr[$attachType];
} else {
$content = 1;
$contentType = "application/octet-stream";
}
}
ob_end_clean();
header("Cache-control: private");
header("Content-type: {$contentType}");
header("Accept-Ranges: bytes");
header("Content-Length: " . sprintf("%u", $this->fileSize($file)));
if ($usingIe) {
$attach["filename"] = urlencode($attach["filename"]);
}
if ($content) {
header("Content-Disposition: attachment; filename=\"" . $attach["filename"] . "\"");
} else {
header("Content-Disposition: filename=\"" . $attach["filename"] . "\"");
}
Attachment::model()->updateDownload($attach["aid"]);
readfile($file);
exit;
}
}
示例5: upload
public function upload()
{
$uid = intval(EnvUtil::getRequest("uid"));
$this->upload->save();
$attach = $this->upload->getAttach();
$attachment = $attach["type"] . "/" . $attach["attachment"];
$data = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "attachment" => $attachment, "isimage" => $attach["isimage"], "uid" => $uid);
$aid = Attachment::model()->add(array("uid" => $uid, "tableid" => 127), true);
$data["aid"] = $aid;
AttachmentUnused::model()->add($data);
$file["icon"] = AttachUtil::attachType(StringUtil::getFileExt($attach["name"]));
$file["aid"] = $aid;
$file["name"] = $attach["name"];
$file["url"] = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $attachment);
if (!empty($file) && is_array($file)) {
return CJSON::encode($file);
} else {
return CJSON::encode(array("aid" => 0, "url" => 0, "name" => 0));
}
}
示例6: actionImport
public function actionImport()
{
$id = EnvUtil::getRequest("formid");
$catId = EnvUtil::getRequest("catid");
if (EnvUtil::submitCheck("formhash")) {
$fileName = $_FILES["import"]["name"];
$fileExt = StringUtil::getFileExt($fileName);
if (!in_array($fileExt, array("txt", "htm", "html"))) {
echo "<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Form import desc") . "');</script>";
} else {
$upload = FileUtil::getUpload($_FILES["import"]);
$upload->save();
$files = $upload->getAttach();
$file = $files["target"];
$inajax = 0;
if (empty($id)) {
$name = strstr($files["name"], ".", true);
$inajax = 1;
$id = FlowFormType::model()->quickAdd($name, $catId);
}
WfFormUtil::import($id, $file);
$nextOpt = $_POST["nextopt"];
$exec = "";
if ($nextOpt == "edit") {
$param = sprintf("{'formid':'%d','inajax':%d}", $id, $inajax);
$exec = "parent.Wfs.formItem.edit({$param});";
} elseif ($nextOpt == "design") {
$param = sprintf("{'formid':'%d'}", $id);
$exec = "parent.Wfs.formItem.design({$param});";
}
$this->ajaxReturn("<script type='text/javascript'>parent.Ui.tip('" . Ibos::lang("Import success") . "', 'success');{$exec}parent.Ui.getDialog('d_import_form').close();</script>", "eval");
}
}
$lang = Ibos::getLangSources();
$this->renderPartial("import", array("lang" => $lang, "id" => $id, "catid" => $catId));
}
示例7: imageSize
public function imageSize($image)
{
if (!is_readable($image)) {
$sufffix = StringUtil::getFileExt($image);
$image = $this->fetchTemp($image, $sufffix);
}
return getimagesize($image);
}
示例8: getBody
public static function getBody($id, &$conn, &$obj, $header)
{
$structure_str = $obj->fetchStructureString($conn, "INBOX", $id);
$structure = EmailMimeUtil::getRawStructureArray($structure_str);
$num_parts = EmailMimeUtil::getNumParts($structure);
$parent_type = EmailMimeUtil::getPartTypeCode($structure);
if ($parent_type == 1 && $num_parts == 1) {
$part = 1;
$num_parts = EmailMimeUtil::getNumParts($structure, $part);
$parent_type = EmailMimeUtil::getPartTypeCode($structure, $part);
} else {
$part = null;
}
$body = array();
$attach = "";
if (0 < $num_parts) {
$attach .= "<table width=100%>\n";
for ($i = 1; $i <= $num_parts; $i++) {
if ($parent_type == 1) {
$code = $part . (empty($part) ? "" : ".") . $i;
} elseif ($parent_type == 2) {
$code = $part . (empty($part) ? "" : ".") . $i;
}
$type = EmailMimeUtil::getPartTypeCode($structure, $code);
$name = EmailMimeUtil::getPartName($structure, $code);
if (is_string($name) && !empty($name)) {
$name = htmlspecialchars(EmailLangUtil::langDecodeSubject($name, CHARSET));
$fileExt = StringUtil::getFileExt($name);
$fileType = AttachUtil::attachType($fileExt);
} else {
$fileType = AttachUtil::attachType(1);
}
$typestring = EmailMimeUtil::getPartTypeString($structure, $code);
list($dummy, $subtype) = explode("/", $typestring);
$bytes = EmailMimeUtil::getPartSize($structure, $code);
$disposition = EmailMimeUtil::getPartDisposition($structure, $code);
if ($type == 1 || $type == 2 || $type == 3 && strcasecmp($subtype, "ms-tnef") == 0) {
continue;
} else {
$href = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => "INBOX", "id" => $id, "part" => $code));
}
$attach .= "<tr><td align=\"center\"><img src=\"{$fileType}\" border=0></td>";
$attach .= "<td><a href=\"" . $href . "\" " . ($type == 1 || $type == 2 || $type == 3 && strcasecmp($subtype, "ms-tnef") == 0 ? "" : "target=_blank") . ">";
$attach .= "<span class=\"small\">" . $name . "</span></a>";
if (0 < $bytes) {
$attach .= "<td>[" . ConvertUtil::sizeCount($bytes) . "]</td>\n";
}
if (is_string($typestring)) {
$attach .= "<td>" . htmlspecialchars($typestring) . "</td>\n";
}
$attach .= "\n</tr>\n";
}
$attach .= "</table>\n";
}
$typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
list($dummy, $subType) = explode("/", EmailMimeUtil::getPartTypeString($structure, $part));
if ($typeCode == 3 && strcasecmp($subType, "ms-tnef") == 0) {
$type = $dummy;
} elseif ($typeCode == 0) {
$typeString = EmailMimeUtil::getPartTypeString($structure, $part);
if (empty($part) && !empty($header->ctype) && strcmp($typeString, $header->ctype) != 0) {
$typeString = $header->ctype;
}
list($type, $subType) = explode("/", $typeString);
$body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
} else {
if ($typeCode == 1 && empty($part) && $structure[0][0] == "message") {
$part = "1.1";
$typeString = EmailMimeUtil::getPartTypeString($structure, $part);
list($type, $subType) = explode("/", $typeString);
$typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
$disposition = EmailMimeUtil::getPartDisposition($structure, $part);
$body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
} else {
if ($typeCode == 1 || $typeCode == 2) {
$typeString = EmailMimeUtil::getPartTypeString($structure, $part);
list($type, $subType) = explode("/", $typeString);
$mode = 0;
$subtypes = array("mixed" => 1, "signed" => 1, "related" => 1, "array" => 2, "alternative" => 2);
$subType = strtolower($subType);
if (0 < $subtypes[$subType]) {
$mode = $subtypes[$subType];
} elseif (strcasecmp($subType, "rfc822") == 0) {
$temp_num = EmailMimeUtil::getNumParts($structure, $part);
if (0 < $temp_num) {
$mode = 2;
}
} elseif (strcasecmp($subType, "encrypted") == 0) {
$encrypted_type = EmailMimeUtil::getPartTypeString($structure, $part . ".1");
if (stristr($encrypted_type, "pgp-encrypted") !== false) {
$mode = -1;
}
}
if ($mode == -1) {
$part = $part . (empty($part) ? "" : ".") . "2";
$typeString = EmailMimeUtil::getPartTypeString($structure, $part);
list($type, $subType) = explode("/", $typeString);
$typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
$disposition = EmailMimeUtil::getPartDisposition($structure, $part);
$body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
//.........这里部分代码省略.........
示例9: actionFeed
public function actionFeed()
{
$feedid = intval(EnvUtil::getRequest("feedid"));
$feedInfo = Feed::model()->get($feedid);
if (!$feedInfo) {
$this->error(Ibos::lang("Weibo not exists"));
}
if ($feedInfo["isdel"] == "1") {
$this->error(Ibos::lang("No relate weibo"));
exit;
}
if ($feedInfo["from"] == "1") {
$feedInfo["from"] = EnvUtil::getFromClient(6, $feedInfo["module"], "3G版");
} else {
switch ($feedInfo["module"]) {
case "mobile":
break;
default:
$feedInfo["from"] = EnvUtil::getFromClient($feedInfo["from"], $feedInfo["module"]);
break;
}
}
if ($feedInfo["type"] === "postimage") {
$var = unserialize($feedInfo["feeddata"]);
$feedInfo["image_body"] = $var["body"];
if (!empty($var["attach_id"])) {
$attach = AttachUtil::getAttachData($var["attach_id"]);
$attachUrl = FileUtil::getAttachUrl();
foreach ($attach as $ak => $av) {
$_attach = array("attach_id" => $av["aid"], "attach_name" => $av["filename"], "attach_url" => FileUtil::fileName($attachUrl . "/" . $av["attachment"]), "extension" => StringUtil::getFileExt($av["filename"]), "size" => $av["filesize"]);
$_attach["attach_small"] = WbCommonUtil::getThumbImageUrl($av, WbConst::ALBUM_DISPLAY_WIDTH, WbConst::ALBUM_DISPLAY_HEIGHT);
$_attach["attach_middle"] = WbCommonUtil::getThumbImageUrl($av, WbConst::WEIBO_DISPLAY_WIDTH, WbConst::WEIBO_DISPLAY_HEIGHT);
$feedInfo["attachInfo"][$ak] = $_attach;
}
}
}
$diggArr = FeedDigg::model()->checkIsDigg($feedid, Ibos::app()->user->uid);
$data = array("diggArr" => $diggArr, "fd" => $feedInfo, "assetUrl" => Ibos::app()->assetManager->getAssetsUrl("user"), "moduleAssetUrl" => Ibos::app()->assetManager->getAssetsUrl("weibo"), "colleagues" => $this->getRelation("colleague"));
if (!$this->getIsMe()) {
$data["bothfollow"] = $this->getRelation("bothfollow");
$data["secondfollow"] = $this->getRelation("secondfollow");
}
$this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Enterprise weibo"), "url" => $this->createUrl("home/index")), array("name" => $feedInfo["user_info"]["realname"] . Ibos::lang("sbs feed"), "url" => $this->createUrl("personal/index", array("uid" => $this->getUid()))), array("name" => Ibos::lang("Detail"))));
$this->render("detail", $data, false, array("user.default"));
}
示例10: getAttach
public static function getAttach($aid, $down = true, $officeDown = true, $edit = false, $delete = false, $getRealAddress = false)
{
$attach = array();
if (!empty($aid)) {
$data = self::getAttachData($aid);
}
$urlManager = Ibos::app()->urlManager;
foreach ($data as $id => &$val) {
$val["date"] = ConvertUtil::formatDate($val["dateline"], "u");
$val["filetype"] = StringUtil::getFileExt($val["filename"]);
$val["filesize"] = ConvertUtil::sizeCount($val["filesize"]);
if ($getRealAddress) {
$val["attachment"] = FileUtil::getAttachUrl() . "/" . $val["attachment"];
}
$val["filename"] = trim($val["filename"]);
$val["delete"] = $delete;
$val["down"] = $down;
$val["down_office"] = $officeDown;
$val["edit"] = $edit;
$val["iconsmall"] = self::attachType($val["filetype"], "smallicon");
$val["iconbig"] = self::attachType($val["filetype"], "bigicon");
$idString = self::getAttachStr($id, $val["tableid"]);
$val["openurl"] = $urlManager->createUrl("main/attach/open", array("id" => $idString));
if ($val["down"]) {
$val["downurl"] = $urlManager->createUrl("main/attach/download", array("id" => $idString));
}
$inOfficeRange = in_array(self::attachType($val["filetype"], "id"), range(3, 5));
if ($inOfficeRange && $val["down_office"]) {
$val["officereadurl"] = "http://view.officeapps.live.com/op/view.aspx?src=" . urlencode(Ibos::app()->setting->get("siteurl") . FileUtil::getAttachUrl() . "/" . $val["attachment"]);
}
if ($inOfficeRange && $val["edit"]) {
$val["officeediturl"] = $urlManager->createUrl("main/attach/office", array("id" => self::getAttachStr($aid, $val["tableid"], array("filetype" => $val["filetype"], "op" => "edit"))));
}
}
return $data;
}
示例11: parseMarcroAttach
protected function parseMarcroAttach($runID, $attachmentID, $showImg = true)
{
$attachDir = Ibos::app()->setting->get("setting/attachdir");
$attach = AttachmentN::model()->fetch("rid:" . $runID, $attachmentID);
if ($attach["isimage"] && $showImg) {
$imgAttr = FileUtil::imageSize($attachDir . $attach["attachment"]);
$attachLink = "<img src=\"{$attachDir}" . $attach["attachment"] . "\" {$imgAttr['3']} alt=\"{$attach["filename"]}\">";
return $attachLink;
}
if ($this->flow->isFixed() && (StringUtil::findIn($this->process->attachpriv, "4") || !$this->process->attachpriv)) {
$down = 1;
} else {
$down = 0;
}
if ($down) {
$attachstr = AttachUtil::getAttachStr($attachmentID);
$url = Ibos::app()->urlManager->createUrl("main/attach/download", array("id" => $attachstr));
$link = "<a target=\"_blank\" class=\"xi2\" href=\"{$url}\">{$attach["filename"]}</a>";
} else {
$link = "<a class=\"xi2\" href=\"#\">{$attach["filename"]}</a>";
}
$type = StringUtil::getFileExt($attach["attach"]);
$path = AttachUtil::attachType($type);
$attachLink = "<span><img src=\"{$path}\">{$link}</span>";
return $attachLink;
}
示例12: parseTemplate
private function parseTemplate($_data)
{
$user = User::model()->fetchByUid($_data["uid"]);
$_data["data"] = unserialize($_data["feeddata"]);
$var = $_data["data"];
if (!empty($var["attach_id"])) {
$var["attachInfo"] = AttachUtil::getAttach($var["attach_id"]);
$attachUrl = FileUtil::getAttachUrl();
foreach ($var["attachInfo"] as $ak => $av) {
$_attach = array("attach_id" => $av["aid"], "attach_name" => $av["filename"], "attach_url" => FileUtil::fileName($attachUrl . "/" . $av["attachment"]), "extension" => StringUtil::getFileExt($av["filename"]), "size" => $av["filesize"]);
if ($_data["type"] == "postimage") {
$_attach["attach_small"] = WbCommonUtil::getThumbImageUrl($av, WbConst::ALBUM_DISPLAY_WIDTH, WbConst::ALBUM_DISPLAY_HEIGHT);
$_attach["attach_middle"] = WbCommonUtil::getThumbImageUrl($av, WbConst::WEIBO_DISPLAY_WIDTH, WbConst::WEIBO_DISPLAY_HEIGHT);
}
$var["attachInfo"][$ak] = $_attach;
}
}
$var["uid"] = $_data["uid"];
$var["actor"] = "<a href='{$user["space_url"]}' data-toggle='usercard' data-param=\"uid={$user["uid"]}\">{$user["realname"]}</a>";
$var["actor_uid"] = $user["uid"];
$var["actor_uname"] = $user["realname"];
$var["feedid"] = $_data["feedid"];
if (!empty($_data["rowid"])) {
empty($_data["table"]) && ($_data["table"] = "feed");
$var["sourceInfo"] = Source::getSourceInfo($_data["table"], $_data["rowid"], false, $_data["module"]);
} else {
$var["sourceInfo"] = null;
}
$feedTemplateAlias = "application.modules.message.config.feed.{$_data["type"]}Feed";
$file = Ibos::getPathOfAlias($feedTemplateAlias);
if (!file_exists($file . ".php")) {
$feedTemplateAlias = "application.modules.message.config.feed.postFeed";
}
$feedXmlContent = Ibos::app()->getController()->renderPartial($feedTemplateAlias, $var, true);
$s = simplexml_load_string($feedXmlContent);
if (!$s) {
return false;
}
$result = $s->xpath("//feed[@type='" . StringUtil::filterCleanHtml($_data["type"]) . "']");
$actions = (array) $result[0]->feedAttr;
$return["content"] = $var["content"];
if (isset($var["attach_id"])) {
$return["attach_id"] = $var["attach_id"];
}
$return["userInfo"] = $user;
$return["title"] = trim((string) $result[0]->title);
$return["body"] = trim((string) $result[0]->body);
$return["info"] = trim((string) $result[0]["info"]);
$return["body"] = StringUtil::parseHtml($return["body"]);
$return["api_source"] = $var["sourceInfo"];
$return["actions"] = $actions["@attributes"];
if (!$this->notDel($_data["module"], $_data["type"], $_data["rowid"])) {
$return["body"] = Ibos::lang("Info already delete", "message.default");
}
return $return;
}