Версия для печати темы

Нажмите сюда для просмотра этой темы в обычном формате

MyDC.ru _ Общалка aka Флуд _ Что Это Такое?

Автор: MEXAHuK 26.1.2009, 20:26

сабж:

CODE
<title>DC Hub Connection Logs</title>
<?php
//Note: anything with "//" before it is a comment
//Anything with "/*" is the start of a comment for a block of code
//Anything with "*/" is the end of a comment for a block of code
//Rename this file to index.php and place it in your root web directory if you want it to load by default

/*
Uncomment these lines if you want to restrict access to this site to only 127.0.x.x networks
and 197.145.x.x networks. You can change the IP address values as needed. Delete this comment also
$test = "^197.145";
$test2 = "^127.0";
$ip = $_SERVER['REMOTE_ADDR'];
if (!eregi($test,$ip) && !eregi($test2,$ip)){
echo "Please wait...";
exit(0);
}
*/

ini_set('display_errors','FALSE'); //we don't want to see any errors; set to TRUE for debugging
error_reporting(E_ALL); //no error reporting; set to error_reporting(0); for debugging
$logfolder = "C:/0.4.1.1/scripts/Rincewind's Grimoire/Settings/Security/UserLog/Logs"; //folder containing the Grimore logs
if (is_dir($logfolder)){
chdir($logfolder);
$error = "";
}
else {
$error = "Could not find log folder.";
}
$debug = FALSE; //Do not show debugging information
$dbx = array();
$forbidden = array(
"",
"..",
".",
"RECYCLER",
"System Volume Information",
"Copy of "
);

//logfile format:
//connect-disconnect, date, time, name, ip, description, email, version, share, mode, speed

?>
<h1 onclick="window.location='grimoirelogsfinal.php'">Search</h1>
<?php echo "<font color=red>$error</font>" ?>
<table>
<tr>
<td>Location
<td>String
<td>Search only today
<td>
</tr>
<tr>
<form name="search" method=get action=<?php echo $_SERVER['SCRIPT_NAME'] ?>>
<td><select name="location">
<option value=0>C/D
<option value=1>Date
<option value=2>Time
<option value=3 selected>Nick
<option value=4>IP
<option value=5>Comment
<option value=6>Email
<option value=7>Version
<option value=8>Share
<option value=9>Mode
<option value=10>Connection
</select>
<td><input type="text" name="searchstring">
<td><input type="checkbox" name="t" checked>
<td><button>Search</button>
</tr>
</table>
<table>
<tr>
<td>C/D
<td>Time
<td>Date
<td>Nick
<td>IP
<td>Comment
<td>Email
<td>Version
<td>Share
<td>Mode
<td>Connection
</tr>
<tr>
<td><input type="checkbox" name="0">
<td><input type="checkbox" name="1">
<td><input type="checkbox" name="2" checked>
<td><input type="checkbox" name="3" checked>
<td><input type="checkbox" name="4" checked>
<td><input type="checkbox" name="5">
<td><input type="checkbox" name="6" checked>
<td><input type="checkbox" name="7">
<td><input type="checkbox" name="8" checked>
<td><input type="checkbox" name="9">
<td><input type="checkbox" name="10">
</tr>
</table>
<br><input type="checkbox" name="debug"> Debug
<br><input type="checkbox" name="raw"> Raw results <p>
<?php
if (isset($_GET['debug'])){
$debug=TRUE;
}
if ($debug){
echo "<tt>Opening Directory: $logfolder<br>";
}
if (isset($_GET['location'])){
//Old log file format for logs in Grimoire v4.1.0
//If you are using Grimoire v5.1.1 only...delete the entire section of code below
//until the next comment where I tell you to stop
$files = scandir($logfolder);
if (isset($_GET['t'])){
$filename = "ConnectionLog-" . date('Y-m-d') . ".csv";
$files = "";
$files = array($filename);
}
for($i=0; $i<count($files); $i++){
if(is_file($files[$i]) && !array_search($files[$i],$forbidden)){
if ($debug){
echo "<tt>Loading $files[$i]...</tt><br>";
}

load_file($files[$i]);
}
}

//Stop deleting the section for the Grimoire v4.1.0 logs here

//New log file format for logs in Grimoire v5.1.1
//If you are using a previous version of Grimoire (like v4.1.0)...delete the entire section of code below
//until the next comment where I tell you to stop
$files = scandir($logfolder);
if (isset($_GET['t'])){
$filename = "UserLog-" . date('Y-m-d') . ".csv";
$files = "";
$files = array($filename);
}
for($i=0; $i<count($files); $i++){
if(is_file($files[$i]) && !array_search($files[$i],$forbidden)){
if ($debug){
echo "<tt>Loading $files[$i]...</tt><br>";
}

load_file($files[$i]);
}
}
//Stop deleting the section for the Grimoire v5.1.1 logs here

$results_local = parse_data();
global $results;
$results = $results_local;
if ($debug){
echo "Results:<pre>"; print_r($results); echo "</pre>";
for ($j=0; $j<=10; $j++){
for ($i=0; $i<20; $i++){
echo "($i,$j)<br>";
}
}
}
if ($debug){
//echo "Search:<pre>"; print_r($dbx); echo "</pre>";
echo "<tt>Finished.</tt><br>";
}
if (isset($_GET['raw'])){

}
?>
<table border=1>
<tr>
<?php
if (isset($_GET['0'])){
echo "<td>C/D\r";
}
if (isset($_GET['1'])){
echo "<td>Time\r";
}
if (isset($_GET['2'])){
echo "<td>Date\r";
}
if (isset($_GET['3'])){
echo "<td>Nick\r";
}
if (isset($_GET['4'])){
echo "<td>IP\r";
}
if (isset($_GET['5'])){
echo "<td>Comment\r";
}
if (isset($_GET['6'])){
echo "<td>Email\r";
}
if (isset($_GET['7'])){
echo "<td>Version\r";
}
if (isset($_GET['8'])){
echo "<td>Share\r";
}
if (isset($_GET['9'])){
echo "<td>Mode\r";
}
if (isset($_GET['10'])){
echo "<td>Connection\r";
}
?>
</tr>
<tr>
<?php
$linkme = $_SERVER['REQUEST_URI'];
$needle = $_GET['searchstring'];
$linkme = strstr($linkme,$needle);
$linkme = strstr($linkme,'&');
if (isset($_GET['0'])){
echo "<td valign=top>";
foreach($results[0] as $value){
echo "$value<br>";
}
}
if (isset($_GET['1'])){
echo "<td valign=top>";
foreach($results[1] as $value){
echo "$value<br>";
}
}
if (isset($_GET['2'])){
echo "<td valign=top>";
foreach($results[2] as $value){
echo "$value<br>";
}
}
if (isset($_GET['3'])){
echo "<td valign=top>";
foreach($results[3] as $value){
echo "<a href=\"?location=3&searchstring=$value$linkme\">$value</a><br>";
}
}
if (isset($_GET['4'])){
echo "<td valign=top>";
foreach($results[4] as $value){
echo "<a href=\"?location=4&searchstring=$value$linkme\">$value</a><br>";
}
}
if (isset($_GET['5'])){
echo "<td valign=top>";
foreach($results[5] as $value){
echo "$value<br>";
}
}
if (isset($_GET['6'])){
echo "<td valign=top>";
foreach($results[6] as $value){
echo "$value<br>";
}
}
if (isset($_GET['7'])){
echo "<td valign=top>";
foreach($results[7] as $value){
echo "$value<br>";
}
}
if (isset($_GET['8'])){
echo "<td valign=top>";
foreach($results[8] as $value){
echo "$value<br>";
}
}
if (isset($_GET['9'])){
echo "<td valign=top>";
foreach($results[9] as $value){
echo "$value<br>";
}
}
if (isset($_GET['10'])){
echo "<td valign=top>";
foreach($results[10] as $value){
echo "$value<br>";
}
}
?>
</tr>
</table>
<?php
}


