Page 5 of 13

[DEV] jQ Who is where v.0.0.2

Posted: 14 Jan 2013, 04:01
by 4seven
martin123456 wrote:Dont make sense to me guess its a lang thing.
+ a case and a append_sid() link

viewonline.php

Code: Select all

		case 'custom_site':
			$location =  $user->lang['VIEWING_CUSTOM_SITE'];
			$location_url = append_sid("{$phpbb_root_path}custom_site.$phpEx");
		break;
Makes absolut sense. In all cases it must be manually added to viewonline.php or this mod main file.
Solidjeuh wrote:Personal choice
Good look

[DEV] jQ Who is where v.0.0.2

Posted: 14 Jan 2013, 12:53
by Blackwolf
My forum simply shows any user as on the index page only......if one uses a test account and goes to various topics, it does not show, but Google adsense shows where the tester is....??

Users only show on Index but bots show wherever they are.......
Screenshot.png
This is one of the best mods out there....awesome work & cant wait for version 3.0 :thumb:

[DEV] jQ Who is where v.0.0.2

Posted: 14 Jan 2013, 22:47
by 4seven
Never heard about this (only index) issue. For me and several others it works out of the box. So all i can say is, check the install again and clear all available Board- and Browser-Caches. Also all codings which can have side effects. Otherwise i need a testuser.

[DEV] jQ Who is where v.0.0.2

Posted: 15 Jan 2013, 11:02
by Blackwolf
PM Sent

[DEV] jQ Who is where v.0.0.2

Posted: 16 Jan 2013, 01:24
by 4seven
Please fix these firebug errors before we go further.

Code: Select all

"NetworkError: 404 Not Found - https://www.ultimateeditionoz.com/forum/styles/prosilver/template/colour-switcher.js"

"NetworkError: 403 Forbidden - https://www.ultimateeditionoz.com/forum/styles/prosilver/template/mchat_body.html"

"NetworkError: 403 Forbidden - https://www.ultimateeditionoz.com/forum/styles/prosilver/template/mchat_body.html"

"NetworkError: 404 Not Found - https://www.ultimateeditionoz.com/forum/styles/prosilver/template/colour-switcher.js"

"NetworkError: 403 Forbidden - https://www.ultimateeditionoz.com/forum/styles/prosilver/template/mchat_body.html"

GET https://www.ultimateeditionoz.com/forum/who_is_where.php?sid=25acf6044f457d0ae82bb8a13f1eaaae
	
200 OK

"NetworkError: 404 Not Found - https://www.ultimateeditionoz.com/forum/styles/prosilver/imageset/en_us/search_bg.png"

"NetworkError: 404 Not Found - https://www.ultimateeditionoz.com/forum/images/prog_grey_index.png"

"NetworkError: 403 Forbidden - https://www.ultimateeditionoz.com/forum/styles/prosilver/template/mchat_body.html"

"NetworkError: 404 Not Found - https://www.ultimateeditionoz.com/forum/images/prog_yellow_index.png"

"NetworkError: 404 Not Found - https://www.ultimateeditionoz.com/forum/styles/prosilver/theme/images/sexytrans.png"
May check your cookie settings, because i get an SID, though i am logged in.

Note: If a guest follows a link, which is for Reg only, the viewer always get a "guest on index". The mod depends on forum read rights*.

*you see it here, where the guest shows right: one have a link name and 0ne is downloading a file.
note.jpg
May check this also.

Have you customize the script? Eg. if a brace or case in false place or order, any syntactical error,
the result can be wired.

Btw. i need a second testuser to check further, bcs. as guest with another browser i see nothing from my testusers action.

[DEV] jQ Who is where v.0.0.2

Posted: 16 Jan 2013, 11:52
by Blackwolf
Cookie sorted, Guests have always been set to view all forums (apart from Admin area)

Whole file. Pm sent with additional Test User :thumb:

Code: Select all

