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


PHP Dir::scan方法代码示例

本文整理汇总了PHP中Dir::scan方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::scan方法的具体用法?PHP Dir::scan怎么用?PHP Dir::scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dir的用法示例。


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

示例1: scan

 public static function scan($path, $recursive = true, $excludeDir = true)
 {
     $path = self::formatPath($path);
     $dh = opendir($path);
     if (!$dh) {
         return [];
     }
     $files = [];
     while (false !== ($file = readdir($dh))) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         $fileType = filetype($path . $file);
         if ('file' == $fileType) {
             $files[] = $path . $file;
         }
         if ('dir' == $fileType) {
             if (true === $recursive) {
                 $innerFiles = Dir::scan($path . $file . '/', $recursive, $excludeDir);
                 $files = Arr::join($files, $innerFiles);
             }
             if (false === $excludeDir) {
                 $files[] = $path . $file . '/';
             }
         }
     }
     closedir($dh);
     return $files;
 }
开发者ID:vimac,项目名称:zan,代码行数:29,代码来源:Dir.php

示例2: getSiteThemes

 /**
  * Get Admin Themes
  */
 public static function getSiteThemes()
 {
     $themes_folders = array();
     // Get all themes folders
     $_themes_folders = Dir::scan(THEMES_SITE);
     // Create an array of valid themes folders
     foreach ($_themes_folders as $folder) {
         if (File::exists(THEMES_SITE . DS . $folder . DS . 'index.template.php')) {
             $__themes_folders[] = $folder;
         }
     }
     foreach ($__themes_folders as $theme) {
         $themes[$theme] = $theme;
     }
     return $themes;
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:19,代码来源:themes.plugin.php

示例3: main

 /**
  * System plugin admin
  */
 public static function main()
 {
     if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
         $filters = Filter::$filters;
         $plugins = Plugin::$plugins;
         $components = Plugin::$components;
         $actions = Action::$actions;
         // Get pages table
         $pages = new Table('pages');
         // Get system timezone
         $system_timezone = Option::get('timezone');
         // Get languages files
         $language_files = File::scan(PLUGINS_BOX . DS . 'system' . DS . 'languages' . DS, '.lang.php');
         foreach ($language_files as $language) {
             $parts = explode('.', $language);
             $languages_array[$parts[0]] = I18n::$locales[$parts[0]];
         }
         // Get all pages
         $pages_array = array();
         $pages_list = $pages->select('[slug!="error404" and parent="" and status="published"]');
         foreach ($pages_list as $page) {
             $pages_array[$page['slug']] = Html::toText($page['title']);
         }
         // Create Sitemap
         // -------------------------------------
         if (Request::get('sitemap') == 'create') {
             if (Security::check(Request::get('token'))) {
                 Notification::set('success', __('Sitemap created', 'system'));
                 Sitemap::create();
                 Request::redirect('index.php?id=system');
             } else {
                 die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
             }
         }
         // Delete temporary files
         // -------------------------------------
         if (Request::get('temporary_files') == 'delete') {
             if (Security::check(Request::get('token'))) {
                 Monstra::cleanTmp();
                 if (count(File::scan(MINIFY, array('css', 'js', 'php'))) == 0 && count(Dir::scan(CACHE)) == 0) {
                     Notification::set('success', __('Temporary files deleted', 'system'));
                     Request::redirect('index.php?id=system');
                 }
             } else {
                 die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
             }
         }
         // Set maintenance state on or off
         // -------------------------------------
         if (Request::get('maintenance')) {
             if (Security::check(Request::get('token'))) {
                 if ('on' == Request::get('maintenance')) {
                     Option::update('maintenance_status', 'on');
                     Request::redirect('index.php?id=system');
                 }
                 if ('off' == Request::get('maintenance')) {
                     Option::update('maintenance_status', 'off');
                     Request::redirect('index.php?id=system');
                 }
             } else {
                 die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
             }
         }
         // Edit settings
         // -------------------------------------
         if (Request::post('edit_settings')) {
             if (Security::check(Request::post('csrf'))) {
                 // Add trailing slashes
                 $_site_url = Request::post('system_url');
                 Option::update(array('sitename' => Request::post('site_name'), 'keywords' => Request::post('site_keywords'), 'description' => Request::post('site_description'), 'slogan' => Request::post('site_slogan'), 'defaultpage' => Request::post('site_default_page'), 'siteurl' => $_site_url, 'timezone' => Request::post('system_timezone'), 'system_email' => Request::post('system_email'), 'language' => Request::post('system_language'), 'maintenance_message' => Request::post('site_maintenance_message')));
                 Notification::set('success', __('Your changes have been saved.', 'system'));
                 Request::redirect('index.php?id=system');
             } else {
                 die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
             }
         }
         // Its mean that you can add your own actions for this plugin
         Action::run('admin_system_extra_actions');
         // Display view
         View::factory('box/system/views/backend/index')->assign('pages_array', $pages_array)->assign('languages_array', $languages_array)->display();
     } else {
         Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id'));
     }
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:87,代码来源:system.admin.php

示例4: cleanTmp

 /**
  * Clean Monstra TMP folder.
  */
 public static function cleanTmp()
 {
     // Cleanup minify
     if (count($files = File::scan(MINIFY, array('css', 'js', 'php'))) > 0) {
         foreach ($files as $file) {
             File::delete(MINIFY . DS . $file);
         }
     }
     // Cleanup cache
     if (count($namespaces = Dir::scan(CACHE)) > 0) {
         foreach ($namespaces as $namespace) {
             Dir::delete(CACHE . DS . $namespace);
         }
     }
 }
开发者ID:Repkit,项目名称:monstra,代码行数:18,代码来源:Monstra.php

示例5: defined

<?php

defined('PANEL_ACCESS') or die('No direct script access.');
// new panel
$p = new Panel();
/*  = Sections
--------------------------------------------*/
/*
* @name   Dashboard | login
* @desc   if session user get Dashboard
* @desc   if not redirecto to login page
*/
$p->route('/', function () use($p) {
    if (Session::exists('user')) {
        // show dashboard
        $p->view('index', ['title' => $p::$lang['Dashboard'], 'pages' => count(File::scan(ROOTBASE . DS . 'storage' . DS . 'pages', 'md')), 'images' => count(File::scan(ROOTBASE . DS . 'public' . DS . 'images')), 'uploads' => count(File::scan(ROOTBASE . DS . 'public' . DS . 'uploads')), 'blocks' => count(File::scan(ROOTBASE . DS . 'storage' . DS . 'blocks', 'md')), 'themes' => count(Dir::scan(ROOTBASE . DS . 'themes' . DS)), 'plugins' => count(Dir::scan(ROOTBASE . DS . 'plugins' . DS))]);
    } else {
        // empty error
        $error = '';
        if (Request::post('login')) {
            if (Request::post('csrf')) {
                if (Request::post('pass') == $p::$site['backend_password'] && Request::post('email') == $p::$site['autor']['email']) {
                    @Session::start();
                    Session::set('user', uniqid('morfy_user'));
                    Request::redirect($p::$site['url'] . '/' . $p::$site['backend_folder']);
                } else {
                    // password not correct show error
                    $error = '<span class="login-error error">' . $p::$lang['Password_Error'] . '</span>';
                }
            } else {
                // crsf
开发者ID:Awilum,项目名称:morfy-admin-panel,代码行数:31,代码来源:Morfy.routes.php

示例6: die

             }
             if (Dir::exists(CACHE_PATH . '/fenom/')) {
                 Dir::delete(CACHE_PATH . '/fenom/');
             }
             Request::redirect(Url::getBase());
         } else {
             die('crsf detect !');
         }
     }
     // logout
     if (Request::post('access_logout')) {
         Session::delete(Config::get('plugins.edit.name') . '_user');
         Request::redirect(Url::getCurrent());
     }
     // show template
     $template->display('admin.tpl', ['title' => $name, 'content' => $page, 'current' => $url, 'directory' => Dir::scan(STORAGE_PATH . '/pages')]);
 } else {
     // login
     if (Request::post('access_login')) {
         if (Request::post('token')) {
             if (sha1(md5(Request::post('password'))) == $password && Request::post('email') == $user) {
                 @Session::start();
                 Session::set(Config::get('plugins.edit.name') . '_user', $hash);
                 // show admin template
                 Request::redirect(Url::getCurrent());
             } else {
                 // password not correct show error
                 $template->display('partials/error.tpl', ['title' => 'Access Error', 'content' => Config::get('plugins.edit.errorPassword')]);
             }
         } else {
             // crsf
开发者ID:nakome,项目名称:Fansoro-edit-plugin,代码行数:31,代码来源:edit.php

示例7: array

    if (Session::exists('user')) {
        // show Diagnostic
        $p->view('diag', array('title' => 'Diagnostic'));
    }
});
/*    DASHBOARD
-----------------------------*/
/*
* @name   Dashboard | login
* @desc   if session user get Dashboard
* @desc   if not redirecto to login page
*/
$p->route('/', function () use($p) {
    if (Session::exists('user')) {
        // show dashboard
        $p->view('index', array('title' => $p::$lang['Dashboard'], 'pages' => count(File::scan(PAGES, 'md')), 'media' => count(File::scan(MEDIA . '/album_thumbs')), 'uploads' => count(File::scan(UPLOADS)), 'blocks' => count(File::scan(BLOCKS, 'md')), 'themes' => count(Dir::scan(ROOTBASE . '/themes')), 'plugins' => count(Dir::scan(ROOTBASE . '/plugins'))));
    } else {
        // empty error
        $error = '';
        if (Request::post('login')) {
            if (Request::post('csrf')) {
                if (Request::post('pass') == $p::$site['backend_password'] && Request::post('email') == $p::$site['author']['email']) {
                    @Session::start();
                    Session::set('user', uniqid('morfy_user'));
                    Request::redirect($p::$site['url'] . '/' . $p::$site['backend_folder']);
                } else {
                    // password not correct show error
                    $error = '<span class="well red">' . $p::$lang['Password_Error'] . '</span>';
                }
            } else {
                // crsf
开发者ID:xxwebplus,项目名称:morfy-admin-panel,代码行数:31,代码来源:pages.php

示例8: main


//.........这里部分代码省略.........
         if (Security::check(Request::post('csrf'))) {
             $id = (int) Request::post('delete_location');
             if (!LocationsRepository::hasEvents($id)) {
                 if (LocationsRepository::update($id, array('deleted' => 1))) {
                     Notification::set('success', __('Location has been moved to trash with success!', 'events'));
                 } else {
                     Notification::set('error', __('Table->update() returned an error. Location could not be deleted.', 'events'));
                 }
             } else {
                 Notification::set('error', __('Deletion failed. This location is assigned to at least one event. Remove this location from every event to delete it.', 'events'));
             }
             Request::redirect('index.php?id=events#locations');
         } else {
             Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
             die;
         }
     }
     // Request: delete trash location
     if (Request::post('delete_trash_location')) {
         if (Security::check(Request::post('csrf'))) {
             $id = (int) Request::post('delete_trash_location');
             if (LocationsRepository::delete($id)) {
                 Notification::set('success', __('Location has been deleted permanently with success!', 'events'));
             } else {
                 Notification::set('error', __('Table->delete() returned an error. Location could not be deleted.', 'events'));
             }
             Request::redirect('index.php?id=events#trash/trash-locations');
         } else {
             Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
             die;
         }
     }
     // get upload directories
     $directory_list = Dir::scan($path);
     $directories = array(DS => DS);
     if (!empty($directory_list)) {
         foreach ($directory_list as $directory_name) {
             $directories[$directory_name] = DS . $directory_name;
         }
         ksort($directories);
     }
     // Get files
     $file_list = File::scan($path . Option::get('events_image_directory'));
     $files = array('' => '');
     if (!empty($file_list)) {
         foreach ($file_list as $file_name) {
             $files[$file_name] = $file_name;
         }
         ksort($files);
     }
     if (Request::get('action')) {
         switch (Request::get('action')) {
             // Request: configuration
             case "configuration":
                 // Request: options
                 if (Request::post('events_options_update') or Request::post('events_options_update_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         Option::update('events_image_directory', (string) Request::post('events_image_directory'));
                         Option::update('events_placeholder_archive', (string) Request::post('events_placeholder_archive'));
                         Notification::set('success', __('Configuration has been saved with success!', 'events'));
                         Request::redirect('index.php?id=events' . (Request::post('events_options_update') ? '&action=configuration' : ''));
                     } else {
                         Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
                         die;
                     }
                 }
开发者ID:devmount-monstra,项目名称:events,代码行数:67,代码来源:events.admin.php


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