UserLogic.php 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112
  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 === false)
  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. ?>