<?php
/**
*
* @package who_is_where  v.0.0.2
* @version $Id: who_is_where.php 2356 2012-07-28 15:38:36Z 4seven $
* @copyright (c) 2012 / 4seven
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx); 

$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

// only if rights
if($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')){


// sending utf8 header / important
header('Content-type: text/html; charset=utf-8');

    // New cookie engine to spare provider load - Part I
	$sessionid     = $config['cookie_name'] . '_base';
	$sessionid_chk = request_var($sessionid, '', false, true);	

	if ($sessionid_chk !== ''){
	$base = true;
	}
	else{
	$base = false;
	echo '<tr class="bg1">
	<td class="name" style="width:25%;">' . $user->lang['WIW_NO_COOKIE'] . '</td>
	<td class="name" style="width:5%; text-align:center;"><img src="images/74t.gif" style="margin-bottom:3px; width:8px;" alt="" /></td>
	<td class="info" style="width:25%; text-align:center;"><img src="images/74t.gif" style="margin-bottom:3px; width:8px;" alt="" /></td>
	<td class="active" style="width:20%;"><img src="images/74t.gif" style="margin-bottom:3px; margin-left:3px; width:8px;" alt="" /></td>
	<td class="active" style="width:25%;"><img src="images/74t.gif" style="margin-bottom:3px; margin-left:3px; width:8px;" alt="" /></td>
	</tr>';
	exit;
	}
	
	if($base){
	// New cookie engine to spare provider load - Part I


	// function user_get_name
	function user_get_name($u_id)
	{	
	   global $db;

	   $sql = 'SELECT username, user_colour
	         FROM ' . USERS_TABLE . '
	         WHERE user_id = ' . $db->sql_escape($u_id);
	   $result = $result = $db->sql_query_limit($sql, 1);
	   $row = $db->sql_fetchrow($result);
	   $db->sql_freeresult($result);

	   if($row)
	   {
	      return ': ' . get_username_string('no_profile', $u_id, $row['username'], $row['user_colour']);
	   }
	   else
	   {
	      return '';
	   }
	}
	// function user_get_name

	// function get_agent
	function get_agent($u_ag){

	global $user, $phpbb_root_path;

	// bot switch
	switch ($u_ag) {

    case (strpos($u_ag, 'Firefox') !== false):
        	$b_out = 'firefox.png';
	        $u_out = preg_replace('#(.*?)Firefox/([0-9\.]+)(.*?)#', $user->lang['WIW_FF'] . ' $2' , $u_ag);
        break;
    case (strpos($u_ag, 'MSIE') !== false):
        	$b_out = 'ie.png';	
	        preg_match('#MSIE ([0-9\.]+)#',  $u_ag, $ie_detect);
	        $u_out = $user->lang['WIW_IE'] . ' ' . $ie_detect[1];
        break;
    case (strpos($u_ag, 'Opera') !== false):
        	$b_out = 'opera.png';
	        $u_out = preg_replace('#(.*?)Opera/([0-9\.]+)(.*?)Version/([0-9\.]+)(.*?)#', 
	        $user->lang['WIW_OPERA'] . ' $4', $u_ag);
        break;
	case ((strpos($u_ag, 'Chrome') !== false) && (strpos($u_ag, 'Safari') !== false)):
        	$b_out = 'chrome.png';
        	$u_out = preg_replace('#(.*?)Mozilla/([0-9\.]+)(.*?)Chrome/([0-9\.]+) ([a-zA-Z]+/[0-9\.]+)#', 
        	$user->lang['WIW_CHROME'] . ' $4', $u_ag);
        break;
	case ((strpos($u_ag, 'Chrome') === false) && (strpos($u_ag, 'Safari') !== false)):
        	$b_out = 'safari.png';
        	$u_out = preg_replace('#(.*?)Version/([0-9\.]+) Safari/([0-9\.]+)#', 
        	$user->lang['WIW_SAFARI'] . ' $2', $u_ag);
        break;
	case (strpos(strtolower($u_ag), 'bot') !== false):
            preg_match('#compatible;(.*?);#',  $u_ag, $bot_detect);
            if (!empty($bot_detect)){
            $b_out = 'unknown.png';
            $u_out = $bot_detect[1];}
			else{
            $b_out = 'unknown.png';
            $u_out = $user->lang['WIW_NO_BROWSER'];}			
        break;		
	}

	// all others are unknown / only the major browser / dont blow up this baby
	if (((isset($u_ag) && isset($u_out)) && ($u_ag === $u_out))){
	$b_out = 'unknown.png';
	$u_out = $user->lang['WIW_NO_BROWSER'];}
	else if (!isset($u_ag) || (!isset($u_out))){
	$b_out = 'unknown.png';
	$u_out = $user->lang['WIW_NO_BROWSER'];}

	// return browser output
	return  '<img style="position:relative; top:1px;" src="' . $phpbb_root_path . 'images/browsers/' . $b_out . '" alt="" />' 
	. ' ' . '<span style="position:relative; bottom:5px;">' . $u_out . '</span>';
	
	}
	// function get_agent

	
	// forum info / grabs and caching forum info
	$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
		FROM ' . FORUMS_TABLE . '
		ORDER BY left_id ASC';
	$result = $db->sql_query($sql, 600);
	
	// tricky thing
	$forum_data = array();
	while ($row = $db->sql_fetchrow($result))
	{
		$forum_data[$row['forum_id']] = $row;
	}
	$db->sql_freeresult($result);

	// dont show hidden users
	$sql_hidden = (!$auth->acl_get('u_viewonline')) ? ' AND session_viewonline != 0 AND user_allow_viewonline !=0' : '';

	// show guests / false or true / on big boards make it better false
	$show_guests = true;

// AND session_page NOT LIKE "%who_is_%"  # beta 
// AND group_id != 6 # beta


	// session sql request
	$sql = 'SELECT DISTINCT(s.session_ip), s.session_user_id, s.session_id, s.session_time, s.session_start, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id, u.user_id, u.username, u.username_clean, u.user_type, u.user_colour 
	FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . ' u 
	WHERE s.session_user_id = u.user_id

		AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
		   $sql_hidden . 
		((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') .  '
	GROUP BY session_ip, user_id';		

	$result = $db->sql_query($sql);


	// AND group_id != 6
	// 
	while ($row = $db->sql_fetchrow($result))
	{

	// var_dump($row);
    // var_dump($row['session_page']);	

	// better make an array before, if empty
	$sizeof_row[] = array();

	// splitting relevant vars
	preg_match('#^([a-z0-9/_-]+)#i', $row['session_page'], $on_page);
	if (!sizeof($on_page))
	{
		$on_page[1] = '';
	}

	$on_apps    =   explode("?",$row['session_page']); 
	$on_apps    = (!empty($on_apps[1])) ? $on_apps[1] : '';

	preg_match('#(&u=)([0-9]+)#', $on_apps, $on_ap);

	$on_apps_u  = (!empty($on_ap[2])) ? user_get_name($on_ap[2]) : '';	
	
	// $on_apps_u  = (!empty($on_ap[2])) ?  ': ' . get_username_string('no_profile', $on_ap[2], $row['username'], $row['user_colour']) : ''; 
	// user_get_name($on_ap[2]) : ''; # performance-check

	// switch the on page thing
	switch ($on_page[1])
	{
		case 'index':
			$location = $user->lang['INDEX'];
			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;

		case 'adm/index':
			$location = $user->lang['ACP'];
			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;

		case 'posting':
		case 'viewforum':
		case 'viewtopic':
			$forum_id = $row['session_forum_id'];

			if ($forum_id && $auth->acl_get('f_list', $forum_id))
			{
				$location = '';
				$location_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);

				if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK)
				{
					$location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']);
					break;
				}

				switch ($on_page[1])
				{
					case 'posting':
						preg_match('#mode=([a-z]+)#', $row['session_page'], $on_page);
						$posting_mode = (!empty($on_page[1])) ? $on_page[1] : '';

						switch ($posting_mode)
						{
							case 'reply':
							case 'quote':
								$location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
							break;

							default:
								$location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
							break;
						}
					break;

					case 'viewtopic':
						$location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']);
					break;

					case 'viewforum':
						$location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']);
					break;
				}
			}
			else
			{
				$location = $user->lang['INDEX'];
				$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
			}
		break;

		case 'search':
			$location = $user->lang['SEARCHING_FORUMS'];
			$location_url = append_sid("{$phpbb_root_path}search.$phpEx");
		break;

		case 'faq':
			$location = $user->lang['VIEWING_FAQ'];
			$location_url = append_sid("{$phpbb_root_path}faq.$phpEx");
		break;

		case 'viewonline':
			$location = $user->lang['VIEWING_ONLINE'];
			$location_url = append_sid("{$phpbb_root_path}viewonline.$phpEx");
		break;

		case 'memberlist':
			$location = $user->lang['VIEWING_MEMBERS'];

			// Grab some common modules
			$url_params = array(
				'mode=viewprofile'	    => 'VIEWING_MEMBER_PROFILE',
				'mode=profile_views'	=> 'VIEWING_PROFILE_VIEWS',	
			);
			
				foreach ($url_params as $param => $lang)
			{
				if (strpos($row['session_page'], $param) !== false)
				{
					$location = $user->lang[$lang];
					break;
				}
			}
			
			$location_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", $on_apps);
		break;

		case 'mcp':
			$location = $user->lang['VIEWING_MCP'];
			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;

		case 'ucp':
			$location = $user->lang['VIEWING_UCP'];

			// Grab some common modules
			$url_params = array(
				'mode=register'		=> 'VIEWING_REGISTER',
				'i=pm&mode=compose'	=> 'POSTING_PRIVATE_MESSAGE',
				'i=pm&'				=> 'VIEWING_PRIVATE_MESSAGES',
				'i=profile&'		=> 'CHANGING_PROFILE',
				'i=prefs&'			=> 'CHANGING_PREFERENCES',
			);

			foreach ($url_params as $param => $lang)
			{
				if (strpos($row['session_page'], $param) !== false)
				{
					$location = $user->lang[$lang];
					break;
				}
			}

			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;

		case 'download/file':
			$location = $user->lang['DOWNLOADING_FILE'];
			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;

		case 'report':
			$location = $user->lang['REPORTING_POST'];
			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;
		
		
		case 'annuaire':
			$location = $user->lang['VIEWING_ANNUAIRE'];

			// Grab some common modules
			$url_params = array(
				'mode=cat&id=1'		=> 'VIEWING_ANNUAIRE_CAT_1',
				'mode=cat&id=2'		=> 'VIEWING_ANNUAIRE_CAT_2',
				'mode=cat&id=3'		=> 'VIEWING_ANNUAIRE_CAT_3',		
			);
			
				foreach ($url_params as $param => $lang)
			{
				if (strpos($row['session_page'], $param) !== false)
				{
					$location = $user->lang[$lang];
					break;
				}
			}

			$location_url = append_sid("{$phpbb_root_path}annuaire.$phpEx");
		break;

		default:
			$location = $user->lang['INDEX'];
			$location_url = append_sid("{$phpbb_root_path}index.$phpEx");
		break;
	}

	// a bit finetuning on username
	$row['username'] = str_replace('Anonymous', $user->lang['GUEST'], $row['username']);
	
	# 1 opening tr
    $echo_1 = '<tr class="bg1">';

	# 2 td class echo / username
	$echo_2 = '<td class="name" style="width:25%;">' . get_username_string('full', $row['session_user_id'], $row['username'], $row['user_colour']) . '</td>';

	// row session ip
	$row_session_ip   = $row['session_ip'];

	// get flags from api with simple text output
	//$session_ip_cat = @file_get_contents("http://api.wipmania.com/$row_session_ip?k=Img-5CWR9I68vXzQgkOhSs4MEAe"); # old API bl

	// Get flags for user_ip
	
	// Prevent for bl
	// $session_ip_c = 'XX';
	// $row_img_tag  = $phpbb_root_path . 'images/flags/XX.png';

	// New cookie engine to spare provider load - Part II
	$session_id_1     = $config['cookie_name'] . '_' . preg_replace('/[^A-Za-z]/', '', $row['session_id']) . '_1';
	$session_id_1_chk = request_var($session_id_1, '', false, true);
	
	$session_id_2     = $config['cookie_name'] . '_' . preg_replace('/[^A-Za-zÄÖÜäöü]/', '', $row['session_id']) . '_2';
	$session_id_2_chk = request_var($session_id_2, '', false, true);	

	// $session_start = $row['session_start']; # test
	
	if (($session_id_1_chk !== '') && ($session_id_2_chk !== ''))
	{
	$session_ip_c  = $session_id_1_chk;	
	$session_ip_n  = $session_id_2_chk;
	$row_img_tag   = $phpbb_root_path . 'images/flags/' . $session_id_1_chk . '.png';
	$cookie_true   = '';
	}	
	else
	{
	$filestream    = @file_get_contents("http://www.geoplugin.net/php.gp?ip=$row_session_ip" );
	
	if($filestream === false)
	{
	$session_ip_c  = 'XX';
	$session_ip_n  = '';
	$row_img_tag   = $phpbb_root_path . 'images/flags/XX.png';
	$cookie_true   = '';
	}
	else
	{
	$filestream    = unserialize($filestream);
	
	$geostream     = $filestream['geoplugin_countryName'];	
	$filestream    = $filestream['geoplugin_countryCode'];
	
	$session_ip_c  = $filestream;
	$session_ip_n  = $geostream;
	
	$row_img_tag   = $phpbb_root_path . 'images/flags/' . $filestream . '.png';	
	
	$set_cookie_1  = "$filestream";
	$set_cookie_2  = "$geostream";
	
	$cookie_true   = '<img src="images/74t.gif" style="margin-bottom:3px; margin-left:10px; width:8px;" alt="" />';
	
	setcookie("$session_id_1", $set_cookie_1, time()+3600*24);
	setcookie("$session_id_2", $set_cookie_2, time()+3600*24);
	}
	
	}
	// New cookie engine to spare provider load - Part II


	# 3 td class echo / flags with ip output for admins and mods
	$echo_3 = '<td class="name" style="width:5%; text-align:center;"><img src="' . $row_img_tag . '" alt="" ' . (($auth->acl_get('a_') || $auth->acl_get('m_')) ? 'title="' . $session_ip_n . ' - ' . $row_session_ip . '"' : 'title="' . $session_ip_n . '"') . ' /></td>';

	# 4 td class echo / location
	$echo_4 = '<td class="info" style="width:25%; text-align:center;"><a href="' . $location_url.'" title="'.$location.'">'.$location . '</a>' . $on_apps_u . '</td>';

	# 5 td class echo / session start
	$echo_5 = '<td class="active" style="width:20%; ">' . $user->format_date($row['session_start']) . $cookie_true . '</td>';	

	// get useragent by session_browser
	$row['session_browser'] = get_agent($row['session_browser']);

	# 6 td class echo / show useragent
	$echo_6 = '<td class="active" style="width:25%;">' . (((strlen($row['session_browser'])) > 180) ? (mb_substr($row['session_browser'], 0, 180) . '...') : $row['session_browser']) . '</td>';

	# 7 closing tr
	$echo_7 = '</tr>';	
	
    // prepare echo out of the whole construct	
	$echo_out[] = $echo_1 . $echo_2 . $echo_3 . $echo_4 . $echo_5 . $echo_6 . $echo_7;

	}

	// free sql result
	$db->sql_freeresult($result);

// echo out the whole construct, if set
if (isset($echo_out)){ 

var_dump($echo_out);

}

// else no online users
else{
	echo '<tr class="bg1">
	<td class="name" style="width:25%;">' . $user->lang['NO_ONLINE_USERS'] . '</td>
	<td class="name" style="width:5%; text-align:center;"><img src="images/74t.gif" style="margin-bottom:3px; width:8px;" alt="" /></td>
	<td class="info" style="width:25%; text-align:center;"><img src="images/74t.gif" style="margin-bottom:3px; width:8px;" alt="" /></td>
	<td class="active" style="width:20%;"><img src="images/74t.gif" style="margin-bottom:3px; margin-left:3px; width:8px;" alt="" /></td>
	<td class="active" style="width:25%;"><img src="images/74t.gif" style="margin-bottom:3px; margin-left:3px; width:8px;" alt="" /></td>
	</tr>';
}
	
}

}
?>

[DEV] jQ Who is where v.0.0.2

Posted: 17 Jan 2013, 07:09
by Jessica
I know you said the next version will come in January and you didn't set a date for v0.0.3, but it's now halfway in January...will the new version be out soon?

[DEV] jQ Who is where v.0.0.2

Posted: 17 Jan 2013, 14:10
by 4seven
Hi Jessica,

newest info you find here
http://www.4seven.de/forum/6test/viewto ... p=828#p828

[DEV] jQ Who is where v.0.0.2

Posted: 18 Jan 2013, 20:36
by martin123456
Got the index only problem too :lol:

But have found the conflict and fixed it once i got my edits togeather if interested 4_seven i'l pass them over to you as it's a jquery conflict between another mod :thumb:

[DEV] jQ Who is where v.0.0.2

Posted: 19 Jan 2013, 02:23
by 4seven
A clean java environment without any mix of java librarys (moo, JQ, whatever) is an ideality and self-evident. I never use a mix. I can build all things with one lib and the best is jQuery. Also, if i can build a script in classic JS, i never use any library. Not each function needs jQ. Anyway. User would be thankfull, if you can share your solution. The false of inserting double, triple instances of jQ must be clear. If any way, the jQ addition should also work with latest_min and not for a designated version. Find a code or update for this ones and all live in peace.