示例#1
0
    default:
        //no error
        $output .= '
          <h1>' . lang("ultra", "title") . '</h1>';
}
unset($err);
$output .= '
        </div>';
// this is a pre-filter because mail from outside mail.php is priority
if ($_GET["moneyresult"]) {
    showresults();
}
$action = isset($_GET["action"]) ? $_GET["action"] : NULL;
switch ($action) {
    case "purchase":
        purchase();
        break;
    case "selected_quantity":
        approve();
        break;
    case "selected_item":
        select_quantity();
        break;
    case "selected_char":
        select_item();
        break;
    default:
        show_list();
}
unset($action);
unset($action_permission);
示例#2
0
//require controller to handle all the work
require_once "../src/controller.php";
//define a few regex
$pattern = '/^\\/test.(mp3|jpg|mp4)\\/?$/';
$pattern2 = '/^\\/show\\/s\\/test.(mp3|jpg|mp4)\\/?$/';
$pattern3 = '/^\\/show\\/u\\/test.(mp3|jpg|mp4)\\/?$/';
//get request path
$path = $_SERVER['REQUEST_URI'];
//get request method
$method = $_SERVER['REQUEST_METHOD'];
//ROUTING LOGIC
//route to proper controller function
if (preg_match($pattern, $path)) {
    if ($method == "POST") {
        unlock($path);
    } else {
        if ($method == "GET") {
            purchase($path);
        }
    }
} else {
    if (preg_match($pattern2, $path)) {
        getScrambledMedia($path);
    } else {
        if (preg_match($pattern3, $path)) {
            getUnscrambledMedia($path);
        } else {
            require "index.html";
        }
    }
}
示例#3
0
function confirm_email($user)
{
    $db = db_connect();
    $confirm_command = "SELECT username,user_email FROM accounts WHERE username ='******';";
    $confirm_result = $db->query($confirm_command);
    $confirm_data = $confirm_result->fetch_object();
    $name = $confirm_data->username;
    $email = $confirm_data->user_email;
    $message = "<html><head></head><body><br><br><br><br><br><br><br>" . $name . ", thank you for buying this stuff.<br>Your Purchases:<table><tbody><tr><th>Item</th><th>Quantity</th><th>Price</th></tr>";
    $to = $email;
    $email_subject = $user . "-- Your Purchase from Crystals, Charms, and Coffee " . date("F d, Y h:i a");
    $total = 0;
    // Iterates through the user's items and retrieves the pertinent info from the dB, then it builds the table html.
    foreach ($_SESSION['out_cart'] as $key => $value) {
        $confirm_email_command = "SELECT * FROM products WHERE productId=" . $_SESSION['out_cart'][$key]['productId'] . ";";
        $confirm_email_results = $db->query($confirm_email_command);
        $confirm_email_data = $confirm_email_results->fetch_object();
        $message .= '<tr><td class="checkout_name">' . $confirm_email_data->name . '</td><td class="checkout_quantity">' . $_SESSION['out_cart'][$key]['quantity'] . '</td><td class="checkout_price">$' . $confirm_email_data->price * intval($_SESSION['out_cart'][$key]['quantity']) . '.00</td></tr>';
        $total += $confirm_email_data->price * intval($_SESSION['out_cart'][$key]['quantity']);
    }
    $message .= '</tbody></table><div class="total_price"> Your Total: $' . number_format($total, 2) . '</div></body></html>';
    $headers = "From: peter.twickler@gmail.com" . "\r\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $mail = mail($to, $email_subject, $message, $headers);
    // If the order went through and the email worked, display the confirmation message and unset the cart.
    if ($mail == true) {
        $thanks = "Thank you for your purchase, " . $user . ". An email with your purchase receipt has been sent to your email address.<br><br>\n                    Your friends at Crystals, Charms, and Coffees";
        purchase();
    } elseif ($mail != true) {
        $thanks = "I'm sorry, something went wrong and we could not send your receipt to the email address on file.";
    }
    $db->close();
    return $thanks;
}