[FONT=Arial]I could try. [/FONT]
[FONT=Arial]I didn't make any notes, and this is a complete hack! Maybe you could help me clean it up? I looks like it works on my site, so I'm happy.[/FONT]
[FONT=Arial]It also keeps a track of the clicks to stop cheating
[/FONT]
Code:
[FONT=Arial]Database:[/FONT]
[FONT=Arial]CREATE TABLE `links_clicks` ( `site_id` int(11) NOT NULL, `click_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `ip_adr` varchar(30) NOT NULL, KEY `site_id` (`site_id`) ) ENGINE=MyISAM;[/FONT]
[FONT=Arial]header file:[/FONT]
[FONT=Arial]elseif (isset($_GET['links_url'])) {[/FONT]
[FONT=Arial]if (get_magic_quotes_gpc()) $_GET['links_url'] = stripslashes($_GET['links_url']);[/FONT]
[FONT=Arial]$links_url = 'http://'.mysql_real_escape_string($_GET['links_url']);[/FONT]
[FONT=Arial]zen_update_links_click_count($links_url); [/FONT]
[FONT=Arial] }[/FONT]
[FONT=Arial]Functions:[/FONT]
[FONT=Arial]//REMOVE HTTPS[/FONT]
[FONT=Arial]function remove_http($url = '')[/FONT]
[FONT=Arial]{[/FONT]
[FONT=Arial]return(str_replace(array('http://','https://'), '', $url));[/FONT]
[FONT=Arial]}[/FONT]
[FONT=Arial]// Return the links url[/FONT]
[FONT=Arial] function zen_get_links_url($identifier) {[/FONT]
[FONT=Arial] global $db;[/FONT]
[FONT=Arial] $link = $db->Execute("select links_id, links_url from " . TABLE_LINKS . " where links_id = '" . (int)$identifier . "'");[/FONT]
[FONT=Arial] $url = remove_http($link->fields['links_url']);[/FONT]
[FONT=Arial] $links_string = 'links?links_url='.$url;[/FONT]
[FONT=Arial] return $links_string;[/FONT]
[FONT=Arial] }[/FONT]
[FONT=Arial]////[/FONT]
[FONT=Arial] function zen_update_links_click_count($links_url) {[/FONT]
[FONT=Arial] global $db;[/FONT]
[FONT=Arial] $url = 'http://www.yoursite.com'; [/FONT]
[FONT=Arial] $result = $db->Execute("select links_id, links_url from " . TABLE_LINKS . " where links_url = '" . $links_url . "'");[/FONT]
[FONT=Arial] if ($result->RecordCount() == 1) {[/FONT]
[FONT=Arial] $url = $links_url; [/FONT]
[FONT=Arial] $id = $result ->fields['links_id']; [/FONT]
[FONT=Arial] $IP = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); [/FONT]
[FONT=Arial] $time_diff = 3600*24*14; [/FONT]
[FONT=Arial] $test = $db->Execute("select COUNT(*) AS testval from " . TABLE_LINKS_CLICKS . " where ip_adr = '".$IP."' AND click_time+".$time_diff." > NOW() AND site_id = '".$id."'");[/FONT]
[FONT=Arial] if ($test->fields['testval'] == 0) {[/FONT]
[FONT=Arial] $db->Execute("INSERT INTO " . TABLE_LINKS_CLICKS . " set ip_adr = '".$IP."', site_id = '".(int)$id."' ");[/FONT]
[FONT=Arial] $db->Execute("update " . TABLE_LINKS . " set links_clicked = links_clicked + 1 where links_id = '" . (int)$id . "'");[/FONT]
[FONT=Arial] }[/FONT]
[FONT=Arial] } [/FONT]
[FONT=Arial]header("Location: $url");[/FONT]
[FONT=Arial]exit;[/FONT]
[FONT=Arial] }[/FONT]
[FONT=Arial][/FONT]
[FONT=Arial]define tag:[/FONT]
define('TABLE_LINKS_CLICKS', DB_PREFIX . 'links_clicks');
Bookmarks