一、设置手机端门户页为首页,但不开启门户(PC端没有门户)

在主目录下(如p.pkgamehub.com)目录下找到index.php

在开头<? php 里增加以下代码:

if(it618_is_mobile()){ //手机访问时跳转
        header("location:portal.php?mobile=2");
        exit;
}

function it618_is_mobile(){
        $user_agent = $_SERVER['HTTP_USER_AGENT'];
        $mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
        $is_mobile = false;
        foreach ($mobile_agents as $device) {
        if (stristr($user_agent, $device)) {
        $is_mobile = true;
        break;
        }
        }
        return $is_mobile;
}

二、让ipad打开触屏版的discuz网站(否则难以上架appstore)

修改文件为:source\function\function_core.php

        if(dstrpos($useragent, $pad_list)) {
                return false;
        }

改成

        if(dstrpos($useragent, $pad_list)) {
                $_G['mobile'] = 'ipad';
                return '2';
        }

还有另外一个方子,仅供参考

discuz/source/function/function_core.php 


01
function checkmobile() {
02
    global $_G;
03
    $mobile = array();
04
    static $touchbrowser_list =array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini',
05
                'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung',
06
                'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser',
07
                'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource',
08
                'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone',
09
                'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop',
10
                'benq', 'haier', '^lct', '320x320', '240x320', '176x220', 'windows phone',***'ipad'***);
11
    static $wmlbrowser_list = array('cect', 'compal', 'ctl', 'lg', 'nec', 'tcl', 'alcatel', 'ericsson', 'bird', 'daxian', 'dbtel', 'eastcom',
12
            'pantech', 'dopod', 'philips', 'haier', 'konka', 'kejian', 'lenovo', 'benq', 'mot', 'soutec', 'nokia', 'sagem', 'sgh',
13
            'sed', 'capitel', 'panasonic', 'sonyericsson', 'sharp', 'amoi', 'panda', 'zte');
14
 
15
    ***//static $pad_list = array('ipad');***
16
 
17
    $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
18
 
19
    if(dstrpos($useragent, $pad_list)) {
20
        return false;
21
    }
22
    if(($v = dstrpos($useragent, $touchbrowser_list, true))){
23
        $_G['mobile'] = $v;
24
        return '2';
25
    }

1、static $pad_list = array(‘ipad’); 注释掉

 2、 $touchbrowser_list 里面添加值: ipad

三、会员模块增加用户组

在block_member文件中增加

	function fields() {
		global $_G;
		$fields = array(
				'id' => array('name' => lang('blockclass', 'blockclass_field_id'), 'formtype' => 'text', 'datatype' => 'int'),
				'url' => array('name' => lang('blockclass', 'blockclass_member_field_url'), 'formtype' => 'text', 'datatype' => 'string'),
				'title' => array('name' => lang('blockclass', 'blockclass_member_field_title'), 'formtype' => 'title', 'datatype' => 'title'),
				'avatar' => array('name' => lang('blockclass', 'blockclass_member_field_avatar'), 'formtype' => 'text', 'datatype' => 'string'),
				'avatar_middle' => array('name' => lang('blockclass', 'blockclass_member_field_avatar_middle'), 'formtype' => 'text', 'datatype' => 'string'),
				'avatar_big' => array('name' => lang('blockclass', 'blockclass_member_field_avatar_big'), 'formtype' => 'text', 'datatype' => 'string'),
				'regdate' => array('name' => lang('blockclass', 'blockclass_member_field_regdate'), 'formtype' => 'date', 'datatype' => 'date'),
				'posts' => array('name' => lang('blockclass', 'blockclass_member_field_posts'), 'formtype' => 'text', 'datatype' => 'int'),
				'threads' => array('name' => lang('blockclass', 'blockclass_member_field_threads'), 'formtype' => 'text', 'datatype' => 'int'),
				'digestposts' => array('name' => lang('blockclass', 'blockclass_member_field_digestposts'), 'formtype' => 'text', 'datatype' => 'int'),
				'credits' => array('name' => lang('blockclass', 'blockclass_member_field_credits'), 'formtype' => 'text', 'datatype' => 'int'),
				'reason' => array('name' => lang('blockclass', 'blockclass_member_field_reason'), 'formtype' => 'text', 'datatype' => 'string'),
				'unitprice' => array('name' => lang('blockclass', 'blockclass_member_field_unitprice'), 'formtype' => 'text', 'datatype' => 'int'),
				'showcredit' => array('name' => lang('blockclass', 'blockclass_member_field_showcredit'), 'formtype' => 'text', 'datatype' => 'int'),
				'shownote' => array('name' => lang('blockclass', 'blockclass_member_field_shownote'), 'formtype' => 'text', 'datatype' => 'string'),
				);
		foreach($_G['setting']['extcredits'] as $key=>$value) {
			$fields['extcredits'.$key] = array('name'=>$value['title'], 'formtype'=>'text', 'datatype'=>'int');
		}
		loadcache('profilesetting');
		foreach($_G['cache']['profilesetting'] as $key=>$value) {
			if($value['available']) {
				$fields[$key] = array('name'=>$value['title'], 'formtype'=>'text', 'datatype'=>'string');
			}
		}
		loadcache('usergroups');
		$fields['usergroup'] = array('name'=> '&#x7528;&#x6237;&#x7EC4;', 'formtype'=>'text', 'datatype'=>'string');
		return $fields;
	}

	function getsetting() {
		global $_G;
		$settings = $this->setting;

		if($settings['extcredit']) {
			foreach($_G['setting']['extcredits'] as $id => $credit) {
				$settings['extcredit']['value'][] = array($id, $credit['title']);
			}
		}
		if($settings['groupid']) {
			$settings['groupid']['value'][] = array(0, lang('portalcp', 'block_all_group'));
			foreach(C::t('common_usergroup')->fetch_all_by_type(array('member', 'special')) as $value) {
				$settings['groupid']['value'][] = array($value['groupid'], $value['grouptitle']);
			}
		}
		return $settings;
	}
