Your browser does not seem to support CSS. If images appear below, please disregard them.
toggle
May
S M T W T F S
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
Topic Options
Rate This Topic
#19047 - 10/20/05 12:00 AM php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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/20/05 12:34 AM Re: php help (I think)
Joined: Feb 2002
Posts: 7,194
Gremelin Online shocked
Community Owner
Gremelin Online shocked

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
have perl? have access logs? Use AWStats


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Top
#19049 - 10/20/05 12:51 AM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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/20/05 01:22 AM Re: php help (I think)
Joined: Feb 2002
Posts: 7,194
Gremelin Online shocked
Community Owner
Gremelin Online shocked

Community Owner

Joined: Feb 2002
Posts: 7,194
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, and VNC Web Services Owner
Top
#19051 - 10/20/05 04:02 AM Re: php help (I think)
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
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 04:11 AM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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 04:15 AM Re: php help (I think)
Joined: Feb 2002
Posts: 7,194
Gremelin Online shocked
Community Owner
Gremelin Online shocked

Community Owner

Joined: Feb 2002
Posts: 7,194
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, and VNC Web Services Owner
Top
#19054 - 10/20/05 06:25 AM Re: php help (I think)
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
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 06:59 AM Re: php help (I think)
Joined: Feb 2002
Posts: 7,194
Gremelin Online shocked
Community Owner
Gremelin Online shocked

Community Owner

Joined: Feb 2002
Posts: 7,194
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, and VNC Web Services Owner
Top
#19056 - 10/20/05 07:04 AM Re: php help (I think)
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
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 03:07 PM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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 04:35 PM Re: php help (I think)
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
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 07:31 PM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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 08:30 PM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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 09:35 PM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
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
#19062 - 10/20/05 09:36 PM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
Asheville, NC
sorry thinking while posting...


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

Tech Ninja Security
Top
#19063 - 10/20/05 09:47 PM Re: php help (I think)
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
Maryland
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.


My New site OpenEyes
Top
#19064 - 10/20/05 10:03 PM Re: php help (I think)
Joined: Sep 2002
Posts: 390
Shinobi Offline
UGN Member
Shinobi Offline
UGN Member

Joined: Sep 2002
Posts: 390
Asheville, NC
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
Top
#19065 - 10/21/05 01:23 AM Re: php help (I think)
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
Maryland
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


My New site OpenEyes
Top

Member Spotlight
Gremelin

Gremelin
Portland, OR; USA
Posts: 7,194
Joined: February 2002
Show All Member Profiles 
Forum Statistics
Forums46
Topics45,706
Posts80,874
Members2,157
Most Online1,567
Apr 25th, 2010
Top Posters(All Time)
UGN Security 38,870
Gremelin 7,194
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Newest Members
Herbert_Sherbert, codemauve, Lillysdragon1984, Brewwit, boa
2157 Registered Users
Who's Online Now
0 registered members (), 3 guests and 1 spider.
Latest News