コード例 #1
0
ファイル: interface.php プロジェクト: shahadat014/geleyi
/**
 * Display a html list of files
 *
 * @param HMBKP_Scheduled_Backup $schedule
 * @param mixed                  $excludes    (default: null)
 * @param string                 $file_method (default: 'get_included_files')
 * @return void
 */
function hmbkp_file_list(HMBKP_Scheduled_Backup $schedule, $excludes = null, $file_method = 'get_included_files')
{
    if (!is_null($excludes)) {
        $schedule->set_excludes($excludes);
    }
    $exclude_string = $schedule->exclude_string('regex');
    ?>

	<ul class="hmbkp_file_list code">

		<?php 
    foreach ($schedule->get_files() as $file) {
        if (!is_null($excludes) && strpos($file, str_ireplace($schedule->get_root(), '', $schedule->get_path())) !== false) {
            continue;
        }
        // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
        if (method_exists($file, 'isDot') && $file->isDot()) {
            continue;
        }
        // Show only unreadable files
        if ($file_method === 'get_unreadable_files' && @realpath($file->getPathname()) && $file->isReadable()) {
            continue;
        } elseif ($file_method !== 'get_unreadable_files' && (!@realpath($file->getPathname()) || !$file->isReadable())) {
            continue;
        }
        // Show only included files
        if ($file_method === 'get_included_files') {
            if ($exclude_string && preg_match('(' . $exclude_string . ')', str_ireplace(trailingslashit($schedule->get_root()), '', HM_Backup::conform_dir($file->getPathname())))) {
                continue;
            }
        }
        // Show only excluded files
        if ($file_method === 'get_excluded_files') {
            if (!$exclude_string || !preg_match('(' . $exclude_string . ')', str_ireplace(trailingslashit($schedule->get_root()), '', HM_Backup::conform_dir($file->getPathname())))) {
                continue;
            }
        }
        if (@realpath($file->getPathname()) && !$file->isReadable() && $file->isDir()) {
            ?>

				<li title="<?php 
            echo esc_attr(HM_Backup::conform_dir(trailingslashit($file->getPathName())));
            ?>
"><?php 
            echo esc_html(ltrim(trailingslashit(str_ireplace(HM_Backup::conform_dir(trailingslashit($schedule->get_root())), '', HM_Backup::conform_dir($file->getPathName()))), '/'));
            ?>
</li>

			<?php 
        } else {
            ?>

				<li title="<?php 
            echo esc_attr(HM_Backup::conform_dir($file->getPathName()));
            ?>
"><?php 
            echo esc_html(ltrim(str_ireplace(HM_Backup::conform_dir(trailingslashit($schedule->get_root())), '', HM_Backup::conform_dir($file->getPathName())), '/'));
            ?>
</li>

			<?php 
        }
    }
    ?>

	</ul>

<?php 
}