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
#18781 - 02/10/04 09:02 PM link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
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)...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Top
Sponsored Links
#18782 - 02/13/04 12:57 PM Re: link.php?target=[url]
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



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


My New site OpenEyes
Top
#18783 - 02/13/04 02:59 PM Re: link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
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


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Top
#18784 - 02/13/04 03:31 PM Re: link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
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
Top
#18785 - 02/14/04 12:33 PM Re: link.php?target=[url]
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
Maryland
$HTTP_REFERER sorry


My New site OpenEyes
Top
#18786 - 02/14/04 12:34 PM Re: link.php?target=[url]
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



Joined: Dec 2002
Posts: 3,255
Maryland
$_SERVER['PHP_SELF'] short path to script


My New site OpenEyes
Top
#18787 - 02/14/04 12:43 PM Re: link.php?target=[url]
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



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


My New site OpenEyes
Top
#18788 - 02/14/04 02:00 PM Re: link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
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
Top
#18789 - 02/16/04 09:15 PM Re: link.php?target=[url]
Joined: Mar 2002
Posts: 256
ninjaneo Offline
UGN Security Staff
ninjaneo Offline
UGN Security Staff

Joined: Mar 2002
Posts: 256
CA, USA
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 shit like... Tell how many people are using Mozilla Firebird or something.

Top
#18790 - 02/17/04 04:20 AM Re: link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
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
Top
#18791 - 02/17/04 04:21 AM Re: link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
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
Top
#18792 - 02/18/04 06:01 PM Re: link.php?target=[url]
Joined: Dec 2002
Posts: 3,255
§intå× Offline
§intå× Offline



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


My New site OpenEyes
Top
#18793 - 02/18/04 09:18 PM Re: link.php?target=[url]
Joined: Feb 2002
Posts: 7,194
Gremelin Offline
Community Owner
Gremelin Offline

Community Owner

Joined: Feb 2002
Posts: 7,194
Portland, OR; USA
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
Top

Member Spotlight
Gremelin

Gremelin
Portland, OR; USA
Posts: 7,194
Joined: February 2002
Show All Member Profiles 
Forum Statistics
Forums46
Topics45,753
Posts80,921
Members2,157
Most Online1,567
Apr 25th, 2010
Top Posters(All Time)
UGN Security 38,917
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 (), 1 guest and 4 spiders.
Latest News