Advertisement
VujkeMod

Untitled

May 21st, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. <?
  2. include('header.php');
  3. $id = $db->EscapeString($_GET['id']);
  4.  
  5. if($_GET['a'] == "skip"){
  6. $sql = $db->Query("SELECT id FROM `youtube` WHERE `id`='".$id."'");
  7. $sit = $db->GetNumRows($sql);
  8. if($sit > 0){
  9. $db->Query("INSERT INTO `viewed` (user_id, site_id) VALUES('".$data['id']."','".$id."')");
  10. }}
  11. ?>
  12. <div class="block medium right">
  13. <div class="top">
  14. <h1>Earn Coins - Youtube</h1>
  15. </div>
  16. <div class="content">
  17. <?
  18. $sql = $db->Query("SELECT id,youtube,title,cpc FROM `youtube` WHERE (`active` = '0' AND `points` >= `cpc`) AND (`id` NOT IN (SELECT `site_id` FROM `viewed` WHERE `user_id`='".$data['id']."') AND `user`!='".$data['id']."') ORDER BY `cpc` DESC LIMIT 0, 1");
  19. $site = $db->FetchArray($sql);
  20. if($site['id'] > 0){
  21. ?>
  22. <script src="js/swfobject.js"></script>
  23. <script type="text/javascript">
  24. var playing = false;
  25. var fullyPlayed = false;
  26. var interval = '';
  27. var played = 0;
  28. var length = 15;
  29.  
  30. function YouTubePlaying(){
  31. played += 0.1;
  32. roundedPlayed = Math.ceil(played);
  33. document.getElementById("played").innerHTML = Math.min(roundedPlayed,length);
  34. if (roundedPlayed == length){
  35. if (fullyPlayed == false){
  36. YouTubePlayed();
  37. fullyPlayed = true;
  38. }
  39. }
  40. }
  41. function YouTubePlayed(){
  42. var response = '<?=$site['youtube']?>';
  43. $.post("pages/ytreceive.php",
  44. { data: response},
  45. function(result){
  46. if(!isNaN(result)) {
  47. var curr_val = $('#points').text();
  48. var new_val = parseInt(curr_val)+parseInt(result);
  49. $('#points').text(new_val);
  50. }
  51. }
  52. );
  53. document.getElementById(response).style.visibility = "visible";
  54. }
  55.  
  56. function onYouTubePlayerReady(playerId){
  57. ytplayer = document.getElementById("myytplayer");
  58. ytplayer.addEventListener("onStateChange", "onYouTubePlayerStateChange");
  59. }
  60. function onYouTubePlayerStateChange(newState){
  61. if (newState == 1){
  62. playing = true;
  63. interval = window.setInterval('YouTubePlaying()',100);
  64. }else{
  65. if (playing) window.clearInterval(interval);
  66. playing = false;
  67. }
  68. }
  69. function refreshpage()
  70. {
  71. window.location.reload();
  72. }
  73. </script>
  74. <center>
  75. <div style="width: 520px; padding: 10px;">
  76. <h3>"<?=$site['title']?>"</h3>
  77. View this video for 15 seconds and after that you will receive <b><?=$site['cpc']?> coins</b><br/><br/>
  78. <div id="ytPlayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>
  79. <script type="text/javascript">
  80. var params = { allowScriptAccess: "always" };
  81. var atts = { id: "myytplayer" };
  82. swfobject.embedSWF("http://www.youtube.com/v/<?=$site['youtube']?>?enablejsapi=1&playerapiid=ytplayer&autoplay=1", "ytPlayer", "425", "356", "8", null, null, params, atts);
  83. </script>
  84. <br/>
  85.  
  86. <br />Must play for <span id="played">0</span>/15 seconds (<a href="youtube.php?a=skip&id=<?=$site['id']?>" style="color:blue">Skip</a>)
  87. <div id="<?=$site['youtube']?>" style="visibility:hidden"><a href="javascript:refreshpage()">View Next Video</a></div>
  88. </div></center>
  89. <?}else{?>
  90. <div class="msg">
  91. <div class="error">Sorry, there are no more coins to be earned at the moment. Please try again later.</div>
  92. <div class="info"><a href="buy.php"><b>Feel like you need more coins? You can purchase them now!</b></a></div></div>
  93. <?}?>
  94. </div>
  95. </div>
  96. <?include('footer.php');?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement