<?PHP 
/* ******************** FOLDER IMAGES FROM SITE ********************** */
$dataX="pxl.png";
if (file_exists($LMsRootF."/".$LMsRootD."/images/".$dataX)){
}else{
copy("./../".$SYSI."/images/".$dataX , $LMsRootF."/".$LMsRootD."/images/".$dataX);
}

$savefile="./../".$SYSD."/".$filename2."-images_list.json";
$imageList1="[";
$imageList3="{ \n
\"image\": \"images/$dataX\", \n
\"thumb\": \"images/$dataX\", \n
\"folder\": \"images\" \n
} \n
]
";
$handle=fopen($savefile, "w");
fwrite($handle,$imageList1."\n");
fclose($handle);
$oldumask = umask(0);
chmod($savefile, 0644);
umask($oldumask);

$handle=opendir(".".$imagesDirXn);
while ($imgList=readdir ($handle)){
$imageArr[]=$imgList;
}
closedir($handle);
natcasesort ($imageArr);
foreach($imageArr as $imageValue)
if($imageValue != '.' && $imageValue != '..' && $imageValue != 'syslms')
{
$imageValue=trim($imageValue);
$imageValueF=$imagesF."/".$imageValue;
$imageList="{
\"image\": \"".$imagesF."/".$imageValue."\",
\"thumb\": \"".$imagesF."/".$imageValue."\",
\"folder\": \"$imagesF\"
},
";
$handle=fopen($savefile, "a+");
fwrite($handle,$imageList."\n");
fclose($handle);
$oldumask = umask(0);
chmod($savefile, 0644);
umask($oldumask);
}

/* ******************** FOLDER IMAGES ********************** */
$handle=opendir(".".$imagesDir2Xn);
while ($imgList2=readdir ($handle)){
$imageArr2[]=$imgList2;
}
closedir($handle);
natcasesort ($imageArr2);
foreach($imageArr2 as $imageValue2)
if($imageValue2 != '.' && $imageValue2 != '..' 
&& $imageValue2 != 'syslms' 
&& $imageValue2 != 'LMs-plakat.png' 
&& $imageValue2 != 'example'
&& $imageValue2 != 'icons'
&& $imageValue2 != 'LMS'
&& $imageValue2 != 'LMS0015'
&& $imageValue2 != 'slider'
&& $imageValue2 != 'video'
)
{
$imageValue2=trim($imageValue2);
$imageValueF2="images/".$imageValue2;
$imageList2="{
\"image\": \"".$imagesX."/".$imageValue2."\",
\"thumb\": \"".$imagesX."/".$imageValue2."\",
\"folder\": \"$imagesX\"
},
";
$handle=fopen($savefile, "a+");
fwrite($handle,$imageList2."\n");
fclose($handle);
$oldumask = umask(0);
chmod($savefile, 0644);
umask($oldumask);
}

$handle=fopen($savefile, "a+");
fwrite($handle,$imageList3."\n");
fclose($handle);
$oldumask = umask(0);
chmod($savefile, 0644);
umask($oldumask);

/* ******************** FOLDER PDF ********************** */
$savefilePDF="./../tmp/".$filename2."-pdf_list.json";

$handle=opendir($pdfDirX);
if($handle)
$pdfSum=0;
while($file=readdir($handle))
{$pdfSum++;}
$pdfSum=$pdfSum-3;
$pdfResult="<?PHP 
\$pdfSum='$pdfSum';
?>";
$handle=fopen($savefilePDF, "w");
fwrite($handle,$pdfResult);
fclose($handle);
$oldumask = umask(0);
chmod($savefilePDF, 0644);
umask($oldumask);
?>

<script src='./../ckeditor/ckeditor.js'></script>
<script>
CKEDITOR.config.language = '<?PHP echo $tlanguage;?>';
//CKEDITOR.dtd.$removeEmpty['span'] = false;
//CKEDITOR.dtd.$removeEmpty['&nbsp;'] = true;

CKEDITOR.config.fillEmptyBlocks = false; 
CKEDITOR.config.ignoreEmptyParagraph = false;
CKEDITOR.config.basicEntities = false;
CKEDITOR.config.allowedContent = true;

//CKEDITOR.config.extraAllowedContent = '*(*)';
CKEDITOR.config.extraAllowedContent = '*(*);*{*}';

