<?php

include "config.php";
include "secureheader.php";
include "style.php";
include "Stripe/syek.php";

function createOrderNumber() {
    $chars = "abcdefghijkmnopqrstuvwxyz023456789";
    srand((double)microtime()*1000000);
    $i = 0;
    $pass = '' ;
    while ($i <= 7) {
        $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $pass = $pass . $tmp;
        $i++;
    }
    return $pass;
}

$ordernumber = createOrderNumber();

if($_POST['item'] == 1){
$sql = mysql_query("SELECT * FROM oto LIMIT 1");
$offer = mysql_fetch_array($sql);
}
if($_POST['item'] == 2){
$sql = mysql_query("SELECT * FROM lastoffer LIMIT 1");
$offer = mysql_fetch_array($sql);
}
if($_POST['item'] == 3){
$sql = mysql_query("SELECT * FROM offerpage LIMIT 1");
$offer = mysql_fetch_array($sql);
}
if($_POST['item'] == 4){
$sql = mysql_query("SELECT * FROM offerpage2 LIMIT 1");
$offer = mysql_fetch_array($sql);
}
?>

<div align="center"><table border="0" bgcolor="#FFFFFF"><tr><td align="center">

<?php

$currency="usd";
$userid=$_POST['userid'];

//make sure these 4 below match what the offers / otos are called on your site.

if($_POST['item'] == 1){
$name="$sitename One-Time Offer - $userid";
}
if($_POST['item'] == 2){
$name="$sitename Last Offer - $userid";
}
if($_POST['item'] == 3){
$name="$sitename Special Offer - $userid";
}
if($_POST['item'] == 4){
$name="$sitename Special Offer 2 - $userid";
}
$amount=$offer['price']*100;
$description= $_POST['userid'];
?>

<p align="center"><font size=5>Please Make Your Payment Of $<? echo $offer['price']; ?> For <?php echo $sitename; ?> Special Offer</font></p>

<? if($_POST['item'] == 1){ ?>
<center><form action="chargeoto.php" method="post">
<? } ?>
<? if($_POST['item'] == 2){ ?>
<center><form action="chargeoto.php" method="post">
<? } ?>
<? if($_POST['item'] == 3){ ?>
<center><form action="chargeoffer.php" method="post">
<? } ?>
<? if($_POST['item'] == 4){ ?>
<center><form action="chargeoffer.php" method="post">
<? } ?>
<input type="hidden" name="ip"     value="<?php echo $_SERVER['REMOTE_ADDR'];?>">
<input type="hidden" name="orderid"          value="<?php echo $ordernumber?>">
<input type="hidden" name="amount"      value="<?php echo $amount?>">
<input type="hidden" name="name"        value="<?php echo $name;?>">
<input type="hidden" name="currency"    value="<?php echo $currency;?>">
<input type="hidden" name="description" value="<?php echo $description;?>">

<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"

        data-key =           "<?php echo $public;?>"
        data-amount =        "<?php echo $amount;?>"
        data-name =          "<?php echo $name;?>"
        data-currency =      "<?php echo $currency;?>"
        data-description =   "<?php echo $description;?>"
        data-zip-code="true"
        data-image="http://highwaymails.com/images/125.png"
        data-locale="auto"
        >
</script>
</form></center>


	<?

    echo "</font></td></tr></table><br><br>";

include("securefooter.php");
mysql_close($dblink);
?>