phpBMS

Changeset 525 for trunk/phpbms/include

Show
Ignore:
Timestamp:
05/13/09 20:00:01 (3 years ago)
Author:
brieb
Message:

* Initial implementation of API interface as a new module. It is now possible to talk to phpBMS through a form posting (api_json.php) in json format. This includes querying more than single records (searching) by accesing mySQL stored procedures.

Location:
trunk/phpbms/include
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/include/db.php

    r512 r525  
    120120 
    121121 
     122    /** 
     123     * Establishes a connection to the database 
     124     * 
     125     * Establishes a connection to the database.  If the {@link $pconnect} setting 
     126     * is set, it uses the mysql_pconnect (for persistennt connections). We pass 
     127     * connection flags of 65536 so that calling simple stored procedures will 
     128     * successfully return results 
     129     */ 
    122130    function connect(){ 
    123         // This functions connects to the server. 
    124         // It uses pconnect if the constant is set (via the settings.php file) 
    125131 
    126132        if($this->pconnect) 
    127             $this->db_link = @ mysql_pconnect($this->hostname,$this->dbuser,$this->dbpass); 
     133            $function = "mysql_pconnect"; 
    128134        else 
    129             $this->db_link = @ mysql_connect($this->hostname,$this->dbuser,$this->dbpass); 
     135            $function = "mysql_connect"; 
     136 
     137        $this->db_link = @ $function($this->hostname, $this->dbuser, $this->dbpass, 65536); 
    130138 
    131139        if(!$this->db_link){ 
  • trunk/phpbms/include/session.php

    r517 r525  
    446446 
    447447 
    448         function verifyAPIlogin($user, $pass){ 
     448        function verifyAPIlogin($user, $pass, $format = "json"){ 
    449449 
    450450                $thereturn = false; 
     
    474474                if(!$queryresult) { 
    475475 
    476                         $error = new appError(-720,"","Error retrieving user record",true,true,true,"json"); 
     476                        $error = new appError(-720,"","Error retrieving user record",true,true,true,$format); 
    477477                        return false; 
    478478 
     
    497497 
    498498                        if(!$queryresult) 
    499                                 $error = new appError(-730,"","Error Updating User Login Time",true,true,true,"json"); 
     499                                $error = new appError(-730,"","Error Updating User Login Time",true,true,true,$format); 
    500500                        else 
    501501                                $thereturn = true; 
     
    553553        //Testing for API login 
    554554        if(strpos($scriptname,"api_")!==false){ 
     555 
     556                if(!isset($_POST["phpbmsformat"])) 
     557                    $_POST["phpbmsformat"] = "json"; 
     558 
    555559                if(isset($_POST["phpbmsusername"]) && isset($_POST["phpbmspassword"])){ 
    556560 
     
    569573 
    570574 
    571                         if(!$phpbmsSession->verifyAPILogin($_POST["phpbmsusername"],$_POST["phpbmspassword"])) 
     575                        if(!$phpbmsSession->verifyAPILogin($_POST["phpbmsusername"],$_POST["phpbmspassword"], $_POST["phpbmsformat"])) 
    572576                                $error = new appError(-700,"","Login credentials incorrect",true,true,true,"json"); 
    573577 
    574578                } else 
    575                         $error= new appError(-710,"","No login credentials passed",true,true,true,"json"); 
     579                    $error= new appError(-710, "", "No login credentials passed", true, true, true, $_POST["phpbmsformat"]); 
    576580 
    577581        } else { 
  • trunk/phpbms/include/tables.php

    r519 r525  
    322322            return $therecord; 
    323323 
    324         }//edn function getDefaults 
     324        }//end function getDefaults 
     325 
    325326 
    326327        // Gets a specific individual record from the table 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.