diff --git a/include/admin/installer.inc.php b/include/admin/installer.inc.php index a7b2651f..0ea36ea7 100644 --- a/include/admin/installer.inc.php +++ b/include/admin/installer.inc.php @@ -28,7 +28,7 @@ if (defined('S9Y_DATA_PATH')) { $data['basedir'] = $basedir; $data['phpversion'] = phpversion(); -$data['versionInstalled'] = $serendipity['versionInstalled']; +$data['versionInstalled'] = $serendipity['versionInstalled'] ?? null; $data['templatePath'] = $serendipity['templatePath']; $data['installerHTTPPath'] = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . '/'); // since different OS handlers for enddir @@ -93,9 +93,9 @@ if ( sizeof($_POST) > 1 && $serendipity['GET']['step'] == '3' ) { } } -$data['s9yGETstep'] = $serendipity['GET']['step']; +$data['s9yGETstep'] = $serendipity['GET']['step'] ?? null; -if ( (int)$serendipity['GET']['step'] == 0 ) { +if ( (int)($serendipity['GET']['step'] ?? null) == 0 ) { $data['getstepint0'] = true; $data['print_ERRORS_ARE_DISPLAYED_IN'] = sprintf(ERRORS_ARE_DISPLAYED_IN, serendipity_installerResultDiagnose(S9Y_I_ERROR, RED), serendipity_installerResultDiagnose(S9Y_I_WARNING, YELLOW), serendipity_installerResultDiagnose(S9Y_I_SUCCESS, GREEN)); $data['s9yversion'] = $serendipity['version']; @@ -308,12 +308,12 @@ if ( (int)$serendipity['GET']['step'] == 0 ) { } } - $data['showWritableNote'] = $showWritableNote; + $data['showWritableNote'] = $showWritableNote ?? null; $data['errorCount'] = $errorCount; } elseif ( $serendipity['GET']['step'] == '2a' ) { $config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE, null, array('simpleInstall')); - $data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from, true, false, false); + $data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from ?? false, true, false, false); } elseif ( $serendipity['GET']['step'] == '2b' ) { $config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE); @@ -321,9 +321,12 @@ if ( (int)$serendipity['GET']['step'] == 0 ) { } elseif ( $serendipity['GET']['step'] == '3' ) { $serendipity['dbPrefix'] = $_POST['dbPrefix']; - - $t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true); - $data['authors_query'] = $t; + try { + $t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true); + $data['authors_query'] = $t; + } catch (PDOException $e) { + $t = null; + } if ( is_array($t) ) { // void @@ -361,7 +364,7 @@ if ( (int)$serendipity['GET']['step'] == 0 ) { include_once dirname(dirname(__FILE__)) . "/functions.inc.php"; -if (!is_object($serendipity['smarty'])) { +if (!is_object($serendipity['smarty'] ?? null)) { serendipity_smarty_init(); } diff --git a/include/db/db.inc.php b/include/db/db.inc.php index 4a03d803..279b931c 100644 --- a/include/db/db.inc.php +++ b/include/db/db.inc.php @@ -3,7 +3,7 @@ # All rights reserved. See LICENSE file for licensing details // PHP 5.5 compat, no longer use deprecated mysql -if ($serendipity['dbType'] == 'mysql' && (version_compare(PHP_VERSION, '5.5.0') >= 0 || !function_exists('mysql_connect'))) { +if ($serendipity['dbType'] ?? '' == 'mysql' && (version_compare(PHP_VERSION, '5.5.0') >= 0 || !function_exists('mysql_connect'))) { $serendipity['dbType'] = 'mysqli'; } diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index 24112f44..2a81911b 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -266,7 +266,7 @@ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath', $force } else { $directories[] = $serendipity['template_backend'] . '/'; # Since 2.0 s9y can have a independent backend theme } - $directories[] = $serendipity['template_engine'] . '/'; # themes can set an engine, which will be used if they do not have the file + $directories[] = $serendipity['template_engine'] ?? null . '/'; # themes can set an engine, which will be used if they do not have the file $directories[] = $serendipity['defaultTemplate'] .'/'; # the default theme is the last place we will look in, serving as pure fallback $directories = array_unique($directories); # save performance by not checking for file existence multiple times in the same directory @@ -674,7 +674,7 @@ function serendipity_load_userdata($username) { * @return boolean TRUE when logged in, FALSE when not. */ function serendipity_userLoggedIn() { - if ($_SESSION['serendipityAuthedUser'] === true && IS_installed) { + if ($_SESSION['serendipityAuthedUser'] ?? false === true && IS_installed) { return true; } else { return false; @@ -798,7 +798,7 @@ function serendipity_deleteCookie($name) { function serendipity_is_iframe() { global $serendipity; - if ($serendipity['GET']['is_iframe'] && is_array($_SESSION['save_entry'])) { + if ($serendipity['GET']['is_iframe'] ?? false && is_array($_SESSION['save_entry'])) { if (!is_object($serendipity['smarty'])) { // We need smarty also in the iframe to load a template's config.inc.php and register possible event hooks. serendipity_smarty_init(); diff --git a/include/functions_installer.inc.php b/include/functions_installer.inc.php index bf6fc7fa..5334f3b6 100644 --- a/include/functions_installer.inc.php +++ b/include/functions_installer.inc.php @@ -290,7 +290,7 @@ function serendipity_query_default($optname, $default, $usertemplate = false, $t function serendipity_parseTemplate($filename, $areas = null, $onlyFlags=null) { global $serendipity; - $userlevel = $serendipity['serendipityUserlevel']; + $userlevel = $serendipity['serendipityUserlevel'] ?? null; if ( !IS_installed ) { $userlevel = USERLEVEL_ADMIN; @@ -425,11 +425,10 @@ function serendipity_guessInput($type, $name, $value='', $default='') { break; case 'list': - $cval = (string)$value; $default = (array)$default; foreach ($default as $k => $v) { - $selected = ((string)$k == (string)$value); - if (empty($cval) && ((string)$k === 'false' || (string)$k === null)) { + $selected = ($k == $value); + if (empty($value) && ((string)$k === 'false' || (string)$k === null)) { $selected = true; } $curOptions[$name][$k]['selected'] = $selected; @@ -469,7 +468,7 @@ function serendipity_printConfigTemplate($config, $from = false, $noForm = false foreach ($config as &$category) { foreach ($category['items'] as &$item) { - $value = $from[$item['var']]; + $value = $from[$item['var']] ?? false; /* Calculate value if we are not installed, how clever :) */ if ($from == false) { @@ -485,7 +484,7 @@ function serendipity_printConfigTemplate($config, $from = false, $noForm = false $value = ''; } - if (!$showDangerous && $item['view'] == 'dangerous') { + if (!$showDangerous && ($item['view'] ?? null) == 'dangerous') { continue; } @@ -892,7 +891,7 @@ function serendipity_updateConfiguration() { // Check permission set. Changes to blogConfiguration or siteConfiguration items // always required authorid = 0, so that it be not specific to a userlogin - if ( $serendipity['serendipityUserlevel'] >= $item['userlevel'] || IS_installed === false ) { + if ( ($serendipity['serendipityUserlevel'] ?? 0) >= $item['userlevel'] || IS_installed === false ) { $authorid = 0; } elseif ($item['permission'] == 'blogConfiguration' && serendipity_checkPermission('blogConfiguration')) { $authorid = 0; @@ -904,8 +903,7 @@ function serendipity_updateConfiguration() { if (is_array($_POST[$item['var']])) { // Arrays not allowed. Use first index value. - list($a_key, $a_val) = each($_POST[$item['var']]); - $_POST[$item['var']] = $a_key; + $_POST[$item['var']] = array_key_first($_POST[$item['var']]); // If it still is an array, munge it all together. if (is_array($_POST[$item['var']])) { diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index 8bd818a1..d758e8c4 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -492,7 +492,7 @@ function serendipity_buildPermalinks() { */ function serendipity_rewriteURL($path, $key='baseURL', $forceNone = false) { global $serendipity; - return $serendipity[$key] . ($serendipity['rewrite'] == 'none' || ($serendipity['rewrite'] != 'none' && $forceNone) ? $serendipity['indexFile'] . '?/' : '') . $path; + return ($serendipity[$key] ?? null) . ($serendipity['rewrite'] == 'none' || ($serendipity['rewrite'] != 'none' && $forceNone) ? $serendipity['indexFile'] . '?/' : '') . $path; } /** diff --git a/include/functions_smarty.inc.php b/include/functions_smarty.inc.php index 7802af53..6a5fc206 100644 --- a/include/functions_smarty.inc.php +++ b/include/functions_smarty.inc.php @@ -890,7 +890,7 @@ function serendipity_smarty_init($vars = array()) { if (!isset($serendipity['smarty'])) { - $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template']; + $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . ($serendipity['template'] ?? null); if (!defined('IN_serendipity_admin') && file_exists($template_dir . '/template.inc.php')) { // If this file exists, a custom template engine will be loaded. @@ -1013,8 +1013,8 @@ function serendipity_smarty_init($vars = array()) { // When templates are switched, append a specific version string to make sure the browser does not cache the CSS if (strstr($serendipity['smarty_vars']['head_link_stylesheet'], '?')) { - $serendipity['smarty_vars']['head_link_stylesheet'] .= '&v=' . $serendipity['last_template_change']; - $serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '&v=' . $serendipity['last_template_change']; + $serendipity['smarty_vars']['head_link_stylesheet'] .= '&v=' . ($serendipity['last_template_change'] ?? null); + $serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '&v=' . ($serendipity['last_template_change'] ?? null); } else { $serendipity['smarty_vars']['head_link_stylesheet'] .= '?v=' . $serendipity['last_template_change']; $serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '?v=' . $serendipity['last_template_change']; @@ -1029,7 +1029,7 @@ function serendipity_smarty_init($vars = array()) { } if (strstr($serendipity['smarty_vars']['head_link_script'], '?')) { - $serendipity['smarty_vars']['head_link_script'] .= '&v=' . $serendipity['last_template_change']; + $serendipity['smarty_vars']['head_link_script'] .= '&v=' . ($serendipity['last_template_change'] ?? null); } else { $serendipity['smarty_vars']['head_link_script'] .= '?v=' . $serendipity['last_template_change']; } @@ -1080,20 +1080,20 @@ function serendipity_smarty_init($vars = array()) { 'use_popups' => $serendipity['enablePopup'] ?? null, 'use_backendpopups' => $serendipity['enableBackendPopup'] ?? null, 'force_backendpopups' => $force_backendpopups, - 'is_embedded' => (!$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false) ? false : true, + 'is_embedded' => $serendipity['embed'] ?? false, 'is_raw_mode' => $serendipity['smarty_raw_mode'] ?? null, 'is_logged_in' => serendipity_userLoggedIn(), 'entry_id' => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) ? $serendipity['GET']['id'] : false, 'is_single_entry' => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])), - 'blogTitle' => $serendipity['blogTitle'], + 'blogTitle' => $serendipity['blogTitle'] ?? null, 'blogSubTitle' => (!empty($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : ''), - 'blogDescription' => $serendipity['blogDescription'], + 'blogDescription' => $serendipity['blogDescription'] ?? null, - 'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'], - 'serendipityDefaultBaseURL' => $serendipity['defaultBaseURL'], - 'serendipityBaseURL' => $serendipity['baseURL'], + 'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'] ?? null, + 'serendipityDefaultBaseURL' => $serendipity['defaultBaseURL'] ?? null, + 'serendipityBaseURL' => $serendipity['baseURL'] ?? null, 'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '', 'serendipityIndexFile' => $serendipity['indexFile'], 'serendipityVersion' => ($serendipity['expose_s9y'] ? $serendipity['version'] : ''), @@ -1145,7 +1145,7 @@ function serendipity_smarty_init($vars = array()) { } - if (is_array($template_loaded_config)) { + if (is_array($template_loaded_config ?? null)) { $template_vars =& $template_loaded_config; $serendipity['smarty']->assignByRef('template_option', $template_vars); } elseif (is_array($template_config)) { @@ -1217,7 +1217,7 @@ function serendipity_smarty_shutdown($serendipity_directory = '') { function serendipity_smarty_show($template, $data = null, $debugtype = null, $debug = null) { global $serendipity; - if (!is_object($serendipity['smarty'])) { + if (!is_object($serendipity['smarty'] ?? null)) { serendipity_smarty_init(); } diff --git a/include/plugin_api.inc.php b/include/plugin_api.inc.php index e37f04b8..cf007b56 100644 --- a/include/plugin_api.inc.php +++ b/include/plugin_api.inc.php @@ -1134,7 +1134,7 @@ class serendipity_plugin_api return false; } - if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($event_name)) { + if ($serendipity['enablePluginACL'] ?? false && !serendipity_hasPluginPermissions($event_name)) { return false; } @@ -1182,7 +1182,7 @@ class serendipity_plugin_api } } - if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($plugin)) { + if ($serendipity['enablePluginACL'] ?? false && !serendipity_hasPluginPermissions($plugin)) { continue; } $plugins[$plugin]['p']->event_hook($event_name, $bag, $eventData, $addData); diff --git a/include/serendipity_smarty_class.inc.php b/include/serendipity_smarty_class.inc.php index 05319433..f97ea451 100644 --- a/include/serendipity_smarty_class.inc.php +++ b/include/serendipity_smarty_class.inc.php @@ -123,7 +123,7 @@ class Serendipity_Smarty extends Smarty $template_dirs = array(); // first add template path - $template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template']; + $template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . ($serendipity['template'] ?? null); // then fallback engines (which should never be a comma separated list) if ($template_engine) { $p = explode(',', $template_engine); diff --git a/serendipity_admin.php b/serendipity_admin.php index 08781152..7f26cee1 100644 --- a/serendipity_admin.php +++ b/serendipity_admin.php @@ -84,7 +84,7 @@ $no_footer = (isset($serendipity['GET']['noFooter']) || isset($serendipity['POST $use_installer = (!isset($serendipity['serendipityPath']) || IS_installed === false || IS_up2date === false ); -$post_action = $serendipity['POST']['action']; +$post_action = $serendipity['POST']['action'] ?? null; $main_content = ''; if (!$use_installer && $is_logged_in) { diff --git a/templates/2k11/admin/config_template.tpl b/templates/2k11/admin/config_template.tpl index 81857c65..f9a1f238 100644 --- a/templates/2k11/admin/config_template.tpl +++ b/templates/2k11/admin/config_template.tpl @@ -20,11 +20,11 @@ {/if} {/if} -
+
{$category.description} {foreach $category.items as $item} {cycle assign='zebra_class' values='odd,even'} - {if $item.guessedInput} + {if isset($item.guessedInput) and $item.guessedInput} {if $item.type == 'bool'}
{$item.title}{if $item.description != ''} {/if} @@ -36,15 +36,15 @@
{else} - {if $item.ignore} + {if $item.ignore|default:false} {cycle advance=true assign='temp'} {/if} -
+
{if $item.description != ''} {$item.description} {/if} - {$item.guessedInput} + {if isset($item.guessedInput)}{$item.guessedInput}{/if}
{/if} {/if} diff --git a/templates/2k11/admin/installer.inc.tpl b/templates/2k11/admin/installer.inc.tpl index b291f98e..e4193608 100644 --- a/templates/2k11/admin/installer.inc.tpl +++ b/templates/2k11/admin/installer.inc.tpl @@ -25,14 +25,14 @@
- {if $is_errors && is_array($errors)} + {if isset($is_errors) && $is_errors && is_array($errors)}
    {foreach $errors AS $error}
  • {$error}
  • {/foreach}
{/if} - {if $getstepint0} + {if $getstepint0|default:false}

{$CONST.WELCOME_TO_INSTALLATION}

{$CONST.FIRST_WE_TAKE_A_LOOK}

@@ -262,7 +262,7 @@ {elseif $s9yGETstep == '3'}

{$CONST.CHECK_DATABASE_EXISTS}

- {if is_array($authors_query)} + {if is_array($authors_query|default:null)} {$CONST.THEY_DO}, {$CONST.WONT_INSTALL_DB_AGAIN} {else} {$CONST.THEY_DONT} @@ -299,7 +299,7 @@