'10.10.33.21', 'username' => 'savvy', 'password' => 'savvy001!', 'database' => 'savvy', 'DBDriver' => 'Postgre', 'DBPrefix' => '', */ class savvyext_api_savvy { var $system = [ "storage_url" => "https://resources.sworks.float.sg/" ]; var $database = [ "host" => "10.10.33.21", "name" => "savvy", "user" => "savvy", "pass" => "savvy001!", "port" => "5432" ]; var $gpsdatabase = [ "host" => "10.10.33.21", "name" => "savvy_gps", "user" => "savvy", "pass" => "savvy001!", "port" => "5432" ]; var $database_replica = [ "host" => "10.10.33.21", "name" => "savvy", "user" => "savvy", "pass" => "savvy001!", "port" => "5432" ]; var $google = [ "api_key" => "AIzaSyBMNecOHz0OHbJti5P9foh_PVPYZntr18I", "api_key_old" => "AIzaSyDvjiRTxngOQyBP4zpqFlZuiquc0ROvo9c", "drive_client_id" => "343605975098-frdrsttkgkih8dm19js6itgs6ps261ea.apps.googleusercontent.com", "drive_client_secret" => "XbUr5SW9Y1CaEjO_3fvglRna", "drive_card_images" => "1NjftJBnFj9zTqWX7GLDhvlh28JOMeqv3", "storage_project_id" => "float-app-224118", "storage_auth_file" => "/home/savvy/savvy/savvyext/etc/float-app-224118-52ef1783d2c5.json", "kms_project_id" => "float-app-224118", "kms_auth_file" => "/home/savvy/savvy/savvyext/etc/float-app-224118-52ef1783d2c5.json", "kms_keyring_id" => "development", "kms_key_id" => "oauth2_tokens" ]; var $savvyext = [ "url" => "localhost:8000/api/v1/admin/login", "key" => "ZmxvYXQ6RmwwYXQh", "token" => "01bef20e2ab1ac21cd6469dd9fbf533b", ]; var $savvyext_admin = [ "url" => "localhost:8000/api/v1/admin", "key" => "ZmxvYXQ6RmwwYXQh", "token" => "01bef20e2ab1ac21cd6469dd9fbf533b", ]; public function cfgReadChar($varname) { $pieces = explode(".", $varname); if ($pieces[0] == 'database') { return $this->database[$pieces[1]]; } if ($pieces[0] == 'gpsdatabase') { return $this->gpsdatabase[$pieces[1]]; } if ($pieces[0] == 'database_replica') { return $this->database_replica[$pieces[1]]; } if (is_array($this->{$pieces[0]})) { return $this->{$pieces[0]}[$pieces[1]]; } else { return []; } } public function cfgReadLong($varname) { return $this->cfgReadChar($varname); } public function savvyext_api($in) { //return []; $postdata = json_encode($in); $url = $this->cfgReadChar('savvyext.url'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'content-type: application/json', 'content-length: ' . strlen($postdata), 'server-token: ' . $this->cfgReadChar('savvyext.token') ]); curl_setopt($ch, CURLOPT_HEADER, false); // Do not show the response headers curl_setopt($ch, CURLOPT_USERPWD, base64_decode($this->cfgReadChar('savvyext.key'))); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $res = curl_exec($ch); //echo "DEBUG: ".$res."=====\n"; curl_close($ch); return json_decode($res, true); } public function savvyext_admin($endpoint, $in) { //return []; $postdata = json_encode($in); $url = $this->cfgReadChar('savvyext_admin.url').$endpoint; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'content-type: application/json', 'content-length: ' . strlen($postdata), 'server-token: ' . $this->cfgReadChar('savvyext.token') ]); curl_setopt($ch, CURLOPT_HEADER, false); // Do not show the response headers curl_setopt($ch, CURLOPT_USERPWD, base64_decode($this->cfgReadChar('savvyext.key'))); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $res = curl_exec($ch); //echo "DEBUG: ".$res."=====\n"; curl_close($ch); return json_decode($res, true); } } if (!array_key_exists('savvyext', $GLOBALS)) { $savvyext = new savvyext_api_savvy(); }