Browse Source

Separated versions for greeder and marigolds

master
Phyks 9 years ago
parent
commit
bdc71f9365
  1. 3
      README.md
  2. 95
      greeder/adblock.plugin.disabled.php
  3. 0
      greeder/css/adblock_plugin_css.css
  4. 0
      greeder/install.php
  5. 0
      greeder/js/adblock_plugin_js.js
  6. 25
      greeder/locale/en.json
  7. 25
      greeder/locale/fr.json
  8. 279
      marigolds/adblock.plugin.disabled.php
  9. 35
      marigolds/css/adblock_plugin_css.css
  10. 6
      marigolds/install.php
  11. 24
      marigolds/js/adblock_plugin_js.js
  12. 25
      marigolds/locale/en.json
  13. 25
      marigolds/locale/fr.json

3
README.md

@ -75,3 +75,6 @@ quote where the original code comes from. @@ -75,3 +75,6 @@ quote where the original code comes from.
in return.
Phyks
---------------------------------------------------------------------------------
Contributors:
* @Cobalt74 - cobalt74 at gmail dot com - www.cobestran.com

95
adblock.plugin.disabled.php → greeder/adblock.plugin.disabled.php

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
@author Phyks <phyks@phyks.me>
@link http://www.phyks.me
@licence BEERWARE (See README.md file)
@version 2.0.0
@version 2.0.1
@description The adblock plugin for leed allows to block embedded flash contents and / or images in feeds. You can set it fine-grained for each feed. You can also disable images only for mobile devices.
*/
@ -146,7 +146,7 @@ function adblock_plugin_setting_link(&$myUser) { @@ -146,7 +146,7 @@ function adblock_plugin_setting_link(&$myUser) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
echo '
<li onclick="toggleBlocks(\'#adblockSettingsBloc\');"><a href="#adblockSettingsBloc">Adblock</a></li>';
<li onclick="toggleBlocks(\'#adblockSettingsBloc\');"><a href="#adblockSettingsBloc">'._t('P_ADBLOCK_TITLE').'</a></li>';
}
}
@ -186,61 +186,64 @@ function adblock_plugin_setting_bloc(&$myUser) { @@ -186,61 +186,64 @@ function adblock_plugin_setting_bloc(&$myUser) {
echo '
<section id="adblockSettingsBloc" class="settingsPage">
<article>
<h2>Plugin Adblock</h2>
<p><em>Note: </em> You must enter a list of id of feeds in the blacklist / whitelist fields. This list must be one id per line. You can find the id of the feed you want in the address bar on the page of the feed in Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).</p>
<h2>'._t('P_ADBLOCK_H2_TITLE').'</h2>
<p>'._t('P_ADBLOCK_NOTE').'</p>
<form action="action.php?action=adblock_update" method="POST">
<fieldset>
<div class="flash_adblockSettingsBlock">
<h3>Flash embedded contents:</h3>
<h3>'._t('P_ADBLOCK_OPT_FLASH_TITLE').'</h3>
<p>
Enable / Disable blocking of flash contents in events:<br/>
<input type="radio" name="flash_adblock_enable" value="1" id="flash_adblock_block_enabled" '.(($flash_enabled) ? 'checked="checked"' : '').'/><label for="flash_adblock_block_enabled">Enabled</label><br/>
<input type="radio" name="flash_adblock_enable" value="0" id="flash_adblock_block_disable" '.((!$flash_enabled) ? 'checked="checked"' : '').'/> <label for="flash_adblock_block_disable">Disabled</label>
'._t('P_ADBLOCK_OPT_FLASH').'<br/>
<input type="radio" name="flash_adblock_enable" value="1" id="flash_adblock_block_enabled" '.(($flash_enabled) ? 'checked="checked"' : '').'/><label for="flash_adblock_block_enabled">'._t('P_ADBLOCK_OPT_ENABLED').'</label><br/>
<input type="radio" name="flash_adblock_enable" value="0" id="flash_adblock_block_disable" '.((!$flash_enabled) ? 'checked="checked"' : '').'/> <label for="flash_adblock_block_disable">'._t('P_ADBLOCK_OPT_DISABLED').'</label>
</p>
<p>Default behavior:<br/>
<input type="radio" name="flash_adblock_default_behavior" value="1" id="flash_adblock_blockall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 1);" '.(($flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_blockall">Block all contents (and use a whitelist)</label><br/>
<input type="radio" name="flash_adblock_default_behavior" value="0" id="flash_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 0);" '.((!$flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_allowall">Allow all contents (and use a blacklist)</label>
</p>
<p>'._t('P_ADBLOCK_DEFAULT_BEHAVIOR').'<br/>
<input type="radio" name="flash_adblock_default_behavior" value="1" id="flash_adblock_blockall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 1);" '.(($flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_blockall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK').'</label><br/>
<p><span id="adblock_flash_whitelist_blacklist">'.(($flash_block) ? 'Whitelist:' : 'Blacklist:').'</span></br>
<textarea name="flash_adblock_list" rows="7">'.$flash_list.'</textarea>
</div>
</fieldset>
<input type="radio" name="flash_adblock_default_behavior" value="0" id="flash_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 0);" '.((!$flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_allowall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW').'</label>
</p>
<fieldset>
<div class="img_adblockSettingsBlock">
<h3>Images:</h3>
<p>
Enable / Disable blocking of images in events:<br/>
<input type="radio" name="img_adblock_enable" value="1" id="img_adblock_block_enabled" '.(($img_enabled) ? 'checked="checked"' : '').'/><label for="img_adblock_block_enabled">Enabled</label><br/>
<input type="radio" name="img_adblock_enable" value="0" id="img_adblock_block_disable" '.((!$img_enabled) ? 'checked="checked"' : '').'/><label for="img_adblock_block_disable">Disabled</label>
</p>
<p><span id="adblock_flash_whitelist_blacklist">'.(($flash_block) ? _t('P_ADBLOCK_WHITELIST') : _t('P_ADBLOCK_BLACKLIST')).'</span></p>
<textarea name="flash_adblock_list" rows="7">'.$flash_list.'</textarea>
</div>
</fieldset>
<p>Default behavior:<br/>
<input type="radio" name="img_adblock_default_behavior" value="1" id="img_adblock_blockall" onchange="adblock_whitelist_blacklist(\'adblock_img_whitelist_blacklist\', 1);" '.(($img_block) ? 'checked="checked"' : '').'/><label for="img_adblock_blockall">Block all contents (and use a whitelist)</label><br/>
<input type="radio" name="img_adblock_default_behavior" value="0" id="img_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_img_whitelist_blacklist\', 0);" '.((!$img_block) ? 'checked="checked"' : '').'/><label for="img_adblock_allowall">Allow all contents (and use a blacklist)</label>
</p>
<fieldset>
<div class="img_adblockSettingsBlock">
<h3>'._t('P_ADBLOCK_OPT_IMAGES_TITLE').'</h3>
<p>
'._t('P_ADBLOCK_OPT_IMAGES').'<br/>
<input type="radio" name="img_adblock_enable" value="1" id="img_adblock_block_enabled" '.(($img_enabled) ? 'checked="checked"' : '').'/><label for="img_adblock_block_enabled">'._t('P_ADBLOCK_OPT_ENABLED').'</label><br/>
<input type="radio" name="img_adblock_enable" value="0" id="img_adblock_block_disable" '.((!$img_enabled) ? 'checked="checked"' : '').'/><label for="img_adblock_block_disable">'._t('P_ADBLOCK_OPT_DISABLED').'</label>
</p>
<p>Block images only on mobile devices?<br/>
<input type="radio" name="img_adblock_only_mobiles" value="1" id="img_adblock_only_mobiles_yes" '.(($img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_yes">Only block images on mobile devices</label><br/>
<input type="radio" name="img_adblock_only_mobiles" value="0" id="img_adblock_only_mobiles_no" '.((!$img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_no">Block images on all devices</label>
</p>
<p>'._t('P_ADBLOCK_DEFAULT_BEHAVIOR').'<br/>
<input type="radio" name="img_adblock_default_behavior" value="1" id="img_adblock_blockall" onchange="adblock_whitelist_blacklist(\'adblock_img_whitelist_blacklist\', 1);" '.(($img_block) ? 'checked="checked"' : '').'/><label for="img_adblock_blockall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK').'</label><br/>
<input type="radio" name="img_adblock_default_behavior" value="0" id="img_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_img_whitelist_blacklist\', 0);" '.((!$img_block) ? 'checked="checked"' : '').'/><label for="img_adblock_allowall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW').'</label>
</p>
<p>'._t('P_ADBLOCK_OPT_IMAGES_MOBILE').'<br/>
<input type="radio" name="img_adblock_only_mobiles" value="1" id="img_adblock_only_mobiles_yes" '.(($img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_yes">'._t('P_ADBLOCK_OPT_IMAGES_BLOCK_MOBILE').'</label><br/>
<input type="radio" name="img_adblock_only_mobiles" value="0" id="img_adblock_only_mobiles_no" '.((!$img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_no">'._t('P_ADBLOCK_OPT_IMAGES_BLOCK_ALL').'</label>
</p>
<p><span id="adblock_img_whitelist_blacklist">'.(($img_block) ? 'Whitelist:' : 'Blacklist:').'</span></br>
<textarea name="img_adblock_list" rows="7">'.$img_list.'</textarea>
</div>
</fieldset>
<p>
Elegant degradation (replace content with same-size content)?<br/>
<input type="radio" name="adblock_elegant_degradation" value="1" id="adblock_elegant_degradation_yes" '.(($elegant_degradation) ? 'checked="checked"' : '').' '.((!$getimagesize_available) ? 'disabled' : '').'/><label for="adblock_elegant_degradation_yes">Yes</label>'.((!$getimagesize_available) ? ' <em>(Not available because the getimagesize seems to not be available on your system or allow_url_fopen is set to Off in php.ini)</em>' : '').'<br/>
<input type="radio" name="adblock_elegant_degradation" value="0" id="adblock_elegant_degradation_no" '.((!$elegant_degradation) ? 'checked="checked"' : '').'/><label for="adblock_elegant_degradation_no">No</label>
</p>
<p id="adblock_settings_submit">
<input type="submit" class="button" value="Save"/>
</p>
</form>
</section>';
<p><span id="adblock_img_whitelist_blacklist">'.(($img_block) ? _t('P_ADBLOCK_WHITELIST') : _t('P_ADBLOCK_BLACKLIST')).'</span></p>
<textarea name="img_adblock_list" rows="7">'.$img_list.'</textarea>
</div>
</fieldset>
<p>
'._t('P_ADBLOCK_OPT_DEGRADATION').'<br/>
<input type="radio" name="adblock_elegant_degradation" value="1" id="adblock_elegant_degradation_yes" '.(($elegant_degradation) ? 'checked="checked"' : '').' '.((!$getimagesize_available) ? 'disabled' : '').'/><label for="adblock_elegant_degradation_yes">'._t('P_ADBLOCK_YES').'</label>'.((!$getimagesize_available) ? _t('P_ADBLOCK_OPT_DEGR_MSG') : '').'<br/>
<input type="radio" name="adblock_elegant_degradation" value="0" id="adblock_elegant_degradation_no" '.((!$elegant_degradation) ? 'checked="checked"' : '').'/><label for="adblock_elegant_degradation_no">'._t('P_ADBLOCK_NO').'</label>
</p>
<p id="adblock_settings_submit">
<input type="submit" class="button" value="'._t('P_ADBLOCK_SAVE').'"/>
</p>
</form>
</article>
</section>';
}
}

