Previous Thread
Next Thread
Print Thread
Rate Thread
#19047 10/19/05 05:00 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19048 10/19/05 05:34 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
have perl? have access logs? Use AWStats


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19049 10/19/05 05:51 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19050 10/19/05 06:22 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
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]


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19051 10/19/05 09:02 PM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
lol OMG are you using PHP 5.X? if so you have SQL lite. If not use a flat file system like UBB works off of. It isn't as fast as a modern db, but I seriously doubt you will generate the traffic to truely make a difference.

Like I say Ubb uses a flat file system, PHP is highly able to do this as well.

There are actually some advantages of using a flat file system also. Check it out

http://www.dummies.com/WileyCDA/DummiesArticle/id-2402.html


Here are some tuts on flat file systems
http://www.tutorialized.com/tutorial/Flat-file-Shoutbox/9119
some file manipulation tuts http://www.tutorialized.com/tutorials/PHP/File-Manipulation/1
http://www.tutorialized.com/tutorial/Data-Access-Benchmarks/5593
http://www.tutorialized.com/tutorial/File-existance-checking/3898
http://www.tutorialized.com/tutorial/File-locking/3905
http://www.tutorialized.com/tutorial/File-Creator-Editor/3012
http://www.tutorialized.com/tutorial/Last-Modified/3016


Those should get you well on your way to creating a flat file system to count hits and such.


The way I see it...


1st file: total_hits.inc(besure to make inc file viewable only by php and might as well place them below the viewable directory)

file lay-out
Code
$hits //$hits is replaced by a running tally of hits
$last_hit // timestamp of last logged hit
$last_ip //ip address of last hit
second file(one will be created every month)
file name: Month_year.inc
$date_timestamp
$hits_count
$ip_address[1 thru whatever] //this is an array of every IP from that day
$browser_per_ip //what browser each ip is using
$tally_unique_ip's
//next day but same month is added below seperated by 2 carriage returns
$date_timestamp
$hits_count
$ip_address[1 thru whatever] //this is an array of every IP from that day
$browser_per_ip //what browser each ip is using
$tally_unique_ip's



Little math and you could have one hell of a stats page.

#19052 10/19/05 09:11 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19053 10/19/05 09:15 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
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 wink


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19054 10/19/05 11:25 PM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
who said you need a whole page? I think you are miss understanding me.


Code
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.

#19055 10/19/05 11:59 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
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...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19056 10/20/05 12:04 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
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.

#19057 10/20/05 08:07 AM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19058 10/20/05 09:35 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
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.

#19059 10/20/05 12:31 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19060 10/20/05 01:30 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19061 10/20/05 02:35 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
UGN Member
Joined: Sep 2002
Posts: 390
ok finally got it if anyone is intersted I'll put the code here...

totalhits.php
Code
 <?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
Code
<?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
#19062 10/20/05 02:36 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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
#19063 10/20/05 02:47 PM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
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.

#19064 10/20/05 03:03 PM
Joined: Sep 2002
Posts: 390
Shinobi Offline OP
UGN Member
OP Offline
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

laugh


"The secret to creativity is knowing how to hide your sources."
-Albert Einstein

Tech Ninja Security
#19065 10/20/05 06:23 PM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
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


Link Copied to Clipboard
Member Spotlight
Phatal
Phatal
Houston, TX
Posts: 298
Joined: April 2004
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Cyrez 1
Girlie 1
unreal 1
Crime 1
Powered by UBB.threads™ PHP Forum Software 7.7.5