( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/googletemplatetoFile3Repair.php
<?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("assets/newtemplates2.php");
$data = json_decode($json , true);




$fixTheme = $_GET['affiliate'];
$original = $_GET['original'];


$count = -1;
   $specialID = $fixTheme -15000-1;


  $row = $data[0]["templates"][$specialID];


if(empty($fixTheme) ||  empty($row))
{
    exit("no id sorry");

}





     $id = $row['_id'];

         $template_name = $row['template_name'];
/*    echo $is_pro = $row['is_pro'];
    echo $is_published = $row['is_published'];
    echo $tags = $row['tags'];
    echo $template_name = $row['template_name'];
    echo $template_desc = $row['template_desc'];

    echo $format_category = $row['format_category'];
    echo $canvas_doc_json = $row['canvas_doc_json'];
    echo $type = $row['type'];
    echo $created_at = $row['created_at'];
    echo $updated_at = $row['updated_at'];
    echo $thumbnail_url = $row['thumbnail_url'];
    echo $thumbnail_width = $row['thumbnail_width'];
    echo $thumbnail_height = $row['thumbnail_height'];
    echo $thumbnail_size = $row['thumbnail_size'];
    */

     $preview = $row['thumbnail_url'];
     $preview = explode('?', $preview)[0];

    //download image

    $file_name = basename($preview);
    $file_name = explode('?', $file_name)[0];






        //process template
         //
           $jsonX =  $row['_id'];

//    $destinationFilePath = "/var/www/html/assets/newDesigns2/preview/$file_name";
//    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>";
//    }
           $urle = "https://www.thebrand.ai/assets/newDesigns2/$jsonX.json";


         $jsonData = file_get_contents($urle);









          $poster = basename($preview);
           $title =  urlencode( $row['template_name']." design template");
         $preview =  urlencode($preview);
         $slug = strtolower($title);
         $slug = preg_replace('/[^A-Za-z0-9-]+/', '-', $slug);
          $slug =  urlencode($slug);
           $poster =  urlencode($poster);


           $doc_width =  urlencode( $row['canvas_doc_json']['doc_width']);
          $doc_height =  urlencode( $row['canvas_doc_json']['doc_height']);


        $main_category =  urlencode( $row['type']['parent_type']);
       $sub_category =  urlencode( $row['type']['group']) ;
        $platform =  urlencode( $row['type']['platform']);
        $format_category =  urlencode( $row['format_category']);
         $tags =  json_encode($row['tags']);
         $tags =str_replace('"',"",$tags);
         $tags =str_replace('&',"",$tags);
         $tags =str_replace('  '," ",$tags);
         $tags =str_replace('[',"",$tags);
         $tags =str_replace(']',"",$tags);
         $tags =  urlencode($tags);

           $url = "https://www.thebrand.ai/TheBrandZ/mode.php?mode=updateTemplatesV2&slug=$slug&title=$title&poster=$poster&specialID=$fixTheme&check=$file_name&doc_width=$doc_width&doc_height=$doc_height&main_category=$main_category&sub_category=$sub_category&platform=$platform&format_category=$format_category&tags=$tags&original=$original";



         $ch = curl_init();

         curl_setopt($ch, CURLOPT_URL,"$url");
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS,
             "$jsonData");


         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

         $server_output = curl_exec($ch);
         $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         curl_close ($ch);

         if($httpcode>=200 && $httpcode<300)
         {
             echo $server_output;
            // header("Location: $server_output");
            
         }
         else
         {
             echo "fail";

         }


         //uncomment when done. it creates the tiempliets


     /*   */