CKEDITOR.config.width = '100%';
CKEDITOR.config.height = 300;
CKEDITOR.config.filebrowserWindowWidth = '275';
CKEDITOR.config.filebrowserWindowHeight = '200'
<?PHP if($progX == 1){ ?>
CKEDITOR.config.filebrowserBrowseUrl = './../ckeditor/editor1-pdfbrowser.php?type=Files<?PHP echo "&pdfSum=$pdfSum&projectN=".$filename2;?>';
CKEDITOR.config.filebrowserImageBrowseUrl = './../ckeditor/editor1-imagebrowser.php?listUrl=<?PHP echo "//".$wssiteW."/".$wssiteL."/".$wssiteA."/".$SYSD."/".$filename1."-".$proX."-images_list.json&projectN=".$filename2;?>';
<?PHP }else{ ?>
CKEDITOR.config.filebrowserBrowseUrl = './../ckeditor/editor1-pdfbrowser.php?type=Files<?PHP echo "&pdfSum=$pdfSum&projectN=".$filename2;?>';
CKEDITOR.config.filebrowserImageBrowseUrl = './../ckeditor/editor1-imagebrowser.php?listUrl=<?PHP echo "//".$wssiteW."/".$wssiteL."/".$wssiteA."/".$SYSD."/".$filename1."-images_list.json&projectN=".$filename2;?>';
<?PHP } ?>
CKEDITOR.config.baseHref = '<?PHP echo @$documentbaseurl;?>';
</script>

<?PHP
if (isset($_POST['editorLMs'])) {
$lastsaveX=$loadingEdit." ".$lastsave;

//define("DATA_FILE", $exCC."/".$sitecontent.".inc.php");
define("DATA_FILE", $fileXcontent);
extract($_POST);
$file=($_POST['editorLMs']);
$file=preg_replace("/\r|\r/s", "\r", $file);
$file=str_replace("<p></p>
","", $file);
$file=str_replace('\"','"',$file);
$file=str_replace('\\"','"',$file);
$file=str_replace('&Acirc;&#160;','',$file);
$file=str_replace('&Acirc;','',$file);
$file=str_replace('&#160;','',$file);
$file=str_replace('Â','',$file);
$file=str_replace('ÂÂ','',$file);
$fileX=strlen($file);
//echo $fileX;
if($fileX == 9){$file=str_replace('<p></p>','',$file);}

//extract($_GET);
//$webX=($_GET['webX']);
//$saveEditortext=$exCC."/".$sitecontent.".inc.php";
$saveEditortext=$fileXcontent;
$handle=fopen($saveEditortext, "w");
fwrite($handle,$file);
fclose($handle);
$oldumask = umask(0);
chmod($saveEditortext, 0644);
umask($oldumask);
}
?>

<div class="animated fadeInLoad">
<div class="col-md-12">
<div class="box boxStyle2 infoBox">
<div class="padd10">

<?PHP 
if($wsArea == ""){
$wsArea="";
}else{
$wsArea=", ".$wsArea;
}

echo "
<div>
<span class='ftL'>".$editArea.": <b>".$$dashlinkR.$wsArea." </b> <span class='formsub'> [".$webX.".php]</span></span> 
<span class='ftR resT font13 fwb'>".$lastsaveX."</span>
</div>
<div class='clearX infoboxline'></div>
";

$fileZcontent=file($fileXcontent);

echo "
<form action='$editaction?webX=$webX' method='post'>

<div>
<textarea id='editorLMs' name='editorLMs'>";
foreach($fileZcontent as $textZcontent){
echo $textZcontent;
}
echo "</textarea>
</div>

<div class='editor-btn1'>
<button type='submit' id='save' name='save' class='btn form-btn1'><i class='fa fa-arrow-circle-right'></i> ".$saveD."</button>
</div>
</form>
";
?>

</div><!-- ./Box -->
</div><!-- ./Box -->
</div><!-- col-12 -->
</div><!-- End animated -->
<div class="clearX"></div>

<script>
CKEDITOR.replace( 'editorLMs',{
customConfig: './../ckeditor/config.js',
<?PHP 
if (file_exists($exC."/webcodeHeader.inc.php")){
include($exC."/webcodeHeader.inc.php");
}else{
echo "contentsCss: 'body {font-family:arial;font-size:14px;padding:0 10px;color:#000;background:#fff;}',
";
}
?>
coreStyles_bold: { element: 'b' },
coreStyles_italic: { element: 'i' },
coreStyles_underline: { element: 'u' },
coreStyles_strike: { element: 'strike' },
});
</script>