Add install.php script to handle installation and initialization of parameters file + bug correction of miscorrect handling of \n in plugin script

This commit is contained in:
Phyks 2013-08-04 22:05:33 +02:00
parent 7cf771b4f8
commit cc77aa9e36
3 changed files with 10 additions and 5 deletions

View File

@ -106,12 +106,14 @@ function adblock_plugin_setting_update($_) {
if($_['action'] == 'adblock_update') { if($_['action'] == 'adblock_update') {
$flash_enabled = (int) $_['flash_adblock_enable']; $flash_enabled = (int) $_['flash_adblock_enable'];
$flash_block = (int) $_['flash_adblock_default_behavior']; $flash_block = (int) $_['flash_adblock_default_behavior'];
$flash_list = str_replace("\n", ",", $_["flash_adblock_list"]); $flash_list = str_replace("\r\n", ",", $_["flash_adblock_list"]);
$flash_list = str_replace("\n", ",", $flash_list);
$img_enabled = (int) $_['img_adblock_enable']; $img_enabled = (int) $_['img_adblock_enable'];
$img_block = (int) $_['img_adblock_default_behavior']; $img_block = (int) $_['img_adblock_default_behavior'];
$img_only_mobiles = (int) $_["img_adblock_only_mobiles"]; $img_only_mobiles = (int) $_["img_adblock_only_mobiles"];
$img_list = str_replace("\n", ",", $_["img_adblock_list"]); $img_list = str_replace("\r\n", ",", $_["img_adblock_list"]);
$img_list = str_replace("\n", ",", $img_list);
if(file_put_contents("plugins/adblock/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)) if(file_put_contents("plugins/adblock/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))
header('location: settings.php'); header('location: settings.php');

View File

@ -1,7 +1,7 @@
flash_enabled = 0 flash_enabled = 0
flash_block = 0 flash_block = 0
flash_list = 1 ,2 ,3 ,4 flash_list =
img_enabled = 0 img_enabled = 0
img_block = 0 img_block = 0
img_only_mobiles = 1 img_only_mobiles = 0
img_list = 0 ,1 img_list =

3
adblock/install.php Normal file
View File

@ -0,0 +1,3 @@
<?php
if(!file_put_contents("plugins/adblock/adblock_constants.php", "flash_enabled = 0\nflash_block = 0\nflash_list = \"\"\nimg_enabled = 0\nimg_block = 0\nimg_only_mobiles = 0\nimg_list = \"\""))
exit("An error occured while initalizing the file to store parameters (plugins/adblock/adblock_constants.php). Check the write permissions of the web server on the parent folders.");