/** * PrintEditForm * Prints a form to edit a user. If you pass in a userid, it will load up that user and print their information. If you pass in the details array, it will prefill the form with that information (eg if you tried to create a user with a duplicate username). Also checks whether you are allowed to edit this user. If you are not an admin, you are only allowed to edit your own account. * * @param Int $userid Userid to load up. * @param Array $details Details to prefill the form with (in case there was a problem creating the user). * * @see User_API::Admin * @see User_API::Status * @see User_API::ListAdmin * @see User_API::EditOwnSettings * @see GetUser * * @return Void Returns nothing. If you don't have access to edit a particular user, it prints an error message and exits. Otherwise it prints the correct form (either edit-own or edit) and then exits. */ function PrintEditForm($userid = 0, $details = array()) { $thisuser = IEM::getCurrentUser(); if (!$thisuser->UserAdmin()) { if ($userid != $thisuser->userid) { $this->DenyAccess(); } if (!$thisuser->EditOwnSettings()) { $this->DenyAccess(); } } $user = $this->GetApi('User'); $listapi = $this->GetApi('Lists'); $all_lists = $listapi->GetLists(0, array('SortBy' => 'name', 'Direction' => 'asc'), false, 0, 0); $segmentapi = $this->GetApi('Segment'); $all_segments = $segmentapi->GetSegments(array('SortBy' => 'segmentname', 'Direction' => 'asc'), false, 0, 'all'); $templateapi = $this->GetApi('Templates'); $all_templates = $templateapi->GetTemplates(0, array('SortBy' => 'name', 'Direction' => 'asc'), false, 0, 0); $all_groups = API_USERGROUPS::getRecords(false, false, 0, 0, 'groupname'); $GLOBALS['CustomSmtpServer_Display'] = '0'; $GLOBALS['XmlPath'] = SENDSTUDIO_APPLICATION_URL . '/xml.php'; if ($userid > 0) { $user = GetUser($userid); if ($user->Get('userid') <= 0) { $GLOBALS['ErrorMessage'] = GetLang('UserDoesntExist'); $this->DenyAccess(); return; } $GLOBALS['UserID'] = $user->Get('userid'); $GLOBALS['UserName'] = htmlspecialchars($user->Get('username'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['FullName'] = htmlspecialchars($user->Get('fullname'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['EmailAddress'] = htmlspecialchars($user->Get('emailaddress'), ENT_QUOTES, SENDSTUDIO_CHARSET); $activity = $user->GetEventActivityType(); if (!is_array($activity)) { $activity = array(); } $GLOBALS['EventActivityType'] = implode("\n", $activity); $GLOBALS['MaxLists'] = $user->group->limit_list; $GLOBALS['MaxEmails'] = $user->group->limit_totalemailslimit; $GLOBALS['PerMonth'] = $user->group->limit_emailspermonth; $GLOBALS['PerHour'] = $user->group->limit_hourlyemailsrate; $GLOBALS['DisplayMaxLists'] = ''; if ($user->Get('maxlists') == 0) { $GLOBALS['LimitListsChecked'] = ' CHECKED'; $GLOBALS['DisplayMaxLists'] = 'none'; } $GLOBALS['DisplayEmailsPerHour'] = ''; if ($user->Get('perhour') == 0) { $GLOBALS['LimitPerHourChecked'] = ' CHECKED'; $GLOBALS['DisplayEmailsPerHour'] = 'none'; } $GLOBALS['DisplayEmailsPerMonth'] = ''; if ($user->Get('permonth') == 0) { $GLOBALS['LimitPerMonthChecked'] = ' CHECKED'; $GLOBALS['DisplayEmailsPerMonth'] = 'none'; } $GLOBALS['LimitMaximumEmailsChecked'] = ' CHECKED'; $GLOBALS['DisplayEmailsMaxEmails'] = 'none'; if (!$user->hasUnlimitedCredit()) { $GLOBALS['LimitMaximumEmailsChecked'] = ''; $GLOBALS['DisplayEmailsMaxEmails'] = ''; } if ($user->Get('usewysiwyg')) { $GLOBALS['UseWysiwyg'] = ' CHECKED'; $GLOBALS['UseXHTMLDisplay'] = ' style="display:block;"'; } else { $GLOBALS['UseXHTMLDisplay'] = ' style="display:none;"'; } if ($user->Get('enableactivitylog')) { $GLOBALS['EnableActivityLog'] = ' CHECKED'; } else { $GLOBALS['EnableActivityLog'] = ''; } $GLOBALS['UseXHTMLCheckbox'] = $user->Get('usexhtml')? ' CHECKED' : ''; $GLOBALS['Xmlapi'] = $user->Get('xmlapi')? ' CHECKED' : ''; $GLOBALS['XMLTokenDisplay'] = ' style="display:none;"'; if ($user->Get('xmlapi')) { $GLOBALS['XMLTokenDisplay'] = ' style="display:block;"'; } $GLOBALS['XmlToken'] = htmlspecialchars($user->Get('xmltoken'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['TextFooter'] = $user->Get('textfooter'); $GLOBALS['HTMLFooter'] = $user->Get('htmlfooter'); $GLOBALS['SmtpServer'] = $user->Get('smtpserver'); $GLOBALS['SmtpUsername'] = $user->Get('smtpusername'); $GLOBALS['SmtpPassword'] = $user->Get('smtppassword'); $GLOBALS['SmtpPort'] = $user->Get('smtpport'); if ($GLOBALS['SmtpServer']) { $GLOBALS['CustomSmtpServer_Display'] = '1'; } $GLOBALS['googlecalendarusername'] = htmlspecialchars($user->Get('googlecalendarusername'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['googlecalendarpassword'] = htmlspecialchars($user->Get('googlecalendarpassword'), ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['FormAction'] = 'Action=Save&UserID=' . $user->userid; if (!$thisuser->UserAdmin()) { $smtp_access = $thisuser->HasAccess('User', 'SMTP'); $GLOBALS['ShowSMTPInfo'] = 'none'; $GLOBALS['DisplaySMTP'] = '0'; if ($smtp_access) { $GLOBALS['ShowSMTPInfo'] = ''; } if ($GLOBALS['SmtpServer']) { $GLOBALS['CustomSmtpServer_Display'] = '1'; if ($smtp_access) { $GLOBALS['DisplaySMTP'] = '1'; } } $this->ParseTemplate('User_Edit_Own'); return; } $GLOBALS['StatusChecked'] = ($user->Status()) ? ' CHECKED' : ''; $GLOBALS['ForceDoubleOptInChecked'] = ($user->Get('forcedoubleoptin')) ? ' CHECKED' : ''; $GLOBALS['ForceSpamCheckChecked'] = ($user->Get('forcespamcheck')) ? ' CHECKED' : ''; $GLOBALS['InfoTipsChecked'] = ($user->InfoTips()) ? ' CHECKED' : ''; $editown = ''; if ($user->UserAdmin()) { $editown = ' CHECKED'; } else { if ($user->EditOwnSettings()) { $editown = ' CHECKED'; } } $GLOBALS['EditOwnSettingsChecked'] = $editown; $timezone = $user->usertimezone; $GLOBALS['TimeZoneList'] = $this->TimeZoneList($timezone); $admintype = $user->AdminType(); $listadmintype = $user->ListAdminType(); $segmentadmintype = $user->SegmentAdminType(); $templateadmintype = $user->TemplateAdminType(); $admin = $user->Admin(); $listadmin = $user->ListAdmin(); $segmentadmin = $user->SegmentAdmin(); $templateadmin = $user->TemplateAdmin(); $permissions = $user->Get('permissions'); $area_access = $user->Get('access'); $GLOBALS['Heading'] = GetLang('EditUser'); $GLOBALS['Help_Heading'] = GetLang('Help_EditUser'); $GLOBALS['AdminNotifyEmailAddress'] = $user->Get('adminnotify_email'); if (empty($GLOBALS['AdminNotifyEmailAddress'])) { $GLOBALS['AdminNotifyEmailAddress'] = constant('SENDSTUDIO_EMAIL_ADDRESS'); } $GLOBALS['AdminNotifications_Send_Email'] = $user->Get('adminnotify_send_emailtext'); if (empty($GLOBALS['AdminNotifications_Send_Email'])) { $GLOBALS['AdminNotifications_Send_Email'] = GetLang('AdminNotifications_Send_Email'); } $GLOBALS['AdminNotifications_Import_Email'] = $user->Get('adminnotify_import_emailtext'); if (empty($GLOBALS['AdminNotifications_Import_Email'])) { $GLOBALS['AdminNotifications_Import_Email'] = GetLang('AdminNotifications_Import_Email'); } $GLOBALS['SendLimit'] = $user->Get('adminnotify_send_threshold'); $GLOBALS['ImportLimit'] = $user->Get('adminnotify_import_threshold'); if (empty($GLOBALS['SendLimit'])) { $GLOBALS['SendLimit'] = 1000; } if (empty($GLOBALS['ImportLimit'])) { $GLOBALS['ImportLimit'] = 1000; } $admin_flag = $user->Get('adminnotify_send_flag'); if ($user->Get('adminnotify_send_flag') == 1) { $GLOBALS['AdminNotificationsSend'] = 'CHECKED'; $GLOBALS['UseNotifySend'] = ''; } else { $GLOBALS['UseNotifySend'] = "style=display:none;"; } if ($user->Get('adminnotify_import_flag') == 1) { $GLOBALS['AdminNotificationsImport'] = 'CHECKED'; $GLOBALS['UseNotifyImport'] = ''; } else { $GLOBALS['UseNotifyImport'] = "style=display:none;"; } $GLOBALS['SmtpPort'] = $user->Get('smtpport'); // Log this to "User Activity Log" IEM::logUserActivity(IEM::urlFor('users', array('Action' => 'Edit', 'UserID' => $userid)), 'images/user.gif', $user->username); } else { $timezone = (isset($details['timezone'])) ? $details['timezone'] : SENDSTUDIO_SERVERTIMEZONE; $GLOBALS['TimeZoneList'] = $this->TimeZoneList($timezone); $activity = $thisuser->defaultEventActivityType; if (!is_array($activity)) { $activity = array(); } $GLOBALS['EventActivityType'] = implode("\n", $activity); $GLOBALS['FormAction'] = 'Action=Create'; if (!empty($details)) { foreach ($details as $area => $val) { $GLOBALS[$area] = $val; } } $GLOBALS['Heading'] = GetLang('CreateUser'); $GLOBALS['Help_Heading'] = GetLang('Help_CreateUser'); $listadmintype = 'c'; $segmentadmintype = 'c'; $admintype = 'c'; $templateadmintype = 'c'; $GLOBALS['DisplayMaxLists'] = 'none'; $GLOBALS['DisplayEmailsPerHour'] = 'none'; $GLOBALS['DisplayEmailsPerMonth'] = 'none'; $GLOBALS['DisplayEmailsMaxEmails'] = 'none'; $GLOBALS['MaxLists'] = '0'; $GLOBALS['PerHour'] = '0'; $GLOBALS['PerMonth'] = '0'; $GLOBALS['MaxEmails'] = '0'; $GLOBALS['StatusChecked'] = ' CHECKED'; $GLOBALS['ForceDoubleOptInChecked'] = ''; $GLOBALS['ForceSpamCheckChecked'] = ''; $GLOBALS['InfoTipsChecked'] = ' CHECKED'; $GLOBALS['EditOwnSettingsChecked'] = ' CHECKED'; $GLOBALS['LimitListsChecked'] = ' CHECKED'; $GLOBALS['LimitPerHourChecked'] = ' CHECKED'; $GLOBALS['LimitPerMonthChecked'] = ' CHECKED'; $GLOBALS['LimitMaximumEmailsChecked'] = ' CHECKED'; $GLOBALS['UseWysiwyg'] = ' CHECKED'; $GLOBALS['EnableLastViewed'] = ''; $GLOBALS['UseXHTMLCheckbox'] = ' CHECKED'; $GLOBALS['HTMLFooter'] = GetLang('Default_Global_HTML_Footer'); $GLOBALS['TextFooter'] = GetLang('Default_Global_Text_Footer'); $GLOBALS['EnableActivityLog'] = ' CHECKED'; $GLOBALS['Xmlapi'] = ''; $GLOBALS['XMLTokenDisplay'] = ' style="display:none;"'; $admin = $listadmin = $segmentadmin = $templateadmin = false; $permissions = array(); $area_access = array('lists' => array(), 'templates' => array(), 'segments' => array()); $GLOBALS['AdminNotifyEmailAddress'] = constant('SENDSTUDIO_EMAIL_ADDRESS'); $GLOBALS['UseNotifySend'] = "style=display:none;"; $GLOBALS['UseNotifyImport'] = "style=display:none;"; $GLOBALS['SendLimit'] = 1000; $GLOBALS['ImportLimit'] = 1000; $GLOBALS['AdminNotifications_Send_Email'] = GetLang('AdminNotifications_Send_Email'); $GLOBALS['AdminNotifications_Import_Email'] = GetLang('AdminNotifications_Import_Email'); } $agencyid = defined('IEM_SYSTEM_LICENSE_AGENCY') ? IEM_SYSTEM_LICENSE_AGENCY : ''; $available_users = $user->AvailableUsers(); $template = GetTemplateSystem(); $template->Assign('UserID', $user->userid); $template->Assign('groupid', $user->groupid); $template->Assign('canChangeUserGroup', !$user->isLastAdmin()); $template->Assign('AgencyEdition', get_agency_license_variables()); $template->Assign('EditOwn', ($user->userid != 0 && $user->userid == $thisuser->userid)); $template->Assign('TrialUser', $user->trialuser); $template->Assign('EditMode', !empty($user->userid)); $template->Assign('AvailableNormalUsers', isset($available_users['normal']) ? $available_users['normal'] : 0); $template->Assign('AvailableTrialUsers', isset($available_users['trial']) ? $available_users['trial'] : 0); $template->Assign('AvailableGroups', $all_groups); $template->Assign('record_groupid', $user->groupid); $template->Assign('DefaultIdTab', IEM::requestGetPOST('id_tab_num', 1, 'intval')); $template->Assign('showSmtpInfo', (bool) $user->smtpserver); $template->ParseTemplate('User_Form'); }
/** * GetLang * Returns the defined language variable based on the name passed in. * * If a default value is NOT specified (or specified to NULL), the function WILL STOP execution * whenever a language definition is NOT found. If it is specified, the function will * return the specified default value instead. * * @param String $langvar Name of the language variable to retrieve. * @param String $default Default value to be returned if language definition does not exists * * @return String Returns the defined string, if it doesn't exist (and default is not specified) the script execution will be halted. */ function GetLang($langvar = false, $default = null) { static $array_to_replace_from = false; static $array_to_replace_to = false; if (!$langvar) { return ''; } if (!defined('LNG_' . $langvar)) { // Language definition is not found, return a default value if it is defined if (!is_null($default)) { return strval($default); } // Make note of where the error occured $message = ''; if (function_exists('debug_backtrace')) { $btrace = debug_backtrace(); $called_from = $btrace[0]; $message = ' (Called from ' . basename($called_from['file']) . ', line ' . $called_from['line'] . ')'; } trigger_error("Langvar '{$langvar}' doesn't exist: " . $message, E_USER_NOTICE); return $langvar; } $var = constant('LNG_' . $langvar); if (!$array_to_replace_from || !$array_to_replace_to) { $agency_edition_info = get_agency_license_variables(); $array_to_replace_from = array('%%WHITELABEL_INFOTIPS%%', '%%IEM_SYSTEM_LICENSE_TRIALUSER_TRIALDAYS%%', '%%IEM_SYSTEM_LICENSE_TRIALUSER_EMAILLIMIT%%'); defined('LNG_NumberFormat_Thousands') or define('LNG_NumberFormat_Thousands', ','); defined('LNG_NumberFormat_Dec') or define('LNG_NumberFormat_Dec', '.'); $array_to_replace_to = array(IEM::enableInfoTipsGet(), $agency_edition_info['trial_days'], number_format((double) $agency_edition_info['trial_email_limit'], 0, LNG_NumberFormat_Dec, LNG_NumberFormat_Thousands)); } return str_replace($array_to_replace_from, $array_to_replace_to, $var); }
/** * Create * This function creates a user based on the current class vars and then save permissions once it has a new userid from the database. * * @return False|Int Returns false if it couldn't create a user, otherwise returns the new userid. */ function Create() { if (!ss9024kwehbehb($this)) { return -1; } $this->FilterData(); if (!$this->Validate('create')) { return false; } $processed_unique_token = API_USERS::generateUniqueToken(SENDSTUDIO_LICENSEKEY . $this->username); $processed_password = API_USERS::generatePasswordHash($this->password, $processed_unique_token); if (!is_array($this->eventactivitytype)) { $this->eventactivitytype = array(); } if ($this->trialuser == '1') { $agency_variables = get_agency_license_variables(); $this->admintype = 'c'; } $query = " INSERT INTO [|PREFIX|]users ( groupid, username, password, unique_token, status, emailaddress, fullname, trialuser, admintype, listadmintype, templateadmintype, segmentadmintype, editownsettings, usertimezone, textfooter, htmlfooter, infotips, smtpserver, smtpusername, smtppassword, smtpport, createdate, lastloggedin, enableactivitylog, usewysiwyg, xmlapi, xmltoken, gettingstarted, googlecalendarusername, googlecalendarpassword, eventactivitytype, adminnotify_email, adminnotify_send_flag, adminnotify_send_threshold, adminnotify_send_emailtext, adminnotify_import_flag, adminnotify_import_threshold, adminnotify_import_emailtext ) VALUES ( " . intval($this->groupid) . ", '" . $this->Db->Quote($this->username) . "', '" . $this->Db->Quote($processed_password) . "', '" . $this->Db->Quote($processed_unique_token) . "', '" . intval($this->status) . "', '" . $this->Db->Quote($this->emailaddress) . "', '" . $this->Db->Quote($this->fullname) . "', '" . ($this->trialuser == '1' ? '1' : '0') . "', '" . $this->Db->Quote($this->admintype) . "', '" . $this->Db->Quote($this->listadmintype) . "', '" . $this->Db->Quote($this->templateadmintype) . "', '" . $this->Db->Quote($this->segmentadmintype) . "', '" . intval($this->editownsettings) . "', '" . $this->Db->Quote($this->usertimezone) . "', '" . $this->Db->Quote($this->textfooter) . "', '" . $this->Db->Quote($this->htmlfooter) . "', '" . intval($this->infotips) . "', '" . $this->Db->Quote($this->smtpserver) . "', '" . $this->Db->Quote($this->smtpusername) . "', '" . $this->Db->Quote(base64_encode($this->smtppassword)) . "', " . intval($this->smtpport) . ", " . time() . ", 0, '" . intval($this->enableactivitylog) . "', '" . intval($this->usewysiwyg) . "', '" . intval($this->xmlapi) . "', '" . $this->Db->Quote($this->xmltoken) . "' ," . intval($this->gettingstarted) . ", '" . $this->Db->Quote($this->googlecalendarusername) . "', '" . $this->Db->Quote($this->googlecalendarpassword) . "', '" . serialize($this->eventactivitytype) . "', '" . $this->Db->Quote($this->adminnotify_email) . "', '" . intval($this->adminnotify_send_flag) . "', '" . intval($this->adminnotify_send_threshold) . "', '" . $this->Db->Quote($this->adminnotify_send_emailtext) . "', '" . intval($this->adminnotify_import_flag) . "', '" . intval($this->adminnotify_import_threshold) . "', '" . $this->Db->Quote($this->adminnotify_import_emailtext) . "' ) "; // We want to get the userid once it is created. if (SENDSTUDIO_DATABASE_TYPE == 'pgsql') { $query .= ' RETURNING userid'; } $this->Db->StartTransaction(); $result = $this->Db->Query($query); if (!$result) { $this->Db->CommitTransaction(); return false; } if (SENDSTUDIO_DATABASE_TYPE == 'pgsql') { $userid = $this->Db->FetchOne($result, 'userid'); } else { $userid = $this->Db->LastId(SENDSTUDIO_TABLEPREFIX . 'users_sequence'); } $this->userid = $userid; $status = (create_user_dir($userid) === true); if (!$status) { $this->Db->RollbackTransaction(); return false; } $this->Db->CommitTransaction(); $this->_cacheUserTypeCount = false; return $userid; }
/** * ShowSettingsPage * Prints out the settings page and pre-fills the form fields as much as it can. * * It will also show: * - if there is a license key issue * - if there is a problem with cron/scheduled tasks set up not working properly * - if 'test mode' is enabled * - if you disable attachments, it checks autoresponders to see if any need to be disabled * * @return Void Prints out the settings form, doesn't return anything. */ function ShowSettingsPage() { require_once(SENDSTUDIO_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'interspire_addons.php'); $addonSystem = new Interspire_Addons(); $addonStatus = $addonSystem->GetAvailableAddons(); $this->PrintHeader(); $tpl = GetTemplateSystem(); $GLOBALS['Message'] = ''; list($license_error, $msg) = sesion_start(); $extra = ''; if ($license_error) { $GLOBALS['Error'] = $msg; $GLOBALS['Message'] .= $this->ParseTemplate('ErrorMsg', true, false); $extra = ' <script> $(function() { $("licensekey").select(); $("licensekey").focus(); }); </script> '; unset($GLOBALS['Error']); } if (!is_writable(SENDSTUDIO_INCLUDES_DIRECTORY . '/config.php')) { FlashMessage(sprintf(GetLang('ConfigFileNotWritable'), SENDSTUDIO_INCLUDES_DIRECTORY . '/config.php'), SS_FLASH_MSG_WARNING); } $api = $this->GetApi(); $api->Load(); $all_areas = $api->Areas; foreach ($all_areas['config'] as $k => $option) { $opt_name = 'SENDSTUDIO_' . $option; ${$opt_name} = constant($opt_name); } unset($all_areas['config']); unset($all_areas['whitelabel']); foreach ($all_areas as $k => $option) { $opt_name = 'SENDSTUDIO_' . $option; ${$opt_name} = constant($opt_name); } if (isset($SENDSTUDIO_FORCE_UNSUBLINK) && $SENDSTUDIO_FORCE_UNSUBLINK == 1) { $SENDSTUDIO_FORCE_UNSUBLINK = ' CHECKED'; } if (!isset($SENDSTUDIO_FORCE_UNSUBLINK)) { $SENDSTUDIO_FORCE_UNSUBLINK = ''; } $cron_checked = false; if (isset($SENDSTUDIO_CRON_ENABLED) && $SENDSTUDIO_CRON_ENABLED == 1) { $SENDSTUDIO_CRON_ENABLED = ' CHECKED'; $cron_checked = true; } if (!isset($SENDSTUDIO_CRON_ENABLED)) { $SENDSTUDIO_CRON_ENABLED = ''; } $GLOBALS['Cron_ShowInfo'] = 'none'; if ($cron_checked) { $GLOBALS['Cron_ShowInfo'] = ''; } $ip_tracking = false; if (isset($SENDSTUDIO_IPTRACKING) && $SENDSTUDIO_IPTRACKING == 1) { $SENDSTUDIO_IPTRACKING = ' CHECKED'; $ip_tracking = true; } if (!isset($SENDSTUDIO_IPTRACKING)) { $SENDSTUDIO_IPTRACKING = ''; } if (isset($SENDSTUDIO_USEMULTIPLEUNSUBSCRIBE) && $SENDSTUDIO_USEMULTIPLEUNSUBSCRIBE == 1) { $SENDSTUDIO_USEMULTIPLEUNSUBSCRIBE = ' CHECKED'; } if (!isset($SENDSTUDIO_USEMULTIPLEUNSUBSCRIBE)) { $SENDSTUDIO_USEMULTIPLEUNSUBSCRIBE = ''; } if (isset($SENDSTUDIO_CONTACTCANMODIFYEMAIL) && $SENDSTUDIO_CONTACTCANMODIFYEMAIL == 1) { $SENDSTUDIO_CONTACTCANMODIFYEMAIL = ' CHECKED'; } if (!isset($SENDSTUDIO_CONTACTCANMODIFYEMAIL)) { $SENDSTUDIO_CONTACTCANMODIFYEMAIL = ''; } $send_test_mode = false; if (isset($SENDSTUDIO_SEND_TEST_MODE) && $SENDSTUDIO_SEND_TEST_MODE == 1) { $SENDSTUDIO_SEND_TEST_MODE = ' CHECKED'; $send_test_mode = true; } if (!isset($SENDSTUDIO_SEND_TEST_MODE) && SENDSTUDIO_SEND_TEST_MODE == 1) { $SENDSTUDIO_SEND_TEST_MODE = ' CHECKED'; $send_test_mode = true; } if (!isset($SENDSTUDIO_SEND_TEST_MODE)) { $SENDSTUDIO_SEND_TEST_MODE = ''; } if ($SENDSTUDIO_SMTP_SERVER) { $GLOBALS['UseSMTP'] = ' CHECKED'; $GLOBALS['DisplaySMTP'] = "'';"; } else { $GLOBALS['UseDefaultMail'] = ' CHECKED'; $GLOBALS['DisplaySMTP'] = 'none'; } $GLOBALS['ShowCronInfo'] = 'none'; $GLOBALS['CronRunTime'] = GetLang('CronRunTime_Never'); $GLOBALS['CronRunTime_Explain'] = GetLang('CronRunTime_Explain'); if ($SENDSTUDIO_CRON_ENABLED) { $GLOBALS['ShowCronInfo'] = ''; $cron_ok = $api->Get('cronok'); if ($cron_ok) { $cron_1 = $api->Get('cronrun1'); $cron_2 = $api->Get('cronrun2'); if (!$cron_1) { $GLOBALS['CronRunTime'] = GetLang('CronRunTime_Once'); } else { $diff = $this->TimeDifference($cron_2 - $cron_1); $GLOBALS['CronRunTime'] = sprintf(GetLang('CronRunTime_Difference'), $diff); } } } $GLOBALS['Settings_CronOptionsList'] = ''; /** * The schedule stuff is a little different and comes from the database. * Look at all of the options in the schedule * as addons can defined their own schedules if they need to. */ $cron_schedule = $api->Get('Schedule'); $cron_options = array_keys($cron_schedule); foreach ($cron_options as $p => $cron_option) { if ($cron_option == 'triggeremails_p') { $GLOBALS['Settings_CronOptionsList'] .= '<tr style="display:none;"><td><input type="hidden" name="cron_triggeremails_p" value="' . SENDSTUDIO_CRON_TRIGGEREMAILS_P . '" /></td></tr>'; continue; } $opt_name = 'Cron_Options'; $GLOBALS[$opt_name] = ''; $settings_var = ${'SENDSTUDIO_CRON_' . strtoupper($cron_option)}; $GLOBALS['Cron_Option_SelectName'] = 'cron_' . $cron_option; $GLOBALS['Cron_Option_Heading'] = GetLang('Cron_Option_'.$cron_option.'_Heading'); foreach ($api->Get($cron_option . '_options') as $opt => $desc) { $selected = ''; if ($opt == $settings_var) { $selected = ' SELECTED'; } $GLOBALS[$opt_name] .= '<option value="' . $opt . '"' . $selected . '>' . GetLang('Cron_Option_' . $desc) . '</option>'; } $GLOBALS['Cron_LastRun'] = $GLOBALS['Cron_NextRun'] = ''; $last_run = $cron_schedule[$cron_option]['lastrun']; if ($last_run > 0) { $GLOBALS['Cron_LastRun'] = IEM::timeGetUserDisplayString(GetLang('Cron_DateFormat'), $last_run); if ($settings_var > 0) { $next_run = $last_run + ($settings_var * 60); $GLOBALS['Cron_NextRun'] = IEM::timeGetUserDisplayString(GetLang('Cron_DateFormat'), $next_run); } else { $GLOBALS['Cron_NextRun'] = GetLang('Cron_Option_Disabled'); } } else { $GLOBALS['Cron_LastRun'] = GetLang('Cron_Option_HasNotRun'); } // Skipping any problematic CRON schedule if (!defined('LNG_Cron_Option_'.$cron_option.'_Heading')) { continue; } $GLOBALS['Cron_Option_Heading'] = GetLang('Cron_Option_'.$cron_option.'_Heading'); $GLOBALS['Settings_CronOptionsList'] .= $this->ParseTemplate('Settings_Cron_Option', true, false); } $GLOBALS['Imap_Selected'] = $GLOBALS['Pop3_Selected'] = ''; if (!isset($SENDSTUDIO_BOUNCE_IMAP) && SENDSTUDIO_BOUNCE_IMAP == 1) { $GLOBALS['Imap_Selected'] = ' SELECTED '; } else { $GLOBALS['Pop3_Selected'] = ' SELECTED '; } if (isset($SENDSTUDIO_BOUNCE_IMAP) && $SENDSTUDIO_BOUNCE_IMAP == 1) { $GLOBALS['Imap_Selected'] = ' SELECTED '; } else { $GLOBALS['Pop3_Selected'] = ' SELECTED '; } if (!isset($SENDSTUDIO_BOUNCE_AGREEDELETE) && SENDSTUDIO_BOUNCE_AGREEDELETE == 1) { $SENDSTUDIO_BOUNCE_AGREEDELETE = ' CHECKED'; } if (isset($SENDSTUDIO_BOUNCE_AGREEDELETE) && $SENDSTUDIO_BOUNCE_AGREEDELETE == 1) { $SENDSTUDIO_BOUNCE_AGREEDELETE = ' CHECKED'; $GLOBALS['ProcessBounceChecked'] = ' CHECKED'; } else { $GLOBALS['DisplayExtraMailSettings'] = 'none'; } if (!isset($SENDSTUDIO_BOUNCE_AGREEDELETEALL) && SENDSTUDIO_BOUNCE_AGREEDELETEALL == 1) { $SENDSTUDIO_BOUNCE_AGREEDELETEALL = ' CHECKED'; } if (isset($SENDSTUDIO_BOUNCE_AGREEDELETEALL) && $SENDSTUDIO_BOUNCE_AGREEDELETEALL == 1) { $SENDSTUDIO_BOUNCE_AGREEDELETEALL = ' CHECKED'; } if ($SENDSTUDIO_BOUNCE_EXTRASETTINGS) { $GLOBALS['Bounce_ExtraSettings'] = ' CHECKED'; } else { $GLOBALS['DisplayExtraMailSettings'] = 'none'; } $allow_attachments = false; if (isset($SENDSTUDIO_ALLOW_ATTACHMENTS) && $SENDSTUDIO_ALLOW_ATTACHMENTS == 1) { $SENDSTUDIO_ALLOW_ATTACHMENTS = ' CHECKED'; $allow_attachments = true; } if (!isset($SENDSTUDIO_ALLOW_ATTACHMENTS) && SENDSTUDIO_ALLOW_ATTACHMENTS == 1) { $SENDSTUDIO_ALLOW_ATTACHMENTS = ' CHECKED'; $allow_attachments = true; } if (!isset($SENDSTUDIO_ALLOW_ATTACHMENTS)) { $SENDSTUDIO_ALLOW_ATTACHMENTS = ''; } $GLOBALS['ShowAttachmentSize'] = 'none'; if ($allow_attachments) { $GLOBALS['ShowAttachmentSize'] = "'';"; } $embedded_images = false; if (isset($SENDSTUDIO_ALLOW_EMBEDIMAGES) && $SENDSTUDIO_ALLOW_EMBEDIMAGES == 1) { $embedded_images = true; $SENDSTUDIO_ALLOW_EMBEDIMAGES = ' CHECKED'; } if (!isset($SENDSTUDIO_ALLOW_EMBEDIMAGES) && SENDSTUDIO_ALLOW_EMBEDIMAGES == 1) { $embedded_images = true; $SENDSTUDIO_ALLOW_EMBEDIMAGES = ' CHECKED'; } if (!isset($SENDSTUDIO_ALLOW_EMBEDIMAGES)) { $SENDSTUDIO_ALLOW_EMBEDIMAGES = ''; } // this option is hidden by the embedded_images check but we should remember the 'state' in case the admin turns off embedded images and then turns it back on. if (isset($SENDSTUDIO_DEFAULT_EMBEDIMAGES) && $SENDSTUDIO_DEFAULT_EMBEDIMAGES == 1) { $SENDSTUDIO_DEFAULT_EMBEDIMAGES = ' CHECKED'; } if (!isset($SENDSTUDIO_DEFAULT_EMBEDIMAGES) && SENDSTUDIO_DEFAULT_EMBEDIMAGES == 1) { $SENDSTUDIO_DEFAULT_EMBEDIMAGES = ' CHECKED'; } if (!isset($SENDSTUDIO_DEFAULT_EMBEDIMAGES)) { $SENDSTUDIO_DEFAULT_EMBEDIMAGES = ''; } $GLOBALS['ShowDefaultEmbeddedImages'] = 'none'; if ($embedded_images) { $GLOBALS['ShowDefaultEmbeddedImages'] = "'';"; } /** * Now we have worked out the logic of what options are pre-filled, * we'll just set up the variables ready for the template system to use everything. */ $disabled_functions = explode(',', SENDSTUDIO_DISABLED_FUNCTIONS); $php_binary = 'php'; if (substr(strtolower(PHP_OS), 0, 3) == 'win') { $php_binary = 'php.exe'; } $php_path = $this->Which($php_binary); // If we can't find the full path, just print the binary so people get the right idea. if ($php_path == '') { $php_path = $php_binary; } $php_path .= ' -f '; $GLOBALS['CronPath'] = $php_path . SENDSTUDIO_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'cron' . DIRECTORY_SEPARATOR . 'cron.php'; $GLOBALS['DatabaseType'] = $SENDSTUDIO_DATABASE_TYPE; $GLOBALS['DatabaseUser'] = $SENDSTUDIO_DATABASE_USER; $GLOBALS['DatabaseHost'] = $SENDSTUDIO_DATABASE_HOST; $GLOBALS['DatabasePass'] = $SENDSTUDIO_DATABASE_PASS; $GLOBALS['DatabaseName'] = $SENDSTUDIO_DATABASE_NAME; $GLOBALS['DatabaseTablePrefix'] = $SENDSTUDIO_TABLEPREFIX; $GLOBALS['ApplicationURL'] = $SENDSTUDIO_APPLICATION_URL; $GLOBALS['LicenseKey'] = $SENDSTUDIO_LICENSEKEY; $GLOBALS['DatabaseVersion'] = $api->Db->FetchOne('SELECT version() AS version'); $GLOBALS['System_Message'] = htmlentities($SENDSTUDIO_SYSTEM_MESSAGE, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['TextFooter'] = strip_tags($SENDSTUDIO_TEXTFOOTER); $GLOBALS['HTMLFooter'] = $SENDSTUDIO_HTMLFOOTER; $GLOBALS['ForceUnsubLink'] = $SENDSTUDIO_FORCE_UNSUBLINK; $GLOBALS['CronEnabled'] = $SENDSTUDIO_CRON_ENABLED; $GLOBALS['IpTracking'] = $SENDSTUDIO_IPTRACKING; $GLOBALS['UseMultipleUnsubscribe'] = $SENDSTUDIO_USEMULTIPLEUNSUBSCRIBE; $GLOBALS['ContactCanModifyEmail'] = $SENDSTUDIO_CONTACTCANMODIFYEMAIL; $GLOBALS['SendTestMode'] = $SENDSTUDIO_SEND_TEST_MODE; $GLOBALS['MaxHourlyRate'] = $SENDSTUDIO_MAXHOURLYRATE; $GLOBALS['MaxOverSize'] = $SENDSTUDIO_MAXOVERSIZE; $GLOBALS['EmailAddress'] = htmlspecialchars($SENDSTUDIO_EMAIL_ADDRESS, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['MaxImageWidth'] = intval($SENDSTUDIO_MAX_IMAGEWIDTH); $GLOBALS['MaxImageHeight'] = intval($SENDSTUDIO_MAX_IMAGEHEIGHT); $GLOBALS['Smtp_Server'] = htmlspecialchars($SENDSTUDIO_SMTP_SERVER, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Smtp_Username'] = htmlspecialchars($SENDSTUDIO_SMTP_USERNAME, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Smtp_Password'] = base64_decode($SENDSTUDIO_SMTP_PASSWORD); $GLOBALS['Smtp_Port'] = $SENDSTUDIO_SMTP_PORT; $GLOBALS['Bounce_Address'] = htmlspecialchars($SENDSTUDIO_BOUNCE_ADDRESS, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Bounce_Server'] = htmlspecialchars($SENDSTUDIO_BOUNCE_SERVER, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Bounce_Username'] = htmlspecialchars($SENDSTUDIO_BOUNCE_USERNAME, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Bounce_Password'] = base64_decode($SENDSTUDIO_BOUNCE_PASSWORD); $GLOBALS['Bounce_Imap'] = $SENDSTUDIO_BOUNCE_IMAP; $GLOBALS['Bounce_ExtraSettings'] = htmlspecialchars($SENDSTUDIO_BOUNCE_EXTRASETTINGS, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Bounce_AgreeDelete'] = $SENDSTUDIO_BOUNCE_AGREEDELETE; $GLOBALS['Bounce_AgreeDeleteAll'] = $SENDSTUDIO_BOUNCE_AGREEDELETEALL; $GLOBALS['AllowAttachments'] = $SENDSTUDIO_ALLOW_ATTACHMENTS; $GLOBALS['AllowEmbedImages'] = $SENDSTUDIO_ALLOW_EMBEDIMAGES; $GLOBALS['AttachmentSize'] = $SENDSTUDIO_ATTACHMENT_SIZE; $GLOBALS['EmailSize_Warning'] = $SENDSTUDIO_EMAILSIZE_WARNING; $GLOBALS['EmailSize_Maximum'] = $SENDSTUDIO_EMAILSIZE_MAXIMUM; $GLOBALS['Resend_Maximum'] = $SENDSTUDIO_RESEND_MAXIMUM; $GLOBALS['DefaultEmbedImages'] = $SENDSTUDIO_DEFAULT_EMBEDIMAGES; $GLOBALS['Copyright'] = htmlspecialchars(LNG_Copyright, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Existing_App_Logo_Image'] = APPLICATION_LOGO_IMAGE; $GLOBALS['Existing_App_Favicon'] = APPLICATION_FAVICON; // $GLOBALS['EnableUpdatesCheck'] = (isset($addonStatus['updatecheck']['enabled']) && $addonStatus['updatecheck']['enabled'] == '1') ? 'CHECKED' : ''; $GLOBALS['ShowIntroVideo'] = (SHOW_INTRO_VIDEO == true) ? 'CHECKED' : ''; $GLOBALS['ShowSmtpComOption'] = (SHOW_SMTP_COM_OPTION == true) ? 'CHECKED' : ''; $GLOBALS['ShowSmtpComOptionShow'] = (SHOW_SMTP_COM_OPTION == true) ? '' : 'none'; $GLOBALS['FormAction'] = 'Action=Save'; if (!$cron_checked) { $api->DisableCron(); } if ($cron_checked) { $this->DisplayCronWarning(false); } $test_mode_report = ''; if ($send_test_mode) { $jobs_api = $this->GetApi('Jobs'); $job_found = $jobs_api->FindJob('send', 'newsletter', 0, true, false, false); if ($job_found) { $test_mode_report = $this->PrintWarning('Send_TestMode_JobsWaiting'); } } $GLOBALS['Send_TestMode_Report'] = $test_mode_report; $attachments_report = ''; if (!$allow_attachments) { $autos_to_disable = array(); $auto_files = list_files(TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'autoresponders', null, true); if (!empty($auto_files)) { $autoresponder_ids = array_keys($auto_files); foreach ($autoresponder_ids as $p => $autoresponderid) { $files = $auto_files[$autoresponderid]; if (isset($files['attachments'])) { if (!empty($files['attachments'])) { $autos_to_disable[] = $autoresponderid; } } } } if (!empty($autos_to_disable)) { $auto_api = $this->GetApi('Autoresponders'); $disabled_list = $auto_api->DisableAutoresponders($autos_to_disable); if (!empty($disabled_list)) { $amount = sizeof(array_keys($disabled_list)); if ($amount == 1) { $attachments_report .= GetLang('Autoresponders_Disabled_Attachments_One_Link'); } else { $attachments_report .= sprintf(GetLang('Autoresponders_Disabled_Attachments_Many_Link'), $this->FormatNumber($amount)); } $email_api = $this->GetApi('Email'); $email_api->Set('CharSet', SENDSTUDIO_CHARSET); foreach ($disabled_list as $p => $disabled_details) { $subject = GetLang('Autoresponders_Disabled_Email_Subject'); $message = sprintf(GetLang('Autoresponders_Disabled_Email_Message'), $disabled_details['autorespondername'], $disabled_details['listname']); $email_api->ClearAttachments(); $email_api->ClearRecipients(); $email_api->Set('Multipart', false); $email_api->AddBody('text', $message); $email_api->Set('Subject', $subject); $email_api->Set('FromAddress', SENDSTUDIO_EMAIL_ADDRESS); $email_api->AddRecipient($disabled_details['owneremail'], $disabled_details['ownername'], 't'); $email_api->Send(); } IEM::sessionSet('AutorespondersDisabled', $disabled_list); } } $newsletters_to_disable = array(); $newsletter_files = list_files(TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'newsletters', null, true); if (!empty($newsletter_files)) { $newsletter_ids = array_keys($newsletter_files); foreach ($newsletter_ids as $newsid) { $files = $newsletter_files[$newsid]; if (isset($files['attachments'])) { if (!empty($files['attachments'])) { $newsletterts_to_disable[] = $newsid; } } } } if (!empty($newsletters_to_disable)) { if ($attachments_report != '') { $attachments_report .= '<br/><br/>'; } $news_api = $this->GetApi('Newsletters'); $disabled_list = $news_api->DisableNewsletters($newsletters_to_disable); if (!empty($disabled_list)) { $amount = sizeof(array_keys($disabled_list)); if ($amount == 1) { $attachments_report .= GetLang('Newsletters_Disabled_Attachments_One_Link'); } else { $attachments_report .= sprintf(GetLang('Newsletters_Disabled_Attachments_Many_Link'), $this->FormatNumber($amount)); } IEM::sessionSet('NewslettersDisabled', $disabled_list); } } } $GLOBALS['DisplayAttachmentsMessage'] = "none;"; if ($attachments_report) { $GLOBALS['DisplayAttachmentsMessage'] = ''; $GLOBALS['Warning'] = $attachments_report; $GLOBALS['Attachments_Message'] = $this->ParseTemplate('WarningMsg', true, false); } $GLOBALS['ExtraScript'] = $extra; $GLOBALS['Settings_AddonsDisplay'] = $this->PrintAddonsList(); // ----- Credit settings $tempPercentageWarnings = array(); $tempFixedWarnings = array(); // TODO fixed credit warnings aren't implemented yet $tempWarnings = $api->GetCreditWarningsSettings(); // If warnings can't be found, create default. if (empty($tempWarnings)) { $tempDefaultLevel = array('0', '15', '25'); $tempWarnings = array(); foreach ($tempDefaultLevel as $each) { $tempPercentageWarnings[] = array( 'enabled' => '0', 'creditlevel' => $each, 'aspercentage' => '1', 'emailsubject' => GetLang('CreditWarnings_Warnings_EmailSubjectDefaultText'), 'emailcontents' => str_replace('%s', "{$each}%", GetLang('CreditSettings_Warnings_PercentageDefaultText')) ); } unset($tempDefaultLevel); // Split the warnings into two arrays (fixed and percentage warnings) } else { foreach ($tempWarnings as $each) { if ($each['aspercentage']) { $tempPercentageWarnings[] = $each; } else { $tempFixedWarnings[] = $each; } } } unset($tempWarnings); $tpl->Assign('credit_settings', array( 'autoresponders_take_credit' => (bool)SENDSTUDIO_CREDIT_INCLUDE_AUTORESPONDERS, 'triggers_take_credit' => (bool)SENDSTUDIO_CREDIT_INCLUDE_TRIGGERS, 'enable_credit_level_warnings' => (bool)SENDSTUDIO_CREDIT_WARNINGS, 'warnings_percentage_level' => $tempPercentageWarnings, 'warnings_percentage_level_choices' => array( '0', '5', '10', '15', '20', '25', '30', '35', '40', '45', '50' ) )); // ----- // ----- Login Security settings $security_settings = array( 'login_wait' => SENDSTUDIO_SECURITY_WRONG_LOGIN_WAIT, 'threshold_login_count' => SENDSTUDIO_SECURITY_WRONG_LOGIN_THRESHOLD_COUNT, 'threshold_login_duration' => SENDSTUDIO_SECURITY_WRONG_LOGIN_THRESHOLD_DURATION / 60, 'ip_login_ban_duration' => SENDSTUDIO_SECURITY_BAN_DURATION / 60 ); $security_settings_options = array( 'login_wait' => array(1, 2, 3, 4, 5), 'threshold_login_count' => array(3, 4, 5, 10, 15), 'threshold_login_duration' => array(1, 5, 10, 15), 'ip_login_ban_duration' => array(1, 5, 10, 15) ); $tpl->Assign('security_settings', $security_settings); $tpl->Assign('security_settings_options', $security_settings_options); // ----- $tpl->Assign('AgencyEdition', get_agency_license_variables()); $showtab = 1; if (isset($_GET['Tab'])) { $tab = (int)$_GET['Tab']; if ($tab > 0) { $showtab = $tab; } } $GLOBALS['Message'] .= GetFlashMessages(); $tpl->Assign('ShowTab', $showtab); $tpl->Assign('DisplayPrivateLabel', (defined('APPLICATION_SHOW_WHITELABEL_MENU')? constant('APPLICATION_SHOW_WHITELABEL_MENU') : true)); $tpl->ParseTemplate('Settings'); $this->PrintFooter(); }
/** * Save * This function saves the current class vars to the settings file. * It checks to make sure the file is writable, then places the appropriate values in there and saves it. It uses a temporary name then copies that over the top of the old one, then removes the temporary file. * * @return Boolean Returns true if it worked, false if it fails. */ function Save() { require_once(SENDSTUDIO_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'interspire_addons.php'); if (!is_writable($this->ConfigFile)) { return false; } $tmpfname = tempnam(TEMP_DIRECTORY, 'SS_'); if (!$handle = fopen($tmpfname, 'w')) { return false; } $copy = true; if (is_file(TEMP_DIRECTORY . '/config.prev.php')) { if (!@unlink(TEMP_DIRECTORY . '/config.prev.php')) { $copy = false; } } if ($copy) { @copy($this->ConfigFile, TEMP_DIRECTORY . '/config.prev.php'); } // the old config backups were in the includes folder so try to clean them up as part of this process. $config_prev = SENDSTUDIO_INCLUDES_DIRECTORY . '/config.prev.php'; if (is_file($config_prev)) { @unlink($config_prev); } $contents = "<?php\n\n"; gmt($this); $areas = $this->Areas; foreach ($areas['config'] as $area) { // See self::LoadSettings() on UTF8PATCH settings if ($area == 'DATABASE_UTF8PATCH') { if (!defined('SENDSTUDIO_DATABASE_UTF8PATCH')) { define('SENDSTUDIO_DATABASE_UTF8PATCH', 1); } $contents .= "define('SENDSTUDIO_DATABASE_UTF8PATCH', '" . SENDSTUDIO_DATABASE_UTF8PATCH . "');\n"; continue; } $string = 'define(\'SENDSTUDIO_' . $area . '\', \'' . addslashes($this->Settings[$area]) . '\');' . "\n"; $contents .= $string; } $contents .= "define('SENDSTUDIO_IS_SETUP', 1);\n"; if (!defined('SENDSTUDIO_DEFAULTCHARSET')) { define('SENDSTUDIO_DEFAULTCHARSET', 'UTF-8'); } $contents .= "define('SENDSTUDIO_DEFAULTCHARSET', '" . SENDSTUDIO_DEFAULTCHARSET . "');\n"; $contents .= "\n\n"; fputs($handle, $contents, strlen($contents)); fclose($handle); chmod($tmpfname, 0644); if (!copy($tmpfname, $this->ConfigFile)) { return false; } unlink($tmpfname); $copy = true; if (is_file(TEMP_DIRECTORY . '/config.bkp.php')) { if (!@unlink(TEMP_DIRECTORY . '/config.bkp.php')) { $copy = false; } } if ($copy) { @copy($this->ConfigFile, TEMP_DIRECTORY . '/config.bkp.php'); } // the old config backups were in the includes folder so try to clean them up as part of this process. $config_bkp = SENDSTUDIO_INCLUDES_DIRECTORY . '/config.bkp.php'; if (is_file($config_bkp)) { @unlink($config_bkp); } unset($areas['config']); if (defined('APPLICATION_SHOW_WHITELABEL_MENU') && constant('APPLICATION_SHOW_WHITELABEL_MENU')) { $query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "whitelabel_settings"; $result = $this->Db->Query($query); foreach ($areas['whitelabel'] as $area) { // If settings are not set, do not continue if (!isset($this->Settings[$area])) { continue; } $value = $this->Settings[$area]; if (strtolower($area) == 'update_check_enabled') { $subAction = 'uninstall'; if ($value == '1') { $subAction = 'install'; } $result = Interspire_Addons::Process('updatecheck', $subAction, array()); continue; } elseif (strtolower($area) == 'lng_accountupgrademessage') { $agencyId = get_agency_license_variables(); if(empty($agencyId['agencyid'])) { continue; } } if (is_bool($value)) { $value = (int)$value; } $query = "INSERT INTO " . SENDSTUDIO_TABLEPREFIX . "whitelabel_settings(name, value) VALUES ('" . $this->Db->Quote($area) . "', '" . $this->Db->Quote($value) . "')"; $result = $this->Db->Query($query); } if ($this->WhiteLabelCache->exists('IEM_SETTINGS_WHITELABEL')) { $this->WhiteLabelCache->remove('IEM_SETTINGS_WHITELABEL'); } } if (isset($areas['whitelabel'])) { unset($areas['whitelabel']); } $stash = IEM_InterspireStash::getInstance(); if ($stash->exists('IEM_SYSTEM_SETTINGS')) { $stash->remove('IEM_SYSTEM_SETTINGS'); } $query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "config_settings"; $result = $this->Db->Query($query); foreach ($areas as $area) { $value = isset($this->Settings[$area]) ? $this->Settings[$area] : ''; if ($area == 'SYSTEM_DATABASE_VERSION') { $value = $this->Db->FetchOne("SELECT version() AS version"); } if (is_bool($value)) { $value = (int)$value; } $query = "INSERT INTO " . SENDSTUDIO_TABLEPREFIX . "config_settings(area, areavalue) VALUES ('" . $this->Db->Quote($area) . "', '" . $this->Db->Quote($value) . "')"; $result = $this->Db->Query($query); } return true; }