From: Roland Haeder Date: Fri, 3 Apr 2015 19:42:18 +0000 (+0200) Subject: Sometimes a whole array needs to be set in session (installer). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7b595f2003d7201127d57bc4fa29d132409d604d;p=mailer.git Sometimes a whole array needs to be set in session (installer). Signed-off-by: Roland Häder --- diff --git a/inc/ajax-functions.php b/inc/ajax-functions.php index 90e48a1a02..39c65bd5fb 100644 --- a/inc/ajax-functions.php +++ b/inc/ajax-functions.php @@ -66,6 +66,7 @@ function initAjax () { function setAjaxReplyContent ($content) { // Log message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content()=' . strlen($content)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content[]=' . gettype($content)); // Set it, but with URL encoding $GLOBALS['ajax_reply']['reply_content'] = urlencode(doFinalCompilation($content, FALSE)); diff --git a/inc/session-functions.php b/inc/session-functions.php index 8feefa3302..dd78b81d4f 100644 --- a/inc/session-functions.php +++ b/inc/session-functions.php @@ -45,10 +45,15 @@ function setSession ($var, $value) { // Trim value and session variable $var = trim(secureString($var)); - $value = trim($value); + + // Is the value no array? + if (!is_array($value)) { + // Then trim it + $value = trim($value); + } // END - if // Is the session variable set? - if (('' . $value . '' == '') && (isSessionVariableSet($var))) { + if ((!is_array($value)) && ('' . $value . '' == '') && (isSessionVariableSet($var))) { // Remove the session //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UNSET:' . $var . '=' . getSession($var)); unset($_SESSION[$var]); @@ -59,7 +64,7 @@ function setSession ($var, $value) { // PHP version < 5.3.0 return session_unregister($var); } - } elseif (('' . $value . '' != '') && (!isSessionVariableSet($var))) { + } elseif ((is_array($value)) || (('' . $value . '' != '') && (!isSessionVariableSet($var)))) { // Set session //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SET:' . $var . '=' . $value); $_SESSION[$var] = $value; diff --git a/inc/template-functions.php b/inc/template-functions.php index caa72894e6..0526f1b40b 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -226,6 +226,9 @@ function compileFinalOutput () { // Main compilation loop function doFinalCompilation ($code, $insertComments = TRUE, $enableCodes = TRUE) { + // Code must not be an array (happens in installer) + assert(!is_array($code)); + // Insert comments? (Only valid with HTML templates, of course) enableTemplateHtml($insertComments); @@ -240,6 +243,7 @@ function doFinalCompilation ($code, $insertComments = TRUE, $enableCodes = TRUE) // Compile it //* DEBUG: */ debugOutput('
'.lineNumberCode($code).'
'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'code[]=' . gettype($code) . ',enableCodes[]=' . gettype($enableCodes)); $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code), $enableCodes)) . '";'; //* DEBUG: */ if (!$insertComments) print('EVAL=
'.lineNumberCode($eval).'
'); eval($eval); diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index a2056a9246..002159c42a 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -3572,8 +3572,14 @@ function getGenericHashFileName () { // "Compiles" the given value and sets it in given key function setSessionCompiled ($key, $value) { - // "Compile" the value - $value = doFinalCompilation(compileRawCode($value)); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key[]=' . gettype($key) . ',value[]=' . gettype($value)); + + // Is the value not an array? + if (!is_array($value)) { + // "Compile" the value + $value = doFinalCompilation(compileRawCode($value)); + } // END - if // And set it return setSession($key, $value);