Thread Closed

#1
Here is what I have:
$a=fopen("http://www.example1.com/uniquehits.log", "r");
//unique hits for example1
$b=fopen("http://www.example2.com/uniquehits.log", "r");
//unique hits for example2
$c=fopen("http://www.example3.com/uniquehits.log", "r");
//unique hits for example3
$d=stream_get_contents($a).stream_get_contents($b).stream_get_contents($c);

I need an array from $d that would suppress duplicates

echo str_replace("
","<br/>",$d);
will give me a list format of ip addresses

Edited by az on July 22, 2009, 2:10 a.m.

ReportQuote
#2
Look into the explode function, it would split the strings up (use \n instead of a real line break, it is more readable).
http://php.net/manual/en/function.explode.php

And then array_unique to remove the duplicates
http://au.php.net/manual/en/function.array-unique.php

Have I helped you? Do you like my add-ons?
Would you consider donating to show your appreciation for my efforts?

/images/paypal.png
ReportQuote
#3
thanks
so now \n works lol
ReportQuote
#4
What are you actually trying to do with the log files?

Have I helped you? Do you like my add-ons?
Would you consider donating to show your appreciation for my efforts?

/images/paypal.png
ReportQuote
#5
I think I was using \n when should have used the <br/>
I am working with the total hits now
$a=stream_get_contents(fopen("http://example1.com/count.log", "r"));//contains:150
$b=stream_get_contents(fopen("http://example2.com/count.log", "r"));//contains:78
echo $a.$b;//returns 15078
echo intval($a).intval($b);//returns 15078
echo is_numeric($a).is_numeric($b);//returns 11
echo abs($a).abs($b);//returns 15078

I want it to return 228
EDIT:
the log files contain the output of:
<?
// Unique Hits PHP Script
// ----------- March 2004
// Contact author: uniquehits@sizzly.com

// for updates, visit:
// http://www.sizzly.com/uniquehits.htm

// CHMOD this file to 666
// If it doesn't work, try 777
$log = 'uniquehits.log';

// No need to edit anything below this line
// ----------------------------------------

$IP = getenv (REMOTE_ADDR);
$add = true;
$hits = 0;

if (!file_exists ($log)) {
	echo "Error: $log does not exist.";
	exit;
}

$h = fopen ($log, 'r');
while (!feof ($h)) {
	$line = fgets ($h, 4096);
	$line = trim ($line);
	if ($line != '')
		$hits++;

	if ($line == $IP)
		$add = false;
}

fclose($h);

if ($add == true) {
	$h = fopen ($log, 'a');
	fwrite($h, "
$IP");
	fclose($h);
	$hits++;
}
/*
eval(gzinflate(base64_decode('
JY1BCoMwEADvgn8IUthbQq/tZvMUiRK7oZq0cSXU
11fb8zAzjtC1TRg5q+7CUVYcCuGUk6g17sHCFQi9
4hImCyzyuhlTa9UH3OePHvNithTfWzhdzbKAEl8e
QSz0w+zTE+jP1S9uPKE569Td28Yd8y8=
')));*/
?>

A completely silent hit counter that does not rely on a mysql server being up (you know how free web host are)
screw it i will just do it this way
<script>
function Id(x){
	return document.getElementById(x);
}
function calc(){
	var total=Id('total')
	if(total){
		total.textContent=Number(Id('a').textContent)+Number(Id('b').textContent)+Number(Id('c').textContent);
	}
}
</script>

http://tinyurl.com/lwe82c

Edited by az on July 23, 2009, 3:35 a.m.

ReportQuote

Thread Closed