link.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. $lid =1;
  3. $sid =1;
  4. if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
  5. $platform = false;
  6. $sid =2;
  7. }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
  8. $platform = true;
  9. $sid =1;
  10. }
  11. $str = $_SERVER['QUERY_STRING'];
  12. $sign = substr($str,0,1).substr($str,2,strlen($str));
  13. $sign = substr($sign,0,floor((strlen($sign)-16)/2)-1).substr($sign,floor((strlen($sign)-16)/2)+15,strlen($sign));
  14. $sign = base64_decode($sign);
  15. $sign = trim($sign,'&');
  16. $signArray = explode('&',$sign);
  17. $param = [];
  18. foreach ($signArray as $row){
  19. $temp = explode('=',$row,2);
  20. $param[$temp[0]] = $temp[1];
  21. }
  22. define('IN_WEB', true);
  23. include (dirname(__FILE__)."/../com.php");
  24. $shareKey = md5($param['uid'].date('YmdHis').mt_rand(0,100));
  25. oo::commonOprRedis('common')->setex(okeys::shareAddFriend($shareKey),$param['uid'],10*60);
  26. $sign = $sign."&shareKey=".$shareKey;
  27. if($platform){
  28. $appLink = 'superant://app.crazygod.com?'.$sign;
  29. $downLink = 'https://play.google.com/store/apps/details?id=com.superant.crazygod';
  30. }else{
  31. $appLink = 'superant://app.crazygod.com?'.$sign;
  32. $downLink = 'https://play.google.com/store/apps/details?id=com.superant.crazygod';
  33. }
  34. ?>
  35. <!Doctype html>
  36. <html xmlns=http://www.w3.org/1999/xhtml>
  37. <head>
  38. <meta http-equiv=Content-Type content="text/html;charset=utf-8">
  39. <head>
  40. <!-- <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>-->
  41. <title>CrazyGod</title>
  42. </head>
  43. <body>
  44. <script type="text/javascript">
  45. function applink(){
  46. window.location = '<?php echo $appLink ?>';
  47. console.log( '<?php echo $appLink ?>');
  48. var clickedAt = +new Date;
  49. setTimeout(function(){
  50. !window.document.webkitHidden && setTimeout(function(){
  51. if (+new Date - clickedAt < 2000){
  52. window.location = '<?php echo $downLink ?>';
  53. }
  54. }, 500);
  55. }, 500);
  56. }
  57. applink();
  58. </script>
  59. </body>
  60. </html>