Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
brojač posjeta u PHPu

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 26.09.2004 11:44    Post subject: brojač posjeta u PHPu Add user to your forum ignore list Reply with quote

pa zahtjevu klijenta sam išo radit jedan jednostavan brojač, nisam htio radit ništa s bazom da ne kompliciram, ali htio bih čuti vaše mišljenje o tome kak je ovo napravljeno.
također, ako se ovdašnji PHP gurui slože da valja, kome god treba nek ga slobodno koristi.

dakle...
prije headera ide ::
Code:

<?php
session_start ();
header("Cache-control: private");
include ( "brojac.php" );
?>


brojac.php ::
Code:

<?php

if ( !isset ( $_SESSION['broji'] )){
     session_register ( "broji" );
     $_SESSION['broji'] = true;
     $ukupno = file_get_contents ( "ukupno.txt" );
     $ukupno ++;
     file_put_contents ( "ukupno.txt", $ukupno );
} else {
    $ukupno = file_get_contents ( "sveukupno.txt" );
    $ukupno ++;
    file_put_contents ( "sveukupno.txt", $ukupno );
}

?>


stat.php (za vidit broj posjeta) ::
Code:

<?php

echo '<font face="arial" size="2"><br><br>';
$ukupno = file_get_contents ( "ukupno.txt" );
echo 'Broj posjeta : <b>', $ukupno,'</b>';

echo '<br><br>';
$sveukupno = file_get_contents ( "sveukupno.txt" );
echo 'Broj pregledanih stranica : <b>',$sveukupno,'</b>';

echo '<br><br>';
echo 'Prosječan broj stranica koje posjetitelj pregleda : <b>', ($ukupno + $sveukupno)/$ukupno,'</b></p>';

?>



eto. kritike su dobrodošle, ovo je napravljeno na brzinu u nedelju ujutro, pa ono...
hehe....
volio bi čuti kaj mislite.
i naravno, u folderu treba imate dvije .txt datoteke :
ukupno.txt
sveukupno.txt

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 26.09.2004 18:11    Post subject: Add user to your forum ignore list Reply with quote

blah...radi lokalno...nije baš oduševljen s radom na serveru.
javim kad sredim, za sad je tek nacrt Confused

ajmo PHP gurui...kaj ne valja?

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 26.09.2004 18:58    Post subject: Add user to your forum ignore list Reply with quote

urm....
file_get_contents() je php4
file_put_contents() je php5

grmbl....

Code:

<?php

if ( !isset ( $_SESSION['broji'] )){

     session_register ( "broji" );
     $_SESSION['broji'] = true;
     $ukupno = file_get_contents ( "ukupno.txt" );
     $ukupno ++;
     $handle = fopen("ukupno.txt", 'w');
     fwrite($handle, $ukupno);
     fclose($handle);

} else {

    $ukupno = file_get_contents ( "sveukupno.txt" );
    $ukupno ++;
    $handle = fopen("sveukupno.txt", 'w');
    fwrite($handle, $ukupno);
    fclose($handle);

}


?>

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 26.09.2004 20:23    Post subject: Add user to your forum ignore list Reply with quote

Nemoj koristiti session_register() i $_SESSION['ime_var'] = 'vrijednost' zajedno...

Takodjer, ako hoces da ti skripta radi neovisno o register_globals, koristi samo $_SESSION[] pristup...

Bad things can happen, a i pise u manualu lijepo: http://hr.php.net/manual/en/function.session-register.php

Ovo je samo kaj sam vidio nabrzaka... Nemam vremena testirat u zivo, ali ako sredis ovo gore kaj sam napisao, mozda ce i malo brze raditi... Nemam pojma...

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 26.09.2004 22:34    Post subject: Add user to your forum ignore list Reply with quote

zato sam i postao...

dakle ne moram session_register() uopće?
mogu samo $_SESSION['spoji'] = true; ?

kad sam čitao tutoriale za sessione bilo je obavezno session_register().
idem probat Smile))

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group