tour.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. define('IN_T',true);
  3. require_once "./source/include/init.php";
  4. $act = Common::sfilter($_REQUEST['act']);
  5. $input = $Json->decode(file_get_contents("php://input"));
  6. $view_uuid = Common::sfilter($_REQUEST['view_uuid']);
  7. if (!empty($input)) {
  8. $act = $input['act'];
  9. $view_uuid = Common::sfilter($input['view_uuid']);
  10. }
  11. //jssdk Ajax
  12. if($act == 'jssdk'){
  13. require_once './source/include/cls_weixin_js.php';
  14. $cur_url = $_REQUEST['currentUrl'];
  15. $appid = $_lang['wx_config']['appid'];
  16. $appSecret = $_lang['wx_config']['appsecret'];
  17. $jssdk = new JSSDK($appid, $appSecret);
  18. $data = $jssdk->getSignPackage($cur_url);
  19. header('Content-Type: application/json;charset=utf-8');
  20. echo json_encode($data);
  21. exit;
  22. }
  23. //初始化全景项目
  24. else if ($act == 'initPano') {
  25. //js 获取配置的json
  26. $pro = $Db->query("SELECT w.* , p.* FROM ".$Base->table('worksmain')." w LEFT JOIN ".$Base->table('pano_config')." p ON w.pk_works_main = p.pk_works_main WHERE w.view_uuid = '$view_uuid' AND flag_publish = 1","Row");
  27. if (empty($pro)) {
  28. die("未查询到相关项目");
  29. }
  30. $pro = Transaction::decode_str2arr($pro);
  31. $hotspots = &$pro['hotspot'];
  32. foreach ($hotspots as &$v) {
  33. $imgtext = &$v['imgtext'];
  34. if (!empty($imgtext)) {
  35. foreach ($imgtext as &$v2) {
  36. if ($v2['imgtext_wordContent']) {
  37. $v2['imgtext_wordContent'] = base64_decode($v2['imgtext_wordContent']);
  38. }else if ($v2['wordContent']){
  39. $v2['imgtext_wordContent'] = base64_decode($v2['wordContent']);
  40. unset($v2['wordContent']);
  41. }
  42. }
  43. }
  44. }
  45. echo $Json->encode($pro);
  46. exit;
  47. }
  48. //点赞
  49. else if($act == "add_praise"){
  50. if (!empty($view_uuid)) {
  51. $Db->execSql("UPDATE ".$Base->table('worksmain')." SET praised_num = praised_num+1 WHERE view_uuid = '$view_uuid'");
  52. }
  53. exit;
  54. }
  55. //校验密码
  56. else if($act=="privacyAccess") {
  57. $re['status'] = 0;
  58. $pid = intval($_POST['pid']);
  59. $pwd = Common::sfilter($_POST['pwd']);
  60. $pro = $Db->query('SELECT privacy_password , view_uuid FROM '.$Base->table('worksmain').' WHERE pk_works_main = '.$pid,'Row');
  61. if (empty($pro)||$pwd!=$pro['privacy_password']) {
  62. $re['msg'] ="密码有误";
  63. }else{
  64. $_SESSION['privacyAccess'][$pro['view_uuid']] = 1;
  65. $re['status'] = 1;
  66. $re['url'] = '/tour/'.$pro['view_uuid'];
  67. }
  68. echo $Json->encode($re);
  69. exit;
  70. }
  71. else{
  72. $pro = $Db->query("SELECT w.*,u.nickname FROM ".$Base->table('worksmain')." w LEFT JOIN ".$Base->table('user')." u ON u.pk_user_main = w.pk_user_main WHERE w.view_uuid = '$view_uuid' AND w.flag_publish = 1 AND u.state=0 ","Row");
  73. if (empty($pro)) {
  74. die("未查询到相关项目");
  75. }
  76. if(!empty($pro['privacy_password'])&&empty($_SESSION['privacyAccess'][$pro['view_uuid']])){
  77. //设置了访问密码并且没有登录
  78. $tp->assign("pid",$pro['pk_works_main']);
  79. $tp->display($_lang['moban']."/privacy.tpl");
  80. exit;
  81. }
  82. require_once ROOT_PATH.'plugin/plugin_init_function.php';
  83. plugin_get_plugins("view");
  84. $Db->execSql("UPDATE ".$Base->table('worksmain')." SET browsing_num = browsing_num+1 WHERE view_uuid = '$view_uuid'");
  85. $tp->assign("pro",$pro);
  86. $tp->display($_lang['moban']."/tour.tpl");
  87. }
  88. ?>