public function transmit() { $post = $this->__get_post(); if (empty($post['W_U_name'])) { echo $this->fun->json_encode(array('error' => -1, 'msg' => '腾讯微博账号不存在')); exit; } if (empty($post['content'])) { echo $this->fun->json_encode(array('error' => -2, 'msg' => '转发信息不能为空')); exit; } //10分钟转发一次 if ($time = $this->db->select_to_1Array("select time from award_wb where W_U_name='{$post['W_U_name']}' order by id desc limit 1;")) { if ($time['time'] + 600 > time()) { $time = ceil(($time['time'] + 600 - time()) / 60); echo $this->fun->json_encode(array('error' => -3, 'msg' => '操作过快,请 ' . $time . ' 分钟后在转发')); exit; } } $call = OpenSDK_Tencent_Weibo::call('t/re_add', array('content' => $post['content'], 'clientip' => $this->userIP, 'reid' => $post['wbID']), 'POST', FALSE, true); $friends = false; if ($post['friends']) { $friends = $this->friends_add($post['friends']); } //提交成功 if ($call['ret'] == 0) { $array = array(); $array['W_U_name'] = $post['W_U_name']; $array['W_U_nick'] = $post['W_U_nick']; $array['W_U_info_id'] = $call['data']['id']; $array['W_U_info'] = $post['content']; $array['W_U_ip'] = $this->userIP; $array['time'] = $call['data']['time']; $array['is_friends'] = $friends ? 1 : 0; if ($tab = $this->db->select_to_2Array("select * from award order by taxis asc")) { $this->load_file('award', '', false); $award = new award(); $keys = $award->exec($tab); $array['aid'] = $keys['id']; $Ks = strtoupper($this->fun->rand_string(16)); $Ks = substr($Ks, 0, 4) . ' - ' . substr($Ks, 4, 4) . ' - ' . substr($Ks, 8, 4) . ' - ' . substr($Ks, 12, 4); $array['key'] = $Ks; $this->db->insert('award_wb', $array); $id = $this->db->get_id(); echo $this->fun->json_encode(array('error' => '0', 'info' => array('msg' => str_replace('{{key}}', $Ks, $keys['views']), 'shareID' => $id, 'share' => $keys['share']))); exit; } else { echo $this->fun->json_encode(array('error' => -4, 'msg' => '程序处理错误,请与管理员联系')); exit; } } else { //接口发送不成功 echo $this->fun->json_encode(array('error' => -5, 'msg' => '转发不成功,请过会操作')); exit; } }
public function buy_stock($sid, $uid, $price, $count) { $db = new DB(); $db->Connect(DBHOST, DBUSER, DBPW, DBNAME); $sql = "insert stock_trans_list(sid,uid,price,count,addtime,type) value({$sid},{$uid},{$price},{$count},now(),'买入')"; $db->query($sql); $sql = "update stock set counts = counts-{$count} where id={$sid}"; $db->query($sql); //扣钱 $sumprice = $price * $count; $sql = "insert income(userid,types,amount,addtime,reason,states,settlementno) values(" . $uid . ",'BUYSTOCK','-" . $sumprice . "',now(),'购买股票',2,'')"; $db->query($sql); $sql = "update users set inputamount = inputamount-{$sumprice},stock=stock+{$count} where id={$uid}"; $db->query($sql); //购买股票产生见点奖 根据投资总额 $stockinfo = new stock(); $award = new award(); /*$stock_price = $stockinfo->get_newprice(1); $amount = $count*$stock_price;*/ $award->recursivepid($db, $uid, 1, $sumprice); }
public function transmit() { $post = $this->__get_post(); if (empty($post['W_U_id'])) { echo $this->fun->json_encode(array('error' => -1, 'msg' => '新浪微博账号不存在')); exit; } if (empty($post['content'])) { echo $this->fun->json_encode(array('error' => -2, 'msg' => '转发信息不能为空')); exit; } //10分钟转发一次 if ($time = $this->db->select_to_1Array("select time from award_wb where W_U_id='{$post['W_U_id']}' order by id desc limit 1;")) { if ($time['time'] + 600 > time()) { $time = ceil(($time['time'] + 600 - time()) / 60); echo $this->fun->json_encode(array('error' => -3, 'msg' => '操作过快,请 ' . $time . ' 分钟后在转发')); exit; } } $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']); //是否在转发的同时发表评论,0:否、1:评论给当前微博、2:评论给原微博、3:都评论,默认为0。 $ret = $c->repost($post['wbID'], $post['content'], 3); $friends = false; if ($post['friends']) { $friends = $this->friends_add($post['friends']); } //var_dump($friends);exit; //提交成功 if (isset($ret['error_code']) && $ret['error_code'] > 0) { echo $this->fun->json_encode(array('error' => -5, 'msg' => '转发不成功,请过会操作')); exit; } else { $array = array(); $array['W_U_id'] = $post['W_U_id']; $array['W_U_name'] = $post['W_U_name']; $array['W_U_info_id'] = $ret['idstr']; $array['W_U_info'] = $post['content']; $array['W_U_ip'] = $this->userIP; $array['time'] = time(); $array['is_friends'] = $friends ? 1 : 0; if ($tab = $this->db->select_to_2Array("select * from award order by taxis asc")) { $this->load_file('award', '', false); $award = new award(); $keys = $award->exec($tab); $array['aid'] = $keys['id']; $Ks = strtoupper($this->fun->rand_string(16)); $Ks = substr($Ks, 0, 4) . ' - ' . substr($Ks, 4, 4) . ' - ' . substr($Ks, 8, 4) . ' - ' . substr($Ks, 12, 4); $array['key'] = $Ks; $this->db->insert('award_wb', $array); $id = $this->db->get_id(); echo $this->fun->json_encode(array('error' => '0', 'info' => array('msg' => str_replace('{{key}}', $Ks, $keys['views']), 'shareID' => $id, 'share' => $keys['share']))); exit; } else { echo $this->fun->json_encode(array('error' => -4, 'msg' => '程序处理错误,请与管理员联系')); exit; } } }