PATH:
home
/
lab2454c
/
caimegroup.com
/
caime-stock-widget
<?php class Functions { protected $logs_path; protected $api_url; public function __construct() { $this->logs_path = dirname(__FILE__) . "/logs/"; $this->api_url = "https://portude.com/api/"; } /** ** Creates a log file for all lead requests on a daily basis **/ public function debug_log($data) { try { throw new Exception(); } catch(Exception $e) { $trace = $e->getTrace(); } $date = date("Y.m.d"); $file = fopen($this->logs_path."log.$date.txt", "ab"); if($file) { fwrite($file, "\n" . date('Y-m-d H:i:s') . ":\n"); fwrite($file, print_r($trace[0]['file'], TRUE) ." ". "Line: ".print_r($trace[0]['line'], TRUE)." ". "\n"); fwrite($file, print_r($data, TRUE) . "\n"); fclose($file); } } public function send_api_request($command, $params) { $url = $this->api_url.$command; $json_params = json_encode($params); $this->debug_log("Sending API Request to " . $url); $this->debug_log("Params:"); $this->debug_log($params); $this->debug_log("JSON Payload:"); $this->debug_log($json_params); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_params); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Accept: application/json', 'Content-Type: application/json', 'Content-Length: ' . strlen($json_params), ) ); $data = curl_exec($ch); if($data === false) { $this->debug_log("Curl Error: " . curl_error($ch)); $this->debug_log("Curl Info: "); $this->debug_log(curl_getinfo($ch)); } curl_close($ch); $this->debug_log("Response from API:"); $this->debug_log($data); $this->debug_log(json_decode($data)); return json_decode($data); } public function get_projects_tickers($params) { $command = "projects_tickers"; $result = $this->send_api_request($command, $params); return $result; } }
[+]
js
[+]
..
[-] wp-blog-header.php
[edit]
[-] test.html
[edit]
[-] caime-stock-widget.iml
[edit]
[-] ajax-functions.php
[edit]
[-] index.html
[edit]
[-] .gitignore
[edit]
[+]
.idea
[+]
logs
[-] .htaccess
[edit]
[-] widget.html
[edit]
[-] functions.php
[edit]
[-] wp-cron.php
[edit]