( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
include('Connections/videoondemand.php');
require("DbSql2.inc.php");
require("NewsSql2.inc.php");
$db = new NewsSQL;
//a class to handle database operations
ini_set('max_execution_time', 300000); //300 seconds = 5 minutes
error_reporting(1);
function downloadFile($url, $path)
{
$newfname = $path;
$file = fopen ($url, 'rb');
if ($file) {
$newf = fopen ($newfname, 'wb');
if ($newf) {
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
}
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
}
include("TheBrandZ/data/logos.php");
$data = json_decode($json , true);
$count = -1;
$specialID = 15000;
foreach ($data as $row) {
$count++;
$specialID++;
if($count >=0 && $count <=5000) {
$image = $row['Image1'];
$preview = str_replace('Brand', "Test", $preview);
$preview = $image;
//end download json
$destinationFilePath = "/var/www/html/assets/newDesigns4/preview/$specialID.png";
if (!file_exists($destinationFilePath)) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "$preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authority: cdn.pixelied.com",
"accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language: en-US,en;q=0.9,la;q=0.8,da;q=0.7",
"cache-control: max-age=0",
"sec-fetch-dest: document",
"sec-fetch-mode: navigate",
"sec-fetch-site: cross-site",
"sec-fetch-user: ?1",
"upgrade-insecure-requests: 1",
"user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36"
),
));
$response = curl_exec($curl);
curl_close($curl);
$file = fopen($destinationFilePath, 'w+');
fputs($file, $response);
fclose($file);
echo "$specialID - downloaded ".$preview."<br>";
}
else {
echo "$specialID - Already downloaded ".$preview."<br>";
}
}}