|
From: OryNider <ory...@us...> - 2008-06-04 00:09:19
|
Update of /cvsroot/mxbb/mx_pjirc/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28916/includes Modified Files: common.php Added Files: functions.php Log Message: Upgrade for latest version with some new features and a chan block inside a portal page. --- NEW FILE: functions.php --- <?php /** * * @package MxPmodule_mx_pafileDB * @version $Id: functions.php,v 1.1 2008/06/04 00:09:11 orynider Exp $ * @copyright (c) 2002-2006 [ory...@rd..., OryNider] MxP Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } // ================================================================================ // [ COMMON FUNCTIONS ] // ================================================================================ function user_join($nick) { global $pjirc_config, $db; $current_time=date("U"); $sql = "DELETE FROM ".PJIRC_SESSION_TABLE." WHERE username = '".addslashes($nick)."'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function user_join(): DELETE<br />" . $sql); } $sql = "INSERT INTO ".PJIRC_SESSION_TABLE." (username, time)" . " VALUES ('" .addslashes($nick). "', ".$current_time.")"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function user_join(): INSERT<br />" . $sql); } } //Update user statue "chatting/not chatting" function update_user($nick,$time) { global $pjirc_config, $board_config, $db, $lang; $sql="update ".PJIRC_SESSION_TABLE." set time='$time' where username='$nick'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function update_users(): UPDATE<br />" . $sql); } } function drop_users($period) { global $pjirc_config, $board_config, $db, $lang; $current_time=date("U"); //prevent delay $period=$period+2; // Calcul max_time $max_time=$current_time-$period; $sql="delete from ".PJIRC_SESSION_TABLE." where time<'$max_time'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function drop_users()"); } } if ((include_once $mx_root_path . "modules/mx_online_adv/includes/functions.$phpEx") === false) { function online_spider_surfing($nick, $bot_id) { global $db; $current_time=date("U"); $sql = "DELETE FROM ".ONLINE_ADV_SESSION_TABLE." WHERE username = '".addslashes($nick)."'"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'SQL Error in function online_spider_surfing()', '', __LINE__, __FILE__, $sql); } $sql = "INSERT INTO ".ONLINE_ADV_SESSION_TABLE." (username, time, bot_id)" . " VALUES ('" .addslashes($nick). "', '" .$current_time. "', '" .$bot_id. "')"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'SQL Error in function online_spider_surfing()', '', __LINE__, __FILE__, $sql); } } function update_spiders_surfing($nick,$time,$bot_id) { global $board_config, $db, $lang; $sql="update ".ONLINE_ADV_SESSION_TABLE." SET time='$time', bot_id='$bot_id' WHERE username='$nick'"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'SQL Error in function update_spiders_surfing()', '', __LINE__, __FILE__, $sql); } } function drop_spiders_surfing($period) { global $radio_config, $db, $lang; $current_time = date("U"); //Prevent delay $period = $period + 10; // Calcul max_time $max_time = $current_time - $period; $sql = "DELETE from " . ONLINE_ADV_SESSION_TABLE . " WHERE time < $max_time"; if(!$result = $db->sql_query($sql)) { //mx_message_die(CRITICAL_ERROR, 'SQL Error in function drop_spiders_surfing()', '', __LINE__, __FILE__, $sql); } } } ?> Index: common.php =================================================================== RCS file: /cvsroot/mxbb/mx_pjirc/includes/common.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** common.php 29 Feb 2008 15:54:07 -0000 1.4 --- common.php 4 Jun 2008 00:09:10 -0000 1.5 *************** *** 39,42 **** --- 39,44 ---- define('PJIRC_SESSION_TABLE', $mx_table_prefix.'pjirc_session'); + include_once($module_root_path . 'includes/functions.'.$phpEx); + $default_lang = ($mx_user->lang['default_lang']) ? $mx_user->get_old_lang($mx_user->lang['default_lang']) : $board_config['default_lang']; *************** *** 87,144 **** } ! // ================================================================================ ! // [ COMMON FUNCTIONS ] ! // ================================================================================ ! function user_join($nick) ! { ! global $pjirc_config, $db; ! $current_time=date("U"); ! $sql = "DELETE FROM ".PJIRC_SESSION_TABLE." WHERE username = '".addslashes($nick)."'"; ! if( !$result = $db->sql_query($sql) ) ! { ! die("SQL Error in function user_join(): DELETE<br />" . $sql); ! } ! $sql = "INSERT INTO ".PJIRC_SESSION_TABLE." (username, time)" . ! " VALUES ('" .addslashes($nick). "', ".$current_time.")"; ! if( !$result = $db->sql_query($sql) ) ! { ! die("SQL Error in function user_join(): INSERT<br />" . $sql); ! } ! } ! //Update user statue "chatting/not chatting" ! function update_user($nick,$time) ! { ! global $pjirc_config, $board_config, $db, $lang; ! $sql="update ".PJIRC_SESSION_TABLE." set time='$time' where username='$nick'"; ! if( !$result = $db->sql_query($sql) ) ! { ! die("SQL Error in function update_users(): UPDATE<br />" . $sql); ! } ! } ! function drop_users($period) ! { ! global $pjirc_config, $board_config, $db, $lang; ! $current_time=date("U"); ! //prevent delay ! $period=$period+2; ! // Calcul max_time ! $max_time=$current_time-$period; ! $sql="delete from ".PJIRC_SESSION_TABLE." where time<'$max_time'"; ! if( !$result = $db->sql_query($sql) ) { ! die("SQL Error in function drop_users()"); } ! } ?> --- 89,421 ---- } ! // ! //Set Time and Period ! // ! $time = date("U"); ! $period = 360; //$board_config['session_length']; ! $user_id = $userdata['user_id']; ! $nick = str_replace(" ", "_", $userdata['username']); ! $bot_id = ANONYMOUS; ! // ! //Get The User Agent ! // ! global $_SERVER, $HTTP_USER_AGENT, $HTTP_SERVER_VARS; ! if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) ) ! { ! $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; ! } ! else if ( !empty( $HTTP_SERVER_VARS['HTTP_USER_AGENT'] ) ) ! { ! $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; ! } ! else if ( !isset( $HTTP_USER_AGENT ) ) ! { ! $HTTP_USER_AGENT = ''; ! } ! if ( empty( $user_agent ) ) ! { ! $user_agent = $HTTP_USER_AGENT; ! } ! $user_agent = strtolower( $user_agent ); ! // Determine browser and version ! // The order in which we test the agents patterns is important ! // Intentionally ignore Konquerer. It should show up as Mozilla. ! // post-Netscape Mozilla versions using Gecko show up as Mozilla 5.0 ! // known browsers, list will be updated routinely, check back now and then ! // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below ! // search engine spider bots: ! // various http utility libaries ! // download apps ! if ( preg_match( '/(googlebot |google\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(google )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(googlebot )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(googlebot-mobile )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(googlebot-image )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(adsbot-google )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(mediapartners-google |adsense\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/([Gg][Oo][Oo][Gg][Ll][Ee]*)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(yahoo-verticalcrawler |yahoo\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(yahoo! slurp |yahoo\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(yahooseeker |yahoo\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(yahoo-mm |yahoomm\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(inktomi |inktomi\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(lycosbot |lycos\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(infoseekbot |infoseek\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(slurp |inktomi\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(fast-webcrawler |fast\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msnbot |msn\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msnbot )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msnbot-media |msnbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msnbot-newsblogs |msnbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msnbot-products |msnbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msnbot-academic |msnbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msn )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(altavistabot |altavista\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(excitebot |excite\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(ask jeeves |ask\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(teoma |ask\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(scooter |scooter\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(openbot |openbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(ia_archiver |ia_archiver\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(zyborg |looksmart\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(almaden |ibm\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(baiduspider |baidu\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(psbot |psbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(gigabot |gigabot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(naverbot |naverbot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(surveybot |surveybot\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(boitho.com-dc |boitho\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(objectssearch |objectsearch\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(answerbus |answerbus\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(sohu-search |sohu\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(iltrovatore-setaccio |il-set\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(opera |opera\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(msie )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(mozilla\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(phoenix\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(firebird\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(omniweb |omni\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(konqueror |konq\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(safari |saf\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(gecko |moz\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(netpositive |netp\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(lynx |lynx\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(elinks |elinks\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(links |links\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(w3m |w3m\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(webtv |webtv\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(amaya |amaya\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(dillo |dillo\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(ibrowsevibrowse |ibrowsevibrowse\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(icab |icab\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(crazy browser |ie\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(sonyericssonp800 |sonyericssonp800\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(aol )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(camino )([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(w3c_validator |w3c\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(wdg_validator |wdg\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(libwww-perl |libwww-perl\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(jakarta commons-httpclient |jakarta\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(python-urllib |python-urllib\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(getright |getright\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! elseif ( preg_match( '/(wget |wget\/)([0-9]*).([0-9]{1,2})/', $user_agent, $matches ) ) ; ! else ! { ! $matches[1] = 'unknown'; ! $matches[2] = 0; ! $matches[3] = 0; ! } ! $majorver = $matches[2]; ! $minorver = $matches[3]; ! $ver = $matches[2] . '.' . $matches[3]; ! switch ($matches[1]) ! { ! case 'googlebot ': ! case 'google ': ! case 'googlebot-mobile ': ! case 'googlebot-image ': ! case 'adsbot-google ': ! case 'mediapartners-google ': ! $agent = 'google'; ! $bot_id = '1'; ! break; ! case 'adsense ': ! $agent = 'adsense'; ! $bot_id = '1'; ! break; ! ! case 'yahoo-verticalcrawler ': ! case 'yahoo ': ! case 'yahoo! slurp ': ! case 'yahoo-mm ': ! case 'yahoomm ': ! case 'inktomi ': ! $agent = 'yahoo'; ! $bot_id = '2'; ! break; ! case 'yahoo! slurp ': ! case 'slurp ': ! $agent = 'slurp'; ! $bot_id = '2'; ! break; ! ! case 'lycosbot ': ! case 'lycos ': ! $agent = 'lycos'; ! $bot_id = '3'; ! break; ! ! case 'infoseekbot ': ! case 'infoseek ': ! $agent = 'infoseek'; ! $bot_id = '4'; ! break; ! ! case 'msnbot ': ! case 'msn ': ! case 'msnbot-newsblogs ': ! case 'msnbot-products ': ! case 'msnbot-academic ': ! $agent = 'msn'; ! $bot_id = '5'; ! break; ! ! case 'altavistabot ': ! case 'altavista ': ! $agent = 'altavista'; ! $bot_id = '6'; ! break; ! ! case 'excitebot ': ! case 'excite ': ! $agent = 'excite'; ! $bot_id = '7'; ! break; ! ! case 'ask jeeves ': ! case 'ask ': ! $agent = 'askjeeves'; ! $bot_id = '8'; ! break; ! ! case 'fast-webcrawler ': ! case 'teoma ': ! case 'scooter ': ! case 'openbot ': ! case 'ia_archiver ': ! case 'zyborg ': ! case 'looksmart ': ! case 'almaden ': ! case 'baiduspider ': ! case 'baidu ': ! case 'psbot ': ! case 'gigabot ': ! case 'naverbot ': ! case 'surveybot ': ! case 'boitho.com-dc ': ! case 'boitho ': ! case 'objectssearch ': ! case 'answerbus ': ! case 'sohu-search ': ! case 'sohu ': ! case 'il-set ': ! case 'iltrovatore-setaccio ': ! $agent = $matches[1]; ! $bot_id = '9'; ! break; ! ! default: ! $agent = 'browser'; ! $bot_id = ''; ! ! } ! // Determine platform ! // This is very incomplete for platforms other than Win/Mac ! if ( preg_match( '/(win|mac|linux|unix|x11|freebsd|beos|os2|irix|sunos|aix)/', $user_agent, $matches ) ); ! else $matches[1] = 'unknown'; ! ! switch ($matches[1]) { ! case 'win': ! $platform = 'Win'; ! break; ! ! case 'mac': ! $platform = 'Mac'; ! break; ! ! case 'linux': ! $platform = 'Linux'; ! break; ! ! case 'unix': ! case 'x11': ! $platform = 'Unix'; ! break; ! ! case 'freebsd': ! $platform = 'FreeBSD'; ! break; ! ! case 'beos': ! $platform = 'BeOS'; ! break; ! ! case 'os2': ! $platform = 'OS2'; ! break; ! ! case 'irix': ! $platform = 'IRIX'; ! break; ! ! case 'sunos': ! $platform = 'SunOS'; ! break; ! ! case 'aix': ! $platform = 'Aix'; ! break; ! ! case 'palm': ! $platform = 'PalmOS'; ! break; ! ! case 'unknown': ! $platform = 'Other'; ! break; ! ! default: ! $platform = 'Oops!'; } ! ! //$agent = 'google'; ! //$bot_id = '1'; ! ! if ( !empty($bot_id) ) ! { ! //$current_time = date("U"); ! online_spider_surfing($agent, $bot_id); ! } ! else ! { ! if(strpos($user_agent, 'googlebot') > -1) ! { ! $agent = 'google'; ! $bot_id = '1'; ! } ! elseif(strpos($user_agent, 'google') > -1) ! { ! $agent = 'google'; ! $bot_id = '1'; ! } ! elseif(strpos($user_agent, 'yahoo') > -1) ! { ! $agent = 'yahoo'; ! $bot_id = '2'; ! } ! elseif(strpos($user_agent, 'lycos') > -1) ! { ! $agent = 'lycos'; ! $bot_id = '3'; ! } ! elseif(strpos($user_agent, 'msnbot') > -1) ! { ! $agent = 'msn'; ! $bot_id = '5'; ! } ! } ! ?> |