0
css/adblock_plugin_css.css → greeder/css/adblock_plugin_css.css

0
install.php → greeder/install.php

0
js/adblock_plugin_js.js → greeder/js/adblock_plugin_js.js

25
greeder/locale/en.json

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
{
"P_ADBLOCK_BLACKLIST":"Blacklist:",
"P_ADBLOCK_DEFAULT_BEHAVIOR":"Default behavior:",
"P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW":"Allow all contents (and use a blacklist)",
"P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK":"Block all contents (and use a whitelist)",
"P_ADBLOCK_ERR_WRITE":"Unable to write parameters to adblock_constants.php. Check permissions on the folders.",
"P_ADBLOCK_H2_TITLE":"Plugin Adblock",
"P_ADBLOCK_NO":"No",
"P_ADBLOCK_NOTE":"<em>Note: </em> You must enter a list of id of feeds in the blacklist / whitelist fields. This list must be one id per line. You can find the id of the feed you want in the address bar on the page of the feed in Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).",
"P_ADBLOCK_OPT_DEGRADATION":"Elegant degradation (replace content with same-size content)?",
"P_ADBLOCK_OPT_DEGR_MSG":"<em>(Not available because the getimagesize seems to not be available on your system or allow_url_fopen is set to Off in php.ini)</em>",
"P_ADBLOCK_OPT_DISABLED":"Disabled",
"P_ADBLOCK_OPT_ENABLED":"Enabled",
"P_ADBLOCK_OPT_FLASH":"Enable / Disable blocking of flash contents in events:",
"P_ADBLOCK_OPT_FLASH_TITLE":"Flash embedded contents:",
"P_ADBLOCK_OPT_IMAGES":"Enable / Disable blocking of images in events:",
"P_ADBLOCK_OPT_IMAGES_BLOCK_ALL":"Block images on all devices",
"P_ADBLOCK_OPT_IMAGES_BLOCK_MOBILE":"Only block images on mobile devices",
"P_ADBLOCK_OPT_IMAGES_MOBILE":"Block images only on mobile devices?",
"P_ADBLOCK_OPT_IMAGES_TITLE":"Images:",
"P_ADBLOCK_SAVE":"Save",
"P_ADBLOCK_TITLE":"Adblock",
"P_ADBLOCK_WHITELIST":"Whitelist:",
"P_ADBLOCK_YES":"Yes"
}

