Jump to content

Vermino

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Vermino's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. found it finally.. future reference for anyone else =) coupons.php mysql_query("UPDATE `coupons` SET `points` = `points` - 1 WHERE `code`='{$protectie['code']}'");
  2. Ok, I laughed at how retarded I was trying to "experiment" on this code to be able to enter a coupon, how much receives, and how many uses before it expires. The main problem is when a member uses a coupon - I don't know how to remove a 'points' from mysql till it hits 0 then deactivates coupons.php <?php include('header.php'); foreach($_POST as $key => $value) { $protectie[$key] = filter($value); } if(isset($_POST['submit'])) { $ext1 = mysql_query("SELECT * FROM `coupons` WHERE `code`='{$protectie['code']}' AND `used`='0'"); $ext = mysql_fetch_object($ext1); if($ext->id != ""){ mysql_query("UPDATE `users` SET `coins`=`coins`+'{$ext->coins}' WHERE `id`='{$data->id}'"); mysql_query("UPDATE `coupons` SET `points`='-1' WHERE `code`='{$protectie['code']}'"); $mesaj = "<div class=\"msg\"><div class=\"msg success\">Success! You have received <b>{$ext->coins} coins</b>!</div></div>"; }else{ $mesaj = "<div class=\"msg\"><div class=\"error\">Error! This coupon code doesn't exist or is already used!</div></div>"; }}?> coupons-dashboard.php <?php $del = $_GET['del']; $del1 = mysql_fetch_object(mysql_query("SELECT * FROM `coupons` WHERE `id`='{$del}'")); if($del1->id != ""){mysql_query("DELETE FROM `coupons` WHERE `id`='{$del}'");} $users = mysql_num_rows(mysql_query("SELECT * FROM `coupons`")); //if points go below 1, it deactivates $active = mysql_num_rows(mysql_query("SELECT * FROM `coupons` WHERE `points`='+0'")); $banned = mysql_num_rows(mysql_query("SELECT * FROM `coupons` WHERE `points`='0'")); ?> addcoupon-dashboard.php <?php $n1 = rand(1000, 9999); $n2 = rand(1000, 9999); $n3 = rand(1000, 9999); $n4 = rand(1000, 9999); $code = $n1."-".$n2."-".$n3."-".$n4; if(isset($_POST['add'])){ mysql_query("INSERT INTO `coupons`(code, coins, points) values('{$_POST['code']}', '{$_POST['coins']}', '{$_POST['points']}')"); $message = "<div class=\"message success\"><h3>Success!</h3><p>Your coupon code is: ".$_POST['code']."</p></div>"; } $users = mysql_num_rows(mysql_query("SELECT * FROM `coupons`")); //$active = mysql_num_rows(mysql_query("SELECT * FROM `coupons` WHERE `used`='0'")); //$banned = mysql_num_rows(mysql_query("SELECT * FROM `coupons` WHERE `used`='1'")); //if points go below 1 - it becomes banned $active = mysql_num_rows(mysql_query("SELECT * FROM `coupons` WHERE `points`='+0'")); $banned = mysql_num_rows(mysql_query("SELECT * FROM `coupons` WHERE `points`='0'")); ?> also i have to say, SERIOUSLY the CAPTCHA? (john, george, paul, and.....??) im not a Beatles fan! haha
  3. [this is in PHPmyadmin] So just saw I've been getting an instant log-out command when i click on one specific database table saying i've been inactive for more than 1800 seconds, i can relog in and it will send me to that database table - but if i ever click on that specific table, it seems to think i've been inactive.. I'm kind-of confused where i should start debugging this issue. I have imported an original .sql to it and didnt fix the problem, so it's probably my config.php??
  4. I think I'm seriously missing some small thing to get this code to just auto refresh after (x) seconds or after video completes fully. This is for users to watch from a database of other users that submitted url's - right now all I could put a skip button to auto-refresh. If anyone can help or at least point me into the right direction on some snippets I can kind-of work off of. here is the snippet (kind-of a big snippet) <? include('header.php'); foreach($_GET as $key => $value) { $secure[$key] = filter($value); } if($_GET['a'] == "skip"){ $sit1 = mysql_query("SELECT * FROM `youtube` WHERE `id`='{$secure['id']}'"); $sit = mysql_num_rows($sit1); if($sit > 0){ mysql_query("INSERT INTO `viewed` (user_id, site_id) VALUES('{$data->id}','{$secure['id']}')"); }} ?> <div class="block medium right"> <div class="top"><?if(isset($data->login)) {?> <h1>Earn Coins - Youtube</h1> </div> <div class="content"> <? // fetches all "unplayed" youtube videos for this user // $site2 = mysql_query("SELECT * FROM `youtube` WHERE (`active` = '0' AND `points` >= `cpc`) AND `id` NOT IN (SELECT `site_id` FROM `viewed` WHERE `user_id`='{$data->id}') ORDER BY `cpc` DESC LIMIT 0, 1"); $site = mysql_fetch_object($site2); $ext = mysql_num_rows($site2); if($ext > 0){ ?> <script src="js/swfobject.js"></script> <script type="text/javascript"> var playing = false; var fullyPlayed = false; var interval = ''; var played = 0; var length = 30; function YouTubePlaying(){ played += 0.1; roundedPlayed = Math.ceil(played); document.getElementById("played").innerHTML = Math.min(roundedPlayed,length); if (roundedPlayed == length){ if (fullyPlayed == false){ YouTubePlayed(); fullyPlayed = true; } } } function YouTubePlayed(){ var response = '<? echo $site->youtube;?>'; var username = "<? echo $data->id;?>"; $.post("ytreceive.php", { data: response + "---" + username}, function(result){ if(!isNaN(result)) { var curr_val = $('#points').text(); var new_val = parseInt(curr_val)+parseInt(result); $('#points').text(new_val); } } ); document.getElementById(response).style.visibility = "visible"; } function onYouTubePlayerReady(playerId){ ytplayer = document.getElementById("myytplayer"); ytplayer.addEventListener("onStateChange", "onYouTubePlayerStateChange"); } function onYouTubePlayerStateChange(newState){ if (newState == 1){ playing = true; interval = window.setInterval('YouTubePlaying()',100); }else{ if (playing) window.clearInterval(interval); playing = false; } } function refreshpage() { window.location.reload(); } </script> <center> <div style="width: 520px; padding: 10px;"> <h3>"<? echo $site->title;?>"</h3> View this video for 30 seconds and after that you will receive <? echo $site->cpc;?> coins<br/><br/> <div id="ytPlayer">You need Flash player 8+ and JavaScript enabled to view this video.</div> <script type="text/javascript"> var params = { allowScriptAccess: "always" }; var atts = { id: "myytplayer" }; swfobject.embedSWF("http://www.youtube.com/v/<? echo $site->youtube;?>?enablejsapi=1&playerapiid=ytplayer&autoplay=1", "ytPlayer", "425", "356", "8", null, null, params, atts); </script> <br/> <br />Must play for <span id="played">0</span>/10 seconds (<a href="youtube.php?a=skip&id=<? echo $site->id;?>" style="color:blue">Skip</a>) <div id="<? echo $site->youtube;?>" style="visibility:hidden"><a href="javascript:refreshpage()">View Next Video</a></div> </div></center> <?}else{?> <div class="msg"> <div class="error">Sorry, there are no more coins to be earned at the moment. Please try again later.</div> <div class="info"><a href="buy.php"><b>Feel like you need more coins? You can purchase them now!</b></a></div></div> <?}}else{?><script>document.location.href='index.php'</script><?}?> </div> </div> <?include('footer.php');?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.