Previous Thread
Next Thread
Print Thread
Rate Thread
#18781 02/10/04 02:02 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
I have a perl script that I've been using since I got UGN Security started that will take and allow users to go to a URL (such as: link.cgi?target=http://www.UnderGroundNews.com/) and it'll load the page for them as if they just clicked the site, however it'll insert into a flat file the time they went to the site, their IP, and the site URL; it'll also increase the site's "popularity" in the flat file for each ckick. The script however isn't being worked on any further since the author's abandoned it due to it being a buggy piece of crap...

Now, what I want to do is take and have a similar URL string (like: link.php?target=http://www.UnderGroundNews.com/) that will take and enter the URL to the SQL database if it is new and follow the procedure for adding hits, if it's old it takes and adds a "hit" to the URL's stats in the SQL db and add's their IP/Time/URL to the db...

I'm not entirely sure how to go about it, I just know that I have to get it done ASAP due to this script bringing me more trouble than it's worth; but I have no clue how to begin; any Ideas? All help is appreciated, kudos goes to those who do the work for me (hey, I'm a busy fscking person)...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18782 02/13/04 05:57 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
You need 2 tables as I see it.

Database_hit_count
Code
table 1
  URL    varchar (255)
  hits   int (11)
  last_hit_time varchar (15)
  id     int (11) auto increment key id uniqu
/tabel1
Code
table2
  ip varchar (20)
  time varchar (15)
  bowser varchar (100)
  reffer varchar (150)
  id int(11) auto increment key id, uniqu
/table2
/Database_hit_count

$ip = "$REMOTE_ADDR"; //Grabs IP addy(built in variable in PHP)
$browser = "$HTTP_USER_AGENT"; //grabs browser info(built in to PHP)
$refferer = "$HTTP_USER_AGENT"; //dosen't allways work, but grabs refferer info (built into PHP)

The form tag could use the GET method to another page like I did in the RRFN. RRFN.php action attribute sends you to Database.php?keyword=What_you_searched_for

Soooooo

(form action="other_page.php" method="GET")
(!--some form stuff--)
(/form)

Code
(?php

$ip = "$REMOTE_ADDR";  
$browser = "$HTTP_USER_AGENT";  
$refferer = "$HTTP_USER_AGENT";  
$URL = "$What_ever_you_named_it";
$this_date = date(see url for format options n/function.date.php);



//MYSQL_login crap here



$dg = mysql_query(SELECT * FROM table1 where URL = '$URL');
   $num_rows = mysql_num_rows($dg);
     if ($num_rows < 1){
        $dh = mysql_query("Insert into table1(feild names here)values(variable names here)");
         // repeate above for table 2
     }else{
         While ($dg2 = mysql_fetch_array($dg)){
             get count from table 1
             now $count = $count++;
             do an Update set feild name = '$variable'
}
That is rough, but that is basicaly how I would do it.

#18783 02/13/04 07:59 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
It's going to be for out of hosting sites; for linking to other sites basically.. I don't see anything in your code that'd resemble a function for calling url smirk


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18784 02/13/04 08:31 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Welp, scallion gave some input... Still thinkin of how to go about it lol...

Code
Scallion: .
Scallion: you're unclear as to what you want
Gizmo: how so?
Gizmo: lol
Gizmo: i said
Gizmo: i want a script that
Gizmo: if you enter script.php?url=siteurl
Gizmo: it'll log the site url in a mysql db
Gizmo: if it's new
Gizmo: and if it exists it'll append a count to the db sayin how many times it's been accessed
Scallion: oh that's easy
Gizmo: does the post make sense now?
Gizmo: heh
Scallion: yeah a little more
Scallion: you should be able to do that on your own ;-)
Gizmo: :/
Scallion: do it like this
Scallion: redirect.php?url=xyz.com
Scallion: have a database like this:
Scallion: CREATE TABLE urls (url TEXT, num INT, id [int not null primary key blah blah blah])
Scallion: then in redirect.php, just access that table, if a select * from urls where url=$_GET[url] returns 0 rows, create a new row
Scallion: simple :-)
Gizmo: hos to have it append a numer to the amount of times it's been accesed?
Gizmo: better yet, what code to use to send user to site heh
Scallion: oh well put <?php header("Location: url"); ?> at the top of the page to redirect
Scallion: to append the num of times accessed, update a row with the url to add one to 'num' in the table.
Scallion: or use javascript to redirect.
Gizmo: mmmk


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18785 02/14/04 05:33 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
$HTTP_REFERER sorry

#18786 02/14/04 05:34 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
$_SERVER['PHP_SELF'] short path to script

#18787 02/14/04 05:43 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
The only issue with scallions way is you will probably have sub scripts later.. Waht I mean is this

Code
if(!$cmd){
//code executed when you first hit page
}
else if($cmd == "redirect_after_selection"){
//code to execute once user clicks said such link
}
so you links would be like so

replace ( with < and you get the idea

Code
(a href="url_to_script/script.php?cmd=redirect&redirect=some_url.com" target="_self")
text or image link here
(/a)
Quick question, if you do not have the URL in your database.... Where will the user get it from? Or are you going to have all URLs re-routed through this..

#18788 02/14/04 07:00 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
I'm going to be linking to them. Go look at the links page; I like directly to all links i want in; i want it so i can just plug them in and have them go


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18789 02/16/04 02:15 PM
Joined: Mar 2002
Posts: 256
Likes: 1
UGN Security Staff
Offline
UGN Security Staff
Joined: Mar 2002
Posts: 256
Likes: 1
Code
<?
 $db = mysql_connect("server","username","password");
 mysql_select_db("db");
 $updated = mysql_query("UPDATE `links` SET `hits`=`hits+1;");
 if(!$updated) {
  mysql_query("INSERT INTO `links` (`hits`,`url`) VALUES ('1','".$HTTP_GET_VARS["target"]."')");
 }
 mysql_close();
 header("Location: " . $HTTP_GET_VARS["target"]);
?>
That is one way to go about things... but that doesn't do hits so.. scrap that here. use the following.

link.php
Code
 $db = mysql_connect("server","username","password");
 mysql_select_db("db");
 mysql_query("INSERT INTO `links` (`url`,`ip`,`time`,`referer`,`browser`) VALUES ('".addslashes($HTTP_GET_VARS["target"])."', '".$_SERVER["REMOTE_ADDR"]."', '".time()."', '".$HTTP_REFERER."', '".$HTTP_USER_AGENT."')");
 }
 mysql_close();
 header("Location: " . $HTTP_GET_VARS["target"]);
?>
viewhits.php
Code
 $db = mysql_connect("server","username","password");
 mysql_select_db("db");
 $hits = mysql_query("SELECT `url` FROM `hits` GROUP BY `url`");
 echo("UGN linked to: ".mysql_num_rows($hits)." different web site(s).
\n");
 while($hit = mysql_fetch_array($hits)) {
  $url = mysql_query("SELECT * FROM `hits` WHERE `url`='".$hits["url"]."'");
  while($page = mysql_fetch_array($url)) {
   echo("url: ".$page["url"].", was visited by: ".$page["ip"].", at: ".date("h:i.a m/j/Y", $page["time"]).", using: ".$page["browser"]."; they came from: ".$page["referer"].".
\n");
  }
 }
 mysql_close();
?>
heres a mysql table for you...

Code
CREATE TABLE `hits` (
`url` TEXT NOT NULL ,
`ip` VARCHAR( 15 ) NOT NULL ,
`time` INT UNSIGNED NOT NULL ,
`referer` TEXT NOT NULL ,
`browser` TEXT NOT NULL ,
FULLTEXT (
`url` ,
`referer` ,
`browser` 
)
) TYPE = MYISAM COMMENT = 'some hittage';
uhh, Talk to me if you wanan figure out how to do [censored] like... Tell how many people are using Mozilla Firebird or something.

#18790 02/16/04 09:20 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Neo, on viewhits.php I get:
Quote:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\view.php on line 5
UGN linked to: different web site(s).

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\view.php on line 6


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18791 02/16/04 09:21 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
The code I'm using is:

Code
<?php
 $db = mysql_connect("127.0.0.1","mysqluser","mysqlpass");
 mysql_select_db("ugn_linked");
 $hits = mysql_query("SELECT `url` FROM `hits` GROUP BY `url`");
 echo("UGN linked to: ".mysql_num_rows($hits)." different web site(s).
\n");
 while($hit = mysql_fetch_array($hits)) {
  $url = mysql_query("SELECT * FROM `hits` WHERE `url`='".$hits["url"]."'");
  while($page = mysql_fetch_array($url)) {
   echo("url: ".$page["url"].", was visited by: ".$page["ip"].", at: ".date("h:i.a m/j/Y", $page["time"]).", using: ".$page["browser"]."; they came from: ".$page["referer"].".
\n");
  }
 }
 mysql_close();
?>


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18792 02/18/04 11:01 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
Code
$hits = mysql_query("SELECT `url` FROM `hits` GROUP BY `url`");
most likely it is this line causeing your error on line 5.


your table name isn't something like undergroundnews_hits is it? If so you need to

Code
 $hits = mysql_query("SELECT `url` FROM `undergroundnews_hits` GROUP BY `url`");
use something like the above. If you have php My Admin it will tell you the full table name. if you want to use telnet, or ssh or command line


http://www.UnderGroundNews.com/cgi-bin/ubbcgi/ultimatebb.cgi?/topic/9/81.html

Might want to try your query in ther to test it before you run the script just to prove it out.

#18793 02/18/04 02:18 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
OP Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Ok, a new issue now...

view.php
Quote:

http://www.undergroundnews.org/ 127.0.0.1 1077110092
http://www.undergroundnews.net/ 127.0.0.1 1077110084
http://www.undergroundnews.com/ 127.0.0.1 1077110059
And in view.php I get the output of:
Quote:

UGN linked to: 3 different web site(s).
I need it to at least tally how many times it went to each site...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner

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