25
greeder/locale/fr.json

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
{
"P_ADBLOCK_BLACKLIST":"Liste noire :",
"P_ADBLOCK_DEFAULT_BEHAVIOR":"Comportement par défaut :",
"P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW":"Permettre tous les contenus (et utiliser la liste noire)",
"P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK":"Bloquer tous les contenus (et utiliser la liste blanche)",
"P_ADBLOCK_ERR_WRITE":"Impossible d'écrire les paramètres dans le fichier adblock_constants.php. Vérifiez les autorisations sur les dossiers.",
"P_ADBLOCK_H2_TITLE":"Plugin Adblock",
"P_ADBLOCK_NO":"Non",
"P_ADBLOCK_NOTE":"<em>Remarque :</em> Vous devez entrer une liste d'identifiants de flux dans les champs liste noire / liste blanche. Cette liste doit être composée d'un id par ligne. Vous pouvez trouver l'ID dans la barre d'adresse sur la page de sélection d'un flux dans Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).",
"P_ADBLOCK_OPT_DEGRADATION":"Dégradation élégante (remplacer le contenu avec le contenu de même taille) ?",
"P_ADBLOCK_OPT_DEGR_MSG":"<em>(Non disponible parce que la fonction getimagesize ne semble pas être disponible sur votre système ou allow_url_fopen est réglé sur Off dans le fichier php.ini)</em>",
"P_ADBLOCK_OPT_DISABLED":"Désactivé",
"P_ADBLOCK_OPT_ENABLED":"Activé",
"P_ADBLOCK_OPT_FLASH":"Activer / Désactiver le blocage de contenu flash dans les événements:",
"P_ADBLOCK_OPT_FLASH_TITLE":"Contenu Flash :",
"P_ADBLOCK_OPT_IMAGES":"Activer / Désactiver le blocage des images sur les événements :",
"P_ADBLOCK_OPT_IMAGES_BLOCK_ALL":"Bloquer les images sur tous les appareils",
"P_ADBLOCK_OPT_IMAGES_BLOCK_MOBILE":"Seulement bloquer les images sur les appareils mobiles",
"P_ADBLOCK_OPT_IMAGES_MOBILE":"Bloquer les images uniquement sur les appareils mobiles ?",
"P_ADBLOCK_OPT_IMAGES_TITLE":"Images :",
"P_ADBLOCK_SAVE":"Sauvegarder",
"P_ADBLOCK_TITLE":"Adblock",
"P_ADBLOCK_WHITELIST":"Liste blanche :",
"P_ADBLOCK_YES":"Oui"
}

