<?
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

session_start();
include('config.php');
include($php_root.'/general.php');
ini_set('max_execution_time', '300');
// use Google\Client;

$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, 'https://endpoints.lidl-flyer.com/v1/overview/ro-RO.jsonp?_=1654777393249');
curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($curlSession);
curl_close($curlSession);

$temp = explode('flyerUrlAbsolute":"', $html);
$temp2 = explode('"', $temp[1]);
$data_array['catalog_url'] = $temp2[0];

$temp = explode('offerStartDate":"', $html);
$temp2 = explode('"', $temp[1]);
$date_start = $temp2[0];
$temp = explode('offerEndDate":"', $html);
$temp2 = explode('"', $temp[1]);
$date_end = $temp2[0];

$data_array['catalog_name'] = 'Catalog Lidl '.$date_start.' ~ '.$date_end;

print_array($data_array);


// $files = glob('uploads/pdf/image/*');
// foreach($files as $file)
// {
//   if (is_file($file)) unlink($file);
// }
//
//
// for ($i=0; $i<100; $i++)
// {
//   $imagick = new Imagick();
//   $imagick->readImage('uploads/pdf/Revista-disponibila-in-perioada-06-06-12-06-2022-03.pdf['.$i.']');
//   $imagick->writeImages('uploads/pdf/image/'.$i.'.jpg', true);
// }

// $client = new Client();
//
// // service_account_file.json is the private key that you created for your service account.
// $client->setAuthConfig('pizzaonline-534b0aff81f4.json');
// $client->addScope('https://www.googleapis.com/auth/indexing');
//
// // Get a Guzzle HTTP Client
// $httpClient = $client->authorize();
// $endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
//
// // Define contents here. The structure of the content is described in the next step.
//
// $place_array = get_place(array('hours'), '', 'ORDER BY id ASC', 'LIMIT 900,100', false, false);
//
// foreach ($place_array as $place)
// {
//   $content = '{
//     "url": "'.$place['url'].'",
//     "type": "URL_UPDATED"
//   }';
//
//   $response = $httpClient->post($endpoint, ['body' => $content]);
//   $status_code = $response->getStatusCode();
//
// 	echo '<b>'.$status_code.'</b> - '.$place['url'].'<br />';
// }
//


?>
