Created
November 30, 2015 08:52
-
-
Save alpharder/7ca95eeddefcb108fb42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/controllers/backend/exim.php b/app/controllers/backend/exim.php | |
index 22409f8..92bbbae 100644 | |
--- a/app/controllers/backend/exim.php | |
+++ b/app/controllers/backend/exim.php | |
@@ -1793,6 +1793,9 @@ function fn_export_build_conditions($pattern, $options) | |
return $conditions; | |
} | |
+/** | |
+ * @deprecated, use fn_exim_quote instead | |
+ */ | |
function fn_exim_set_quotes($value, $quote = "'") | |
{ | |
if (is_array($value) && !empty($value)) { | |
@@ -1810,6 +1813,16 @@ function fn_exim_set_quotes($value, $quote = "'") | |
return $result; | |
} | |
+function fn_exim_quote(&$value, $quote = "'") | |
+{ | |
+ if (is_string($value)) { | |
+ $value = $quote . $value . $quote; | |
+ } elseif (is_array($value) && !empty($value)) { | |
+ foreach ($value as $k => &$v) { | |
+ fn_exim_quote($v, $quote); | |
+ } | |
+ } | |
+} | |
function fn_exim_get_values($values, $pattern, $options, $vars = array(), $data = array(), $quote = "'") | |
{ | |
@@ -1818,24 +1831,29 @@ function fn_exim_get_values($values, $pattern, $options, $vars = array(), $data | |
foreach ($values as $field => $value) { | |
if (is_array($value)) { | |
- $val[$field] = fn_exim_set_quotes($value); | |
- | |
+ $val[$field] = $value; | |
+ fn_exim_quote($val[$field]); | |
} else { | |
$operator = substr($value, 0, 1); | |
if ($operator === '@') { | |
$opt = str_replace('@', '', $value); | |
- $val[$field] = (isset($options[$opt])) ? fn_exim_set_quotes($options[$opt], $quote) : ''; | |
+ $val[$field] = isset($options[$opt]) ? $options[$opt] : ''; | |
+ | |
+ isset($options[$opt]) && fn_exim_quote($val[$field], $quote); | |
} elseif ($value === '#this') { | |
if (!empty($vars['field'])) { | |
- $val[$field] = fn_exim_set_quotes($data[$vars['field']], $quote); | |
+ $val[$field] = $data[$vars['field']]; | |
} else { | |
- $val[$field] = fn_exim_set_quotes($data[$field], $quote); | |
+ $val[$field] = $data[$field]; | |
} | |
+ fn_exim_quote($val[$field], $quote); | |
} elseif ($value === '#key') { | |
- $val[$field] = (sizeof($vars['key']) == 1) ? reset($vars['key']) : (isset($vars['key'][$field]) ? $vars['key'][$field] : $vars['key']); | |
+ $val[$field] = (sizeof($vars['key']) == 1) | |
+ ? reset($vars['key']) | |
+ : (isset($vars['key'][$field]) ? $vars['key'][$field] : $vars['key']); | |
} elseif ($operator === '&') { | |
$val[$field] = $pattern['table'] . '.' . substr($value, 1); | |
@@ -1848,7 +1866,8 @@ function fn_exim_get_values($values, $pattern, $options, $vars = array(), $data | |
} | |
} elseif ($value === '#lang_code') { | |
- $val[$field] = !empty($vars['lang_code']) ? fn_exim_set_quotes($vars['lang_code'], $quote) : ''; | |
+ $val[$field] = empty($vars['lang_code']) ? '' : $vars['lang_code']; | |
+ empty($vars['lang_code']) || fn_exim_quote($val[$field], $quote); | |
} elseif ($value === '#row') { | |
$val[$field] = $data; | |
@@ -1859,14 +1878,15 @@ function fn_exim_get_values($values, $pattern, $options, $vars = array(), $data | |
} elseif ($operator === '$') { | |
$opt = str_replace('$', '', $value); | |
if (isset($data[$opt])) { | |
- $data[$opt] = fn_exim_set_quotes($data[$opt], $quote); | |
+ fn_exim_quote($data[$opt], $quote); | |
$val[$field] = &$data[$opt]; | |
} else { | |
$val[$field] = ''; | |
} | |
} else { | |
- $val[$field] = fn_exim_set_quotes($value, $quote); | |
+ $val[$field] = $value; | |
+ fn_exim_quote($val[$field], $quote); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment