Example #1
0
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    $result = curl_exec($curl);
    $result = json_decode($result, true);
    $result_info = curl_getinfo($curl);
    $result_status = $result_info['http_code'];
    $campaign_id = $result['id'];
    $out = ">\tcampaign: {$campaign_id}\n>\ttitle: {$result['title']}\n>\treport: http://{$dc}.admin.mailchimp.com/reports/summary?id={$result['web_id']}\n>\tsend: https://{$dc}.admin.mailchimp.com/campaigns/wizard/confirm?id={$result['web_id']}\n\n";
    echo $out;
    return $campaign_id;
}
//-----------------------------------------------------------------
$emails = getList($list_id);
if ($emails) {
    if ($create_campaign) {
        $campaign_id = createCampaign();
    }
    $order_id = generateOrderId();
    $inc = 0;
    foreach ($emails as $email_address => $email_id) {
        $orders[] = new Order($email_address, $email_id, $campaign_id, $store_id, $store_name, $products, $order_id + $inc);
        $inc++;
    }
    addOrders($orders);
    if ($inc > 50) {
        echo $out;
    }
}
$end_time = date('H:i:s', time());
$elapsed_time = abs(strtotime($end_time) - strtotime($start_time));
echo "{$elapsed_time}s elapsed\n\n";
<?php

require_once 'db_products.php';
if (!empty($_POST['fname']) || !empty($_POST['lname']) || !empty($_POST['address']) || !empty($_POST['phone']) || !empty($_POST['email'])) {
    if (validate()) {
        addOrders();
        header('Location: thankyou.html');
    }
}
function validate()
{
    if (!validateAlpha($_POST['fname'])) {
        echo '<script type="text/javascript">alert("Not a valid firstname!")</script>';
        return false;
    }
    if (!validateAlpha($_POST['lname'])) {
        echo '<script type="text/javascript">alert("Not a valid lastname!")</script>';
        return false;
    }
    if (!validateAlphaNumeric($_POST['address'])) {
        echo '<script type="text/javascript">alert("Not a valid address!")</script>';
        return false;
    }
    if (!validatePhone($_POST['phone'])) {
        echo '<script type="text/javascript">alert("Not a valid phone number, use ###-###-####!")</script>';
        return false;
    }
    if (!validateEmail($_POST['email'])) {
        echo '<script type="text/javascript">alert("Not a valid email!")</script>';
        return false;
    }