video.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. //添加视频项目
  3. if(!defined('IN_T')){
  4. die('hacking attempt');
  5. }
  6. $act = Common::sfilter($_REQUEST['act']);
  7. $input=null;
  8. if (empty($act)) {
  9. $input = $Json->decode(file_get_contents("php://input"));
  10. if (!empty($input)) {
  11. $act = $input['act'];
  12. }
  13. }
  14. //添加视频
  15. if($act == "doAdd"){
  16. $re['flag'] = 0;
  17. $params = $Json->decode(stripslashes($_REQUEST['params']));
  18. $data['vname'] = Common::sfilter($params['vname']);
  19. $videos = $params['videos'];
  20. $tags = $params['video_tags'];
  21. if (empty($data['vname'])||mb_strlen($data['vname'])>30) {
  22. $re['msg'] = "请输入1到30个字符的项目名称";
  23. }else if(empty($tags)||sizeof($tags)>3){
  24. $re['msg'] = "请选择1到3个标签";
  25. }else if(empty($videos)){
  26. $re['msg'] = "视频不能为空";
  27. }else{
  28. $data['profile'] = Common::sfilter($params['profile']);
  29. $data['flag_publish'] = 1;
  30. $data['state'] = 0;
  31. $data['create_time'] =date("Y-m-d H:i:s",Common::gmtime());
  32. $data['pk_user_main'] = $user['pk_user_main'];
  33. $size = 0 ;
  34. require_once __DIR__.'/../../source/krpano/cls_common_operation.php';
  35. foreach ($videos as &$v) {
  36. $v['thumb_path'] = KrOperation::get_video_thumb($v['location'],3);
  37. $size = intval($v['size']/1024)+$size;
  38. }
  39. $data['thumb_path'] = urldecode($videos[0]['thumb_path']);
  40. $data['videos'] = $Json->encode_unescaped_unicode($videos);
  41. $data['size'] = $size;
  42. $data['cdn_host'] = $_lang['cdn_host'];
  43. $vid = $Db->insert($Base->table("video"),$data);
  44. foreach ($tags as $tid) {
  45. if ($Db->getCount($Base->table("tag"),"id",array("id"=>$tid,"type"=>2))) {
  46. $Db->insert($Base->table("tag_video"),array("tag_id"=>$tid,"video_id"=>$vid));
  47. }
  48. }
  49. $re['flag'] = 1;
  50. }
  51. echo $Json->encode($re,JSON_NUMERIC_CHECK);
  52. exit;
  53. }
  54. ?>