function get_file_listing($dir, $excludeprefix = '', $assign = '')
 {
     $gCms = cmsms();
     $smarty = $gCms->GetSmarty();
     $config = $gCms->GetConfig();
     $fileprefix = '';
     if (!empty($excludeprefix)) {
         $fileprefix = $excludeprefix;
     }
     if (startswith($dir, '/')) {
         return;
     }
     $dir = cms_join_path($config['uploads_path'], $dir);
     $list = get_matching_files($dir, '', true, true, $fileprefix, 1);
     if (!empty($assign)) {
         $smarty->assign(trim($assign), $list);
         return;
     }
     return $list;
 }
Example #2
0
function include_matching_files($dir, $match = '/\\.php$/')
{
    foreach (get_matching_files($dir, $match) as $file) {
        include_once $file;
    }
}
/**
 * Create a dropdown form element containing a list of files that match certain conditions
 *
 * @internal
 * @param string The name for the select element.
 * @param string The directory name to search for files.
 * @param string The name of the file that should be selected
 * @param string A comma separated list of extensions that should be displayed in the list
 * @param string An optional string with which to prefix each value in the output by
 * @param boolean Wether 'none' should be an allowed option
 * @param string Text containing additional parameters for the dropdown element
 * @param string A prefix to use when filtering files
 * @param boolean A flag indicating wether the files matching the extension and the prefix should be included or excluded from the result set
 * @return string
 */
function create_file_dropdown($name, $dir, $value, $allowed_extensions, $optprefix = '', $allownone = false, $extratext = '', $fileprefix = '', $excludefiles = 1)
{
    $files = array();
    $files = get_matching_files($dir, $allowed_extensions, true, true, $fileprefix, $excludefiles);
    if ($files === false) {
        return false;
    }
    $out = "<select name=\"{$name}\" id=\"{$name}\" {$extratext}>\n";
    if ($allownone) {
        $txt = '';
        if (empty($value)) {
            $txt = 'selected="selected"';
        }
        $out .= "  <option value=\"-1\" {$txt}>--- " . lang('none') . " ---</option>\n";
    }
    foreach ($files as $file) {
        $txt = '';
        $opt = $file;
        if (!empty($optprefix)) {
            $opt = $optprefix . '/' . $file;
        }
        if ($opt == $value) {
            $txt = 'selected="selected"';
        }
        $out .= "  <option value=\"{$opt}\" {$txt}>{$file}</option>\n";
    }
    $out .= "</select>";
    return $out;
}
Example #4
0
<?php

/*
 * LibreNMS front page graphs
 *
 * Author: Paul Gear
 * Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
echo '
<div class="cycle-slideshow"
data-cycle-fx="fade"
data-cycle-timeout="10000"
data-cycle-slides="> div"
style="clear: both">
';
foreach (get_matching_files($config['html_dir'] . '/includes/front/', '/^top_.*\\.php$/') as $file) {
    if ($file == 'top_ports.inc.php' && $config['top_ports'] == 0 || $file == 'top_device_bits.inc.php' && $config['top_devices'] == 0) {
    } else {
        echo "<div class=box>\n";
        include_once $file;
        echo "</div>\n";
    }
}
echo "</div>\n";
Example #5
0
/*
 * LibreNMS front page graphs
 *
 * Author: Paul Gear
 * Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
echo '
<div class="cycle-slideshow"
    data-cycle-fx="fade"
    data-cycle-timeout="10000"
    data-cycle-slides="> div"
    style="clear: both">
';
foreach (get_matching_files($config['html_dir'] . "/includes/front/", "/^top_.*\\.php\$/") as $file) {
    if ($file == 'top_ports.inc.php' && $config['top_ports'] == 0 || $file == 'top_device_bits.inc.php' && $config['top_devices'] == 0) {
    } else {
        echo "<div class=box>\n";
        include_once $file;
        echo "</div>\n";
    }
}
echo "</div>\n";
?>