本文整理汇总了PHP中is_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP is_dir函数的具体用法?PHP is_dir怎么用?PHP is_dir使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: command_dd
function command_dd()
{
$args = func_get_args();
$options = $this->get_options();
$dd = kernel::single('dev_docbuilder_dd');
if (empty($args)) {
$dd->export();
} else {
foreach ($args as $app_id) {
$dd->export_tables($app_id);
}
}
if ($filename = $options['result-file']) {
ob_start();
$dd->output();
$out = ob_get_contents();
ob_end_clean();
if (!is_dir(dirname($filename))) {
throw new Exception('cannot find the ' . dirname($filename) . 'directory');
} elseif (is_dir($filename)) {
throw new Exception('the result-file path is a directory.');
}
file_put_contents($options['result-file'], $out);
echo 'data dictionary doc export success.';
} else {
$dd->output();
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getArgument('path');
if (!file_exists($path)) {
$output->writeln("{$path} is not a file or a path");
}
$filePaths = [];
if (is_file($path)) {
$filePaths = [realpath($path)];
} elseif (is_dir($path)) {
$filePaths = array_diff(scandir($path), array('..', '.'));
} else {
$output->writeln("{$path} is not known.");
}
$generator = new StopwordGenerator($filePaths);
if ($input->getArgument('type') === 'json') {
echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
echo json_last_error_msg();
die;
$output->write(json_encode($this->toArray($generator->getStopwords())));
} else {
$stopwords = $generator->getStopwords();
$stdout = fopen('php://stdout', 'w');
echo 'token,freq' . PHP_EOL;
foreach ($stopwords as $token => $freq) {
fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
}
fclose($stdout);
}
}
示例3: save
/**
* Save an uploaded file to a new location.
*
* @param mixed name of $_FILE input or array of upload data
* @param string new filename
* @param string new directory
* @param integer chmod mask
* @return string full path to new file
*/
public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0755)
{
// Load file data from FILES if not passed as array
$file = is_array($file) ? $file : $_FILES[$file];
if ($filename === NULL) {
// Use the default filename, with a timestamp pre-pended
$filename = time() . $file['name'];
}
// Remove spaces from the filename
$filename = preg_replace('/\\s+/', '_', $filename);
if ($directory === NULL) {
// Use the pre-configured upload directory
$directory = WWW_ROOT . 'files/';
}
// Make sure the directory ends with a slash
$directory = rtrim($directory, '/') . '/';
if (!is_dir($directory)) {
// Create the upload directory
mkdir($directory, 0777, TRUE);
}
//if ( ! is_writable($directory))
//throw new exception;
if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
if ($chmod !== FALSE) {
// Set permissions on filename
chmod($filename, $chmod);
}
//$all_file_name = array(FILE_INFO => $filename);
// Return new file path
return $filename;
}
return FALSE;
}
示例4: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - file: The file path or a php wrapper to log messages
* You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
* - format: The log line format (default to %time% %type% [%priority%] %message%%EOL%)
* - time_format: The log time strftime format (default to %b %d %H:%M:%S)
* - dir_mode: The mode to use when creating a directory (default to 0777)
* - file_mode: The mode to use when creating a file (default to 0666)
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
if (!isset($options['file'])) {
throw new sfConfigurationException('You must provide a "file" parameter for this logger.');
}
if (isset($options['format'])) {
$this->format = $options['format'];
}
if (isset($options['time_format'])) {
$this->timeFormat = $options['time_format'];
}
if (isset($options['type'])) {
$this->type = $options['type'];
}
$dir = dirname($options['file']);
if (!is_dir($dir)) {
mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true);
}
$fileExists = file_exists($options['file']);
if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) {
throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file']));
}
$this->fp = fopen($options['file'], 'a');
if (!$fileExists) {
chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666);
}
return parent::initialize($dispatcher, $options);
}
示例5: createPath
protected function createPath()
{
$fullPath = dirname($this->fullFilePath());
if (!is_dir($fullPath)) {
mkdir($fullPath, 0755, true);
}
}
示例6: initialize
/**
* Initialize the provider
*
* @return void
*/
public function initialize()
{
$this->options = array_merge($this->defaultConfig, $this->options);
date_default_timezone_set($this->options['log.timezone']);
// Finally, create a formatter
$formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false);
// Create a new directory
$logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path'];
if (!is_dir($logPath)) {
mkdir($logPath, 0755);
}
// Create a handler
$stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log');
// Set our formatter
$stream->setFormatter($formatter);
// Create LogWriter
$logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor())));
// Bind our logger to Bono Container
$this->app->container->singleton('log', function ($c) {
$log = new Log($c['logWriter']);
$log->setEnabled($c['settings']['log.enabled']);
$log->setLevel($c['settings']['log.level']);
$env = $c['environment'];
$env['slim.log'] = $log;
return $log;
});
// Set the writer
$this->app->config('log.writer', $logger);
}
示例7: __invoke
public function __invoke($ctx)
{
if (isset($ctx['Directory']['path'])) {
$path = $ctx['Directory']['path'];
} else {
$url = $ctx['env']['PATH_INFO'];
if (strpos($url, '..') !== false) {
return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
}
$path = $this->path . $url;
}
// Sanity checks
if (!file_exists($path)) {
return array(404, array('Content-Type', 'text/plain'), 'File not found');
}
$path = realpath($path);
if (false === $path) {
// resolving failed. not enough rights for intermediate folder?
return array(404, array('Content-Type', 'text/plain'), 'File not found');
}
if (strpos($path, $this->path) !== 0) {
// gone out of "chroot"?
return array(404, array('Content-Type', 'text/plain'), 'File not found');
}
if (!is_readable($path)) {
return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
}
// Only files are served
if (is_dir($path)) {
return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
}
return $this->serve($path);
}
示例8: checkSkinStyles
/**
*
*/
public function checkSkinStyles($name, $values)
{
$config = Zend_Registry::get('config');
$basePath = $config->design->pathToSkins;
$xhtml = array();
$this->view->name = $name;
$this->view->selectedStyles = $values;
//load the skin folders
if (is_dir('./' . $basePath)) {
$folders = Digitalus_Filesystem_Dir::getDirectories('./' . $basePath);
if (count($folders) > 0) {
foreach ($folders as $folder) {
$this->view->skin = $folder;
$styles = Digitalus_Filesystem_File::getFilesByType('./' . $basePath . '/' . $folder . '/styles', 'css');
if (is_array($styles)) {
foreach ($styles as $style) {
//add each style sheet to the hash
// key = path / value = filename
$hashStyles[$style] = $style;
}
$this->view->styles = $hashStyles;
$xhtml[] = $this->view->render($this->partialFile);
unset($hashStyles);
}
}
}
} else {
throw new Zend_Acl_Exception('Unable to locate skin folder');
}
return implode(null, $xhtml);
}
示例9: bootstrap
protected function bootstrap()
{
if (is_file('package.json')) {
$this->comment(' -> Installing npm dependencies (with yarn)...');
$this->executeCommand($this->input->getOption('sudo') ? 'sudo yarn' : 'yarn');
}
if (is_file('bower.json')) {
$this->comment(' -> Installing bower dependencies...');
$this->executeCommand('bower install');
}
if (is_file('composer.json')) {
$this->comment(' -> Installing composer dependencies...');
$this->executeCommand('composer install');
}
if (is_dir('storage')) {
$this->comment(' -> Dando permissão de escrita no diretório storage...');
$this->executeCommand('chmod -R 777 storage');
}
if (is_dir('app/storage')) {
$this->comment(' -> Dando permissão de escrita no diretório storage...');
$this->executeCommand('chmod -R 777 app/storage');
}
if (is_file('.env.example')) {
$this->comment(' -> Criando o arquivo .env');
$this->executeCommand('cp .env.example .env');
}
}
示例10: __construct
function __construct(array $config = array())
{
$this->_config =& $config;
// Try to locate app folder.
if (!isset($config['app_dir'])) {
$cwd = getcwd();
while (!is_dir("{$cwd}/app")) {
if ($cwd == dirname($cwd)) {
throw new \LogicException('/app folder not found.');
}
$cwd = dirname($cwd);
}
$config['app_dir'] = "{$cwd}/app";
}
$is_web_request = isset($_SERVER['SERVER_NAME']);
$config += array('debug' => !$is_web_request || $_SERVER['SERVER_NAME'] == 'localhost', 'register_exception_handler' => $is_web_request, 'register_error_handler' => $is_web_request, 'core_dir' => __DIR__ . '/../..', 'data_dir' => "{$config['app_dir']}/../data");
$this->exception_handler = new ExceptionHandler($this->debug);
if ($this->register_exception_handler) {
set_exception_handler(array($this->exception_handler, 'handle'));
}
if ($this->register_error_handler) {
$this->errorHandler = \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
}
foreach (array($config['data_dir'], "{$config['data_dir']}/cache", "{$config['data_dir']}/logs") as $dir) {
if (!is_dir($dir)) {
mkdir($dir);
}
}
}
示例11: getAllClassNames
public function getAllClassNames()
{
if (null === $this->classCache) {
$this->initialize();
}
$classes = array();
if ($this->paths) {
foreach ((array) $this->paths as $path) {
if (!is_dir($path)) {
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iterator as $file) {
$fileName = $file->getBasename($this->fileExtension);
if ($fileName == $file->getBasename() || $fileName == $this->globalBasename) {
continue;
}
// NOTE: All files found here means classes are not transient!
if (isset($this->prefixes[$path])) {
$classes[] = $this->prefixes[$path] . '\\' . str_replace('.', '\\', $fileName);
} else {
$classes[] = str_replace('.', '\\', $fileName);
}
}
}
}
return array_merge($classes, array_keys($this->classCache));
}
示例12: __construct
function __construct($name)
{
$this->folder = TEMP_FOLDER . '/' . $name;
if (!is_dir($this->folder)) {
mkdir($this->folder);
}
}
示例13: submitInfo
public function submitInfo()
{
$this->load->model("settings_model");
// Gather the values
$values = array('nickname' => htmlspecialchars($this->input->post("nickname")), 'location' => htmlspecialchars($this->input->post("location")));
// Change language
if ($this->config->item('show_language_chooser')) {
$values['language'] = $this->input->post("language");
if (!is_dir("application/language/" . $values['language'])) {
die("3");
} else {
$this->user->setLanguage($values['language']);
$this->plugins->onSetLanguage($this->user->getId(), $values['language']);
}
}
// Remove the nickname field if it wasn't changed
if ($values['nickname'] == $this->user->getNickname()) {
$values = array('location' => $this->input->post("location"));
} elseif (strlen($values['nickname']) < 4 || strlen($values['nickname']) > 14 || !preg_match("/[A-Za-z0-9]*/", $values['nickname'])) {
die(lang("nickname_error", "ucp"));
} elseif ($this->internal_user_model->nicknameExists($values['nickname'])) {
die("2");
}
if (strlen($values['location']) > 32 && !ctype_alpha($values['location'])) {
die(lang("location_error", "ucp"));
}
$this->settings_model->saveSettings($values);
$this->plugins->onSaveSettings($this->user->getId(), $values);
die("1");
}
示例14: getPoint
/**
* @brief Get the points
*/
function getPoint($member_srl, $from_db = false)
{
$member_srl = abs($member_srl);
// Get from instance memory
if (!$from_db && $this->pointList[$member_srl]) {
return $this->pointList[$member_srl];
}
// Get from file cache
$path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
if (!$from_db && file_exists($cache_filename)) {
return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
}
// Get from the DB
$args = new stdClass();
$args->member_srl = $member_srl;
$output = executeQuery('point.getPoint', $args);
if (isset($output->data->member_srl)) {
$point = (int) $output->data->point;
$this->pointList[$member_srl] = $point;
if (!is_dir($path)) {
FileHandler::makeDir($path);
}
FileHandler::writeFile($cache_filename, $point);
return $point;
}
return 0;
}
示例15: createSymbolicLink
public static function createSymbolicLink($rootDir = null)
{
IS_MULTI_MODULES || exit('please set is_multi_modules => true');
$deper = Request::isCli() ? PHP_EOL : '<br />';
echo "{$deper}**************************create link start!*********************{$deper}";
echo '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
is_null($rootDir) && ($rootDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web');
is_dir($rootDir) || mkdir($rootDir, true, 0700);
//modules_static_path_name
// 递归遍历目录
$dirIterator = new \DirectoryIterator(APP_MODULES_PATH);
foreach ($dirIterator as $file) {
if (!$file->isDot() && $file->isDir()) {
$resourceDir = $file->getPathName() . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name');
if (is_dir($resourceDir)) {
$distDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $file->getFilename();
$cmd = Request::operatingSystem() ? "mklink /d {$distDir} {$resourceDir}" : "ln -s {$resourceDir} {$distDir}";
exec($cmd, $result);
$tip = "create link Application [{$file->getFilename()}] result : [" . (is_dir($distDir) ? 'true' : 'false') . "]";
$tip = str_pad($tip, 64, ' ', STR_PAD_BOTH);
print_r($deper . '|' . $tip . '|');
}
}
}
echo $deper . '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
echo "{$deper}****************************create link end!**********************{$deper}";
}