$blacklabel['blacklabel_whitelabel_url'].'/'.$language.'/api/v1/'.$endpoint.$queryString, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 3, CURLOPT_HEADER => 0, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'X-Application-Secret: '.$blacklabel['blacklabel_apikey'], 'X-Client-Ip: '.$ipAddress.'', 'X-User-Agent: '.$_SERVER['HTTP_USER_AGENT'].'', 'X-Session-Id: '.$_SESSION['X-Session-Id'].'', ), )); $response = curl_exec($curl); //var_dump($response); curl_close($curl); if (!$err && $response) { $response = json_decode($response,true); if($response['errors'][0]['code'] == 401) { echo "401 ERROR - Your API Key is most likely incorrect"; } else { return $response; } } } /** * aweBlacklabelCurlRequestPost - Same as aweBlacklabelCurlRequest but sends POST * * @param [in] Endpoint to use * @param [in] $postData array of post data. * @return array * */ function aweBlacklabelCurlRequestPost($endpoint, $postData = array()) { global $blacklabel; global $basepath; if($blacklabel['blacklabel_language']) { $language = $blacklabel['blacklabel_language']; } else { $language = 'en'; } if(substr($_SESSION['X-Session-Id'],0,1) == 'm' || $forceMember) { $language = "$language/member"; } if($_SESSION['username']) { $thisUser = $_SESSION['username']; } else { $thisUser = "Guest"; } $logToFile = date('Y-m-d H:i:s').": ".$thisUser." - ".$_SESSION['X-Session-Id']." (GET REQUEST | ".$blacklabel['blacklabel_whitelabel_url'].'/'.$language.'/api/v1/'.$endpoint." | $queryString)\n"; file_put_contents("$basepath/cache/awelog.txt",$logToFile, FILE_APPEND); if($endpoint == 'users') { //this is to force /en/auth/ on user authentication to fix some issue with banned ips. $language = "$language/auth"; } if(isset($_SERVER["HTTP_CF_CONNECTING_IP"])){ $ipAddress = $_SERVER["HTTP_CF_CONNECTING_IP"]; } else{ $ipAddress = $_SERVER['REMOTE_ADDR']; } //echo $language; $curl = curl_init(); if($endpoint == 'users') { //send without X-Session-Id to circumvent issue with API returning guest status curl_setopt_array($curl, array( CURLOPT_URL => $blacklabel['blacklabel_whitelabel_url'].'/'.$language.'/api/v1/'.$endpoint, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($postData), CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_FOLLOWLOCATION => 0, CURLOPT_TIMEOUT => 3, CURLOPT_HEADER => 1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'X-Application-Secret: '.$blacklabel['blacklabel_apikey'], 'X-Client-Ip: '.$ipAddress.'', 'X-User-Agent: '.$_SERVER['HTTP_USER_AGENT'].'' ), )); } else { curl_setopt_array($curl, array( CURLOPT_URL => $blacklabel['blacklabel_whitelabel_url'].'/'.$language.'/api/v1/'.$endpoint, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($postData), CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_FOLLOWLOCATION => 0, CURLOPT_TIMEOUT => 3, CURLOPT_HEADER => 1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'X-Application-Secret: '.$blacklabel['blacklabel_apikey'], 'X-Client-Ip: '.$ipAddress.'', 'X-User-Agent: '.$_SERVER['HTTP_USER_AGENT'].'', 'X-Session-Id: '.$_SESSION['X-Session-Id'].'', ), )); } $response = curl_exec($curl); $err = curl_error($curl); $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size); $headers = get_headers_from_curl_response($header); if($headers['X-Session-Id']) { $_SESSION['X-Session-Id'] = $headers['X-Session-Id']; } $response = $body; curl_close($curl); if (!$err && $response) { $response = json_decode($response,true); if($response['errors'][0]['code'] == 401) { echo "401 ERROR - Your API Key is most likely incorrect"; } else { return $response; } } } function aweBlacklabelHeaderCallback($ch, $header_line) { global $headers; $headers[] = $header_line; return strlen($header_line); } function get_headers_from_curl_response($response) { $headers = array(); $header_text = substr($response, 0, strpos($response, "\r\n\r\n")); foreach (explode("\r\n", $header_text) as $i => $line) if ($i === 0) $headers['http_code'] = $line; else { list ($key, $value) = explode(': ', $line); $headers[$key] = $value; } return $headers; } /** * fetchLiveVideoList - Fetches live json feed from AWEmpire Videos API * * @param [in] $limit Max Number Of Results * @param [in] $category Category as per AWEmpire Documentation * @param [in] $tags Tags as per AWEmpire Documentation * @param [in] $cobrandId CobrandId as per AWEmpire Documentation * @param [in] $site Siteid as per AWEmpire Documentation * @return Return description * */ function fetchLiveVideoList($limit = 10, $category = 'girls', $tags = "", $cobrandId = "", $site = "") { global $AWEmpirePSID; global $AWEmpireAccessKey; global $AWEmpirePrimaryColor; global $AWEmpireLabelColor; global $AWEmpirecobrandID; //set defaults if(isset($_SERVER["HTTP_CF_CONNECTING_IP"])){ $ipAddress = $_SERVER["HTTP_CF_CONNECTING_IP"]; } else{ $ipAddress = $_SERVER['REMOTE_ADDR']; } $data = file_get_contents("https://pt.ptawe.com/api/video-promotion/v1/list?category=girl&clientIp=".$ipAddress."&limit=".$limit."&pageIndex=1&psid=".$AWEmpirePSID."&accessKey=".$AWEmpireAccessKey."&cobrandId=".$AWEmpirecobrandID."primaryColor=".$AWEmpirePrimaryColor."&labelColor=".$AWEmpireLabelColor."&cobrandId=".$cobrandId."&site=".$site."&tags=".$tags."&mitigable=true"); $json = json_decode($data,true); if(!is_array($json)) { echo "An error has occured while fetching the feed. ".$data; return false; } else { $counter = 0; foreach($json['data']['videos'] as $i) { $result[$counter]['id'] = $i['id']; $result[$counter]['title'] = $i['title']; $result[$counter]['length'] = $i['duration']; $result[$counter]['keywords'] = implode(",",$i['tags']); $result[$counter]['thumbnail'] = $i['thumbImage']; $result[$counter]['submitter'] = $i['uploader']; $result[$counter]['rating'] = rand(75,100); $result[$counter]['views'] = rand(100,10000); if($i['quality'] == 'sd') { //fake the movie height for hd tags on templates, which are typically based on if statement using $rrow[movie_height] $result[$counter]['movie_height'] = '480'; } else { $result[$counter]['movie_height'] = '720'; } $counter++; } return $result; } } /** * showAweVideos - Displays the data from fetchLiveVideoList in template * * @param [in] $template Template file being used * @param [in] $limit Max number of results, passed to fetchLiveVideoList * @param [in] $tags Tags, passed to fetchLiveVideoList * @param [in] $category Category, passed to fetchLiveVideoList * @param [in] $cobrandId Cobrandid, passed to fetchLiveVideoList * @param [in] $site Siteid, passed to fetchLiveVideoList * @return Return description * */ function showAweVideos($template = 'template.content_item.php', $limit = 10, $tags = "", $category = 'girls', $cobrandId = "", $site = "") { global $basehttp; global $basepath; global $gallery_url; global $template_path; global $thumb_url; global $thumbwidth; global $thumbheight; global $picthumbwidth; global $picthumbheight; global $bad; global $good; global $results_per_row; global $template_url; global $currentLang; global $dblink; global $config; $farray = fetchLiveVideoList($limit, $category, $tags, $cobrandId, $site); //fetch data; if (is_array($farray)) { $i = 0; $j = 0; $maxRes = count($farray); foreach ($farray as $row) { if ($results_per_row > 0) { $i++; $rest = $i % $results_per_row; if ($rest == 0) { $class = ' last'; } else { $class = ''; } } if ($slider) { if ($j % $slider_per_page == 0) { echo '
'; } } include($template_path . '/' . $template); if ($slider) { if (($j + 1) % $slider_per_page == 0 || $j == ($maxRes - 1)) { echo '
'; } } ++$j; } } } /** * getAweDetails - Gets details of a single AWEmpire Video * * @param [in] $id id number of video * @return Return description * */ function getAweDetails($id) { global $AWEmpirePSID; global $AWEmpireAccessKey; global $AWEmpirePrimaryColor; global $AWEmpireLabelColor; global $AWEmpirecobrandID; if(isset($_SERVER["HTTP_CF_CONNECTING_IP"])){ $ipAddress = $_SERVER["HTTP_CF_CONNECTING_IP"]; } else{ $ipAddress = $_SERVER['REMOTE_ADDR']; } $data = file_get_contents("https://pt.ptawe.com/api/video-promotion/v1/details/".$id."?clientIp=".$ipAddress."&cobrandId=".$AWEmpirecobrandID."&psid=".$AWEmpirePSID."&accessKey=".$AWEmpireAccessKey.""); $json = json_decode($data,true); $i = $json['data']; $result['id'] = $i['id']; $result['title'] = $i['title']; $result['length'] = $i['duration']; $result['keywords'] = implode(",",$i['tags']); $result['thumbnail'] = $i['thumbImage']; $result['submitter'] = $i['uploader']; $result['rating'] = rand(75,100); $result['views'] = rand(100,10000); $result['embed'] = "
"; if($i['quality'] == 'sd') { //fake the movie height for hd tags on templates, which are typically based on if statement using $rrow[movie_height] $result['movie_height'] = '480'; } else { $result['movie_height'] = '720'; } return $result; }