123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- <?php
- /**
- * 问答显示业务ajax
- * @author cp
- *
- */
- if (! defined ( 'IN_ZHASK' )) {
- exit ( 'invalid request' );
- }
- class AjaxUserController extends DooController {
-
- private $userlogic;
- private $asklogic;
-
- private $userinfo = array ('uid' => '0' );
-
- function __construct() {
-
- Load::controller ( "BaseController" );
-
- $base = new BaseController ();
-
- $this->userinfo = $base->init ();
-
- Load::logic ( 'User' );
- Load::logic ( 'Ask' );
-
- $this->userlogic = new UserLogic ();
- $this->asklogic = new AskLogic ();
- }
-
- /**
- * 获取分词
- */
- function get_search_works(){
-
- $keywork = isset($_GET['term']) ? $_GET['term'] : '';
-
- require_once (XUNSEARCH_URL);
-
- $xs = new XS ( SEARCH_INI );
-
- $words = $xs->search->addDb ( SEARCH_WD_DB )->getExpandedQuery($keywork);
-
- if (!empty($words)) {
- echo json_encode($words);
- }
- }
-
- /**
- * 设置赞同数
- */
- function do_support_answer() {
- $aid = $this->get_args ( 'aid' );
-
- $aid = is_numeric ( $aid ) ? $aid : 0;
-
- if ($aid < 0) {
- echo "{false}";
- return false;
- }
-
- $re = $this->userlogic->update_support_answer ( $aid, $this->userinfo ['uid'] );
-
- $json = '{"success": true}';
- if (! $re) {
- echo "{false}";
- return false;
- }
- echo $json;
- }
-
- /**
- * 编辑回答
- */
- function do_edit_answer() {
-
- $aid = is_numeric ( $this->get_args ( 'aid' ) ) ? $this->get_args ( 'aid' ) : 0;
-
- $data ['content'] = stripcslashes ( $this->get_args ( 'content' ) );
-
- if ($aid < 0 || empty ( $data ['content'] )) {
- echo "{false}";
- return false;
- }
-
- $this->userlogic->update_answer_content ( $aid, $data );
-
- $json = '{"success": true}';
-
- echo $json;
- }
-
- /**
- * 编辑问题
- */
- function do_edit_question() {
-
- $qid = is_numeric ( $this->get_args ( 'qid' ) ) ? $this->get_args ( 'qid' ) : 0;
-
- $data ['description'] = stripcslashes ( $this->get_args ( 'content' ) );
-
- if ($qid < 0 || empty ( $data ['description'] )) {
- echo "{false}";
- return false;
- }
-
- $this->userlogic->update_queston_description ( $qid, $data );
-
- $json = '{"success": true}';
-
- echo $json;
- }
-
- /**
- * 提高悬赏值
- */
- function do_up_price() {
- $qid = $this->get_args ( 'qid' );
-
- $add_price = $this->get_args ( 'add_price' );
-
- $qid = is_numeric ( $qid ) ? $qid : 0;
-
- $data ['add_price'] = is_numeric ( $add_price ) ? $add_price : 0;
-
- if ($qid < 0 || $data ['add_price'] < 0) {
- echo "{false}";
- return false;
- }
-
- $reslut = $this->asklogic->get_question_user_info ( $qid );
-
- //判断是否是该用户操作
- if ($reslut ['uid'] != $this->userinfo ['uid'] || $data ['add_price'] > $reslut ['credit3'] || $reslut ['status'] == QUESTOIN_STATUS_CLOSE) {
- echo "{false}";
- return false;
- }
-
- //减少用户财富总值-记录到日常操作类
- $is=$this->userlogic->set_credit3 ( - $data ['add_price'], $reslut ['uid'], RICH_ACTION_OFFER,SSO_UID );
-
- if($is==0){
- echo "{false}";
- return false;
- }
-
- //记录流向
- $this->userlogic->set_credit3_log ( $reslut, $data ['add_price'] );
-
- //提高悬赏值
- $this->userlogic->do_up_price ( $qid, $data ['add_price'] );
-
- $json = '{"success": true}';
-
- echo $json;
- }
-
- /**
- * 添加补充问题内容
- */
- function do_add_supply() {
- $qid = is_numeric ( $this->get_args ( 'qid' ) ) ? $this->get_args ( 'qid' ) : 0;
-
- $data ['supply'] = stripcslashes ( $this->get_args ( 'supply' ) );
-
- if ($qid == 0)
- return false;
-
- $this->userlogic->update_queston_supply ( $data, $qid );
-
- $json = '{"success": true}';
-
- echo $json;
-
- }
-
- /**
- * 上次图片
- */
- public function upload_avatar() {
- if (isset ( $_FILES ['Filedata'] ['name'] )) {
-
- $file = $_FILES ['Filedata'] ['tmp_name'];
-
- $error = false;
-
- if (! is_uploaded_file ( $file )) {
-
- $error = '400 Bad Request';
- }
-
- if ($error) {
-
- header ( 'HTTP/1.0 ' . $error );
-
- die ( 'Error ' . $error );
- } else {
-
- Load::lib ( "io" );
-
- $IoHandler = new IoHandler ();
-
- $dateline = get_date ();
-
- $filedir = date ( 'y/m/d' );
-
- //调用定义物理路径
- $t = ROOT_PATH . "global/upload/" . $filedir;
-
- $li = $IoHandler->MakeDir ( $t );
-
- $filename = _GetFileEXT ( $_FILES ['Filedata'] ['name'] );
-
- $upload_dir = $t . "/" . $dateline . "." . $filename;
-
- $k = move_uploaded_file ( $file, $upload_dir );
-
- //存储相对的视频路径
- $upload_video = "<input type='hidden' name='avatar' value='/global/upload/" . $filedir . "/" . $dateline . "." . $filename . "' /><img src='/global/upload/" . $filedir . "/" . $dateline . "." . $filename . "' height='100' width='100' /> <a href='javascript:void(0)'>删除图片</a>";
-
- if ($k) {
-
- echo $upload_video;
- } else {
-
- echo "";
- }
-
- }
- }
- }
-
- /**
- * 编辑名师答疑问题
- */
- function do_edit_vip_question() {
-
- $qid = is_numeric ( $this->get_args ( 'qid' ) ) ? $this->get_args ( 'qid' ) : 0;
-
- $data ['description'] = stripcslashes ( $this->get_args ( 'description' ) );
-
- //检测该问题是否是该用户
- if ($this->userinfo ['groupid'] == USER_VIP || $this->userinfo ['groupid'] == SUPER_ADMIN_ID || $this->userinfo ['groupid'] == ADMIN_ID)
- $vip_question = $this->asklogic->get_vip_questions_by_id ( $qid );
- else
- $vip_question = $this->asklogic->get_vip_question_by_quid ( $qid, $this->userinfo ['uid'] );
-
- if (empty ( $vip_question )) {
- echo '{"success": false}';
- die ();
- }
-
- $this->asklogic->update_vip_question_description ( $qid, $data ['description'] );
-
- $json = '{"success": true}';
-
- echo $json;
- }
-
- /**
- * 对名师答疑的回答进行评价
- */
- function do_comment_vip_answer(){
- $qid = is_numeric ( $this->get_args ( 'qid' ) ) ? $this->get_args ( 'qid' ) : 0;
-
- $data ['comment'] = stripcslashes ( $this->get_args ( 'comment' ) );
-
- //检测该问题是否是该用户
- if ($this->userinfo ['groupid'] == USER_VIP || $this->userinfo ['groupid'] == SUPER_ADMIN_ID || $this->userinfo ['groupid'] == ADMIN_ID)
- $vip_question = $this->asklogic->get_vip_questions_by_id ( $qid );
- else
- $vip_question = $this->asklogic->get_vip_question_by_quid ( $qid, $this->userinfo ['uid'] );
-
- if (empty ( $vip_question )) {
- echo '{"success": false}';
- die ();
- }
-
- $this->userlogic->update_vip_answer_comment($qid,$data ['comment']);
-
- $json = '{"success": true}';
-
- echo $json;
- }
-
- /**
- * 获取用户的退款次数
- */
- function get_vip_refunds(){
- $qid = is_numeric ( $this->get_args ( 'qid' ) ) ? $this->get_args ( 'qid' ) : 0;
-
- $vip_question = $this->asklogic->get_vip_question_by_quid ( $qid, $this->userinfo ['uid'] );
-
- if(empty($vip_question)){
- echo '{"message": false}';
- die ();
- }elseif($vip_question['status']!=PAID_FILL_IN){
- echo '{"message": false}';
- die ();
- }
-
- if($this->userinfo['refunds']==1)
- echo '{"message":"确定后,我们将为您这次答疑退款;<br><a href=javascript:void(0) >关于\"退款\"</a>","refunds":1}';
- else
- echo '{"message":"您无法进行不满意\"操作\";无法退款!<br><a href=javascript:void(0) >关于退款</a>","refunds":0}';
-
-
- }
-
- /**
- * 用户登录处理--session和用户日志后期可以改成写入文件
- */
- function do_login_index() {
-
- $username = $this->get_args ( "username" );
-
- $password = $this->get_args ( "password" );
-
- $day = is_numeric ( $this->get_args ( "day" ) ) ? $this->get_args ( "day" ) : 1;
-
- $lifetime = $day < 0 ? 0 : $day;
-
- if (empty ( $username ) || empty ( $password )) {
- echo '{"is_login":false,"message":""}';die;
- }
-
- $user = $this->userlogic->get_users_by_name ( $username );
-
- require_once (SITE_PATH . '/protected/plugin/client.php');
-
- $client = new client ( ZHSSO );
-
- $is_login = $client->zhsso_member_login ( $username, $password );
-
- if (is_numeric ( $is_login )) {
- if ($is_login == USERNAME_ONFINE) {
-
- echo '{"is_login":false}';die;
- } elseif ($is_login == PASSWORD_ERROR){
-
- echo '{"is_login":false}';die;
- }
- }
- echo '{"is_login":true}';
- }
-
- /**
- * 获取get或者POST值
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else
- return addslashes ( $_GET [$name] );
-
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else
- return addslashes ( $_POST [$name] );
- } else {
-
- return false;
- }
- }
-
- /**
- * 检测数据输入的非法字符和转义非法字符
- */
- function check_params($name = "") {
- if (isset ( $this->params [$name] )) {
-
- return addslashes ( $this->params [$name] );
- } else {
-
- return false;
- }
- }
- public function askUpdate(){
- $creditlist = $this->asklogic->get_credit_log();
- require_once (SITE_PATH . '/protected/plugin/client.php');
- $client = new client ( ZHSSO );
- foreach($creditlist as $k => $v){
- $type = $v['amount'] < 0 ? 2 : 1;
- $is_succes = $client->zhsso_member_askupdate($v['username'], $type, abs($v['amount']), $v['time']);
- $is_succes = explode ( "\r", $is_succes );
- $ts = json_decode ( $is_succes ['0'], true );
- if($ts != 1){
- exit($k);
- }
- }
- exit('success');
- }
- }
- ?>
|