/** * makeThumbs - Generates thumbnails for galleries * * @param [in] $dir Full linux path to directory full of jpegs * @return void * */ function makeThumbs($dir) { global $gallery_path; global $basepath; global $picthumbwidth; global $picthumbheight; global $mogrify_path; global $convert_path; global $jpegoptim_path; global $jpegoptim_command; global $basepath; global $ceph_enabled; global $ceph_delete_local; unset($array); $array = scandir($gallery_path.'/'.$dir); foreach($array as $i) { if($i != '.' && $i != '..' && !is_dir($gallery_path.'/'.$dir.'/'.$i) && (stripos($i,'.jpg') || stripos($i,'.jpeg') || stripos($i,'.gif') ||stripos($i,'.png')) ) { if(!file_exists($gallery_path.'/'.$dir.'/thumbs/'.$i)) { $input = $gallery_path.'/'.$dir.'/'.$i; $output = $gallery_path.'/'.$dir.'/thumbs/'.$i; shell_exec("$convert_path -auto-orient -resize ".($picthumbwidth)."x".($picthumbheight)."^ -gravity Center -extent ".$picthumbwidth."x".$picthumbheight." \"$input\" \"$output\""); } shell_exec("$mogrify_path -auto-orient \"$input\""); if($jpegoptim_path) { shell_exec("$jpegoptim_path $jpegoptim_command \"$input\""); } if($jpegoptim_path) { shell_exec("$jpegoptim_path $jpegoptim_command \"$output\""); } if($ceph_enabled) { if(cephUploadObject($input, str_replace("$basepath/media/","",$input))) { if($ceph_delete_local) { if(file_exists($input)) { @unlink($input); } } } if(cephUploadObject($output, str_replace("$basepath/media/","",$output))) { if($ceph_delete_local) { if(file_exists($output)) { @unlink($output); } } } } } } } //NEVER EDIT THIS FILE!// //Why is this file here instead of just patching bits of code? Sometimes we need to change something that effects in a file that is often edited by users - such as inc.seo.php, which would make it difficult for people to update. This is messy, but no other way around it. if($_REQUEST['mode'] == 'my-uploads') { $_REQUEST['mode'] = 'my_uploads'; $_GET['mode'] = 'my_uploads'; } if($_REQUEST['sortby'] == 'longest') { $_REQUEST['sortby'] = 'length'; $_GET['sortby'] = 'length'; } /** * file_crc - Return crc32 value of a file * * @param [in] $file File path * @return crc32 value * */ function file_crc($file) { $file_string = file_get_contents($file); $crc = crc32($file_string); return sprintf("%u", $crc); } /** * _mogrifyImageThumbnail - Runs image through mogrify comand line * * @param [in] $input Input File * @param [in] $thumbwidth Thumbnail Width in pixels * @param [in] $thumbheight Thumbnail height in pixels * @return void * */ function _mogrifyImageThumbnail($input, $thumbwidth, $thumbheight) { global $mogrify_path; $input = escapeshellcmd($input); shell_exec("$mogrify_path -adaptive-resize ".($thumbwidth)."x".($thumbheight)."^ -gravity Center -extent ".$thumbwidth."x".$thumbheight." \"$input\""); } if(stripos($_SERVER['REQUEST_URI'],'includes/ajax.login.php') !== false) { header('HTTP/1.0 403 Forbidden'); exit(); } if(stripos($_SERVER['REQUEST_URI'],'includes/ajax.signup.php') !== false) { header('HTTP/1.0 403 Forbidden'); exit(); } if(isset($_GET['q'])) { $_GET['q'] = htmlspecialchars($_GET['q'], ENT_QUOTES, "UTF-8"); } if(isset($_GET['option'])) { $_GET['option'] = htmlentities($_GET['option']); } //Extract data for blacklabel API if(file_exists($basepath."/admin/modules/awempire_blacklabel/config/blacklabel.json")) { $blacklabel = json_decode(file_get_contents($basepath . '/admin/modules/awempire_blacklabel/config/blacklabel.json'), true); } /** * aweBlacklabelDisplayThumbs - A summary has for this function has not yet been written. * * @param [in] $category Main category. girls or boys * @param [in] $substring Search string for a particular type of model * @param [in] $amount Number of performers to display, default 5 * @return void * */ function aweBlacklabelDisplayThumbs($category = 'girls', $substring = '',$amount = 5) { global $blacklabel; global $headers; global $basepath; global $template_path; global $basehttp; //prepare translation api usage if($blacklabel['blacklabel_use_translation_api']) { $thisUserApiTranslation = 1; } else { $thisUserApiTranslation = 0; } $performers = aweBlacklabelCurlRequest('performers',"?category=".$category."&searchText=".$substring."&pageSize=".$amount."&useApiTranslation=".$thisUserApiTranslation); if(!is_array($performers['data']['performers']) || count($performers['data']['performers']) == 0 ) { echo "No live performers found."; } else { foreach($performers['data']['performers'] as $row) { include("$template_path/awe_blacklabel/template.content_item_aweblacklabel.php"); } } } /** * aweBlacklabelCurlRequest - Wrapper for AWEmpire blacklabel API curl requests * * @param [in] $endpoint Endpoint to use * @param [in] $queryString Querystring to append to endpoint. ex: "?category=girls&searchText=lesbian" * @return array * */ function aweBlacklabelCurlRequest($endpoint, $queryString = '') { global $blacklabel; global $headers; global $basepath; if($blacklabel['blacklabel_language']) { $language = $blacklabel['blacklabel_language']; } else { $language = 'en'; } if(substr($_SESSION['X-Session-Id'],0,1) == 'm') { $language = "$language/member"; } if($_SESSION['username']) { $thisUser = $_SESSION['username']; } else { $thisUser = "Guest"; } 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']; } $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); $debug = false; if($debug) { $tmp = 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'].''); $ep = $blacklabel['blacklabel_whitelabel_url'].'/'.$language.'/api/v1/'.$endpoint.$queryString; print_r($tmp); echo $ep."\n"; } $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $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 '