• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Website Problem Again xD

RunarM

Finally back
Joined
Jul 17, 2008
Messages
1,636
Reaction score
34
Location
Norway/Tromsø
Still working on my uploading website, but i still need some help.
How can i put my counter into my php file?
Counter:
Code:
<? 
    $file = "counter.txt"; 
    if (!file_exists($file)) 
    { 
        touch($file); 
        $handle = fopen($file, 'r+'); 
        $str = "<? \$count=0 ?>"; 
    } 
    else 
    { 
        include "counter.txt"; 
        $count++; 
        $str = "<? \$count=".$count." ?>"; 
        $handle = fopen ($file, 'r+'); 
    } 

    fwrite($handle, $str); 
    fclose($handle); 
    
    echo 'Views: ';
    echo $count; 
?>

(Please explain, i am not good with php, html etc...)

Thanks for helping
Yours, Runarm.
 
Last edited:
hmm u can test to take html from piczo.com sites XD

they got counter and take their html code and set it to ur config.lua :)

rep++? if it works

im not sure it will works but i will try it myself :)
 
PHP:
<?
	$file = "counter.txt";
	if (!file_exists($file))
	{
        touch($file);
        $handle = fopen($file, 'r+');
        $str = "<? \$count=0 ?>";
	}
	else
	{
        include "counter.txt";
        $count++;
        $str = "<? \$count=".$count." ?>";
        $handle = fopen ($file, 'r+');
	}

	fwrite($handle, $str);
	fclose($handle);
	
	echo $count;
?>
 
hmm u can test to take html from piczo.com sites XD

they got counter and take their html code and set it to ur config.lua :)

rep++? if it works

im not sure it will works but i will try it myself :)

I want a easy counter, not a fancy piczo counter :p
Something like: 2304 has visited the site..
 
here

test to add this:
Code:
<a href="javascript:addObjectToPage('hitCounter', true)" class="btn_toolbar_green" title="This will let visitors see how many visits your page has."><img src="http://cdnimg.piczo.com/images/toolbar/newtoolbar/icon_toolbar_hit_counter.gif" align="absmiddle" border="0" height="12" width="12">HIT COUNTER</a>

thats like that (

2304 hits

)
 
Script

PHP:
<?php
$file = 'counter.txt';
$cookie = 'visited';
$count = @file_get_contents($file);
if (!is_int((int)$count)) $count = 0;
if (!isset($_COOKIE[$cookie])) {
    $count++;
    if(@file_put_contents($file, $count)!=FALSE) 
        setcookie($cookie, '1', time()+60*60*24*30);
    else die("File $file is not writable !");
}
echo $count.' hits.';
?>

Preview: http://dondaniello.com/pliki/skrypty/counter.php
 
Last edited:
PHP:
<?php
$file = 'counter.txt';
$cookie = 'visited';
$count = @file_get_contents($file);
if (!is_int((int)$count)) $count = 0;
if (!isset($_COOKIE[$cookie])) {
    $count++;
    if(@file_put_contents($file, $count)!=FALSE) 
        setcookie($cookie, '1', time()+60*60*24*30);
    else die("File $file is not writable !");
}
echo $count.' hits.';
?>

Preview: http://dondaniello.com/pliki/skrypty/counter.php

It dosnt work...
Do i need counter.txt?
 
2 options:
first one:
- paste script to file counter.php
- in your script add include('counter.php');
second one:
- add this script into yours where you want counter displayed, without <?php and ?>
 
Back
Top