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


PHP filename函数代码示例

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


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

示例1: fsDirRead

function fsDirRead($path, $full = true, $keyformat = null, $post = '/')
{
    if (file_exists($path)) {
        $temp = scandir($path);
        foreach ($temp as $file) {
            if (!in_array(strtolower($file), array('.', '..', '.ds_store'))) {
                if ($keyformat == lc_filename) {
                    $key = strtolower(filename($file));
                } else {
                    if ($keyformat == lc_basename) {
                        $key = strtolower($file);
                    } else {
                        if ($keyformat == uc_filename) {
                            $key = strtolower(filename($file));
                        } else {
                            if ($keyformat == uc_basename) {
                                $key = strtoupper($file);
                            } else {
                                if ($keyformat == filename) {
                                    $key = filename($file);
                                } else {
                                    if ($keyformat == basename) {
                                        $key = $file;
                                    } else {
                                        if ($keyformat == position_in_array) {
                                            $key = count($output) - 1;
                                        } else {
                                            if ($keyformat == path) {
                                                $key = $path;
                                            } else {
                                                if ($keyformat == full_path) {
                                                    $key = $path . $file;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!$full) {
                    $output[$key] = $file . $post;
                } else {
                    $output[$key] = $path . '/' . $file . $post;
                }
            }
        }
        return $output;
    }
}
开发者ID:axiixc,项目名称:elemental,代码行数:51,代码来源:Filesystem.php

示例2: render

function render($template, $template_vars = array())
{
    $template_file = filename($template);
    if (file_exists($template_file)) {
        if (!empty($template_vars) and is_array($template_vars)) {
            extract($template_vars);
        }
        ob_start();
        require $template_file;
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
    } else {
        trigger_error("Eh-oh! Required template {$template} ({$template_file}) not found", E_USER_ERROR);
    }
    return false;
}
开发者ID:phpish,项目名称:template,代码行数:17,代码来源:template.php

示例3: create_model

function create_model($opts)
{
    $filename = filename($opts[0]);
    $text = <<<MODEL
<?php

class {$filename} extends Model {
  const TABLE = "{$opts['0']}";

}

MODEL;
    $fh = fopen(APP_ROOT . '/app/models/' . $filename . '.class.php', 'w');
    fwrite($fh, $text);
    fclose($fh);
    create_migration($opts);
}
开发者ID:rawhide,项目名称:phpframework,代码行数:17,代码来源:generate.php

示例4: iframe_accept_images

 function iframe_accept_images($val)
 {
     $root_patt = prepare_pattern(config_get('http-document-root'));
     $val = preg_replace("'(<img[\\/\\!]*?[^<>]*?)(ilo-full-src\\s*=\\s*\"?[\\w\\:\\+\\-\\/\\%\\\$\\#\\.\\,]*\"?)([^<>]*?>)'si", '\\1\\3', $val);
     $val = preg_replace("'(<img[\\/\\!]*?[^<>]*?)(src\\s*=\\s*\"?{$root_patt}([\\w\\+\\-\\:\\/\\%\\\$\\#\\.\\,]*)\"?)([^<>]*?>)'si", '\\1src="\\3"\\4', $val);
     $images = iframe_get_images($val);
     $files = iframe_get_files($val);
     $f = combine_arrays($images, $files);
     for ($i = 0, $n = count($f); $i < $n; $i++) {
         $storage = manage_storage_by_dir(dirname($f[$i]));
         if ($storage) {
             $storage->AcceptFile(filename($f[$i]));
         }
     }
     $val = preg_replace("'(<img[\\/\\!]*?[^<>]*?)(src\\s*=\\s*\"?\\/([\\w\\+\\-\\:\\/\\%\$\\#\\.\\,]*)\"?)([^<>]*?>)'si", '\\1src="${document-root}/\\3"\\4', $val);
     return $val;
 }
开发者ID:Nazg-Gul,项目名称:gate,代码行数:17,代码来源:iframe.php

示例5: MaintenanceMode

/**
 *  Maintenance Mode 
 */
function MaintenanceMode($mode = MAINTENANCE)
{
    # $mode either equals true or false
    if ($mode) {
        # if we are in maintenance, require all pages to go to the maintenance page
        if (filename($_SERVER['SCRIPT_FILENAME']) != 'maintenance.php') {
            # Replace the location to the loacation of your maintenance page
            header("Location: " . BASE_URL . "maintenance.php");
            exit;
        }
    } else {
        # if we are not in maintenance, don't allow link to maintenance page
        if (filename($_SERVER['SCRIPT_FILENAME']) == 'maintenance.php') {
            # Replace the location to the loacation to your home page
            header("Location: BASE_URL");
            exit;
        }
    }
}
开发者ID:Bolvar,项目名称:FlameCMS,代码行数:22,代码来源:function.php

示例6: func_cp

function func_cp($params)
{
    if (isset($params[2])) {
        if (!file_exists($params[1])) {
            echo "cp: {$params[1]}: No such file or directory\n";
        } elseif (!file_exists($params[2])) {
            echo "cp: {$params[2]}: No such file or directory\n";
        } elseif (is_dir($params[1])) {
            echo "cp: {$params[1]}: Is a directory\n";
        } elseif (!is_dir($params[2])) {
            echo "cp: {$params[2]}: Not a directory\n";
        } else {
            if (!is_executable($params[2])) {
                echo "cp: {$params[2]}: Permission denied\n";
            } else {
                $dir = opendir($params[2]);
                if (!($file_r = fopen($params[1], "r"))) {
                    echo "cp: {$params[1]}: Cannot open file\n";
                } else {
                    $str = "";
                    while (ord($char = fread($file_r, 1))) {
                        $str = $str . $char;
                    }
                    fclose($file_r);
                    if (!($file_w = fopen(filename($params[2], $params[1]), "w"))) {
                        echo "cp: {$params[1]}: Cannot open file\n";
                    } else {
                        $i = 0;
                        while (isset($str[$i])) {
                            fwrite($file_w, $str[$i]);
                            $i++;
                        }
                        fclose($file_w);
                    }
                }
                closedir($dir);
            }
        }
    } else {
        echo "Invalid arguments\nCorrect usage : cp FILE DIRECTORY\n";
    }
}
开发者ID:TristanMarion,项目名称:MicroShell,代码行数:42,代码来源:func_cp.php

示例7: upload

 function upload($name, $targetPath, $extensions = array())
 {
     if (($perms = getperms($targetPath)) != '0777') {
         return $perms;
     }
     $result = array();
     if (!is_array($_FILES[$name]['name'])) {
         if (!empty($extensions) && !in_array(extension($_FILES[$name]['name']), $extensions)) {
             return false;
         }
         $targetPathCurrent = $targetPath . basename($_FILES[$name]['name']);
         $i = 1;
         while (file_exists($targetPathCurrent)) {
             $targetPathCurrent = $targetPath . filename($_FILES[$name]['name']) . '_' . $i . '.' . extension($_FILES[$name]['name']);
             $i++;
         }
         if (move_uploaded_file($_FILES[$name]['tmp_name'], $targetPathCurrent) && file_exists($targetPathCurrent)) {
             return array($targetPathCurrent);
         } else {
             return $result;
         }
     }
     $i = 0;
     foreach ($_FILES[$name]['name'] as $fileName) {
         if (!empty($extensions) && !in_array(extension($fileName), $extensions)) {
             return false;
         }
         $targetPathCurrent = $targetPath . basename($fileName);
         $j = 1;
         while (file_exists($targetPathCurrent)) {
             $targetPathCurrent = $targetPath . filename($fileName) . '_' . $j . '.' . extension($fileName);
             $j++;
         }
         if (move_uploaded_file($_FILES[$name]['tmp_name'][$i], $targetPathCurrent) && file_exists($targetPathCurrent)) {
             $result[$i] = $targetPathCurrent;
             $i++;
         }
     }
     return $result;
 }
开发者ID:kimihub,项目名称:nemesis-framework,代码行数:40,代码来源:functions.php

示例8: array

            }
        }
    }
}
require_once 'inc.config.php';
require_once 'inc.tpl.header.php';
$szStart1 = SCRIPT_ROOT . '/';
$g_arrFiles = array();
exploreFolder($szStart1);
krsort($g_arrFiles);
$g_arrFiles1 = $g_arrFiles;
function filename($file)
{
    return substr($file, strlen(SCRIPT_ROOT));
    return $file;
    return substr($file, 0 !== strpos($file, PROJECT_PUBLIC) ? strlen(SCRIPT_SOURCE) : strlen(PROJECT_PUBLIC));
}
?>
<style type="text/css">
th { font-weight:normal; text-align:left; padding-right:7px; border-right:solid 5px #dddddd; }
table table td { padding-left:5px; }
.hd td { font-weight:bold; font-size:24px; padding-left:100px; }
</style>
<?php 
echo '<table border="0">';
foreach ($g_arrFiles1 as $time => $arrSFiles) {
    foreach ($arrSFiles as $szFile) {
        echo '<tr><th>' . date('Y-m-d H:i:s', $time) . '</th><td>' . filename($szFile) . '</td></tr>';
    }
}
echo '</table>';
开发者ID:rudiedirkx,项目名称:CMS1,代码行数:31,代码来源:modified_files.php

示例9: filename

<?php

$filename = filename(__FILE__);
$github = \shgysk8zer0\Core\resources\Parser::parseFile('github.json');
$PDO = new \shgysk8zer0\Core\PDO($github);
$parser = new \Parsedown\Parsedown();
$start = (array_key_exists('commit_start', $_REQUEST) and is_numeric($_REQUEST['commit_start'])) ? abs((int) $_REQUEST['commit_start']) : 0;
$end = $start + 10;
$commits = $PDO("SELECT\n\t\t\t`SHA`,\n\t\t\t`Branch`,\n\t\t\t`Commit_URL` AS `URL`,\n\t\t\t`Commit_Message` AS `Message`,\n\t\t\t`Author_Username` AS `Author`,\n\t\t\t`Author_Email` AS `Email`,\n\t\t\t`Time` AS `Timestamp`\n\t\tFROM `Commits`\n\t\tWHERE `Branch` = 'refs/heads/master'\n\t\tORDER BY `Timestamp`\n\t\tDESC\n\t\tLIMIT {$start}, 10;");
array_walk($commits, function (\stdClass &$commit) {
    $commit->Message = mb_convert_encoding($commit->Message, 'utf-8');
    $commit->Message = explode(PHP_EOL, $commit->Message);
});
?>
<dialog id="<?php 
echo $filename;
?>
_dialog">
	<button type="button" data-delete="#<?php 
echo $filename;
?>
_dialog"></button>
	<br />
	<table border="1">
		<caption>
			Recent commits to
			<a href="<?php 
echo $github->repository->html_url;
?>
">
				<?php 
开发者ID:gitter-badger,项目名称:chriszuber,代码行数:31,代码来源:recent_commits.php

示例10: filename

<?php

$formname = filename(__FILE__);
?>
<dialog id="<?php 
echo $formname;
?>
_dialog">
	<form name="<?php 
echo $formname;
?>
" action="<?php 
echo URL;
?>
" method="post">
		<details open>
			<summary>Server Database Connection Credentials</summary>
			<fieldset form="<?php 
echo $formname;
?>
">
				<legend>Root MySQL User</legend>
				<label for="<?php 
echo $formname;
?>
_root_useer" data-icon="U"></label>
				<input type="text" name="<?php 
echo $formname;
?>
[root][user]" id="<?php 
echo $formname;
开发者ID:gitter-badger,项目名称:chriszuber,代码行数:31,代码来源:install.php

示例11: foreach

<footer id="footer">
	<?php 
if ($DB->connected) {
    foreach ($DB->fetchArray("SELECT\n\t\t\t\t`url`,\n\t\t\t\t`icon`,\n\t\t\t\t`alt`\n\t\t\tFROM `footer_links`\n\t\t\tORDER BY `order` ASC;") as $link) {
        ?>
	<a href="<?php 
        echo $link->url;
        ?>
" target="_blank" class="logo currentColor" title="<?php 
        echo $link->alt;
        ?>
">
		<?php 
        echo SVG_use(filename($link->icon));
        ?>
	</a>
	<?php 
    }
}
foreach (['git-commit' => ['title' => 'Recent Commits', 'class' => 'logo currentColor', 'data-request' => "action=recent_commits"], 'issue-opened' => ['title' => 'GitHub Issues', 'class' => 'logo currentColor', 'data-request' => 'action=github_issues'], 'mail' => ['title' => 'Email Me', 'class' => 'logo currentColor', 'data-show-modal' => '#email_admin_dialog'], 'people' => ['title' => 'Contact Info', 'class' => 'logo currentColor', 'data-show-modal' => '#contactDialog'], 'question' => ['title' => 'Show README', 'class' => 'logo currentColor', 'data-request' => 'action=README'], 'copyleft' => ['title' => 'Copyleft', 'class' => 'logo currentColor', 'data-show-modal' => '#copyleftDialog']] as $icon => $attributes) {
    ?>
			<span <?php 
    echo join(' ', array_map(function ($key, $value) {
        return "{$key}=\"{$value}\"";
    }, array_keys($attributes), array_values($attributes)));
    ?>
>
				<?php 
    echo SVG_use($icon);
    ?>
			</span>
开发者ID:gitter-badger,项目名称:chriszuber,代码行数:31,代码来源:footer.php

示例12: h5upload

 public function h5upload()
 {
     // Make sure file is not cached (as it happens for example on iOS devices)
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // 5 minutes execution time
     @set_time_limit(5 * 60);
     $fileurl = createdir();
     $target_dir = ATTACHMENT_ROOT . $fileurl;
     // Get a file name
     if (isset($GLOBALS["name"])) {
         $fileName = $GLOBALS["name"];
     } elseif (!empty($_FILES)) {
         $fileName = $_FILES["file"]["name"];
     } else {
         $fileName = uniqid("file_");
     }
     $insert = array();
     $insert['name'] = iconv('utf-8', CHARSET, $fileName);
     $fileName = filename($fileName);
     //不允许上传的文件扩展
     if ($fileName == FALSE) {
         die('{"jsonrpc" : "2.0", "error" : {"code": 105, "message": "Ban file name."}, "id" : "id"}');
     }
     $filePath = $target_dir . '/' . $fileName;
     // Chunking might be enabled
     $chunk = isset($GLOBALS["chunk"]) ? intval($GLOBALS["chunk"]) : 0;
     $chunks = isset($GLOBALS["chunks"]) ? intval($GLOBALS["chunks"]) : 0;
     // Open temp file
     if (!($out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb"))) {
         die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
     }
     if (!empty($_FILES)) {
         $stream_input = false;
         if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
             die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
         }
         // Read binary input stream and append it to temp file
         if (!($in = @fopen($_FILES["file"]["tmp_name"], "rb"))) {
             die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
         }
     } else {
         $stream_input = true;
         if (!($in = @fopen("php://input", "rb"))) {
             die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
         }
     }
     while ($buff = fread($in, 4096)) {
         fwrite($out, $buff);
     }
     @fclose($out);
     @fclose($in);
     // Check if file has been uploaded
     if (!$chunks || $chunk == $chunks - 1) {
         // Strip the temp .part suffix off
         rename("{$filePath}.part", $filePath);
     }
     $insert['path'] = $fileurl . $fileName;
     $insert['addtime'] = SYS_TIME;
     $insert['filesize'] = $_FILES['file']['size'] ? $_FILES['file']['size'] : filesize($filePath);
     $insert['ip'] = get_ip();
     $_username = get_cookie('_username');
     $wz_name = get_cookie('wz_name');
     $insert['username'] = $_username ? $_username : $wz_name ? $wz_name : '';
     if ($insert['username'] == '') {
         die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Not allow guest upload."}, "id" : "id"}');
     }
     $md5file = md5_file(ATTACHMENT_ROOT . $insert['path']);
     if ($r = $this->db->get_one('attachment', array('md5file' => $md5file))) {
         unlink(ATTACHMENT_ROOT . $insert['path']);
         $id = $r['id'];
         die('{"jsonrpc" : "2.0", "exttype" : "img", "result" : "' . ATTACHMENT_URL . $r['path'] . '", "id" : "' . $id . '", "filename" : "' . $r['name'] . '" }');
     } else {
         $attachment = load_class('attachment', M);
         $insert['md5file'] = $md5file;
         $id = $attachment->insert($insert);
         // Return Success JSON-RPC response
         $info = pathinfo($insert['name']);
         $file_name = basename($insert['name'], '.' . $info['extension']);
         die('{"jsonrpc" : "2.0", "exttype" : "img", "result" : "' . ATTACHMENT_URL . $fileurl . $fileName . '", "id" : "' . $id . '", "filename" : "' . $file_name . '" }');
     }
 }
开发者ID:another3000,项目名称:wuzhicms,代码行数:85,代码来源:index.php

示例13: DeletePictureFile

 public function DeletePictureFile()
 {
     if (!$this->PictureFile) {
         return false;
     }
     $main = filename($this->PictureFile);
     $ext = extension($this->PictureFile, "jpg");
     $thumb = $main . "_thumb." . $ext;
     $med = $main . "_med." . $ext;
     $result = @unlink(DOCROOT . "/uploads/" . $this->PictureFile) && @unlink(DOCROOT . "/uploads/" . $thumb) && @unlink(DOCROOT . "/uploads/" . $med);
     if ($result) {
         $this->PictureFile = '';
         $this->Save();
     }
     return $result;
 }
开发者ID:bluegate010,项目名称:ysaward,代码行数:16,代码来源:Member.php

示例14: set_time_limit

	Protect this file if you upload it. It has no security built-in.
*/
exit;
// SAFETY LINE; disable to use this file
require_once "../lib/init.php";
echo "<pre>";
set_time_limit(0);
$mems = DB::Run("SELECT ID FROM Members ORDER BY ID ASC");
$i = 0;
while ($row = mysql_fetch_array($mems)) {
    $mem = Member::Load($row['ID']);
    if (!$mem->PictureFile) {
        continue;
    }
    $picFile = $mem->PictureFile;
    $main = filename($mem->PictureFile);
    $ext = extension($mem->PictureFile, "jpg");
    $newRand = rand(1000, 9999);
    $newMain = $mem->FirstName . "_" . $mem->LastName . "_" . $mem->ID() . "_" . $newRand;
    $newFull = $newMain . "." . $ext;
    $newMedium = $newMain . "_med." . $ext;
    $newThumb = $newMain . "_thumb." . $ext;
    echo "PICTURE:\n{$newMain}\n{$newFull}\n{$newMedium}\n{$newThumb}\n";
    copy("uploads/" . $mem->PictureFile, "uploads/" . $newFull);
    create_jpgthumb("uploads/" . $mem->PictureFile, "uploads/" . $newMedium, Member::MEDIUM_DIM, Member::MEDIUM_DIM, 85, true);
    create_jpgthumb("uploads/" . $mem->PictureFile, "uploads/" . $newThumb, Member::THUMB_DIM, Member::THUMB_DIM, 70, false);
    $mem->DeletePictureFile();
    $mem->PictureFile = $newFull;
    $mem->Save();
    $i++;
    echo "DONE.\n\n";
开发者ID:bluegate010,项目名称:ysaward,代码行数:31,代码来源:picupgrade.php

示例15: str_replace

require LIB . 'output.lib.php';
if (isset($_SESSION['loginUsername']) && $_SESSION['userLevel'] <= 1) {
    include DB . 'output_email_export.db.php';
    //echo $query_sql;
    $separator = ",";
    $extension = ".csv";
    $contest = str_replace(' ', '_', $_SESSION['contestName']);
    $contest = ltrim(filename($contest), "_");
    if ($filter == "default") {
        $type = "All_Participants";
    } else {
        $type = $filter;
    }
    if ($section == "loc") {
        $loc = str_replace(' ', '_', $row_judging['judgingLocName']);
        $loc = filename($loc);
    } else {
        $loc = "";
    }
    $date = date("Y-m-d");
    // Appropriately name the CSV file for each type of download
    if ($filter == "judges") {
        $filename = $contest . "_Assigned_Judge_Email_Addresses_" . $date . $loc . $extension;
    } elseif ($filter == "stewards") {
        $filename = $contest . "_Assigned_Steward_Email_Addresses_" . $date . $loc . $extension;
    } elseif ($filter == "staff") {
        $filename = $contest . "_Assigned_Staff_Email_Addresses_" . $date . $loc . $extension;
    } elseif ($filter == "avail_judges") {
        $filename = $contest . "_Available_Judge_Email_Addresses_" . $date . $loc . $extension;
    } elseif ($filter == "avail_stewards") {
        $filename = $contest . "_Available_Steward_Email_Addresses_" . $date . $loc . $extension;
开发者ID:dducrest,项目名称:brewcompetitiononlineentry,代码行数:31,代码来源:email_export.php


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