Get IP address in Ajax shoutbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rinawmt
    New Member
    • Jun 2007
    • 12

    #1

    Get IP address in Ajax shoutbox

    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
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    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?

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      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

      Comment

      • rinawmt
        New Member
        • Jun 2007
        • 12

        #4
        Originally posted by pbmods
        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("c onfiguration.ph p");
        } else {
        require_once(". ./configuration.p hp");
        }

        //require_once($p ath_to_mambo."/configuration.p hp");
        $user = isset($mosConfi g_user)? $mosConfig_user : "";
        $db = isset($mosConfi g_db)? $mosConfig_db : "";
        $host = isset($mosConfi g_host)? $mosConfig_host : "";
        $pass = isset($mosConfi g_password)? $mosConfig_pass word : "";
        $prefix = isset($mosConfi g_dbprefix)? $mosConfig_dbpr efix : "";
        $live = isset($mosConfi g_live_site)? $mosConfig_live _site : "";

        # Get the right language if it exists
        if (file_exists($m osConfig_absolu te_path.'/components/com_smo_ajax_sh outbox/languages/' .$mosConfig_lan g.'.php')) {
        include($mosCon fig_absolute_pa th.'/components/com_smo_ajax_sh outbox/languages/' .$mosConfig_lan g.'.php');
        } else {
        include($mosCon fig_absolute_pa th.'/components/com_smo_ajax_sh outbox/languages/ english.php');
        }

        //get the configuration file
        require_once( $mosConfig_abso lute_path."/administrator/components/com_smo_ajax_sh outbox/ smo_ajax_shoutb ox.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.

        Comment

        • rinawmt
          New Member
          • Jun 2007
          • 12

          #5
          Originally posted by acoder
          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.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by rinawmt
            Thanks for helping me in when i did wrong .

            thanks Moderator.
            No problem. Good thread titles help everyone.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              I've copied the thread over to PHP where the experts will be able to help you with getting the IP address.

              Comment

              Working...