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
Topic Options
Rate This Topic
#18781 - 02/10/04 04:02 PM link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top
Sponsored Links
      
#18782 - 02/13/04 07:57 AM Re: link.php?target=[url]
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: 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 09:59 AM Re: link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top
#18784 - 02/13/04 10:31 AM Re: link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top
#18785 - 02/14/04 07:33 AM Re: link.php?target=[url]
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
$HTTP_REFERER sorry
_________________________
My New site OpenEyes

Top
#18786 - 02/14/04 07:34 AM Re: link.php?target=[url]
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
$_SERVER['PHP_SELF'] short path to script
_________________________
My New site OpenEyes

Top
#18787 - 02/14/04 07:43 AM Re: link.php?target=[url]
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: 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 09:00 AM Re: link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top
#18789 - 02/16/04 04:15 PM Re: link.php?target=[url]
ninjaneo Offline
UGN Security Staff

Registered: 03/06/02
Posts: 256
Loc: 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/16/04 11:20 PM Re: link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top
#18791 - 02/16/04 11:21 PM Re: link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top
#18792 - 02/18/04 01:01 PM Re: link.php?target=[url]
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: 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 04:18 PM Re: link.php?target=[url]
Gremelin Offline

Community Owner
*****

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

Top

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 10/28/14
Posts: 1
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 (), 318 Guests and 356 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!