当前位置: 首页>>代码示例>>PHP>>正文


PHP f::name方法代码示例

本文整理汇总了PHP中f::name方法的典型用法代码示例。如果您正苦于以下问题:PHP f::name方法的具体用法?PHP f::name怎么用?PHP f::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在f的用法示例。


在下文中一共展示了f::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: crawl

 function crawl()
 {
     $path = url::strip_query($this->raw);
     $path = (array) str::split($path, '/');
     if (a::first($path) == 'index.php') {
         array_shift($path);
     }
     // parse params
     foreach ($path as $p) {
         if (str::contains($p, ':')) {
             $parts = explode(':', $p);
             if (count($parts) < 2) {
                 continue;
             }
             $this->params->{$parts}[0] = $parts[1];
         } else {
             $this->path->_[] = $p;
         }
     }
     // get the extension from the last part of the path
     $this->extension = f::extension($this->path->last());
     if ($this->extension != false) {
         // remove the last part of the path
         $last = array_pop($this->path->_);
         $this->path->_[] = f::name($last);
     }
     return $this->path;
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:28,代码来源:uri.php

示例2: language

 public function language()
 {
     if (!is_null($this->language)) {
         return $this->language;
     }
     $codes = $this->page->site()->languages()->codes();
     $code = f::extension(f::name($this->root));
     return $this->language = in_array($code, $codes) ? $this->page->site()->languages()->find($code) : false;
 }
开发者ID:kristianhalte,项目名称:super_organic,代码行数:9,代码来源:content.php

示例3: to

 public function to()
 {
     $source = $this->source();
     $name = f::name($source['name']);
     $extension = f::extension($source['name']);
     $safeName = f::safeName($name);
     $safeExtension = str_replace('jpeg', 'jpg', str::lower($extension));
     return str::template($this->options['to'], array('name' => $name, 'filename' => $source['name'], 'safeName' => $safeName, 'safeFilename' => $safeName . '.' . $safeExtension, 'extension' => $extension, 'safeExtension' => $safeExtension));
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:9,代码来源:upload.php

示例4: __construct

 public function __construct()
 {
     $root = kirby::instance()->roots()->accounts();
     foreach (dir::read($root) as $file) {
         // skip invalid account files
         if (f::extension($file) != 'php') {
             continue;
         }
         $user = new User(f::name($file));
         $this->append($user->username(), $user);
     }
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:12,代码来源:users.php

示例5: all

 public static function all()
 {
     $files = dir::read(static::$root);
     $result = array();
     $home = site()->homePage()->uid();
     $error = site()->errorPage()->uid();
     foreach ($files as $file) {
         $name = f::name($file);
         if ($name != 'site' and $name != $home and $name != $error) {
             $result[] = $name;
         }
     }
     return $result;
 }
开发者ID:kompuser,项目名称:panel,代码行数:14,代码来源:blueprint.php

示例6: all

 public static function all()
 {
     $files = dir::read(static::$root);
     $result = array();
     $home = kirby()->option('home', 'home');
     $error = kirby()->option('error', 'error');
     foreach ($files as $file) {
         $name = f::name($file);
         if ($name != 'site' and $name != $home and $name != $error) {
             $result[] = $name;
         }
     }
     return $result;
 }
开发者ID:biggtfish,项目名称:Clean-Blog-Kirby-Theme,代码行数:14,代码来源:blueprint.php

示例7: to

 public function to()
 {
     if (!is_null($this->to)) {
         return $this->to;
     }
     $source = $this->source();
     $name = f::name($source['name']);
     $extension = f::extension($source['name']);
     $safeName = f::safeName($name);
     $safeExtension = str_replace('jpeg', 'jpg', str::lower($extension));
     if (empty($safeExtension)) {
         $safeExtension = f::mimeToExtension(f::mime($source['tmp_name']));
     }
     return $this->to = str::template($this->options['to'], array('name' => $name, 'filename' => $source['name'], 'safeName' => $safeName, 'safeFilename' => $safeName . r(!empty($safeExtension), '.' . $safeExtension), 'extension' => $extension, 'safeExtension' => $safeExtension));
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:15,代码来源:upload.php

示例8: file

 function file($field, $destination, $params = array())
 {
     $allowed = a::get($params, 'allowed', c::get('upload.allowed', array('image/jpeg', 'image/png', 'image/gif')));
     $maxsize = a::get($params, 'maxsize', c::get('upload.maxsize', self::max_size()));
     $overwrite = a::get($params, 'overwrite', c::get('upload.overwrite', true));
     $sanitize = a::get($params, 'sanitize', true);
     $file = a::get($_FILES, $field);
     if (empty($file)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.missing-file', 'The file has not been found'));
     }
     $name = a::get($file, 'name');
     $type = a::get($file, 'type');
     $tmp_name = a::get($file, 'tmp_name');
     $error = a::get($file, 'error');
     $size = a::get($file, 'size');
     $msg = false;
     $extension = self::mime_to_extension($type, 'jpg');
     // convert the filename to a save name
     $fname = $sanitize ? f::safe_name(f::name($name)) : f::name($name);
     // setup the destination
     $destination = str_replace('{name}', $fname, $destination);
     $destination = str_replace('{extension}', $extension, $destination);
     if (file_exists($destination) && $overwrite == false) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.file-exists', 'The file exists and cannot be overwritten'));
     }
     if (empty($tmp_name)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.missing-file', 'The file has not been found'));
     }
     if ($error != 0) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.invalid-upload', 'The upload failed'));
     }
     if ($size > $maxsize) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.too-big', 'The file is too big'));
     }
     if (!in_array($type, $allowed)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.invalid-file', 'The file type is not allowed') . ': ' . $type);
     }
     // try to change the permissions for the destination
     @chmod(dirname($destination), 0777);
     if (!@copy($tmp_name, $destination)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.move-error', 'The file could not be moved to the server'));
     }
     // try to change the permissions for the final file
     @chmod($destination, 0777);
     return array('status' => 'success', 'msg' => l::get('upload.success', 'The file has been uploaded'), 'type' => $type, 'extension' => $extension, 'file' => $destination, 'size' => $size, 'name' => f::filename($destination));
 }
开发者ID:o-github-o,项目名称:jQuery-Ajax-Upload,代码行数:46,代码来源:upload.php

示例9: templates

 protected function templates()
 {
     $templates = ['all'];
     foreach (dir::read($this->dir() . '/site/blueprints') as $file) {
         if (!in_array(f::extension($file), ['php', 'yml', 'yaml'])) {
             continue;
         }
         $name = f::name($file);
         if (!in_array($name, ['error', 'site', 'home'])) {
             $templates[] = $name;
         }
     }
     return $templates;
 }
开发者ID:getkirby,项目名称:cli,代码行数:14,代码来源:Blueprint.php

示例10: init

 function init($page)
 {
     foreach ($page->rawfiles as $key => $file) {
         // skip invisible files
         if (preg_match('!^\\.!', $file)) {
             continue;
         }
         $info = array('name' => f::name($file), 'filename' => $file, 'extension' => f::extension($file), 'root' => $page->root . '/' . $file, 'uri' => $page->diruri . '/' . $file, 'parent' => $this, 'modified' => @filectime($page->root . '/' . $file));
         switch ($info['extension']) {
             case 'jpg':
             case 'jpeg':
             case 'gif':
             case 'png':
                 $info['type'] = 'image';
                 $class = 'image';
                 break;
             case 'pdf':
             case 'doc':
             case 'xls':
             case 'ppt':
                 $info['type'] = 'document';
                 $class = 'file';
                 break;
             case 'mov':
             case 'avi':
             case 'ogg':
             case 'ogv':
             case 'webm':
             case 'flv':
             case 'swf':
             case 'mp4':
                 $info['type'] = 'video';
                 $class = 'video';
                 break;
             case 'mp3':
                 $info['type'] = 'sound';
                 $class = 'file';
                 break;
             case c::get('content.file.extension', 'txt'):
                 $info['type'] = 'content';
                 $class = 'variables';
                 break;
             default:
                 $info['type'] = 'other';
                 $class = 'file';
         }
         $this->{$file} = new $class($info);
     }
     $this->dispatchImages();
     $this->dispatchContent();
 }
开发者ID:nilshendriks,项目名称:kirbycms,代码行数:51,代码来源:files.php

示例11: stillHasDefaultAccount

 static function stillHasDefaultAccount()
 {
     $file = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts/admin.php';
     if (file_exists($file)) {
         return true;
     }
     $dir = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts';
     $files = dir::read($dir);
     $default = array('username' => 'admin', 'password' => 'adminpassword', 'language' => 'en');
     foreach ($files as $file) {
         $username = f::name($file);
         $user = user::load($username);
         $diff = array_diff($user, $default);
         if (empty($diff)) {
             return true;
         }
     }
     return false;
 }
开发者ID:nilshendriks,项目名称:kirbycms-panel,代码行数:19,代码来源:check.php

示例12: plugins

 /**
  * Loads all available plugins for the site
  *
  * @return array
  */
 public function plugins()
 {
     // check for a cached plugins array
     if (!is_null($this->plugins)) {
         return $this->plugins;
     }
     // get the plugins root
     $root = $this->roots->plugins();
     // start the plugin registry
     $this->plugins = array();
     // check for an existing plugins dir
     if (!is_dir($root)) {
         return $this->plugins;
     }
     foreach (array_diff(scandir($root), array('.', '..')) as $file) {
         if (is_dir($root . DS . $file)) {
             $this->plugin($file, 'dir');
         } else {
             if (f::extension($file) == 'php') {
                 $this->plugin(f::name($file), 'file');
             }
         }
     }
     return $this->plugins;
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:30,代码来源:kirby.php

示例13: findTemplates

 static function findTemplates()
 {
     global $settings, $pages, $page, $site;
     $templates = array();
     if (@$settings->pages['template'] && !$site->isHome) {
         $templates[] = $settings->pages['template'];
     } else {
         $files = dir::read(c::get('root.site') . '/templates');
         foreach ($files as $file) {
             $name = f::name($file);
             // check if it is valid or already there.
             if (empty($name) || in_array($name, $templates)) {
                 continue;
             }
             // add it to the list of templates
             $templates[] = $name;
         }
     }
     return $templates;
 }
开发者ID:nilshendriks,项目名称:kirbycms-panel,代码行数:20,代码来源:data.php

示例14: createNewFilename

 /**
  * Generates a new filename for a given name
  * and makes sure to handle badly given extensions correctly
  * 
  * @param string $name
  * @return string
  */
 public function createNewFilename($name, $safeName = true)
 {
     $name = basename($safeName ? f::safeName($name) : $name);
     $ext = f::extension($name);
     // remove possible extensions
     if (in_array($ext, f::extensions())) {
         $name = f::name($name);
     }
     return trim($name . '.' . $this->extension(), '.');
 }
开发者ID:kristianhalte,项目名称:super_organic,代码行数:17,代码来源:file.php

示例15: secure_upload

/**
 * Upload image
 *
 * Requirement: Kirby
 *
 * @param string $name Name POSTNAME
 * @return array
 * @version 1.0 - 2011-01-12
 */
function secure_upload($options)
{
    /* 	
    $options['field'] // (required) source string
    $options['path'] // (required) source string
    */
    $options['image'] = isset($options['image']) ? $options['image'] : true;
    // default true
    $options['max_size'] = isset($options['max_size']) ? min($options['max_size'], server_maxupload()) : server_maxupload();
    // default server max upload in bytes
    if (empty($options['field']) || empty($options['path'])) {
        return array('error' => 'Option field and path is required');
    }
    if (!isset($_FILES[$options['field']])) {
        return array('error' => 'No file was selected');
    }
    // validate path
    $upload_path = $options['path'];
    $upload_path = rtrim($upload_path, '/') . '/';
    if (@realpath($upload_path) !== false) {
        $upload_path = str_replace("\\", "/", realpath($upload_path));
    }
    if (!file_exists($upload_path)) {
        if (!@mkdir($upload_path, 0777)) {
            return array('error' => 'Directory isnt writable');
        }
        chmod($upload_path, 0777);
    }
    if (!@is_dir($upload_path) || !is_writable($upload_path)) {
        return array('error' => 'Directory isnt writable');
    }
    $upload_path = preg_replace("/(.+?)\\/*\$/", "\\1/", $upload_path);
    // ?
    // Remapping for loop
    if (!is_array($_FILES[$options['field']]['tmp_name'])) {
        $_FILES[$options['field']] = array_map(function ($item) {
            return array($item);
        }, $_FILES[$options['field']]);
    }
    $success = array();
    foreach ($_FILES[$options['field']]['tmp_name'] as $key => $value) {
        // Get upload info
        $error = $_FILES[$options['field']]['error'][$key];
        $name = $_FILES[$options['field']]['name'][$key];
        $tmp_name = $_FILES[$options['field']]['tmp_name'][$key];
        $size = $_FILES[$options['field']]['size'][$key];
        $type = $_FILES[$options['field']]['type'][$key];
        if (!is_uploaded_file($tmp_name) || $error != UPLOAD_ERR_OK) {
            continue;
        }
        $type = preg_replace("/^(.+?);.*\$/", "\\1", $type);
        // ?
        $type = strtolower(trim(stripslashes($type), '"'));
        $ext = f::extension($name);
        $name = f::safe_name(f::name($name));
        $name = substr($name, 0, 100);
        // Check allowed file type
        $image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');
        if ($options['image']) {
            if (!in_array($ext, $image_types) || !is_image($type) || getimagesize($tmp_name) === false) {
                continue;
            }
        }
        // Check file size
        if ($options['max_size'] < $size) {
            continue;
        }
        // Unique filename
        if (file_exists($upload_path . $name . "." . $ext)) {
            $number = 1;
            while (file_exists($upload_path . $name . $number . "." . $ext)) {
                $number++;
            }
            $name = $name . $number;
        }
        // save
        if (!@move_uploaded_file($tmp_name, $upload_path . $name . "." . $ext)) {
            continue;
        }
        // TODO xss clean
        $success[] = array('extension' => $ext, 'filename' => $name . "." . $ext, 'original_filename' => $_FILES[$options['field']]['name'][$key], 'name' => $name, 'size' => $size, 'nice_size' => f::nice_size($size), 'md5' => md5(file_get_contents($upload_path . $name . "." . $ext)));
    }
    return array('failed' => count($_FILES[$options['field']]['tmp_name']) - count($success), 'success' => $success);
}
开发者ID:o-github-o,项目名称:jQuery-Ajax-Upload,代码行数:93,代码来源:secure_upload.php


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