#18781 - 02/10/04 09:02 PM
link.php?target=[url]
|
Joined: Feb 2002
Posts: 7,202
Gremelin
Community Owner
|
Community Owner

Joined: Feb 2002
Posts: 7,202
Likes: 11
Portland, OR; USA
|
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)...
|
|
|
#18782 - 02/13/04 12:57 PM
Re: link.php?target=[url]
|
Joined: Dec 2002
Posts: 3,255
§intå×
|

Joined: Dec 2002
Posts: 3,255
Likes: 3
Maryland
|
You need 2 tables as I see it. Database_hit_count table 1
URL varchar (255)
hits int (11)
last_hit_time varchar (15)
id int (11) auto increment key id uniqu
/tabel1 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) (?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.
|
|
|
#18784 - 02/13/04 03:31 PM
Re: link.php?target=[url]
|
Joined: Feb 2002
Posts: 7,202
Gremelin
Community Owner
|
Community Owner

Joined: Feb 2002
Posts: 7,202
Likes: 11
Portland, OR; USA
|
Welp, scallion gave some input... Still thinkin of how to go about it lol... 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
|
|
|
#18785 - 02/14/04 12:33 PM
Re: link.php?target=[url]
|
Joined: Dec 2002
Posts: 3,255
§intå×
|

Joined: Dec 2002
Posts: 3,255
Likes: 3
Maryland
|
|
|
|
#18787 - 02/14/04 12:43 PM
Re: link.php?target=[url]
|
Joined: Dec 2002
Posts: 3,255
§intå×
|

Joined: Dec 2002
Posts: 3,255
Likes: 3
Maryland
|
The only issue with scallions way is you will probably have sub scripts later.. Waht I mean is this 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 (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..
|
|
|
#18789 - 02/16/04 09:15 PM
Re: link.php?target=[url]
|
Joined: Mar 2002
Posts: 256
ninjaneo
UGN Security Staff
|
UGN Security Staff

Joined: Mar 2002
Posts: 256
Likes: 1
CA, USA
|
<?
$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 $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 $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... 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.
|
|
|
#18792 - 02/18/04 06:01 PM
Re: link.php?target=[url]
|
Joined: Dec 2002
Posts: 3,255
§intå×
|

Joined: Dec 2002
Posts: 3,255
Likes: 3
Maryland
|
$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 $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 09:18 PM
Re: link.php?target=[url]
|
Joined: Feb 2002
Posts: 7,202
Gremelin
Community Owner
|
Community Owner

Joined: Feb 2002
Posts: 7,202
Likes: 11
Portland, OR; USA
|
Ok, a new issue now... view.php And in view.php I get the output of: UGN linked to: 3 different web site(s).
I need it to at least tally how many times it went to each site...
|
|
|
|
Forums41
Topics33,701
Posts68,795
Average Daily Posts0
|
Members2,173
Most Online1,567 Apr 25th, 2010
|
|
|
Okay WTF?
by HenryMiring on 09/27/17 08:45 AM
|
|
|
|
|
|
|
|