Exemplo n.º 1
0
 function clear_dir($dir)
 {
     $list = myscandir($dir);
     foreach ($list as $file) {
         if (is_dir($dir . $file)) {
             clear_dir($dir . $file . '/');
             rmdir($dir . $file);
         } else {
             unlink($dir . $file);
         }
     }
 }
Exemplo n.º 2
0
function myscandir($dir, &$dir_list, &$info_list)
{
    $my_dir = dir($dir);
    $dir_list[$dir] = array();
    while ($file = $my_dir->read()) {
        $p = $dir . "/" . $file;
        if ($file == "." or $file == "..") {
            continue;
        }
        if ($file == "url.h") {
            if (file_exists($p)) {
                $info_list[$dir] = file_get_contents($p);
            }
            continue;
        }
        if (is_dir($p)) {
            myscandir($p, $dir_list, $info_list);
        } else {
            array_push($dir_list[$dir], $file . " (<a href='{$p}' name=path>路径</a> <a href='./php/download.php?file_path=" . urlencode($p) . "' name=download>下载</a>)");
        }
    }
}
Exemplo n.º 3
0
function myscandir($dir, $exp, $how = 'name', $desc = 0)
{
    $r = array();
    $dh = @opendir($dir);
    if ($dh) {
        while (($fname = readdir($dh)) !== false) {
            if (preg_match($exp, $fname)) {
                $stat = stat("{$dir}/{$fname}");
                $r[$fname] = $how == 'name' ? $fname : $stat[$how];
            }
        }
        closedir($dh);
        if ($desc) {
            arsort($r);
        } else {
            asort($r);
        }
    }
    return array_keys($r);
}
$a = myscandir("raw/", "/.+/", "ctime", 1);
$r = 0;
for ($i = 0; $i < 5; $i++) {
    if (!preg_match('/^([a-zA-Z0-9]+)$/', $a[$r])) {
        $i--;
        $r++;
        continue;
    }
    echo "<a href='/{$a[$r]}'><img src='/{$a[$r]}'></a><br />";
    $r++;
}
Exemplo n.º 4
0
function myscandir($pathname)
{
    $i = 1;
    foreach (glob($pathname) as $filename) {
        if (is_dir($filename)) {
            myscandir($filename . '/*');
        } else {
            echo "<li><input type='radio' id=pic{$i} name='cus_pic' value='/" . $filename . "'/>";
            echo "<img id={$i} onclick='select(this.id)' src='/" . $filename . "'/></li>";
        }
        $i++;
    }
}
Exemplo n.º 5
0
function editmsgs()
{
    // в админке выводит для редактирования список мессаг из sys_msg и sys_err
    if (empty($_SESSION['Jlib_auth']['u_grp']) || $_SESSION['Jlib_auth']['u_grp'] != 'adm') {
        return 'Err: admin access is required';
    }
    // взять из базы
    $ma = array();
    $mt = mysql_query("SELECT * FROM sys_msg ORDER BY msg_id ASC");
    while ($m = mysql_fetch_assoc($mt)) {
        $mi = $m['msg_id'];
        if (!isset($ma[$mi])) {
            $ma[$mi] = array();
        }
        if (!isset($ma[$mi]['ln'])) {
            $ma[$mi]['ln'] = array();
        }
        $ma[$mi]['ln'][$m['ln']] = $m['msg'];
    }
    $mt = mysql_query("SELECT * FROM sys_err ORDER BY err_id ASC");
    while ($m = mysql_fetch_assoc($mt)) {
        $mi = 'err.' . $m['err_id'];
        if (!isset($ma[$mi])) {
            $ma[$mi] = array();
        }
        if (!isset($ma[$mi]['ln'])) {
            $ma[$mi]['ln'] = array();
        }
        $ma[$mi]['ln'][$m['ln']] = $m['msg'];
    }
    // взять из файлов и сопоставить
    $fa = myscandir('./');
    $ha = array('msg:', 'sys:', 'err:', '?:');
    foreach ($fa as $fi => $fv) {
        if (!file_exists($fi)) {
            continue;
        }
        $trimlast = array("'", '"', '}', ')', ']');
        $ta = explode(PHP_EOL, file_get_contents($fi));
        $tl = count($ta);
        for ($ti = 0; $ti < $tl; ++$ti) {
            $tv = $ta[$ti];
            foreach ($ha as $hv) {
                $pl = strlen($hv) - 1;
                $p1 = -1;
                while (($p1 = strpos($tv, $hv, $p1 + 1)) !== false && $p1 + 1 < strlen($tv)) {
                    if ($p1 > 0) {
                        $ps = array($tv[$p1 - 1]);
                    } else {
                        $ps = array(' ');
                    }
                    if ($ps[0] == '$' || $ps[0] == '-') {
                        continue;
                    }
                    $pb = 0;
                    $pi = $p1 + $pl - 1;
                    for (; $pi < strlen($tv); ++$pi) {
                        if ($tv[$pi] == '{' || $tv[$pi] == '(' || $tv[$pi] == '[') {
                            ++$pb;
                            $ps[$pb] = $tv[$pi];
                        }
                        if ($ps[$pb] == '(') {
                            $ps[$pb] = ')';
                        }
                        if ($ps[$pb] == '{') {
                            $ps[$pb] = '}';
                        }
                        if ($ps[$pb] == '[') {
                            $ps[$pb] = ']';
                        }
                        if ($tv[$pi] == $ps[$pb]) {
                            --$pb;
                        }
                        if ($pb < 0) {
                            if ($pi + 1 < strlen($tv) && $tv[$pi + 1] == '.') {
                                $pb = 0;
                                $ps = array(';');
                            } else {
                                break;
                            }
                        }
                    }
                    $p2 = $pi + 2;
                    $tt = trim(substr($tv, $p1 - 1, $p2 - $p1));
                    if ($tt) {
                        $t1 = $tt[0];
                        $t2 = $tt[strlen($tt) - 1];
                        if ($t1 == '{' && $t2 == '}' || $t1 == $t2 && ($t1 == '"' || $t1 == "'" || $t1 == '-')) {
                            $mi = trim(substr($tt, $pl + 2, -1));
                        } else {
                            $mi = trim(substr($tt, $pl + 2));
                        }
                        //echo $fi,' | ',$tt,' | ',$mi,'<br>';
                        if ($mi) {
                            for ($ci = strlen($mi) - 1; $ci >= 0; --$ci) {
                                $cc = $mi[$ci];
                                if ($cc == '*' || $cc == '\\' || $cc == ')' || $cc == '&' || $cc == '$') {
                                    $mi = '';
                                    break;
                                }
                            }
                        }
                        if ($mi) {
                            if (!isset($ma[$mi])) {
                                $ma[$mi] = array();
                            }
                            if (!isset($ma[$mi]['ln'])) {
                                $ma[$mi]['ln'] = array();
                            }
                            if (!isset($ma[$mi]['fa'])) {
                                $ma[$mi]['fa'] = array();
                            }
                            if (!isset($ma[$mi]['fa'][$fi])) {
                                $ma[$mi]['fa'][$fi] = array();
                            }
                            if (!isset($ma[$mi]['fa'][$fi][$hv])) {
                                $ma[$mi]['fa'][$fi][$hv] = array();
                            }
                            $ma[$mi]['fa'][$fi][$hv][] = $ti;
                            if (!isset($fa[$fi][$mi])) {
                                $fa[$fi][$mi] = array();
                            }
                            if (!isset($fa[$fi][$mi][$hv])) {
                                $fa[$fi][$mi][$hv] = array();
                            }
                            $fa[$fi][$mi][$hv][] = $ti;
                        }
                    }
                }
            }
        }
    }
    ksort($ma);
    //echo '<pre>$ma = ',print_r( $ma ,true),'</pre>';
    ksort($fa);
    //echo '<pre>$fa = ',print_r( $fa ,true),'</pre>';
    // подготовить вывод
    //$la=array_flip(split(',', $GLOBALS['Jlib_defaults']['langset'] ));
    $la = array_flip(explode(',', $GLOBALS['Jlib_defaults']['langset']));
    //foreach($ma as $mv) foreach($mv['ln'] as $li=>$lv) $la[$li]=1;
    $ll = count($la);
    $res = "\n" . '<tr valign="top"><td colspan="2"><a href="#add" onclick="addmsg();return false;">добавить новое</a><br><span id="_-_"></span><div id="_--_" style="display:none;"></div></td></tr>' . "\n";
    foreach ($ma as $mi => $mv) {
        $ts = '<td width="40%"><a name="' . $mi . '"><b>' . $mi . '</b></a>';
        if (!empty($mv['fa'])) {
            $ts .= '<span style="color:#999999;">';
            ksort($mv['fa']);
            foreach ($mv['fa'] as $fi => $fv) {
                $ts .= '<br>' . $fi . ': ';
                foreach ($fv as $hi => $hv) {
                    $ts .= $hi . ' ';
                    $tk = 0;
                    foreach ($hv as $ti) {
                        if ($tk) {
                            $ts .= ', ';
                        }
                        $tk = 1;
                        $ts .= $ti;
                    }
                }
            }
            $ts .= '</span>';
        }
        $ts .= '</td><td>';
        if (strpos($mi, '{') !== false || strpos($mi, '}') !== false) {
            $ts .= 'проверь наличие всех возможных вариантов';
        } else {
            foreach ($la as $li => $lv) {
                $ts .= "\n<a href=\"#edit\" onclick=\"editmsg('{$mi}','{$li}');return false;\"" . (empty($mv['ln'][$li]) ? empty($mv['fa']) ? ' style="color:#990000;"' : ' style="color:#990000;font-weight:bold;"' : '') . ">{$li}</a>: <span id=\"_{$mi}-{$li}_\">" . (empty($mv['ln'][$li]) ? '' : $mv['ln'][$li]) . "</span><div id=\"_{$mi}--{$li}_\" class=\"ifrm\" style=\"display:none;\"></div><br>";
            }
        }
        $ts .= '</td>';
        $res .= "\n<tr" . (empty($ma[$mi]['fa']) ? ' style="color:#666666;"' : '') . ' valign="top">' . $ts . "</tr>\n";
    }
    // завернуть в обертку и отдать на вывод
    return "\n\t\t<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>\n\t\t<script type=\"text/javascript\" src=\"/js/JsHttpRequest.js\"></script>\n\t\t<script type=\"text/javascript\" src=\"/js/cms/admin_messages.js\"></script>\n\t\t<style>.ifrm{display:inline-block;}</style>\n\t\t<div style=\"display:none;\" id=\"sessID\">" . session_id() . "</div>\n\t\t<table border=\"0\" width=\"100%\">{$res}</table>";
}