FlashPioneer Video Chat Installation Documentation
Copyright (C) 2001-2006 SourceTec Software Co., LTD.
All Rights Reserved

----------------------------------------------------------------
Table of Contents
      
    * Install Chat's database (PHP)
    * PHP Interface description

----------------------------------------------------------------

Install Chat's database (PHP)

    There two ways to keep the data. One is using the file format which is the 
    same as the former version, there is no need for users to setup to use, 
    Users' information and chat history are stored under the Chat server path 
    with an encryption; the other is integrating with the present database by 
    PHP interface through which the users' information and chat history store 
    in the database. 

    1) First please make sure that your web server supports php and MySQL

    2) Build MySQL database

        please use your MySQL control panel to create a data base named 
        "flashchat".
        Operating sql statement of database.sql and build two new data tables: 
        users and log

        "users" table is for saving the users' information, the structure is as 
        following:
            uid            Primary KEY, autoincrease 
            username       User's name 
            password       Password 
            level          The user's level, the default value is 0, if it is 1 
                           then it is the administrator 
            signDate       Register time 
            lastLogin      The last login time  

        "log" table is for chatting history, the structure as is as following:
            lid            Primary KEY, autoincrease 
            target         Massage receiving one 
            ip             The user's IP address
            username       Massage sending one 
            message        Message content 
            date           Message sending time 

        After running sql statement, insert two users in users table:
            username    password    level
            admin       admin       1
            user        user        0

    3) Install amfphp program

        Unzip phpService.zip, go into the amfphp_1.2 folder after unzipping, 
        use Notepad or other text editor tools to open 
        "services/flashchat/chatService.php", and modify the code.

        Find the two lines of code as following: 

==================================================================
// connect the data server
mysql_connect("localhost", "root","root");
// choose the database, if the name of your database is different, please 
// change it to your database name.
mysql_select_db("flashchat"); 
==================================================================

        Modify the database server address, database user's name and password, 
        database name in mysql as your configuration respectively.
        PHP interface detail usages, please refer to "PHP interface 
        description".

    4) Configure Flashchat

        After finishing install chat program, log in chat as administrator, and 
        then go to the administrator panel.

        In the Setting panel, choose "remote database" in the red pane in the 
        picture. In "Remoting gateway URL" textfield, fill the absolute url of 
        gateway.php in amfphp_1.2 directory. And then fill the class path of 
        server object in "Remoting class path" textfield, save the setting. 


----------------------------------------------------------------

PHP Interface description

    There is PHP reserved interface. Through this, you can save the chat users' 
    information and chat history into your database on the website. And you 
    also can check the user's identity through the interface.
    Flash Remoting technology which is based on open source library AMFPHP is 
    used for PHP interface. The following is the usage description:

    1) Server Environment

        Php (php4,php5) + mysql
        Remoting gateway interface program: Amfphp 1.2

    2) Server-side program

        Remoting program file exists as class file, and it is placed in 
        "Service" folder of amfphp directory. Class file can be put directly in 
        service directory, or it is can be put in the individual folder in 
        Service directory. 

        When Flash client invoke the method of the program object on the 
        server, the class path must be appointed completely. For example, class 
        file "Helloword" is saved in "service" directory, the path is 
        "Helloworld", if class file "Helloworld" is in the "test" directory of 
        "service" directory, its class path changes to "test.Helloworld".

    3) Server program syntax

        The class files must include by the following 3 methods, the name of 
        method and parameters style must be the same as the following 
        description, or the program can't work properly.

==================================================================
/*
* used for login and identifying
*
* @ param $username: User's name login
* @ param $pass: password, if login as a guest, don't fill in the blank
* @ param $isRegister: whether the user is new, if he/she is, it is true, or it 
* is a blank or false
*/
function doLogin($username,$pass = null,$isRegister = false){
    /*
        Please put your code here to database connection processing 
    */
    return Null/"guest"/"member"/"admin"
}
==================================================================

        doLogin Function must have return value for Red5/FMS to receive, there 
        are four kinds of return value:
        (1) Null: Null, login failed 
        (2) "guest": String, login succeed and login as a guest 
        (3) "member": String, login succeed and login as a register user 
        (4) "admin": String, login succeed and login as an administrator who 
            has the highest purview. 

        Explanation: doLogin function is the most important, if it is wrong 
        then nobody can login. So please check it very carefully before you 
        modify.


==================================================================
/*
* change the password, only for the register users
*
* @ param $username: User's login name
* @ param $oldPass: old pass word
* @ param $newPass: new pass word
*/
function modifyPassword($username,$oldPass,$newPass){
    /*
        Please put your code for checking your old password and setting your 
        new password here
    */
    return true/false;
}
==================================================================

        "modifyPassword" function must have return value and it is true of 
        false which is for showing whether the action is completed. 


==================================================================
/*
* save the chat history
*
* @ param $target: Receiving massage one's name, if the one is in the 
* chatting room then it is the room's name. If it is a private chat, it is the 
* user's name.
* @ param $ip: The user's IP address
* @ param $username: Sending message user's name
* @ param $message: Massage content
*/
function saveChatLog($target,$ip,$username,$message){
    /*
        Please put the code for saving the chat record into the database.
    */
}
==================================================================

        The function doesn't need the return value.

        Explanation: only the administrator enables the function of saving 
        chatting history in the control panel at the background, the function 
        works.



END
