• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP utf8_basename函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中utf8_basename函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_basename函数的具体用法?PHP utf8_basename怎么用?PHP utf8_basename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了utf8_basename函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:27,代码来源:newlink.php


示例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 <[email protected]>
 */
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;
}
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:71,代码来源:pageutils.php


示例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] . "')");
     }
 }
开发者ID:richmahn,项目名称:Door43,代码行数:7,代码来源:utf8_basename.test.php


示例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);
 }
开发者ID:boycaught,项目名称:dokuwiki,代码行数:15,代码来源:Mailer.class.php


示例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;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:8,代码来源:EyeosApplicationExecutable.php


示例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());
     }
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:9,代码来源:PrincipalDirsUMListener.php


示例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);
     }
 }
开发者ID:Gfksx,项目名称:customisation-db,代码行数:14,代码来源:contrib_tools.php


示例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;
         }
     }
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:11,代码来源:profile.php


示例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;
 }
开发者ID:007durgesh219,项目名称:phpbb,代码行数:59,代码来源:remote.php


示例10: utf8_pathinfo

/**
 * Returns information about a file path
 *
 * @author Lars Knickrehm <[email protected]>
 * @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;
}
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:28,代码来源:pathinfo.php


示例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;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:15,代码来源:ResourcesExecModule.php


示例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;
 }
开发者ID:RnBConsulting,项目名称:dokuwiki,代码行数:22,代码来源:ZipLib.class.php


示例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++;
 }
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:24,代码来源:code.php


示例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;
        }
    }
开发者ID:Noxwizard,项目名称:customisation-db,代码行数:23,代码来源:sync.php


示例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;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:21,代码来源:pdfviewer.php


示例16: getHandler

 /**
  * 
  * @param string $handlerId The ID of the handler to return (e.g. "SQL/EyeosDAO").
  * @param IStorageHandler
  */
 public function getHandler($handlerId, array $params = null)
 {
     //TODO need a resolution of the ID here (remove leading slashes, ".." occurrences, etc.)
     if (!isset($this->handlers[$handlerId])) {
         if (!is_file(SERVICE_STORAGE_HANDLERS_PATH . '/' . $handlerId . '.php')) {
             throw new EyeFileNotFoundException(SERVICE_STORAGE_HANDLERS_PATH . '/' . $handlerId . '.php');
         }
         require SERVICE_STORAGE_HANDLERS_PATH . '/' . $handlerId . '.php';
         $this->handlers[$handlerId] = utf8_basename($handlerId, '.php');
     }
     $className = $this->handlers[$handlerId];
     try {
         $obj = new $className($params);
         if ($obj === false) {
             throw new EyeBadMethodCallException('Unable to create instance of class ' . $className);
         }
     } catch (Exception $e) {
         throw new EyeRuntimeException('Unable to create instance of the security manager class ' . $className, 0, $e);
     }
     return $obj;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:26,代码来源:StorageManager.php


示例17: check_friends

 public function check_friends($event)
 {
     $context = new RequestContext();
     $context->fromRequest($this->symfony_request);
     $baseUrl = generate_board_url(true) . $context->getBaseUrl();
     $scriptName = $this->symfony_request->getScriptName();
     $scriptName = substr($scriptName, -1, 1) == '/' ? '' : utf8_basename($scriptName);
     if ($scriptName != '') {
         $baseUrl = str_replace('/' . $scriptName, '', $baseUrl);
     }
     $user_id = $event['member']['user_id'];
     $sender_id = $this->user->data['user_id'];
     $request = $this->friends_model->get_request_by_sender_id($sender_id);
     $check_friend = $this->friends_model->check_friend(array('user_id' => $this->user->data['user_id'], 'friend_id' => $user_id));
     $check_request = $this->friends_model->check_request(array('user_id' => $user_id, 'sender_id' => $this->user->data['user_id']));
     $check_request_confirm = $this->friends_model->check_request(array('user_id' => $this->user->data['user_id'], 'sender_id' => $user_id));
     $check_widget = true;
     if ($user_id == $this->user->data['user_id']) {
         $check_widget = false;
     }
     $this->template->assign_vars(array('U_USER_ID' => $user_id, 'U_CHECK_FRIEND' => $check_friend, 'U_CHECK_REQUEST' => $check_request, 'U_CHECK_REQUEST_CONFIRM' => $check_request_confirm, 'U_CHECK_WIDGET' => $check_widget, 'U_REQUEST_ID' => $request['request_id'], 'BASE_URL' => $baseUrl));
 }
开发者ID:TWEagle,项目名称:phpbb-messenger,代码行数:22,代码来源:main_listener.php


示例18: 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);
     $filename = utf8_stripspecials($filename, '_');
     // send CRLF to Windows clients
     if (strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false) {
         $text = str_replace("\n", "\r\n", $text);
     }
     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++;
 }
开发者ID:wernerflamme,项目名称:dokuwiki,代码行数:29,代码来源:code.php


