# # Unspecified copying policy, please contact the author # Banmiklos,,, #============================================================================= $timestamp = time(); $startday = mktime(0,0,0,10,22,2003); $alldays = round(($timestamp-$startday)/60/60/24); $VER = '0.3.2'; session_start(); $file_name = split ("/", $PHP_SELF); $h = count($file_name)-1; $hitfile = "./sb_counter/".$file_name[$h].".txt"; ## txt where the hits are stored if (!file_exists($hitfile)) { if(!touch ($hitfile)) { print "Can't be create $hitfile! ... exitting now --"; exit; } } else { $fp = fopen($hitfile,"r+"); ## file pointer if(filesize($hitfile)) $hits = fread($fp,filesize($hitfile)); else $hits = 0; if ($$file_name != $file_name) { fseek($fp,0); ftruncate($fp,0); ## clear the file out $hits++; fwrite($fp,$hits); $_SESSION["$file_name"] = $file_name; } fclose($fp); } ## The graphical counter (delete this part if you use text counter) $ghits = $hits; $garray = array(); while ($ghits) { $flt = $ghits%10; $int = sprintf("%d", $ghits/10); array_push($garray,"$flt"); $ghits = $int; } if ( count($garray) < 5 ) { $c = 5-count($garray); for($i=0;$i<$c;$i++) { array_push($garray,"0"); } } ## End of graphical counter part ============================== $garray2 = $garray; ## ============================== F U N C T I O N S ============================= function semigraphic($STYLE,$TEXT_3,$garray,$TEXT_4,$date,$TEXT_5) { if ($STYLE == 'palladio') { $PRE = 'a'; } else { $PRE = ''; } print "
$TEXT_3  "; while($garray) { $hits = array_pop($garray); print " "; } print "
 $TEXT_4 $date $TEXT_5
"; } ## =========================== E N D F U N C T I O N S ========================= if (!isset($lang)) { $language = $HTTP_ACCEPT_LANGUAGE; $lang = substr($language,0,2); } if ( $lang == 'en' ) { $TITLE = 'Session Based Visiting Counter'; $TEXT_0 = "[magyarul]"; $TEXT_0_1 = "

Session based web visiting counter

The session based method is a solution that the counter value only increase at the time when new visitor come to your page.
The counter will count only if the visitor opens a new session. Basically it means that a new browser window is opened after the previous was closed.

Hereinafter I show to two shape visitor counters:

1. PHP visiting counter (v.$VER) :
If your web server or webcaster support php.
To use this counter download the script below, insert the php code into your html page. Make a directory 'sb_counter' in the parent directory of your page. The directory's owner should be the owner of the web server, i.e. 'www-data' on debain systems. Script will try to create the file which contains the counter data, but if it is unsuccessful, you'll see an error message on the web page (unless your php is set otherwise)."; $TEXT_0_2 = "

2. If You haven't got Your own web-server, or your webcaster doesn't support php
Insert the the undermentioned javascript code into your page where you want to visualize the counter value. Your counter value will be stored in our server. The disadvantage of this counter is that it can only be viewed with browsers that support javascript.

You've got the possibility that you to manipulate your counter's appearance with by handing over the parameters described hereinafter:

'<SCRIPT src='http://kornel.zool.klte.hu/pub/counter/server_side_SBcounter.php?start=500&size=14px&color=gray&style=staki:deadea,abcdef'></SCRIPT>'

The seeded part is an example to parameters. You can deliver over the parameters after the ? and the & symbols separate the parameters. In the given example the start assigns a start value for your counter, e.g. 500 here (the server storages the real value). The size parameter is to define the size of numbers (default is 12 pixels). The color parameter defines the numbers' color (default is black). With the style parameter you can make CSS style border around the numbers. The method is this: style=staki means that you want to make a border. Two comma separeted color codes come after the :fill color,border color. If the parameter is ?graphic=basic, then numbers will be visualized in the semigraphic style showed hereinafter."; $TEXT_0_3 = "If you ask me, why it is good for me storaging the visiting value of Your page, that is a justifiable question. The counter value appears as hiperlink in your page. The link points to a page determined by me, so I will have more incoming links...

"; $TEXT_1a = 'paremeter is ?color=red:'; $TEXT_1b = 'paremeter is ?style=staki:ffffff,114253&size=10&weight=normal:'; $TEXT_2a = 'paremeter is ?graphic=basic:'; $TEXT_2b = 'paremeter is ?graphic=paladio:'; $TEXT_3 = 'This page was visited'; $TEXT_4 = 'times last'; $TEXT_5 = 'days.'; $TEXT_6 = 'view php counter source'; $TEXT_7 = 'download php counter'; $TEXT_8 = 'This file was downloaded'; $TEXT_9 = 'times'; # $TEXT_10 = 'Some example appearance (see more):'; $TEXT_10 = 'Some example appearance:'; $TEXT_11 = 'Counter stats'; } else { $TITLE = 'Session Alapú Látogatottság Számláló'; $TEXT_0 = "[in english]"; $TEXT_0_1 = "

