function buyDeckvStyle($deckSN, $vStyle, $userId, $sMethod) { //possibly change $deckSN to receive $deckId, more proper? if (getOwnershipDeckVstyle($deckSN, $vStyle, $userId) == FALSE) { if (getMoneyBalances($vStyle, $sMethod, $userId) == 'sufficient') { setOwnershipvStyle($deckSN, $vStyle, $userId); setMoneyBalances($vStyle, $sMethod, $userId); incrStat('ttlpvstyl', $userId); return "success"; } else { if (setMoneyBalances($vStyle, $sMethod, $userId) != 'sufficient') { return "Insufficient funds"; } } } else { if (getOwnershipDeckVstyle($deckSN, $vStyle, $userId) == TRUE) { return "already owned"; } } }
$sql = sprintf("INSERT INTO users (username, email, password, gender, country, ip, jlpt, signup, last_login, notescheck) VALUES('%s','%s','%s','%s','%s','%s','%s',now(),now(),now())", $u, $e, $pHashed, $g, $c, $ip, $j); $query = mysql_query($sql) or die(mysql_error()); $userID = mysql_insert_id($conn); require_once 'stats.php'; setStat('atk', $userID, '5'); setStat('def', $userID, '2'); setStat('conf', $userID, '0'); setStat('maxconf', $userID, '150'); setStat('mag', $userID, '5'); setStat('lv', $userID, '1'); //Set Money setStat('gold', $userID, '0'); setStat('dmd', $userID, '0'); //Set Initial Deck setOwnershipDeck('hirkat', $userID); setOwnershipvStyle('hirkat', 'audioR', $userID); setOwnershipDeck('minna', $userID); //sets ownership of deck(adds this deck to users' user_decks); initializesdeck_lv, deck_progress, deck_prog_max setStat('ttldks', $userID, '2'); setSkill('cvset', $userID, 'hirkat'); setSkill('vstyle', $userID, 'kanjiRE'); setAchiev('submit_jlpt', $userID, '1'); //Could create a folder for this user at this point. Folder would hold their files //Email the suer their activation link $to = "{$e}"; $from = "*****@*****.**"; //create this $subject = 'Free JP decks for ' . $u . ' coming right up! One step left.'; $message = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>jpvocab.com Email Confirmation</title></head><body style="margin:0px; font-family:Tahoma, Geneva, sans-serif;"><div style="padding:10px; background: #2c3e50; font-size:24px; color:#CCC;"><a href="http://www.jpvocab.com" style="color:white;"><!--<img src="http://www.jpvocab.com/img/logo.png" width="36" height="30" alt="jpvocab.com" style="border:none; float:left;"></a>-->jpvocab.com Account Activation</div><div style="padding:24px; font-size:17px;">Welcome ' . $u . '!<p>I am so grateful that you decided to check out jpvocab! My name is Ben and I am a Japanese learner just like you. I went on a year exchange to Japan in 2012-2013 and it changed my life. Now I am working towards helping others learn Japanese even faster than I did.</p><p>So, free vocab decks? All you need to do is click the link to confirm your email and they\'ll be transmorgified straight to your account (Calvin & Hobbes reference anyone?).</p><p>Sincerely,</p><p>Ben<br />jpvocab.com</p><p>Click the link to activate your account.</p><p><a href="http://www.jpvocab.com/activation.php?id=' . $userID . '&u=' . $u . '&e=' . $e . '&p=' . $pHashed . '">Click to activate</a><br /><br />Your login info:<br /><b>Username:</b> ' . $u . '<br /><b>Email:</b> ' . $e . '</div><br /><a href="https://twitter.com/jpvocab_ben" target="_blank"><img src="http://static.viewbook.com/images/social_icons/twitter_32.png"/></a></p></body></html>'; $headers = "From: {$from}\n";
$userCurrencyFunds = getStat('Diamonds', getUserID($_SESSION['username'])); } $balance = $userCurrencyFunds - $price; if ($owned == true) { $hTitle = "Oops..."; $failBuy = "You already own this deck."; $bought = false; } elseif ($balance < 0) { $lhsIcon = "<img src='../img/fail.jpg'>"; $hTitle = "Uh oh"; $failBuy = "<b>Insufficient funds. It seems you need more funds.</b><p>{$title} could be yours instantly if you get Diamonds from <a href='../diamond.php'>here</a>.</p>"; $bought = false; } elseif ($balance >= 0 and $owned == false) { buyDeck(getDeckInfoFromId($_POST['deckId'], 'short_name'), $userId, $currency); setOwnershipvStyle(getDeckInfoFromId($_POST['deckId'], 'short_name'), 'kanjiE', $userId); setOwnershipvStyle(getDeckInfoFromId($_POST['deckId'], 'short_name'), 'kanjiH', $userId); $bought = true; } else { $lhsIcon = ""; } //Assign Values for Results Template $msg = $failBuy; $linkLHS = ""; $linkRHS = ""; if ($bought == true) { $hTitle = "Congratulations!"; $lhsIcon = "<i class='fa check-circle-o fa-x5 text-success text-center' ></i>"; $msg = "You've purchased <b>{$title}</b> Japanese flashcard vocabulary deck. Thank you and Enjoy!"; $linkRHS = '<a href="#2" class="btn btn-link btn-block" onClick="sendToQuiz(' . $_POST['deckId'] . ',"kanjiRE","null")" role="button">Click to use it now <i class="fa fa-hand-point-o"></i></a>'; } ?>