1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
| <?php
require('config/config.php');
header("Pragma: no-cache");
header("Cache-Control: max-age=1, maxage=1, no-cache, must-revalidate" );
session_cache_limiter("nocache");
$lc_archives = "";
if(isset($_GET['archive']) && !empty($_GET['archive']))
{
$lc_archives = $_GET['archive'];
$path = "$pathTemplates/{$_GET['site']}/{$_GET['name']}/archives/".$_GET['archive'].".html";
}
else
{
$path = "templates/{$_GET['site']}/{$_GET['name']}/newsletter.html";
}
if(!isset($_GET['view']) && !isset($_GET['viewWithoutTags']))
{
require($path);
$lc_xml = simplexml_load_file('config/newsletters.xml');
$newsletter = $lc_xml->xpath("//newsletter[@site='{$_GET['site']}'][@name='{$_GET['name']}']");
$couleur_info = $newsletter[0]['couleur_info'];
$couleur_edit = $newsletter[0]['couleur_edit'];
$couleur_form = $newsletter[0]['couleur_form'];
$code_xtor = $newsletter[0]['xtor'];
?>
<div class="scripts-newsletter">
<script>var app_path = '<?= $url_app ?>';</script>
<style>body{margin-top:39px;}</style>
<link rel="shortcut icon" href="img/favicon.gif" type="image/x-icon" />
<script src="scripts/mootools.v1.2.js" type="text/javascript"></script>
<script src="scripts/inlineEdit.js" type="text/javascript"></script>
<script src="scripts/box.js" type="text/javascript"></script>
<script src="scripts/core.js" type="text/javascript"></script>
<script src="scripts/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEvent('domready',function(){
new informations({couleur_info:'<?=$couleur_info ?>', couleur_edit:'<?=$couleur_edit ?>', couleur_form:'<?=$couleur_form ?>', site:'<?=$_GET['site'] ?>', name:'<?=$_GET['name'] ?>', archive:'<?=$lc_archives ?>', code_xtor:'<?=$code_xtor ?>'});
//On rajoute le code xtor à la fin de chaque url de la NL.
if('<?=$code_xtor ?>' != '') {
$$('a').each(function(el){
var url = el.href;
if((url != "#") && (url != "") &&
!(url.contains ("&&&")) &&
!(url.contains("mailto:")) &&
!(url.contains("xtor=")) &&
(
(url.contains("www.marieclaire.fr")) ||
(url.contains("www.marieclairemaison.com")) ||
(url.contains("www.cosmopolitan.fr")) ||
(url.contains("www.famili.fr")) ||
(url.contains("www.larvf.com")) ||
(url.contains("www.cuisineetvinsdefrance.com")) ||
(url.contains("www.larvf.com")) ||
(url.contains("www.envy.fr")) ||
(url.contains("forum.magicmaman.com")) ||
(url.contains("www.magicmaman.com")) ||
(url.contains("www.magic-maison.com")) ||
(url.contains("www.magic-recettes.com")) ||
(url.contains("www.magic-recre.com")) ||
(url.contains("www.magicmaman.be")) ||
(url.contains("www.magicmama.be")) ||
(url.contains("www.magazine-avantages.fr"))
)
) {
// $$('a.tipz').each(function(element,index) {
// var truc = element.get('title')
// alert(truc);
if (url.contains('?')) {
el.href = url + '&xtor=<?=$code_xtor ?>';
}
else {
el.href = url + '?xtor=<?=$code_xtor ?>';
}
}
});
}
});
</script>
</div>
<?
}
else if (isset($_GET['view']))
{
ob_start();
require($path);
$lc_contents = ob_get_contents();
ob_end_clean();
// on supprime les elements cachés
$lc_contents = preg_replace("|(<!--[^-->])(.*)([^//]-->)|Usi", "", $lc_contents);
echo "[EMV HTMLPART]\n".$lc_contents;
}
if(isset($_GET['viewWithoutTags']))
{
ob_start();
require($path);
$lc_contents = ob_get_contents();
ob_end_clean();
// on supprime les elements cachés
$lc_contents = preg_replace("|(<!--[^-->])(.*)([^//]-->)|Usi", "", $lc_contents);
traitement($lc_contents);
$lc_contents = file_get_contents("viewNewsletter.php");
echo $lc_contents;
}
function traitement($lc_contents){
//suppression des balises inutiles pour l'envoi de newsletters
$lc_contents=str_replace ('<tbody>','', $lc_contents);
$lc_contents=str_replace ('</tbody>','', $lc_contents);
$lc_contents=preg_replace('#class="(.*?)"#','',$lc_contents);
$lc_contents=str_replace ('%3C','<', $lc_contents);
$lc_contents=str_replace ('%3E','>', $lc_contents);
$lc_contents=preg_replace('/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/','',$lc_contents);
$lc_contents=preg_replace('/(?:<noscript.*?>)((\n|\r|.)*?)(?:<\/noscript>)/','',$lc_contents);
$lc_contents=preg_replace('/(?:class=".*?>)((\n|\r|a-z|A-Z|0-9)*?)(?:e")/','',$lc_contents);
if(preg_match('#title="Magic récré"#',$lc_contents)) {
$lc_contents=preg_replace('#href="http://www.magic-maison.com(.*?)"#','#href="(.*?)xtor=EPR-27(.*?)title="Magic récré"#',$lc_contents);
}
//suppression de 1 à 3 <table display: none ... pas réussi à automatiser à l'infini (le cas ne doit pas exister de toute façon)
if(preg_match('#<table(.*?)display: none;"#',$lc_contents)) {
if(preg_match('#<table(.*?)display: none;"(.*?)<table(.*?)display: none;"(.*?)</table>(.*?)</table>#',$lc_contents)) {
if(preg_match('#<table(.*?)display: none;"(.*?)<table(.*?)display: none;"(.*?)<table(.*?)display: none;"(.*?)</table>(.*?)</table>(.*?)</table>#',$lc_contents)) {
$lc_contents=preg_replace('#<table(.*?)display: none;"(.*?)<table(.*?)display: none;"(.*?)<table(.*?)display: none;"(.*?)</table>(.*?)</table>(.*?)</table>#','',$lc_contents);
}
else {
$lc_contents=preg_replace('#<table(.*?)display: none;"(.*?)<table(.*?)display: none;"(.*?)</table>(.*?)</table>#','',$lc_contents);
}
}
else {
$lc_contents=preg_replace('#<table(.*?)display: none;"(.*?)</table>#','',$lc_contents);
}
}
$file=fopen("viewNewsletter.php","w");
//on écrit les données dans le fichier texte
fwrite($file,trim($lc_contents));
//procédure permettant de supprimer les lignes vides dans le fichier
$content = file_get_contents("viewNewsletter.php");
$new_content = "";
$lines = explode(chr(10), $content);
foreach ($lines as $line) {
if (strlen(trim($line)) > 0) {
$new_content .= $line . chr(10);
}
}
//on supprime le fichier qui contient les lignes vides
unlink("viewNewsletter.php");
//et on réinsère le nouveau code dans le fichier vidé
$file=fopen("viewNewsletter.php","w");
fwrite($file,trim($new_content));
}
?> |
Partager