UserLogic.php 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111
  1. <?php
  2. /**
  3. * 用户操作逻辑
  4. * @author cp
  5. */
  6. class UserLogic extends BaseLogic {
  7. private $categorydao;
  8. private $userdao;
  9. private $questiondao;
  10. private $answerdao;
  11. private $messagedao;
  12. private $group;
  13. private $creditdao;
  14. private $sessiondao;
  15. private $userlogdao;
  16. private $crontadstatusdao;
  17. private $credit3logdao;
  18. private $authissuedao;
  19. private $vipquestiondao;
  20. private $vipanswerdao;
  21. function __construct() {
  22. Doo::loadModel ( 'CategoryDao' );
  23. Doo::loadModel ( 'UserDao' );
  24. Doo::loadModel ( 'QuestionDao' );
  25. Doo::loadModel ( 'CreditDao' );
  26. Doo::loadModel ( 'AnswerDao' );
  27. Doo::loadModel ( 'MessageDao' );
  28. Doo::loadModel ( 'GroupDao' );
  29. Doo::loadModel ( 'SessionDao' );
  30. Doo::loadModel ( 'UserlogDao' );
  31. Doo::loadModel ( 'CrontadstatusDao' );
  32. Doo::loadModel ( 'Credit3logDao' );
  33. Doo::loadModel ( 'AuthissueDao' );
  34. Doo::loadModel ( 'VipquestionDao' );
  35. Doo::loadModel ( 'VipanswerDao' );
  36. $this->categorydao = new CategoryDao ();
  37. $this->userdao = new UserDao ();
  38. $this->questiondao = new QuestionDao ();
  39. $this->creditdao = new CreditDao ();
  40. $this->answerdao = new AnswerDao ();
  41. $this->messagedao = new MessageDao ();
  42. $this->groupdao = new GroupDao ();
  43. $this->sessiondao = new SessionDao ();
  44. $this->userlogdao = new UserlogDao ();
  45. $this->crontadstatusdao = new CrontadstatusDao ();
  46. $this->credit3logdao = new Credit3logDao ();
  47. $this->authissuedao = new AuthissueDao ();
  48. $this->vipquestiondao = new VipquestionDao ();
  49. $this->vipanswerdao = new VipanswerDao ();
  50. }
  51. /**
  52. * 完善名师问题
  53. * @param unknown_type $id
  54. * @param unknown_type $title
  55. * @param unknown_type $description
  56. */
  57. function update_vip_question($id = 0, $title = "", $description = "", $uid = 0, $phone = "", $qq = "") {
  58. $this->vipquestiondao->id = $id;
  59. $this->vipquestiondao->title = $title;
  60. $this->vipquestiondao->description = $description;
  61. $this->vipquestiondao->time = get_date ();
  62. $this->vipquestiondao->status = PAID_FILL_IN;
  63. $result = $this->db ()->update ( $this->vipquestiondao );
  64. //更新今天发布数--需要修改每时间段的更新次数-setp2
  65. $this->authissuedao->set_authissue_totals ( $uid );
  66. //添加积分值-setp2
  67. $this->set_credit1 ( 'add', $uid, CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
  68. $que_rs = $this->vipquestiondao->get_vip_question_by_id ( $id );
  69. //加入检索索引-分词还未加入-数据配置--等待搜索页面
  70. //$pams = array ('id' => $id, 'price' => $que_rs ['price'], 'author' => $que_rs ['author'], 'authorid' => $uid, 'title' => $title, 'description' => $description, 'supply' => '', 'time' => $this->vipquestiondao->time, 'hot' => 0, 'status' => PAID_FILL_IN, 'answers' => 0, 'answer' => '' );
  71. //$this->add_search_index ( $pams, SEARCH_WD_DB, SEARCH_VIP_INI );
  72. $this->userdao->uid = $uid;
  73. if (! empty ( $phone ))
  74. $this->userdao->phone = $phone;
  75. if (! empty ( $qq ))
  76. $this->userdao->qq = $qq;
  77. $result = $this->db ()->update ( $this->userdao );
  78. if($result){
  79. include SITE_PATH . '/protected/config/set_email_to_admin.conf.php';
  80. $list=explode("-", $sys ['set_email']);
  81. foreach ($list as $value){
  82. if(filter_var($value, FILTER_VALIDATE_EMAIL))
  83. $this->_mail("有用户发布了名师答疑,赶紧去后台查看:<a href='http://zhzdwd.com/'>问答后台</a>","有新的名师答疑提问",$value);
  84. }
  85. }
  86. }
  87. /**
  88. * 添加名师问题
  89. * @param unknown_type $data
  90. */
  91. function add_vip_question($data = array()) {
  92. $this->vipquestiondao->status = PAID_NO_FILL_IN;
  93. $price = abs ( $data ['price'] );
  94. $this->vipquestiondao->price = $price;
  95. $this->credit3logdao->amount = $price;
  96. $this->vipquestiondao->author = $data ['author'];
  97. $this->credit3logdao->username = $data ['author'];
  98. $this->vipquestiondao->authorid = $data ['authorid'];
  99. $time = get_date ();
  100. $this->vipquestiondao->time = $time;
  101. $this->credit3logdao->time = $time;
  102. $ip = client_ip ();
  103. $this->vipquestiondao->ip = $ip;
  104. $this->credit3logdao->ip = $ip;
  105. $this->vipquestiondao->refunds = 1;
  106. //扣除通行证金额
  107. if ($data ['price'] > 0) {
  108. //扣除通行证的钱 //用户表和记录表
  109. $is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
  110. if (!$is)
  111. return 0;
  112. }
  113. $result = $this->db ()->insert ( $this->vipquestiondao );
  114. //发邮件
  115. $this->send_email ( $data ['authorid'], "VIP_PAY_FORMONEY", $result, 0 );
  116. if ($result) {
  117. //扣除财富值--财富值记录
  118. if ($data ['price'] > 0) {
  119. $this->credit3logdao->qid = $result;
  120. $action = $this->credit3logdao->set_ACTION_ADD_VIP_QUESTION ();
  121. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $ip, 1 );
  122. }
  123. //发布系统信息
  124. $subject = "您的新问题(" . $result ['title'] . ")";
  125. $content = $this->messagedao->set_MESSAGE_ADD_VIP_PAID ();
  126. $this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
  127. }
  128. return $result;
  129. }
  130. /**
  131. * 会话推出
  132. * @param unknown_type $sid
  133. */
  134. function delete_session($sid = "") {
  135. $rs = $this->sessiondao->get_seesion ( $sid );
  136. $this->userlogdao->uid = $rs ['uid'];
  137. $this->userlogdao->username = $rs ['username'];
  138. $this->userlogdao->ip = client_ip ();
  139. $this->userlogdao->time = get_date ();
  140. $action = $this->userlogdao->set_USER_EXIT ();
  141. $this->userlogdao->set_userlog ( $rs ['uid'], $rs ['username'], $action, client_ip () );
  142. $this->sessiondao->sid = $sid;
  143. $this->db ()->delete ( $this->sessiondao );
  144. }
  145. /**
  146. * 完成任务
  147. * @param unknown_type $uid
  148. * @param unknown_type $mission_type
  149. */
  150. function complete_daily_crontab($uid = 0, $mission_type = 0) {
  151. $this->crontadstatusdao->complete_crontab ( $uid, $mission_type );
  152. }
  153. /**
  154. * 获取任务进行状态
  155. * @param unknown_type $uid
  156. * @param unknown_type $mission_type
  157. */
  158. function get_crontab_status($uid = 0, $mission_type = 0) {
  159. $time = get_date ();
  160. //$this->crontadstatusdao->delete_crontab();
  161. //每日登录任务
  162. if ($mission_type == SYSTEM_DAILY_LOGIN) {
  163. $rs = $this->crontadstatusdao->get_crontab_status ( $uid, $mission_type );
  164. $day = get_today ();
  165. if (empty ( $rs )) {
  166. $this->crontadstatusdao->uid = $uid;
  167. $this->crontadstatusdao->cid = $mission_type;
  168. $this->crontadstatusdao->status = NOT_COMPLETED;
  169. $this->crontadstatusdao->time = $time;
  170. $this->db ()->insert ( $this->crontadstatusdao );
  171. return NOT_COMPLETED;
  172. } elseif ($rs ['time'] < $day ['start'])
  173. return DOING;
  174. elseif ($rs ['status'] != 2 && $rs ['time'] > $day ['start']) {
  175. return DOING;
  176. } else
  177. return COMPLETE;
  178. }
  179. }
  180. /**
  181. * 记录用户日志
  182. * @param unknown_type $uid
  183. * @param unknown_type $username
  184. */
  185. function set_userlog($uid = 0, $username = "") {
  186. $this->userlogdao->uid = $uid;
  187. $this->userlogdao->username = $username;
  188. $this->userlogdao->ip = client_ip ();
  189. $this->userlogdao->time = get_date ();
  190. $this->userlogdao->action = $this->userlogdao->set_USER_LOGIN_LOG ();
  191. //设置用户日志
  192. $result = $this->db ()->insert ( $this->userlogdao );
  193. }
  194. /**
  195. * 设置会话
  196. * @param unknown_type $sessionID
  197. * @param unknown_type $uid
  198. * @param unknown_type $username
  199. * @param unknown_type $lifetime
  200. */
  201. function set_session($sessionID = "", $uid = 0, $username = "", $lifetime = 0) {
  202. $this->sessiondao->sid = $sessionID;
  203. $this->sessiondao->uid = $uid;
  204. $this->sessiondao->username = $username;
  205. $this->sessiondao->islogin = 1;
  206. $this->sessiondao->ip = client_ip ();
  207. $this->sessiondao->time = get_date ();
  208. $this->sessiondao->lifetime = $lifetime;
  209. //设置会话
  210. $result = $this->db ()->insert ( $this->sessiondao );
  211. }
  212. /**
  213. * 添加用户--是否要发系统信息
  214. */
  215. function add_user($username = "", $password = "") {
  216. $this->userdao->username = $username;
  217. $this->userdao->password = $password;
  218. $this->userdao->groupid = USER_LV1;
  219. $this->userdao->credits = POINT_REGISTER;
  220. $this->userdao->credit1 = POINT_REGISTER;
  221. $this->userdao->regip = client_ip ();
  222. $this->userdao->regtime = get_date ();
  223. //添加用户
  224. $result = $this->db ()->insert ( $this->userdao );
  225. //注册加20分
  226. $this->creditdao->set_credit_log ( $result, ACTION_REGISTER, POINT_REGISTER, 0, 0 );
  227. return $result;
  228. }
  229. /**
  230. * 添加用户--是否要发系统信息
  231. */
  232. function add_user2($param) {
  233. $this->userdao->username = $param['username'];
  234. $this->userdao->password = $param['password'];
  235. $this->userdao->email = $param['email'];
  236. $this->userdao->phone = $param['mobile'];
  237. $this->userdao->groupid = USER_LV1;
  238. $this->userdao->credits = POINT_REGISTER;
  239. $this->userdao->credit1 = POINT_REGISTER;
  240. $this->userdao->regip = client_ip ();
  241. $this->userdao->regtime = get_date ();
  242. //添加用户
  243. $result = $this->db ()->insert ( $this->userdao );
  244. //注册加20分
  245. $this->creditdao->set_credit_log ( $result, ACTION_REGISTER, POINT_REGISTER, 0, 0 );
  246. return $result;
  247. }
  248. /**
  249. * 更新用户信息
  250. * @param unknown_type $params
  251. */
  252. function update_user2($id,$params) {
  253. $this->userdao->uid = $id;
  254. $this->userdao->phone = $params ['phone'];
  255. $this->userdao->password = md5 ( $params ['password'] );
  256. $this->userdao->email = $params ['email'];
  257. $this->userdao->groupid = $params ['groupid'];
  258. $this->userdao->credits = $params ['credits'];
  259. $this->userdao->credit1 = $params ['credit1'];
  260. $this->userdao->gender = $params ['gender'];
  261. $this->userdao->bday = $params ['bday'];
  262. $this->userdao->qq = $params ['qq'];
  263. $this->userdao->msn = $params ['msn'];
  264. $this->userdao->signature = $params ['signature'];
  265. $this->userdao->expert = $params ['expert'];
  266. $this->userdao->cids=$params['cids'];
  267. $result = $this->db ()->update ( $this->userdao );
  268. }
  269. /**
  270. * 根据用户ID删除,和删除相关信息
  271. */
  272. function delete_user_tem($uid = 0) {
  273. //删除问题
  274. $this->questiondao->delete_question_by_authorid ( $uid );
  275. //删除回答
  276. $this->answerdao->delete_answer_by_authorid ( $uid );
  277. //删除用户积分记录--之后还有财富记录
  278. $this->creditdao->delete_credit_by_uid ( $uid );
  279. $this->userdao->uid = $uid;
  280. $this->db ()->delete ( $this->userdao );
  281. }
  282. /**
  283. * 将问题设置为未解决-值针对已关闭
  284. * @param unknown_type $id
  285. */
  286. function update_question_list($id = array()) {
  287. $id=implode(",", $id);
  288. $queList=array();
  289. if(!empty($id))
  290. $queList=$this->questiondao->get_questions_By_Idlist($id);
  291. foreach ($queList as $key=>$value){
  292. $question = new QuestionDao ();
  293. $question->id=$value['id'];
  294. $question->status=QUESTOIN_STATUS_UNRESOLVED;
  295. $question->time=time();
  296. $question->update();
  297. }
  298. }
  299. /**
  300. * 删除选中问题
  301. * @param unknown_type $id
  302. */
  303. function delete_question_list($id = array()) {
  304. $this->questiondao->delete_question_list ( $id );
  305. //删除索引
  306. $this->delete_search_index ( $id, SEARCH_WD_DB, SEARCH_INI );
  307. }
  308. /**
  309. * 删除选中问题
  310. * @param unknown_type $id
  311. */
  312. function delete_answer_list($id = array()) {
  313. $this->answerdao->delete_answer_list ( $id );
  314. }
  315. /**
  316. * 删除一个用户组
  317. * @param unknown_type $groupid
  318. */
  319. function delete_group($groupid = 0) {
  320. if ($groupid <= GROUPIDLIMIT)
  321. return false;
  322. $this->groupdao->groupid = $groupid;
  323. $this->db ()->delete ( $this->groupdao );
  324. }
  325. /**
  326. * 添加一条用户组
  327. * @param unknown_type $params
  328. */
  329. function add_group($params = array()) {
  330. if (empty ( $params ))
  331. return false;
  332. $this->groupdao->grouptitle = $params ['grouptitle'];
  333. $this->groupdao->grouptype = 2;
  334. $result = $this->db ()->insert ( $this->groupdao );
  335. }
  336. /**
  337. * 批量更新用户组
  338. * @param unknown_type $params
  339. */
  340. function update_group_list($params) {
  341. $pa = array ();
  342. $co = array ();
  343. $wh = array ();
  344. $count = count ( $params ['groupid'] );
  345. foreach ( $params as $key => $value ) {
  346. array_push ( $pa, $key );
  347. if ($key != "groupid") {
  348. array_push ( $wh, $key . "=VALUES(" . $key . ")" );
  349. }
  350. }
  351. //获取更新内容
  352. for($i = 0; $i < $count; $i ++) {
  353. $tm = array ();
  354. foreach ( $pa as $k ) {
  355. array_push ( $tm, "'" . $params [$k] [$i] . "'" );
  356. }
  357. $tm = implode ( ",", $tm );
  358. array_push ( $co, "(" . $tm . ")" );
  359. }
  360. $pa = implode ( ",", $pa );
  361. $wh = implode ( ",", $wh );
  362. $co = implode ( ",", $co );
  363. $this->groupdao->update_group_list ( $pa, $co, $wh );
  364. }
  365. /**
  366. * 删除用户和问答
  367. * @param unknown_type $uid
  368. */
  369. function delete_user_and_QA($uid = array()) {
  370. $this->userdao->delete_user_and_QA ( $uid );
  371. }
  372. /**
  373. * 删除用户
  374. * @param unknown_type $uid
  375. */
  376. function delete_user($uid = array()) {
  377. $this->userdao->delete_user ( $uid );
  378. }
  379. function update_user_avatar_by_id($uid, $avatar) {
  380. Doo::loadModel ( 'UserDao' );
  381. $userdao = new UserDao ();
  382. $userdao->uid = $uid;
  383. $userdao->avatar = $avatar;
  384. $userdao->lastlogin = time ();
  385. $result = $this->db ()->update ( $userdao );
  386. }
  387. /**
  388. * 更新用户信息
  389. * @param unknown_type $params
  390. */
  391. function update_user($params) {
  392. $this->userdao->uid = $params ['uid'];
  393. $this->userdao->phone = $params ['phone'];
  394. $this->userdao->password = md5 ( $params ['password'] );
  395. $this->userdao->email = $params ['email'];
  396. $this->userdao->groupid = $params ['groupid'];
  397. $this->userdao->credits = $params ['credits'];
  398. $this->userdao->credit1 = $params ['credit1'];
  399. $this->userdao->gender = $params ['gender'];
  400. $this->userdao->bday = $params ['bday'];
  401. $this->userdao->qq = $params ['qq'];
  402. $this->userdao->msn = $params ['msn'];
  403. $this->userdao->signature = $params ['signature'];
  404. $this->userdao->expert = $params ['expert'];
  405. $this->userdao->cids=$params['cids'];
  406. $result = $this->db ()->update ( $this->userdao );
  407. }
  408. /**
  409. * 更新退款机会
  410. * @param unknown_type $refunds
  411. */
  412. function update_user_refunds($refunds = array()) {
  413. $this->userdao->uid = $refunds ['uid'];
  414. $this->userdao->refunds = $refunds ['refunds'];
  415. $result = $this->db ()->update ( $this->userdao );
  416. }
  417. /**
  418. * 获取用户组
  419. */
  420. function get_group() {
  421. $result = $this->groupdao->get_group ();
  422. $re = array ('sys' => array (), 'user' => array (), 'vip_user' => array () );
  423. foreach ( $result as $value ) {
  424. if ($value ['grouptype'] == 1)
  425. array_push ( $re ['sys'], $value );
  426. elseif ($value ['grouptype'] == 2)
  427. array_push ( $re ['user'], $value );
  428. elseif ($value ['grouptype'] == 3)
  429. array_push ( $re ['vip_user'], $value );
  430. }
  431. return $re;
  432. }
  433. /**
  434. * 设置赞同数
  435. * @param unknown_type $aid
  436. * @param unknown_type $uid 登录者UID
  437. */
  438. function update_support_answer($aid = 0, $uid = 0) {
  439. $user = $this->userdao->get_userinfo_by_uid ( $uid );
  440. $aids_ar = explode ( ",", $user ['aids'] );
  441. if (in_array ( $aid, $aids_ar ))
  442. return false;
  443. //记录谁赞同
  444. $data ['aids'] = $user ['aids'] . "," . $aid;
  445. if (empty ( $user ['aids'] ))
  446. $data ['aids'] = $aid;
  447. $condition = " ,elect=elect+1 where uid = " . $uid;
  448. $this->userdao->update_user ( $data, $condition );
  449. //更新赞同数
  450. $this->answerdao->update_support_answer ( $aid );
  451. //更新赞同操作
  452. $rs = $this->answerdao->get_answer_by_id ( $aid );
  453. $this->questiondao->set_question_goods ( $rs ['qid'] );
  454. //加积分
  455. $this->set_credit1 ( 'add', $user ['uid'], POINT_SUPPORT, ACTION_SUPPORT );
  456. return true;
  457. }
  458. /**
  459. * 设置最佳答案--整理
  460. * @param unknown_type $qid
  461. */
  462. function set_best_answer($data = array()) {
  463. $type = "ADOPT_ANSWER";
  464. if ($data ['price'] > 0) {
  465. //获取回答用户的通行证ID
  466. $sso_info = $this->get_sso_user_info_by_name ( $data ['username'] );
  467. $is = $this->set_credit3 ( + $data ['price'], $data ['auid'], RICH_ACTION_ADOPT, $sso_info [0] ['id'] );
  468. $type = "PAY_ADOPT_ANSWER";
  469. if ($is == 0)
  470. return $is;
  471. }
  472. //更新问题
  473. $data_question ['endtime'] = get_date ();
  474. $data_question ['status'] = ADOPT;
  475. $condition = " where id = " . $data ['qid'];
  476. $this->questiondao->update_question ( $data_question, $condition );
  477. //更新答案
  478. $data_answer ['adopttime'] = $data_question ['endtime'];
  479. $data_answer ['comment'] = $data ['comment'];
  480. $data_answer ['status'] = ADOPT;
  481. $condition = " where id = " . $data ['aid'];
  482. $this->answerdao->update_answer ( $data_answer, $condition );
  483. //发送邮件
  484. $this->send_email ( $data ['auid'], $type, $data ['qid'], $data ['aid'] );
  485. //更新回答用户信息积分信息
  486. $this->userdao->add_credit1 ( POINT_ADOPT, $data ['auid'], ACTION_ADOPT );
  487. if ($data ['price'] > 0) {
  488. //财富操作记录, 将用户财富划到回答方
  489. //$this->userdao->add_credit3 ( + $data ['price'], $data ['auid'], RICH_ACTION_ADOPT );
  490. //财富流向表
  491. $this->credit3logdao->qid = $data ['qid'];
  492. $this->credit3logdao->ip = client_ip ();
  493. $this->credit3logdao->amount = $data ['price'];
  494. $this->credit3logdao->username = $data ['username'];
  495. $this->credit3logdao->time = get_date ();
  496. $action = $this->credit3logdao->set_ACTION_ADOPT_QUESTION ();
  497. $this->credit3logdao->add_credit3_log ( $data ['auid'], $data ['username'], $data ['qid'], $action, $data ['price'], $this->credit3logdao->ip );
  498. }
  499. //更新该用户的采纳数
  500. $this->userdao->add_adopts ( $data ['auid'], 1 );
  501. $p = "";
  502. if ($data ['price'] > 0)
  503. $p = "<span class=colOrange >获得¥" . $data ['price'] . "元</span>";
  504. //发送系统信息-发送给发回答用户
  505. $subject = "回答&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;被采纳为最佳答案&nbsp;" . $p;
  506. $content = "回答&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;被采纳为最佳答案&nbsp;" . $p;
  507. $this->messagedao->send_message ( ADMIN_NAME, 0, $data ['auid'], $subject, $content );
  508. }
  509. /**
  510. * 获取通行证用户头像--
  511. * @param unknown_type $username
  512. */
  513. function get_user_avatar_by_username($username = "", $client = "") {
  514. if (empty ( $client )) {
  515. require_once (SITE_PATH . '/protected/plugin/client.php');
  516. $client = new client ( ZHSSO );
  517. }
  518. $avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR );
  519. $userinfo = $client->zhsso_getUserbyName ( $username );
  520. $userinfo = explode ( "\r", $userinfo );
  521. $ts = json_decode ( $userinfo ['1'], true );
  522. //$avatar = $client->url_exists($client->ps_getavatar($ts[0]['id'])) ? $client->ps_getavatar($ts[0]['id']) : DEF_AVATAR;
  523. if (isset ( $ts ) && ! empty ( $ts )) {
  524. $avatar = $client->ps_getavatar ( $ts [0] ['id'] );
  525. }
  526. return $avatar;
  527. }
  528. /**
  529. * 获取用户相关信息
  530. * @param unknown_type $data
  531. * @param unknown_type $condition
  532. * @param unknown_type $limit
  533. */
  534. function get_users_list($data = array(), $condition = "", $limit = "") {
  535. $result = $this->userdao->get_users_list ( $data, $condition, $limit );
  536. $src = "";
  537. $now = 1;
  538. foreach ( $result as $key => $value ) {
  539. $lv = get_lv ( $value ['credit1'] );
  540. $result [$key] ['lv'] = $lv [0];
  541. $result [$key] ['lv_max'] = $lv [1];
  542. $result [$key] ['lv_need'] = $lv [1] - $value ['credit1'];
  543. $result [$key] ['lv_percent'] = $value ['credit1'] / $lv [1] * 100;
  544. $result [$key] ['category'] = "";
  545. $result [$key] ['question'] = "";
  546. $result [$key] ['lastlogin'] = my_date_format2 ( $value ['lastlogin'], "Y-m-d H:i:s" );
  547. //$avatar = $this->get_user_avatar_by_username ( $value ['username'] );
  548. $avatar = json_decode ( $value ['avatar'], true );
  549. if (empty ( $avatar ))
  550. $avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR );
  551. $result [$key] ['avatar'] = $avatar;
  552. $cidsList = json_decode ( $value ['cids'] );
  553. if(!empty($cidsList)){
  554. foreach ( $cidsList as $c_key => $values ) {
  555. $list = explode ( ":", $values );
  556. $src .= "<a href='/index_c/" . $list[0] . "'>" .$list[1] . "</a>&nbsp;";
  557. }
  558. $result [$key] ['category'] = $src;
  559. }
  560. //读取专家分类
  561. // if (! empty ( $value ['cids'] )) {
  562. // $condition = " and id in (" . $value ['cids'] . ") ";
  563. //
  564. // $c_result = $this->categorydao->get_category_list ( array (), $condition, "" );
  565. //
  566. // $src = "";
  567. //
  568. // foreach ( $c_result as $c_key => $c_value ) {
  569. //
  570. // $src .= "<a href='/index_c/" . $c_value ['id'] . "'>" . $c_value ['name'] . "</a>&nbsp;";
  571. // }
  572. // $result [$key] ['category'] = $src;
  573. // }
  574. $result [$key] ['now'] = $now;
  575. //获取相关问题
  576. $param ['authorid'] = $value ['uid'];
  577. $limit = " order by time desc limit 0 , 3 ";
  578. $q_result = $this->get_list ( $param, "", $limit, t_answer );
  579. $src = "";
  580. if (! empty ( $q_result )) {
  581. foreach ( $q_result as $q_key => $q_value ) {
  582. $src .= "<a href='/askpage/" . $q_value ['qid'] . "'>" . $q_value ['title'] . "</a>";
  583. }
  584. $result [$key] ['question'] = $src;
  585. }
  586. $now ++;
  587. }
  588. return $result;
  589. }
  590. /**
  591. * 根据用户名获取信息
  592. */
  593. function get_users_by_name($username = "") {
  594. $result = $this->userdao->get_users_by_name ( $username );
  595. return $result;
  596. }
  597. function get_group_by_id($id = 0) {
  598. $rs = $this->groupdao->get_group_by_id ( $id );
  599. return $rs;
  600. }
  601. /**
  602. * 获取用户基本信息
  603. * @param unknown_type $uid
  604. * @return $result array;
  605. */
  606. function get_users_information($uid = 0) {
  607. if ($uid == 0 || (! is_numeric ( $uid )))
  608. return array ();
  609. $result = $this->userdao->get_userinfo_by_uid ( $uid );
  610. if (empty ( $result ))
  611. return array ();
  612. $lv = get_lv ( $result ['credit1'] );
  613. $result ['lv'] = $lv [0];
  614. $result ['lv_max'] = $lv [1];
  615. $result ['lv_need'] = $lv [1] - $result ['credit1'];
  616. $result ['lv_percent'] = $result ['credit1'] / $lv [1] * 100;
  617. $result ['credit3'] = 0;
  618. if (defined ( 'CREDIT3' ))
  619. $result ['credit3'] = CREDIT3;
  620. $result ['email'] = "";
  621. if (defined ( 'EMAIL' ))
  622. $result ['email'] = EMAIL;
  623. $cidsList = json_decode ( $result ['cids'] );
  624. $cids=array();
  625. $cids_key = array ();
  626. $cids_name = array ();
  627. if(!empty($cidsList)){
  628. foreach ( $cidsList as $key => $value ) {
  629. $list = explode ( ":", $value );
  630. array_push ( $cids_key, $list [0] );
  631. array_push ( $cids_name, $list [1] );
  632. }
  633. $result ['cids'] = implode(",", $cids_key);
  634. $cids = array_combine($cids_key, $cids_name);
  635. $result ['cids_json'] = $cids;
  636. }
  637. return $result;
  638. }
  639. /**
  640. * 添加一个问题
  641. * @param unknown_type $data
  642. * @return $result 问题ID;
  643. */
  644. function add_question($data = array()) {
  645. $this->questiondao->title = $data ['title'];
  646. $this->questiondao->cid = $data ['category_id'];
  647. $this->questiondao->description = $data ['description'];
  648. //取绝对值
  649. $price = abs ( $data ['price'] );
  650. $this->questiondao->price = $price;
  651. $this->credit3logdao->amount = $price;
  652. $this->questiondao->author = $data ['author'];
  653. $this->credit3logdao->username = $data ['author'];
  654. $this->questiondao->authorid = $data ['authorid'];
  655. $this->credit3logdao->uid = $data ['authorid'];
  656. $this->questiondao->time = get_date ();
  657. $this->credit3logdao->time = $this->questiondao->time;
  658. $this->questiondao->endtime = get_date ( 15 );
  659. $this->questiondao->ip = client_ip ();
  660. $this->credit3logdao->ip = $this->questiondao->ip;
  661. //扣除金额后才可以添加问题
  662. if ($data ['price'] > 0) {
  663. $is = $this->set_credit3 ( - $data ['price'], $data ['authorid'], RICH_ACTION_OFFER, SSO_UID );
  664. if ($is == 0)
  665. return 0;
  666. }
  667. //推广手段
  668. if($data['price']==0){
  669. $fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
  670. if($fundstr){
  671. //获取基金
  672. Doo::loadModel ( 'FundDao' );
  673. $funddao = new FundDao ();
  674. $fund=$funddao->get_fund_by_amount();
  675. if(!empty($fund)){
  676. $funddao->set_fund_amount_spread("-1",$fund['id']);
  677. $this->questiondao->price=1;
  678. }
  679. }
  680. }
  681. $result = $this->db ()->insert ( $this->questiondao );
  682. //发送邮件
  683. if ($data ['price'] > 0) {
  684. $this->send_email ( $data ['authorid'], "PAY_FORMONEY", $result, 0 );
  685. }
  686. //是否需要优化
  687. if ($result) {
  688. //加入检索索引-分词还未加入-数据配置
  689. //$pams = array ('id' => $result, 'cid' => $data ['category_id'], 'price' => $price, 'authorid' => $data ['authorid'], 'author' => $data ['author'], 'title' => $data ['title'], 'description' => $data ['description'], 'time' => $this->questiondao->time, 'status' => QUESTOIN_STATUS_UNRESOLVED );
  690. //$this->add_search_index ( $pams );
  691. //扣除财富值--财富值记录
  692. if ($data ['price'] > 0) {
  693. $this->credit3logdao->qid = $result;
  694. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  695. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $result, $action, - $price, $this->questiondao->ip );
  696. }
  697. //更新今天发布数--需要修改每时间段的更新次数
  698. $this->authissuedao->set_authissue_totals ( $data ['authorid'] );
  699. //发布系统信息
  700. //$subject = "问题 &nbsp;" . $result ['title'] . "&nbsp;新的问题";
  701. //
  702. //$content = $this->messagedao->set_MESSAGE_ADD_QUESTION ( $data ['title'], $result );
  703. //
  704. //$this->messagedao->send_message ( ADMIN_NAME, 0, $data ['authorid'], $subject, $content );
  705. //
  706. //添加提问数
  707. $this->set_questions ( 'add', $data ['authorid'], $data ['category_id'] );
  708. //添加积分值
  709. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ADD, CREDIT_ACTION_ADD );
  710. }
  711. return $result;
  712. }
  713. /**
  714. * 更新检索库
  715. * @param unknown_type $params
  716. */
  717. function update_vip_question_search($params) {
  718. //$pams = array ('id' => $params ['vip_question'] ['id'], 'answers' => 1, 'answer' => $params ['answer'], 'title' => $params ['vip_question'] ['title'], 'price' => $params ['vip_question'] ['price'], 'author' => $params ['vip_question'] ['author'], 'authorid' => $params ['vip_question'] ['authorid'], 'description' => $params ['vip_question'] ['description'], 'supply' => $params ['vip_question'] ['supply'], 'time' => $params ['vip_question'] ['time_stamp'], 'hot' => $params ['vip_question'] ['hot'] );
  719. //$this->update_search_index ( $pams, SEARCH_VWD_DB, SEARCH_VIP_INI );
  720. }
  721. /**
  722. * 设置积分值
  723. * @param unknown_type $type add or take_out
  724. * @param unknown_type $uid
  725. * @param unknown_type $point
  726. * @param unknown_type $action_type
  727. */
  728. function set_credit1($type = 'add', $uid = 0, $point = 0, $action_type = "") {
  729. if ("add" == $type)
  730. return $this->userdao->add_credit1 ( $point, $uid, $action_type );
  731. else if ("take_out" == $type)
  732. return $this->userdao->take_out_credit1 ( $point, $uid, $action_type );
  733. else
  734. return false;
  735. }
  736. /**
  737. * 设置财富值
  738. * @param unknown_type $type add or take_out
  739. * @param unknown_type $price
  740. * @return error_message
  741. */
  742. function set_credit3($price = 0, $uid = 0, $action_type = "", $sso_uid = 0) {
  743. if ($sso_uid == 0)
  744. return 0;
  745. $sso_price = abs ( $price );
  746. //扣除或者增加通行证金额
  747. if ($price < 0)
  748. $is = $this->offer_price_by_sso ( $sso_price, $sso_uid );
  749. else
  750. $is = $this->add_price_by_sso ( $sso_price, $sso_uid );
  751. if ($is <= 0)
  752. return 0;
  753. $this->userdao->add_credit3 ( $price, $uid, $action_type );
  754. return $is;
  755. }
  756. /**
  757. * 设置提问数
  758. * @param unknown_type $type
  759. * @param unknown_type $uid
  760. */
  761. function set_questions($type = 'add', $uid = 0, $category_id = 0) {
  762. if ("add" == $type)
  763. return $this->userdao->add_questions ( $uid, $category_id );
  764. else if ("take_out" == $type)
  765. return $this->userdao->take_out_questions ( $uid, $category_id );
  766. else
  767. return false;
  768. }
  769. /**
  770. * 设置回答数
  771. * @param unknown_type $type
  772. * @param unknown_type $uid 回答问题人UID
  773. * @param unknown_type $qid 回答问题ID
  774. */
  775. function set_answers($type = 'add', $uid = 0, $qid = 0) {
  776. if ("add" == $type)
  777. return $this->userdao->add_answers ( $uid, $qid );
  778. else if ("take_out" == $type)
  779. return $this->userdao->take_out_answers ( $uid, $qid );
  780. else
  781. return false;
  782. }
  783. /**
  784. * 添加一个回答
  785. * @param unknown_type $data
  786. */
  787. function add_answer($data = array()) {
  788. $this->answerdao->qid = $data ['qid'];
  789. $this->answerdao->title = $data ['title'];
  790. $this->answerdao->author = $data ['author'];
  791. $this->answerdao->authorid = $data ['authorid'];
  792. $this->answerdao->content = $data ['content'];
  793. $this->answerdao->time = get_date ();
  794. $this->answerdao->status = 1;
  795. $this->answerdao->ip = client_ip ();
  796. $result = $this->db ()->insert ( $this->answerdao );
  797. if ($result > 0) {
  798. $question = $this->questiondao->get_question_by_id ( $data ['qid'] );
  799. //添加回答数
  800. $this->set_answers ( 'add', $data ['authorid'], $data ['qid'] );
  801. //添加积分值
  802. $this->set_credit1 ( 'add', $data ['authorid'], CREDIT_POINT_ANSWER, CREDIT_ACTION_ANSWER );
  803. $subject = "问题&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;有新的回答";
  804. $content = "问题&nbsp;<a href=/askpage/" . $data ['qid'] . " >" . $data ['title'] . "</a>&nbsp;有新的回答";
  805. $this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
  806. $answer_list = $this->answerdao->get_answer_user_info_by_id ( $data ['qid'] );
  807. $answer = array ();
  808. foreach ( $answer_list as $key => $value ) {
  809. $ans = array ();
  810. $ans ['id'] = $value ['id'];
  811. $ans ['qid'] = $value ['qid'];
  812. $ans ['title'] = $value ['title'];
  813. $ans ['authorid'] = $value ['authorid'];
  814. $ans ['author'] = $value ['author'];
  815. $ans ['time'] = get_date ();
  816. $ans ['adopttime'] = $value ['adopttime'];
  817. $ans ['content'] = $value ['content'];
  818. $ans ['comment'] = $value ['comment'];
  819. array_push ( $answer, $ans );
  820. }
  821. $ans = array ();
  822. $ans ['id'] = $result;
  823. $ans ['qid'] = $data ['qid'];
  824. $ans ['title'] = $data ['title'];
  825. $ans ['authorid'] = $data ['authorid'];
  826. $ans ['author'] = $data ['author'];
  827. $ans ['time'] = $this->answerdao->time;
  828. $ans ['content'] = $data ['content'];
  829. array_push ( $answer, $ans );
  830. $answer = serialize ( $answer );
  831. //更新检索库
  832. //$pams = array ('id' => $data ['qid'], 'cid' => $question ['cid'], 'cid1' => $question ['cid1'], 'cid2' => $question ['cid2'], 'price' => $question ['price'], 'authoid' => $data ['authorid'], 'author' => $data ['author'], 'title' => $data ['title'], 'description' => $question ['description'], 'supply' => $question ['supply'], 'time' => $question ['time'], 'status' => QUESTOIN_STATUS_UNRESOLVED, 'answers' => $question ['answers'], 'answer' => $answer );
  833. //$this->update_search_index ( $pams );
  834. }
  835. return $result;
  836. }
  837. /**
  838. * 删除一个回答
  839. * @param unknown_type $aid
  840. */
  841. function delete_answer($aid = 0, $qid = 0) {
  842. $this->answerdao->id = $aid;
  843. $rs = $this->answerdao->get_answer_by_id ( $aid );
  844. $subject = "回答&nbsp;" . $rs ['title'] . "&nbsp;违规被删除";
  845. $content = "回答&nbsp;" . $rs ['title'] . "&nbsp;<span class=colRed >违规被删除</span>";
  846. $this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
  847. $this->db ()->delete ( $this->answerdao );
  848. $question = $this->questiondao->get_question_by_id ( $qid );
  849. //回答数更新
  850. $this->set_answers ( 'take_out', $question ['authorid'], $qid );
  851. //扣除积分
  852. $this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_ANSWER, ACTION_DELETE_ANSWER );
  853. }
  854. /**
  855. * 删除一个问题
  856. * @param unknown_type $qid
  857. */
  858. function delete_question($qid) {
  859. $condition = " where id = " . $qid;
  860. $data ['hidden'] = 1;
  861. $this->questiondao->update_question ( $data, $condition );
  862. $rs = $this->questiondao->get_question_by_id ( $qid );
  863. //扣除积分
  864. $this->set_credit1 ( 'take_out', $rs ['authorid'], POINT_DELETE_QUESTION, ACTION_DELETE_QUESTION );
  865. $question = $this->questiondao->get_question_by_id ( $qid );
  866. $subject = "问题&nbsp;<a href=/askpage/" . $question ['id'] . ">" . $question ['title'] . "</a>&nbsp;<span class=colRed>违规被删除</span>";
  867. $content = "问题&nbsp;<a href=/askpage/" . $question ['id'] . ">" . $question ['title'] . "</a>&nbsp;<span class=colRed>违规被删除</span>";
  868. $this->send_sys_message ( $subject, $content, $question ['authorid'] );
  869. }
  870. /**
  871. * 修改回答内容
  872. * @param unknown_type $aid
  873. * @param unknown_type $data
  874. */
  875. function update_answer_content($aid = 0, $data) {
  876. $condition = " where id = " . $aid;
  877. $this->answerdao->update_answer ( $data, $condition );
  878. }
  879. /**
  880. * 修改问题内容
  881. * @param unknown_type $qid
  882. * @param unknown_type $data
  883. */
  884. function update_queston_description($qid, $data) {
  885. $condition = " where id = " . $qid;
  886. $this->questiondao->update_question ( $data, $condition );
  887. }
  888. /**
  889. * 添加一个追问
  890. * @param unknown_type $data
  891. */
  892. function to_ask_question($data = array()) {
  893. $data ['tag'] = serialize ( array (0 => $data ['tag'] ) );
  894. $data ['tagtime'] = get_date ();
  895. $this->answerdao->update_taginfo_by_id ( $data );
  896. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  897. $question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
  898. $type = "FOLLOW_QUESTION";
  899. if ($question ['price'] > 0)
  900. $type = "PAY_FOLLOW_QUESTION";
  901. $this->send_email ( $rs ['authorid'], $type, $rs ['qid'], $rs ['id'] );
  902. //发送系统信息-发送给发回答用户
  903. $subject = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;提问者向您追问";
  904. $content = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;提问者向您追问";
  905. $this->messagedao->send_message ( ADMIN_NAME, 0, $rs ['authorid'], $subject, $content );
  906. }
  907. /**
  908. * 添加一个在回答
  909. * @param unknown_type $data
  910. */
  911. function answer_again($data = array()) {
  912. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  913. //追问和回答
  914. $tag_array = unserialize ( $rs ['tag'] );
  915. array_push ( $tag_array, $data ['tag'] );
  916. array_push ( $tag_array, get_date () );
  917. $tag = serialize ( $tag_array );
  918. $data ['tag'] = $tag;
  919. $data ['tagtime'] = $rs ['tagtime'];
  920. $this->answerdao->update_taginfo_by_id ( $data );
  921. $rs = $this->answerdao->get_answer_by_id ( $data ['id'] );
  922. $question = $this->questiondao->get_question_by_id ( $rs ['qid'] );
  923. $type = "FOLLOW_ANSWER";
  924. if ($question ['price'] > 0)
  925. $type = "PAY_FOLLOW_ANSWER";
  926. $this->send_email ( $question ['authorid'], $type, $rs ['qid'], $data ['id'] );
  927. //发送系统信息-发送给发回答用户
  928. $subject = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;追问后有新的回答";
  929. $content = "回答&nbsp;<a href=/askpage/" . $rs ['qid'] . " >" . $rs ['title'] . "</a>&nbsp;追问后有新的回答";
  930. $this->messagedao->send_message ( ADMIN_NAME, 0, $question ['authorid'], $subject, $content );
  931. }
  932. /**
  933. * 更新用户头像
  934. * @param unknown_type $data
  935. */
  936. function update_avatar($data = array()) {
  937. $this->userdao->update_avatar ( $data );
  938. }
  939. /**
  940. * 关闭问题
  941. * @param unknown_type $qid
  942. */
  943. function close_question($qid = 0) {
  944. $this->questiondao->close_question ( $qid );
  945. $result = $this->questiondao->get_question_user_info_by_id ( $qid );
  946. $subject = "问题&nbsp;<a href=/askpage/" . $result ['id'] . " >" . $result ['title'] . "</a>&nbsp;已经关闭";
  947. $content = "问题&nbsp;<a href=/askpage/" . $result ['id'] . " >" . $result ['title'] . "</a>&nbsp;已经关闭";
  948. $this->messagedao->send_message ( ADMIN_NAME, 0, $result ['authorid'], $subject, $content );
  949. //扣除RMB到基金中
  950. if ($result ['price'] > 0)
  951. $this->_set_fund ( $result ['authorid'], $result ['id'], $result ['price'] );
  952. }
  953. /**
  954. * 添加悬赏值
  955. * @param unknown_type $qid
  956. * @param unknown_type $add_price
  957. */
  958. function do_up_price($qid = 0, $add_price = 0) {
  959. $this->questiondao->do_up_price ( $qid, $add_price );
  960. }
  961. /**
  962. * 更新问题补充信息
  963. */
  964. function update_queston_supply($data = array(), $qid = 0) {
  965. $question = $this->questiondao->get_question_by_id ( $qid );
  966. if (! empty ( $question ['supply'] ))
  967. return false;
  968. $condition = " where id = " . $qid;
  969. $supply [0] ['content'] = $data ['supply'];
  970. $supply [0] ['time'] = get_date ();
  971. $data ['supply'] = serialize ( $supply );
  972. $this->questiondao->update_question ( $data, $condition );
  973. $type = "REPLENISH_QUESTION";
  974. if ($question ['price'] > 0)
  975. $type = "PAY_REPLENISH_QUESTION";
  976. $this->send_email ( $question ['authorid'], $type, $qid, 0 );
  977. }
  978. /**
  979. * 更新用户信息-仅电话和昵称
  980. * @param unknown_type $data
  981. */
  982. function update_user_info($data = array()) {
  983. Doo::loadModel ( 'UserDao' );
  984. $userdao = new UserDao ();
  985. $userdao->uid = $data ['uid'];
  986. if (isset ( $data ['phone'] ))
  987. $userdao->phone = $data ['phone'];
  988. if (isset ( $data ['nickname'] ))
  989. $userdao->nickname = $data ['nickname'];
  990. if (isset ( $data ['cids'] ))
  991. $userdao->cids = $data ['cids'];
  992. if (isset ( $data ['is_email'] ))
  993. $userdao->is_email = $data ['is_email'];
  994. $result = $this->db ()->update ( $userdao );
  995. }
  996. /**
  997. * 记录财富流向
  998. * @param unknown_type $data
  999. */
  1000. function set_credit3_log($data = array(), $price = 0) {
  1001. $this->credit3logdao->qid = $data ['id'];
  1002. $this->credit3logdao->username = $data ['username'];
  1003. $this->credit3logdao->time = get_date ();
  1004. $this->credit3logdao->ip = client_ip ();
  1005. $this->credit3logdao->amount = $price;
  1006. $action = $this->credit3logdao->set_ACTION_OFFER_QUESTION ();
  1007. $this->credit3logdao->add_credit3_log ( $data ['uid'], $data ['username'], $data ['id'], $action, - $price, $this->credit3logdao->ip );
  1008. }
  1009. /**
  1010. * 记录退款
  1011. */
  1012. function set_credit3_refunds_log($data = array()) {
  1013. $this->credit3logdao->qid = $data ['id'];
  1014. $this->credit3logdao->username = $data ['author'];
  1015. $this->credit3logdao->time = get_date ();
  1016. $this->credit3logdao->ip = client_ip ();
  1017. $this->credit3logdao->amount = $data ['price'];
  1018. $action = $this->credit3logdao->set_ACTION_REFUNDS_QUESTION ();
  1019. $this->credit3logdao->add_credit3_log ( $data ['authorid'], $data ['author'], $data ['id'], $action, + $data ['price'], $this->credit3logdao->ip, 1 );
  1020. }
  1021. /**
  1022. * 将名师答疑的问题设置成满意
  1023. * @param unknown_type $id
  1024. */
  1025. function set_vip_question_status($id = 0, $status = 0, $refunds_description = "") {
  1026. if ($status == 0)
  1027. return false;
  1028. $this->vipquestiondao->set_vip_question_status ( $id, $status, $refunds_description );
  1029. }
  1030. /**
  1031. * 发送系统信息
  1032. * @param unknown_type $subject
  1033. * @param unknown_type $content
  1034. * @param unknown_type $uid
  1035. */
  1036. function send_sys_message($subject, $content, $uid) {
  1037. $this->messagedao->send_message ( ADMIN_NAME, 0, $uid, $subject, $content );
  1038. }
  1039. /**
  1040. * 追加一个名师答疑的追问
  1041. * @param unknown_type $id
  1042. * @param unknown_type $tag
  1043. */
  1044. function do_add_vip_tag($id = 0, $tag = "") {
  1045. $tag = serialize ( array (0 => $tag, 1 => get_date () ) );
  1046. $this->vipanswerdao->do_add_vip_tag ( $id, $tag );
  1047. }
  1048. /**
  1049. * 更新名师答疑回答数
  1050. * @param unknown_type $id
  1051. */
  1052. function update_vip_question_by_answers($id) {
  1053. $this->vipquestiondao->update_vip_question_by_answers ( $id );
  1054. }
  1055. /**
  1056. * 添加追问答案
  1057. * @param unknown_type $id
  1058. * @param unknown_type $content
  1059. */
  1060. function update_vip_answer($content = "", $aid = 0, $tag = "") {
  1061. $this->vipanswerdao->id = $aid;
  1062. //追问和回答
  1063. $tag_array = unserialize ( $tag );
  1064. $tag_array ['2'] = $content;
  1065. $tag = serialize ( $tag_array );
  1066. $this->vipanswerdao->tag = $tag;
  1067. $result = $this->db ()->update ( $this->vipanswerdao );
  1068. }
  1069. /**
  1070. * 添加一个公告
  1071. * @param unknown_type $params
  1072. */
  1073. function add_article($params = array()) {
  1074. Doo::loadModel ( 'ArticleDao' );
  1075. $articledao = new ArticleDao ();
  1076. $articledao->title = $params ['title'];
  1077. $articledao->content = $params ['content'];
  1078. $articledao->time = time ();
  1079. $result = $this->db ()->insert ( $articledao );
  1080. }
  1081. /**
  1082. * 获取一个文章
  1083. * @param unknown_type $id
  1084. */
  1085. function get_article_by_id($id = 0) {
  1086. Doo::loadModel ( 'ArticleDao' );
  1087. $articledao = new ArticleDao ();
  1088. $articledao->aid = $id;
  1089. $rs = $this->db ()->find ( $articledao, array ('limit' => 1 ) );
  1090. $rs->time = format_date ( $rs->time );
  1091. return $rs;
  1092. }
  1093. /**
  1094. * 更新一篇文章
  1095. * @param unknown_type $params
  1096. */
  1097. function update_article($params) {
  1098. Doo::loadModel ( 'ArticleDao' );
  1099. $articledao = new ArticleDao ();
  1100. $articledao->aid = $params ['id'];
  1101. $articledao->title = $params ['title'];
  1102. $articledao->content = $params ['content'];
  1103. $this->db ()->update ( $articledao );
  1104. }
  1105. /**
  1106. * 删除文档
  1107. * @param unknown_type $uid
  1108. */
  1109. function delete_article($id = array()) {
  1110. Doo::loadModel ( 'ArticleDao' );
  1111. $articledao = new ArticleDao ();
  1112. $articledao->delete_article ( $id );
  1113. }
  1114. /**
  1115. * 添加名师答疑评价
  1116. * @param unknown_type $qid
  1117. * @param unknown_type $comment
  1118. */
  1119. function update_vip_answer_comment($qid = 0, $comment = "") {
  1120. $this->vipanswerdao->update_vip_answer_comment ( $qid, $comment );
  1121. }
  1122. /**
  1123. * 添加讨论
  1124. * @param unknown_type $qid
  1125. * @param unknown_type $uid
  1126. * @param unknown_type $content
  1127. * @param unknown_type $cid
  1128. */
  1129. function add_discuss($qid = 0, $uid = 0, $content = "", $cid = 0) {
  1130. Doo::loadModel ( 'DiscussDao' );
  1131. $discussdao = new DiscussDao ();
  1132. $discussdao->uid = $uid;
  1133. $discussdao->qid = $qid;
  1134. $discussdao->cid = $cid;
  1135. $discussdao->content = $content;
  1136. $discussdao->time = get_date ();
  1137. $discussdao->discuss = 0;
  1138. $result = $this->db ()->insert ( $discussdao );
  1139. return $result;
  1140. }
  1141. /**
  1142. * 更新讨论数
  1143. * @param unknown_type $cid
  1144. */
  1145. function update_discuss($cid = 0) {
  1146. Doo::loadModel ( 'DiscussDao' );
  1147. $discussdao = new DiscussDao ();
  1148. $discussdao->update_discuss ( $cid );
  1149. }
  1150. /**
  1151. * 添加一个公告
  1152. * @param unknown_type $params
  1153. */
  1154. function add_category($params = array()) {
  1155. Doo::loadModel ( 'CategoryDao' );
  1156. $categorydao = new CategoryDao ();
  1157. $categorydao->name = $params ['name'];
  1158. $categorydao->pid = $params ['pid'];
  1159. $categorydao->grade = 1;
  1160. $result = $this->db ()->insert ( $categorydao );
  1161. }
  1162. /**
  1163. * 删除选中问题
  1164. * @param unknown_type $id
  1165. */
  1166. function delete_category_list($id = array()) {
  1167. $this->categorydao->delete_category_list ( $id );
  1168. }
  1169. /**
  1170. * 更新分类信息
  1171. * @param unknown_type $id
  1172. * @param unknown_type $name
  1173. * @param unknown_type $pid
  1174. */
  1175. function update_category($id = 0, $name = "", $pid = 0) {
  1176. $this->categorydao->id = $id;
  1177. $this->categorydao->name = $name;
  1178. $this->categorydao->pid = $pid;
  1179. $result = $this->db ()->update ( $this->categorydao );
  1180. }
  1181. /**
  1182. * 设置为默认发送邮件
  1183. * @param unknown_type $uid
  1184. */
  1185. function set_email_config($uid = 0) {
  1186. if ($uid == 0)
  1187. return false;
  1188. $data ['normal_question_mail'] = array ("0" => "NEW_ANSWER", "1" => "CLOSE_QUESTION", "2" => "FOLLOW_ANSWER", "3" => "FOLLOW_QUESTION", "4" => "REPLENISH_QUESTION", "5" => "ADOPT_ANSWER" );
  1189. $data ['pay_question_mail'] = array ("1" => "PAY_NEW_ANSWER", "2" => "PAY_CLOSE_QUESTION", "3" => "PAY_FOLLOW_ANSWER", "4" => "PAY_FOLLOW_QUESTION", "5" => "PAY_REPLENISH_QUESTION", "6" => "PAY_ADOPT_ANSWER", "7" => "PAY_FORMONEY" );
  1190. $data ['vip_question_mail'] = array ("1" => "VIP_PAY_FORMONEY", "2" => "VIP_MONEY_BACK", "3" => "VIP_NEW_ANSWER", "4" => "VIP_FOLLOW_ANSWER" );
  1191. $this->add_email_config ( $data, $uid );
  1192. $data ['uid'] = $uid;
  1193. $data ['is_email'] = 1;
  1194. $this->update_user_info ( $data );
  1195. }
  1196. /**
  1197. * 获取个人email配置
  1198. * @param unknown_type $uid
  1199. */
  1200. function get_email_config($uid = 0) {
  1201. Doo::loadModel ( 'EmailconfigDao' );
  1202. $emailconfigdao = new EmailconfigDao ();
  1203. $result = $emailconfigdao->get_emailconfig_by_uid ( $uid );
  1204. $is_email = array ();
  1205. foreach ( $result as $key => $value ) {
  1206. array_push ( $is_email, $value ['action_id'] );
  1207. }
  1208. return $is_email;
  1209. }
  1210. /**
  1211. * 添加email配置
  1212. * @param unknown_type $data
  1213. * @param unknown_type $uid
  1214. */
  1215. function add_email_config($data = array(), $uid = 0) {
  1216. Doo::loadModel ( 'EmailconfigDao' );
  1217. $emailconfigdao = new EmailconfigDao ();
  1218. $emailconfigdao->delete_emailconfig_by_uid ( $uid );
  1219. $normal = $pay = $vip = array ();
  1220. //添加普通问答配置
  1221. foreach ( $data ['normal_question_mail'] as $key => $value ) {
  1222. array_push ( $normal, "(" . $uid . ",'" . $value . "')" );
  1223. }
  1224. if (! empty ( $normal )) {
  1225. $normal = implode ( ",", $normal );
  1226. $emailconfigdao->add_emailconfig ( $normal );
  1227. }
  1228. //悬赏问答
  1229. foreach ( $data ['pay_question_mail'] as $key => $value ) {
  1230. array_push ( $pay, "(" . $uid . ",'" . $value . "')" );
  1231. }
  1232. if (! empty ( $pay )) {
  1233. $pay = implode ( ",", $pay );
  1234. $emailconfigdao->add_emailconfig ( $pay );
  1235. }
  1236. //名师答疑
  1237. foreach ( $data ['vip_question_mail'] as $key => $value ) {
  1238. array_push ( $vip, "(" . $uid . ",'" . $value . "')" );
  1239. }
  1240. if (! empty ( $vip )) {
  1241. $vip = implode ( ",", $vip );
  1242. $emailconfigdao->add_emailconfig ( $vip );
  1243. }
  1244. }
  1245. /**
  1246. * 实现接口
  1247. * (non-PHPdoc)
  1248. * @see BaseLogic::format_email_content()
  1249. */
  1250. protected function format_email_content($html_templete, $templete_name, $qid = 0, $aid = 0) {
  1251. if ($templete_name == "VIP_PAY_FORMONEY" || $templete_name == "VIP_MONEY_BACK" || $templete_name == "VIP_NEW_ANSWER" || $templete_name == "VIP_FOLLOW_ANSWER") {
  1252. $question = $this->vipquestiondao->get_vip_question_by_id ( $qid );
  1253. $answer = $this->vipanswerdao->get_vip_answer_by_qid ( $qid );
  1254. } else {
  1255. $question = $this->questiondao->get_question_by_id ( $qid );
  1256. $answer = $this->answerdao->get_answer_by_id ( $aid );
  1257. }
  1258. $userinfo = $this->get_sso_user_info_by_name ( $question ['author'] );
  1259. $result = array ();
  1260. if ($templete_name == "NEW_ANSWER" || $templete_name == "PAY_NEW_ANSWER") { //提问有新的回答
  1261. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1262. $str = str_replace ( "%uid%", $answer ['authorid'], $str );
  1263. $str = str_replace ( "%answer_username%", $answer ['author'], $str );
  1264. $str = str_replace ( "%answer_time%", format_date ( $answer ['time'], "Y年m月d日" ), $str );
  1265. $str = str_replace ( "%qid%", $question ['id'], $str );
  1266. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1267. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1268. $result ['templete'] = $str;
  1269. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的提问有新的回答' ) . "?=";
  1270. //$result ['subject'] = "";
  1271. $result ['toemail'] = $userinfo [0] ['useremail'];
  1272. //$result ['toemail'] = "cpthought@vip.qq.com";
  1273. return $result;
  1274. } elseif ($templete_name == "CLOSE_QUESTION" || $templete_name == "PAY_CLOSE_QUESTION") { //问题被关闭
  1275. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1276. $str = str_replace ( "%qid%", $question ['id'], $str );
  1277. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1278. $str = str_replace ( "%question_time%", format_date ( time (), "Y年m月d日" ), $str );
  1279. $result ['templete'] = $str;
  1280. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的问题被关闭' ) . "?=";
  1281. $result ['toemail'] = $userinfo [0] ['useremail'];
  1282. return $result;
  1283. } elseif ($templete_name == "FOLLOW_ANSWER" || $templete_name == "PAY_FOLLOW_ANSWER") { //追问有新的回答
  1284. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1285. $str = str_replace ( "%qid%", $question ['id'], $str );
  1286. $str = str_replace ( "%answer_username%", $answer ['author'], $str );
  1287. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1288. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1289. $tag_array = unserialize ( $answer ['tag'] );
  1290. $str = str_replace ( "%ask2%", $tag_array [0], $str );
  1291. $str = str_replace ( "%answer2%", $tag_array [1], $str );
  1292. $result ['templete'] = $str;
  1293. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的追问有新的回答' ) . "?=";
  1294. $result ['toemail'] = $userinfo [0] ['useremail'];
  1295. return $result;
  1296. } elseif ($templete_name == "FOLLOW_QUESTION" || $templete_name == "PAY_FOLLOW_QUESTION") { //提问者向您追问
  1297. $str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
  1298. $str = str_replace ( "%qid%", $question ['id'], $str );
  1299. $str = str_replace ( "%username%", $question ['author'], $str );
  1300. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1301. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1302. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1303. $tag_array = unserialize ( $answer ['tag'] );
  1304. $str = str_replace ( "%ask2%", $tag_array [0], $str );
  1305. $result ['templete'] = $str;
  1306. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者向您追问' ) . "?=";
  1307. $result ['toemail'] = $userinfo [0] ['useremail'];
  1308. return $result;
  1309. } elseif ($templete_name == "REPLENISH_QUESTION" || $templete_name == "PAY_REPLENISH_QUESTION") { //提问这对问题进行了补充
  1310. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1311. $str = str_replace ( "%qid%", $question ['id'], $str );
  1312. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1313. $tag_array = unserialize ( $question ['supply'] );
  1314. $str = str_replace ( "%supply%", $tag_array [0] ['content'], $str );
  1315. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1316. $result ['templete'] = $str;
  1317. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:提问者对问题进行了补充' ) . "?=";
  1318. $result ['toemail'] = $userinfo [0] ['useremail'];
  1319. return $result;
  1320. } elseif ($templete_name == "ADOPT_ANSWER" || $templete_name == "PAY_ADOPT_ANSWER") { //回答被采纳了
  1321. $str = str_replace ( "%answer_username%", $answer ['author'], $html_templete );
  1322. $str = str_replace ( "%qid%", $answer ['qid'], $str );
  1323. $str = str_replace ( "%username%", $question ['author'], $str );
  1324. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1325. $str = str_replace ( "%question_title%", $question ['title'], $str );
  1326. $str = str_replace ( "%answer_content%", $answer ['content'], $str );
  1327. $result ['templete'] = $str;
  1328. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您的回答被采纳了!' ) . "?=";
  1329. $userinfo = $this->get_sso_user_info_by_name ( $answer ['author'] );
  1330. $result ['toemail'] = $userinfo [0] ['useremail'];
  1331. return $result;
  1332. } elseif ($templete_name == "PAY_FORMONEY") {
  1333. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1334. $str = str_replace ( "%price%", $question ['price'], $str );
  1335. $str = str_replace ( "%qid%", $question ['id'], $str );
  1336. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1337. $result ['templete'] = $str;
  1338. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
  1339. $result ['toemail'] = $userinfo [0] ['useremail'];
  1340. return $result;
  1341. } elseif ($templete_name == "VIP_PAY_FORMONEY") { //名师答疑付费提醒
  1342. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1343. $str = str_replace ( "%price%", $question ['price'], $str );
  1344. $str = str_replace ( "%uid%", $question ['authorid'], $str );
  1345. $result ['templete'] = $str;
  1346. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:您进行了一项付费操作' ) . "?=";
  1347. $result ['toemail'] = $userinfo [0] ['useremail'];
  1348. return $result;
  1349. } elseif ($templete_name == "VIP_NEW_ANSWER") { //名师答疑有回答提醒
  1350. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1351. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1352. $str = str_replace ( "%vqid%", $question ['id'], $str );
  1353. $str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
  1354. $str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
  1355. $result ['templete'] = $str;
  1356. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你的名师答疑有新的回答' ) . "?=";
  1357. $result ['toemail'] = $userinfo [0] ['useremail'];
  1358. return $result;
  1359. } elseif ($templete_name == "VIP_MONEY_BACK") { //名师答疑退费提醒
  1360. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1361. $str = str_replace ( "%price%", $question ['price'], $str );
  1362. $str = str_replace ( "%uid%", $question ['authorid'], $str );
  1363. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1364. $result ['templete'] = $str;
  1365. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:向您退费成功' ) . "?=";
  1366. $result ['toemail'] = $userinfo [0] ['useremail'];
  1367. return $result;
  1368. } elseif ($templete_name == "VIP_FOLLOW_ANSWER") { //名师答疑追问有了新的回答
  1369. $str = str_replace ( "%username%", $question ['author'], $html_templete );
  1370. $str = str_replace ( "%time%", format_date ( time (), "Y年m月d日" ), $str );
  1371. $str = str_replace ( "%vipquestion_title%", $question ['title'], $str );
  1372. $str = str_replace ( "%vanswer_content%", $answer ['content'], $str );
  1373. $str = str_replace ( "%vqid%", $question ['id'], $str );
  1374. $result ['templete'] = $str;
  1375. $result ['subject'] = "=?UTF-8?B?" . base64_encode ( '纵横知道·问答提醒您:你在名师答疑中追问有新的回答' ) . "?=";
  1376. $result ['toemail'] = $userinfo [0] ['useremail'];
  1377. //$result ['toemail'] = "cpthought@vip.qq.com";
  1378. return $result;
  1379. }
  1380. }
  1381. }
  1382. ?>