| Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | What up bitches, I never ask for help, but on this I am truly stumped..... I'm trying to make a public web stats section on my webpage. To display:
Today's Hits: Today's Unique Hits: Total Unique Hits:
I can't seem to it it to work how I want it to. The only condition is that no mysql database. I do not have mysql installed and setup and I really do not want to do it cause... Well I'm lazy. But if anyone has any ideas. Please Help would be greatly appreciated
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | |
▼ Sponsored Links ▼
▲ Sponsored Links ▲
| | | Joined: Feb 2002 Posts: 7,203 Likes: 11 Community Owner | Community Owner Joined: Feb 2002 Posts: 7,203 Likes: 11 | have perl? have access logs? Use AWStats | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | I do have a reports page that show me all of this, and perl is active. However the reports page is...[censored] up is the best way I can describe it
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Feb 2002 Posts: 7,203 Likes: 11 Community Owner | Community Owner Joined: Feb 2002 Posts: 7,203 Likes: 11 | reports page? access logs are generated by the apache webserver; usually /var/logs or some [censored] | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | Well the thing is I don't want a whole page dedicated to stats, its just a little portion of the main page. So all I need is something that counts hits, unique hits and total unique hits, and generates a normal looking number. To be displayed on the index page.
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Feb 2002 Posts: 7,203 Likes: 11 Community Owner | Community Owner Joined: Feb 2002 Posts: 7,203 Likes: 11 | we're now running PHP4.3.9 heh; Apache 2.0; but we can upgrade to whatever since it's our vps  | | | | Joined: Dec 2002 Posts: 3,255 Likes: 3 UGN Elite | UGN Elite Joined: Dec 2002 Posts: 3,255 Likes: 3 | who said you need a whole page? I think you are miss understanding me. Figure 1 - Flat file data storage system
------Flat file1.inc
/
index.php-----
\
------Flat File2.inc
######################################################
Figure 2 - MySQL data storage system
------mySql Table 1
/
index.php-----
\
------mySql Table 2 Think of the flat files as database tables you use to pull data from to populate a/any page. Also you add a bit of code to every page to ensure the flat files are updated with every hit. Basically what I am saying is you can use plain old text files as a database. You can read and write to them just as you can a database. | | | | Joined: Feb 2002 Posts: 7,203 Likes: 11 Community Owner | Community Owner Joined: Feb 2002 Posts: 7,203 Likes: 11 | we use flat files for storing our link statistics; mainly cas i'm too lazy to get on dem knees... | | | | Joined: Dec 2002 Posts: 3,255 Likes: 3 UGN Elite | UGN Elite Joined: Dec 2002 Posts: 3,255 Likes: 3 | They are easy to use. A little more work than MySQL to manipulat data, but a good solid alternative if you are missing a SQL db. | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | I gotcha now, thanks a lot sintax
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Dec 2002 Posts: 3,255 Likes: 3 UGN Elite | UGN Elite Joined: Dec 2002 Posts: 3,255 Likes: 3 | Anytime man, any time. Let us know how it works out. I have never created a flat file system myself, but If you need help I am willing learn and lend a hand. | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | Yes yes, it should be a learning experience for me as well. I'm actully getting started on it right.... .... ..... ...... .......
NOW
hehe I'll keep you updated as to how it went.
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | these damn tutorials are like pulling teeth...
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | ok finally got it if anyone is intersted I'll put the code here... totalhits.php <?php
$myfile = "totalhits.txt";
//Assigns file name to the variable we'll use to handle it
if(file_exists($myfile))//if the file exists
{ // runs counter script
$var = fopen( $myfile,'r+');
//opens in read and write mode for file
$visits = fread($var,filesize($myfile));
//puts the content of the file for its whole length
rewind( $var );
//resets the file position indicator to the beginning
$visits++; //increments the actual number of vists by 1
fwrite($var, $visits);
//writes on the variable the actual (incremented) value
fclose($var);//closes our file reference
}
else
{
print "File $myfile doesn't exist...";
Die();
//if the file doesn't exist prompts a warning and kills the script
}
$message = sprintf("Total Hits: %s",$visits);
//saves our visits message in a variable ($message) that will be used as output
print $message;
?> Code in index.php <?php include 'totalhits.php'; ?> only question I have is permissions... The txtfile has to be 777, thats the only way it will work... is that correct? Wait... I can use .inc......
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | sorry thinking while posting...
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Dec 2002 Posts: 3,255 Likes: 3 UGN Elite | UGN Elite Joined: Dec 2002 Posts: 3,255 Likes: 3 | you should not have to use 777 for it to work. 666 should be a viable secure chmod. you can use any file extension you want for the tex/flat files. inc is common. I have used .fun for functions, .pwd for MySQL login info, etc etc etc
You have to modify your .htaccess file however to may these files treated as PHP files. Once you do that you should beable to store sensative data in them. | | | | Joined: Sep 2002 Posts: 390 UGN Member | UGN Member Joined: Sep 2002 Posts: 390 | Well I changed them to .inc, and moved them out of the main directory to a hidden on, I'm now changing the chmod to 666 to see if it works. TY for all the help sintax, it was not as hard as I had first thought 
"The secret to creativity is knowing how to hide your sources." -Albert Einstein Tech Ninja Security | | | | Joined: Dec 2002 Posts: 3,255 Likes: 3 UGN Elite | UGN Elite Joined: Dec 2002 Posts: 3,255 Likes: 3 | you do not need a hidden directory, it would just be more secure to store them below the pulic accesable directory.
ie...
/home/your_dir/public_html
or
/vars/your_dir/htdocs
or
/vars/your_dir/www
each of the "your_dir" in the examples above will not be reachable by a web browser. FTP yes, but not a web browser. This keep people from harvesting your IP list | | |
Forums41 Topics33,840 Posts68,858 Members2,176 | Most Online3,253 Jan 13th, 2020 | | | |