本文整理汇总了PHP中getSuffix函数的典型用法代码示例。如果您正苦于以下问题:PHP getSuffix函数的具体用法?PHP getSuffix怎么用?PHP getSuffix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSuffix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: accessMedia
function accessMedia($attr, $path, $data, $volume)
{
//allow only tinyMCE recognized media suffixes
$valid = array("mp3", "wav", "mp4", "webm", "ogg", "swf");
if (access($attr, $path, $data, $volume) || !is_dir($path) && !in_array(getSuffix($path), $valid)) {
return !($attr == 'read' || $attr == 'write');
}
return NULL;
}
示例2: getImageProcessorURIFromCacheName
function getImageProcessorURIFromCacheName($match, $watermarks)
{
$args = array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
$set = array();
$done = false;
$params = explode('_', stripSuffix($match));
while (!$done && count($params) > 1) {
$check = array_pop($params);
if (is_numeric($check) && !isset($set['w']) && !isset($set['h'])) {
$set['s'] = $check;
break;
} else {
$c = substr($check, 0, 1);
if ($c == 'w' || $c == 'h') {
if (is_numeric($v = substr($check, 1))) {
$set[$c] = (int) $v;
continue;
}
}
if ($c == 'c') {
$c = substr($check, 0, 2);
if (is_numeric($v = substr($check, 2))) {
$set[$c] = (int) $v;
continue;
}
}
if (!isset($set['w']) && !isset($set['h']) && !isset($set['s'])) {
if (!isset($set['wm']) && in_array($check, $watermarks)) {
$set['wmk'] = $check;
} else {
if ($check == 'thumb') {
$set['t'] = true;
} else {
$set['effects'] = $check;
}
}
} else {
array_push($params, $check);
break;
}
}
}
if (!isset($set['wmk'])) {
$set['wmk'] = '!';
}
$image = preg_replace('~.*/' . CACHEFOLDER . '/~', '', implode('_', $params)) . '.' . getSuffix($match);
// strip out the obfustication
$album = dirname($image);
$image = preg_replace('~^[0-9a-f]{' . CACHE_HASH_LENGTH . '}\\.~', '', basename($image));
$image = $album . '/' . $image;
return array($image, getImageArgs($set));
}
示例3: zp_imageGet
/**
* Takes an image filename and returns a GD Image using the correct function
* for the image's format (imagecreatefrom*). Supports JPEG, GIF, and PNG.
* @param string $imagefile the full path and filename of the image to load.
* @return image the loaded GD image object.
*
*/
function zp_imageGet($imgfile)
{
$ext = getSuffix($imgfile);
switch ($ext) {
case 'png':
return imagecreatefrompng($imgfile);
case 'wbmp':
return imagecreatefromwbmp($imgfile);
case 'jpeg':
case 'jpg':
return imagecreatefromjpeg($imgfile);
case 'gif':
return imagecreatefromgif($imgfile);
}
return false;
}
示例4: getPHPFiles
function getPHPFiles($folder, $exclude, &$files = array())
{
$dir = opendir($folder);
while (($file = readdir($dir)) !== false) {
$file = str_replace('\\', '/', $file);
if (strpos($file, '.') !== 0) {
if (is_dir($folder . '/' . $file) && !in_array($file, $exclude)) {
getPHPFiles($folder . '/' . $file, $exclude, $files);
} else {
if (getSuffix($file) == 'php') {
$entry = $folder . '/' . $file;
$files[] = $entry;
}
}
}
}
closedir($dir);
return $files;
}
示例5: getResidentFiles
/**
*
* enumerates the files in folder(s)
* @param $folder
*/
function getResidentFiles($folder)
{
global $_zp_resident_files;
$localfiles = array();
$localfolders = array();
if (file_exists($folder)) {
$dirs = scandir($folder);
foreach ($dirs as $file) {
if ($file[0] != '.') {
$file = str_replace('\\', '/', $file);
$key = $folder . '/' . $file;
if (is_dir($folder . '/' . $file)) {
$localfolders = array_merge($localfolders, getResidentFiles($folder . '/' . $file));
} else {
if (getSuffix($key) == 'php') {
$localfiles[] = $key;
}
}
}
}
}
return array_merge($localfiles, $localfolders);
}
示例6: printjPlayerPlaylist
/**
* Prints a playlist using jPlayer. Several playlists per page supported.
*
* The playlist is meant to replace the 'next_image()' loop on a theme's album.php.
* It can be used with a special 'album theme' that can be assigned to media albums with with .flv/.mp4/.mp3s, although Flowplayer 3 also supports images
* Replace the entire 'next_image()' loop on album.php with this:
* <?php printjPlayerPlaylist("playlist"); ?> or <?php printjPlayerPlaylist("playlist-audio"); ?>
*
* @param string $option "playlist" use for pure video and mixed video/audio playlists or if you want to show the poster/videothumb with audio only playlists,
* "playlist-audio" use for pure audio playlists (m4a,mp3,fla supported only) if you don't need the poster/videothumb to be shown only.
* @param string $albumfolder album name to get a playlist from directly
*/
function printjPlayerPlaylist($option = "playlist", $albumfolder = "")
{
global $_zp_current_album, $_zp_current_search;
if (empty($albumfolder)) {
if (in_context(ZP_SEARCH)) {
$albumobj = $_zp_current_search;
} else {
$albumobj = $_zp_current_album;
}
} else {
$albumobj = newAlbum($albumfolder);
}
$entries = $albumobj->getImages(0);
if (($numimages = count($entries)) != 0) {
switch ($option) {
case 'playlist':
$suffixes = array('m4a', 'm4v', 'mp3', 'mp4', 'flv', 'fla');
break;
case 'playlist-audio':
$suffixes = array('m4a', 'mp3', 'fla');
break;
default:
// an invalid option parameter!
return;
}
$id = $albumobj->getID();
?>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_<?php
echo $id;
?>
",
cssSelectorAncestor: "#jp_container_<?php
echo $id;
?>
"
}, [
<?php
$count = '';
$number = '';
foreach ($entries as $entry) {
$count++;
if (is_array($entry)) {
$ext = getSuffix($entry['filename']);
} else {
$ext = getSuffix($entry);
}
$numbering = '';
if (in_array($ext, $suffixes)) {
$number++;
if (getOption('jplayer_playlist_numbered')) {
$numbering = '<span>' . $number . '</span>';
}
$video = newImage($albumobj, $entry);
$videoThumb = '';
$this->setModeAndSuppliedFormat($ext);
if ($option == 'playlist' && getOption('jplayer_poster')) {
$videoThumb = ',poster:"' . $video->getCustomImage(null, $this->width, $this->height, $this->width, $this->height, null, null, true) . '"';
}
$playtime = '';
if (getOption('jplayer_playlist_playtime')) {
$playtime = ' (' . $video->get('VideoPlaytime') . ')';
}
?>
{
title:"<?php
echo $numbering . html_encode($video->getTitle()) . $playtime;
?>
",
<?php
if (getOption('jplayer_download')) {
?>
free:true,
<?php
}
?>
<?php
echo $this->supplied;
?>
:"<?php
echo html_encode(pathurlencode($url = $video->getFullImageURL(FULLWEBPATH)));
?>
"
<?php
echo $this->getCounterpartFiles($url, $ext);
//.........这里部分代码省略.........
示例7: header
$_zp_gallery_page = 'password.php';
$_zp_script = $_zp_themeroot . '/password.php';
if (!file_exists(internalToFilesystem($_zp_script))) {
$_zp_script = SERVERPATH . '/' . ZENFOLDER . '/password.php';
}
header('Content-Type: text/html; charset=' . LOCAL_CHARSET);
header("HTTP/1.0 302 Found");
header("Status: 302 Found");
header('Last-Modified: ' . ZP_LAST_MODIFIED);
include internalToFilesystem($_zp_script);
exposeZenPhotoInformations($_zp_script, array(), $theme);
exitZP();
}
}
$image_path = $imageobj->localpath;
$suffix = getSuffix($image_path);
switch ($suffix) {
case 'wbm':
case 'wbmp':
$suffix = 'wbmp';
break;
case 'jpg':
$suffix = 'jpeg';
break;
case 'png':
case 'gif':
case 'jpeg':
break;
default:
if ($disposal == 'Download') {
require_once dirname(__FILE__) . '/lib-MimeTypes.php';
示例8: isTextFile
function isTextFile($file)
{
global $ok_extensions;
$ext = strtolower(getSuffix($file));
return in_array($ext, $ok_extensions);
}
示例9: zp_apply_filter
$album->setOwner($_zp_current_admin_obj->getUser());
$album->save();
}
@chmod($targetPath, CHMOD_VALUE);
$error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile);
if (!$error) {
if (is_valid_image($name) || is_valid_other_type($name)) {
$seoname = seoFriendly($name);
if (strrpos($seoname, '.') === 0) {
$seoname = sha1($name) . $seoname;
}
// soe stripped out all the name.
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
if (file_exists($targetFile)) {
$append = '_' . time();
$seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
}
if (move_uploaded_file($tempFile, $targetFile)) {
@chmod($targetFile, 0666 & CHMOD_VALUE);
$album = new Album($gallery, $folder);
$image = newImage($album, $seoname);
$image->setOwner($_zp_current_admin_obj->getUser());
if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) {
$image->setTitle(substr($name, 0, strrpos($name, '.')));
}
$image->save();
} else {
$error = UPLOAD_ERR_NO_FILE;
}
} else {
示例10: is_zip
/**
* Checks for a zip file
*
* @param string $filename name of the file
* @return bool
*/
function is_zip($filename)
{
$ext = getSuffix($filename);
return $ext == "zip";
}
示例11: getSitemapImages
/**
* currently this splitts only sitemaps for albums and its images. Spliting the images itself requires a major rework...
*
* Gets links to all images for all albums (album by album)
*
* @return string
*/
function getSitemapImages()
{
global $_zp_gallery, $sitemap_number;
$data = '';
$sitemap_locales = generateLanguageList();
$imagechangefreq = getOption('sitemap_changefreq_images');
$imagelastmod = getOption('sitemap_lastmod_images');
$limit = sitemap_getDBLimit(1);
$albums = array();
getSitemapAlbumList($_zp_gallery, $albums, 'passImages');
$offset = $sitemap_number - 1;
$albums = array_slice($albums, $offset, SITEMAP_CHUNK);
if ($albums) {
$data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
if (GOOGLE_SITEMAP) {
$data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">');
} else {
$data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
}
foreach ($albums as $album) {
@set_time_limit(120);
// Extend script timeout to allow for gathering the images.
$albumobj = newAlbum($album['folder']);
$images = $albumobj->getImages();
// print plain images links if available
if ($images) {
foreach ($images as $image) {
$imageobj = newImage($albumobj, $image);
$ext = getSuffix($imageobj->filename);
$date = sitemap_getDateformat($imageobj, $imagelastmod);
switch (SITEMAP_LOCALE_TYPE) {
case 1:
foreach ($sitemap_locales as $locale) {
$path = seo_locale::localePath(true, $locale) . '/' . pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX;
$data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
if (GOOGLE_SITEMAP) {
$data .= getSitemapGoogleImageVideoExtras($albumobj, $imageobj, $locale);
}
$data .= sitemap_echonl("</url>");
}
break;
case 2:
foreach ($sitemap_locales as $locale) {
$path = rewrite_path(pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&image=' . urlencode($imageobj->filename), dynamic_locale::fullHostPath($locale));
$data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
if (GOOGLE_SITEMAP) {
$data .= getSitemapGoogleImageVideoExtras($albumobj, $imageobj, $locale);
}
$data .= sitemap_echonl("</url>");
}
break;
default:
$path = rewrite_path(pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&image=' . urlencode($imageobj->filename), FULLWEBPATH);
$data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
if (GOOGLE_SITEMAP) {
$data .= getSitemapGoogleImageVideoExtras($albumobj, $imageobj, NULL);
}
$data .= sitemap_echonl("</url>");
break;
}
}
}
}
$data .= sitemap_echonl('</urlset>');
// End off the <urlset> tag
}
return $data;
}
示例12: prefix
}
}
}
$sql = 'SELECT * FROM ' . prefix($table) . ' WHERE `' . $field . '` REGEXP "<img.*src\\s*=\\s*\\".*' . CACHEFOLDER . '((\\.|[^\\"])*)"';
$result = query($sql);
if ($result) {
while ($row = db_fetch_assoc($result)) {
preg_match_all('~\\<img.*src\\s*=\\s*"((\\.|[^"])*)~', $row[$field], $matches);
foreach ($matches[1] as $key => $match) {
$updated = false;
if (preg_match('~/' . CACHEFOLDER . '/~', $match)) {
$found++;
list($image, $args) = getImageProcessorURIFromCacheName($match, $watermarks);
$try = $_zp_supported_images;
$base = stripSuffix($image);
$prime = getSuffix($image);
array_unshift($try, $prime);
$try = array_unique($try);
$missing = true;
//see if we can match the cache name to an image in the album.
//Note that the cache suffix may not match the image suffix
foreach ($try as $suffix) {
if (file_exists(getAlbumFolder() . $base . '.' . $suffix)) {
$missing = false;
$image = $base . '.' . $suffix;
$uri = getImageURI($args, dirname($image), basename($image), NULL);
if (strpos($uri, 'i.php?') !== false) {
$fixed++;
$title = getTitle($table, $row);
?>
<a href="<?php
示例13: cacheImage
//.........这里部分代码省略.........
$watermark_image = getWatermarkPath($watermark_image);
if (!file_exists($watermark_image)) {
$watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
}
}
}
}
}
if ($watermark_image) {
$offset_h = getOption('watermark_h_offset') / 100;
$offset_w = getOption('watermark_w_offset') / 100;
$watermark = zp_imageGet($watermark_image);
$watermark_width = zp_imageWidth($watermark);
$watermark_height = zp_imageHeight($watermark);
$imw = zp_imageWidth($newim);
$imh = zp_imageHeight($newim);
$nw = sqrt($imw * $imh * $percent * ($watermark_width / $watermark_height));
$nh = $nw * ($watermark_height / $watermark_width);
$percent = getOption('watermark_scale') / 100;
$r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height));
if (!getOption('watermark_allow_upscale')) {
$r = min(1, $r);
}
$nw = round($watermark_width * $r);
$nh = round($watermark_height * $r);
if ($nw != $watermark_width || $nh != $watermark_height) {
$watermark = zp_imageResizeAlpha($watermark, $nw, $nh);
}
// Position Overlay in Bottom Right
$dest_x = max(0, floor(($imw - $nw) * $offset_w));
$dest_y = max(0, floor(($imh - $nh) * $offset_h));
if (DEBUG_IMAGE) {
debugLog("Watermark:" . basename($imgfile) . ": \$offset_h={$offset_h}, \$offset_w={$offset_w}, \$watermark_height={$watermark_height}, \$watermark_width={$watermark_width}, \$imw={$imw}, \$imh={$imh}, \$percent={$percent}, \$r={$r}, \$nw={$nw}, \$nh={$nh}, \$dest_x={$dest_x}, \$dest_y={$dest_y}");
}
zp_copyCanvas($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh);
zp_imageKill($watermark);
}
// Create the cached file (with lots of compatibility)...
mkdir_recursive(dirname($newfile));
if (zp_imageOutput($newim, getSuffix($newfile), $newfile, $quality)) {
// successful save of cached image
if (getOption('ImbedIPTC') && getSuffix($newfilename) == 'jpg') {
// the imbed function works only with JPEG images
$iptc_data = zp_imageIPTC($imgfile);
if (empty($iptc_data)) {
global $_zp_extra_filetypes;
// because we are doing the require in a function!
if (!$_zp_extra_filetypes) {
$_zp_extra_filetypes = array();
}
require_once dirname(__FILE__) . '/functions.php';
// it is ok to increase memory footprint now since the image processing is complete
$gallery = new Gallery();
$iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47), '2#115' => $gallery->getTitle());
$imgfile = str_replace(ALBUM_FOLDER_SERVERPATH, '', $imgfile);
$imagename = basename($imgfile);
$albumname = dirname($imgfile);
$image = newImage(new Album(new Gallery(), $albumname), $imagename);
$copyright = $image->getCopyright();
if (empty($copyright)) {
$copyright = getOption('default_copyright');
}
if (!empty($copyright)) {
$iptc['2#116'] = $copyright;
}
$credit = $image->getCredit();
if (!empty($credit)) {
$iptc['2#110'] = $credit;
}
foreach ($iptc as $tag => $string) {
$tag_parts = explode('#', $tag);
$iptc_data .= iptc_make_tag($tag_parts[0], $tag_parts[1], $string);
}
} else {
if (GRAPHICS_LIBRARY == 'Imagick' && IMAGICK_RETAIN_PROFILES) {
// Imageick has preserved the metadata
$iptc_data = false;
}
}
if ($iptc_data) {
$content = iptcembed($iptc_data, $newfile);
$fw = fopen($newfile, 'w');
fwrite($fw, $content);
fclose($fw);
clearstatcache();
}
}
if (DEBUG_IMAGE) {
debugLog('Finished:' . basename($imgfile));
}
} else {
if (DEBUG_IMAGE) {
debugLog('cacheImage: failed to create ' . $newfile);
}
}
@chmod($newfile, 0666 & CHMOD_VALUE);
zp_imageKill($newim);
zp_imageKill($im);
}
}
示例14: new_image
/**
* Filter for handling image objects
*
* @param object $image
* @return object
*/
static function new_image($image)
{
global $_zp_exifvars;
$source = '';
$metadata_path = '';
$files = safe_glob(substr($image->localpath, 0, strrpos($image->localpath, '.')) . '.*');
if (count($files) > 0) {
foreach ($files as $file) {
if (strtolower(getSuffix($file)) == XMP_EXTENSION) {
$metadata_path = $file;
break;
}
}
}
if (!empty($metadata_path)) {
$source = self::extractXMP(file_get_contents($metadata_path));
} else {
if (getOption('xmpMetadata_examine_images_' . strtolower(substr(strrchr($image->localpath, "."), 1)))) {
$f = file_get_contents($image->localpath);
$l = filesize($image->localpath);
$abort = 0;
$i = 0;
while ($i < $l && $abort < 200 && !$source) {
$tag = bin2hex(substr($f, $i, 2));
$size = hexdec(bin2hex(substr($f, $i + 2, 2)));
switch ($tag) {
case 'ffe1':
// EXIF
// EXIF
case 'ffe2':
// EXIF extension
// EXIF extension
case 'fffe':
// COM
// COM
case 'ffe0':
// IPTC marker
$source = self::extractXMP($f);
$i = $i + $size + 2;
$abort = 0;
break;
default:
if ($f[$i] == '<') {
$source = self::extractXMP($f);
}
$i = $i + 1;
$abort++;
break;
}
}
}
}
if (!empty($source)) {
$metadata = self::extract($source);
$image->set('hasMetadata', count($metadata > 0));
foreach ($metadata as $field => $element) {
if (array_key_exists($field, $_zp_exifvars)) {
if (!$_zp_exifvars[$field][5]) {
continue;
// the field has been disabled
}
}
$v = self::to_string($element);
switch ($field) {
case 'EXIFDateTimeOriginal':
$image->setDateTime($element);
break;
case 'IPTCImageCaption':
$image->setDesc($v);
break;
case 'IPTCCity':
$image->setCity($v);
break;
case 'IPTCState':
$image->setState($v);
break;
case 'IPTCLocationName':
$image->setCountry($v);
break;
case 'IPTCSubLocation':
$image->setLocation($v);
break;
case 'EXIFExposureTime':
$v = formatExposure(self::rationalNum($element));
break;
case 'EXIFFocalLength':
$v = self::rationalNum($element) . ' mm';
break;
case 'EXIFAperatureValue':
case 'EXIFFNumber':
$v = 'f/' . self::rationalNum($element);
break;
case 'EXIFExposureBiasValue':
case 'EXIFGPSAltitude':
//.........这里部分代码省略.........
示例15: getImageType
/**
* Returns the object "type" of the "image".
*
* Note:
* If the root object is a video object then
* If a mediaplayer is enabled a sub-type of video or audio will
* be determined from the suffix. If it is not one of the
* known suffixes or if the mediaplayer is not enabled then 'other' is
* returned as the object type.
*
* Pure images return empty for an object type.
*
* @return string
*/
function getImageType($imageobj)
{
$imageType = strtolower(get_class($imageobj));
switch ($imageType) {
case 'video':
$imagesuffix = getSuffix($imageobj->filename);
switch ($imagesuffix) {
case 'flv':
case 'mp4':
case 'm4v':
$imageType = 'video';
break;
case 'mp3':
case 'fla':
case 'm4a':
$imageType = 'audio';
break;
}
break;
case 'image':
$imageType = '';
break;
default:
$parent = strtolower(get_parent_class($imageobj));
if ($parent == 'textobject') {
$imageType = 'textobject';
}
break;
}
return $imageType;
}