示例#1
0
 function DoModifyNormal()
 {
     if ('11111111' == $this->Post['config']['iphone_passphrase']) {
         $this->Post['config']['iphone_passphrase'] = $this->Config['iphone_passphrase'];
     }
     if (!($this->Post['config']['iphone_push_enable'] > 0 && $this->Post['config']['iphone_download_url'] && $this->Post['config']['iphone_passphrase'] && $this->Post['config']['iphone_pem_file'] && $this->_check_ipone_file($this->Post['config']['iphone_pem_file']) && is_file(ROOT_PATH . $this->Post['config']['iphone_pem_file']) && function_exists("openssl_open") && $this->_check_iphone_join($this->Post['config']['iphone_pem_file'], $this->Post['config']['iphone_passphrase']))) {
         $this->Post['config']['iphone_push_enable'] = 0;
     }
     if (isset($this->Post['config']['nickname_length'])) {
         $this->Post['config']['nickname_length'] = (int) $this->Post['config']['nickname_length'];
         if ($this->Config['ucenter_enable']) {
             $this->Post['config']['nickname_length'] = $this->Post['config']['nickname_length'] > 15 ? 15 : $this->Post['config']['nickname_length'];
         } elseif ($this->Post['config']['nickname_length'] > 50) {
             $this->Post['config']['nickname_length'] = 50;
         }
     }
     if (isset($this->Post['config']['website_home_page'])) {
         $website_home_page = explode('|', $this->Post['config']['website_home_page']);
         $this->Post['config']['default_module'] = $website_home_page[0];
         $this->Post['config']['default_code'] = $website_home_page[1] ? $website_home_page[1] : $website_home_page[0];
         unset($this->Post['config']['website_home_page']);
     }
     if (isset($this->Post['user_forbid'])) {
         if ($this->Post['user_forbid']) {
             $forbid_list = explode("\r\n", $this->Post['user_forbid']);
             $forbid_list = array_unique($forbid_list);
             $forbid = implode("\r\n", $forbid_list);
             jconf::set('user', array('forbid' => $forbid));
         }
         unset($this->Post['user_forbid']);
         $this->Post['config']['regstatus'] = isset($this->Post['config']['regstatus']) ? $this->Post['config']['regstatus'] : array();
         $this->Post['config']['third_party_regstatus'] = isset($this->Post['config']['third_party_regstatus']) ? $this->Post['config']['third_party_regstatus'] : array();
     }
     isset($this->Post['config']['regiter_tuijian']) && ($this->Post['config']['regiter_tuijian'] = $this->Post['config']['regiter_tuijian'] ? $this->Post['config']['regiter_tuijian'] : array());
     if (isset($this->Post['config']['watermark_contents_size'])) {
         $this->Post['config']['watermark_contents'] = isset($this->Post['config']['watermark_contents']) ? $this->Post['config']['watermark_contents'] : array();
     }
     if (isset($this->Post['email_white_list'])) {
         if ($this->Post['email_white_list']) {
             $email_white_list = explode("\r\n", $this->Post['email_white_list']);
             $email_white_list = array_remove_empty(array_unique($email_white_list));
             jconf::set('email_white_list', $email_white_list);
         } else {
             jconf::set('email_white_list', '');
         }
         unset($this->Post['email_white_list']);
     }
     if (isset($this->Post['register']['ip'])) {
         $register = jconf::get('register');
         $register['ip']['time_val'] = max(0, (int) $this->Post['register']['ip']['time_val']);
         $register['ip']['time_unit'] = $this->Post['register']['ip']['time_unit'];
         $register['ip']['limit'] = max(0, (int) $this->Post['register']['ip']['limit']);
         $time_unit_config = jconf::get('time_unit');
         $register['ip']['time'] = (int) ($register['ip']['time_val'] * $time_unit_config[$register['ip']['time_unit']]['unit']);
         $register['ip']['time_html'] = $register['ip']['time_val'] . $time_unit_config[$register['ip']['time_unit']]['name'];
         $ip_white_list = '';
         if ($this->Post['register']['ip']['white_list']) {
             $ip_white_list = explode("\n", $this->Post['register']['ip']['white_list']);
             foreach ($ip_white_list as $k => $v) {
                 $ip_white_list[$k] = trim($v);
             }
             $ip_white_list = array_remove_empty(array_unique($ip_white_list));
         }
         $register['ip']['white_list'] = $ip_white_list;
         jconf::set('register', $register);
         $this->Post['config']['register_check_ip_enable'] = $register['ip']['time'] > 0 && $register['ip']['limit'] > 0 ? 1 : 0;
         unset($this->Post['register']['ip']);
     }
     if (isset($this->Post['config']['site_name']) && empty($this->Post['config']['site_name'])) {
         $this->Messager("修改出现错误,站点名称不能为空");
     }
     if (isset($this->Post['config']['normal_default_role_id']) && empty($this->Post['config']['normal_default_role_id'])) {
         $this->Messager("修改出现错误,请先选择一个角色");
     }
     if (isset($this->Post['config']['thumbwidth'])) {
         $this->Post['config']['thumbwidth'] = min(300, max(30, (int) $this->Post['config']['thumbwidth']));
     }
     if (isset($this->Post['config']['thumbheight'])) {
         $this->Post['config']['thumbheight'] = min(300, max(30, (int) $this->Post['config']['thumbheight']));
     }
     if (isset($this->Post['config']['watermark_position'])) {
         $this->Post['config']['watermark_position'] = (int) $this->Post['config']['watermark_position'];
     }
     if (isset($this->Post['config']['image_size'])) {
         $this->Post['config']['image_size'] = max(10, min(51200, (int) $this->Post['config']['image_size']));
         $this->Post['config']['image_size_limit'] = $this->Post['config']['image_size'] * 1024;
     }
     if (isset($this->Post['seccode_setting'])) {
         $this->Post['config']['seccode_login'] = $this->Post['config']['seccode_login'] ? 1 : 0;
         $this->Post['config']['seccode_register'] = $this->Post['config']['seccode_register'] ? 1 : 0;
         $this->Post['config']['seccode_password'] = $this->Post['config']['seccode_password'] ? 1 : 0;
         $this->Post['config']['seccode_publish'] = $this->Post['config']['seccode_publish'] ? 1 : 0;
         $this->Post['config']['seccode_comment'] = $this->Post['config']['seccode_comment'] ? 1 : 0;
         $this->Post['config']['seccode_forward'] = $this->Post['config']['seccode_forward'] ? 1 : 0;
         $this->Post['config']['seccode_sms'] = $this->Post['config']['seccode_sms'] ? 1 : 0;
         $this->Post['config']['seccode_no_email'] = $this->Post['config']['seccode_no_email'] ? 1 : 0;
         $this->Post['config']['seccode_no_photo'] = $this->Post['config']['seccode_no_photo'] ? 1 : 0;
         $this->Post['config']['seccode_no_vip'] = $this->Post['config']['seccode_no_vip'] ? 1 : 0;
         $this->Post['config']['seccode_purviews'] = array();
         if (is_array($this->Post['config']['seccode_purview']) && count($this->Post['config']['seccode_purview'])) {
             foreach ($this->Post['config']['seccode_purview'] as $__spid) {
                 $__spid = jfilter($__spid, 'int');
                 if ($__spid > 0) {
                     $this->Post['config']['seccode_purviews'][$__spid] = $__spid;
                 }
             }
         }
         $this->Post['config']['seccode_enable'] = $this->Post['seccode_enable'] ? (int) $this->Post['seccode_enable'] : 0;
         if ($this->Post['config']['seccode_enable'] == 1) {
             $this->Post['config']['seccode_login'] = $this->Post['config']['seccode_logins'] ? 1 : 0;
             $this->Post['config']['seccode_register'] = $this->Post['config']['seccode_registers'] ? 1 : 0;
             $this->Post['config']['seccode_password'] = $this->Post['config']['seccode_passwords'] ? 1 : 0;
         }
         $this->Post['config']['seccode_purview'] = is_array($this->Post['config']['seccode_purview']) ? implode(',', $this->Post['config']['seccode_purview']) : '';
         $this->Post['config']['seccode_pri_key'] = $this->Post['config']['seccode_pri_key'] ? $this->Post['config']['seccode_pri_key'] : $this->yxm_pri_key;
         $this->Post['config']['seccode_pub_key'] = $this->Post['config']['seccode_pub_key'] ? $this->Post['config']['seccode_pub_key'] : $this->yxm_pub_key;
         unset($this->Post['seccode_setting']);
     }
     if (isset($this->Post['config']['is_qmd'])) {
         $this->Post['config']['is_qmd'] = $this->Post['config']['is_qmd'] ? 1 : 0;
         if ($this->Post['config']['is_qmd']) {
             if (!$this->Post['config']['qmd_file_url'] || !jmkdir($this->Post['config']['qmd_file_url'])) {
                 $this->Post['config']['qmd_file_url'] = 'images/qmd/';
             }
             if (!$this->Post['config']['qmd_fonts_url'] || !file_exists($this->Post['config']['qmd_fonts_url'])) {
                 $this->Post['config']['is_qmd'] = 0;
                 $this->Messager('请上传签名档必须的字体文件 ' . $this->Post['config']['qmd_fonts_url']);
             }
         }
         $this->Post['config']['qmd_link_display'] = $this->Post['config']['qmd_link_display'] ? 1 : 0;
     }
     if (isset($this->Post['config']['follow_limit'])) {
         $this->Post['config']['follow_limit'] = max(0, (int) $this->Post['config']['follow_limit']);
     }
     if (isset($this->Post['config']['topic_input_length'])) {
         $this->Post['config']['topic_input_length'] = max(0, (int) $this->Post['config']['topic_input_length']);
     }
     if (isset($this->Post['config']['gzip'])) {
         $this->Post['config']['gzip'] = $this->Post['config']['gzip'] && function_exists('ob_gzhandler') ? 1 : 0;
     }
     if (isset($this->Post['config']['reply_mode_normal'])) {
         $this->Post['config']['reply_mode_normal'] = $this->Post['config']['reply_mode_normal'] ? 1 : 0;
     }
     $new_config = $config = jconf::core_settings();
     foreach ($this->Post['config'] as $k => $v) {
         if (isset($this->Post['config'][$k]) && !is_null($v)) {
             $new_config[$k] = $v;
         }
     }
     $new_config['topic_cut_length'] = (int) $new_config['topic_cut_length'];
     if ($new_config['topic_cut_length'] > 200 || $new_config['topic_cut_length'] < 10) {
         $new_config['topic_cut_length'] = 140;
     }
     if (!$new_config['wap_url']) {
         $new_config['wap_url'] = $new_config['site_url'] . '/wap';
     }
     if (!$new_config['mobile_url']) {
         $new_config['mobile_url'] = $new_config['site_url'] . '/mobile';
     }
     $new_config['extra_domains'] = array();
     if ($new_config['extra_domain']) {
         $_arrs = explode("\n", $new_config['extra_domain']);
         foreach ($_arrs as $v) {
             $v = trim($v);
             $vl = strlen($v);
             if ($vl > 3 && $vl < 100) {
                 $new_config['extra_domains'][] = strtolower($v);
             }
         }
         $new_config['extra_domain'] = implode("\n", $new_config['extra_domains']);
     }
     $new_config['copyright'] = jstripslashes($new_config['copyright']);
     $new_config['tongji'] = jstripslashes($new_config['tongji']);
     $new_config['topic_view_share_code'] = jstripslashes($new_config['topic_view_share_code']);
     $new_config['regclosemessage'] = jstripslashes($new_config['regclosemessage']);
     $result = jconf::set($new_config);
     if ($result != false) {
         $this->Messager("配置修改成功");
     } else {
         $this->Messager("配置修改失败");
     }
 }