| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049 | <?php/** * 用户操作业务 * @author cp * */if (! defined ( 'IN_ZHASK' )) {	exit ( 'invalid request' );}class UserController extends DooController {		private $userlogic;	private $asklogic;		private $userinfo = array ('uid' => '0' );		function __construct() {				Load::controller ( "BaseController" );				$base = new BaseController ();				$this->userinfo = $base->init ();				Load::logic ( 'User' );		Load::logic ( 'Ask' );				$this->userlogic = new UserLogic ();		$this->asklogic = new AskLogic ();	}		public function index() {				//$this->userlogic->test_send_gmail("",$this->userinfo['uid'],"NEW_ANSWER");				//$this->userlogic->sendmail("","cpthought@vip.qq.com");				$this->userlogic->delete_search_index(array('17847', '17846', '17845'));		//		require_once (SITE_PATH . '/protected/plugin/client.php');	//			//		$client = new client ( ZHSSO );	//			//		$is_succes = $client->zhsso_member_madd ( 88,5,"ask" );	//			//		$is_succes=explode("\r",$is_succes);	//			//		$ts = json_decode ( $is_succes['1'], true );	//			//		var_dump($ts);		}		function user_exit() {				$sid = $_COOKIE ['sid'];		$this->userlogic->delete_session ( $sid );				setcookie ( "auth", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );		setcookie ( "sid", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );		setcookie ( "tuid", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );		setcookie ( "e", '1', time () + 3600 * 24, "/", COOKIE_WEB_SITE );		$this->Messager ( "登出成功", "/" );	}		public function sysLoginOut(){		$sid = $_COOKIE ['sid'];				$this->userlogic->delete_session ( $sid );				setcookie ( "auth", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );				setcookie ( "sid", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );				setcookie ( "tuid", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );	}		/**	 * 同步登陆	 */	public function synLogin() {    	    	$uid=$this->params['username'];    	    	require_once (SITE_PATH . '/protected/plugin/client.php');        $client = new client(ZHSSO);        //检测认证        $auth=$client->zhsso_checkauth($uid);                $a = explode ( "\r", $auth );//        var_dump($a);//		exit();        if($a!='1')        	return false;        	        $user=$client->zhsso_getuserinfo_by_uid ( $uid );                $u = explode ( "\r", $user );        		$user = json_decode($u[0]);				//同步通行证用户		$us = $this->userlogic->get_users_by_name ( $user[0]->username );				if (empty ( $us )) {			$uid = $this->userlogic->add_user2 ( $user[0] );							$us = $this->userlogic->get_users_information ( $uid );		} else {			$uid = $this->userlogic->update_user2 ( $us['uid'], $user[0] );		}				$userinfo = authcode ( $user[0]->username, "tr" );				$sessionID = random ( 8 );				//写入session		//默认生命周期1天		$lifetime = get_date ( 1 );		$this->userlogic->set_session ( $sessionID, $us ['uid'], $user[0]->username, $lifetime );		        header('P3P: CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"');//p3p          setcookie ( "auth", $userinfo, time () + 3600 * 24, "/", COOKIE_WEB_SITE );		setcookie ( "sid", $sessionID, time () + 3600 * 24, "/", COOKIE_WEB_SITE );		setcookie ( "tuid", $user[0]->id, time () + 3600 * 24, "/", COOKIE_WEB_SITE );    }	// 检测手机格式	function checkMobile($mobile) {		if(preg_match("/^1[34578]{1}\d{9}$/",$mobile)){			return TRUE;		} else {			return FALSE;		}	}		/**	 * 用户登录处理--session和用户日志后期可以改成写入文件	 */	function do_login() {				$username = $this->get_args ( "username" );		$password = $this->get_args ( "password" );				$day = is_numeric ( $this->get_args ( "day" ) ) ? $this->get_args ( "day" ) : 1;				$lifetime = $day < 0 ? 0 : $day;				if (empty ( $username ) || empty ( $password )) {			$this->Messager ( "请输入正确的参数", "/login" );		}				require_once (SITE_PATH . '/protected/plugin/client.php');				$client = new client ( ZHSSO );				if(filter_var($username, FILTER_VALIDATE_EMAIL)){			$is_login = $client->zhsso_member_login ( $username, $password ,1);					}else if($this->checkMobile($username)) {			$is_login = $client->zhsso_member_login( $username, $password, 2 );		}else{			$is_login = $client->zhsso_member_login ( $username, $password );		}		$is_login = explode ( "\r", $is_login );		if (is_numeric ( $is_login [0] )) {			if ($is_login [0] == USERNAME_ONFINE) {								$this->Messager ( "您输入的帐号或者密码有误", "/login" );								//删除用户相关记录--是否有同步删除功能				//if ($user) {					//$this->userlogic->delete_user_tem( $user['uid']);				//}			} elseif ($is_login [0] == PASSWORD_ERROR)				$this->Messager ( "您输入的帐号或者密码有误", "/login" );			elseif ($is_login [0] == - 3) //USER_NOACTION				$this->Messager ( "用户未激活", "http://sso.smartcost.com.cn/" );			else 				$this->Messager ( "您输入的帐号或者密码有误", "/login" );		} elseif (! empty ( $is_login [0] )) {						$ts = json_decode ( $is_login [0], true );						if (empty ( $ts ))				$this->Messager ( "通信异常", "/login" );						$user = $this->userlogic->get_users_by_name ( $ts [0] ['username'] );			//同步通行证用户			if (empty ( $user )) {				$uid = $this->userlogic->add_user2 ( $ts [0]);								$user = $this->userlogic->get_users_information ( $uid );			}else{				$uid = $this->userlogic->update_user2 ( $user['uid'], $ts [0]);			}			Doo::loadModel ( 'MessageDao' );						$messagedao = new MessageDao ();						$message_count = $messagedao->get_message_count_by_touid ( $user ['uid'] );						$sessionID = random ( 8 );						$ip = client_ip ();						//默认生命周期1天			$lifetime = get_date ( $lifetime );						$userinfo = authcode ( $user ['username'], "tr" );						//写入session			$this->userlogic->set_session ( $sessionID, $user ['uid'], $user ['username'], $lifetime );						//写入用户日志			$this->userlogic->set_userlog ( $user ['uid'], $user ['username'] );						//积分值增加-做今天登陆判断			$s_status = $this->userlogic->get_crontab_status ( $user ['uid'], SYSTEM_DAILY_LOGIN );						if ($s_status != COMPLETE||$s_status===0) {								$this->userlogic->set_credit1 ( 'add', $user ['uid'], CREDIT_POINT_LOGIN, CREDIT_ACTION_LOGIN );								$this->userlogic->complete_daily_crontab ( $user ['uid'], SYSTEM_DAILY_LOGIN );			}						if($user['is_email']!=1){								$this->userlogic->set_email_config($user['uid']);			}						$avatar = $client->ps_getavatar ( $ts [0] ['id'] );						foreach ($avatar as $key=>$value){				if(!file_get_contents($value,0,null,0,1))					$avatar[$key]=DEF_AVATAR;			}						$avatar=json_encode($avatar);						$this->userlogic->update_user_avatar_by_id($user ['uid'],$avatar);						define ( "MASTER_ID", $user ['uid'] );			define ( 'MEMBER_NAME', $user ['username'] );						define ( "MESSAGE_COUNT", $message_count ['count'] );						setcookie ( "auth", $userinfo, time () + 3600 * 24, "/", COOKIE_WEB_SITE );			setcookie ( "sid", $sessionID, time () + 3600 * 24, "/", COOKIE_WEB_SITE );			setcookie ( "tuid", $ts [0] ['id'], time () + 3600 * 24, "/", COOKIE_WEB_SITE );			setcookie ( "d", $ts [0] ['keys_auth'], time () + 3600 * 24, "/", COOKIE_WEB_SITE );			//define("SYS_LOGIN",'<script src="http://zhzdwk.com/api/text_cook"></script>');					} else {			$this->Messager ( "通信异常", "/login" );		}				//http://localzhask.com/login http://zhzdwd.com/login				if($_SERVER['HTTP_REFERER']=="http://zhzdwd.com/login")			return "/";		else			return $_SERVER['HTTP_REFERER'];	}		function getquestion(){		$condition = " and price != 0 ";		$limit = " order by time desc limit 3";		$question= $this->asklogic->get_questions_list_tem ( array (), $condition, $limit );		$page['question']=array();		 		$t=array();		foreach ($question as $key=>$value){			$t['id']=$value['id'];			$t['price']=$value['price'];			$t['title']=$value['title'];						array_push($page['question'], $t);		}				/*		$QA=$this->asklogic->get_QA();		$page['QA']=$QA;		*/		echo json_encode($page);	}		/**	 * 删除回答	 */	function do_delete_answer() {		$aid = $this->check_params ( 'aid' );		$qid = $this->check_params ( 'qid' );				$aid = is_numeric ( $aid ) ? $aid : 0;				$qid = is_numeric ( $qid ) ? $qid : 0;				if ($aid <= 0 || $qid <= 0)			$this->Messager ( "请输入正确的参数", "/askpage/" . $qid );				//用户组		if ($this->userinfo ['groupid'] != SUPER_ADMIN_ID && $this->userinfo ['groupid'] != ADMIN_ID)			$this->Messager ( "权限不足,请联系管理员", "/askpage/" . $qid );				$this->userlogic->delete_answer ( $aid ,$qid);				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=问题已经成功删除&url=/askpage/" . $qid );		}		/**	 * 删除问题	 */	function do_delete_question() {		$qid = $this->check_params ( 'qid' );				$qid = is_numeric ( $qid ) ? $qid : 0;				if ($qid <= 0)			$this->Messager ( "请输入正确的参数", "/askpage/" . $qid );				//用户组		if ($this->userinfo ['groupid'] != SUPER_ADMIN_ID && $this->userinfo ['groupid'] != ADMIN_ID)			$this->Messager ( "权限不足,请联系管理员", "/askpage/" . $qid );				$this->userlogic->delete_question ( $qid );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=问题已经成功删除&url=/" );	}		/**	 * 关闭问题	 */	public function do_question_close() {				$qid = is_numeric ( $this->params ['qid'] ) ? $this->params ['qid'] : 0;		$rs = $this->asklogic->get_question_by_uqid ( $qid, $this->userinfo ['uid'] );				if ($qid <= 0)			$this->Messager ( "请输入正确的参数", "/" );				//删除权限的判定		if ($this->userinfo ['groupid'] != SUPER_ADMIN_ID && $this->userinfo ['groupid'] != ADMIN_ID) {			if (empty ( $rs ))				$this->Messager ( "操作有误", "/" );		}				$this->userlogic->close_question ( $qid );				$type="CLOSE_QUESTION";				if($rs['price']>0)			$type="PAY_CLOSE_QUESTION";				$this->userlogic->send_email($this->userinfo ['uid'],$type,$qid,0);				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=问题已经成功关闭&url=/askpage/" . $qid );	}		/**	 * 设置最佳答案--管理员也使用	 */	public function do_best_answer() {				$data ['qid'] = $this->get_args ( 'qid' );		$data ['aid'] = $this->get_args ( 'aid' );				$data ['comment'] = $this->get_args ( 'comment' );				$rs = $this->asklogic->get_question_by_uqid ( $data ['qid'], $this->userinfo ['uid'] );		$ans = $this->asklogic->get_answer_by_aqid ( $data ['aid'], $data ['qid'] );				//操作权限的判定		if ($this->userinfo ['groupid'] != SUPER_ADMIN_ID && $this->userinfo ['groupid'] != ADMIN_ID) {			if (empty ( $rs ))				$this->Messager ( "权限不足,请联系管理员", "/" );		}				if($rs['status']!=QUESTOIN_STATUS_UNRESOLVED){			$this->Messager ( "该问题已进行相关操作", "/" );		}				if (empty ( $ans ))			$this->Messager ( "没有相关问题", "/" );				if (! is_numeric ( $data ['qid'] ) || ! is_numeric ( $data ['aid'] ))			$this->Messager ( "请输入正确的值", "/" );				$data ['quid'] = $rs ['authorid'];		$data ['auid'] = $ans ['authorid'];		$data ['title'] = $rs ['title'];		$data ['price'] = $rs ['price'];		$data ['username'] = $ans ['author'];		$this->userlogic->set_best_answer ( $data );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=答案采纳成功&url=/askpage/" . $data ['qid'] );	}		/**	 * 发起名师答疑2	 */	public function do_update_vip_question() {				$rs = $this->asklogic->get_vip_question_by_paid ( $this->userinfo ['uid'] );				if (empty ( $rs ))			$this->Messager ( "请先付款", "/question/add_vip" );				$title = $this->get_args ( 'title' );        // xxs过滤        $title = htmlspecialchars($title);		$description = stripcslashes ( $this->get_args ( 'description' ) );				if (empty ( $title ) || empty ( $description ))			$this->Messager ( "请填写相关信息", "/question/add_vip" );				$phone = $this->get_args ( 'phone' );		$qq = $this->get_args ( 'qq' );		$this->userlogic->update_vip_question ( $rs ['id'], $title, $description, $this->userinfo ['uid'], $phone, $qq );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=问题发起成功&url=/advisory_page/" . $rs ['id'] );	}		/**	 * 发起名师答疑1	 */	public function do_add_vip_question() {		require_once SITE_PATH . '/protected/config/auth_issue.conf.php';				$auth = $auth ['GENERAL_USER_GROUP' . $this->userinfo ['groupid']];				$issue = $this->asklogic->auth_question_issue ( $this->userinfo ['uid'], $this->userinfo ['groupid'], $auth );				if ($issue == 2)			$this->Messager ( "您今天提问条数(" . $auth ['DAY_TOTALS'] . ")已用完", "/" );		elseif ($issue == 3)			$this->Messager ( "每" . $auth ['TIME_INTERVAL']/60 . "分钟内只可以发布" . $auth ['TIME_TOTALS'] . "条", "/" );				$price = $this->get_args ( 'price' );				$price = is_numeric ( $price ) ? $price : 0;				//已付款未填写		$rs = $this->asklogic->get_vip_question_by_paid ( $this->userinfo ['uid'] );				$data ['mod'] = 'askpost';		$data ['price'] = $price;		$data ['qq'] = $this->userinfo ['qq'];		$data ['phone'] = $this->userinfo ['phone'];		if (! empty ( $rs )) { //防止重复提交			$data ['qid'] = $rs ['id'];			$data ['message'] = "您上一次付款后没有发布问题,故本次提问不做重复扣费";			$this->render ( 'askPost_pay_2', $data );						die ();		}				if ($price <= 0)			$this->Messager ( "金额不足,请充值", "/question/add_vip" );				if ($price > $this->userinfo ['credit3'])			$this->Messager ( "金额不足,请充值", "/question/add_vip" );				if (($this->userinfo ['credit3'] - $price) < 0)			$this->Messager ( "金额不足,请充值", "/question/add_vip" );				if (! ($price == 500 || $price == 200 || $price == 100))			$this->Messager ( "金额只能为500元,200元,100元", "/question/add_vip" );				//确认付费		$data ['author'] = $this->userinfo ['username'];		$data ['authorid'] = $this->userinfo ['uid'];				$id = $this->userlogic->add_vip_question ( $data );		if ($id == 0)			$this->Messager ( "操作失败-请重新操作", "/question/postenter" );				$data ['qid'] = $id;				$this->render ( 'askPost_pay_2', $data );	}		/**	 * 添加一条问题	 */	public function do_add_question() {						$start=strtotime(date("Y-m-d")." 23:00:00");		$end=strtotime(date("Y-m-d")." 23:59:59");				$one=strtotime(date("Y-m-d")." 00:00:00");		$two=strtotime(date("Y-m-d")." 8:00:00");				//$end=strtotime(date("Y-m-d",strtotime("+1 day"))." 8:00:00");				if ($one<=time()&&$two>=time()){			$this->render ( 'askPost_close' );			die;		}				if ($start<=time()&&$end>=time()){			$this->render ( 'askPost_close' );			die;		}				session_start();				require_once ('./protected/plugin/class.geetestlib.php');				$GtSdk = new GeetestLib();		if ($_SESSION['gtserver'] == 1) {		    $result = $GtSdk->validate($_POST['geetest_challenge'], $_POST['geetest_validate'], $_POST['geetest_seccode']);		    if ($result == TRUE) {		        //echo 'Yes!';		    } else if ($result == FALSE) {		       $this->Messager("请检查验证是否正确", "/question/add");		    } else {		       $this->Messager("请检查验证是否正确", "/question/add");		    }		}else{		    if ($GtSdk->get_answer($_POST['geetest_validate'])) {		        //echo "yes";		    }else{		       $this->Messager("请检查验证是否正确", "/question/add");		    }		}//		die;		//		if(!isset($_POST['vc']) || ($_SESSION['vc']!=$_POST['vc'])){//				 $this->Messager("请检查验证是否正确", "/question/add");//		}		//检测问题数		require_once SITE_PATH . '/protected/config/auth_issue.conf.php';				$auth = $auth ['GENERAL_USER_GROUP' . $this->userinfo ['groupid']];				$issue = $this->asklogic->auth_question_issue ( $this->userinfo ['uid'], $this->userinfo ['groupid'], $auth );				if ($issue == 2)			$this->Messager ( "您今天提问条数(" . $auth ['DAY_TOTALS'] . ")已用完", "/" );		elseif ($issue == 3)			$this->Messager ( "每" . $auth ['TIME_INTERVAL']/60 . "分钟内只可以发布" . $auth ['TIME_TOTALS'] . "条", "/" );				$data ['title'] = $this->get_args ( 'title' );		// 防止xxs攻击        $data['title'] = htmlspecialchars($data['title']);		$data ['category_id'] = $this->get_args ( 'category_id' );		$data ['description'] = stripcslashes ( $this->get_args ( 'description' ) );		$data ['price'] = $this->get_args ( 'price' );				if ($data ['price'] !== false) {						$data ['price'] = is_numeric ( $data ['price'] ) ? $data ['price'] : 0;						if ($this->userinfo ['credit3'] < $data ['price'])				$this->Messager ( "财富值不足,请充值", "/question/add" );		} else {			$data ['price'] = 0;		}				$data ['authorid'] = $this->userinfo ['uid'];				$data ['author'] = $this->userinfo ['username'];		//|| empty ( $data ['description'] )		if (empty ( $data ['title'] ) || (! is_numeric ( $data ['category_id'] )))			$this->Messager ( "问题发起不成功,请重新填写", "/question/add" );		$id = $this->userlogic->add_examine_question ( $data );		$_SESSION['vc']='NULL';		if ($id) {			header ( 'Content-Type:text/html;charset=utf-8' );			@header ( "Location: " . WEB_SITE . "/messager?content=问题发起成功,待审批通过&url=/" );		} else {			header ( 'Content-Type:text/html;charset=utf-8' );			@header ( "Location: " . WEB_SITE . "/messager?content=问题发起不成功,请重新填写&url=/question/add" );		}	}	/**	 * 回答一个问题--添加积分,财富	 */	public function do_reply_question() {		//include Doo::conf()->BASE_PATH.'diagnostic/debug.php';		$answer_data = $this->get_args ( 'answer_data' );				$content = stripcslashes ( $this->get_args ( 'content' ) );				if (empty ( $content ))			return false;				$answer_data = explode ( ":", $answer_data );				$data ['qid'] = $answer_data [0];				$data ['title'] = $answer_data [1];				$data ['author'] = $this->userinfo ['username'];				$data ['authorid'] = $this->userinfo ['uid'];				$data ['content'] = $content;				if (! is_numeric ( $data ['qid'] ) || ! is_numeric ( $data ['authorid'] ))			return false;				$answer=$this->asklogic->get_answer_by_quid($data ['qid'],$this->userinfo ['uid']);					if(!empty($answer))			return false;					//添加一个回答		$id = $this->userlogic->add_answer ( $data );				$question=$this->asklogic->get_question_by_qid($data ['qid']);					$type="NEW_ANSWER";				if($question['price']>0)			$type="PAY_NEW_ANSWER";					//发送邮件		$this->userlogic->send_email($this->userinfo ['uid'],$type,$data ['qid'],$id);				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=回答成功&url=/askpage/" . $answer_data [0] );	}		/**	 * 追问一个回答	 */	public function to_ask_question() {				$id = $this->get_args ( 'id' );				$id = explode ( ":", $id );				$tag = stripcslashes ( $this->get_args ( 'tag' ) );				if(!is_numeric($id [1])||!is_numeric($id[0]))			$this->Messager ( "请输入正确的参数", "/askpage/". $id [1] );				if(empty($tag))			$this->Messager ( "请填写追问内容", "/askpage/". $id [1] );				$data ['id'] = $id [0];				$data ['tag'] = $tag;				//添加一个回答		$this->userlogic->to_ask_question ( $data );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=追问成功&url=/askpage/" . $id [1] );	}		/**	 * 回答一个追问	 */	public function answer_again() {				$id = $this->get_args ( 'id' );				$id = explode ( ":", $id );				$tag = stripcslashes ( $this->get_args ( 'tag' ) );				//回答ID		$data ['id'] = $id [0];				//再一次回答内容		$data ['tag'] = $tag;				//添加一个回答		$this->userlogic->answer_again ( $data );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=回答追问成功&url=/askpage/" . $id [1] );	}		/**	 * 更新一个用户的头像	 */	public function do_update_avatar() {				$data ['uid'] = $this->get_args ( 'uid' );				$data ['avatar'] = $this->get_args ( 'avatar' );				$this->userlogic->update_avatar ( $data );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=头像修改成功&url=/home_avatar" );		}		/**	 * 更新一个用户信息	 */	public function do_update_user_info() {				$data ['uid'] = $this->get_args ( 'uid' );				$data ['nickname'] = $this->get_args ( 'nickname' );				$data ['phone'] = $this->get_args ( 'phone' );				$data ['cids'] = json_encode($_POST['cids']);				$this->userlogic->update_user_info ( $data );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=用户信息修改成功&url=/home_per_info" );	}		/**	 * 名师答疑设置为满意	 */	function set_vip_question_satisfy() {		$id = $this->get_args ( 'id' );				$id = is_numeric ( $id ) ? $id : 0;				$vip_question = $this->asklogic->get_vip_question_by_quid ( $id, $this->userinfo ['uid'] );				if (empty ( $vip_question ))			$this->Messager ( "该问题未找到或该问题不属于你", "/advisory" );				if ($vip_question ['status'] != PAID_FILL_IN)			$this->Messager ( "不允许设置", "/advisory_page/" . $id );				//设置满意		$this->userlogic->set_vip_question_status ( $id, ANSWER_SATISFY );				//设置退款		if ($this->userinfo ['refunds'] != 1) {			$params ['uid'] = $this->userinfo ['uid'];			//退款机会为1			$params ['refunds'] = 1;						$this->userlogic->update_user_refunds ( $params );		}				//发送系统信息		$subject = "名师答疑问题(" . $vip_question ['title'] . ")已经设置为满意";				$content = "名师答疑 <a href=/advisory_page/" . $vip_question ['id'] . ">" . $vip_question ['title'] . "</a> 设置为满意";				$this->userlogic->send_sys_message ( $subject, $content, $this->userinfo ['uid'] );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=问题设置成功&url=/advisory_page/" . $id );	}		/**	 * 名师答疑添加一个追问--加入检索库已加入	 */	function do_add_vip_tag() {		$id = $this->get_args ( 'id' );				$tag = stripcslashes ( $this->get_args ( 'to_ask_text' ) );				$id = is_numeric ( $id ) ? $id : 0;				if (empty ( $tag ))			$this->Messager ( "请填写追问", "/advisory_page/" . $id );				$vip_question = $this->asklogic->get_vip_question_by_quid ( $id, $this->userinfo ['uid'] );				if (empty ( $vip_question ))			$this->Messager ( "该问题未找到或该问题不属于你", "/advisory" );				//添加追问		$this->userlogic->do_add_vip_tag ( $id, $tag );				//加入检索库		$params ['vip_question'] = $vip_question;				$answer = $this->asklogic->get_vip_answer_by_id ( $id );				$ans ['aid'] = $answer ['id'];		$ans ['time'] = $answer ['time'];		$ans ['content'] = $answer ['content'];		$ans ['comment'] = $answer ['comment'];		$tag = serialize ( array (0 => $tag, 1 => get_date () ) );		$ans ['tag'] = $tag;		$answer = serialize ( array (0 => $ans ) );				$params ['answer'] = $answer;				$this->userlogic->update_vip_question_search ( $params );				//设置满意		$this->userlogic->set_vip_question_status ( $id, ANSWER_SATISFY );				//设置退款		if ($this->userinfo ['refunds'] != 1) {			$params ['uid'] = $this->userinfo ['uid'];			//退款机会为1			$params ['refunds'] = 1;						$this->userlogic->update_user_refunds ( $params );		}				//发送系统信息		$subject = "您的名师答疑问题(" . $vip_question ['title'] . ")的追问";				$content = "名师答疑 <a href=/advisory_page/" . $vip_question ['id'] . ">" . $vip_question ['title'] . "</a> 追问成功,问题已经设置为满意";				$this->userlogic->send_sys_message ( $subject, $content, $this->userinfo ['uid'] );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=追问后,该提问自动设为‘满意’&url=/advisory_page/" . $id );	}		/**	 * 名师答疑设置为不满意	 */	function set_vip_question_nosatisfy() {		$id = $this->get_args ( 'id' );				$id = is_numeric ( $id ) ? $id : 0;				$refunds_description = $this->get_args ( 'refunds_description' );				$vip_question = $this->asklogic->get_vip_question_by_quid ( $id, $this->userinfo ['uid'] );				if (empty ( $vip_question ))			$this->Messager ( "该问题未找到或该问题不属于你", "/advisory" );				if ($vip_question ['status'] != PAID_FILL_IN || $this->userinfo ['refunds'] != 1)			$this->Messager ( "不允许设置", "/advisory_page/" . $id );				$content = "名师答疑 <a href=/advisory_page/" . $vip_question ['id'] . " >" . $vip_question ['title'] . "</a>设置为不满意";				$message = "问题设置成功";				//设置退款		if ($this->userinfo ['refunds'] == 1) {			//设置不满意			$this->userlogic->set_vip_question_status ( $id, ANSWER_NO_SATISFY, $refunds_description );						//退款<span class="colRed">不满意,退款¥200元</span>			$this->userlogic->set_credit3 ( + $vip_question ['price'], $this->userinfo ['uid'], RICH_ACTION_REFUNDS, SSO_UID );			//退款流向记录			$this->userlogic->set_credit3_refunds_log ( $vip_question );						//发送邮件			$this->userlogic->send_email($vip_question['authorid'],"VIP_MONEY_BACK",$id,0);						$params ['uid'] = $this->userinfo ['uid'];						$params ['refunds'] = 0;						//退款机会为0			$this->userlogic->update_user_refunds ( $params );						$content = "名师答疑 <a href=/advisory_page/" . $vip_question ['id'] . " >" . $vip_question ['title'] . "</a>设置为不满意,<span class=colRed>退款金额为" . $vip_question ['price'] . "</span>";						$message = "退款成功";		}				//发送系统信息		$subject = "您的名师答疑问题(" . $vip_question ['title'] . ")已经答案为不满意";				$this->userlogic->send_sys_message ( $subject, $content, $this->userinfo ['uid'] );				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=" . $message . "&url=/advisory_page/" . $id );	}		/**	 * 添加讨论	 */	function do_add_discuss() {		$qid = $this->get_args ( 'qid' );				$qid = is_numeric ( $qid ) ? $qid : 0;				$cid = $this->get_args ( 'topid' );				$cid = is_numeric ( $cid ) ? $cid : 0;				$content = $this->get_args ( 'discuss_content' );				if ($this->userinfo ['groupid'] == USER_VIP || $this->userinfo ['groupid'] == SUPER_ADMIN_ID || $this->userinfo ['groupid'] == ADMIN_ID)			$vip_question = $this->asklogic->get_vip_questions_by_id ( $qid );		else			$vip_question = $this->asklogic->get_vip_question_by_quid ( $qid, $this->userinfo ['uid'] );				if (empty ( $vip_question ))			$this->Messager ( "该问题不存在", "/advisory_page/" . $qid . "#dis" );				if (empty ( $content ))			$this->Messager ( "请填写内容", "/advisory_page/" . $qid . "#dis" );				$this->userlogic->add_discuss ( $qid, $this->userinfo ['uid'], $content, $cid );				if ($cid > 0) {			$this->userlogic->update_discuss ( $cid );		}				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/messager?content=添加讨论成功&url=/advisory_page/" . $qid . "#dis" );	}		/**	 * 添加邮件发送配置	 */	function do_add_email_config() {		$data['normal_question_mail'] = $this->get_args ( 'normal_question_mail' );				$data['pay_question_mail'] = $this->get_args ( 'pay_question_mail' );				$data['vip_question_mail'] = $this->get_args ( 'vip_question_mail' );				$this->userlogic->add_email_config($data,$this->userinfo['uid']);				header ( 'Content-Type:text/html;charset=utf-8' );		@header ( "Location: " . WEB_SITE . "/home_per_info" );	}		/**	 * 获取get或者POST值	 * @param string $name 属性名称	 * @return fixed 值	 */	function get_args($name) {		if (isset ( $_GET [$name] )) {			if (is_array ( $_GET [$name] ))				return $_GET [$name];			else				return addslashes ( $_GET [$name] );				} elseif (isset ( $_POST [$name] )) {			if (is_array ( $_POST [$name] ))				return $_POST [$name];			else				return addslashes ( $_POST [$name] );		} else {						return false;		}	}		/**	 * 检测数据输入的非法字符和转义非法字符	 */	function check_params($name = "") {		if (isset ( $this->params [$name] )) {						return addslashes ( $this->params [$name] );		} else {						return false;		}	}		/**	 * 限时跳转	 * @param unknown_type $message	 * @param unknown_type $redirectto	 * @param unknown_type $time	 * @param unknown_type $return_msg	 * @param unknown_type $js	 */	function Messager($message, $redirectto = '', $time = -1, $return_msg = false, $js = null) {		global $rewriteHandler;		$data ['redirectto'] = $redirectto;		$data ['message'] = $message;				if ($time === - 1) {			//配置文件			//$time=(is_numeric($this->Config['msg_time'])?$this->Config['msg_time']:5);			$data ['time'] = 2;		}				$data ['to_title'] = ($data ['redirectto'] === '' or $data ['redirectto'] == - 1) ? "返回上一页" : "跳转到指定页面";				if ($data ['redirectto'] === null) {			$return_msg = $return_msg === false ? " " : $return_msg;		} else {			$data ['redirectto'] = ($data ['redirectto'] !== '') ? $data ['redirectto'] : ($from_referer = referer ());			//			if(str_exists($data['redirectto'],'mod=login','code=register','/login','/register'))			//			{			//				$referer='&referer='.urlencode('index.php?'.$_SERVER['QUERY_STRING']);			//				$this->CookieHandler->Setvar('referer','index.php?'.$_SERVER['QUERY_STRING']);			//			}						if (is_numeric ( $data ['redirectto'] ) !== false and $data ['redirectto'] !== 0) {				if ($data ['time'] !== null) {					$data ['url_redirect'] = "<script language=\"JavaScript\" type=\"text/javascript\">\r\n";					$data ['url_redirect'] .= sprintf ( "window.setTimeout(\"history.go(%s)\",%s);\r\n", $data ['redirectto'], $data ['time'] * 1000 );					$data ['url_redirect'] .= "</script>\r\n";								}								$data ['redirectto'] = "javascript:history.go({$data['redirectto']})";			} else {				if ($rewriteHandler && null !== $data ['message']) {					$data ['redirectto'] .= $referer;					if (! $from_referer && ! $referer) {						$data ['redirectto'] = $rewriteHandler->formatURL ( $data ['redirectto'], true );					}				}								if ($data ['message'] === null) {					$data ['redirectto'] = rawurldecode ( stripslashes ( ($data ['redirectto']) ) );					@header ( "Location: " . $data ['redirectto'] ); #HEADER跳转				}				if ($data ['time'] !== null) {					$data ['url_redirect'] = ($data ['redirectto'] ? '<meta http-equiv="refresh" content="' . $data ['time'] . '; URL=' . $data ['redirectto'] . '">' : null);				}			}		}		$title = "消息提示:" . (is_array ( $data ['message'] ) ? implode ( ',', $data ['message'] ) : $data ['message']);				$title = strip_tags ( $title );		if ($js != "") {			$js = "<script language=\"JavaScript\" type=\"text/javascript\">{$js}</script>";		}		$additional_str = $data ['url_redirect'] . $js;				$this->render ( 'messager', $data );				exit ();	}}?>
 |