279
marigolds/adblock.plugin.disabled.php

@ -0,0 +1,279 @@ @@ -0,0 +1,279 @@
<?php
/*
@name Adblock
@author Phyks <phyks@phyks.me>
@link http://www.phyks.me
@licence BEERWARE (See README.md file)
@version 2.2.0
@description The adblock plugin for leed allows to block embedded flash contents and / or images in feeds. You can set it fine-grained for each feed. You can also disable images only for mobile devices.
*/
function adblock_isMobileDevice() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
function adblock_trim_list($input) {
$output = array();
foreach($input as $key=>$value) {
$output[$key] = trim($value, "\t\n\r\0\x0B,\"");
}
return $output;
}
function adblock_plugin_treat_events(&$events) {
//Set params
$configurationManager = new Configuration();
$partial = $configurationManager->get('articleView') == "partial";
$adblock_constants = file_get_contents("adblock_constants.php");
$adblock_constants = explode("\n", $adblock_constants);
$adblock_params = array();
foreach($adblock_constants as $adblock_constant) {
if(trim($adblock_constant) != "") {
$adblock_constant = explode("=", $adblock_constant);
$adblock_params[trim($adblock_constant[0])] = trim($adblock_constant[1]);
}
}
if(isset($adblock_params["flash_enabled"]) && $adblock_params["flash_enabled"] == "1") {
$filter_flash = true;
if(isset($adblock_params["flash_block"]) && $adblock_params["flash_block"] == "1") {
$block_flash = true;
}
else {
$block_flash = false;
}
}
else {
$filter_flash = false;
}
$flash_except_list = explode(',', trim($adblock_params["flash_list"], "\t\n\r\0\x0B,"));
$flash_except_list = adblock_trim_list($flash_except_list);
if(isset($adblock_params["img_enabled"]) && $adblock_params["img_enabled"] == "1") {
$filter_img = true;
if(isset($adblock_params["img_block"]) && $adblock_params["img_block"] == "1") {
$block_img = true;
}
else {
$block_img = false;
}
if(isset($adblock_params["img_only_mobiles"]) && $adblock_params["img_only_mobiles"] == "1" && !adblock_isMobileDevice()) { //If filter only on mobile devices and not a mobile device
$filter_img = false;
}
}
else {
$filter_img = false;
}
$img_except_list = explode(',', trim($adblock_params["img_list"], "\t\n\r\0\x0B,"));
$img_except_list = adblock_trim_list($flash_except_list);
$elegant_degradation = (isset($adblock_params["elegant_degradation"]) && $adblock_params["elegant_degradation"] == "1") ? true : false;
foreach($events as $event) {
$filtered_content = ($partial) ? $event->getDescription : $event->getContent();
$modified = false;
// Flash handling
if($filter_flash) {
if(($block_flash && !in_array($event->getFeed(), $flash_except_list)) || (!$block_flash && in_array($event->getFeed(), $flash_except_list))) {
//Replace flash content
preg_match_all("#<iframe.{0,}/(iframe)?>#U", $filtered_content, $object_list_in_event, PREG_SET_ORDER);
foreach($object_list_in_event as $object) {
if(!$elegant_degradation) {
$replacement_content = '
<span class="blocked_flash" onclick="return adblock_unblock_flash(this, \''.htmlspecialchars($object[0]).'\');">X</span>
';
$filtered_content = str_replace($object[0], $replacement_content, $filtered_content);
}
else {
preg_match("#width=[\"']([0-9]{1,})[\"']#U", $object[0], $width);
preg_match("#height=[\"']([0-9]{1,})[\"']#U", $object[0], $height);
$font_size = min($width[1], $height[1]);
$replacement_content = '
<span class="blocked_flash" '.((!empty($width[1]) && !empty($height[1])) ? 'style="width: '.$width[1].'px; height: '.$height[1].'px; padding: 0; padding-top: '.((int) $font_size) / 2 .'px; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; font-size: '.$font_size.'px;"' : '').' onclick="return adblock_unblock_flash(this, \''.htmlspecialchars($object[0]).'\');">X</span>
';
$filtered_content = str_replace($object[0], $replacement_content, $filtered_content);
}
}
$modified = true;
}
}
// Images handling
if($filter_img) {
if(($block_img && !in_array($event->getFeed(), $img_except_list)) || (!$block_img && in_array($event->getFeed(), $img_except_list))) {
//Replace images
preg_match_all("#<img.{0,}src=[\"'](.{1,})[\"'].{0,}/?(img)?>#U", $filtered_content, $img_list_in_event, PREG_SET_ORDER);
foreach($img_list_in_event as $img) {
if(!$elegant_degradation) {
$replacement_content = '
<span class="blocked_image" onclick="return adblock_unblock_img(this, \''.urlencode($img[1]).'\');">X</span>
';
$filtered_content = str_replace($img[0], $replacement_content, $filtered_content);
}
else {
$content_size = getimagesize($img[1]); //Index 0 is width, index 1 is height
$font_size = min($content_size[0], $content_size[1]);
$replacement_content = '
<span class="blocked_image" style="width:'.(int) $content_size[0].'px; height:'.(int) $content_size[1].'px; padding:0; padding-top: '.((int) $font_size) / 2 .'px; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; font-size: '.$font_size.'px;" onclick="return adblock_unblock_img(this, \''.urlencode($img[1]).'\'):">X</span>
';
$filtered_content = str_replace($img[0], $replacement_content, $filtered_content);
}
}
$modified = true;
}
}
if($modified) {
if($partial)
$event->setDescription($filtered_content);
else
$event->setContent($filtered_content);
}
}
}
function adblock_plugin_setting_link(&$myUser) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
echo '
<li><a class="toggle" href="#adblockSettingsBloc">'._t('P_ADBLOCK_TITLE').'</a></li>';
}
}
function adblock_plugin_setting_bloc(&$myUser) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
$adblock_constants = file_get_contents('adblock_constants.php');
$adblock_constants = explode("\n", $adblock_constants);
$adblock_params = array();
foreach($adblock_constants as $adblock_constant) {
if(trim($adblock_constant) != "") {
$adblock_constant = explode("=", $adblock_constant);
$adblock_params[trim($adblock_constant[0])] = trim($adblock_constant[1]);
}
}
$flash_enabled = (isset($adblock_params["flash_enabled"]) && $adblock_params["flash_enabled"] == "1") ? true : false;
$flash_block = (isset($adblock_params["flash_block"]) && $adblock_params["flash_block"] == "1") ? true : false;
if(isset($adblock_params["flash_list"]))
$flash_list = str_replace(",", "\n", trim($adblock_params["flash_list"], "\t\n\r\0\x0B,"));
else
$flash_list = "";
$img_enabled = (isset($adblock_params["img_enabled"]) && $adblock_params["img_enabled"] == "1") ? true : false;
$img_only_mobiles = (isset($adblock_params["img_only_mobiles"]) && $adblock_params["img_only_mobiles"] == 1) ? true : false;
$img_block = (isset($adblock_params["img_block"]) && $adblock_params["img_block"] == "1") ? true : false;
if(isset($adblock_params["img_list"]))
$img_list = str_replace(",", "\n", trim($adblock_params["img_list"], "\t\n\r\0\x0B,"));
else
$img_list = "";
$elegant_degradation = (isset($adblock_params["elegant_degradation"]) && $adblock_params["elegant_degradation"] == "1") ? true : false;
$getimagesize_available = function_exists("getimagesize") && ((ini_get("allow_url_fopen") == "1") ? true : false);
echo '
<section id="adblockSettingsBloc" class="adblockSettingsBloc">
<h2>'._t('P_ADBLOCK_H2_TITLE').'</h2>
<p>'._t('P_ADBLOCK_NOTE').'</p>
<form action="action.php?action=adblock_update" method="POST">
<fieldset>
<div class="flash_adblockSettingsBlock">
<h3>'._t('P_ADBLOCK_OPT_FLASH_TITLE').'</h3>
<p>
'._t('P_ADBLOCK_OPT_FLASH').'<br/>
<input type="radio" name="flash_adblock_enable" value="1" id="flash_adblock_block_enabled" '.(($flash_enabled) ? 'checked="checked"' : '').'/><label for="flash_adblock_block_enabled">'._t('P_ADBLOCK_OPT_ENABLED').'</label><br/>
<input type="radio" name="flash_adblock_enable" value="0" id="flash_adblock_block_disable" '.((!$flash_enabled) ? 'checked="checked"' : '').'/> <label for="flash_adblock_block_disable">'._t('P_ADBLOCK_OPT_DISABLED').'</label>
</p>
<p>'._t('P_ADBLOCK_DEFAULT_BEHAVIOR').'<br/>
<input type="radio" name="flash_adblock_default_behavior" value="1" id="flash_adblock_blockall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 1);" '.(($flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_blockall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK').'</label><br/>
<input type="radio" name="flash_adblock_default_behavior" value="0" id="flash_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 0);" '.((!$flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_allowall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW').'</label>
</p>
<p><span id="adblock_flash_whitelist_blacklist">'.(($flash_block) ? _t('P_ADBLOCK_WHITELIST') : _t('P_ADBLOCK_BLACKLIST')).'</span></p>
<textarea name="flash_adblock_list" rows="7">'.$flash_list.'</textarea>
</div>
</fieldset>
<fieldset>
<div class="img_adblockSettingsBlock">
<h3>'._t('P_ADBLOCK_OPT_IMAGES_TITLE').'</h3>
<p>
'._t('P_ADBLOCK_OPT_IMAGES').'<br/>
<input type="radio" name="img_adblock_enable" value="1" id="img_adblock_block_enabled" '.(($img_enabled) ? 'checked="checked"' : '').'/><label for="img_adblock_block_enabled">'._t('P_ADBLOCK_OPT_ENABLED').'</label><br/>
<input type="radio" name="img_adblock_enable" value="0" id="img_adblock_block_disable" '.((!$img_enabled) ? 'checked="checked"' : '').'/><label for="img_adblock_block_disable">'._t('P_ADBLOCK_OPT_DISABLED').'</label>
</p>
<p>'._t('P_ADBLOCK_DEFAULT_BEHAVIOR').'<br/>
<input type="radio" name="img_adblock_default_behavior" value="1" id="img_adblock_blockall" onchange="adblock_whitelist_blacklist(\'adblock_img_whitelist_blacklist\', 1);" '.(($img_block) ? 'checked="checked"' : '').'/><label for="img_adblock_blockall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK').'</label><br/>
<input type="radio" name="img_adblock_default_behavior" value="0" id="img_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_img_whitelist_blacklist\', 0);" '.((!$img_block) ? 'checked="checked"' : '').'/><label for="img_adblock_allowall">'._t('P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW').'</label>
</p>
<p>'._t('P_ADBLOCK_OPT_IMAGES_MOBILE').'<br/>
<input type="radio" name="img_adblock_only_mobiles" value="1" id="img_adblock_only_mobiles_yes" '.(($img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_yes">'._t('P_ADBLOCK_OPT_IMAGES_BLOCK_MOBILE').'</label><br/>
<input type="radio" name="img_adblock_only_mobiles" value="0" id="img_adblock_only_mobiles_no" '.((!$img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_no">'._t('P_ADBLOCK_OPT_IMAGES_BLOCK_ALL').'</label>
</p>
<p><span id="adblock_img_whitelist_blacklist">'.(($img_block) ? _t('P_ADBLOCK_WHITELIST') : _t('P_ADBLOCK_BLACKLIST')).'</span></p>
<textarea name="img_adblock_list" rows="7">'.$img_list.'</textarea>
</div>
</fieldset>
<p>
'._t('P_ADBLOCK_OPT_DEGRADATION').'<br/>
<input type="radio" name="adblock_elegant_degradation" value="1" id="adblock_elegant_degradation_yes" '.(($elegant_degradation) ? 'checked="checked"' : '').' '.((!$getimagesize_available) ? 'disabled' : '').'/><label for="adblock_elegant_degradation_yes">'._t('P_ADBLOCK_YES').'</label>'.((!$getimagesize_available) ? _t('P_ADBLOCK_OPT_DEGR_MSG') : '').'<br/>
<input type="radio" name="adblock_elegant_degradation" value="0" id="adblock_elegant_degradation_no" '.((!$elegant_degradation) ? 'checked="checked"' : '').'/><label for="adblock_elegant_degradation_no">'._t('P_ADBLOCK_NO').'</label>
</p>
<p id="adblock_settings_submit">
<input type="submit" class="button" value="'._t('P_ADBLOCK_SAVE').'"/>
</p>
</form>
</section>';
}
}
function adblock_plugin_setting_update($_) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
if($_['action'] == 'adblock_update') {
$flash_enabled = (int) $_['flash_adblock_enable'];
$flash_block = (int) $_['flash_adblock_default_behavior'];
$flash_list = str_replace("\r\n", ",", trim($_["flash_adblock_list"]));
$flash_list = str_replace("\n", ",", trim($flash_list));
$img_enabled = (int) $_['img_adblock_enable'];
$img_block = (int) $_['img_adblock_default_behavior'];
$img_only_mobiles = (int) $_["img_adblock_only_mobiles"];
$img_list = str_replace("\r\n", ",", trim($_["img_adblock_list"]));
$img_list = str_replace("\n", ",", trim($img_list));
$elegant_degradation = (int) $_["adblock_elegant_degradation"];
if(file_put_contents("adblock_constants.php", "flash_enabled = ".$flash_enabled."\nflash_block = ".$flash_block."\nflash_list = ".$flash_list."\nimg_enabled = ".$img_enabled."\nimg_block = ".$img_block."\nimg_only_mobiles = ".$img_only_mobiles."\nimg_list = ".$img_list."\nelegant_degradation = ".$elegant_degradation))
header('location: settings.php');
else
exit(_t('P_ADBLOCK_ERR_WRITE'));
}
}
}
Plugin::addCSS("/css/adblock_plugin_css.css");
Plugin::addJS("/js/adblock_plugin_js.js");
Plugin::addHook("index_post_treatment", "adblock_plugin_treat_events");
Plugin::addHook("setting_post_link", "adblock_plugin_setting_link");
Plugin::addHook("setting_post_section", "adblock_plugin_setting_bloc");
Plugin::addHook("action_post_case", "adblock_plugin_setting_update");
?>

