page->ajaxReplace = array(); //add examples to smtp_hosts $langmessage['about_config']['smtp_hosts'] .= 'ssl://smtp.gmail.com:465 ; tls://smtp.live.com:587'; $langmessage['about_config']['showgplink'] = 'Showing the "powered by" link on your site is a great way to support '.CMS_NAME.' CMS.'; $langmessage['about_config']['history_limit'] = 'Max: '.gp_backup_limit; $langmessage['about_config']['maxthumbsize'] .= ' '.\gp\tool::Link('Admin/Configuration',$langmessage['recreate_all_thumbnails'],'cmd=recreate_thumbs','class="" data-cmd="creq"'); $this->variables = array( // these values aren't used //'timeoffset'=>'', //'dateformat'=>'', /* General Settings */ 'general_settings' => false, 'title' => '', 'keywords' => '', 'desc' => 'textarea', 'Interface' => false, 'colorbox_style' => [ 'minimalistic' => 'Minimalistic', 'example1' => 'Example 1', 'example2' => 'Example 2', 'example3' => 'Example 3', 'example4' => 'Example 4', 'example5' => 'Example 5', ], 'gallery_legacy_style' => 'boolean', 'language' => '', 'langeditor' => '', 'showsitemap' => 'boolean', 'showlogin' => 'boolean', 'showgplink' => 'boolean', 'Images' => false, 'allow_svg_upload' => 'boolean', 'maximgarea' => 'integer', 'resize_images' => 'boolean', 'preserve_icc_profiles' => 'boolean', 'preserve_image_metadata' => 'boolean', 'maxthumbsize' => 'integer', 'maxthumbheight' => 'integer', 'thumbskeepaspect' => 'boolean', 'Performance' => false, 'auto_redir' => 'integer', 'history_limit' => 'integer', 'HTML_Tidy' => '', 'Report_Errors' => 'boolean', 'combinejs' => 'boolean', 'minifyjs' => 'boolean', 'combinecss' => 'boolean', 'etag_headers' => 'boolean', 'space_char' => [ '_' => 'Underscore "_"', '-' => 'Dash "-"' ], /* Hide Admin UI Settings */ 'Hide Admin UI' => false, 'admin_ui_autohide_below' => 'integer', 'admin_ui_hotkey' => '', 'admin_ui_hotkey_code' => 'hidden', /* Contact Configuration */ 'contact_config' => false, 'toemail' => '', 'toname' => '', 'from_address' => '', 'from_name' => '', 'from_use_user' => 'boolean', 'require_email' => '', 'contact_advanced' => false, 'mail_method' => '', 'sendmail_path' => '', 'smtp_hosts' => '', 'smtp_user' => '', 'smtp_pass' => 'password', //'fromemail' => '', 'reCaptcha' => false, 'recaptcha_public' => '', 'recaptcha_private' => '', 'recaptcha_language' => '', ); } public function RunScript(){ $cmd = \gp\tool::GetCommand(); switch($cmd){ case 'save_config': $this->SaveConfig(); break; case 'recreate_thumbs': $this->RecreateThumbs(); break; } $this->showForm(); } /** * Save the posted configuration * */ protected function SaveConfig(){ global $config, $langmessage; $config_before = $config; $possible = $this->getPossible(); foreach($possible as $key => $curr_possible){ if( $curr_possible == 'boolean' ){ if( isset($_POST[$key]) && ($_POST[$key] == 'true') ){ $config[$key] = true; }else{ $config[$key] = false; } }elseif( $curr_possible == 'integer' ){ if( isset($_POST[$key]) && ( is_numeric($_POST[$key]) || $_POST[$key] == '' ) ){ // also allow empty values $config[$key] = $_POST[$key]; } }elseif( isset($_POST[$key]) ){ $config[$key] = $_POST[$key]; } } $config['history_limit'] = min($config['history_limit'],gp_backup_limit); if( !\gp\admin\Tools::SaveConfig(true) ){ return false; } if( isset($_GET['gpreq']) && $_GET['gpreq'] == 'json' ){ msg($langmessage['SAVED'].' '.$langmessage['REFRESH']); }else{ msg($langmessage['SAVED']); } //resize thumbnails if( $config_before['preserve_icc_profiles'] !== $config['preserve_icc_profiles'] || $config_before['preserve_image_metadata'] !== $config['preserve_image_metadata'] || $config_before['maxthumbsize'] !== $config['maxthumbsize'] || $config_before['maxthumbheight'] !== $config['maxthumbheight'] || $config_before['thumbskeepaspect'] !== $config['thumbskeepaspect'] ){ msg(\gp\tool::Link( 'Admin/Configuration', $langmessage['recreate_all_thumbnails'], 'cmd=recreate_thumbs', [ 'class' => '', 'data-cmd' => 'creq', ] )); } } private function getValues(){ global $config; $mailer = new \gp\tool\Emailer(); if( $_SERVER['REQUEST_METHOD'] != 'POST'){ $show = $config; }else{ $show = $_POST; } if( empty($show['recaptcha_language']) ){ $show['recaptcha_language'] = 'inherit'; } if( empty($show['from_address']) ){ $show['from_address'] = $mailer->From_Address(); } if( empty($show['from_name']) ){ $show['from_name'] = $mailer->From_Name(); } if( empty($show['mail_method']) ){ $show['mail_method'] = $mailer->Mail_Method(); } //suhosin will stop the script if a POST value contains a real path like /usr/sbin/sendmail //if( empty($show['sendmail_path']) ){ // $show['sendmail_path'] = $mailer->Sendmail_Path(); //} return $show; } /** * Get possible configuration values * */ protected function getPossible(){ global $dataDir,$langmessage; $possible = $this->variables; $langDir = $dataDir.'/include/thirdparty/ckeditor/lang'; //ckeditor $possible['langeditor'] = \gp\tool\Files::readDir($langDir,'js'); unset($possible['langeditor']['_languages']); $possible['langeditor']['inherit'] = ' '.$langmessage['default']; //want it to be the first in the list asort($possible['langeditor']); //recaptcha language $possible['recaptcha_language'] = []; $possible['recaptcha_language']['inherit'] = $langmessage['default']; // According to https://developers.google.com/recaptcha/docs/language $recaptcha_languages = [ 'af', 'am', 'ar', 'az', 'bn', 'bg', 'ca', 'cs', 'da', 'de', 'de-AT', 'de-CH', 'el', 'en', 'en-GB', 'es', 'es-419', 'et', 'eu', 'fa', 'fi', 'fil', 'fr', 'fr-CA', 'gl', 'gu', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'iw', 'ja', 'ka', 'kn', 'ko', 'lo', 'lt', 'lv', 'ml', 'mn', 'mr', 'ms', 'nl', 'no', 'pl', 'pt', 'pt-BR', 'pt-PT', 'ro', 'ru', 'si', 'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk', 'ur', 'vi', 'zh-HK', 'zh-CN', 'zh-TW', 'zu', ]; foreach($recaptcha_languages as $lang){ $possible['recaptcha_language'][$lang] = $lang; } //website language $possible['language'] = $this->GetPossibleLanguages(); //tidy if( function_exists('tidy_parse_string') ){ $possible['HTML_Tidy'] = [ 'off' => $langmessage['Off'], '' => $langmessage['On'] ]; }else{ $possible['HTML_Tidy'] = [''=>'Unavailable']; } //required email fields $possible['require_email'] = [ 'none' => 'None', '' => 'Subject & Message', 'email' => 'Subject, Message & Email' ]; //see xoopsmultimailer.php $possible['mail_method'] = [ 'mail' => 'PHP mail()', 'sendmail' => 'sendmail', 'smtp' => 'smtp', 'smtpauth' => 'SMTPAuth' ]; //CDN foreach(\gp\tool\Output\Combine::$scripts as $key => $script_info){ if( !isset($script_info['cdn']) ){ continue; } $config_key = 'cdn_'.$key; if( !array_key_exists($config_key, $possible) ){ continue; } $opts = array_keys($script_info['cdn']); $possible[$config_key] = array_combine($opts, $opts); array_unshift($possible[$config_key],$langmessage['None']); } gpSettingsOverride('configuration',$possible); return $possible; } /** * Return a list of possible languages * Based on the files in /include/languages * */ private function GetPossibleLanguages(){ global $dataDir; $lang_dir = $dataDir.'/include/languages'; $files = scandir($lang_dir); $languages = array(); foreach($files as $file){ if( $file == '.' || $file == '..' || strpos($file,'main.inc') === false ){ continue; } $languages[] = str_replace('.main.inc','',$file); } return array_combine($languages, $languages); } /** * Display configuration settings * */ protected function showForm(){ global $langmessage; $possible_values = $this->getPossible(); $array = $this->getValues(); echo '
'; } /** * Display Save buttons * */ protected function SaveButtons(){ global $langmessage; echo ''; echo ''; echo $langmessage['see_also']; echo ' '; echo \gp\tool::Link('Admin/Preferences',$langmessage['Preferences'],'','data-cmd="gpabox"'); echo '
'; } /** * Display Save All buttons * @param boolean $is_last If true include admin notice and hidden cmd input */ protected function SaveAllButton($is_last=true){ global $langmessage; echo ''; echo ''; echo $langmessage['see_also']; echo ' '; echo \gp\tool::Link('Admin/Preferences',$langmessage['Preferences'],'','data-cmd="gpabox"'); echo '
'; } } /** * Form Functions * */ public function formCheckbox($key,$value){ $checked = ''; if( $value && $value !== 'false' ){ $checked = ' checked="checked"'; } echo ' '; echo ' '; } public function formInput($name,$value,$type='text'){ echo "\n