Session alapú web látogatottság számláló

A session alapú módszer megoldás, hogy a számlálód értéke csak akkor növekedjen ha valóban új találat éri az oldaladat.
A számláló értéke csak akkor növekszik, ha a látogató új sessiont nyit. Ez alapesetben azt jelenti, hogy új böngésző ablak lett nyitva, miután az előző be lett zárva.

Az alábbiakban kétféle látogatottság számlálót teszek közzé:

1. PHP látogatottság számláló (v.$VER) :
Ha a webszervered, vagy a szolgáltatód támogatja a php-t.
Hogy használni tudd ezt a számlálót töltsd le a scriptet lentebb, illeszd bele a HTML oldaladba a php kódot. Hozz létre egy könyvtárat sb_counter néven egy könyvtárszinttel feljebb mint az oldalad van. A könyvtár tulajdonosa a webszerver tulajdonosa legyen pl: debian rendszeren 'www-data'. A számláló adatokat tartalmazó fájlt a szkript próbálja meg létrehozni, ha ez nem sikerül, hibaüzenetet fogsz látni a weboldaladon (ha nincs másképp beállítva a php)."; $TEXT_0_2 = "

2. Ha nincs webszervered, vagy nem lehet a webszolgáltatódnál php-t futtatni,
illeszd be a lapodba az alábbi javascript kódot ahol a számláló értéket szeretnéd megjeleníteni. A számlálód értéke a mi szerverünkön fog tárolódni. Az előbbi számlálóval szemben ennek az a hátránya, hogy csak javascriptet támogató böngészők tudják megjeleníteni a számlálód állását.

Lehetőséged van a számláló kinézetét manipulálnod paraméterek átadásával az alábbi módon:

'<SCRIPT src='http://kornel.zool.klte.hu/pub/server_side_SBcounter.php?start=500&size=14px&color=gray&style=staki:deadea,abcdef'> </SCRIPT>'
A paraméterekre példa a vastagon kiemelt rész. A ? után tudsz paramétereket átadni, a & jel választja el egymástól a paramétereket. A példában a start a számlálódnak egy kezdő értéket ad, itt 500 (a szerveren a kezdőértéktől függetlenül a valódi látogatottsági érték tárolódik). A size paraméter a számok méretét határozza meg (az alapbeállítás 12 pixel). A color paraméter a számok színére vonatkozik (az alapszín fekete). A style paraméterrel CSS style-os keretet tudsz előállítani. A mód a következő style=staki jelenti, hogy keretet akarsz a számok köré. A : után két szín kód következik vesszővel elválasztva :kitöltés színe,keret színe módon. Ha az átadott paramétered ?graphic, akkor a lennt látható félég grafikus verzió stílusában jelenik meg a számlálási értéked."; $TEXT_0_3 = "Ha azt kérded, ez miért jó nekem, hogy tárolom a Te oldalad látogattsági értékét az jogos kérdés. A számló érték egy hiperhivatkozásként jelenik meg az oldaladon. A link egy általam meghatározott oldalra mutat. Így növelem a bejövő linkek számát.

"; $TEXT_1a = '?color=red paraméterrel:'; $TEXT_1b = '?style=staki:ffffff,114253&size=10&weight=normal paraméterrel:'; $TEXT_2a = '?graphic=basic paraméterrel:'; $TEXT_2b = '?graphic=paladio paraméterrel:'; $TEXT_3 = 'Ez az oldal'; $TEXT_4 = 'alkalommal volt látogatva az elmúlt'; $TEXT_5 = 'napban.'; $TEXT_6 = 'PHP látogatottság számláló forrásának megtekintése'; $TEXT_7 = 'PHP látogatottság számláló letöltése'; $TEXT_8 = 'Ez a fájl eddig'; $TEXT_9 = 'alkalommal lett letöltve'; # $TEXT_10 = 'Néhány megjelenítési példa (próbálgató):'; $TEXT_10 = 'Néhány megjelenítési példa:'; $TEXT_11 = 'Számláló állások'; } ####====================================================================================#### # HTML output --------------------------------------------------------------------------> ####====================================================================================#### print " ..:: $TITLE ::..
 $TEXT_0  
$TEXT_0_1

[$TEXT_6]

[$TEXT_7] $TEXT_8 "; virtual("/cgi-bin/showload.cgi?counter/download/web_counter.tar.gz"); print " $TEXT_9.


2.
The remote method no more available, sorry.
$TEXT_11

$TEXT_10

$TEXT_1a

$TEXT_3 000$hits $TEXT_4 $alldays $TEXT_5

$TEXT_1b

$TEXT_3 000$hits $TEXT_4 $alldays $TEXT_5

$TEXT_2a

"; semigraphic('basic',$TEXT_3,$garray,$TEXT_4,$alldays,$TEXT_5); print "

$TEXT_2b

"; semigraphic('palladio',$TEXT_3,$garray,$TEXT_4,$alldays,$TEXT_5); print "

 By Bán Miklós  
"; ?>