35
marigolds/css/adblock_plugin_css.css

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
#adblockSettingsBloc {
display: none;
}
#adblockSettingsBloc textarea {
width: 75%;
}
#adblock_settings_submit {
text-align: center;
}
.blocked_image {
display: inline-block;
background-color: rgb(141, 141, 141);
color: rgb(241, 101, 41);
font-weight: bold;
text-align: center;
font-size: 2em;
padding: 0.2em;
cursor: pointer;
max-width: 100%;
}
.blocked_flash {
display: inline-block;
color: white;
background-color: rgb(241, 101, 41);
font-weight: bold;
text-align: center;
font-size: 2em;
padding: 0.2em;
cursor: pointer;
max-width: 100%;
}

6
marigolds/install.php

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?php
$getimagesize_available = function_exists("getimagesize") && ((ini_get("allow_url_fopen") == "1") ? true : false);
$getimagesize_available = ($getimagesize_available) ? 1 : 0;
if(!file_put_contents("adblock_constants.php", "flash_enabled = 0\nflash_block = 0\nflash_list = \nimg_enabled = 0\nimg_block = 0\nimg_only_mobiles = 0\nimg_list = \nelegant_degradation = ".$getimagesize_available))
exit("An error occured while initalizing the file to store parameters (adblock_constants.php). Check the write permissions of the web server on the parent folders.");