function max_share($data){
static $maxshare = 0;
static $maxusers = 0;
static $currentshare = 0;
static $currentusers = 0;
$share = explode(" ",$data[8]);
switch ($share[1]){
case "KiBs":
$nshare = $share[0];
break;
case "MiBs":
$nshare = $share[0]*1000;
break;
case "GiBs":
$nshare = $share[0]*10000;
break;
case "TiBs":
$nshare = $share[0]*100000;
break;
}

echo "$share[0]$share[1] = $nshare KiBs<br>";
if ($data[0] == "C"){
$currentshare = $currentshare + $nshare;
}

if ($data[0] == "D"){
$currentshare = $currentshare - $nshare;
}

if ($currentshare > $maxshare){
$maxshare = $currentshare;
$show = $maxshare/1000000;
echo "Maxshare: $show TB<br>";
}

}
function load_file($file){
global $debug, $dbx;
$line = file($file);
for($i=0; $i<count($line); $i++){
$data = split(",",$line[$i]);
if ($debug){
//echo "<tt>Beginning search()...</tt><br>";
}
search($data);

if ($debug){
//echo "<pre>"; print_r($results); echo "</pre>";
}
//max_share($data);

}
if ($debug){
echo "<tt>Beginning parse_data()...</tt><br>";
}

}
function search($data){
global $debug, $dbx;
$index = $_GET['location'];
if ($data[$index] == $_GET['searchstring']){
if ($debug){
echo "<tt>$data[0]\t$data[1]\t$data[2]\t$data[3]\t$data[4]\t$data[5]\t$data[6]\t$data[7]\t$data[8]\t$data[9]\t$data[10]\t</tt><br>";
}
if (isset($_GET['raw'])){
echo "<tt>$data[0]\t$data[1]\t$data[2]\t$data[3]\t$data[4]\t$data[5]\t$data[6]\t$data[7]\t$data[8]\t$data[9]\t$data[10]\t</tt><br>";
}
$dbx[] = $data;

}
}
function parse_data(){
global $dbx, $debug;
$result = array_fill(0,11,array());
$total = count($dbx);
echo "Found <b>$total</b> entries.";
if ($debug){
echo "<b>$total</b>";
//$dbx[row entry (0,1,2,3,4)][current column(c/d,date,ip,nick)]
}

for ($j=0; $j<=10; $j++){

for ($i=0; $i<$total; $i++){
if ($debug){
echo "<tt>($i,$j)</tt><br>";
}
$needle = $dbx[$i][$j];
$haystack = $result[$j];

if ($debug){
echo "<tt>Searching for {$dbx[$i][$j]} in result($j) ($i,$j)</tt><br>";
}
if (!in_array($needle,$haystack)){
if ($debug){
echo "<tt>{$dbx[$i][$j]} Was not found.</tt><br>";
$use = count($result[$j]);
$use++;
}
$result[$j][] = $dbx[$i][$j];
if ($debug){
echo "<pre>"; print_r($result); echo "</pre>";
}
}
else{
if ($debug){
echo "<tt>{$dbx[$i][$j]} FOUND, skipping<br>";
break;
}
}

}

}
return $result;
}

?>

Автор: Wariner 26.1.2009, 20:31

а тебе не кажется что ты форумом ошибся, ну или хотя бы разделом?!!!

PS: тему перенёс....