+ Reply to Thread
Results 1 to 5 of 5

Thread: Ajax with Php

  1. #1
    nyanko's Avatar
    nyanko is offline x10Hosting Member nyanko is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    In front of my pc
    Posts
    57

    Ajax with Php

    Well I need some script that loads this code below every x seconds or minutes automatically, I know it can be done with Ajax but cant find the way to do it, any Ajax oracle out there please help D:
    I wrote this code by Myself and it works but, to do the check again, if the server is receiving connections into the ports desired, I need to Hit reload.
    This is my php file:
    PHP Code:
    <style type="text/css">
    #ServerStatus {
        opacity: 0.75;
        background-color: #4B92B4;
        position: absolute;
        left: 10%;
        top: 20px;
        font-family: Geneva, Arial, Helvetica, sans-serif;
        font-size: 12px;
        border: solid 1px #fff;
        color:#fff;
        padding:5px;
    }
    </style>
    <div id='ServerStatus'>
        <?php
            
    //config start

            
    $ip 'HERE GOES THE IP';
            
    $logport 'port1';
            
    $charport 'port2';
            
    $mapport 'port3';
            
    $offline '<b><FONT COLOR=red>Offline</b>&nbsp;<img src="./images/RedDownArrow.gif" ALT="Offline"></FONT></b>';
            
    $online '<b><FONT COLOR=lime>Online</b>&nbsp;&nbsp;<img src="./images/GreenUpArrow.gif" ALT="Online"></FONT></b>';

            
    //config end -- cheching opening listening ports

            
    $login = @fsockopen($ip$logport$num$error5);
            if(!
    $login) {
                
    $login_status $offline;
                
    $logy=0;
            } else {
                
    $login_status $online
                
    $logy=1;
                
    fclose($login);
            }
            
    $char = @fsockopen($ip$charport$num$error5);
            if(!
    $char) {
                
    $char_status $offline;
                
    $chary=0;
            } else {
                
    $char_status $online
                
    $chary=1;
                
    fclose($char);
            }
            
    $map = @fsockopen($ip$mapport$num$error5);
            if(!
    $map) {
                
    $map_status $offline;
                
    $mapy=0;
            } else {
                
    $map_status $online
                
    $mapy=1;
                
    fclose($map);
            }
            if (
    $logy==1&&$chary==1&&$mapy==1){
                
    //Checking Users Online
                
    mysql_connect($ip,'worldmap','') or die();
                @
    mysql_select_db('epitaph');
                
    $query "SELECT COUNT(*) as total FROM `char` WHERE online = '1'";
                
    $result mysql_query($query);
                
    mysql_close();
                
    $arr mysql_fetch_array($result);
                
    $usersonline "<b><FONT COLOR=lime> $arr[total] </FONT></b>";
            } else 
                
    $usersonline '<b><FONT COLOR=red>Offline</b>&nbsp;<img src="./images/RedDownArrow.gif" ALT="Offline"></FONT></b>';
            
    //Printing Results
            
    echo "<b>";
            echo 
    "<tbody><table><tr><td>Server Status</tr></td>";
            echo 
    "<tr><td>Login Server:</td><td>$login_status</td></tr>";
            echo 
    "<tr><td>Char Server:</td><td>$char_status</td></tr>";
            echo 
    "<tr><td>Map Server:</td><td>$map_status</td></tr>";
            echo 
    "<tr><td>Players Online:</td><td>$usersonline</td></tr></table></tbody>";
            echo 
    "</b>";
        
    ?>
    </div>
    Edit:
    bump D: I buried my own post with some of my responses xD
    Last edited by nyanko; 09-07-2008 at 05:38 PM. Reason: Automerged Doublepost
    Hago banners/logos/diseños por comida y/o links a mi sitio :P.
    Making banners/logos/designs for food/backlink to my site :P.

  2. #2
    sunils's Avatar
    sunils is offline x10 Spammer sunils is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Chennai ,India
    Posts
    2,264

    Re: Ajax with Php

    you can google for ajax script here. google for ajax script calling server function...

    here is some of the link that i found out

    http://en.wikipedia.org/wiki/XMLHttpRequest

    you have to use the XMLHTTPRequest function to do that..

    Here is another link...with help of jquery...

    http://roshanbh.com.np/2008/03/call-...nd-jquery.html
    [LEFT][B]Sunil Sankar
    -------------------------------------------------------------------------

  3. #3
    jhahoney is offline x10Hosting Member jhahoney is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    34

    Re: Ajax with Php

    try http://www.w3schools.com and goto AJAX tutorials, its superb

  4. #4
    nyanko's Avatar
    nyanko is offline x10Hosting Member nyanko is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    In front of my pc
    Posts
    57

    Smile Re: Ajax with Php

    Thanks :3
    I will try, besides I didn't want to use XMLHTTPRequest cause it shows the activex thing on IE
    Edit:
    Thanks I got it solved, now I know Ajax :P.

    Wheres the close button :o? :lockd:
    Last edited by nyanko; 09-08-2008 at 05:52 PM. Reason: Automerged Doublepost
    Hago banners/logos/diseños por comida y/o links a mi sitio :P.
    Making banners/logos/designs for food/backlink to my site :P.

  5. #5
    phpasks is offline x10 Sophmore phpasks is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    145

    Re: Ajax with Php

    Ajax Simple Example Download
    http://www.phpasks.com/ajax/simple_ajax.html

    Using Prototype js framework
    http://www.phpasks.com/ajax/prototype_ajax.html
    Asif Khalyani
    http://www.phpasks.com

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. Places to learn php
    By JaWasabi in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-13-2009, 02:03 AM
  4. Pregunta sobre las Configuraciones PHP
    By Trevelin in forum Soporte
    Replies: 11
    Last Post: 04-28-2008, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers