Login   Register  
PHP Classes
elePHPant
Icontem

File: Example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Peter  >  Users  >  Example.php  >  Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example main script
Class: Users
Manage user records stored in files
Author: By
Last change: Example main script
Date: 2011-05-11 18:44
Size: 4,317 bytes
 

Contents

Class file image Download
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
        <script language="javascript">
        $(document).ready(function(){
            
            var Initialization = function(){
                $('#show').attr('disabled', true);
            }
            
            $('#update').bind(
                'click',
                function(e){
                    var url = 'Server.php';
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        success:function(response){
                            $('#show').attr('disabled', false);
                            alert('Server Update Success!!');
                        },
                        error:function(xhr){
                            alert('Server Update Failuere!!');
                        }
                    });
                }
            );
                
            $('#show').bind(
                'click',
                function(e){
                    var url = 'Client.php';
                    var mode = 'getAllUser';
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{
                            url:url,
                            mode:mode
                        },
                        success:function(response){
                            var mode = 'checkUsers';
                            var users = '';
                            if(!response['responseStatus']){
                                return false;
                            }
                            for(var i = 0; i < response['responseText']['users'].length; i++){
                                if(i + 1 < response['responseText']['users'].length){
                                    users += response['responseText']['users'][i] + ',';
                                }else{
                                    users += response['responseText']['users'][i];
                                }
                            }
                            $.ajax({
                                url:url,
                                type:'POST',
                                dataType:'json',
                                data:{
                                    url:url,
                                    mode:mode,
                                    users:users
                                },
                                success:function(response){
                                    var html = '';
                                    if(!response['responseStatus']){
                                        return false;
                                    }
                                    for(var i = 0; i < response['responseText']['online'].length; i++){
                                        html += response['responseText']['users'][i] + (response['responseText']['online'][i] ? ' Online <br />' : ' Offline <br />');
                                    }
                                    $('#message').html(html);
                                },
                                error:function(xhr){
                                    alert('Get Data From Server Failure!!!');
                                }
                            });
                        },
                        error:function(response){
                            alert('Get Data From Server Failure!!!');
                        }
                    });
                }
            );
                
            Initialization();
        });
        </script>
        <title>User Online</title>
    </head>
    <body>
        <input type="button" id="update" value="Update Server Data" /><br />
        <input type="button" id="show" value="Show Online Users" /><br />
        <div id="message"></div>
    </body>
</html>