By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,563 Members | 1,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,563 IT Pros & Developers. It's quick & easy.

Get IP address in Ajax shoutbox

P: 12
hello fren...
i'm using joomla software in my website.
There i put one shouth box... and for that shoutbox i'm using Ajax shoutbox, there when ever people shouth using through Guest or the member ip never shows up.
I wan to show there ip address int he shoutbox who ever send messages in the soutbox so do help write the code and send me using through this site or send me
One more thing... the ip can be view by the Adminsitrator only of th site. not every one who register. or who is online.
hope you get my point
Thank you.
directly in my e-mail id.
**** - email removed
Jun 23 '07 #1
Share this Question
Share on Google+
10 Replies


pbmods
Expert 5K+
P: 5,821
Heya, rinawmt. Welcome to TSDN!

If you're having trouble getting the IP address, that's a server-side problem (I'm assuming that you are not passing the IP in the AJAX request because that's too easy to spoof).

What language are you using server-side?
Jun 23 '07 #2

acoder
Expert Mod 15k+
P: 16,027
I've changed the thread title for you.

This helps people find similar problems/solutions more easily and people can tell a a glance what the thread is about.

MODERATOR
Jun 25 '07 #3

P: 12
Heya, rinawmt. Welcome to TSDN!

If you're having trouble getting the IP address, that's a server-side problem (I'm assuming that you are not passing the IP in the AJAX request because that's too easy to spoof).

What language are you using server-side?
[PHP]<?php

/*
* @package Joomla_1.0.x
* @copyright (C) 2004 - 2006 Siemens-mobiles.org
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Joomla is Free Software
*/

// The number of comments that should show up in one viewing.
$jal_number_of_comments = 35;

//disabling notice to escape the weird undefined $mosConfig_user when
//shoutbox is on a wrapper page
error_reporting(E_ALL ^ E_NOTICE);

if(defined( '_VALID_MOS' )) {
require_once("configuration.php");
} else {
require_once("../configuration.php");
}

//require_once($path_to_mambo."/configuration.php");
$user = isset($mosConfig_user)? $mosConfig_user : "";
$db = isset($mosConfig_db)? $mosConfig_db : "";
$host = isset($mosConfig_host)? $mosConfig_host : "";
$pass = isset($mosConfig_password)? $mosConfig_password : "";
$prefix = isset($mosConfig_dbprefix)? $mosConfig_dbprefix : "";
$live = isset($mosConfig_live_site)? $mosConfig_live_site : "";

# Get the right language if it exists
if (file_exists($mosConfig_absolute_path.'/components/com_smo_ajax_shoutbox/languages/' .$mosConfig_lang.'.php')) {
include($mosConfig_absolute_path.'/components/com_smo_ajax_shoutbox/languages/' .$mosConfig_lang.'.php');
} else {
include($mosConfig_absolute_path.'/components/com_smo_ajax_shoutbox/languages/ english.php');
}

//get the configuration file
require_once( $mosConfig_absolute_path."/administrator/components/com_smo_ajax_shoutbox/ smo_ajax_shoutbox.cfg.php");

// Register globals - Thanks Karan et Etienne
$jal_lastID = isset($_GET['jal_lastID']) ? $_GET['jal_lastID'] : "";
$jal_user_name = isset($_POST['n']) ? $_POST['n'] : "";
$jal_user_url = isset($_POST['u']) ? $_POST['u'] : "";
$jal_user_text = isset($_POST['c']) ? $_POST['c'] : "";
$jalGetChat = isset($_GET['jalGetChat']) ? $_GET['jalGetChat'] : "";
$jalSendChat = isset($_GET['jalSendChat']) ? $_GET['jalSendChat'] : "";

// Time Since function courtesy
// http://blog.natbat.co.uk/archive/200...jal_time_since

// Works out the time since the entry post, takes a an argument in unix time (seconds)
function jal_time_since($original) {
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , _JAL_YEAR , _JAL_YEARS),
array(60 * 60 * 24 * 30 , _JAL_MONTH , _JAL_MONTHS),
array(60 * 60 * 24 * 7, _JAL_WEEK , _JAL_WEEKS),
array(60 * 60 * 24 , _JAL_DAY , _JAL_DAYS),
array(60 * 60 , _JAL_HOUR , _JAL_HOURS),
array(60 , _JAL_MINUTE , _JAL_MINUTES),
);
$original = $original - 10; // Shaves a second, eliminates a bug where $time and $original match.
$today = time(); /* Current unix time */
$since = $today - $original;

// $j saves performing the count function each time around the loop
for ($i = 0, $j = count($chunks); $i < $j; $i++) {

$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
$names = $chunks[$i][2];

// finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0) {
break;
}
}

$print = ($count == 1) ? '1 '.$name : "$count {$names}";

if ($i + 1 < $j) {
// now getting the second item
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
$names2 = $chunks[$i + 1][2];

// add second item if it's greater than 0
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
$print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$names2}";
}
}
return $print;
}[/PHP]

I cant probably say what scrip i'm using LOlz... that y i just past some of the script here.

If you can make it, do modify and send me the script which can show the IP when they shout in the south box... do mail me the code in at **** (email removed - MODERATOR)
I want the IP can be view by the Moderator only.
Jun 27 '07 #4

P: 12
I've changed the thread title for you.

This helps people find similar problems/solutions more easily and people can tell a a glance what the thread is about.

MODERATOR
Thanks for helping me in when i did wrong .

thanks Moderator.
Jun 27 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Thanks for helping me in when i did wrong .

thanks Moderator.
No problem. Good thread titles help everyone.
Jun 28 '07 #6

acoder
Expert Mod 15k+
P: 16,027
I've copied this thread to PHP too. We'll deal with the AJAX aspect in this thread.
Jun 28 '07 #7

P: 12
I've copied this thread to PHP too. We'll deal with the AJAX aspect in this thread.
Nope... This is not all the script for the shoutbox. if you want to modify all the script i will probably paste all the script. i paste only that much because i wanna let you know what script did they used in Ajax. thanks
Jun 28 '07 #8

acoder
Expert Mod 15k+
P: 16,027
Nope... This is not all the script for the shoutbox. if you want to modify all the script i will probably paste all the script. i paste only that much because i wanna let you know what script did they used in Ajax. thanks
I know it's not the full script, but trying to get the IP address back in your Ajax shoutbox, you would need to know a bit of Ajax/Javascript.
Jun 29 '07 #9

P: 12
I know it's not the full script, but trying to get the IP address back in your Ajax shoutbox, you would need to know a bit of Ajax/Javascript.
I dunno the script thats why i'm posting the question here. anyway thanks for helpoing me. does anyone can help me please?/
Jun 29 '07 #10

pbmods
Expert 5K+
P: 5,821
Heya, rinawmt.

On the PHP side, you can get the IP address of the client by using $_SERVER['REMOTE_ADDR'].

This is the recommended way of doing it. On the JavaScript side, anything you send to the server is potentially editable by the browser.
Jun 29 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.