$checkfullimages = !empty($_POST['checkfullimages']) ? 1 : 0; $checkimagesexist = !empty($_POST['checkimagesexist']) ? 1 : 0; $checkfulllinks = !empty($_POST['checkfulllinks']) ? 1 : 0; $baseurl = ''; if (!empty($_POST['action']) && $_POST['action'] == "addimages") { if (!$id) { $msg = $GLOBALS['I18N']->get('No such template'); } else { $content_req = Sql_Fetch_Row_Query("select template from {$tables["template"]} where id = {$id}"); $images = getTemplateImages($content_req[0]); if (sizeof($images)) { include "class.image.inc"; $image = new imageUpload(); while (list($key, $val) = each($images)) { # printf('Image name: <b>%s</b> (%d times used)<br />',$key,$val); $image->uploadImage($key, $id); } $msg = $GLOBALS['I18N']->get('Images stored'); } else { $msg = $GLOBALS['I18N']->get('No images found'); } } $_SESSION['action_result'] = $msg . '<br/>' . s('Template saved and ready for use in campaigns'); Redirect('templates'); return; //print '<p class="actionresult">'.$msg.'</p>'; //$msg = ''; } elseif (!empty($_POST['save']) || !empty($_POST['sendtest'])) { ## let's save when sending a test $templateok = 1; $title = $_POST['title'];
function SaveConfig($item, $value, $editable = 1, $ignore_errors = 0) { global $tables; ## in case DB hasn't been initialised if (empty($_SESSION['hasconf'])) { $_SESSION['hasconf'] = Sql_Table_Exists($tables['config']); } if (empty($_SESSION['hasconf'])) { return; } if (isset($GLOBALS['default_config'][$item])) { $configInfo = $GLOBALS['default_config'][$item]; } else { $configInfo = array('type' => 'unknown', 'allowempty' => true, 'value' => ''); } ## to validate we need the actual values $value = str_ireplace('[domain]', $GLOBALS['domain'], $value); $value = str_ireplace('[website]', $GLOBALS['website'], $value); switch ($configInfo['type']) { case 'boolean': if ($value == 'false' || $value == 'no') { $value = 0; } elseif ($value == 'true' || $value == 'yes') { $value = 1; } break; case 'integer': $value = sprintf('%d', $value); if ($value < $configInfo['min']) { $value = $configInfo['min']; } if ($value > $configInfo['max']) { $value = $configInfo['max']; } break; case 'email': if (!empty($value) && !is_email($value)) { ## hmm, this is displayed only later # $_SESSION['action_result'] = s('Invalid value for email address'); return $configInfo['description'] . ': ' . s('Invalid value for email address'); $value = ''; } break; case 'emaillist': $valid = array(); $hasError = false; $emails = explode(',', $value); foreach ($emails as $email) { if (is_email($email)) { $valid[] = $email; } else { $hasError = true; } } $value = implode(',', $valid); /* * hmm, not sure this is good or bad for UX * */ if ($hasError) { return $configInfo['description'] . ': ' . s('Invalid value for email address'); } break; case 'image': include 'class.image.inc'; $image = new imageUpload(); $imageId = $image->uploadImage($item, 0); if ($imageId) { $value = $imageId; } ## we only use the image type for the logo flushLogoCache(); } ## reset to default if not set, and required if (empty($configInfo['allowempty']) && empty($value)) { $value = $configInfo['value']; } if (!empty($configInfo['hidden'])) { $editable = 0; } ## force reloading config values in session unset($_SESSION['config']); ## and refresh the config immediately https://mantis.phplist.com/view.php?id=16693 unset($GLOBALS['config']); Sql_Query(sprintf('replace into %s set item = "%s", value = "%s", editable = %d', $tables['config'], sql_escape($item), sql_escape($value), $editable)); return false; ## true indicates error, and which one }