<?php
header("Pragma: no-cache");
define('CHEMIN', '../');
include CHEMIN.'inc/includes.inc';
include CHEMIN.'admin/hpage.inc';
$fctwri = NULL;
$lng      = import('lng', 'GET');
if ($lng == '') $lng = $lang[0];

include CHEMIN.'inc/lang/'.$lng.'-admin.inc';
$qtitle= 'CORRECTION Des datas contenant iframe avec sandbox</strong>';
htable($qtitle, '100%');
echo '
<center>
<p><strong>CORRECTION Des datas contenant iframe avec sandbox</strong></p>
<div style="margin-top:40px;padding-top:20px;width:600px;background-color:#eee;">';
$motcherch = array('allow-presentation', 'allow-top-navigation', 'allow-scripts', 'allow-downloads', 'allow-popups');
$nobretot = count($motcherch);
$ok = "non";
if(isset($_POST['submit']))
	{
		echo "<p><strong>Correction en cours</strong><br /><br />";
		$n = 0; 
		$x = 0;
		$dbw    = SelectDBFieldsByNotStatus(ReadDBFields(DOCID),'d');
		for ($i = 0; $i < count($dbw); $i++) 
		{
			ReadDoc($dbw[$i][1]);
			$id = $dbw[$i][1];
			$x++;
			$modif = 0;
			if (str_contains($fieldc1, '<iframe') && str_contains($fieldc1, 'sandbox=')) {
				$contenu = stripslashes($fieldc1);
				for ($j =0; $j< $nobretot; $j++)
				{
					if (str_contains($contenu, $motcherch[$j])) {
						$contenu = str_replace(' allow-', 'allow-', $contenu);
						$contenu = str_replace($motcherch[$j], "", $contenu);
					}
				}
					$contenu = stripslashes($contenu);
					$contenu = str_replace('sandbox=""', '', $contenu);
					$fieldc1 = $contenu;
					$modif = 1;	
			}	
			if (str_contains($fieldc2, '<iframe') && str_contains($fieldc2, 'sandbox=')) {
				for ($j =0; $j< $nobretot; $j++)
				{
					if (str_contains($contenu, $motcherch[$j])) {
						$contenu = str_replace(' allow-', 'allow-', $contenu);
						$contenu = str_replace($motcherch[$j], "", $contenu);
					}
				}
					$contenu = stripslashes($contenu);
					$contenu = str_replace('sandbox=""', '', $contenu);
					$fieldc2 = $contenu;
					$modif = 2;
	
			}						
		    if ($modif != 0)
			{
				    $data[0] = $type;
					$data[1] = $id;
					$data[2] = $status;
					$data[3] = $creadate;
					$data[4] = $moddate;
					$data[5] = $author;
					$data[6] = $email;
					$data[7] = $fielda1;
					$data[8]  = $fielda2;
					$data[9]  = $fieldb1;
					$data[10] = $fieldb2;
					$data[11] = $fieldc1;
					$data[12] = $fieldc2;
					$data[13] = $fieldd1;
					$data[14] = $fieldd2;
					$data[15] = $fieldweb;
					$data[16] = $fieldmail;
					$data[17] = $fieldmod; 
					ActionOnFields('mod', $data);
					echo 'Nom doc: '.$id.' rectifié <br />';
					$n++;
			}

		}
		$ok = "oui";
		echo "<br /><br />----------<br /><strong>".$x." fichiers vérifiés, ".$n." fichiers rectifiés</strong><br />----------<br /></p>\n";       
	}

if ($ok == "non") {
    echo '
<strong><u>ATTENTION</strong></u><br /><br />
<p style="color:red"><strong>Il s\'agit d\'une correction des données !!!</strong></p><br /><br />
Ce script permet <u>seulement</u> de mettre en conformité la balise iframe avec sandbox5<br /><br />
Il ne fait <u>que</u> supprimer sandbox avec les attributs<br /><br />'."\n";

    echo '
<p align="center"><br />Corriger vos datas maintenant?<br />
<form name="migrer" action="correctiondata.php" method="POST">
<input type="submit" name="submit" value="Oui" />
<input type="reset" name="reset" value="Non" />
</form>'."\n";
}
echo '
<p align="center"><a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'">'.$admin[22].'</a> || <b><a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&logout=1">'.$admin[19].'</a></b></p>';
btable();

include CHEMIN.'admin/bpage.inc';
?>