24
marigolds/js/adblock_plugin_js.js

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
function adblock_whitelist_blacklist(id, whitelist_blacklist) {
if(whitelist_blacklist == 0)
document.getElementById(id).innerHTML = _t('P_ADBLOCK_BLACKLIST');
else
document.getElementById(id).innerHTML = _t('P_ADBLOCK_WHITELIST');
}
function adblock_unblock_img(span, url) {
if($(span).html() != "X")
return true;
$(span).html("<img src='"+url+"'/>");
$(span).removeClass("blocked_image");
return false;
}
function adblock_unblock_flash(span, new_content) {
if($(span).html() != "X")
return true;
$(span).html(new_content);
$(span).removeClass("blocked_flash");
return false;
}

25
marigolds/locale/en.json

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
{
"P_ADBLOCK_BLACKLIST":"Blacklist:",
"P_ADBLOCK_DEFAULT_BEHAVIOR":"Default behavior:",
"P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW":"Allow all contents (and use a blacklist)",
"P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK":"Block all contents (and use a whitelist)",
"P_ADBLOCK_ERR_WRITE":"Unable to write parameters to adblock_constants.php. Check permissions on the folders.",
"P_ADBLOCK_H2_TITLE":"Plugin Adblock",
"P_ADBLOCK_NO":"No",
"P_ADBLOCK_NOTE":"<em>Note: </em> You must enter a list of id of feeds in the blacklist / whitelist fields. This list must be one id per line. You can find the id of the feed you want in the address bar on the page of the feed in Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).",
"P_ADBLOCK_OPT_DEGRADATION":"Elegant degradation (replace content with same-size content)?",
"P_ADBLOCK_OPT_DEGR_MSG":"<em>(Not available because the getimagesize seems to not be available on your system or allow_url_fopen is set to Off in php.ini)</em>",
"P_ADBLOCK_OPT_DISABLED":"Disabled",
"P_ADBLOCK_OPT_ENABLED":"Enabled",
"P_ADBLOCK_OPT_FLASH":"Enable / Disable blocking of flash contents in events:",
"P_ADBLOCK_OPT_FLASH_TITLE":"Flash embedded contents:",
"P_ADBLOCK_OPT_IMAGES":"Enable / Disable blocking of images in events:",
"P_ADBLOCK_OPT_IMAGES_BLOCK_ALL":"Block images on all devices",
"P_ADBLOCK_OPT_IMAGES_BLOCK_MOBILE":"Only block images on mobile devices",
"P_ADBLOCK_OPT_IMAGES_MOBILE":"Block images only on mobile devices?",
"P_ADBLOCK_OPT_IMAGES_TITLE":"Images:",
"P_ADBLOCK_SAVE":"Save",
"P_ADBLOCK_TITLE":"Adblock",
"P_ADBLOCK_WHITELIST":"Whitelist:",
"P_ADBLOCK_YES":"Yes"
}

