function main() { global $http_uri, $docroot, $conf, $vhost, $rq_err, $out_contenttype, $real_uri, $out_add_headers, $accessdir, $mime, $query_string; foreach (access_query("fbiconbytype") as $icndef) { $ic = explode(" ", $icndef); $icons[trim($ic[1])] = trim($ic[0]); } $icndef = access_query("fbicondefault", 0); if (!($icndir = access_query("fbicondirectory", 0))) { $icndir = $icndef; } if ($http_uri[strlen($http_uri) - 1] != "/") { $http_uri .= "/"; } if (access_query("filebrowser", 0)) { if (@is_readable($docroot . $http_uri)) { $dfmt = access_query("fbdateformat", 0) or $dfmt = "d-M-Y H:i:s"; $rq_err = 200; $out_contenttype = "text/html"; // Generate directory listing $hnd = opendir(realpath($docroot . $http_uri)); unset($fb_arr); unset($fsort); while ($f = readdir($hnd)) { $fi = stat($docroot . $http_uri . $f); $fi["isdir"] = is_dir($docroot . $http_uri . $f); $fi["f"] = $f; $fb_arr[$f] = $fi; if (!$fi["isdir"]) { $fb_ts += $fi[7]; $fb_tf++; } } if ($fbstmp = access_query("fbsortorder", 0)) { $fbsort = explode(" ", $fbstmp); } else { $fbsort = array("name"); } parse_str($query_string, $ptmp); if (count($ptmp)) { if ($ptmp["sort"]) { $fbsort[0] = $ptmp["sort"]; } if ($ptmp["order"]) { $fbsort[1] = $ptmp["order"]; } } switch ($fbsort[0]) { case "date": $sortidx = 9; break; case "size": $sortidx = 7; break; case "name": default: $sortidx = "f"; } $dsort = $fsort = array(); foreach ($fb_arr as $fstmp) { if (!$fstmp["isdir"]) { $fsort[$fstmp["f"]] = $fstmp[$sortidx]; } else { if ($fstmp["f"] != "..") { $dsort[$fstmp["f"]] = $fstmp[$sortidx]; } else { $has_parent = $fstmp[$sortidx]; } } } if ($fbsort[1] == "desc") { arsort($fsort); arsort($dsort); } else { asort($fsort); asort($dsort); } if ($has_parent) { $dsort = array_reverse($dsort); $dsort[".."] = $has_parent; $dsort = array_reverse($dsort); } // Do other processing if (@is_readable($wfn = $docroot . $http_uri . $conf[$vhost]["fbwelcomefile"][0])) { $wfc = implode("<br>", file($wfn)); $welcome_formated = "<br><font size=\"1\" face=\"fixedsys\">" . $wfc . "</font><br><br>"; } else { $welcome_formated = ""; } $fhdr = array(); $fhdr["dir_name"] = "/" . $real_uri; $fhdr["welcome"] = $welcome_formated; $fhdr["total_files"] = $fb_tf; $fhdr["total_files_formated"] = number_format($fb_tf); $fhdr["total_size"] = $fb_ts; $fhdr["total_size_formated"] = number_format($fb_ts); $resp = nw_apply_template(NW_TMPL_FB_HEADER, $fhdr); $dfile = access_query("fbdescfile", 0); unset($fb_desc); if (@is_readable($dfcomp = realpath($accessdir . "/" . $dfile))) { if ($descf = file($dfcomp)) { foreach ($descf as $dfline) { if (trim($dfline)) { $didx = trim(substr($dfline, 0, strpos($dfline, " "))); $desc = trim(substr($dfline, strpos($dfline, " "))); $fb_desc[$didx] = $desc; } } } } // Display each row foreach (array_keys($dsort) as $fidx) { $fi = $fb_arr[$fidx]; $f = $fi["f"]; if ($f == "..") { $dname = nw_apply_template(NW_TMPL_FB_PARENT, array()); $tmpdl = explode("/", trim($real_uri, "/")); array_pop($tmpdl); $dlink = url_to_absolute(implode("/", $tmpdl) . "/"); } else { $dname = $f; $dlink = url_to_absolute($real_uri . rawurlencode($f) . "/"); } if ((substr($f, 0, 1) != "." || $f == ".." || $conf[$vhost]["fbshowdotfiles"][0]) && $f != "." && !($f == ".." && $http_uri == "/")) { $d_row = array(); $d_row["icon"] = $icndir; $d_row["link"] = $dlink; $d_row["name"] = $dname; $d_row["date"] = date($dfmt, $fi[9]); $d_row["desc"] = $fb_desc[$f] ? $fb_desc[$f] : "-"; $resp .= nw_apply_template(NW_TMPL_FB_ROW_D, $d_row, true); } } foreach (array_keys($fsort) as $fidx) { $fi = $fb_arr[$fidx]; $f = $fi["f"]; $fp = pathinfo($f); $t = $mime[strtolower($fp["extension"])]; $icnf = $icndef; if ($icons) { foreach ($icons as $key => $val) { if (strpos($t, $key) === 0) { $icnf = $val; break; } } } if (($f[0] != "." || $f == ".." || $conf[$vhost]["fbshowdotfiles"][0]) && $f != "." && !($f == ".." && $http_uri == "/")) { $f_row = array(); $f_row["icon"] = $icnf; $f_row["link"] = url_to_absolute($real_uri . rawurlencode($f)); $f_row["name"] = $f; $f_row["date"] = date($dfmt, $fi[9]); $f_row["size"] = number_format($fi[7]); $f_row["desc"] = $fb_desc[$f] ? $fb_desc[$f] : "-"; $resp .= nw_apply_template(NW_TMPL_FB_ROW_F, $f_row, true); } } closedir($hnd); $resp .= nw_apply_template(NW_TMPL_FB_FOOTER, $fhdr); } else { $rq_err = 403; } } else { $rq_err = 404; } if ($resp) { $GLOBALS["lf"] =& new static_response($resp); } }
function url(&$rq_err, &$out_contenttype, &$out_add_headers) { $tmpl = array('error_label' => "Protected Email Address", 'error_resource' => "", 'error_add_message' => "", 'error_admin' => '<br><br>the <a href="' . $this->urls[0] . "?" . $this->urlparam_encemail . "=" . mod_emailprotect::encode($GLOBALS["conf"][$GLOBALS["vhost"]]["serveradmin"][0], 1) . '">adminstrator</a> of this server<br>'); $html =& $tmpl['error_resource']; $REQU = $this->_REQUEST(); if ($email = @$REQU[$this->urlparam_encemail]) { if (empty($REQU[$this->urlparam_nospambot])) { $html .= "The email address you've clicked on is protected by this\nform, so it won't get found by <a href=\"http://google.com/search?q=spambots\">spambots</a>\n(automated search engines, which crawl the net for addresses just for the\nentertainment of the marketing mafia).\n<br><br><br>"; $html .= '<form action="' . $this->urls[0] . '" method="POST" enctype="application/x-www-form-urlencoded" encoding="iso-8859-1">'; $html .= '<input type="hidden" name="' . $this->urlparam_encemail . '" value="' . $email . '">'; $html .= '<input type="checkbox" name="' . $this->urlparam_nospambot . '" value="true"> I\'m no spambot, really!<br><br>'; $html .= '<input type="submit" name="go"></form><br><br>'; $html .= "\n<b>spammers, please eat these:</b><br>\n"; $html .= $this->feedbots($REQU); } else { $email = mod_emailprotect::encode($email, -1); $html .= "the email address you've clicked on is:<br>"; $html .= '<a href="mailto:' . $email . '">' . $email . '</a>'; } } $rq_err = 200; $out_contenttype = "text/html"; $r = nw_apply_template(NW_TMPL_ERROR_PAGE, $tmpl) or $r = "<HTML><BODY>{$html}</BODY></HTML>"; return $r; }
function nw_error_page($rq_err) { global $HTTP_HEADERS, $http_resource, $conf, $vhost, $add_errmsg; $err["error_code"] = $rq_err; $err["error_label"] = $HTTP_HEADERS[$rq_err]; $err["error_add_message"] = $add_errmsg; unset($add_errmsg); $err["error_resource"] = $http_resource ? nw_apply_template(NW_TMPL_ERROR_RESOURCE, array("resource_name" => htmlentities($http_resource)), true) : ""; if ($conf[$vhost]["serveradmin"][0]) { $err["error_admin"] = nw_apply_template(NW_TMPL_ERROR_ADMIN, array("admin" => $conf[$vhost]["serveradmin"][0]), true); } $err_page = nw_apply_template(NW_TMPL_ERROR_PAGE, $err) or $err_page = "<html><head><title>" . $HTTP_HEADERS[$rq_err] . "</title></head><body><h1>" . $HTTP_HEADERS[$rq_err] . "</h1></body></html>"; return $err_page; }