本文整理汇总了PHP中utf8_basename函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_basename函数的具体用法?PHP utf8_basename怎么用?PHP utf8_basename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_basename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createLink
public static function createLink($params)
{
$structure = array();
$structure['url'] = $params[0];
$structure['width'] = $params[1];
$structure['height'] = $params[2];
$structure['icon'] = str_replace('eyeos/extern/', 'index.php?extern=', $params[5]);
$structure['openInNewWindow'] = $params[6];
$structure['type'] = 'web';
$linkName = utf8_basename($params[3]);
$info = pathinfo($linkName);
if (!isset($info['extension']) || $info['extension'] != 'lnk') {
$linkName .= '.lnk';
}
$path = $params[4];
$text = json_encode($structure);
$linkName = str_replace('?', '_', $linkName);
$linkName = str_replace('#', '_', $linkName);
$newFile = FSI::getFile($path . '/' . $linkName);
$newFile->createNewFile();
$newFile->putContents($text);
$currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
$settings = MetaManager::getInstance()->retrieveMeta($currentUser);
//TODO: better message?
$message = new ClientBusMessage('file', 'uploadComplete', self::getFileInfo($newFile, $settings));
ClientMessageBusController::getInstance()->queueMessage($message);
}
示例2: getID
/**
* Fetch the an ID from request
*
* Uses either standard $_REQUEST variable or extracts it from
* the full request URI when userewrite is set to 2
*
* For $param='id' $conf['start'] is returned if no id was found.
* If the second parameter is true (default) the ID is cleaned.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getID($param = 'id', $clean = true)
{
global $INPUT;
global $conf;
$id = $INPUT->str($param);
//construct page id from request URI
if (empty($id) && $conf['userewrite'] == 2) {
$request = $_SERVER['REQUEST_URI'];
$script = '';
//get the script URL
if ($conf['basedir']) {
$relpath = '';
if ($param != 'id') {
$relpath = 'lib/exe/';
}
$script = $conf['basedir'] . $relpath . utf8_basename($_SERVER['SCRIPT_FILENAME']);
} elseif ($_SERVER['PATH_INFO']) {
$request = $_SERVER['PATH_INFO'];
} elseif ($_SERVER['SCRIPT_NAME']) {
$script = $_SERVER['SCRIPT_NAME'];
} elseif ($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']) {
$script = preg_replace('/^' . preg_quote($_SERVER['DOCUMENT_ROOT'], '/') . '/', '', $_SERVER['SCRIPT_FILENAME']);
$script = '/' . $script;
}
//clean script and request (fixes a windows problem)
$script = preg_replace('/\\/\\/+/', '/', $script);
$request = preg_replace('/\\/\\/+/', '/', $request);
//remove script URL and Querystring to gain the id
if (preg_match('/^' . preg_quote($script, '/') . '(.*)/', $request, $match)) {
$id = preg_replace('/\\?.*/', '', $match[1]);
}
$id = urldecode($id);
//strip leading slashes
$id = preg_replace('!^/+!', '', $id);
}
// Namespace autolinking from URL
if (substr($id, -1) == ':' || $conf['useslash'] && substr($id, -1) == '/') {
if (page_exists($id . $conf['start'])) {
// start page inside namespace
$id = $id . $conf['start'];
} elseif (page_exists($id . noNS(cleanID($id)))) {
// page named like the NS inside the NS
$id = $id . noNS(cleanID($id));
} elseif (page_exists($id)) {
// page like namespace exists
$id = substr($id, 0, -1);
} else {
// fall back to default
$id = $id . $conf['start'];
}
send_redirect(wl($id, '', true));
}
if ($clean) {
$id = cleanID($id);
}
if (empty($id) && $param == 'id') {
$id = $conf['start'];
}
return $id;
}
示例3: test1
function test1()
{
$data = array(array('/this/foo/bar.test.png', '', 'bar.test.png'), array('\\this\\foo\\bar.test.png', '', 'bar.test.png'), array('/this\\foo/bar.test.png', '', 'bar.test.png'), array('/this/foo\\bar.test.png', '', 'bar.test.png'), array('/this/ДокуВики/bar.test.png', '', 'bar.test.png'), array('\\this\\ДокуВики\\bar.test.png', '', 'bar.test.png'), array('/this\\ДокуВики/bar.test.png', '', 'bar.test.png'), array('/this/ДокуВики\\bar.test.png', '', 'bar.test.png'), array('/this/foo/ДокуВики.test.png', '', 'ДокуВики.test.png'), array('\\this\\foo\\ДокуВики.test.png', '', 'ДокуВики.test.png'), array('/this\\foo/ДокуВики.test.png', '', 'ДокуВики.test.png'), array('/this/foo\\ДокуВики.test.png', '', 'ДокуВики.test.png'), array('/this/foo/bar.test.png', '.png', 'bar.test'), array('\\this\\foo\\bar.test.png', '.png', 'bar.test'), array('/this\\foo/bar.test.png', '.png', 'bar.test'), array('/this/foo\\bar.test.png', '.png', 'bar.test'), array('/this/ДокуВики/bar.test.png', '.png', 'bar.test'), array('\\this\\ДокуВики\\bar.test.png', '.png', 'bar.test'), array('/this\\ДокуВики/bar.test.png', '.png', 'bar.test'), array('/this/ДокуВики\\bar.test.png', '.png', 'bar.test'), array('/this/foo/ДокуВики.test.png', '.png', 'ДокуВики.test'), array('\\this\\foo\\ДокуВики.test.png', '.png', 'ДокуВики.test'), array('/this\\foo/ДокуВики.test.png', '.png', 'ДокуВики.test'), array('/this/foo\\ДокуВики.test.png', '.png', 'ДокуВики.test'), array('/this/foo/bar.test.png', '.foo', 'bar.test.png'), array('\\this\\foo\\bar.test.png', '.foo', 'bar.test.png'), array('/this\\foo/bar.test.png', '.foo', 'bar.test.png'), array('/this/foo\\bar.test.png', '.foo', 'bar.test.png'), array('/this/ДокуВики/bar.test.png', '.foo', 'bar.test.png'), array('\\this\\ДокуВики\\bar.test.png', '.foo', 'bar.test.png'), array('/this\\ДокуВики/bar.test.png', '.foo', 'bar.test.png'), array('/this/ДокуВики\\bar.test.png', '.foo', 'bar.test.png'), array('/this/foo/ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), array('\\this\\foo\\ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), array('/this\\foo/ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), array('/this/foo\\ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), array('/this/foo/ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), array('\\this\\foo\\ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), array('/this\\foo/ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), array('/this/foo\\ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), array('/this/foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('\\this\\foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('/this\\foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('/this/foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('bar.test.png', '', 'bar.test.png'), array('bar.test.png', '.png', 'bar.test'), array('/bar.test.png', '', 'bar.test.png'), array('/bar.test.png', '.png', 'bar.test'), array('\\bar.test.png', '', 'bar.test.png'), array('\\bar.test.png', '.png', 'bar.test'), array('\\/bar.test.png', '', 'bar.test.png'), array('\\/bar.test.png', '.png', 'bar.test'), array('/\\bar.test.png', '', 'bar.test.png'), array('/\\bar.test.png', '.png', 'bar.test'), array('foo/', '', 'foo'), array('foo\\', '', 'foo'), array('foo\\/', '', 'foo'), array('foo/\\', '', 'foo'), array('foo.png/', '.png', 'foo'), array('foo.png\\', '.png', 'foo'), array('foo.png\\/', '.png', 'foo'), array('foo.png/\\', '.png', 'foo'));
foreach ($data as $test) {
$this->assertEquals($test[2], utf8_basename($test[0], $test[1]), "input: ('" . $test[0] . "', '" . $test[1] . "')");
}
}
示例4: attachFile
/**
* Attach a file
*
* @param string $path Path to the file to attach
* @param string $mime Mimetype of the attached file
* @param string $name The filename to use
* @param string $embed Unique key to reference this file from the HTML part
*/
public function attachFile($path, $mime, $name = '', $embed = '')
{
if (!$name) {
$name = utf8_basename($path);
}
$this->attach[] = array('data' => file_get_contents($path), 'mime' => $mime, 'name' => $name, 'embed' => $embed);
}
示例5: loadModule
private static function loadModule($moduleName)
{
$path = FRAMEWORK_APPLICATION_EXECUTABLES_EYEOSMODULES_PATH . '/' . utf8_basename($moduleName) . '.php';
if (!is_file($path) || !is_readable($path)) {
throw new EyeFileNotFoundException('File not found or not readable for module "' . $moduleName . '".');
}
require $path;
}
示例6: userCreated
public function userCreated(UMEvent $e)
{
if ($e->getSource() instanceof AbstractEyeosUser) {
$userDirPath = UMManager::getEyeosUserDirectory($e->getSource()->getName());
$skel = utf8_basename($e->getSkel());
AdvancedPathLib::cpdirs(SYSTEM_SKEL_PATH . '/' . USERS_DIR . '/profiles/' . $skel . '/skel_files/', $userDirPath, false);
ProfileManager::executeProfile(new Profile($skel), $e->getSource());
}
}
示例7: __construct
/**
* @param string $zip Full path to the zip package
* @param string $new_dir_name name of the directory you want to use in the zip package (leave blank if the initial steps have been run already)
*/
public function __construct($original_zip, $new_dir_name = '')
{
$this->original_zip = $original_zip;
if ($new_dir_name) {
$this->new_dir_name = utf8_basename($new_dir_name);
$this->unzip_dir = titania::$config->contrib_temp_path . $this->new_dir_name . '/';
// Unzippage
$this->extract($this->original_zip, $this->unzip_dir);
}
}
示例8: executeProfile
public static function executeProfile(Profile $profile, AbstractEyeosUser $user)
{
$path = SYSTEM_SKEL_PATH . '/' . USERS_DIR . '/profiles/' . utf8_basename($profile->getName()) . '/scripts/';
$directory = new DirectoryIterator($path);
foreach ($directory as $fileInfo) {
$fileInfoName = $fileInfo->getFileName();
if (!$fileInfo->isDot() && $fileInfoName != '.svn') {
require_once $path . $fileInfoName;
}
}
}
示例9: remote_upload
/**
* Remote upload method
* Uploads file from given url
*
* @param string $upload_url URL pointing to file to upload, for example http://www.foobar.com/example.gif
* @return filespec $file Object "filespec" is returned, all further operations can be done with this object
* @access public
*/
protected function remote_upload($upload_url)
{
$upload_ary = array();
$upload_ary['local_mode'] = true;
if (!preg_match('#^(https?://).*?\\.(' . implode('|', $this->upload->allowed_extensions) . ')$#i', $upload_url, $match)) {
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'URL_INVALID'));
}
$url = parse_url($upload_url);
$upload_ary['type'] = 'application/octet-stream';
$url['path'] = explode('.', $url['path']);
$ext = array_pop($url['path']);
$url['path'] = implode('', $url['path']);
$upload_ary['name'] = utf8_basename($url['path']) . ($ext ? '.' . $ext : '');
$remote_max_filesize = $this->get_max_file_size();
$guzzle_options = ['timeout' => $this->upload->upload_timeout, 'connect_timeout' => $this->upload->upload_timeout, 'verify' => !empty($this->config['remote_upload_verify']) ? (bool) $this->config['remote_upload_verify'] : false];
$client = new \GuzzleHttp\Client($guzzle_options);
try {
$response = $client->get($upload_url, $guzzle_options);
} catch (\GuzzleHttp\Exception\ClientException $clientException) {
return $this->factory->get('filespec')->set_error($this->upload->error_prefix . 'URL_NOT_FOUND');
} catch (\GuzzleHttp\Exception\RequestException $requestException) {
if (strpos($requestException->getMessage(), 'cURL error 28') !== false || preg_match('/408|504/', $requestException->getCode())) {
return $this->factory->get('filespec')->set_error($this->upload->error_prefix . 'REMOTE_UPLOAD_TIMEOUT');
} else {
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'));
}
} catch (\Exception $e) {
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED'));
}
$content_length = $response->getBody()->getSize();
if ($remote_max_filesize && $content_length > $remote_max_filesize) {
$max_filesize = get_formatted_filesize($remote_max_filesize, false);
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'WRONG_FILESIZE', $max_filesize['value'], $max_filesize['unit']));
}
if ($content_length == 0) {
return $this->factory->get('filespec')->set_error($this->upload->error_prefix . 'EMPTY_REMOTE_DATA');
}
$data = $response->getBody();
$filename = tempnam(sys_get_temp_dir(), unique_id() . '-');
if (!($fp = @fopen($filename, 'wb'))) {
return $this->factory->get('filespec')->set_error($this->upload->error_prefix . 'NOT_UPLOADED');
}
$upload_ary['size'] = fwrite($fp, $data);
fclose($fp);
unset($data);
$upload_ary['tmp_name'] = $filename;
/** @var filespec $file */
$file = $this->factory->get('filespec')->set_upload_ary($upload_ary)->set_upload_namespace($this->upload);
$this->upload->common_checks($file);
return $file;
}
示例10: utf8_pathinfo
/**
* Returns information about a file path
*
* @author Lars Knickrehm <mail@lars-sh.de>
* @category Library
* @copyright Copyright © 2009 Lars Knickrehm
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
* @link http://php.net/manual/function.pathinfo.php
* @package UTF-8
* @param string $path The path being checked.
* @return array The following associative array elements are returned: dirname, basename, extension (if any), and filename.
* @since Version 0.5.0
* @version 0.5.0
*/
function utf8_pathinfo($path)
{
$return['dirname'] = dirname($path);
$return['basename'] = utf8_basename($path);
$position = utf8_strrpos($return['basename'], '.');
if ($position !== false) {
$return['extension'] = utf8_substr($return['basename'], $position + 1);
$return['filename'] = $return['basename'];
$return['filename'] = utf8_substr($return['filename'], 0, $position);
} else {
$return['filename'] = $return['basename'];
}
return $return;
}
示例11: getIcons
public function getIcons($params)
{
$cat = utf8_basename($params[0]);
$size = utf8_basename($params[1]);
$icons = array();
if ($handle = opendir('extern/images/' . $size . '/' . $cat)) {
while (false !== ($file = readdir($handle))) {
if ($file[0] != '.') {
$icons[] = $file;
}
}
closedir($handle);
}
return $icons;
}
示例12: Add
/**
* @param array $files array filled with array(string filename, string data)
* @param bool $compact
* @return array
*/
function Add($files, $compact)
{
if (!is_array($files[0])) {
$files = array($files);
}
$ret = array();
for ($i = 0; $files[$i]; $i++) {
$fn = $files[$i];
if (!in_Array(dirname($fn[0]), $this->dirs)) {
$this->add_Dir(dirname($fn[0]));
}
if (utf8_basename($fn[0])) {
$ret[utf8_basename($fn[0])] = $this->add_File($fn[1], $fn[0], $compact);
}
}
return $ret;
}
示例13: code
/**
* Send the wanted code block to the browser
*
* When the correct block was found it exits the script.
*/
function code($text, $language = NULL, $filename = '')
{
global $INPUT;
if (!$language) {
$language = 'txt';
}
if (!$filename) {
$filename = 'snippet.' . $language;
}
$filename = utf8_basename($filename);
if ($this->_codeblock == $INPUT->str('codeblock')) {
header("Content-Type: text/plain; charset=utf-8");
header("Content-Disposition: attachment; filename={$filename}");
header("X-Robots-Tag: noindex");
echo trim($text, "\r\n");
exit;
}
$this->_codeblock++;
}
示例14: attachments
/**
* Sync attachments
*/
public function attachments($mode, $attachment_id = false)
{
switch ($mode) {
case 'hash':
$sql = 'SELECT * FROM ' . TITANIA_ATTACHMENTS_TABLE . ($attachment_id !== false ? ' WHERE attachment_id = ' . (int) $attachment_id : '');
$result = phpbb::$db->sql_query($sql);
while ($row = phpbb::$db->sql_fetchrow($result)) {
$file = titania::$config->upload_path . utf8_basename($row['attachment_directory']) . '/' . utf8_basename($row['physical_filename']);
$md5 = md5_file($file);
if ($md5 != $row['hash']) {
$sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . '
SET hash = \'' . phpbb::$db->sql_escape($md5) . '\'
WHERE attachment_id = ' . $row['attachment_id'];
phpbb::$db->sql_query($sql);
}
}
phpbb::$db->sql_freeresult($result);
break;
}
}
示例15: getFile
public static function getFile($params)
{
$hash = utf8_basename($params[0]);
$num = utf8_basename(intval($params[1]));
$thubnail = $params[2];
$to = 'home:///';
//then, check the destination file
$myFileDest = FSI::getFile($to);
$myFileDest->checkWritePermission();
$myRealFile = $myFileDest->getRealFile();
$fileNameDestination = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath());
header('Content-Type: image/jpeg');
if (!$thubnail) {
readfile($fileNameDestination . '/.office/' . $hash . '/' . $hash . '-' . $num . '.jpg');
} else {
session_write_close();
require_once 'system/Frameworks/Applications/Executables/EyeosModules/FileSystemExecModule.php';
FileSystemExecModule::getScaledImage(array('maxWidth' => '150', 'path' => $fileNameDestination . '/.office/' . $hash . '/' . $hash . '-' . $num . '.jpg'));
}
exit;
}