25
marigolds/locale/fr.json

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
{
"P_ADBLOCK_BLACKLIST":"Liste noire:",
"P_ADBLOCK_DEFAULT_BEHAVIOR":"Comportement par defaut :",
"P_ADBLOCK_DEFAULT_BEHAVIOR_ALLOW":"Permettre tous les contenus (et utiliser la liste noire)",
"P_ADBLOCK_DEFAULT_BEHAVIOR_BLOCK":"Bloquer tous les contenus (et utiliser la liste blanche)",
"P_ADBLOCK_ERR_WRITE":"Impossible d'écrire les paramètres dans le fichier adblock_constants.php. Vérifiez les autorisations sur les dossiers.",
"P_ADBLOCK_H2_TITLE":"Plugin Adblock",
"P_ADBLOCK_NO":"Non",
"P_ADBLOCK_NOTE":"<em>Remarque :</em> Vous devez entrer une liste d'identifiant de flux dans les champs liste noire / liste blanche. Cette liste doit être composée d'un id par ligne. Vous pouvez trouver l'ID dans la barre d'adresse sur la page de selection d'un Flux dans Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).",
"P_ADBLOCK_OPT_DEGRADATION":"Dégradation élégante (remplacer le contenu avec le contenu de même taille)?",
"P_ADBLOCK_OPT_DEGR_MSG":"<em>(Non disponible parce que la fonction getimagesize semble ne pas être disponibles sur votre système ou allow_url_fopen est réglé sur Off dans le fichier php.ini)</em>",
"P_ADBLOCK_OPT_DISABLED":"Désactivé",
"P_ADBLOCK_OPT_ENABLED":"Activé",
"P_ADBLOCK_OPT_FLASH":"Activer / Désactiver le blocage de contenu flash dans les événements:",
"P_ADBLOCK_OPT_FLASH_TITLE":"Contenu Flash :",
"P_ADBLOCK_OPT_IMAGES":"Activer / Désactiver le blocage des images sur les événements :",
"P_ADBLOCK_OPT_IMAGES_BLOCK_ALL":"Bloquer les images sur tous les appareils",
"P_ADBLOCK_OPT_IMAGES_BLOCK_MOBILE":"Seulement bloquer les images sur les appareils mobiles",
"P_ADBLOCK_OPT_IMAGES_MOBILE":"Bloquer les images uniquement sur les appareils mobiles ?",
"P_ADBLOCK_OPT_IMAGES_TITLE":"Images:",
"P_ADBLOCK_SAVE":"Sauvegarder",
"P_ADBLOCK_TITLE":"Adblock",
"P_ADBLOCK_WHITELIST":"Liste blanche:",
"P_ADBLOCK_YES":"Oui"
}
Loading…
Cancel
Save