Permalink
Browse files

Move is_suhosin_blacklisted to Common.php

code fixed based on style guideline.
  • Loading branch information...
1 parent c9da86f commit 7ae7dce522538f4af356d889b98ad427107ef920 @swznd committed Sep 18, 2012
Showing with 39 additions and 39 deletions.
  1. +36 −0 system/core/Common.php
  2. +3 −39 system/libraries/Upload.php
View
@@ -637,5 +637,41 @@ function _stringify_attributes($attributes, $js = FALSE)
}
}
+// ------------------------------------------------------------------------
+
+if( ! function_exists('is_suhosin_blacklist'))
+{
+ /**
+ * Check Suhosin Blacklist
+ *
+ *
+ * @param string
+ * @return bool
+ */
+ function is_suhosin_blacklisted($func)
+ {
+ if (extension_loaded('suhosin'))
+ {
+ $blacklist = @ini_get('suhosin.executor.func.blacklist');
+ if ( ! empty($blacklist))
+ {
+ if (strpos($blacklist,',') !== FALSE)
+ {
+ $blackarray = explode(',',trim($blacklist));
+ }
+ else {
+ $blackarray[] = $blacklist;
+ }
+
+ if (in_array($func,$blackarray))
+ {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+}
+
/* End of file Common.php */
/* Location: ./system/core/Common.php */
@@ -1033,7 +1033,7 @@ protected function _file_mime_type($file)
? 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'
: 'file --brief --mime '.$file['tmp_name'].' 2>&1';
- if (function_exists('exec') && !$this->_is_suhosin_blacklisted('exec'))
+ if (function_exists('exec') && ! is_suhosin_blacklisted('exec'))
{
/* This might look confusing, as $mime is being populated with all of the output when set in the second parameter.
* However, we only neeed the last line, which is the actual return value of exec(), and as such - it overwrites
@@ -1048,7 +1048,7 @@ protected function _file_mime_type($file)
}
}
- if ( (bool) @ini_get('safe_mode') === FALSE && function_exists('shell_exec') && !$this->_is_suhosin_blacklisted('shell_exec'))
+ if ( (bool) @ini_get('safe_mode') === FALSE && function_exists('shell_exec') && ! is_suhosin_blacklisted('shell_exec'))
{
$mime = @shell_exec($cmd);
if (strlen($mime) > 0)
@@ -1062,7 +1062,7 @@ protected function _file_mime_type($file)
}
}
- if (function_exists('popen') && !$this->_is_suhosin_blacklisted('popen'))
+ if (function_exists('popen') && ! is_suhosin_blacklisted('popen'))
{
$proc = @popen($cmd, 'r');
if (is_resource($proc))
@@ -1094,42 +1094,6 @@ protected function _file_mime_type($file)
$this->file_type = $file['type'];
}
-
- // --------------------------------------------------------------------
-
- /**
- * Check Suhosin Blacklist
- *
- *
- * @param string
- * @return bool
- */
-
- function _is_suhosin_blacklisted($func)
- {
- if(extension_loaded('suhosin'))
- {
- $blacklist = @ini_get("suhosin.executor.func.blacklist");
- if(!empty($blacklist))
- {
- if(strpos($blacklist,',') !== false)
- {
- $blackarray = explode(',',$blacklist);
- }
- else {
- $blackarray[] = $blacklist;
- }
-
- if(in_array($func,$blackarray))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- // --------------------------------------------------------------------
}

0 comments on commit 7ae7dce

Please sign in to comment.