/////////////////////////////////////////////////// $i = 1; //当前用户组 $group = $_CACHE['system']['group'][$_G['manager']['gid']]; //遍历模块 foreach ($_CACHE['system']['module'] as $appid => $config) { //插件目录 $root = VI_ROOT . "module/" . $appid . "/widget/"; //加载配置 if (file_exists($root) && $group['widget'] && is_array($group['widget'][$appid])) { $app = $_CACHE['system']['module'][$appid]; echo '<dt>' . $app["name"] . '</dt>'; echo '<dd>'; echo '<ul>'; //遍历目录 $list = loop_dir($root); foreach ($list as $file) { // $widget = $file; $doc = $root . $widget . "/config.xml"; //如果配置文件存在 if (file_exists($doc) && in_array($widget, $group['widget'][$appid])) { $config = xml_array(sreadfile($doc)); //var_dump($config); //UTF8 转 GBK if ($_G['product']['charset'] == "gbk") { foreach ($config['widget'] as $key => $val) { if (is_string($val)) { $config['widget'][$key] = $val ? iconv('UTF-8', 'GBK//IGNORE', $val) : $val; } }
function loop_dir2($dir2) { global $self2, $fname2, $content2, $subdirs2, $refresh2, $dir_up2, $all_dir2, $unread_dir2, $all_file2, $unread_file2, $file_count2; global $home2, $browsing2, $browseflag2, $listTypeSrc2; //check if directory can be open if ($handle2 = @opendir($dir2)) { //loop through the dir for FILES and DIR while (false != ($file2 = readdir($handle2))) { $q_file2 = addslashes($file2); $q_dir2 = addslashes($dir2); //increase the maximum execute time set_time_limit(10); $full_path2 = str_replace("//", "/", $dir2 . "/" . $file2); if ($file2 == ".") { $refresh2 = "<tr bgcolor=\"#F5F5F5\">"; if (!$browsing2) { $refresh2 .= "<td align=\"left\" oncontextmenu=\"\n action_file = '';\n action_dir = '{$q_dir2}';\n show_contextmenu(event, refreshmenu);\n return false;\n \">"; } else { $refresh2 .= "<td align=\"left\">"; } $refresh2 .= "<img src=\"" . BASE_PATH . "/images/sysimg/refresh.png\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?dir2={$dir2}{$browseflag2}{$listTypeSrc2}\">Refresh</a></td>\n <td align=\"center\"></td>\n <td align=\"left\"></td>\n <td align=\"left\"></td></tr>\r\n"; } elseif ($file2 == "..") { if (RESTRICTED_BROWSING && $dir2 == $home2) { continue; } // no browsing up from home ! $up_lvl2 = str_replace("\\", "/", dirname($dir2 . "..")); $dir_up2 = "<tr bgcolor=\"#FFFFFF\">\n <td align=\"left\"><img src=\"" . BASE_PATH . "/images/sysimg/back.png\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?dir2={$up_lvl2}{$browseflag2}{$listTypeSrc2}\">Up one level</a></td>\n <td align=\"center\"></td>\n <td align=\"left\"></td>\n <td align=\"left\"></td></tr>\r\n"; } elseif (is_dir($full_path2)) { $perm2 = substr(sprintf('%o', @fileperms("{$full_path2}")), -4); $time_mod2 = date("Y M d h:i A", filemtime($full_path2)); //check if the dir can be open or not if (@opendir($full_path2)) { //loop to subdirs if specify by user if ($subdirs2 == 1) { loop_dir($full_path2); } if (!empty($fname2) && stristr($file2, $fname2)) { //store all dirs in array $all_dir2[] .= "<td align=\"left\" oncontextmenu=\"\n action_file = '{$q_file2}';\n action_dir = '{$q_dir2}';\n show_contextmenu(event, dirmenu);\n return false;\n \">\n <img src=\"" . BASE_PATH . "/images/ext_ico/folder.png\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?dir2={$full_path2}{$listTypeSrc2}{$listTypeSrc2}\" title=\"{$full_path2}\">{$file2}</a></td>\n <td align=\"center\">-</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } elseif (empty($content2)) { //store all dirs in array if (!$browsing2) { $all_dir2[] .= "<td align=\"left\" oncontextmenu=\"\n action_file = '{$q_file2}';\n action_dir = '{$q_dir2}';\n show_contextmenu(event, dirmenu);\n return false;\">\n <img src=\"" . BASE_PATH . "/images/ext_ico/folder.png\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?dir2={$full_path2}{$browseflag2}{$listTypeSrc2}\" title=\"{$full_path2}\">{$file2}</a></td>\n <td align=\"center\">-</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>\n "; } else { $all_dir2[] .= "<td align=\"left\">\n <img src=\"" . BASE_PATH . "/images/ext_ico/folder.png\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?dir2={$full_path2}{$browseflag2}{$listTypeSrc2}\" title=\"{$full_path2}\">{$file2}</a></td>\n <td align=\"center\">-</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>\n "; } } } else { $unread_dir2[] .= "<td align=\"left\">\n <img src=\"" . BASE_PATH . "/images/ext_ico/folder2.png\" border=\"0\" alt=\"\" /> \n {$file2}\n </td>\n <td align=\"center\">-</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } } else { //for normal file, these are the attr $size2 = filesize($full_path2); if ($size2 >= 0 && $size2 < 1024) { $size2 = $size2 . " B"; } elseif ($size2 >= 1024 && $size2 < 1048576) { //round to KB $size2 = round($size2 / 1024, 2) . " KB"; } elseif ($size2 >= 1048576 && $size2 < 1073741824) { //round to MB $size2 = round($size2 / 1048576, 2) . " MB"; } elseif ($size2 >= 1073741824) { //round to GB $size2 = round($size2 / 1073741824, 2) . " GB"; } else { //invalid size, error $size2 = "--"; } $perm2 = substr(sprintf('%o', @fileperms("{$full_path2}")), -4); $time_mod2 = date("Y M d h:i A", filemtime($full_path2)); //check for icon for this filetype $ext2 = substr(strrchr($file2, "."), 1); //icon for normal readable file if (file_exists("" . BASE_PATH . "/images/ext_ico/" . $ext2 . ".png")) { $icon_normal2 = "" . BASE_PATH . "/images/ext_ico/" . $ext2 . ".png"; } else { //set as unknown filetype icon $icon_normal2 = "" . BASE_PATH . "/images/ext_ico/file.png"; } //icon for unreadable file if (file_exists("" . BASE_PATH . "/images/ext_ico/" . $ext2 . "2.png")) { $icon_unview2 = "" . BASE_PATH . "/images/ext_ico/" . $ext2 . "2.png"; } else { //set as unknown filetype icon $icon_unview2 = "" . BASE_PATH . "/images/ext_ico/file2.png"; } //check if the file can be read if (@fopen($full_path2, "rb")) { //search for the content as well if user request if (!empty($content2)) { $file_data2 = file_get_contents($full_path2); } //searching for files and content if so if (!empty($fname2)) { //search for the name if (stristr($file2, $fname2)) { //store all files in array $all_file2[] .= "\n<!--{$file2}!-->\n <td align=\"left\" oncontextmenu=\"\n action_file = '{$q_file2}';\n action_dir = '{$q_dir2}';\n show_contextmenu(event, filemenu);\n return false;\n \">\n <img src=\"{$icon_normal2}\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?fname={$full_path2}\" title=\"{$full_path2}\">" . $file2 . "</a></td>\n <td align=\"right\">{$size2}</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } } elseif (!empty($content2)) { if (stristr($file_data2, $content2)) { //store all files in array $all_file2[] .= "\n<!--{$file2}!-->\n <td align=\"left\" oncontextmenu=\"\n action_file = '{$q_file2}';\n action_dir = '{$q_dir2}';\n show_contextmenu(event, filemenu);\n return false;\n \">\n <img src=\"{$icon_normal2}\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?fname={$full_path2}\" title=\"{$full_path2}\">" . $file2 . "</a></td>\n <td align=\"right\">{$size2}</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } } elseif (empty($fname2)) { //store all files in array if (!$browsing2) { $all_file2[] .= "\n<!--{$file2}!-->\n <td align=\"left\" oncontextmenu=\"\n action_file = '{$file2}';\n action_dir = '{$dir2}';\n show_contextmenu(event, filemenu);\n return false;\n \">\n <img src=\"{$icon_normal2}\" border=\"0\" alt=\"\" />\n <a href=\"{$self2}?fname={$full_path2}\" title=\"{$full_path2}\">{$file2}</a></td>\n <td align=\"right\">{$size2}</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } else { $all_file2[] .= "\n<!--{$file2}!-->\n <td align=\"left\"\">\n <img src=\"{$icon_normal2}\" border=\"0\" alt=\"\" />{$file2}</td>\n <td align=\"right\">{$size2}</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } } } else { //file cannot be read $unread_file2[] .= "\n<!--{$file2}!-->\n <td align=\"left\"><img src=\"{$icon_unview2}\" border=\"0\" alt=\"\" /> " . $file2 . "</td>\n <td align=\"right\">{$size2}</td>\n <td align=\"center\">{$perm2}</td>\n <td align=\"left\">{$time_mod2}</td>"; } } //incre the file number $file_count2++; } //display the files and dirs @natcasesort($all_dir2); @natcasesort($unread_dir2); @natcasesort($all_file2); @natcasesort($unread_file2); } }
public function search() { global $_G; global $_CACHE; //模块列表缓存文件 $file = self::get_list(); $list = loop_dir(VI_ROOT . 'module/'); $module = array(); $cached = $_CACHE['system']['module']; foreach ($list as $appid) { //创建缓存目录 create_dir(VI_ROOT . 'cache/dataset/' . $appid); create_dir(VI_ROOT . 'cache/compile/' . $appid); //配置文件 $config = 'module/' . $appid . '/config.php'; //加载配置 file_exists(VI_ROOT . $config) && (require_once VI_ROOT . $config); $app = $_G['module'][$appid]; //有配置文件 if (is_array($app)) { $_CACHE['system']['module'][$appid] = $module[$appid] = array('name' => $app['name'], 'appid' => $appid, 'model' => $app['model'], 'signed' => $app['signed'], 'version' => $app['version'], 'serve' => $app['serve'], 'hooks' => $app['hooks'], 'index' => self::get_index($appid), 'domain' => $_G['setting'][$appid]['domain'], 'statis' => $app['statis'], 'permit' => $app['permit'], 'author' => $app['author'], 'support' => $app['support'], 'context' => $app['context'], 'writable' => $app['writable'], 'describe' => $app['describe'], 'external' => $app['external'], 'state' => isset($cached[$appid]['state']) ? $cached[$appid]['state'] : TRUE); //新模块标识 if (!is_array($_CACHE['system']['module'][$appid])) { $module[$appid]['dateline'] = time(); } //刷新伪静态 self::rewrite($appid); //没有配置文件 } else { $_CACHE['system']['module'][$appid] = $module[$appid] = array('name' => $appid, 'appid' => $appid, 'state' => TRUE); } } $text = '<?php' . chr(13); $text .= ' /*' . date("Y-m-t H:i:s") . '*/ ' . chr(13); $text .= '$_CACHE[\'system\'][\'module\']=' . var_export($module, true); $text .= ';'; //实时缓存 //$_CACHE['system']['module'] = $module; //写入缓存 return create_file($file, $text); }
function fixKey($data, $ele, $grp = FALSE) { $key = $ele->getAttribute("name"); //是否数组 preg_match('/(\\S*)\\[(\\S*)\\]/', $key, $matche); //二维数组 if ($matche) { $val = $data[$matche[1]][$matche[2]]; } else { $val = $data[$key]; } $val = dhtmlspecialchars($val); $des = str_replace(array('{$TIME}', '{$BASE}', '{$HOST}'), array(time(), VI_BASE, VI_HOST), $ele->getAttribute("comment")); ////////////////////////////////////////////// $res = $grp ? $ele->getAttribute("label") : ''; //类型 switch ($ele->getAttribute("type")) { case "hidden": $res .= '<input name="' . $key . '" type="hidden" value="' . $val . '" />'; $res .= $key; break; case "password": $res .= '<input name="' . $key . '" type="password" class="text" size="' . $ele->getAttribute("size") . '" value="' . ($val ? $this->password : '') . '" />'; break; case "text": if ($ele->getAttribute("readonly")) { $res .= '<input name="' . $key . '" size="' . $ele->getAttribute("size") . '" class="text" value="' . $val . '" ' . $this->fixAttr($ele) . ' readonly="true" />'; } else { $res .= '<input name="' . $key . '" size="' . $ele->getAttribute("size") . '" placeholder="' . $ele->getAttribute("placeholder") . '" class="text" value="' . $val . '" ' . $this->fixAttr($ele) . ' />'; } break; case "textarea": $res .= '<textarea name="' . $key . '" rows="' . $ele->getAttribute("rows") . '" placeholder="' . $ele->getAttribute("placeholder") . '" cols="' . $ele->getAttribute("cols") . '" ' . $this->fixAttr($ele) . '>' . $val . '</textarea>'; break; case "select": $res .= '<select name="' . $key . '" style="width:' . $ele->getAttribute("size") . 'px;">'; //遍历子选项 $sub = $ele->getElementsByTagName('option'); for ($s = 0; $s < $sub->length; $s++) { $res .= '<option value="' . dhtmlspecialchars($sub->item($s)->getAttribute("value")) . '" ' . ($val == $sub->item($s)->getAttribute("value") ? 'selected="selected"' : '') . '>' . $sub->item($s)->nodeValue . '</option>'; } ////////////////////////// //遍历文件夹 if ($ele->getAttribute("folder")) { //遍历皮肤目录 $list = loop_dir(VI_ROOT . $ele->getAttribute("folder")); foreach ($list as $file) { $res .= '<option value="' . $file . '" ' . ($val == $file ? 'selected="selected"' : '') . '>' . $file . '</option>'; } } $res .= '</select>'; break; case "radio": //子选项 $sub = $ele->getElementsByTagName('option'); for ($s = 0; $s < $sub->length; $s++) { $res .= '<label><input name="' . $key . '" value="' . dhtmlspecialchars($sub->item($s)->getAttribute("value")) . '" class="radio" type="radio" ' . ($val == $sub->item($s)->getAttribute("value") ? 'checked="checked"' : '') . ' />' . $sub->item($s)->nodeValue . '</option></label>'; } break; case "checkbox": //子选项 $sub = $ele->getElementsByTagName('option'); for ($s = 0; $s < $sub->length; $s++) { $res .= '<label><input name="' . $key . '[]" value="' . dhtmlspecialchars($sub->item($s)->getAttribute("value")) . '" class="checkbox" type="checkbox" ' . (in_array($sub->item($s)->getAttribute("value"), $val) ? 'checked="checked"' : '') . ' />' . $sub->item($s)->nodeValue . '</option></label>'; } break; case "notice": $res .= '<div class="highlight">' . $des . '</div>'; $des = ''; break; default: $res .= 'ERROR'; break; } return $res . ' '; }
<div id="wrapper"> <?php //未登录 if (!$_G['manager']['id']) { exit('<div id="state" class="failure">未登录,请先登录!</div>'); } ?> <ul id="theme"> <?php //遍历皮肤目录 $root = VI_ROOT . 'static/theme/'; $dirs = loop_dir($root); foreach ($dirs as $file) { //皮肤名称 $name = fileparm($root . $file . '/style.css', 'name'); //忽略没有名称的,为删除皮肤提供方法 if ($name) { echo '<li rel="' . $file . '"><img src="' . VI_BASE . 'static/theme/' . $file . '/preview.png" />' . $name . ' </li>'; } } ?> </ul> <div class="tabs"></div> <script type="text/javascript">