Talk Directories - Directory Discussion Forums  

Welcome to Talk Directories forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

Go Back   Talk Directories - Directory Discussion Forums > Web Directories > Modifications

Modifications A place to discuss directory modifications. Members may post new mods, offer support, and help others with mods for directories.

Reply
 
LinkBack Thread Tools Display Modes
Old 05-09-2007, 03:01 PM   #1
tdz
 
tdz's Avatar
 
Status: New Member
Join Date: Apr 2007
Posts: 13
tdz is on a distinguished road
IM:
Default [MOD] Who's Online for PHPLD

I've made this mod for The Directory Zone for grab all users and spiders/bots.
You may use/share this mod but you are forbidden to remove the comments from code.


Create the SQL table:
Code:
-- 
-- Table structure for table `PLD_WHOS_ONLINE`
-- 

CREATE TABLE `PLD_WHOS_ONLINE` (
  `id` bigint(20) NOT NULL auto_increment,
  `timestamp` int(15) NOT NULL default '0',
  `ip` varchar(40) NOT NULL default '',
  `isbot` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `ip` (`ip`),
  KEY `timestamp` (`timestamp`),
  KEY `isbot` (`isbot`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
in init.php find:
Code:
?>
and above add:
Code:
//START - Who's online mod for PHPLD v3.2
// Writtem by Paulo Matoso - The Directory Zone - http://www.thedirectoryzone.com/
//

//Fetch Time
$time_stamp = time();
$time_limit = $time_stamp - 900; //900=15 minutes :: 86400=24h

$the_ip = get_client_ip(); //Get user IP
$ispider = is_spider(); // See if is a spider. return true if is a spider

//Insert User in MySQL
$result = mysql_query("INSERT INTO ".TABLE_PREFIX."WHOS_ONLINE (timestamp, ip, isbot) VALUES('$time_stamp','$the_ip','$ispider')");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

//Delete Users online greater than $time_limit
$result = mysql_query("DELETE FROM ".TABLE_PREFIX."WHOS_ONLINE WHERE timestamp<$time_limit");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

//Fetch online users
$result = mysql_query("SELECT DISTINCT ip,isbot FROM ".TABLE_PREFIX."WHOS_ONLINE WHERE isbot=0");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
$online_users = mysql_num_rows($result);


//Fetch online spiders
$result = mysql_query("SELECT DISTINCT ip,isbot FROM ".TABLE_PREFIX."WHOS_ONLINE WHERE isbot=1");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
$online_spiders = mysql_num_rows($result);


$tpl->assign('online_users' , $online_users);
$tpl->assign('online_spiders' , $online_spiders);
$tpl->assign('total_online' , ($online_users+$online_spiders));

//END - Who's online mod
open /include/functions.php and find:
Code:
?>
and above add:
Code:
/*

is_spider()
	- Function for testing if a useragent matches that of a spider
	- Returns useragent string if true


Copyright (c) 2006, Takeshi Media

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

*/

function is_spider()
{
	global $_SERVER;
	static $isspider = 'init';

	if( $isspider != 'init' )
	{
// its set so don't do anything 
	} else {
// don't know if this is a spider or not yet
		$spiders = array(
		"almaden.ibm.com" ,
		"gigabot" ,
		"appie 1.1" ,
		"architext" ,
		"ask jeeves",
		"asterias2.0",
		"augurfind" ,
		"baiduspider" ,
		"bannana_bot" ,
		"bdcindexer" ,
		"crawler" ,
		"crawler@fast" ,
		"docomo" ,
		"fast-webcrawler", 
		"fluffy the spider",
		"frooglebot",
		"geobot",
		"googlebot",
		"mediapartners-google",
		"gulliver",
		"henrythemiragorobot",
		"ia_archiver",
		"infoseek",
		"kit_fireball",
		"lachesis",
		"lycos_spider",
		"mantraagent",
		"mercator",
		"msnbot",
		"moget" ,
		"muscatferret" ,
		"nationaldirectory-webspider" ,
		"naverrobot" ,
		"ncsa beta" ,
		"netresearchserver" ,
		"ng/1.0" ,
		"osis-project" ,
		"polybot" ,
		"pompos" ,
		"scooter" ,
		"seventwentyfour" ,
		"sidewinder" ,
		"sleek spider" ,
		"slurp" ,
		"steeler" ,
		"szukacz" ,
		"t-h-u-n-d-e-r-s-t-o-n-e" ,
		"teoma" ,
		"turnitinbot" ,
		"ultraseek" ,
		"vagabondo" ,
		"voilabot" ,
		"w3c_validator" ,
		"zao" ,
		"zyborg" 
		);

		$useragent = strtolower( $_SERVER["HTTP_USER_AGENT"] );
		$isspider = 0;
		while( $pattern = array_pop( $spiders ))
		{
			$isspider = strpos( $useragent, $pattern);
			if( is_integer( $isspider ) ) 
			{ 
				$isspider = 1; 
				break;
			}
		}
	}
	return $isspider;
}
now add this code in the template where you want to show the who's online:
Code:
Currently Active Users: {$total_online} {if $online_users eq 0 and $online_spiders eq 1}({$online_spiders} spider){elseif $online_users eq 1 and $online_spiders eq 0}({$online_users} user){elseif $online_users eq 1 and $online_spiders eq 1}({$online_users} user and {$online_spiders} spider){elseif $online_users gt 1 and $online_spiders eq 0}({$online_users} users){elseif $online_users eq 0 and $online_spiders gt 1}({$online_spiders} spiders){elseif $online_users gt 1 and $online_spiders eq 1}({$online_users} users and {$online_spiders} spider){elseif $online_users eq 1 and $online_spiders gt 1}({$online_users} user and {$online_spiders} spiders){elseif $online_users gt 1 and $online_spiders gt 1}({$online_users} users and {$online_spiders} spiders){/if}
you are done!

I?m not a PHP ?expert? (far from it), but I learn quickly, and I love to learn, so any comments/critics' are always accepted :-)
tdz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-10-2007, 12:19 AM   #2
 
alang's Avatar
 
Status: Pagerank 1
Join Date: Apr 2007
Posts: 91
alang is on a distinguished road
IM:
Default

great mod. Thank you very much
alang is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-10-2007, 02:35 AM   #3
 
3wlink's Avatar
 
Status: Pagerank 1
Join Date: Apr 2007
Posts: 69
3wlink is on a distinguished road
IM:
Default

Nice work tdz. Hope your mod will help a lot
And thanks for your contribution.
3wlink is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-10-2007, 12:51 PM   #4
 
Fastian's Avatar
 
Status: Pagerank 1
Join Date: Apr 2007
Posts: 83
Fastian is on a distinguished road
IM:
Default

Any idea if that could work with 3.1 version ?
__________________
Best Web Directory ~ Permanent Regular listing with 3 Deep Links for $19.95 Only
Fastian is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-04-2007, 12:20 AM   #5
 
mikey1090's Avatar
 
Status: Talk Directories - Admin
Join Date: Apr 2007
Posts: 579
mikey1090 is on a distinguished road
IM:
Default

Thanks for this mod!
__________________
Welcome to TalkDirectories - a great place to discuss Search Engines, Web Directories and other webmaster issues. Fell free to join our community today and start talking!
Turnkey Websites | Turnkey Websites
mikey1090 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-10-2007, 01:15 AM   #6
 
rakib's Avatar
 
Status: Pagerank 2
Join Date: Apr 2007
Posts: 227
rakib is on a distinguished road
IM:
Default

great mod. it will help us a lot.
rakib is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-13-2007, 10:55 AM   #7
 
sizzler_chetan's Avatar
 
Status: Pagerank 2
Join Date: May 2007
Location: India
Posts: 142
sizzler_chetan will become famous soon enough
IM:
Default

Great Mod

Thanks for sharing it!
sizzler_chetan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Online Marketing shreya General Marketing 6 09-03-2008 05:13 AM
How much time do you spend online? mikey1090 Off Topic 33 07-29-2008 08:29 AM
What do you do when you aren't online? mikey1090 Off Topic 13 04-24-2008 08:05 AM
Integrated online marketing and lead generation Lazarus General Marketing 0 03-28-2008 01:53 AM
Online Marketing Strategy pauljun Search Engine Optimization 2 03-14-2008 03:16 AM



Copyright © 2007 - 2010 iTalkWebs Network - .Ad Management by RedTyger

LinkBacks Enabled by vBSEO 3.1.0

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