phpBMS

Changeset 750

Show
Ignore:
Timestamp:
01/13/10 14:15:06 (2 years ago)
Author:
nate
Message:
  • Implemented specific (existing) api specific commands in the apiwrapper.
  • Tweaked said api commands to report consistent information.
  • Note: Overall wrapper still untested.
Location:
trunk/phpbms/modules
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/api/apiwrapper.php

    r748 r750  
    4848     *  
    4949     * @param string $hostname The hostname of the target script 
    50      * @param string $urlPath The path from the host to the target script (usually something like 'modules/api/api_json.php'). 
     50     * @param string $urlPath The location of the target script in relation to $hostname (usually something like 'modules/api/api_json.php'). 
    5151     * @param string $username The username of an user with portal access 
    5252     * @param string $password The password of the same user with portal access 
     
    197197        else 
    198198            return false; 
     199         
     200    }//end function 
     201     
     202     
     203    /* 
     204     * function searchClientByEmail 
     205     * @param string $email The email to be searched for 
     206     * @param array $options An associative array of options. Possible options are : 'useUuid' 
     207     * 
     208     * @return array An associative array response for the get 
     209     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
     210     * @returnf string message The detailed message describing the result 
     211     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     212     */ 
     213     
     214    public function searchClientByEmail($email, $options = NULL) { 
     215         
     216        $method = "api_searchByEmail"; 
     217        $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 
     218        $data["email"] = (string)$email; 
     219         
     220        $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 
     221         
     222        if($response !== false) 
     223            return $response[0]; 
     224        else 
     225            return false; 
     226         
     227    }//end function 
     228     
     229    /* 
     230     * function searchClientByNameAndPostalcode 
     231     * @param $firstname 
     232     * @param $lastname 
     233     * @param $postalcode 
     234     * @param array $options An associative array of options. Possible options are : 'useUuid' 
     235     * 
     236     * @return array An associative array response for the get 
     237     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
     238     * @returnf string message The detailed message describing the result 
     239     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     240     */ 
     241     
     242    public function searchClientByNameAndPostalcode($firstname, $lastname, $postalcode, $options = NULL) { 
     243         
     244        $method = "api_searchByNameAndPostalcode"; 
     245        $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 
     246        $data["firstname"] = (string)$firstname; 
     247        $data["lastname"] = (string)$lastname; 
     248        $data["postalcode"] = (string)$postalcode; 
     249         
     250        $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 
     251         
     252        if($response !== false) 
     253            return $response[0]; 
     254        else 
     255            return false; 
     256         
     257    }//end function 
     258     
     259     
     260    /* 
     261     * function searchClientByUsernameAndPassword 
     262     * @param $username 
     263     * @param $password 
     264     * @param array $options An associative array of options. Possible options are : 'useUuid' 
     265     * 
     266     * @return array An associative array response for the get 
     267     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
     268     * @returnf string message The detailed message describing the result 
     269     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     270     */ 
     271     
     272    public function searchClientByUsernameAndPassword($username, $password, $options = NULL) { 
     273         
     274        $method = "api_searchByUsernameAndPassword"; 
     275        $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 
     276        $data["username"] = (string)$username; 
     277        $data["password"] = (string)$password; 
     278         
     279        $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 
     280         
     281        if($response !== false) 
     282            return $response[0]; 
     283        else 
     284            return false; 
     285         
     286    }//end function 
     287     
     288     
     289    /* 
     290     * function searchSalesOrdersByClientUuid 
     291     * @param $clientuuid 
     292     * @param $ordertype 
     293     * @param $startdate 
     294     * @param $enddate 
     295     * @param array $options An associative array of options. Possible options are : 'useUuid' 
     296     * 
     297     * @return array An associative array response for the get 
     298     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
     299     * @returnf string message The detailed message describing the result 
     300     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     301     */ 
     302     
     303    function searchSalesOrdersByClientUuid($clientuuid, $ordertype = NULL, $startdate = NULL, $enddate = NULL, $options = NULL) { 
     304         
     305        $method = "api_searchByClientUuid"; 
     306        $tabledefuuid = "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883"; 
     307        $data["clientid"] = $clientuuid; 
     308        if($ordertype !== NULL) 
     309            $data["type"] = $ordertype; 
     310        if($startdate !== NULL) 
     311            $data["startdate"] = $startdate; 
     312        if($enddate !== NULL) 
     313            $data["enddate"] = $enddate; 
     314             
     315        $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 
     316         
     317        if($response !== false) 
     318            return $response[0]; 
     319        else 
     320            return false; 
     321         
     322    }//end function 
     323     
     324     
     325    /* 
     326     * function getFile 
     327     * @param string $url The full url to the api_servfile.php url. This can be retrieved from the getRecords method on a `files` table get (the 'apifileurl' key in the record). 
     328     * 
     329     * @return mixed The file if successful, false, if not. 
     330     */ 
     331     
     332    public function getFile($url) { 
     333         
     334        $urlInfo = parse_url($url); 
     335         
     336        $oldHost = $this->apiHostname; 
     337        $oldPort = $this->port; 
     338        $oldUrl = $this->apiUrl; 
     339         
     340        $this->apiHostname = $urlInfo["host"]; 
     341        if($port === 0 || (int)$port > 0) 
     342            $this->port = $urlInfo["port"]; 
     343        else 
     344            $this->port = NULL; 
     345        $this->apiUrl = $urlInfo["path"]."?".$urlInfo["query"]; 
     346         
     347        $response = $this->_callServer(array()); 
     348         
     349        $this->apiUrl = $oldUrl; 
     350        $this->apiHostname = $oldHost; 
     351        $this->port = $oldPort; 
     352         
     353        if($response !== false) 
     354            return $response; 
     355        else{ 
     356            $this->errorMessage = ""; 
     357            return false; 
     358        }//end if 
    199359         
    200360    }//end function 
     
    318478     *  
    319479     * @param array $params 
     480     * @param bool $decode 
    320481     *  
    321482     * @return array False if major (i.e. connection) error has occurred.  Otherwise, returns an array of associative arrays. 
    322483     */ 
    323484     
    324     private function _callServer($params) { 
     485    private function _callServer($params, $decode = false) { 
    325486         
    326487        $params["phpbmsusername"] = $this->username; 
     
    382543        if(ini_get("magic_quotes_runtime")) $response = stripslashes($response); 
    383544         
    384         $decode = $this->_decode($response); 
    385          
    386         if($response && $decode === false) { 
    387             $this->errorMessage = "Bad Response. Got This:".$response; 
    388             return false; 
    389         } else { 
    390                 $response = $decode; 
    391         } 
     545        if($decode){ 
     546            $decodedResponse = $this->_decode($response); 
     547                 
     548            if($response && $decodedResponse === false) { 
     549                $this->errorMessage = "Bad Response. Got This:".$response; 
     550                return false; 
     551            } else { 
     552                $response = $decodedResponse; 
     553            } 
     554        }//end if 
    392555         
    393556         
  • trunk/phpbms/modules/bms/include/clients.php

    r713 r750  
    441441                 * false, the id. 
    442442                 * @return array An array containing response information 
    443                  * @returnf string 'type' The type of response (e.g. 'error' or 'result') 
    444                  * @returnf string 'message' Message explaining the type / result 
    445                  * @returnf array details Either the array of uuid / ids if no errors 
    446                  * were encountered, or the original $requestData if there was an error 
     443                 * @returnf string type The type of response (e.g. 'error' or 'result') 
     444                 * @returnf string message Message explaining the type / result 
     445                 * @returnf array extras Either the array of uuid / ids if no errors 
     446                 * were encountered, or the empty if there was an error 
    447447                 */ 
    448448 
     
    455455                                $response["type"] = "error"; 
    456456                                $response["message"] = "Data does not contain a key of 'email'"; 
    457                                 $response["details"] = $requestData; 
    458457                                return $response; 
    459458                        }//end if 
     
    479478                        $thereturn["type"] = "result"; 
    480479                        $thereturn["message"] = "The function api_searchByEmail has been run successfully."; 
    481                         $thereturn["details"] = array(); 
     480                        $thereturn["extras"] = array(); 
    482481                        while($therecord = $this->db->fetchArray($queryresult)){ 
    483482 
    484483                                if($returnUuid) 
    485                                         $thereturn["details"][] = $therecord["uuid"]; 
     484                                        $thereturn["extras"][] = $therecord["uuid"]; 
    486485                                else 
    487                                         $thereturn["details"][] = $therecord["id"]; 
     486                                        $thereturn["extras"][] = $therecord["id"]; 
    488487 
    489488                        }//end while 
     
    500499                 * false, the id. 
    501500                 * @return array An array containing response information 
    502                  * @returnf string 'type' The type of response (e.g. 'error' or 'result') 
    503                  * @returnf string 'message' Message explaining the type / result 
    504                  * @returnf array details Either the array of uuid / ids if no errors 
    505                  * were encountered, or the original $requestData if there was an error 
     501                 * @returnf string type The type of response (e.g. 'error' or 'result') 
     502                 * @returnf string message Message explaining the type / result 
     503                 * @returnf array extras Either the array of uuid / ids if no errors 
     504                 * were encountered, or the empty if there was an error 
    506505                 */ 
    507506 
     
    527526 
    528527                                $response["type"] = "error"; 
    529                                 $response["details"] = $requestData; 
    530528                                $response["message"] = ""; 
    531529 
     
    574572                          *  report findings 
    575573                          */ 
    576                         $thereturn["details"] = array(); 
     574                        $thereturn["extras"] = array(); 
    577575                        $thereturn["type"] = "result"; 
    578576                        $thereturn["message"] = "The function api_searchByNameAndPostalcode has been run successfully."; 
     
    580578 
    581579                                if($returnUuid) 
    582                                         $thereturn["details"][] = $therecord["uuid"]; 
     580                                        $thereturn["extras"][] = $therecord["uuid"]; 
    583581                                else 
    584                                         $thereturn["details"][] = $therecord["id"]; 
     582                                        $thereturn["extras"][] = $therecord["id"]; 
    585583 
    586584                        }//end while 
     
    597595                 * false, the id. 
    598596                 * @return array An array containing response information 
    599                  * @returnf string 'type' The type of response (e.g. 'error' or 'result') 
    600                  * @returnf string 'message' Message explaining the type / result 
    601                  * @returnf array details Either the array of uuid / ids if no errors 
    602                  * were encountered, or the original $requestData if there was an error 
     597                 * @returnf string type The type of response (e.g. 'error' or 'result') 
     598                 * @returnf string message Message explaining the type / result 
     599                 * @returnf array extras Either the array of uuid / ids if no errors 
     600                 * were encountered, or the empty if there was an error 
    603601                 */ 
    604602 
     
    623621 
    624622                                $response["type"] = "error"; 
    625                                 $response["details"] = $requestData; 
    626623                                $response["message"] = ""; 
    627624 
     
    665662                          *  report findings 
    666663                          */ 
    667                         $thereturn["details"] = array(); 
     664                        $thereturn["extras"] = array(); 
    668665                        $thereturn["type"] = "result"; 
    669666                        $thereturn["message"] = "The function api_searchByUsernameAndPassword has been run successfully."; 
     
    671668 
    672669                                if($returnUuid) 
    673                                         $thereturn["details"][] = $therecord["uuid"]; 
     670                                        $thereturn["extras"][] = $therecord["uuid"]; 
    674671                                else 
    675                                         $thereturn["details"][] = $threturn["id"]; 
     672                                        $thereturn["extras"][] = $threturn["id"]; 
    676673 
    677674                        }//end while 
  • trunk/phpbms/modules/bms/include/invoices.php

    r734 r750  
    12251225                 * false, the id. 
    12261226                 * @return array An array containing response information 
    1227                  * @returnf string 'type' The type of response (e.g. 'error' or 'result') 
    1228                  * @returnf string 'message' Message explaining the type / result 
    1229                  * @returnf array details Either the array of uuid / ids if no errors 
    1230                  * were encountered, or the original $requestData if there was an error 
     1227                 * @returnf string type The type of response (e.g. 'error' or 'result') 
     1228                 * @returnf string message Message explaining the type / result 
     1229                 * @returnf array extras Either the array of uuid / ids if no errors 
     1230                 * were encountered, or the empty if there was an error 
    12311231                 */ 
    12321232 
     
    12391239                                $response["type"] = "error"; 
    12401240                                $response["message"] = "Data does not contain a key of 'clientid'."; 
    1241                                 $response["details"] = $requestData; 
    12421241 
    12431242                                return $response; 
     
    12711270                          *  report findings 
    12721271                          */ 
    1273                         $thereturn["details"] = array(); 
     1272                        $thereturn["extras"] = array(); 
    12741273                        $thereturn["message"] = "The function api_searchByPartNumber has been run successfully."; 
    12751274                        $thereturn["type"] = "result"; 
     
    12771276 
    12781277                                if($returnUuid) 
    1279                                         $thereturn["details"][] = $therecord["uuid"]; 
     1278                                        $thereturn["extras"][] = $therecord["uuid"]; 
    12801279                                else 
    1281                                         $thereturn["details"][] = $therecord["id"]; 
     1280                                        $thereturn["extras"][] = $therecord["id"]; 
    12821281 
    12831282                        }//end while 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.