示例19: glob

 /**
  * Finds pathnames matching a pattern.
  * Note: This function does not return hidden files (.*) under *NIX with default pattern (*)
  * 
  * @see glob() in PHP manual
  * @param string $path
  * @param mixed $pattern A simple string or an array of strings representing the patterns.
  * @param int $flags
  * 			GLOB_ONLY_DIR: Set it to retrieve directories only.<br />
  * 			GLOB_DIR_IGNORE_PATTERN: Set it to apply given $pattern on files only, and retrieve all directories.<br />
  * 			GLOB_DIR_FIRST: Set it to force placing directories first in the returned list.<br />
  * 			GLOB_RETURN_SIMPLE_PATH: Set it to force returning a simple path (from the root) instead of a URL.<br />
  * 			GLOB_CASEINSENSITIVE: Set it to apply given $pattern in a case insensitive way.<br />
  * 			GLOB_FORCE_SCANDIR: Set it to force direct use of scandir() instead of glob().
  * @return array(string)
  */
 public static function glob($path, $pattern = self::WILDCARD_CHAR, $flags = self::GLOB_NORMAL)
 {
     if (!is_string($path)) {
         throw new EyeInvalidArgumentException('$path must be a string (given: ' . gettype($pattern) . ').');
     }
     if (!is_string($pattern) && !is_array($pattern)) {
         throw new EyeInvalidArgumentException('$pattern must be a string or an array (given: ' . gettype($pattern) . ').');
     }
     if (is_array($pattern)) {
         if (count($pattern) === 0) {
             $pattern = self::WILDCARD_CHAR;
         } else {
             if (count($pattern) === 1) {
                 $pattern = $pattern[0];
             }
         }
     }
     $globFlags = 0;
     if (is_array($pattern)) {
         // Clean original $pattern (common to glob & scandir)
         foreach ($pattern as &$subPattern) {
             $subPattern = str_replace('/', '', $subPattern);
             if ($flags & self::GLOB_CASEINSENSITIVE) {
                 $subPattern = mb_sql_regcase($subPattern);
             }
         }
         // Create a glob-compatible expression with multiple patterns using braces
         $globPattern = '{' . implode(',', $pattern) . '}';
         $globFlags |= GLOB_BRACE;
     } else {
         $globPattern =& $pattern;
         $pattern = str_replace('/', '', $pattern);
         if ($flags & self::GLOB_CASEINSENSITIVE) {
             $pattern = mb_sql_regcase($pattern);
         }
     }
     $return = array();
     $globFlags |= $flags & self::GLOB_ONLY_DIR ? GLOB_ONLYDIR : 0;
     $globPath = self::getPhpLocalHackPath(strtr($path, array('[' => '\\[', ']' => '\\]')), self::PARSE_URL_DONTRESOLVE);
     //first of all, let's try with the normal glob() function (works only on localhost, but faster)
     if (!($flags & self::GLOB_FORCE_SCANDIR) && ($allFiles = glob($globPath . '/' . $globPattern, $globFlags))) {
         //_and_ glob() must succeed (an empty array may indicate that glob() failed)
         $onlyDirs = array();
         if ($flags & self::GLOB_DIR_IGNORE_PATTERN) {
             $onlyDirs = glob($globPath . '/' . self::WILDCARD_CHAR, GLOB_ONLYDIR);
         } else {
             $onlyDirs = glob($globPath . '/' . $globPattern, GLOB_ONLYDIR);
         }
         //in some servers glob is returning false, documentation says it shoul
         //return an empty array, however, this is not happening.
         if (!$onlyDirs) {
             $onlyDirs = array();
         }
         natcasesort($onlyDirs);
         $onlyFiles = array_diff($allFiles, $onlyDirs);
         $sortedFiles = array_merge($onlyDirs, $onlyFiles);
         //dirs are placed first (alphab. sorted), then files (alphab. sorted)
         if (!($flags & self::GLOB_DIR_FIRST)) {
             natcasesort($sortedFiles);
         }
         $scheme = '';
         if (!($flags & self::GLOB_RETURN_SIMPLE_PATH)) {
             //retrieve the original scheme
             $urlParts = self::parse_url($path, self::PARSE_URL_NO_AUTOSET_SCHEME);
             if (isset($urlParts['scheme'])) {
                 $scheme = $urlParts['scheme'] . '://';
             }
         }
         foreach ($sortedFiles as $filepath) {
             if (utf8_basename($filepath) != '.' && utf8_basename($filepath) != '..') {
                 $return[] = $scheme . $filepath;
             }
         }
     } else {
         $files = @scandir($path);
         if ($files === false) {
             throw new EyeIOException('Unable to list files in directory "' . $path . '"');
         }
         $files_tmp = array();
         $dirs_tmp = array();
         foreach ($files as $filepath) {
             if ($filepath != '.' && $filepath != '..') {
                 // Single pattern (string)
                 if (is_string($pattern)) {
//.........这里部分代码省略.........
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:101,代码来源:AdvancedPathLib.php


示例20: submit_pm


//.........这里部分代码省略.........
        unset($sql);
        $sql_ary = array();
        foreach ($recipients as $user_id => $type) {
            $sql_ary[] = array('msg_id' => (int) $data['msg_id'], 'user_id' => (int) $user_id, 'author_id' => (int) $data['from_user_id'], 'folder_id' => PRIVMSGS_NO_BOX, 'pm_new' => 1, 'pm_unread' => 1, 'pm_forwarded' => $mode == 'forward' ? 1 : 0);
        }
        $db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary);
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . '
			WHERE ' . $db->sql_in_set('user_id', array_keys($recipients));
        $db->sql_query($sql);
        // Put PM into outbox
        if ($put_in_outbox) {
            $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array('msg_id' => (int) $data['msg_id'], 'user_id' => (int) $data['from_user_id'], 'author_id' => (int) $data['from_user_id'], 'folder_id' => PRIVMSGS_OUTBOX, 'pm_new' => 0, 'pm_unread' => 0, 'pm_forwarded' => $mode == 'forward' ? 1 : 0)));
        }
    }
    // Set user last post time
    if ($mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward' || $mode == 'post') {
        $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_lastpost_time = {$current_time}\n\t\t\tWHERE user_id = " . $data['from_user_id'];
        $db->sql_query($sql);
    }
    // Submit Attachments
    if (!empty($data['attachment_data']) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward'))) {
        $space_taken = $files_added = 0;
        $orphan_rows = array();
        foreach ($data['attachment_data'] as $pos => $attach_row) {
            $orphan_rows[(int) $attach_row['attach_id']] = array();
        }
        if (sizeof($orphan_rows)) {
            $sql = 'SELECT attach_id, filesize, physical_filename
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . '
					AND in_message = 1
					AND is_orphan = 1
					AND poster_id = ' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            $orphan_rows = array();
            while ($row = $db->sql_fetchrow($result)) {
                $orphan_rows[$row['attach_id']] = $row;
            }
            $db->sql_freeresult($result);
        }
        foreach ($data['attachment_data'] as $pos => $attach_row) {
            if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) {
                continue;
            }
            if (!$attach_row['is_orphan']) {
                // update entry in db if attachment already stored in db and filespace
                $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tSET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "'\n\t\t\t\t\tWHERE attach_id = " . (int) $attach_row['attach_id'] . '
						AND is_orphan = 0';
                $db->sql_query($sql);
            } else {
                // insert attachment into db
                if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) {
                    continue;
                }
                $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize'];
                $files_added++;
                $attach_sql = array('post_msg_id' => $data['msg_id'], 'topic_id' => 0, 'is_orphan' => 0, 'poster_id' => $data['from_user_id'], 'attach_comment' => $attach_row['attach_comment']);
                $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . '
					WHERE attach_id = ' . $attach_row['attach_id'] . '
						AND is_orphan = 1
						AND poster_id = ' . $user->data['user_id'];
                $db->sql_query($sql);
            }
        }
        if ($space_taken && $files_added) {
            $config->increment('upload_dir_size', $space_taken, false);
            $config->increment('num_files', $files_added, false);
        }
    }
    // Delete draft if post was loaded...
    $draft_id = $request->variable('draft_loaded', 0);
    if ($draft_id) {
        $sql = 'DELETE FROM ' . DRAFTS_TABLE . "\n\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\tAND user_id = " . $data['from_user_id'];
        $db->sql_query($sql);
    }
    $db->sql_transaction('commit');
    // Send Notifications
    $pm_data = array_merge($data, array('message_subject' => $subject, 'recipients' => $recipients));
    /* @var $phpbb_notifications \phpbb\notification\manager */
    $phpbb_notifications = $phpbb_container->get('notification_manager');
    if ($mode == 'edit') {
        $phpbb_notifications->update_notifications('notification.type.pm', $pm_data);
    } else {
        $phpbb_notifications->add_notifications('notification.type.pm', $pm_data);
    }
    /**
     * Get PM message ID after submission to DB
     *
     * @event core.submit_pm_after
     * @var	string	mode	PM Post mode - post|reply|quote|quotepost|forward|edit
     * @var	string	subject	Subject of the private message
     * @var	array	data	The whole row data of the PM.
     * @var	array	pm_data	The data sent to notification class
     * @since 3.1.0-b5
     */
    $vars = array('mode', 'subject', 'data', 'pm_data');
    extract($phpbb_dispatcher->trigger_event('core.submit_pm_after', compact($vars)));
    return $data['msg_id'];
}
开发者ID:binano,项目名称:phpbb,代码行数:101,代码来源:functions_privmsgs.php



注:本文中的utf8_basename函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP utf8_check函数代码示例发布时间:2022-05-23
下一篇:
PHP utf8_bad_replace函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap