本文整理匯總了PHP中DIRNAME函數的典型用法代碼示例。如果您正苦於以下問題:PHP DIRNAME函數的具體用法?PHP DIRNAME怎麽用?PHP DIRNAME使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DIRNAME函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bootstrapScript
public function bootstrapScript($url = 'bootstrap.min.js', $options = array())
{
$pluginRoot = dirname(dirname(DIRNAME(__FILE__)));
$pluginName = end(explode(DS, $pluginRoot));
$url = '/' . Inflector::underscore($pluginName) . '/js/' . $url;
return parent::script($url, $options);
}
示例2: applyWrapper
protected static function applyWrapper($connection, $wrapper_name)
{
$wrapper_class = 'lmb' . ucfirst($wrapper_name) . 'CacheWrapper';
if (!class_exists($wrapper_class)) {
$file = DIRNAME(__FILE__) . '/wrappers/' . $wrapper_class . '.class.php';
if (!file_exists($file)) {
throw new lmbException("Cache wripper '{$wrapper_class}' file not found", array('dsn' => $dsn, 'name' => $wrapper_name, 'class' => $wrapper_class, 'file' => $file));
}
lmb_require($file);
}
return new $wrapper_class($connection);
}
示例3: run
/**
* Run validation
* @param array $data
* @param array $rules
* @return bool
*/
public function run($data, $rules = NULL)
{
// Optional rules
if ($rules !== NULL) {
// Add rules
if ($this->add_rules($rules) === FALSE) {
// Could not add rules
return FALSE;
}
}
// Set data to validate
$this->data = $data;
$this->rules = $rules;
error_log(print_r($rules, true), 3, DIRNAME(__FILE__) . '/rules.log');
// Rules are set
if (is_array($this->rules)) {
// Check fields
foreach ($this->rules as $k => $v) {
$this->check_field($k);
}
}
// Check if any errors were set
return !empty($this->error) ? $this->error : TRUE;
}
示例4: foreach
<?php
/* LOAD FUNCTION MODULES */
foreach (glob(dirname(__FILE__) . '/functions/*.php') as $filename) {
require_once $filename;
}
foreach (glob(dirname(__FILE__) . '/functions/**/*.php') as $filename) {
require_once $filename;
}
/* APPLICATION LOGIC */
require DIRNAME(__FILE__) . '/application.php';
/* LOAD APPLICATION MODULES */
foreach (glob(dirname(__FILE__) . '/application/*.php') as $filename) {
require_once $filename;
}
foreach (glob(dirname(__FILE__) . '/application/**/*.php') as $filename) {
require_once $filename;
}
示例5: __call
function __call($method, $params)
{
$this->status = null;
$this->error = null;
$this->raw_response = null;
$this->response = null;
// If no parameters are passed, this will be an empty array
$params = array_values($params);
// The ID should be unique for each call
$this->id++;
// Build the request, it's ok that params might have any empty array
$request = json_encode(array('method' => $method, 'params' => $params, 'id' => $this->id));
// Build the cURL session
$curl = curl_init("{$this->proto}://{$this->username}:{$this->password}@{$this->host}:{$this->port}/{$this->url}");
$options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_MAXREDIRS => 10, CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $request);
// This prevents users from getting the following warning when open_basedir is set:
// Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
if (ini_get('open_basedir')) {
unset($options[CURLOPT_FOLLOWLOCATION]);
}
if ($this->proto == 'https') {
// If the CA Certificate was specified we change CURL to look for it
if ($this->CACertificate != null) {
$options[CURLOPT_CAINFO] = $this->CACertificate;
$options[CURLOPT_CAPATH] = DIRNAME($this->CACertificate);
} else {
// If not we need to assume the SSL cannot be verified so we set this flag to FALSE to allow the connection
$options[CURLOPT_SSL_VERIFYPEER] = FALSE;
}
}
curl_setopt_array($curl, $options);
// Execute the request and decode to an array
$this->raw_response = curl_exec($curl);
$this->response = json_decode($this->raw_response, TRUE);
// If the status is not 200, something is wrong
$this->status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// If there was no error, this will be an empty string
$curl_error = curl_error($curl);
curl_close($curl);
if (!empty($curl_error)) {
$this->error = $curl_error;
}
if ($this->response['error']) {
// If gamecreditsd returned an error, put that in $this->error
$this->error = $this->response['error']['message'];
} elseif ($this->status != 200) {
// If gamecreditsd didn't return a nice error message, we need to make our own
switch ($this->status) {
case 400:
$this->error = 'HTTP_BAD_REQUEST';
break;
case 401:
$this->error = 'HTTP_UNAUTHORIZED';
break;
case 403:
$this->error = 'HTTP_FORBIDDEN';
break;
case 404:
$this->error = 'HTTP_NOT_FOUND';
break;
}
}
if ($this->error) {
return FALSE;
}
return $this->response['result'];
}
示例6: __call
function __call($method, $params)
{
$this->status = null;
$this->error = null;
$this->raw_response = null;
$this->response = null;
// The ID should be unique for each call
$this->id++;
// If no parameters are passed, this will be an empty array
if ($method == 'getblocktemplate') {
$param = $params[0];
$request = "{\"method\":\"{$method}\",\"params\":[{$param}],\"id\":{$this->id}}";
// debuglog($request);
} else {
$params = array_values($params);
// Build the request, it's ok that params might have any empty array
$request = json_encode(array('method' => $method, 'params' => $params, 'id' => $this->id));
}
// Build the cURL session
$curl = curl_init("{$this->proto}://{$this->username}:{$this->password}@{$this->host}:{$this->port}/{$this->url}");
$options = array(CURLOPT_CONNECTTIMEOUT => 20, CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_MAXREDIRS => 10, CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $request);
if ($this->proto == 'https') {
// If the CA Certificate was specified we change CURL to look for it
if ($this->CACertificate != null) {
$options[CURLOPT_CAINFO] = $this->CACertificate;
$options[CURLOPT_CAPATH] = DIRNAME($this->CACertificate);
} else {
// If not we need to assume the SSL cannot be verified so we set this flag to FALSE to allow the connection
$options[CURLOPT_SSL_VERIFYPEER] = FALSE;
}
}
curl_setopt_array($curl, $options);
// Execute the request and decode to an array
$this->raw_response = curl_exec($curl);
// debuglog($this->raw_response);
$this->response = json_decode($this->raw_response, TRUE);
// If the status is not 200, something is wrong
$this->status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// If there was no error, this will be an empty string
$curl_error = curl_error($curl);
curl_close($curl);
// debuglog($this->response);
if (!empty($curl_error)) {
$this->error = $curl_error;
}
if (isset($this->response['error']) && $this->response['error']) {
// If bitcoind returned an error, put that in $this->error
$this->error = strtolower($this->response['error']['message']);
} elseif ($this->status != 200) {
// If bitcoind didn't return a nice error message, we need to make our own
switch ($this->status) {
case 400:
$this->error = 'HTTP_BAD_REQUEST';
break;
case 401:
$this->error = 'HTTP_UNAUTHORIZED';
break;
case 403:
$this->error = 'HTTP_FORBIDDEN';
break;
case 404:
$this->error = 'HTTP_NOT_FOUND';
break;
}
}
if ($this->error) {
return FALSE;
}
return $this->response['result'];
}
示例7: DIRNAME
<?php
/**
* include FFmpeg class
**/
include DIRNAME(DIRNAME(__FILE__)) . '/src/ffmpeg.class.php';
/**
* get options from database
**/
$options = array('duration' => 99, 'position' => 0, 'itsoffset' => 2);
/**
* Create command
*/
$FFmpeg = new FFmpeg('/usr/local/bin/ffmpeg');
$FFmpeg->input('/var/media/original.avi');
$FFmpeg->transpose(0)->vflip()->grayScale()->vcodec('h264')->frameRate('30000/1001');
$FFmpeg->acodec('aac')->audioBitrate('192k');
foreach ($options as $option => $values) {
$FFmpeg->call($option, $values);
}
$FFmpeg->output('/var/media/new.mp4', 'mp4');
print $FFmpeg->command;
示例8: chdir
$g_ignore_weights = true;
} else {
if ($arg == "--no-drop-db") {
$locals['no_drop_db'] = true;
} else {
if ($arg == "--keep-all") {
$locals['keep_all'] = true;
} else {
if ($arg == "--no-demo") {
$g_skipdemo = true;
} else {
if ($arg == "--no-marks") {
$g_usemarks = false;
} else {
if ($arg == "--cwd") {
chdir(DIRNAME(__FILE__));
} else {
if (is_dir($arg)) {
$test_dirs[] = $arg;
} else {
if (preg_match("/^(\\d+)-(\\d+)\$/", $arg, $range)) {
$test_range = array($range[1], $range[2]);
// from, to
} else {
if (preg_match("/^(\\d+):(\\d+)\$/", $arg, $range)) {
// FIXME! lockdown gen model, only keep test mode
// FIXME! lockdown $test_dirs from here, and check it for emptiness
// ie. make sure there are NO other test arguments when this syntax is in use
$test_dirs = array(sprintf("test_%03d", $range[1]));
$g_pick_query = (int) $range[2];
} else {
示例9: define
<?php
define('MENU_STAFF', true);
require_once DIRNAME(__DIR__) . '/includes/globals.php';
require_once DIRNAME(__DIR__) . '/includes/class/class_mtg_paginate.php';
$pages = new Paginator();
$_SESSION['staff_authed_time'] = time() + 900;
$_GET['pull'] = isset($_GET['pull']) && ctype_alpha(str_replace('.php', '', $_GET['pull'])) ? str_replace('.php', '', $_GET['pull']) : null;
$file = empty($_GET['pull']) ? 'index.php' : $_GET['pull'] . '.php';
$path = __DIR__ . '/pull/' . $file;
if (file_exists($path)) {
require_once $path;
} else {
$mtg->error('Invalid pull request' . ($users->hasAccess('override_all') ? ' - ' . $path : ''));
}
示例10: DIRNAME
<?php
namespace JBBCode\visitors;
require_once DIRNAME(__DIR__) . '/CodeDefinition.php';
require_once DIRNAME(__DIR__) . '/DocumentElement.php';
require_once DIRNAME(__DIR__) . '/ElementNode.php';
require_once DIRNAME(__DIR__) . '/NodeVisitor.php';
require_once DIRNAME(__DIR__) . '/TextNode.php';
/**
* This visitor is used by the jBBCode core to enforce nest limits after
* parsing. It traverses the parse graph depth first, removing any subtrees
* that are nested deeper than an element's code definition allows.
*
* @author jbowens
* @since May 2013
*/
class NestLimitVisitor implements \JBBCode\NodeVisitor
{
protected $depth = array();
/* A map from tag name to current depth. */
public function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
{
foreach ($documentElement->getChildren() as $child) {
$child->accept($this);
}
}
public function visitTextNode(\JBBCode\TextNode $textNode)
{
/* Nothing to do. Text nodes don't have tag names or children. */
}
示例11: error_reporting
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
DEFINE('SMARTY_ROOT', DIRNAME(__FILE__) . '/../_smarty');
DEFINE('CONTENT_ROOT', DIRNAME(__FILE__) . '/../_content');
DEFINE('CURRENT_THEME', 'cogsci');
示例12: DIRNAME
<?php
require 'php-dpa-parser/parser.php';
$dirname = DIRNAME(__FILE__);
foreach (glob("{$dirname}/php-dpa-parser/result/*.php") as $file) {
require $file;
}
foreach (glob("{$dirname}/php-dpa-parser/result/media/*.php") as $file) {
require $file;
}
foreach (glob("{$dirname}/php-dpa-parser/result/content/*.php") as $file) {
require $file;
}
foreach (glob("{$dirname}/php-dpa-parser/result/content/media/*.php") as $file) {
require $file;
}
示例13: explode
<?php
/**
* 2013-7-6 13:41:44
* @author x.li
* @abstract 入口文件
*/
$arr = explode('/', $_SERVER['PHP_SELF']);
$root_dir = $arr[1];
// 站點物理路徑
defined("HOME_REAL_PATH") || define("HOME_REAL_PATH", $_SERVER['DOCUMENT_ROOT'] . '/' . $root_dir);
// 站點根目錄
defined("HOME_PATH") || define("HOME_PATH", 'http://' . $_SERVER['HTTP_HOST'] . '/' . $root_dir);
// 應用根目錄
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// 第三方庫目錄
defined("LIBRARY_PATH") || define("LIBRARY_PATH", realpath(DIRNAME(__FILE__) . "/../library"));
// 站點配置文件目錄
defined("CONFIGS_PATH") || define("CONFIGS_PATH", REALPATH(APPLICATION_PATH . "/configs"));
// 默認以調試方式運行
defined("APPLICATION_ENV") || define("APPLICATION_ENV", getenv("APPLICATION_ENV") ? getenv("APPLICATION_ENV") : "development");
set_include_path(implode(PATH_SEPARATOR, array(realpath(LIBRARY_PATH), get_include_path())));
// 自動加載library/Evolve目錄下的文件
require_once LIBRARY_PATH . "/Evolve/ClassLoader.php";
// 常量
require_once CONFIGS_PATH . "/Constant.php";
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, CONFIGS_PATH . "/application.ini");
$application->bootstrap()->run();
示例14: __construct
//.........這裏部分代碼省略.........
- MTG Codes v9</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css" />
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-min.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="css/layouts/side-menu-old-ie.css" />
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-old-ie-min.css" />
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="css/layouts/side-menu.css" />
<!--<![endif]-->
<style type='text/css'>
.center {
text-align:center;
}
</style>
<link rel="stylesheet" type="text/css" href="css/message.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
</head>
<body>
<div id="layout">
<a href="#menu" id="menuLink" class="menu-link"><span> </span></a>
<div id="menu">
<div class="userinfo">
<ul class="pure-menu-list">
<li class="pure-menu-item"><?php
echo $users->name($my['id'], true);
?>
</li>
<li class="pure-menu-item"><strong>Money:</strong> <?php
echo $set['main_currency_symbol'] . $mtg->format($my['money']);
?>
</li>
<li class="pure-menu-item"><strong>Level:</strong> <?php
echo $mtg->format($my['level']);
?>
</li>
<li class="pure-menu-item"><strong>Points:</strong> <?php
echo $mtg->format($my['points']);
?>
</li>
<li class="pure-menu-item"><strong>Merits:</strong> <?php
echo $mtg->format($my['merits']);
?>
</li>
</ul><hr />
<ul class="pure-menu-list">
<li class="pure-menu-item">Energy: <?php
echo $my['energy'] . '/' . $my['energy_max'];
?>
</li>
<li class="pure-menu-item">Nerve: <?php
echo $my['nerve'] . '/' . $my['nerve_max'];
?>
</li>
<li class="pure-menu-item">Happy: <?php
echo $my['happy'] . '/' . $my['happy_max'];
?>
</li>
<li class="pure-menu-item">Life: <?php
echo $my['health'] . '/' . $my['health_max'];
?>
</li>
<li class="pure-menu-item">Exp: <?php
echo $mtg->format($my['exp'], 2) . '/' . $users->expRequired(true);
?>
</li>
</ul>
</div>
<div class="pure-menu"><?php
if (!defined('MENU_ENABLE')) {
define('MENU_ENABLE', true);
}
require_once defined('MENU_STAFF') ? DIRNAME(__DIR__) . '/staff/menu.php' : __DIR__ . '/menu.php';
?>
</div>
</div>
<div id="main">
<div class="header">
<div class="logo"> </div><?php
if (defined('HEADER_TEXT')) {
echo '<h3>', HEADER_TEXT, '</h3>';
}
?>
</div>
<div class="content"><?php
if (array_key_exists('action', $_GET) && $_GET['action'] == 'logout') {
session_unset();
session_destroy();
session_start();
$_SESSION['msg'] = ['type' => 'success', 'content' => 'You\'ve logged out. Come back soon!'];
exit(header('Location: index.php'));
}
if ($my['hospital']) {
echo '<strong>Nurse:</strong> You\'re currently in hospital for ' . $mtg->time_format($my['hospital'] * 60) . '.<br />';
}
if ($my['jail']) {
echo '<strong>Officer:</strong> You\'re currently in jail for ' . $mtg->time_format($my['jail'] * 60) . '.<br />';
}
}
示例15: csyn_main_menu
function csyn_main_menu()
{
if (function_exists('add_menu_page')) {
add_menu_page('CyberSyn', 'CyberSyn', 'add_users', DIRNAME(__FILE__) . '/cybersyn-options.php');
add_submenu_page(DIRNAME(__FILE__) . '/cybersyn-options.php', 'CyberSyn RSS/Atom Syndicator', 'RSS/Atom Syndicator', 'add_users', DIRNAME(__FILE__) . '/cybersyn-syndicator.php');
}
}