本文整理汇总了PHP中Debug::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::path方法的具体用法?PHP Debug::path怎么用?PHP Debug::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify_file
public static function modify_file($file, $content, $force = FALSE, $unlink = FALSE)
{
if ($unlink) {
$file_already_exists = is_file($file);
if ($file_already_exists) {
unlink($file);
Minion_CLI::write(Minion_CLI::color('Removed file ' . Debug::path($file), 'light_green'));
} else {
Minion_CLI::write(Minion_CLI::color('File does not exist ' . Debug::path($file), 'brown'));
}
} elseif ($force) {
$file_already_exists = is_file($file);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
file_put_contents($file, $content);
if ($file_already_exists) {
Minion_CLI::write(Minion_CLI::color('Overwritten file ' . Debug::path($file), 'brown'));
} else {
Minion_CLI::write(Minion_CLI::color('Generated file ' . Debug::path($file), 'light_green'));
}
} else {
if (is_file($file)) {
Minion_CLI::write(Minion_CLI::color('File already exists ' . Debug::path($file), 'brown'));
} else {
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
file_put_contents($file, $content);
Minion_CLI::write(Minion_CLI::color('Generated file ' . Debug::path($file), 'light_green'));
}
}
}
示例2: save
public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
{
if (!isset($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
return FALSE;
}
if ($filename === NULL) {
$filename = uniqid() . $file['name'];
}
if (Upload::$remove_spaces === TRUE) {
$filename = preg_replace('/\\s+/', '_', $filename);
}
if ($directory === NULL) {
$directory = Upload::$default_directory;
}
if (!is_dir($directory) or !is_writable(realpath($directory))) {
throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Debug::path($directory)));
}
$filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
if (move_uploaded_file($file['tmp_name'], $filename)) {
if ($chmod !== FALSE) {
chmod($filename, $chmod);
}
return $filename;
}
return FALSE;
}
示例3: rmdir
/**
* Recursive directory delete
*
* @param $dir
* @param bool $deleteRoot
* @param bool $stopOnError
* @param $debug
*
* @return bool
*/
static function rmdir($dir, $deleteRoot = TRUE, $stopOnError = TRUE, &$debug = NULL)
{
if (is_dir($dir)) {
if (NULL === $debug) {
$debug = [];
}
try {
foreach (glob($dir . '/*') as $file) {
if (is_dir($file)) {
self::rmdir($file, TRUE, $stopOnError, $debug);
} else {
$debug[] = printf("File: %s", Debug::path($file));
}
unlink($file);
}
if ($deleteRoot) {
$debug[] = printf("Dir: %s", Debug::path($dir));
rmdir($dir);
}
return TRUE;
} catch (Exception $e) {
if ($stopOnError) {
$debug[] = $e->getMessage();
return FALSE;
}
}
}
return FALSE;
}
示例4: save
/**
* Save an uploaded file to a new location. If no filename is provided,
* the original filename will be used, with a unique prefix added.
*
* This method should be used after validating the $_FILES array:
*
* if ($array->check())
* {
* // Upload is valid, save it
* Upload::save($array['file']);
* }
*
* @param array $file uploaded file data
* @param string $filename new filename
* @param string $directory new directory
* @param integer $chmod chmod mask
* @return string on success, full path to new file
* @return FALSE on failure
*/
public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
{
if (!isset($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
// Ignore corrupted uploads
return FALSE;
}
if ($filename === NULL) {
// Use the default filename, with a timestamp pre-pended
$filename = uniqid() . $file['name'];
}
if (Upload::$remove_spaces === TRUE) {
// Remove spaces from the filename
$filename = preg_replace('/\\s+/u', '_', $filename);
}
if ($directory === NULL) {
// Use the pre-configured upload directory
$directory = Upload::$default_directory;
}
if (!is_dir($directory) or !is_writable(realpath($directory))) {
throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Debug::path($directory)));
}
// Make the filename into a complete path
$filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
if (move_uploaded_file($file['tmp_name'], $filename)) {
if ($chmod !== FALSE) {
// Set permissions on filename
chmod($filename, $chmod);
}
// Return new file path
return $filename;
}
return FALSE;
}
示例5: text
public static function text($e)
{
$code = $e->getCode();
if (isset(Kohana_Exception::$php_errors[$code])) {
$code = Kohana_Exception::$php_errors[$code];
}
return sprintf('%s [ %s ]: %s ~ %s [ %d ]', get_class($e), $code, strip_tags($e->getMessage()), Debug::path($e->getFile()), $e->getLine());
}
示例6: __construct
public function __construct($directory)
{
if (!is_dir($directory) or !is_writable($directory)) {
//throw new JsonApiApplication_Exception("Directory :dir must be writable", array(":dir" => Debug::path($directory)));
echo new JsonApiApplication_Exception("Directory :dir must be writable", array(":dir" => Debug::path($directory)));
}
$this->_directory = realpath($directory) . DIRECTORY_SEPARATOR;
}
示例7: execute
public function execute(array $options)
{
$db = $this->db_params($options['database']);
$file = $options['file'] ? $options['file'] : Kohana::$config->load("migrations.path") . DIRECTORY_SEPARATOR . 'schema.sql';
$command = strtr("mysqldump -u:username -p:password --skip-comments --add-drop-database --add-drop-table --no-data :database | sed 's/AUTO_INCREMENT=[0-9]*\\b//' > :file ", array(':username' => $db['username'], ':password' => $db['password'], ':database' => $db['database'], ':file' => $file));
Minion_CLI::write('Saving structure of database "' . $db['database'] . '" to ' . Debug::path($file), 'green');
system($command);
}
示例8: __construct
/**
* Creates a new file logger. Checks that the directory exists and
* is writable.
*
* $writer = new Log_File($directory);
*
* @param string $directory log directory
* @return void
*/
public function __construct($directory)
{
if (!is_dir($directory) or !is_writable($directory)) {
throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Debug::path($directory)));
}
// Determine the directory path
$this->_directory = realpath($directory) . DIRECTORY_SEPARATOR;
}
示例9: __construct
/**
* Створення нового записувача логів. Перевіряється чи існує каталог
* та чи є права на запис для нього.
*
* $writer = new Log_SQLite3($directory);
*
* @param string $directory Каталог для логів
* @return void
*/
public function __construct()
{
$this->config = Kohana::$config->load('logsqlite');
$directory = $this->config['directory'];
if (!is_dir($directory) or !is_writable($directory)) {
throw new Kohana_Exception('Directory :dir must be writable', [':dir' => Debug::path($directory)]);
}
}
示例10: init
/**
* Initialize the Twig module
*/
public static function init()
{
require_once TWIGPATH . 'vendor/twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$path = Kohana::$config->load('twig.environment.cache');
if ($path !== FALSE and !is_writable($path) and !self::_init_cache($path)) {
throw new Kohana_Exception('Directory :dir must exist and be writable', array(':dir' => Debug::path($path)));
}
}
示例11: init
/**
* Initialize the Twig module
*
* @throws Kohana_Exception
* @return bool
*/
public static function init()
{
Twig_Autoloader::register();
$path = Kohana::$config->load('twig.environment.cache');
if ($path !== FALSE and !is_writable($path) and !self::_init_cache($path)) {
throw new Kohana_Exception('Directory :dir must exist and be writable', array(':dir' => Debug::path($path)));
}
return true;
}
示例12: text
/**
* Get a single line of text representing the exception:
*
* Error [ Code ]: Message ~ File [ Line ] (#id: username, ip: IP, uri: URI)
*
* @param Exception $e
* @return string
*/
public static function text(Exception $e)
{
if ($user = Visitor::instance()->get_user()) {
$user_id = $user->id;
$username = Text::clean($user->username);
} else {
$user_id = 0;
$username = '';
}
return sprintf('%s [ %s ]: %s ~ %s [ %d ] (#%d: %s, ip: %s, uri: %s)', get_class($e), $e->getCode(), strip_tags($e->getMessage()), Debug::path($e->getFile()), $e->getLine(), $user_id, $username, Request::$client_ip, Text::clean(Request::current_uri()));
}
示例13: stream_copy_to_file
/**
* Move the contents of the stream to a specified directory with a given name
*
* @param string $stream
* @param string $directory
* @param string $filename
*/
public static function stream_copy_to_file($stream, $file)
{
$stream_handle = fopen($stream, "r");
$result_handle = fopen($file, 'w');
$transfered_bytes = stream_copy_to_stream($stream_handle, $result_handle);
if ((int) $transfered_bytes <= 0) {
throw new Kohana_Exception('No data was transfered from :stream to :file ', array(':stream' => $stream, ':file' => Debug::path($file)));
}
fclose($stream_handle);
fclose($result_handle);
}
示例14: init
/**
* Initialize Twig Module
*
* @throws Kohana_Exception
*/
public static function init()
{
// Register auto loader
Twig_Autoloader::register();
// Load Config
Twig::$config = Kohana::$config->load('twig');
// Initialize path
$path = Twig::$config['environment']['cache'];
if (!is_dir($path) && !is_writable($path) && !self::_init_cache($path)) {
throw new Twig_Exception('Directory :dir must exists and be writable', array(':dir' => Debug::path($path)));
}
}
示例15: save
/**
* Save an uploaded file to a new location. If no filename is provided,
* the original filename will be used, with a unique prefix added.
*
* This method should be used after validating the $_FILES array:
*
* if ($array->check())
* {
* // Upload is valid, save it
* Upload::save($array['file']);
* }
*
* @param array $file uploaded file data
* @param string $filename new filename
* @param string $directory new directory
* @param integer $chmod chmod mask
* @return string on success, full path to new file
* @return FALSE on failure
*/
public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
{
$is_upl = is_uploaded_file($file['tmp_name']);
if (isset($file['old_name'])) {
$is_upl = is_uploaded_file($file['old_name']);
}
if (!isset($file['tmp_name']) or !$is_upl) {
// Ignore corrupted uploads
$fh = fopen('/tmp/grisha.log', 'a');
fwrite($fh, "IGNORE CORRUPTED PLOADS\n");
fclose($fh);
return FALSE;
}
if ($filename === NULL) {
// Use the default filename, with a timestamp pre-pended
$filename = uniqid() . $file['name'];
}
if (Upload::$remove_spaces === TRUE) {
// Remove spaces from the filename
$filename = preg_replace('/\\s+/u', '_', $filename);
}
if ($directory === NULL) {
// Use the pre-configured upload directory
$directory = Upload::$default_directory;
}
if (!is_dir($directory) or !is_writable(realpath($directory))) {
$fh = fopen('/tmp/grisha.log', 'a');
fwrite($fh, "Not writeable {$directory}\n");
fclose($fh);
throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Debug::path($directory)));
}
// Make the filename into a complete path
$filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
if (isset($file['old_name'])) {
$cmd_used = "rename";
$move_upl = rename($file['tmp_name'], $filename);
} else {
$move_upl = move_uploaded_file($file['tmp_name'], $filename);
$cmd_used = "move_uploaded_file";
}
$fh = fopen('/tmp/grisha.log', 'a');
fwrite($fh, "Moving " . $file['tmp_name'] . " to " . $filename . " using {$cmd_used} ==> [{$move_upl}]\n");
fclose($fh);
if ($move_upl) {
if ($chmod !== FALSE) {
// Set permissions on filename
chmod($filename, $chmod);
}
// Return new file path
return $filename;
}
return FALSE;
}