UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
December
Su M Tu W Th F Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Sponsored Links
Latest Postings
Latest Reviews
Page 1 of 2 1 2 >
Topic Options
Rate This Topic
#19047 - 10/19/05 08:00 PM php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
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

Top
Sponsored Links
      
#19048 - 10/19/05 08:34 PM Re: php help (I think)
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
have perl? have access logs? Use AWStats
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19049 - 10/19/05 08:51 PM Re: php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
I do have a reports page that show me all of this, and perl is active. However the reports page is...fucked 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

Top
#19050 - 10/19/05 09:22 PM Re: php help (I think)
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
reports page? access logs are generated by the apache webserver; usually /var/logs or some shit
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19051 - 10/20/05 12:02 AM Re: php help (I think)
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
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.
_________________________
My New site OpenEyes

Top
#19052 - 10/20/05 12:11 AM Re: php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
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

Top
#19053 - 10/20/05 12:15 AM Re: php help (I think)
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
we're now running PHP4.3.9 heh; Apache 2.0; but we can upgrade to whatever since it's our vps
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19054 - 10/20/05 02:25 AM Re: php help (I think)
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
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.
_________________________
My New site OpenEyes

Top
#19055 - 10/20/05 02:59 AM Re: php help (I think)
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
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, Elite Web Gamers & VNC Web Design Owner

Top
#19056 - 10/20/05 03:04 AM Re: php help (I think)
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
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.
_________________________
My New site OpenEyes

Top
#19057 - 10/20/05 11:07 AM Re: php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
I gotcha now, thanks a lot sintax
_________________________
"The secret to creativity is knowing how to hide your sources."
-Albert Einstein

Tech Ninja Security

Top
#19058 - 10/20/05 12:35 PM Re: php help (I think)
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
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.
_________________________
My New site OpenEyes

Top
#19059 - 10/20/05 03:31 PM Re: php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
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

Top
#19060 - 10/20/05 04:30 PM Re: php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
these damn tutorials are like pulling teeth...
_________________________
"The secret to creativity is knowing how to hide your sources."
-Albert Einstein

Tech Ninja Security

Top
#19061 - 10/20/05 05:35 PM Re: php help (I think)
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
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

Top
Page 1 of 2 1 2 >

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 03/02/02
Posts: 136
Forum Stats
2152 Members
46 Forums
36281 Topics
71451 Posts

Max Online: 1567 @ 04/25/10 05:20 AM
Top Posters
UGN Security 29442
Gremelin 7193
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
cdefgh368568, HushHush, golqm, Tim050, Gecko666
2151 Registered Users
Who's Online
0 registered (), 331 Guests and 352 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!