Apptrian_Image_Optimizer - Version 1.0.1

Version Notes

* Fixed small bug related to exec() function

Download this release

Release Info

Developer Apptrian
Extension Apptrian_Image_Optimizer
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/Apptrian/ImageOptimizer/Helper/Data.php CHANGED
@@ -25,6 +25,35 @@ class Apptrian_ImageOptimizer_Helper_Data extends Mage_Core_Helper_Abstract
25
return (string) Mage::getConfig()->getNode()->modules->Apptrian_ImageOptimizer->version;
26
}
27
28
/**
29
* Optimized way of getting logging flag from config.
30
*
25
return (string) Mage::getConfig()->getNode()->modules->Apptrian_ImageOptimizer->version;
26
}
27
28
+ /**
29
+ * Checks if exec() function is enabled in php and suhosin config.
30
+ *
31
+ * @return boolean
32
+ */
33
+ public function isExecFunctionEnabled()
34
+ {
35
+ $r = false;
36
+
37
+ // PHP disabled functions
38
+ $phpDisabledFunctions = array_map('strtolower', array_map('trim', explode(',', ini_get('disable_functions'))));
39
+ // Suhosin disabled functions
40
+ $suhosinDisabledFunctions = array_map('strtolower', array_map('trim', explode(',', ini_get('suhosin.executor.func.blacklist'))));
41
+
42
+ $disabledFunctions = array_merge($phpDisabledFunctions, $suhosinDisabledFunctions);
43
+
44
+ $disabled = false;
45
+
46
+ if (in_array('exec', $disabledFunctions)) {
47
+ $disabled = true;
48
+ }
49
+
50
+ if(function_exists('exec') === true && $disabled === false) {
51
+ $r = true;
52
+ }
53
+
54
+ return $r;
55
+ }
56
+
57
/**
58
* Optimized way of getting logging flag from config.
59
*
app/code/community/Apptrian/ImageOptimizer/Model/Cron.php CHANGED
@@ -16,22 +16,30 @@ class Apptrian_ImageOptimizer_Model_Cron
16
17
$helper = Mage::helper('apptrian_imageoptimizer');
18
19
- try {
20
-
21
- $result1 = $helper->scanAndReindex();
22
- $result2 = $helper->optimize();
23
-
24
- if ($result1 !== true ) {
25
- Mage::log('Apptrian ImageOptimizer - Cron - Process - scanAndReindex() method failed.');
26
- }
27
-
28
- if ($result2 !== true ) {
29
- Mage::log('Apptrian ImageOptimizer - Cron - Process - optimize() method failed.');
30
}
31
32
- } catch (Exception $e) {
33
-
34
- Mage::log($e);
35
36
}
37
16
17
$helper = Mage::helper('apptrian_imageoptimizer');
18
19
+ if ($helper->isExecFunctionEnabled()) {
20
+
21
+ try {
22
+
23
+ $result1 = $helper->scanAndReindex();
24
+ $result2 = $helper->optimize();
25
+
26
+ if ($result1 !== true ) {
27
+ Mage::log('Apptrian Image Optimizer - Cron - Process - scanAndReindex() method failed.');
28
+ }
29
+
30
+ if ($result2 !== true ) {
31
+ Mage::log('Apptrian Image Optimizer - Cron - Process - optimize() method failed.');
32
+ }
33
+
34
+ } catch (Exception $e) {
35
+
36
+ Mage::log($e);
37
+
38
}
39
+
40
+ } else {
41
42
+ Mage::log('Apptrian Image Optimizer - Cron - Process - Optimization failed because PHP exec() function is disabled.');
43
44
}
45
app/code/community/Apptrian/ImageOptimizer/controllers/Adminhtml/OptimizerController.php CHANGED
@@ -38,22 +38,31 @@ class Apptrian_ImageOptimizer_Adminhtml_OptimizerController extends Mage_Adminht
38
{
39
40
$helper = Mage::helper('apptrian_imageoptimizer');
41
-
42
- try {
43
-
44
- $helper->optimize();
45
-
46
- $message = $this->__('Optimization operations completed successfully.');
47
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
48
-
49
- } catch (Exception $e) {
50
-
51
- $message = $this->__('Optimization failed.');
52
Mage::getSingleton('adminhtml/session')->addError($message);
53
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
54
-
55
}
56
-
57
$url = Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit/section/apptrian_imageoptimizer');
58
Mage::app()->getResponse()->setRedirect($url);
59
38
{
39
40
$helper = Mage::helper('apptrian_imageoptimizer');
41
+
42
+ if ($helper->isExecFunctionEnabled()) {
43
+
44
+ try {
45
+
46
+ $helper->optimize();
47
+
48
+ $message = $this->__('Optimization operations completed successfully.');
49
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
50
+
51
+ } catch (Exception $e) {
52
+
53
+ $message = $this->__('Optimization failed.');
54
+ Mage::getSingleton('adminhtml/session')->addError($message);
55
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
56
+
57
+ }
58
+
59
+ } else {
60
+
61
+ $message = $this->__('Optimization failed because PHP exec() function is disabled.');
62
Mage::getSingleton('adminhtml/session')->addError($message);
63
+
64
}
65
+
66
$url = Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit/section/apptrian_imageoptimizer');
67
Mage::app()->getResponse()->setRedirect($url);
68
app/code/community/Apptrian/ImageOptimizer/etc/config.xml CHANGED
@@ -11,7 +11,7 @@
11
<config>
12
<modules>
13
<Apptrian_ImageOptimizer>
14
- <version>1.0.0</version>
15
</Apptrian_ImageOptimizer>
16
</modules>
17
<global>
11
<config>
12
<modules>
13
<Apptrian_ImageOptimizer>
14
+ <version>1.0.1</version>
15
</Apptrian_ImageOptimizer>
16
</modules>
17
<global>
app/locale/en_US/Apptrian_ImageOptimizer.csv CHANGED
@@ -11,6 +11,7 @@
11
"Scanning and reindexing failed.","Scanning and reindexing failed."
12
"Optimization operations completed successfully.","Optimization operations completed successfully."
13
"Optimization failed.","Optimization failed."
14
"Info","Info"
15
"Image Optimizer","Image Optimizer"
16
"Apptrian Extensions","Apptrian Extensions"
11
"Scanning and reindexing failed.","Scanning and reindexing failed."
12
"Optimization operations completed successfully.","Optimization operations completed successfully."
13
"Optimization failed.","Optimization failed."
14
+ "Optimization failed because PHP exec() function is disabled.","Optimization failed because PHP exec() function is disabled."
15
"Info","Info"
16
"Image Optimizer","Image Optimizer"
17
"Apptrian Extensions","Apptrian Extensions"
package.xml CHANGED
@@ -1,18 +1,18 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>Apptrian_Image_Optimizer</name>
4
- <version>1.0.0</version>
5
<stability>stable</stability>
6
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
<channel>community</channel>
8
<extends/>
9
<summary>Optimize your images, reduce their file size without losing image quality and speed up your site.</summary>
10
<description>Apptrian Image Optimizer will optimize your images (GIF, JPG, PNG) reduce their file size without losing image quality and speed up your site. Extension is very easy to install and use. You can optimize images by clicking a button in Magento Admin or automatically by a configurable cron job. If you are an advanced user you will be pleased to know that extension is fully configurable. You can change optimization options even swap utilities used for optimization with the ones you like. (By default our extension is using optimization utilities recommended by Google.)</description>
11
- <notes>Initial release.</notes>
12
<authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
13
- <date>2015-04-14</date>
14
- <time>13:00:01</time>
15
- <contents><target name="magecommunity"><dir name="Apptrian"><dir name="ImageOptimizer"><dir name="Block"><file name="About.php" hash="834da469edf8670760c18af77f818964"/><dir name="Adminhtml"><dir name="Button"><file name="Optimize.php" hash="c23d84e058178b2dae14e7d0840d2ca8"/><file name="Scan.php" hash="15f74acc0e0ccd3af620ca50ca873dc6"/></dir><file name="Stats.php" hash="7eadf213828ddad56a97d16ac018f586"/></dir><file name="Info.php" hash="ce3f500107f0522d663e5e5ca9ab6ae8"/></dir><dir name="Helper"><file name="Data.php" hash="0c77f9b26cf7661a779a94beec29408f"/><file name="Utility.php" hash="8da906b04a33011753123591787d8f38"/></dir><dir name="Model"><dir name="Config"><file name="Batchsize.php" hash="20ad8a6109396ab46dd6869729461c82"/><file name="Cron.php" hash="287ca20c0c2858bb084c1027d9db7df9"/><file name="Options.php" hash="149fed0c7d4ff5e3f5450fb508e54665"/><file name="Path.php" hash="3551ddc448355408a31f364f1d7e9c72"/><file name="Paths.php" hash="106f13dd1ac686b2ff114f7dea305f60"/><file name="Utility.php" hash="ee8f797047402554d15a03d5dffc7d6e"/></dir><file name="Cron.php" hash="9ec861ba9fe89510130a87763f53330a"/><file name="File.php" hash="c9dfb79b4a69bee1e58e7653b73df162"/><dir name="Resource"><dir name="File"><file name="Collection.php" hash="28d975785edc53cb54402770ab5259d1"/></dir><file name="File.php" hash="fe4c2607d55d8407b4e7b36c0f250af8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="OptimizerController.php" hash="0b2d4af205b34a84645b1f7492301547"/></dir></dir><dir name="etc"><file name="config.xml" hash="63bfdb7f6cdd25475b333164787c747f"/><file name="system.xml" hash="b197c5428f867227c18caa5a2535d3f3"/></dir><dir name="sql"><dir name="apptrian_imageoptimizer_setup"><file name="install-1.0.0.php" hash="d34e04d6467ec06481042445ccfea24b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="apptrian_imageoptimizer.xml" hash="257c63a9c81f7d901dbf7668c9d0387a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_ImageOptimizer.xml" hash="784bdacc19fadc96f17ae7e82c962b4b"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_ImageOptimizer.csv" hash="7ce29c3e80103ad54ac5dd8ab3042cd9"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="apptrian_imageoptimizer.css" hash="79907671228ae14227423cdfce413ecc"/></dir></dir></dir></dir></target><target name="magelib"><dir name="apptrian"><dir name="imageoptimizer"><dir name="elf32"><file name="gifsicle" hash="2583e5ceecf67a058fba2858986bb37f"/><file name="jpegoptim" hash="8a035613dd1a9467e5fe47c88a774104"/><file name="optipng" hash="fb1334c73c7a91858a1816b05bfa3133"/></dir><dir name="elf64"><file name="gifsicle" hash="13adc57a621501a27a19443cb587ab2b"/><file name="jpegoptim" hash="8a035613dd1a9467e5fe47c88a774104"/><file name="optipng" hash="8fbf61c7e24f90128bbc138ddb671201"/></dir><dir name="win32"><file name="gifsicle.exe" hash="574a9274bbd4aec6a905b64b7da79617"/><file name="jpegoptim.exe" hash="cb4fa736e8b60aebfebff583d0ea6f34"/><file name="optipng.exe" hash="e3d154829ea57a0bdd88b080f6851265"/></dir><dir name="win64"><file name="gifsicle.exe" hash="c7fe0fc6744a4e5303f8d924ee08a8d3"/><file name="jpegoptim.exe" hash="cb4fa736e8b60aebfebff583d0ea6f34"/><file name="optipng.exe" hash="e3d154829ea57a0bdd88b080f6851265"/></dir></dir></dir></target></contents>
16
<compatible/>
17
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>Apptrian_Image_Optimizer</name>
4
+ <version>1.0.1</version>
5
<stability>stable</stability>
6
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
<channel>community</channel>
8
<extends/>
9
<summary>Optimize your images, reduce their file size without losing image quality and speed up your site.</summary>
10
<description>Apptrian Image Optimizer will optimize your images (GIF, JPG, PNG) reduce their file size without losing image quality and speed up your site. Extension is very easy to install and use. You can optimize images by clicking a button in Magento Admin or automatically by a configurable cron job. If you are an advanced user you will be pleased to know that extension is fully configurable. You can change optimization options even swap utilities used for optimization with the ones you like. (By default our extension is using optimization utilities recommended by Google.)</description>
11
+ <notes>* Fixed small bug related to exec() function</notes>
12
<authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
13
+ <date>2015-04-16</date>
14
+ <time>21:08:35</time>
15
+ <contents><target name="magecommunity"><dir name="Apptrian"><dir name="ImageOptimizer"><dir name="Block"><file name="About.php" hash="834da469edf8670760c18af77f818964"/><dir name="Adminhtml"><dir name="Button"><file name="Optimize.php" hash="c23d84e058178b2dae14e7d0840d2ca8"/><file name="Scan.php" hash="15f74acc0e0ccd3af620ca50ca873dc6"/></dir><file name="Stats.php" hash="7eadf213828ddad56a97d16ac018f586"/></dir><file name="Info.php" hash="ce3f500107f0522d663e5e5ca9ab6ae8"/></dir><dir name="Helper"><file name="Data.php" hash="ee204272ca8ffa3520047bf4f2284ffd"/><file name="Utility.php" hash="8da906b04a33011753123591787d8f38"/></dir><dir name="Model"><dir name="Config"><file name="Batchsize.php" hash="20ad8a6109396ab46dd6869729461c82"/><file name="Cron.php" hash="287ca20c0c2858bb084c1027d9db7df9"/><file name="Options.php" hash="149fed0c7d4ff5e3f5450fb508e54665"/><file name="Path.php" hash="3551ddc448355408a31f364f1d7e9c72"/><file name="Paths.php" hash="106f13dd1ac686b2ff114f7dea305f60"/><file name="Utility.php" hash="ee8f797047402554d15a03d5dffc7d6e"/></dir><file name="Cron.php" hash="7d32b6cfed67c0bc620ee488c0edc6c6"/><file name="File.php" hash="c9dfb79b4a69bee1e58e7653b73df162"/><dir name="Resource"><dir name="File"><file name="Collection.php" hash="28d975785edc53cb54402770ab5259d1"/></dir><file name="File.php" hash="fe4c2607d55d8407b4e7b36c0f250af8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="OptimizerController.php" hash="dfb1347ebc3c85ce5dda4a7e4782291b"/></dir></dir><dir name="etc"><file name="config.xml" hash="d1862168d6926bebe015f3d3d28ba4f1"/><file name="system.xml" hash="b197c5428f867227c18caa5a2535d3f3"/></dir><dir name="sql"><dir name="apptrian_imageoptimizer_setup"><file name="install-1.0.0.php" hash="d34e04d6467ec06481042445ccfea24b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="apptrian_imageoptimizer.xml" hash="257c63a9c81f7d901dbf7668c9d0387a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_ImageOptimizer.xml" hash="784bdacc19fadc96f17ae7e82c962b4b"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_ImageOptimizer.csv" hash="1cd68289ca79e9948ac2dea635e063a2"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="apptrian_imageoptimizer.css" hash="79907671228ae14227423cdfce413ecc"/></dir></dir></dir></dir></target><target name="magelib"><dir name="apptrian"><dir name="imageoptimizer"><dir name="elf32"><file name="gifsicle" hash="2583e5ceecf67a058fba2858986bb37f"/><file name="jpegoptim" hash="8a035613dd1a9467e5fe47c88a774104"/><file name="optipng" hash="fb1334c73c7a91858a1816b05bfa3133"/></dir><dir name="elf64"><file name="gifsicle" hash="13adc57a621501a27a19443cb587ab2b"/><file name="jpegoptim" hash="8a035613dd1a9467e5fe47c88a774104"/><file name="optipng" hash="8fbf61c7e24f90128bbc138ddb671201"/></dir><dir name="win32"><file name="gifsicle.exe" hash="574a9274bbd4aec6a905b64b7da79617"/><file name="jpegoptim.exe" hash="cb4fa736e8b60aebfebff583d0ea6f34"/><file name="optipng.exe" hash="e3d154829ea57a0bdd88b080f6851265"/></dir><dir name="win64"><file name="gifsicle.exe" hash="c7fe0fc6744a4e5303f8d924ee08a8d3"/><file name="jpegoptim.exe" hash="cb4fa736e8b60aebfebff583d0ea6f34"/><file name="optipng.exe" hash="e3d154829ea57a0bdd88b080f6851265"/></dir></dir></dir></target></contents>
16
<compatible/>
17
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
</package>