Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/dev/htdocs/custom/crfact/class/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/crfact/class/crfactAPI.class.php
<?php


class crfactAPI {

	public $APIKEY = false;
	public $ROOT = 'https://facapi.dps-lat.com/api.php';

    var $timeDrift = 0;

    public function __construct($_apikey=false, $_root=false) {
		 mb_internal_encoding('UTF-8');
        if ($_apikey) $this->APIKEY = $_apikey;
		if ($_root) $this->ROOT = $_root;

    }


    function call($params, $url=NULL)
    {
        if (is_null($url)){
            $url = $this->ROOT;
        }
        $postdata = http_build_query($params);
        $opts = array('http' =>
            array(
                'method'  => 'POST',
                'header'  => 'Content-Type: application/x-www-form-urlencoded',
                'content' => $postdata
            )
        );
        $context  = stream_context_create($opts);
        $response = file_get_contents($url, false, $context);
    //echo '<pre>';var_dump($response); echo '</pre>';
        return json_decode($response); 
    }
	function callbound($params, $url=NULL, $file)
    {
        if (is_null($url)){
            $url = $this->ROOT;
        }

        define('MULTIPART_BOUNDARY', '--------------------------'.microtime(true));
        $header = 'Content-Type: multipart/form-data; boundary='.MULTIPART_BOUNDARY;
        define('FORM_FIELD', 'fileToUpload'); 
        $file_contents = file_get_contents($file);    
        $content =  "--".MULTIPART_BOUNDARY."\r\n".
                    "Content-Disposition: form-data; name=\"".FORM_FIELD."\"; filename=\"".basename($file)."\"\r\n".
                    "Content-Type: application/x-pkcs12\r\n\r\n".
                    $file_contents."\r\n";
        // add some POST fields to the request too: $_POST['foo'] = 'bar'
        foreach($params as $param => $value){
            $content .= "--".MULTIPART_BOUNDARY."\r\n".
            "Content-Disposition: form-data; name=\"$param\"\r\n\r\n".
            "$value\r\n";
            // signal end of request (note the trailing "--")
            $content .= "--".MULTIPART_BOUNDARY."--\r\n";
        }

        //$postdata = http_build_query($params);
        $opts = array('http' =>
            array(
                'method'  => 'POST',
                'header'  => $header,
                'content' => $content
            )
        );
        $context  = stream_context_create($opts);

        $response = file_get_contents($url, false, $context);
        return json_decode($response); 
    }
}

?>

Hry