static function getTrafficInfo($name) { $oldtime = time() - 40 * 3600; $newtime = time(); $file = "__path_httpd_root/{$name}/stats/{$name}-custom_log"; $file = expand_real_root($file); $fp = @lfopen($file, "r"); $total = 0; dprint("\n{$file}: " . @date('Y-m-d-H-i-s', $oldtime) . " {$newtime} " . @date('Y-m-d-H-i-s', $newtime) . "\n"); if (!$fp) { dprint("File Does Not Exist:returning Zero"); return 0; } $fsize = lfilesize($file); if ($fsize <= 10) { dprint("File Size is Less Than Zero and Returning Zero:\n"); return ""; } dprint("File Size is :{$fsize}\n\n\n"); if ($fsize > 20 * 1024) { fseek($fp, -19 * 1024, SEEK_END); $line = fgets($fp); } $i = 3; $total = 0; $count = 0; while (!feof($fp)) { $count++; $line = fgets($fp); $res[] = webtraffic::apacheLogFullString($line); } $c = 0; foreach ($res as $k => $r) { $c++; if ($count - 50 > $c) { unset($res[$k]); } } $ncount = 0; foreach ($res as $r) { if (!$r['Time']) { continue; } $file = strfrom($r['Request'], " "); $file = strtil($file, "HTTP"); $time = trim($r['Time'], "[]"); $time = strtil($time, " "); $o['realtime'] = $r['realtime']; $o['time'] = $time; $o['nname'] = $ncount; $o['file'] = $file; $o['referer'] = $r['Referer']; $o['remote_host'] = $r['Remote-Host']; $out[] = $o; $ncount++; } return $out; }
function lxfile_tail($file, $getsize) { $size = lfilesize($file); $fp = lfopen($file, "r"); if (!$fp) { return null; } fseek($fp, $size - $getsize); $ret = null; while (!feof($fp)) { $ret .= fread($fp, 1024); } return $ret; }
function do_serve_file($fd, $rem) { $file = $rem->filename; $file = basename($file); $file = "__path_serverfile/{$file}"; if (!lxfile_exists($file)) { log_log("servfile", "datafile {$file} dosn't exist, exiting"); print_or_write($fd, "fFile Doesn't {$file} Exist...\n\n\n\n"); return false; } $array = lfile_get_unserialize($file); lunlink($file); $realfile = $array['filename']; $pass = $array['password']; if ($fd) { dprint("Got request for {$file}, realfile: {$realfile}\n"); } log_log("servfile", "Got request for {$file} realfile {$realfile}"); if (!($pass && $pass === $rem->password)) { print_or_write($fd, "fPassword doesn't match\n\n"); return false; } if (is_dir($realfile)) { // This should neverhappen. The directories are zipped at cp-fileserv and tar_to_filserved then itself. $b = basename($realfile); lxfile_mkdir("__path_serverfile/tmp/"); $tfile = tempnam("__path_serverfile/tmp/", "{$b}.tar"); $list = lscandir_without_dot($realfile); lxshell_tar($realfile, $tfile, $list); $realfile = $tfile; } $fpr = lfopen($realfile, "rb"); if (!$fpr) { print_or_write($fd, "fCouldn't open {$realfile}\n\n"); return false; } print_or_write($fd, "s"); while (!feof($fpr)) { $written = print_or_write($fd, fread($fpr, 8092)); if ($written <= 0) { break; } } // Just send a newline so that the fgets will break after reading. This has to be removed after the file is read. print_or_write($fd, "\n"); fclose($fpr); fileserv_unlink_if_tmp($realfile); return true; }
function lx_phpdebug() { global $gbl, $sgbl; if ($sgbl->dbg <= 0) { return; } if (!lfile_exists("/tmp/.php_debug")) { return; } $fp = lfopen("/tmp/.php_debug", "r"); $s = fgets($fp, 1024); fclose($fp); $s = preg_replace("/--noraise /i", "", $s); $arr = parse_url($s); parse_str($arr['query'], $out); $ghtml->print_input("hidden", "start_debug", "1"); $ghtml->print_input("hidden", "debug_port", $out['debug_port']); $ghtml->print_input("hidden", "debug_text_mode", "1"); $ghtml->print_input("hidden", "debug_no_cache", "1095197145"); }
static function getEachwebfilequota($file, $oldtime, $newtime) { global $gbl, $sgbl, $login, $ghtml; $fp = @lfopen($file, "r"); $total = 0; print "\n{$file}: " . @date('Y-m-d-H', $oldtime) . " " . @date('Y-m-d-H', $newtime) . "\n"; if (!$fp) { print "File Does Not Exist:returning Zero"; return 0; } $fsize = lfilesize($file); if ($fsize <= 10) { print "File Size is Less Than Zero and Returning Zero:\n"; return 0; } print "File Size is :{$fsize}\n\n\n"; $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("webtraffic", "getTimeFromString")); if ($ret < 0) { return; } print "Current Position " . ftell($fp) / $fsize * 100 . "\n"; $total = 0; $count = 0; $break = 1000; while (!feof($fp)) { $count++; $line = fgets($fp); list($time, $size) = self::apacheLogConvertString($line); if ($time > $newtime) { break; } $total += $size; if ($count > 100000) { $break = 10000; } if (!($count % $break)) { print "Count {$count} {$newtime} {$time} {$total} {$size}\n"; } } print "{$count} lines actually processed in {$file}\n"; $total = $total / (1024 * 1024); $total = round($total, 1); fclose($fp); print "Returning Total From OUT SIDE This File: {$total} \n"; return $total; }
function show_help_file($hhelp_file) { global $gbl, $login, $ghtml; $help_file = getreal($hhelp_file); if (!lfile_exists($help_file)) { dprint("Debug Message: File <h3> <font color=red> {$hhelp_file} Doesn't Exist </font> </h3> . Showing default</h1> "); lfile_put_contents("missing.txt", $hhelp_file . "\n", FILE_APPEND); return 0; } dprint(" Debug Message: Showing <h3> {$hhelp_file} </h3> "); $fp = lfopen($help_file, "r"); if (!$fp) { print "cannot open {$help_file} <br> "; return 0; } $last = ""; $inblock = "out"; while (!feof($fp)) { $buf = fgets($fp, 1024); $buf = trim($buf); if (preg_match("/<reseller>/", $buf)) { $inblock = "reseller"; continue; } if (preg_match("/<notlogin>/", $buf)) { $inblock = "notlogin"; continue; } if (preg_match("/<admin>/", $buf)) { $inblock = "admin"; continue; } if (preg_match("/<lximg:\\s*([^>]*)>/", $buf, $matches)) { $img = $matches[1]; $buf = preg_replace("/<lximg:\\s*([^>]*)>/", "<img src=/img/image/collage/\$1>", $buf); print $buf . "\n<br>"; continue; } $buf = preg_replace("/<\\/link>/", "</a>", $buf); if (preg_match("/.*<link:\\s*([^>]*)>.*/", $buf, $matches)) { $url = $matches[1]; $url = str_replace(".dart", "", $url); $buf = preg_replace("/<link:\\s*([^>]*)>/", "<a href=/htmllib/mibin/help.php?frm_action=show&frm_q={$url}>", $buf); print $buf . "<br> "; continue; } if (preg_match("/<\\/reseller>/", $buf) || preg_match("/<\\/admin>/", $buf)) { $inblock = "out"; continue; } if (preg_match("/<\\/notlogin>/", $buf)) { $inblock = "out"; continue; } if ($login->isGte('reseller') && $inblock === "admin") { continue; } if ($login->isLogin() && $inblock === 'notlogin') { continue; } if ($login->isGte('customer') && ($inblock === "reseller" || $inblock === "admin")) { continue; } $buf = preg_replace("/href=(\\S*).dart/i", "href=/htmllib/mibin/help.php?frm_q=/\$1", $buf); if (preg_match("/:\\[.*\\]:/", $buf)) { $buttonpath = get_image_path() . "/button/"; $value = preg_replace("/.*:\\[(.*)\\]:.*/", "\$1", $buf); $rest = preg_replace("/.*:\\[.*\\]:/", "", $buf); $ghtml->get_post_from_get(trim($value), $path, $post); $descr = $ghtml->get_action_descr($path, $post, $class, $name); $image = $ghtml->get_image($buttonpath, $class, $name, ".gif"); print "<img src={$image}> <b> {$descr['1']}: </b> {$rest} <br> <br> "; continue; } if ($buf === '') { if ($last === "blank") { continue; } $last = "blank"; $buf = "</p> <p> "; } else { if ($last === "blank") { $last = ""; } $buf = $buf . "<br> \n"; } print $buf; } return 1; }
static function fixErrorLogbad($list) { global $gbl, $sgbl, $login, $ghtml; $file = "/home/kloxo/httpd/lighttpd/error.log"; $fp = lfopen($file); if (!$fp) { return; } while (!feof($fp)) { $s = fgets($fp); foreach ($list as $l) { if (csa($s, $l)) { $out[$l] .= $s; } } } foreach ($out as $k => $v) { lfile_put_contents("/home/httpd/{$k}/stats/{$k}-error_log", $v, FILE_APPEND); } fclose($fp); $fp = getNotexistingFile(dirname($file), $file); lxfile_mv($file, $nfile); }
static function upload_to_server($file, $uploadfilename, $object) { $fn = ftp_connect($object->ftp_server); $mylogin = ftp_login($fn, $object->rm_username, $object->rm_password); if (!$mylogin) { $p = error_get_last(); throw new lxException('could_not_connect_to_ftp_server', '', $p); } ftp_pasv($fn, true); $fp = lfopen($file, "r"); if ($object->rm_directory) { ftp_mkdir($fn, $object->rm_directory); ftp_chdir($fn, $object->rm_directory); } $ret = ftp_fput($fn, $uploadfilename, $fp, FTP_BINARY); if (!$ret) { $p = error_get_last(); log_log("ftp_error", $p); throw new lxException('could_not_upload_file', '', $object->ftp_server); } fclose($fp); if ($object->isOn('no_local_copy_flag')) { lunlink($file); } }
if (preg_match("/Mozilla\\/\\d.+Compatible; MSIE/i", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/Opera/i", $_SERVER['HTTP_USER_AGENT'])) { header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Expires: 0'); header('Pragma: no-cache'); } include "common.php"; include "ircfunc.php"; $gl_never_responded = 1; $gl_client_started = 0; $livetrfp = null; if ($g_login) { $livetrfp = lfopen("__path_program_etc/livetranscript.txt", "a"); } /* $channel = $_GET['channel']; echo "$channel <br>"; if (!$channel) { $channel = $channels[0]; } */ if ($redirect) { $channel = "{$chanbase}-command"; } else { $channel = $chanbase; } $licid = $_GET['licid']; $user = $_GET['username'];