ho capito, in teoria basterebbe aggiungere il js ad ogni pagina html che viene salvata.
Ho abbozzato questa modifica al codice dell'editor:
Codice PHP:
<?php
$percorso = 'documents/';
$file_esiste=false;
$editor1="";
//http://eurosalute.altervista.org/test-prove/index_friend.html
$dropincontent='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="http://webskey.altervista.org/jquery.easing.1.3.js"></script>
<script src="http://webskey.altervista.org/dropincontentbox.js"></script>
<script>
var dropinbox1=new dropincontentbox({
source:["#dropbox", "http://eurosalute.altervista.org/test-prove/index_friend.html"],
cssclass:"dropinbox standardshadow",
showduration:55
})
</script>
</head>
<body>';
$end_html='</body></html>';
if(isset($_POST['ok']) and $_POST['file_esiste']==true) {
//<script src="http://webskey.altervista.org/dropincontentbox.js">
$pattern='/<script[^>]*?src=[\'"](.*?)[\'"][^>]*?>/si';
//$contents=file_get_contents($percorso.$_POST['nomefile'].".html");
$contents=$_POST['editor1'];
preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER);
//print_r($matches);
if (count($matches)>0) $byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$_POST['editor1']);
else $byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$dropincontent.$_POST['editor1'].$end_html);
//$byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$dropincontent.$_POST['editor1'].$end_html);
//echo "<script>alert('File Sovrascritto!');</script>";
if ($byte_scritti){
echo '<div id="sponsorAdDiv" align="center" style="z-index:10001;visibility:hidden;position:absolute;width:500px;background-color:#ccffcc;border:#c0c0c0;border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px">
<br><br>
<font size="4">File Sovrascritto ! '.$byte_scritti.' Byte Scritti</font>
<br><br>
<input type="button" value="Close" onclick="closeAd();">
<br><br>
</div>';
}
}
else if(isset($_POST['annulla']) and $_POST['file_esiste']==true) {
//echo "<script>alert('Richiesta Annullata!');</script>";
echo '<div id="sponsorAdDiv" align="center" style="z-index:10001;visibility:hidden;position:absolute;width:500px;background-color:#ccffcc;border:#c0c0c0;border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px">
<br><br>
<font size="4">Richiesta Annullata !</font>
<br><br>
<input type="button" value="Close" onclick="closeAd();">
<br><br>
</div>';
}
else if(isset($_POST['back']) and $_POST['file_esiste']==true) echo "<script>history.go(-2);</script>";
else {
//$file_esiste=false;
if(!empty($_POST['editor1'])) $editor1=$_POST['editor1'];
if(!empty($_POST['editor1']) and isset($_POST['save']) and !empty($_POST['nomefile'])){
if (file_exists($perc
codice completo con correzzioni inerenti al contenuto del file salvato in precedenza, prelevare solo il contenuto del body in modo tale che l'utente non possa modificare o cancellare il codice javascript del dropincontent
codice:
Codice PHP:
<?php
$percorso = 'documents/';
$file_esiste=false;
$editor1="";
//http://eurosalute.altervista.org/test-prove/index_friend.html
$dropincontent='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="http://webskey.altervista.org/jquery.easing.1.3.js"></script>
<script src="http://webskey.altervista.org/dropincontentbox.js"></script>
<script>
var dropinbox1=new dropincontentbox({
source:["#dropbox", "http://eurosalute.altervista.org/test-prove/index_friend.html"],
cssclass:"dropinbox standardshadow",
showduration:55
})
</script>
</head>
<body>';
$end_html='</body>
</html>';
if(isset($_POST['ok']) and $_POST['file_esiste']==true) {
//<script src="http://webskey.altervista.org/dropincontentbox.js">
$pattern='/<script[^>]*?src=[\'"](.*?)[\'"][^>]*?>/si';
//$contents=file_get_contents($percorso.$_POST['nomefile'].".html");
$contents=$_POST['editor1'];
preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER);
//print_r($matches);
if (count($matches)>0) $byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$_POST['editor1']);
else $byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$dropincontent.$_POST['editor1'].$end_html);
//$byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$dropincontent.$_POST['editor1'].$end_html);
//echo "<script>alert('File Sovrascritto!');</script>";
if ($byte_scritti){
echo '<div id="sponsorAdDiv" align="center" style="z-index:10001;visibility:hidden;position:absolute;width:500px;background-color:#ccffcc;border:#c0c0c0;border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px">
<br><br>
<font size="4">File Sovrascritto ! '.$byte_scritti.' Byte Scritti</font>
<br><br>
<input type="button" value="Close" onclick="closeAd();">
<br><br>
</div>';
}
}
else if(isset($_POST['annulla']) and $_POST['file_esiste']==true) {
//echo "<script>alert('Richiesta Annullata!');</script>";
echo '<div id="sponsorAdDiv" align="center" style="z-index:10001;visibility:hidden;position:absolute;width:500px;background-color:#ccffcc;border:#c0c0c0;border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px">
<br><br>
<font size="4">Richiesta Annullata !</font>
<br><br>
<input type="button" value="Close" onclick="closeAd();">
<br><br>
</div>';
}
else if(isset($_POST['back']) and $_POST['file_esiste']==true) echo "<script>history.go(-2);</script>";
else {
//$file_esiste=false;
if(!empty($_POST['editor1'])) $editor1=$_POST['editor1'];
if(!empty($_POST['editor1']) and isset($_POST['save']) and !empty($_POST['nomefile'])){
if (file_exists($percorso.$_POST['nomefile'].'.html')){
$file_esiste=true;
?>
<div id="sponsorAdDiv" align="center" style="z-index:10001;visibility:hidden;position:absolute;width:500px;background-color:#ccffcc;border:#c0c0c0;border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px">
<?
//per verifica:
//echo $percorso.$_POST['nomefile'].$_POST['editor1']."<br>";
?>
<br><br>
<font size="4">File Esistente, Vuoi Sovrascriverlo ?</font>
<br><br>
<input type="hidden" name="file_esiste" value="<?=$file_esiste?>" >
<input type="submit" name="ok" value="Ok" >
<input type="submit" name="annulla" value="Annulla" >
<input type="submit" name="back" value="Back" >
<br><br>
</div>
<?
}else {
$byte_scritti=file_put_contents($percorso.$_POST['nomefile'].'.html',$dropincontent.$_POST['editor1'].$end_html);
//echo "<script>alert('File Salvato!');</script>";
if ($byte_scritti) {
echo '<div id="sponsorAdDiv" align="center" style="z-index:10001;visibility:hidden;position:absolute;width:500px;background-color:#ccffcc;border:#c0c0c0;border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px">
<br><br>
<font size="4">File Salvato ! '.$byte_scritti.' Byte Scritti</font>
<br><br>
<input type="button" value="Close" onclick="closeAd();">
<br><br>
</div>';
}
}
}
}
?>
<?php
if(!is_dir($percorso))
{
exit('La cartella indicata non esiste!');
}
$array_file = glob($percorso."*.html") or die ('Impossible leggere la cartella!');
echo '<textarea style="width:200px; height:50px" readonly>';
foreach ($array_file as $key => $value)
{
$no_ext=substr($value, 0, strrpos($value, '.'));
echo substr($no_ext, strrpos($no_ext, '/')+1, strlen($no_ext))."\n";
}
echo '</textarea>';
?>
NOME FILE: <input type=text name='nomefile' value="<?php if(!empty($_POST['nomefile'])) echo $_POST['nomefile']; ?>">
<input type="submit" name="load" value="load" >
<input type="submit" name="save" value="Save" >
<textarea cols="100" id="editor1" name="editor1" rows="10">
<?php
if (!$file_esiste) {
if(file_exists($percorso.$_POST['nomefile'].'.html')) {
//echo htmlentities(file_get_contents($percorso.$_POST['nomefile'].'.html'), ENT_QUOTES, 'UTF-8');
//prelevo solo il contenuto del body:
$pattern = "#\<body\>(.*?)\</body\>#si";
$contents=file_get_contents($percorso.$_POST['nomefile'].".html");
if (preg_match($pattern,$contents,$matches)){
echo htmlentities($matches[1], ENT_QUOTES, 'UTF-8');
}
}
}else if ($editor1){
echo $editor1;
}
?>
</textarea>
</form>
<script type="text/javascript">
//<![CDATA[
// Replace the <textarea id="editor1"> with an CKEditor instance.
var editor = CK