if($uids) {
			$wheres[] = 'm.uid IN ('.dimplode($uids).')';
		}
		$wheres[] = '(m.groupid < 4 OR m.groupid > 8)';

		$tables = array_unique($tables);
		$wheres = array_unique($wheres);
		$tablesql = implode(',',$tables);
		$wheresql = implode(' AND ',$wheres);
		$query = DB::query("SELECT m.*, mc.*$reason$show FROM $tablesql WHERE $wheresql $sqlorderby LIMIT $startrow,$items");
		$resultuids = array();
		loadcache('usergroups');
		while($data = DB::fetch($query)){
			$resultuids[] = intval($data['uid']);
			$list[] = array(
				'id' => $data['uid'],
				'idtype' => 'uid',
				'title' => $data['username'],
				'url' => 'home.php?mod=space&uid='.$data['uid'],
				'pic' => '',
				'picflag' => 0,
				'summary' => '',
				'fields' => array(
					'avatar' => avatar($data['uid'], 'small', true, false, false, $_G['setting']['ucenterurl']),
					'avatar_middle' => avatar($data['uid'], 'middle', true, false, false, $_G['setting']['ucenterurl']),
					'avatar_big' => avatar($data['uid'], 'big', true, false, false, $_G['setting']['ucenterurl']),
					'credits' => $data['credits'],
					'extcredits1' => $data['extcredits1'],
					'extcredits2' => $data['extcredits2'],
					'extcredits3' => $data['extcredits3'],
					'extcredits4' => $data['extcredits4'],
					'extcredits5' => $data['extcredits5'],
					'extcredits6' => $data['extcredits6'],
					'extcredits7' => $data['extcredits7'],
					'extcredits8' => $data['extcredits8'],
					'regdate' => $data['regdate'],
					'posts' => empty($todayposts[$data['uid']]) ? $data['posts'] : $todayposts[$data['uid']],
					'threads' => $data['threads'],
					'digestposts' => $data['digestposts'],
					'reason' => isset($data['reason']) ? $data['reason'] : '',
					'unitprice' => isset($data['unitprice']) ? $data['unitprice'] : '',
					'showcredit' => isset($data['showcredit']) ? $data['showcredit'] : '',
					'shownote' => isset($data['shownote']) ? $data['shownote'] : '',
					'usergroup' => $_G['cache']['usergroups'][$data['groupid']]['grouptitle'],
				)
			);
		}

四、让简易版和标准版都直接进入触屏版

source/class/discuz/discuz_application.php文件

'mobiletpl' => array('1' => 'mobile', '2' => 'touch', '3' => 'wml', 'yes' => 'touch'),

修改为

'mobiletpl' => array('1' => 'touch', '2' => 'touch', '3' => 'wml', 'yes' => 'touch'),

以及

if(!$mobile || $mobile == 'yes') {
	$mobile = isset($mobile_) ? $mobile_ : 2;
}

修改为

if(!$mobile || $mobile == 'yes' || $mobile == '1') {
	$mobile = 2;
}

五、头像无法保存

原因是因为如果域名使用了https,则在UCcent处的地址也要为https

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据