publish.action.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | FANWE 直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------c
  9. class publishCModule extends baseCModule
  10. {
  11. //发布信息
  12. public function do_publish(){
  13. $root = array();
  14. $data = array();
  15. $m_config = load_auto_cache("m_config");//初始化手机端配置
  16. if(!$GLOBALS['user_info']){
  17. $root['error'] = "用户未登陆,请先登陆.";
  18. $root['status'] = 0;
  19. api_ajax_return($root);
  20. }
  21. $user_id = intval($GLOBALS['user_info']['id']);//用户ID
  22. if ($m_config['svideo_must_authentication']) {
  23. $sql = "select is_authentication from ".DB_PREFIX."user where id = ".$user_id;
  24. $is_authentication = $GLOBALS['db']->getOne($sql);
  25. if ($is_authentication != 2) {
  26. api_ajax_return(array("error"=>"请认证后再发布小视频 ", "status"=>0));
  27. }
  28. }
  29. $type_array = array(
  30. 'imagetext','video','weixin','goods','red_photo','photo'
  31. );
  32. $type = strim($_REQUEST['publish_type']);
  33. if(!in_array($type,$type_array)){
  34. $root = array(
  35. 'status'=>0,
  36. 'error'=>$type.'上传类型错误:'
  37. );
  38. api_ajax_return($root);
  39. }
  40. if($type=='photo'||$type=='goods'||$type=='weixin'){
  41. if(floatval($_REQUEST['price'])<=0){
  42. $root = array(
  43. 'status'=>0,
  44. 'error'=>'价格不能为空'
  45. );
  46. api_ajax_return($root);
  47. }
  48. }
  49. if($type == 'weixin'){
  50. $data['weixin_account'] =$_REQUEST['data'];
  51. $data['weixin_price'] =floatval($_REQUEST['price']);
  52. $data['weixin_account_time'] = to_date( get_gmtime());
  53. $GLOBALS['db']->autoExecute(DB_PREFIX."user", $data,'UPDATE','id = '.$user_id);
  54. }else{
  55. $data['content'] = strim($_REQUEST['content']);
  56. if(empty($data['content'])){
  57. $root = array(
  58. 'status'=>0,
  59. 'error'=>'内容不能为空:'
  60. );
  61. api_ajax_return($root);
  62. }
  63. if($type=='photo'||$type=='video'){
  64. if(empty($_REQUEST['photo_image'])){
  65. $root = array(
  66. 'status'=>0,
  67. 'error'=>'封面不能为空:'
  68. );
  69. api_ajax_return($root);
  70. }else{
  71. $data['photo_image'] = strim($_REQUEST['photo_image']);
  72. }
  73. }
  74. if($type=='video'){
  75. // $data['photo_image'] = strim($_REQUEST['image_url']);
  76. $video_url = strim($_REQUEST['video_url']);
  77. if(!$video_url){
  78. $root = array(
  79. 'status'=>0,
  80. 'error'=>'视频不能为空!'
  81. );
  82. api_ajax_return($root);
  83. }
  84. $data['data'] = $video_url;
  85. }else{
  86. $_REQUEST['data'] = json_decode($_REQUEST['data'],TRUE);
  87. if(is_array($_REQUEST['data'])){
  88. $image_array = $_REQUEST['data'];
  89. if($type=='goods'&&$image_array[0]['url']){
  90. $data['photo_image'] = $image_array[0]['url'];
  91. }
  92. if($type=='red_photo'){
  93. $_REQUEST['price'] = floatval(count( $image_array))*floatval($m_config['weibo_red_price']);
  94. if(floatval($_REQUEST['price'])<=0){
  95. $root = array(
  96. 'status'=>0,
  97. 'error'=>'红包价格不能小于0!'
  98. );
  99. api_ajax_return($root);
  100. }
  101. }
  102. $data['data'] = serialize($image_array);
  103. }else{
  104. $root = array(
  105. 'status'=>0,
  106. 'error'=>'图片结构错误!:'
  107. );
  108. api_ajax_return($root);
  109. }
  110. }
  111. $data['type'] = strim($type);
  112. $data['status'] =1 ;
  113. $data['price'] = floatval($_REQUEST['price']);
  114. $data['xpoint'] = strim($_REQUEST['xpoint']);
  115. $data['ypoint'] = strim($_REQUEST['ypoint']);
  116. $data['create_time'] = to_date(NOW_TIME);
  117. $data['user_id'] = $user_id;
  118. $data['is_audit'] = 1;
  119. //$ipinfo = get_ip_info();
  120. // $province = $ipinfo['province'];
  121. // $city = $ipinfo['city'];
  122. $data['province'] = strim($_REQUEST['province']);
  123. $data['city'] = strim($_REQUEST['city']);
  124. $data['address'] = strim($_REQUEST['address']);
  125. if($data['city'] =='不显示'||$data['address'] =='不显示'){
  126. $data['city'] = '';
  127. $data['address'] = '';
  128. $data['province'] = '';
  129. }
  130. $GLOBALS['db']->autoExecute(DB_PREFIX."weibo", $data,'INSERT');
  131. }
  132. if($GLOBALS['db']->affected_rows()){
  133. $root = array(
  134. 'status'=>1,
  135. 'error'=>'发布成功'
  136. );
  137. $weibo_count = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."weibo where user_id = ".$user_id);
  138. $re = $GLOBALS['db']->query("update ".DB_PREFIX."user set weibo_count = ".intval($weibo_count)." where id = ".$user_id);
  139. }else{
  140. $root = array(
  141. 'status'=>0,
  142. 'error'=>'上传失败'
  143. );
  144. }
  145. api_ajax_return($root);
  146. }
  147. //微信下架
  148. public function off_weixin(){
  149. if(!$GLOBALS['user_info']){
  150. $root['error'] = "用户未登陆,请先登陆.";
  151. $root['status'] = 2;
  152. api_ajax_return($root);
  153. }
  154. $user_id = intval($GLOBALS['user_info']['id']);//用户ID
  155. $data = array('weixin_account'=>'','weixin_price'=>0);
  156. $where = 'id = '.$user_id;
  157. $res = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  158. if($res){
  159. $root = array(
  160. 'status'=>1,
  161. 'error'=>'微信下架成功'
  162. );
  163. }else{
  164. $root = array(
  165. 'status'=>0,
  166. 'error'=>'微信下架失败'
  167. );
  168. }
  169. api_ajax_return($root);
  170. }
  171. //获取会员权限
  172. public function check_type(){
  173. if(!$GLOBALS['user_info']){
  174. $root['error'] = "用户未登陆,请先登陆.";
  175. $root['status'] = 0;
  176. api_ajax_return($root);
  177. }
  178. $user_info = $GLOBALS['db']->getRow("select is_authentication,weibo_count from ".DB_PREFIX."user where id = ".$GLOBALS['user_info']['id']);
  179. $root = array(
  180. 'status'=>1,
  181. 'error'=>'',
  182. 'info'=>$user_info
  183. );
  184. api_ajax_return($root);
  185. }
  186. }
  187. ?>