????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.147.44.46 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.astacus.se/fixface/ |
Upload File : |
<?php /* * Official PHP client for the PixLab Machine Vision APIs - https://pixlab.io. * Copyright (C) 2017 - 2020 PixLab | Symisc Systems, SUARL https://pixlab.io. * License: BSD-2 Clause */ class Pixlab { private $key = null; /* The PixLab Key */ public $status = 200; /* HTTP status code */ public $json = null; /* Decoded JSON response from the Pixlab API server */ public $raw_json = null; /* Raw JSON response */ public $blob = null; /* Raw (Binary image content) response from the Pixlab API server */ public $mime = ''; /* PixLab API Server MIME type response */ public $error = ''; /* Error message if $status != 200 */ public $scheme = 'http://'; /* Default to HTTPS but if you are calling from a trusted network consider using clear http:// for performance reason */ public function __construct($key) { $this->key = $key; } public function get_status(){ return $this->status; } public function get_blob(){ return $this->blob; } public function switch_to_http(){ $this->scheme = 'http://'; } public function get_decoded_json(){ return $this->json; } public function get_raw_json(){ return $this->raw_json; } public function get_mime(){ return $this->mime; } public function get_error_message(){ return $this->error; } public function get($cmd,$param = []) { if(!$this->key || strlen($this->key) < 15 ){ $this->status = 401; /* Unauthorized */ $this->error = 'Missing/Invalid PixLab API Key'; return false; } $cmd = basename(trim($cmd," \t/")); /* Build the query first */ $param['key'] = $this->key; $request = $this->scheme."api.pixlab.io/$cmd?".http_build_query($param); /* Make the request now */ $curl = curl_init($request); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($curl); if ($res === false) { $this->status = curl_getinfo($curl, CURLINFO_HTTP_CODE); $this->error = curl_error($curl); curl_close($curl); return false; } /* Get the response mime type */ $this->mime = trim(curl_getinfo($curl, CURLINFO_CONTENT_TYPE)); /* Close that connection */ curl_close($curl); if( $this->mime == 'application/json'){ $this->raw_json = $res; $this->json = json_decode($res); $this->status = $this->json->status; if( $this->status != 200){ $this->error = $this->json->error; return false; } }else{ /* Successful blob response since error are returned in JSON format */ $this->blob = $res; } /* All done */ return true; } public function post($cmd,$param = [],$file_upload = false) { if(!$this->key || strlen($this->key) < 15 ){ $this->status = 401; /* Unauthorized */ $this->error = 'Missing/Invalid PixLab API Key'; return false; } $cmd = basename(trim($cmd," \t/")); $curl = curl_init($this->scheme."api.pixlab.io/$cmd?"); curl_setopt($curl, CURLOPT_POST, true); /* Build the query first */ $param['key'] = $this->key; if( !$file_upload ){ /* Default to JSON form */ $request = json_encode($param); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); }else{ $file_upload = realpath($file_upload); if(!is_readable($file_upload) ){ $this->status = 404; /* Not found */ $this->error = "Target file '$file_upload' not found or is unreadable"; return false; } $cFile = curl_file_create($file_upload); /* Standard multi-part/form-data upload */ $param['file'] = $cFile; $request = $param; } /* Make the request now */ curl_setopt($curl, CURLOPT_POSTFIELDS, $request); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($curl); if ($res === false) { $this->status = curl_getinfo($curl, CURLINFO_HTTP_CODE); $this->error = curl_error($curl); curl_close($curl); return false; } /* Get the response mime type */ $this->mime = trim(curl_getinfo($curl, CURLINFO_CONTENT_TYPE)); /* Close that connection */ curl_close($curl); if( $this->mime == 'application/json'){ $this->raw_json = $res; $this->json = json_decode($res); $this->status = $this->json->status; if( $this->status != 200){ $this->error = $this->json->error; return false; } }else{ /* Successful blob response since error are returned in JSON format */ $this->blob = $res; } /* All done */ return true; } } ?>