本文整理汇总了PHP中baseName函数的典型用法代码示例。如果您正苦于以下问题:PHP baseName函数的具体用法?PHP baseName怎么用?PHP baseName使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了baseName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load()
{
$queries = $this->path . '/queries.php';
$script = $this->path . '/script.php';
if (file_exists($queries)) {
$sql = null;
include $queries;
if (is_array($sql)) {
$this->queries = $sql;
}
}
if (file_exists($script)) {
include_once $script;
$suffix = str_replace('-', '_', baseName($this->path));
$class = 'Nano_Migrate_Script_' . $suffix;
if (class_exists($class, false)) {
$reflection = new ReflectionClass($class);
if ($reflection->isInstantiable() && $reflection->isSubclassOf('Nano_Migrate_Script')) {
$this->script = $reflection->newInstance();
} else {
$this->script = Nano_Migrate_ScriptEmpty::instance();
}
} else {
$this->script = Nano_Migrate_ScriptEmpty::instance();
}
} else {
$this->script = Nano_Migrate_ScriptEmpty::instance();
}
}
示例2: get_listing
public function get_listing($path = '', $page = '')
{
global $CFG, $OUTPUT;
$list = array();
$list['list'] = array();
// the management interface url
$list['manage'] = false;
// dynamically loading
$list['dynload'] = true;
// the current path of this list.
// set to true, the login link will be removed
$list['nologin'] = true;
// set to true, the search button will be removed
$list['nosearch'] = true;
$tree = array();
if (empty($path)) {
$buckets = $this->s->listBuckets();
foreach ($buckets as $bucket) {
$folder = array('title' => $bucket, 'children' => array(), 'thumbnail' => $OUTPUT->old_icon_url('f/folder-32'), 'path' => $bucket);
$tree[] = $folder;
}
} else {
$contents = $this->s->getBucket($path);
foreach ($contents as $file) {
$info = $this->s->getObjectInfo($path, baseName($file['name']));
$tree[] = array('title' => $file['name'], 'size' => $file['size'], 'date' => userdate($file['time']), 'source' => $path . '/' . $file['name'], 'thumbnail' => $OUTPUT->old_icon_url(file_extension_icon($file['name'], 32)));
}
}
$list['list'] = $tree;
return $list;
}
示例3: writeErrorToTempFile
static function writeErrorToTempFile($message)
{
global $configuration;
$tmpDir = sys_get_temp_dir();
$tmpFileName = tempnam($tmpDir, "PE-");
file_put_contents($tmpFileName, $message);
return baseName($tmpFileName);
}
示例4: InitRecordCall
function InitRecordCall($filename, $index, $comment)
{
//FIXME
$user = gs_user_get($_SESSION['sudo_user']['name']);
$call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: __record_file=" . $filename . "\n";
$filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
$cf = @fOpen($filename, 'wb');
if (!$cf) {
gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
echo 'Failed to write call file.';
die;
}
@fWrite($cf, $call, strLen($call));
@fClose($cf);
@chmod($filename, 0666);
$spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
$our_host_ids = @gs_get_listen_to_ids();
if (!is_array($our_host_ids)) {
$our_host_ids = array();
}
$user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
} else {
$user_is_on_this_host = true;
}
if ($user_is_on_this_host) {
# the Asterisk of this user and the web server both run on this host
$err = 0;
$out = array();
@exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
if ($err != 0) {
@unlink($filename);
gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
echo 'Failed to move call file.';
die;
}
} else {
$cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
//echo $cmd, "\n";
@exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
@unlink($filename);
if ($err != 0) {
gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
echo 'Failed to scp call file.';
die;
}
//remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
$cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
//echo $cmd, "\n";
@exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
if ($err != 0) {
gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
echo 'Failed to mv call file on remote host.';
die;
}
}
}
示例5: __construct
public function __construct($fileidentifier)
{
try {
$this->fullpath = $fileidentifier;
$this->name = baseName($fileidentifier);
$this->ext = strtolower(preg_replace('/^.*\\./', '', $this->name));
$this->relativePathHash = getFilePathHash($fileidentifier);
} catch (Exception $e) {
}
}
示例6: print_usage
function print_usage($options)
{
echo 'Usage: ' . baseName(__FILE__) . ' [options]' . "\n\t";
echo '-v : verbose mode - default is to be extremely silent' . "\n\t";
echo '-h : create html table and exit' . "\n\t";
echo '-w : set working directory - default: "/tmp/gen_prompts/' . "\n\t";
echo '-l : select output language(s) - default: "de,en"' . "\n\t";
echo '-e : select database engine - default: "file"' . "\n\t";
echo '-f : use CSV file as source' . "\n\t";
echo '-g : specify voice generator command - default: "mbrola {INFILE} {OUTFILE}"' . "\n\t";
echo '-s : specify output file suffixes - default: ".wav"' . "\n\n";
}
示例7: uploadFile
public function uploadFile($local_file, $remote_key = false, $private = true)
{
if ($private) {
$s3_acl = S3::ACL_PRIVATE;
} else {
$s3_acl = S3::ACL_PUBLIC_READ;
}
if (!$remote_key) {
$remote_key = baseName($local_file);
}
return $this->s3->putObjectFile($local_file, $this->bucket, $remote_key, $s3_acl);
}
示例8: _gs_ami_get_enabled
function _gs_ami_get_enabled()
{
$conf_files_enabled = array();
clearStatCache();
$files = glob('/etc/gemeinschaft/asterisk/manager.conf.d-enabled/*.conf');
foreach ($files as $filename) {
$filename_basename = baseName($filename);
$conf_files_enabled[] = $filename_basename;
}
unset($files);
return $conf_files_enabled;
}
示例9: __construct
public function __construct($exception)
{
$exceptionClass = get_class($exception);
if ($exceptionClass != 'ErrorException') {
$this->Message = $exceptionClass . ': ' . $exception->getMessage();
$this->BuildStackTrace($exception);
$this->ClassName = $exceptionClass;
} else {
$this->Message = 'Error: ' . $exception->getMessage();
$this->BuildErrorTrace($exception);
}
$this->FileName = baseName($exception->getFile());
}
示例10: amazonS3Upload
public static function amazonS3Upload($uploadFile, $prefix = "")
{
if (!$prefix && defined("AMAZON_DEFAULT_PREFIX")) {
$prefix = AMAZON_DEFAULT_PREFIX;
}
$configClass = APP_NAMESPACE . "\\config";
$s3 = $configClass::getAmazonS3();
$out = "";
if ($s3->putObjectFile($uploadFile, AMAZON_BUCKET_NAME, $prefix . baseName($uploadFile), \S3::ACL_PUBLIC_READ)) {
$out = AMAZON_BASE_PATH . $prefix . baseName($uploadFile);
}
return $out;
}
示例11: upload
public function upload()
{
if (!empty($this->_upload_dir)) {
$this->_bucket_name .= $this->_bucket_name . '/' . $this->_upload_dir;
}
// アマゾンS3のインスタンス生成
$s3 = new S3($this->_access_key, $this->_secret_key);
if (!$s3) {
throw new Teamlab_Batch_Exception(sprintf("AWS接続に失敗しました。: %s", $this->_bucket_name));
}
// ファイルアップロード
if ($s3->putObjectFile($this->_upload_file, $this->_bucket_name, baseName($this->_upload_file), S3::ACL_PUBLIC_READ)) {
return true;
} else {
throw new Teamlab_Batch_Transport_Exception(sprintf("ファイルのアップロードに失敗しました。サーバ情報:%s ファイル名:%s", $this->_bucket_name, baseName($this->_upload_file)));
}
}
示例12: put
public static function put($file, $type, $name = false)
{
global $globals;
if (!$name) {
$name = baseName($file);
}
if (empty($type)) {
$type = 'notype';
}
$uri = "{$type}/{$name}";
S3::setAuth($globals['Amazon_access_key'], $globals['Amazon_secret_key']);
if (S3::putObjectFile($file, $globals['Amazon_S3_media_bucket'], $uri, S3::ACL_PUBLIC_READ, array(), array("Cache-Control" => "max-age=864000", "Expires" => gmdate("D, d M Y H:i:s T", time() + 864000)))) {
//syslog(LOG_NOTICE, "Meneame, uploaded $uri to S3");
return true;
}
syslog(LOG_NOTICE, "Meneame, failed to upload {$uri} to S3");
return false;
}
示例13: fetch_vedio_url
function fetch_vedio_url($url)
{
$files = file_get_url($url);
$source_url = "";
if (strpos($url, 'www.tudou.com') !== false) {
if (strpos($url, '.html')) {
preg_match("/,iid: (\\w+)/i", $files, $items);
$iid = $items[1];
if (!empty($iid)) {
$source_url = "http://www.tudou.com/v/" . $iid . "/v.swf";
}
} else {
preg_match("/,iid: (\\w+)/i", $files, $items);
$iid = $items[1];
if (!empty($iid)) {
//$source_url=tudou_get($url);
$source_url = "http://www.tudou.com/v/" . $iid . "/v.swf";
} else {
$source_url = tudou_get($url);
}
}
} elseif (strpos($url, 'v.ku6.com') !== false) {
preg_match("/A.VideoInfo(.*)/i", $files, $context);
$context = $context[1];
//匹配网页中的内容\"bigpicpath\" 获取图片
//id:\s*\"([^,]+) 获取 视频ID ,"http://player.ku6.com/refer/$id/v.swf"
preg_match("/\"bigpicpath\":\"([^,]+)\"/i", $context, $items);
//json的UTF8 js编码
$pattner = array('\\u003a' => ':', '\\u002e' => '.');
$pic = $items[1];
if (!empty($pic)) {
preg_match("/id:\\s*\"([^,]+)\"/i", $context, $items);
$id = $items[1];
$source_url = "http://player.ku6.com/refer/{$id}/v.swf";
}
} elseif (strpos($url, 'v.youku.com') !== false) {
// preg_match("/videoId2=(.*)';/i",$files,$items);
// $videoId2=trim(str_replace('\'','',$items[1]));
// if(!empty($videoId2))
// $source_url="http://player.youku.com/player.php/sid/$videoId2/v.swf";
$source_url = preg_replace("/id_(.*)\\.html(.*)/i", "http://player.youku.com/embed/\${1}", baseName($url));
}
return $source_url;
}
示例14: wp_db_backup_completed
public static function wp_db_backup_completed(&$args)
{
$destination_s3 = get_option('wp_db_backup_destination_s3');
if (isset($destination_s3) && $destination_s3 == 1 && get_option('wpdb_dest_amazon_s3_bucket') && get_option('wpdb_dest_amazon_s3_bucket_key') && get_option('wpdb_dest_amazon_s3_bucket_secret')) {
try {
if (!class_exists('S3')) {
require_once 'S3.php';
}
// AWS access info
if (!defined('awsAccessKey')) {
define('awsAccessKey', get_option('wpdb_dest_amazon_s3_bucket_key'));
}
if (!defined('awsSecretKey')) {
define('awsSecretKey', get_option('wpdb_dest_amazon_s3_bucket_secret'));
}
// Check for CURL
if (!extension_loaded('curl') && !@dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
error_log("ERROR: CURL extension not loaded");
}
$s3 = new S3(awsAccessKey, awsSecretKey);
$bucketName = get_option('wpdb_dest_amazon_s3_bucket');
$result = $s3->listBuckets();
if (get_option('wpdb_dest_amazon_s3_bucket')) {
if (in_array(get_option('wpdb_dest_amazon_s3_bucket'), $result)) {
if ($s3->putObjectFile($args[1], $bucketName, baseName($args[1]), S3::ACL_PUBLIC_READ)) {
error_log("S3::{$args['0']} upload in bucket {$bucketName}");
$args[2] = $args[2] . '<br> Upload Database Backup on s3 bucket ' . $bucketName;
} else {
error_log("S3::Failed to upload {$args['0']}");
$args[2] = $args[2] . '<br>Failed to upload Database Backup on s3 bucket ' . $bucketName;
}
} else {
error_log("Invalid bucket name or AWS details");
$args[2] = $args[2] . '<br>Invalid bucket name or AWS details';
}
}
} catch (Exception $e) {
// echo ($e->getMessage());
error_log("Invalid AWS details");
}
}
}
示例15: gs_gen_ivr_pretty
function gs_gen_ivr_pretty($ext, $ivr, $name = 'main', $level = 0)
{
if (!is_array($ivr)) {
return '';
}
static $indentstr = ' ';
$indent = str_repeat($indentstr, $level * 2);
$ret = '';
if (is_array(@$ivr['dp'])) {
foreach ($ivr['dp'] as $step) {
if (!preg_match('/^([a-z]+)\\s+(.*)/', $step, $m)) {
continue;
}
$cmd = $m[1];
$cmddata = $m[2];
switch ($cmd) {
case 'play':
$ret .= $indent . "PLAY " . baseName($cmddata) . "\n";
break;
case 'app':
$ret .= $indent . "APP {$cmddata}\n";
break;
case 'hangup':
//$ret.= $indent. "(hangup)\n";
break;
}
}
}
if (!is_array(@$ivr['options'])) {
//$ret.= $indent. "(hangup)\n";
} else {
//$ret.= $indent. "(wait)\n";
foreach ($ivr['options'] as $newext => $newivr) {
$ret .= $indentstr . $indent . "\n";
//$ret.= $indentstr.$indent. $newext ."\n";
$ret .= $indentstr . $indent . str_pad($newext, 4, ' ') . ' ';
$ret2 = gs_gen_ivr_pretty($newext, $newivr, $name . "-" . str_replace(array('#', '*'), array('pound', 'star'), $newext), $level + 1);
$ret .= preg_replace('/^[ ]{' . (strLen($indentstr) * 2 + strLen($indent) - 3) . '}/', '', $ret2);
}
}
return $ret;
}