function viewer_tar($fp, $filename, $ext, $dir, $query_string) { global $tar_exec, $gunzip_exec, $viewers; switch ($ext) { case "tgz": case "gz": $tar_parms = " -tzf "; break; default: $tar_parms = " -tf "; } $find_ext = explode(".", strtolower($filename)); $gz_ext = $find_ext[count($find_ext) - 2]; $tmp_name = tempnam("/tmp", "tar"); $tp = fopen($tmp_name, "w+"); while (!feof($fp)) { fwrite($tp, fread($fp, 1024), 1024); } fclose($tp); $out_fp = tmpfile(); if ($ext == "tar" || $ext == "tgz" || $gz_ext == "tar") { fwrite($out_fp, sprintf("%s %s:\n\n", gettext("Listing of"), $filename)); fwrite($out_fp, shell_exec($tar_exec . $tar_parms . $tmp_name)); $file = array("text/plain", $out_fp); } else { fwrite($out_fp, shell_exec($gunzip_exec . " -c " . $tmp_name)); rewind($out_fp); if (compat_array_key_exists($gz_ext, $viewers)) { $use_viewer = $gz_ext; } else { $use_viewer = "default"; } $file = $viewers[$use_viewer]($out_fp, $filename, $gz_ext, $dir, $query_string); } unlink($tmp_name); return $file; }
function find_theme($fp, $personal, $default_theme) { // if a theme is specified if (compat_array_key_exists("theme", $personal)) { // if the user is using their personal theme if ($personal["theme"] == "personal") { // point to the beginning of the array reset($personal); // grab the first value in the array $temp = each($personal); while ($temp) { // if the key is a theme variable if (substr($temp["key"], 0, 4) == "thm_") { $theme[$temp["key"]] = $personal[$temp["key"]]; } $temp = each($personal); } } else { // if the theme exists if (@is_readable("themes/" . $personal["theme"] . ".thm")) { // open the file $tp = fopen("themes/" . $personal["theme"] . ".thm", 'r'); // grab the theme $theme = load_theme($tp); // close the file fclose($tp); } } } else { // if the theme exists if (@is_readable("themes/" . $default_theme . ".thm")) { // open the file $tp = fopen("themes/" . $default_theme . ".thm", 'r'); // grab the theme $theme = load_theme($tp); // close the file fclose($tp); } } // return the updated theme return $theme; }
exit; } // default settings loaded, may be overwritten when preferences get loaded // to handle older .wfmrc files $personal["language"] = $default_lang; $personal["prev_size"] = $editor_prefs["preview_size"]; $personal["edit_col"] = $editor_prefs["cols"]; $personal["edit_row"] = $editor_prefs["rows"]; $personal["show_hidden"] = FALSE; // load users theme if allow_custom setting is on if ($allow_custom) { // load the .wfmrc file, then load the appropriate theme // overwrites default settings set earlier $personal = array_merge($personal, load_settings($fp, $default_theme, $def_Display_Hidden, $numeric_val)); // if the user specified to start in a different dir from his home dir if (compat_array_key_exists("start_dir", $personal) && $personal["start_dir"] != "") { $location = "Location: crossover.php?SID=" . session_id() . "&submit=CD&CHDIR={$personal['start_dir']}" . $lang_loc; } } $theme = find_theme($fp, $personal, $default_theme); // Following variables are stored in an array in the session in this order // user - user who is logging in // pass - users encrypted (if supported) password // server - server connected too // port - port connected on // dir - current directory // warn - warning messagez // IP - remote IP address // level - warning severity level // Server Name - Display name for the ftp server (selected from the login dropdown) $sess_Data = array("user" => $ftp_User, "pass" => $enc_ftp_Pass, "server" => $ftp_Server, "port" => $ftp_Port, "dir" => ftp_pwd($fp), "warn" => "", "level" => 0, "Server Name" => $login_server, "IP" => $REMOTE_ADDR);
"> </td> </tr> <tr> <td colspan=2 align="center"> <?php $cookie_checked = ""; if ($cookie_present) { $cookie_checked = " CHECKED"; } if (!$ftp_remember_me) { $cookie_checked = " DISABLED"; } printf("<input type=\"checkbox\" name=\"ftp_Remember\" value=\"TRUE\" %s> %s\n", $cookie_checked, gettext("Remember Me")); // Pass the language if it's set. if (isset($_GET) && compat_array_key_exists('lang', $_GET)) { printf("<input type=\"hidden\" name=\"lang\" value=\"%s\">", $_GET['lang']); } ?> </td> </tr> <?php if ($cookie_present == TRUE) { print " <tr class=\"alt_row\">"; print " <td colspan=2 align=\"center\" style=\"font-size: smaller\">"; printf(" <A href=\"%s?nocookie=1\">%s</A>", $PHP_SELF, gettext("Remove Login Cookie")); print " </td>"; print " </tr>"; } ?> </table>
// Get a list of viewer files in the viewers directory. $dp = opendir($viewer_dir); while ($viewer_file = readdir($dp)) { if (substr($viewer_file, strlen($viewer_file) - 4) == ".php") { $viewer_list[] = $viewer_file; } } closedir($dp); // Set the default viewer. $viewers["default"] = "viewer_" . $viewer_default; foreach ($viewer_list as $val) { if (is_readable($viewer_dir . $val)) { require_once $viewer_dir . $val; } } if (compat_array_key_exists($ext, $viewers)) { $use_viewer = $ext; } else { $use_viewer = "default"; } $viewer_return = $viewers[$use_viewer]($tp, $Filename, $ext, ftp_pwd($fp), $QUERY_STRING); header("Content-Disposition: inline; filename=\"{$PHP_SELF}\"\n\n"); $header = "Content-type: " . $viewer_return[0] . "; name=\"{$PHP_SELF}\"\n\n"; header($header); rewind($viewer_return[1]); fpassthru($viewer_return[1]); } else { printf("<HTML><HEAD><TITLE>VHCS File Manager %s: %s</TITLE></HEAD>\n", "Viewer", "Error"); printf("<BODY><P>%s: %s \"%s\".</P>\n</BODY></HTML>", "Error", "An error occurred while trying to retrieve", $Filename); exit; }
<?php /* Weeble File Manager (c) Christopher Michaels & Jonathan Manna This software is released under the BSD License. For a copy of the complete licensing agreement see the LICENSE file. */ require_once "tools/compat.php"; if (isset($_GET) && compat_array_key_exists('lang', $_GET)) { $iso_code = $_GET['lang']; if (isset($personal)) { $personal['language'] = $_GET['lang']; } } elseif (isset($personal) && compat_array_key_exists('language', $personal)) { $iso_code = $personal['language']; } else { $iso_code = $default_lang; } putenv('LANGUAGE=' . $iso_code); putenv('LC_ALL=' . $iso_code); $locale_path = dirname($_SERVER['SCRIPT_FILENAME']) . '/lang'; bindtextdomain('messages', $locale_path); textdomain('messages'); // need to write some kinda of substitute for gettext() if it doesn't exist, // even if all it does is return the test passed to it. Otherwise we'll // be dependant on gettext().
} else { $output[$input_type] .= $input_line; } } if ($search_found == TRUE || !isset($search)) { foreach ($output as $key => $val) { if ($key != "category") { $val = str_replace($wfm_html_tags, $wfm_bb_tags, $val); $val = htmlentities($val); $val = str_replace($wfm_bb_tags, $wfm_html_tags, $val); } else { $val = htmlentities($val); } $output[$key] = $val; } if (!isset($wfm_sol_files) || !compat_array_key_exists("category", $output) || !compat_array_key_exists($output["category"], $wfm_sol_files)) { $wfm_sol_files[$output["category"]] = tmpfile(); } $wfm_docs_found["total"]++; $wfm_docs_found[$output["category"]]++; $out_id = substr($sol_file, 0, strlen($sol_file) - 4); fwrite($wfm_sol_files[$output["category"]], sprintf("<P><A NAME=\"%s\"></A>ID: <A HREF=\"{$PHP_SELF}?id=%s\">%s</A><BR>\n", $out_id, rawurlencode($out_id), $out_id)); fwrite($wfm_sol_files[$output["category"]], sprintf("Modified: %s<BR>\n", date("D M j G:i:s T Y", filectime($wfm_sol_dir . $sol_file)))); fwrite($wfm_sol_files[$output["category"]], sprintf("Version(s): %s<BR>\n", $output["version"])); fwrite($wfm_sol_files[$output["category"]], sprintf("Keyword(s): %s</P>\n", $output["keyword"])); fwrite($wfm_sol_files[$output["category"]], sprintf("<H4>Problem:</H4>\n<BLOCKQUOTE>%s</BLOCKQUOTE>\n", text_to_links($output["problem"]))); fwrite($wfm_sol_files[$output["category"]], sprintf("<H4>Solution:</H4>\n<BLOCKQUOTE>%s</BLOCKQUOTE>\n", text_to_links($output["solution"]))); foreach ($wfm_types as $val) { unset($output[$val]); } if (count($output) > 1) {