예제 #1
0
<p>
	<a href="../home/home.html">Back To Home</a>
</p>

<?php 
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    # collect input data
    $address = $_POST['address'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    if (!empty($address) && !empty($phone) && !empty($email)) {
        $address = prepareInput($address);
        $email = prepareInput($email);
        $phone = prepareInput($phone);
        if (checkAddress($address) && checkPhone($phone) && checkEmail($email)) {
            error_reporting(E_ALL);
            $db_host = "localhost";
            $db_user = "******";
            $db_pass = "******";
            $db_name = "mysql";
            $con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
            // Check connection
            if (mysqli_connect_errno()) {
                echo "Failed to connect to MySQL: " . mysqli_connect_error();
            }
            $sql = "select * from members where Email='{$email}'";
            $result = $con->query($sql);
            if (!$result) {
                die('Error: ' . mysqli_error($con));
            }
예제 #2
0
     goBack('Billing Address: City');
     return false;
 }
 if (!(isset($_POST['billing_state']) && checkState($_POST['billing_state']))) {
     goBack('Billing Address: State');
     return false;
 }
 if (!(isset($_POST['billing_zip']) && checkZip($_POST['billing_zip']))) {
     goBack('Billing Address: Zip');
     return false;
 }
 if (!(isset($_POST['email']) && checkEmail($_POST['email'], 30))) {
     goBack('Email');
     return false;
 }
 if (!(isset($_POST['night_phone_a']) && isset($_POST['night_phone_b']) && isset($_POST['night_phone_c']) && checkPhone($_POST['night_phone_a'] . $_POST['night_phone_b'] . $_POST['night_phone_c']))) {
     goBack('Phone');
     return false;
 }
 if (!(isset($_POST['first_name']) && checkName($_POST['first_name'], 20))) {
     goBack('Shipping Address: First Name');
     return false;
 }
 if (!(isset($_POST['last_name']) && checkName($_POST['last_name'], 20))) {
     goBack('Shipping Address: Last Name');
     return false;
 }
 if (!(isset($_POST['address1']) && checkStreetAddress($_POST['address1'], 20))) {
     goBack('Shipping Address: Address 1');
     return false;
 }
예제 #3
0
 function eshop_checkout($espost)
 {
     $espost = stripslashes_deep($espost);
     global $blog_id, $eshopoptions, $wpdb;
     $contineproceed = '1';
     //cache
     eshop_cache();
     $echoit = '';
     include_once ABSPATH . 'wp-includes/wp-db.php';
     include_once WP_PLUGIN_DIR . "/eshop/cart-functions.php";
     if (isset($espost['eshop_payment'])) {
         $_SESSION['eshop_payment' . $blog_id] = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $espost['eshop_payment']);
     }
     if (!isset($_SESSION['eshop_payment' . $blog_id])) {
         $paymentmethod = 'paypal';
     } else {
         $paymentmethod = $_SESSION['eshop_payment' . $blog_id];
     }
     //left over from previous script, leaving in just in case another payment method is used.
     $chkerror = 0;
     $numberofproducts = 0;
     //filter for plugin merchant gateways
     $eshopmgincpath = apply_filters('eshop_mg_inc_path', WP_PLUGIN_DIR . '/eshop/' . $paymentmethod . '.php', $paymentmethod);
     // if everything went ok do the following, hopefully the rest won't happen!
     if (isset($_GET['eshopaction'])) {
         if ($_GET['eshopaction'] == 'success') {
             include_once $eshopmgincpath;
         }
     }
     //filter for plugin merchant gateways
     $eshopmgincidxpath = apply_filters('eshop_mg_inc_idx_path', WP_PLUGIN_DIR . '/eshop/' . $paymentmethod . '/index.php', $paymentmethod);
     if (file_exists($eshopmgincidxpath)) {
         include_once $eshopmgincidxpath;
     }
     if (isset($_SESSION['eshopcart' . $blog_id])) {
         $shopcart = $_SESSION['eshopcart' . $blog_id];
         $numberofproducts = sizeof($_SESSION['eshopcart' . $blog_id]);
         /* unused code?
         			$productsandqty='';
         			while (list ($product, $amount) = each ($_SESSION['eshopcart'.$blog_id])){
         				$productsandqty.=" $product-$amount";
         				$productsandqty=trim($productsandqty);
         			}
         			*/
         $keys = array_keys($_SESSION['eshopcart' . $blog_id]);
         $productidkeys = implode(",", $keys);
         $productidkeys = trim($productidkeys);
         //reqd for shipping - finds the correct state for working out shipping, and set things up for later usage.
         if (isset($espost['ship_name'])) {
             if ($espost['ship_name'] != '' || $espost['ship_address'] != '' || $espost['ship_city'] != '' || $espost['ship_postcode'] != '' || $espost['ship_company'] != '' || $espost['ship_phone'] != '' || $espost['ship_country'] != '' || $espost['ship_state'] != '') {
                 if ($espost['ship_name'] == '') {
                     $espost['ship_name'] = $espost['first_name'] . " " . $espost['last_name'];
                 }
                 if ($espost['ship_company'] == '') {
                     $espost['ship_company'] = $espost['company'];
                 }
                 if ($espost['ship_phone'] == '') {
                     $espost['ship_phone'] = $espost['phone'];
                 }
                 if ($espost['ship_address'] == '') {
                     $espost['ship_address'] = $espost['address1'];
                     if ($espost['address2'] != '') {
                         $espost['ship_address'] .= ", " . $espost['address2'];
                     }
                 }
                 if ($espost['ship_city'] == '') {
                     $espost['ship_city'] = $espost['city'];
                 }
                 if ($espost['ship_postcode'] == '') {
                     $espost['ship_postcode'] = $espost['zip'];
                 }
                 if ($espost['ship_country'] == '') {
                     $espost['ship_country'] = $espost['country'];
                 }
                 if ($espost['ship_state'] == '') {
                     $espost['ship_state'] = $espost['state'];
                 }
                 if ($espost['ship_altstate'] == '') {
                     $espost['ship_altstate'] = $espost['altstate'];
                 }
             } else {
                 $espost['ship_name'] = $espost['first_name'] . " " . $espost['last_name'];
                 $espost['ship_company'] = $espost['company'];
                 $espost['ship_phone'] = $espost['phone'];
                 if ($espost['ship_address'] == '') {
                     $espost['ship_address'] = $espost['address1'];
                     if ($espost['address2'] != '') {
                         $espost['ship_address'] .= ", " . $espost['address2'];
                     }
                 }
                 $espost['ship_city'] = $espost['city'];
                 $espost['ship_postcode'] = $espost['zip'];
                 $espost['ship_country'] = $espost['country'];
                 $espost['ship_state'] = $espost['state'];
                 $espost['ship_altstate'] = $espost['altstate'];
             }
             $tablecountries = $wpdb->prefix . 'eshop_countries';
             $tablestates = $wpdb->prefix . 'eshop_states';
             $shippingzone = $eshopoptions['shipping_zone'];
             if (isset($espost['eshop_shiptype']) && $espost['eshop_shiptype'] != '0') {
                 $sztype = $espost['eshop_shiptype'];
                 $shippingzone = $wpdb->get_var("SELECT area FROM " . $wpdb->prefix . "eshop_rates WHERE rate_type='ship_weight' && class='{$sztype}' LIMIT 1");
             }
             $pzoneid = '';
             //$eshopoptions['unknown_state'];
             if ($shippingzone == 'country') {
                 if (isset($espost['ship_country']) && $espost['ship_country'] != '') {
                     $pzoneid = $espost['ship_country'];
                 } elseif (isset($espost['country']) && $espost['country'] != '') {
                     $pzoneid = $espost['country'];
                 }
                 $pzone = $wpdb->get_var("SELECT zone FROM {$tablecountries} WHERE code='{$pzoneid}' LIMIT 1");
             } else {
                 if (isset($espost['state']) && $espost['state'] != '') {
                     $pzoneid = $espost['state'];
                 }
                 if (isset($espost['ship_state']) && $espost['ship_state'] != '') {
                     $pzoneid = $espost['ship_state'];
                 }
                 $pzone = $wpdb->get_var("SELECT zone FROM {$tablestates} WHERE id='{$pzoneid}' LIMIT 1");
                 if (isset($espost['altstate']) && $espost['altstate'] != '') {
                     $pzone = $eshopoptions['unknown_state'];
                 }
                 if (isset($espost['ship_altstate']) && $espost['ship_altstate'] != '') {
                     $pzone = $eshopoptions['unknown_state'];
                 }
             }
             $_SESSION['shiptocountry' . $blog_id] = $eshopoptions['location'];
             if (isset($espost['ship_country']) && $espost['ship_country'] != '') {
                 $_SESSION['shiptocountry' . $blog_id] = $espost['ship_country'];
             } elseif (isset($espost['country']) && $espost['country'] != '') {
                 $_SESSION['shiptocountry' . $blog_id] = $espost['country'];
             }
         } else {
             $pzoneid = '';
             //$eshopoptions['unknown_state'];
             $tablecountries = $wpdb->prefix . 'eshop_countries';
             $tablestates = $wpdb->prefix . 'eshop_states';
             $shippingzone = $eshopoptions['shipping_zone'];
             if (isset($espost['eshop_shiptype'])) {
                 $sztype = $espost['eshop_shiptype'];
                 $shippingzone = $wpdb->get_var("SELECT area FROM " . $wpdb->prefix . "eshop_rates WHERE rate_type='ship_weight' && class='{$sztype}' LIMIT 1");
             }
             if ($shippingzone == 'country') {
                 if (isset($espost['ship_country']) && $espost['ship_country'] != '') {
                     $pzoneid = $espost['ship_country'];
                 } elseif (isset($espost['country']) && $espost['country'] != '') {
                     $pzoneid = $espost['country'];
                 }
                 $pzone = $wpdb->get_var("SELECT zone FROM {$tablecountries} WHERE code='{$pzoneid}' LIMIT 1");
             } else {
                 if (isset($espost['ship_state']) && $espost['ship_state'] != '') {
                     $pzoneid = $espost['ship_state'];
                 }
                 if (isset($espost['state']) && $espost['state'] != '') {
                     $pzoneid = $espost['state'];
                 }
                 $pzone = $wpdb->get_var("SELECT zone FROM {$tablestates} WHERE id='{$pzoneid}' LIMIT 1");
                 if (isset($espost['altstate']) && $espost['altstate'] != '') {
                     $pzone = $eshopoptions['unknown_state'];
                 }
                 if (isset($espost['ship_altstate']) && $espost['ship_altstate'] != '') {
                     $pzone = $eshopoptions['unknown_state'];
                 }
             }
         }
         //
         $shiparray = array();
         $eshopcartarray = $_SESSION['eshopcart' . $blog_id];
         foreach ($eshopcartarray as $productid => $opt) {
             if (is_array($opt)) {
                 switch ($eshopoptions['shipping']) {
                     case '1':
                         //( per quantity of 1, prices reduced for additional items )
                         for ($i = 1; $i <= $opt['qty']; $i++) {
                             array_push($shiparray, $opt["pclas"]);
                         }
                         break;
                     case '2':
                         //( once per shipping class no matter what quantity is ordered )
                         if (!in_array($opt["pclas"], $shiparray)) {
                             array_push($shiparray, $opt["pclas"]);
                         }
                         break;
                     case '3':
                         //( one overall charge no matter how many are ordered )
                         if (!in_array($opt["pclas"], $shiparray)) {
                             if ($opt["pclas"] != 'F') {
                                 array_push($shiparray, 'A');
                             }
                         }
                         break;
                     case '4':
                         //( weight )
                         if (isset($espost['eshop_shiptype'])) {
                             unset($shiparray);
                             $shiparray = $espost['eshop_shiptype'];
                         }
                         break;
                 }
             }
         }
         //need an extra check
         if ($eshopoptions['shipping'] == '4' && 'no' == $eshopoptions['downloads_only'] && isset($espost['submit']) && !isset($espost['eshop_shiptype']) && !eshop_only_downloads()) {
             $pzone = '';
         }
         //need to check the discount codes here as well:
         if (eshop_discount_codes_check()) {
             $_SESSION['eshop_discount' . $blog_id] = '';
             unset($_SESSION['eshop_discount' . $blog_id]);
             if (isset($espost['eshop_discount']) && $espost['eshop_discount'] != '') {
                 $chkcode = valid_eshop_discount_code($espost['eshop_discount']);
                 if ($chkcode) {
                     $_SESSION['eshop_discount' . $blog_id] = $espost['eshop_discount'];
                 }
             }
         }
         //show the cart
         if (isset($_GET['eshopaction']) && $_GET['eshopaction'] != 'redirect' || !isset($_GET['eshopaction'])) {
             $echoit .= display_cart($_SESSION['eshopcart' . $blog_id], false, $eshopoptions['checkout'], $pzone, $shiparray);
         }
     }
     $error = '';
     if (isset($espost['submit'])) {
         //form handling
         foreach ($espost as $key => $value) {
             $key = $value;
         }
         //setupshipping arrays
         $reqdvalues = array('shipping', 'first_name', 'last_name', 'email', 'phone', 'address', 'city', 'zip', 'pay');
         if ($eshopoptions['shipping'] != '4') {
             if ($eshopoptions['shipping_zone'] == 'country') {
                 $reqdvalues[] = 'country';
             } else {
                 $reqdvalues[] = 'state';
             }
         } else {
             $creqd = '';
             $dtable = $wpdb->prefix . 'eshop_rates';
             $query = $wpdb->get_results("SELECT DISTINCT(area) from {$dtable} where rate_type='ship_weight'");
             foreach ($query as $k) {
                 $reqdvalues[] = $k->area;
             }
         }
         $linkattr = apply_filters('eShopCheckoutLinksAttr', '');
         $reqdarray = apply_filters('eshopCheckoutReqd', $reqdvalues);
         if ($eshopoptions['shipping'] == '4' && 'no' == $eshopoptions['downloads_only'] && !isset($espost['eshop_shiptype']) && !eshop_only_downloads()) {
             $error .= '<li>' . __('<strong>Shipping</strong> - not selected.', 'eshop') . '</li>';
         }
         if (isset($espost['first_name'])) {
             $valid = checkAlpha($espost['first_name']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'first_name')) {
                 $error .= '<li>' . __('<strong>First name</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (isset($espost['last_name'])) {
             $valid = checkAlpha($espost['last_name']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'last_name')) {
                 $error .= '<li>' . __('<strong>Last name</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (isset($espost['email'])) {
             $valid = checkEmail($espost['email']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'email')) {
                 $error .= '<li>' . __('<strong>Email address</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (isset($espost['phone'])) {
             $valid = checkPhone($espost['phone']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'phone')) {
                 $error .= '<li>' . __('<strong>Phone Number</strong> - missing or incorrect', 'eshop') . '.</li>';
             }
         }
         if (isset($espost['address1'])) {
             $valid = checkAlpha($espost['address1']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'address')) {
                 $error .= '<li>' . __('<strong>Address</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (isset($espost['city'])) {
             $valid = checkAlpha($espost['city']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'city')) {
                 $error .= '<li>' . __('<strong>City or town</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (eshop_checkreqd($reqdarray, 'state')) {
             if (isset($espost['state']) && $espost['state'] == '' && $espost['altstate'] == '') {
                 $error .= '<li>' . __('<strong>State/County/Province</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (eshop_checkreqd($reqdarray, 'country')) {
             if (isset($espost['country'])) {
                 $valid = checkAlpha($espost['country']);
                 if ($valid == FALSE) {
                     $error .= '<li>' . __('<strong>Country</strong> - missing or incorrect.', 'eshop') . '</li>';
                 }
             }
         }
         if (isset($espost['country']) && $espost['country'] == 'US' && $espost['state'] == '' && $espost['altstate'] == '') {
             //must pick a state for US deliveries
             $error .= '<li>' . __('<strong><abbr title="United States">US</abbr> State</strong> - missing or incorrect.', 'eshop') . '</li>';
         }
         if (isset($espost['zip'])) {
             $valid = checkAlphaNum($espost['zip']);
             if ($valid == FALSE && eshop_checkreqd($reqdarray, 'zip')) {
                 $error .= '<li>' . __('<strong>Zip/Post code</strong> - missing or incorrect.', 'eshop') . '</li>';
             }
         }
         if (isset($espost['reference'])) {
             if ($espost['reference'] == '' && eshop_checkreqd($reqdarray, 'ref')) {
                 $error .= '<li>' . __('<strong>Reference</strong> - missing.', 'eshop') . '</li>';
             }
         }
         if (isset($espost['comments'])) {
             if ($espost['comments'] == '' && eshop_checkreqd($reqdarray, 'comments')) {
                 $error .= '<li>' . __('<strong>Comments</strong> - missing.', 'eshop') . '</li>';
             }
         }
         if (isset($eshopoptions['users']) && $eshopoptions['users'] == 'yes' && !is_user_logged_in()) {
             if (!isset($espost['eshop_users']) && eshop_checkreqd($reqdarray, 'signup')) {
                 $error .= '<li>' . __('<strong>Sign Up</strong> - not checked.', 'eshop') . '</li>';
             }
         }
         //add in error checking for any new values here
         $temperror = apply_filters('eshoperrorcheckout', $espost);
         if (!is_array($temperror)) {
             $error .= $temperror;
         }
         ////////////////////////////////////////////////
         if ('yes' == $eshopoptions['tandc_use']) {
             if (!isset($espost['eshop_tandc'])) {
                 $error .= '<li><strong>' . $eshopoptions['tandc'] . '</strong>' . __(' - not checked.', 'eshop') . '</li>';
             }
         }
         if (!isset($espost['eshop_payment'])) {
             $error .= '<li>' . __('You have not chosen a <strong>payment option</strong>.', 'eshop') . '</li>';
         }
         if (eshop_discount_codes_check()) {
             $_SESSION['eshop_discount' . $blog_id] = '';
             unset($_SESSION['eshop_discount' . $blog_id]);
             if (isset($espost['eshop_discount']) && $espost['eshop_discount'] != '') {
                 $chkcode = valid_eshop_discount_code($espost['eshop_discount']);
                 if (!$chkcode) {
                     $error .= '<li>' . __('<strong>Discount Code</strong> - is not valid.', 'eshop') . '</li>';
                 } else {
                     $_SESSION['eshop_discount' . $blog_id] = $espost['eshop_discount'];
                 }
             }
         }
         if (isset($eshopoptions['users']) && $eshopoptions['users'] == 'yes' && isset($espost['eshop_users']) && !is_user_logged_in()) {
             $_SESSION['eshop_user' . $blog_id] = '1';
         }
         if ($error != '') {
             $echoit .= "<p><strong class=\"eshoperror error\">" . __('There were some errors in the details you entered&#8230;', 'eshop') . "</strong></p><ul class=\"eshoperrors errors\">" . $error . '</ul>';
             $first_name = $last_name = $company = $phone = $reference = '';
             $email = $address1 = $address2 = $city = $country = '';
             $state = $altstate = $zip = $ship_name = $ship_company = '';
             $ship_phone = $ship_address = $ship_city = $ship_postcode = '';
             $ship_country = $ship_state = $ship_altstate = $comments = '';
             if (isset($espost['first_name'])) {
                 $first_name = $espost['first_name'];
             }
             if (isset($espost['last_name'])) {
                 $last_name = $espost['last_name'];
             }
             if (isset($espost['phone'])) {
                 $phone = $espost['phone'];
             }
             if (isset($espost['reference'])) {
                 $reference = $espost['reference'];
             }
             if (isset($espost['email'])) {
                 $email = $espost['email'];
             }
             if (isset($espost['address1'])) {
                 $address1 = $espost['address1'];
             }
             if (isset($espost['address2'])) {
                 $address2 = $espost['address2'];
             }
             if (isset($espost['city'])) {
                 $city = $espost['city'];
             }
             if (isset($espost['country'])) {
                 $country = $espost['country'];
             }
             if (isset($espost['state'])) {
                 $state = $espost['state'];
             }
             if (isset($espost['altstate'])) {
                 $altstate = $espost['altstate'];
             }
             if (isset($espost['zip'])) {
                 $zip = $espost['zip'];
             }
             if (isset($espost['ship_name'])) {
                 $ship_name = $espost['ship_name'];
             }
             if (isset($espost['ship_company'])) {
                 $ship_company = $espost['ship_company'];
             }
             if (isset($espost['ship_phone'])) {
                 $ship_phone = $espost['ship_phone'];
             }
             if (isset($espost['ship_address'])) {
                 $ship_address = $espost['ship_address'];
             }
             if (isset($espost['ship_city'])) {
                 $ship_city = $espost['ship_city'];
             }
             if (isset($espost['ship_country'])) {
                 $ship_country = $espost['ship_country'];
             }
             if (isset($espost['ship_state'])) {
                 $ship_state = $espost['ship_state'];
             }
             if (isset($espost['ship_altstate'])) {
                 $ship_altstate = $espost['ship_altstate'];
             }
             if (isset($espost['ship_postcode'])) {
                 $ship_postcode = $espost['ship_postcode'];
             }
             if (isset($espost['comments'])) {
                 $comments = $espost['comments'];
             }
             $chkerror = '1';
         } else {
             if (!isset($_GET['eshopaction'])) {
                 $shipping = 0;
                 $echoit .= "<div class=\"hr\"></div><div class=\"eshopcheckoutconf\"><h3>" . __('<span class="noprint">Please Confirm </span>Your Details', 'eshop') . '</h3>';
                 // create a custom id, and shove details in database
                 $date = date('YmdHis');
                 $_SESSION['date' . $blog_id] = $date;
                 $fprice = number_format($_SESSION['final_price' . $blog_id], 2, '.', '');
                 $espost['amount'] = $fprice;
                 $espost['custom'] = $date;
                 $espost['numberofproducts'] = sizeof($_SESSION['eshopcart' . $blog_id]);
                 //shipping
                 if (isset($_SESSION['shipping' . $blog_id])) {
                     $shipping = eshopShipTaxAmt();
                 }
                 //discount shipping
                 if (is_shipfree(calculate_total())) {
                     $shipping = 0;
                 }
                 //shipping
                 $espost['shipping_1'] = $shipping;
                 $ctable = $wpdb->prefix . 'eshop_countries';
                 $stable = $wpdb->prefix . 'eshop_states';
                 if ('no' == $eshopoptions['downloads_only']) {
                     $echoit .= '<h4>' . __('Mailing Address', 'eshop') . '</h4><ul class="eshop confirm">';
                 } else {
                     $echoit .= '<h4>' . __('Contact Details', 'eshop') . '</h4><ul class="eshop confirm">';
                 }
                 $echoit .= "<li><span class=\"items fullname\">" . __('Full name:', 'eshop') . "</span> " . $espost['first_name'] . " " . $espost['last_name'] . "</li>\n";
                 if ('no' == $eshopoptions['downloads_only']) {
                     $echoit .= "<li class=\"company\"><span class=\"items\">" . __('Company:', 'eshop') . "</span> " . $espost['company'] . "</li>\n";
                 }
                 $echoit .= "<li class=\"email\"><span class=\"items\">" . __('Email:', 'eshop') . "</span> " . $espost['email'] . "</li>\n";
                 if ('no' == $eshopoptions['downloads_only']) {
                     $echoit .= "<li class=\"phone\"><span class=\"items\">" . __('Phone:', 'eshop') . "</span> " . $espost['phone'] . "</li>\n";
                     $echoit .= "<li class=\"address\"><span class=\"items\">" . __('Address:', 'eshop') . "</span> " . $espost['address1'] . " " . $espost['address2'] . "</li>\n";
                     $echoit .= "<li class=\"city\"><span class=\"items\">" . __('City or town:', 'eshop') . "</span> " . $espost['city'] . "</li>\n";
                     $qcode = $wpdb->escape($espost['state']);
                     $qstate = $wpdb->get_var("SELECT stateName FROM {$stable} WHERE id='{$qcode}' limit 1");
                     if ($espost['altstate'] != '') {
                         $echoit .= "<li class=\"state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $espost['altstate'] . "</li>\n";
                     } elseif ($qstate != '') {
                         $echoit .= "<li class=\"state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $qstate . "</li>\n";
                     }
                     $echoit .= "<li class=\"zip\"><span class=\"items\">" . __('Zip/Post code:', 'eshop') . "</span> " . $espost['zip'] . "</li>\n";
                     $qccode = $wpdb->escape($espost['country']);
                     $qcountry = $wpdb->get_var("SELECT country FROM {$ctable} WHERE code='{$qccode}' limit 1");
                     $echoit .= "<li class=\"country\"><span class=\"items\">" . __('Country:', 'eshop') . "</span> " . $qcountry . "</li>\n";
                 }
                 $echoit .= "</ul>\n";
                 //
                 $temp = apply_filters('eshopconfcheckout', $espost);
                 if (!is_array($temp)) {
                     $echoit .= $temp;
                 }
                 //
                 if (!isset($espost['reference'])) {
                     $espost['reference'] = '';
                 }
                 if (!isset($espost['comments'])) {
                     $espost['comments'] = '';
                 }
                 if (trim($espost['reference']) != '' && trim($espost['comments']) == '') {
                     $echoit .= "<div class=\"eshop fld3\"><h4>" . __('Additional information', 'eshop') . "</h4>\n<ul class=\"eshop confirmref\">\n";
                     $echoit .= '<li><span class="items">' . __('Reference or <abbr title="Purchase Order number">PO</abbr>', 'eshop') . '</span> ' . $espost['reference'] . '</li>' . "\n";
                     $echoit .= '</ul></div>' . "\n";
                 }
                 if (trim($espost['reference']) == '' && trim($espost['comments']) != '') {
                     $echoit .= "<div class=\"eshop fld3\"><h4>" . __('Additional information', 'eshop') . "</h4>\n<ul class=\"eshop confirmref\">\n";
                     $echoit .= '<li><span class="items">' . __('Comments or instructions:', 'eshop') . '</span> ' . $espost['comments'] . '</li>' . "\n";
                     $echoit .= '</ul></div>' . "\n";
                 }
                 if (trim($espost['reference']) != '' && trim($espost['comments']) != '') {
                     $echoit .= "<div class=\"eshop fld3\"><h4>" . __('Additional information', 'eshop') . "</h4>\n<ul class=\"eshop confirmref\">\n";
                     $echoit .= '<li><span class="items">' . __('Reference or PO:', 'eshop') . '</span> ' . $espost['reference'] . '</li>' . "\n";
                     $echoit .= '<li><span class="items">' . __('Comments or instructions:', 'eshop') . '</span> ' . $espost['comments'] . '</li>' . "\n";
                     $echoit .= '</ul></div>' . "\n";
                 }
                 if ('no' == $eshopoptions['downloads_only']) {
                     if ('yes' != $eshopoptions['hide_shipping']) {
                         if ($espost['ship_name'] != '' || $espost['ship_address'] != '' || $espost['ship_city'] != '' || $espost['ship_postcode'] != '') {
                             $echoit .= "<div class=\"eshop fld4\"><h4>" . __('Shipping Address', 'eshop') . "</h4>\n<ul class=\"eshop confirmship\">\n";
                             $echoit .= "<li><span class=\"items\">" . __('Full name:', 'eshop') . "</span> " . $espost['ship_name'] . "</li>\n";
                             $echoit .= "<li class=\"ship_company\"><span class=\"items\">" . __('Company:', 'eshop') . "</span> " . $espost['ship_company'] . "</li>\n";
                             $echoit .= "<li><span class=\"items\">" . __('Phone:', 'eshop') . "</span> " . $espost['ship_phone'] . "</li>\n";
                             $echoit .= "<li><span class=\"items\">" . __('Address:', 'eshop') . "</span> " . $espost['ship_address'] . "</li>\n";
                             $echoit .= "<li><span class=\"items\">" . __('City or town:', 'eshop') . "</span> " . $espost['ship_city'] . "</li>\n";
                             $qcode = $wpdb->escape($espost['ship_state']);
                             $qstate = $wpdb->get_var("SELECT stateName FROM {$stable} WHERE id='{$qcode}' limit 1");
                             if ($espost['ship_altstate'] != '') {
                                 $echoit .= "<li class=\"ship_state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $espost['ship_altstate'] . "</li>\n";
                             } elseif ($qstate != '') {
                                 $echoit .= "<li class=\"ship_state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $qstate . "</li>\n";
                             }
                             $echoit .= "<li><span class=\"items\">" . __('Zip/Post code:', 'eshop') . "</span> " . $espost['ship_postcode'] . "</li>\n";
                             $qccode = $wpdb->escape($espost['ship_country']);
                             $qcountry = $wpdb->get_var("SELECT country FROM {$ctable} WHERE code='{$qccode}' limit 1");
                             $echoit .= "<li class=\"shipcountry\"><span class=\"items\">" . __('Country:', 'eshop') . "</span> " . $qcountry . "</li>\n";
                             $echoit .= "</ul></div>\n";
                         }
                     }
                 }
                 $echoit .= "\n";
                 $echoit .= "</div>\n";
             }
             //add to a session to store address:
             $_SESSION['addy' . $blog_id]['first_name'] = $espost['first_name'];
             $_SESSION['addy' . $blog_id]['last_name'] = $espost['last_name'];
             $_SESSION['addy' . $blog_id]['email'] = $espost['email'];
             if (isset($espost['company'])) {
                 $_SESSION['addy' . $blog_id]['company'] = $espost['company'];
             } else {
                 $_SESSION['addy' . $blog_id]['company'] = '';
             }
             if (isset($espost['phone'])) {
                 $_SESSION['addy' . $blog_id]['phone'] = $espost['phone'];
             } else {
                 $_SESSION['addy' . $blog_id]['phone'] = '';
             }
             if (isset($espost['reference'])) {
                 $_SESSION['addy' . $blog_id]['reference'] = $espost['reference'];
             } else {
                 $_SESSION['addy' . $blog_id]['reference'] = '';
             }
             if (isset($espost['address1'])) {
                 $_SESSION['addy' . $blog_id]['address1'] = $espost['address1'];
             } else {
                 $_SESSION['addy' . $blog_id]['address1'] = '';
             }
             if (isset($espost['address2'])) {
                 $_SESSION['addy' . $blog_id]['address2'] = $espost['address2'];
             } else {
                 $_SESSION['addy' . $blog_id]['address2'] = '';
             }
             if (isset($espost['city'])) {
                 $_SESSION['addy' . $blog_id]['city'] = $espost['city'];
             }
             if (isset($espost['country'])) {
                 $_SESSION['addy' . $blog_id]['country'] = $espost['country'];
             } else {
                 $_SESSION['addy' . $blog_id]['country'] = '';
             }
             if (isset($espost['state'])) {
                 $_SESSION['addy' . $blog_id]['state'] = $espost['state'];
             } else {
                 $_SESSION['addy' . $blog_id]['state'] = '';
             }
             if (isset($espost['altstate']) && $espost['altstate'] != '') {
                 $_SESSION['addy' . $blog_id]['state'] = $espost['altstate'];
             }
             if (isset($espost['zip'])) {
                 $_SESSION['addy' . $blog_id]['zip'] = $espost['zip'];
             } else {
                 $_SESSION['addy' . $blog_id]['zip'] = '';
             }
             if (isset($espost['ship_name'])) {
                 $_SESSION['addy' . $blog_id]['ship_name'] = $espost['ship_name'];
                 $_SESSION['addy' . $blog_id]['ship_company'] = $espost['ship_company'];
                 $_SESSION['addy' . $blog_id]['ship_phone'] = $espost['ship_phone'];
                 $_SESSION['addy' . $blog_id]['ship_address'] = $espost['ship_address'];
                 $_SESSION['addy' . $blog_id]['ship_city'] = $espost['ship_city'];
                 $_SESSION['addy' . $blog_id]['ship_country'] = $espost['ship_country'];
                 $_SESSION['addy' . $blog_id]['ship_state'] = $espost['ship_state'];
                 if (isset($espost['ship_altstate']) && $espost['ship_altstate'] != '') {
                     $_SESSION['addy' . $blog_id]['ship_state'] = $espost['ship_altstate'];
                 }
                 $_SESSION['addy' . $blog_id]['ship_postcode'] = $espost['ship_postcode'];
             }
             if (isset($espost['comments'])) {
                 $_SESSION['addy' . $blog_id]['comments'] = $espost['comments'];
             } else {
                 $_SESSION['addy' . $blog_id]['comments'] = '';
             }
             if (!isset($_SESSION['shipping' . $blog_id])) {
                 $_SESSION['shipping' . $blog_id]['cost'] = $shipping;
             }
             //grab all the POST variables and store in cookie
             $array = $espost;
             //but first make a few extra equal nothing
             //add others in here if needed
             $array['comments'] = $array['reference'] = '';
             $eshopsetcookie = apply_filters('eshop_use_cookie', true);
             if ($eshopsetcookie == true) {
                 $biscuits = eshop_build_cookie($array);
                 setcookie("eshopcart", $biscuits, time() + 60 * 60 * 24 * 365);
             }
             $eshopmgincpath = apply_filters('eshop_mg_inc_path', WP_PLUGIN_DIR . '/eshop/' . $paymentmethod . '.php', $paymentmethod);
             include_once $eshopmgincpath;
             $contineproceed = '3';
         }
     } else {
         //for first time form usage.
         if (isset($_SESSION['addy' . $blog_id])) {
             $first_name = $_SESSION['addy' . $blog_id]['first_name'];
             $last_name = $_SESSION['addy' . $blog_id]['last_name'];
             $company = $_SESSION['addy' . $blog_id]['company'];
             $phone = $_SESSION['addy' . $blog_id]['phone'];
             $reference = $_SESSION['addy' . $blog_id]['reference'];
             $email = $_SESSION['addy' . $blog_id]['email'];
             $address1 = $_SESSION['addy' . $blog_id]['address1'];
             $address2 = $_SESSION['addy' . $blog_id]['address2'];
             $city = '';
             if (isset($_SESSION['addy' . $blog_id]['city'])) {
                 $city = $_SESSION['addy' . $blog_id]['city'];
             }
             $country = $_SESSION['addy' . $blog_id]['country'];
             $state = $_SESSION['addy' . $blog_id]['state'];
             if (!is_numeric($state)) {
                 $li = $wpdb->escape($state);
                 $table = $wpdb->prefix . 'eshop_states';
                 $stateList = $wpdb->get_var("SELECT id FROM {$table} WHERE code='{$li}' limit 1");
                 $state = $stateList;
             }
             if (isset($_SESSION['addy' . $blog_id]['altstate'])) {
                 $altstate = $_SESSION['addy' . $blog_id]['altstate'];
             } else {
                 $altstate = '';
             }
             $zip = $_SESSION['addy' . $blog_id]['zip'];
             /* defaults */
             $ship_name = $ship_company = '';
             $ship_phone = $ship_address = $ship_city = $ship_postcode = '';
             $ship_country = $ship_state = $ship_altstate = $comments = '';
             if (isset($_SESSION['addy' . $blog_id]['ship_name'])) {
                 $ship_name = $_SESSION['addy' . $blog_id]['ship_name'];
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_company'])) {
                 $ship_company = $_SESSION['addy' . $blog_id]['ship_company'];
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_phone'])) {
                 $ship_phone = $_SESSION['addy' . $blog_id]['ship_phone'];
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_address'])) {
                 $ship_address = $_SESSION['addy' . $blog_id]['ship_address'];
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_city'])) {
                 $ship_city = $_SESSION['addy' . $blog_id]['ship_city'];
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_country'])) {
                 $ship_country = $_SESSION['addy' . $blog_id]['ship_country'];
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_state'])) {
                 $ship_state = $_SESSION['addy' . $blog_id]['ship_state'];
                 if (!is_numeric($ship_state)) {
                     $li = $wpdb->escape($ship_state);
                     $table = $wpdb->prefix . 'eshop_states';
                     $stateSList = $wpdb->get_var("SELECT id FROM {$table} WHERE code='{$li}' limit 1");
                     $ship_state = $stateSList;
                 }
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_altstate'])) {
                 $ship_altstate = $_SESSION['addy' . $blog_id]['ship_altstate'];
             } else {
                 $ship_altstate = '';
             }
             if (isset($_SESSION['addy' . $blog_id]['ship_postcode'])) {
                 $ship_postcode = $_SESSION['addy' . $blog_id]['ship_postcode'];
             }
             if (isset($_SESSION['addy' . $blog_id]['comments'])) {
                 $comments = $_SESSION['addy' . $blog_id]['comments'];
             }
         } else {
             $first_name = $last_name = $company = $phone = $reference = '';
             $email = $address1 = $address2 = $city = $country = '';
             $state = $altstate = $zip = $ship_name = $ship_company = '';
             $ship_phone = $ship_address = $ship_city = $ship_postcode = '';
             $ship_country = $ship_state = $ship_altstate = $comments = '';
             $eshopsetcookie = apply_filters('eshop_use_cookie', true);
             if (isset($_COOKIE["eshopcart"]) && calculate_items() != 0 && $eshopsetcookie == true) {
                 $crumbs = eshop_break_cookie($_COOKIE["eshopcart"]);
                 foreach ($crumbs as $k => $v) {
                     ${$k} = $v;
                 }
             }
             if (is_user_logged_in() && isset($eshopoptions['users']) && 'yes' == $eshopoptions['users']) {
                 global $current_user;
                 get_currentuserinfo();
                 $crumbs = stripslashes_deep(get_the_author_meta('eshop', $current_user->ID));
                 if (is_array($crumbs)) {
                     foreach ($crumbs as $k => $v) {
                         ${$k} = esc_attr($v);
                     }
                     $first_name = esc_attr($current_user->user_firstname);
                     $last_name = esc_attr($current_user->user_lastname);
                     $email = esc_attr($current_user->user_email);
                 }
             }
         }
     }
     if ($chkerror != 0 || !isset($espost['submit']) && $numberofproducts >= 1) {
         // only show form if not filled in.
         $echoit .= eshopShowform($first_name, $last_name, $company, $phone, $email, $address1, $address2, $city, $state, $altstate, $zip, $country, $reference, $comments, $ship_name, $ship_company, $ship_phone, $ship_address, $ship_city, $ship_postcode, $ship_state, $ship_altstate, $ship_country);
     }
     if (isset($_SESSION['eshopcart' . $blog_id])) {
         switch ($contineproceed) {
             case '1':
                 $echoit .= '<ul class="continue-proceed eshopcp1"><li class="editcart"><a href="' . get_permalink($eshopoptions['cart']) . '">' . __('&laquo; Edit Cart or Continue Shopping', 'eshop') . '</a></li></ul>';
                 break;
             case '2':
                 $echoit .= '<ul class="continue-proceed redirect eshopcp2"><li class="editcheckout"><a href="' . get_permalink($eshopoptions['checkout']) . '">' . __('&laquo; Edit Details or Continue Shopping', 'eshop') . '</a></li></ul>';
                 break;
             case '3':
                 $echoit .= '<ul class="continue-proceed redirect eshopcp3"><li class="editcheckout"><a href="' . get_permalink($eshopoptions['checkout']) . '">' . __('&laquo; Edit Details or Continue Shopping', 'eshop') . '</a></li></ul>';
                 break;
         }
     } else {
         $echoit .= "<p><strong class=\"eshoperror error\">" . __('Your shopping cart is currently empty.', 'eshop') . "</strong></p>";
     }
     return $echoit;
 }
예제 #4
0
        try {
            $stmt = $db->prepare("select * from `users` where username=:username");
            $stmt->bindParam(":username", addslashes($_POST['username']));
            $stmt->execute();
            if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $usernameError = 3;
            }
        } catch (PDOException $e) {
            echo "Database error";
        }
    }
    $basicChanged = 1;
    $usernameChanged = 1;
}
if (isset($_POST['phone']) && !empty($_POST['phone']) && addslashes($_POST['phone']) != $_SESSION['phone']) {
    $phoneError = checkPhone();
    $basicChanged = 1;
    $phoneChanged = 1;
}
if (isset($_POST['address']) && !empty($_POST['address']) && addslashes($_POST['address']) != $_SESSION['address']) {
    $addressError = checkAddress();
    $basicChanged = 1;
    $addressChanged = 1;
}
if (isset($_POST['birthdate']) && !empty($_POST['birthdate']) && addslashes($_POST['birthdate']) != $_SESSION['birthdate']) {
    $dateError = checkBirth();
    $basicChanged = 1;
    $dateChanged = 1;
}
if (isset($_POST['email']) && !empty($_POST['email']) && $_SESSION['email'] != addslashes($_POST['email'])) {
    $emailError = checkEmail();
예제 #5
0
 * 发送短信
 *
 * @param string $phone 手机号
 */
function sendSms($phone)
{
    $content = '您的验证码为: [code], 任何人索取验证码均为咋骗,切勿泄露!此验证码会在15分钟后失效';
    $code = mt_rand(100000, 999999);
    Sp_Sendmsg::send(array('type' => Sp_Dictionary::getSmsType(0), 'username' => $phone, 'code' => $code, 'content' => str_replace('[code]', $code, $content)));
    return true;
}
$jsonParam = array();
$request = Request::current();
$phone = $request->phone;
// 获得手机号
$rs = checkPhone($phone);
if (is_array($rs)) {
    $jsonParam = $rs;
} else {
    // 获取短信验证码
    if ('getcode' == $request->type) {
        sendSms($phone);
        $jsonParam = array('code' => '200', 'msg' => '短信发送成功');
    } else {
        // 登陆
        $code = $request->code;
        $rs = checkLogin($code, $phone);
        if (is_array($rs)) {
            $jsonParam = $rs;
        } else {
            $user = Sp_Account_SignIn::getUserByPhone($phone);
예제 #6
0
checkMandatory("surname", "surname", "custErrors", "custFormVars");
// Validate the Address
checkMandatory("address", "address", "custErrors", "custFormVars");
// Validate the Initial
if (!empty($_SESSION["custFormVars"]["initial"]) && !eregi("^[[:alpha:]]{1}\$", $_SESSION["custFormVars"]["initial"])) {
    $_SESSION["custErrors"]["initial"] = "The initial field must be empty or one " . "alphabetic character in length.";
}
// Validate the City
checkMandatory("city", "city", "custErrors", "custFormVars");
// Validate Zipcode
if (checkMandatory("zipcode", "Zip code", "custErrors", "custFormVars")) {
    checkZipcode("zipcode", "Zip code", "custErrors", "custFormVars");
}
// Phone is optional, but if it is entered it must have correct format
if (!empty($_SESSION["custFormVars"]["phone"])) {
    checkPhone("phone", "telephone", "custErrors", "custFormVars");
}
// Validate Date of Birth
if (checkMandatory("birth_date", "date of birth", "custErrors", "custFormVars")) {
    checkDateAndAdult("birth_date", "date of birth", "custErrors", "custFormVars");
}
// Only validate email if this is an INSERT
if (!isset($_SESSION["loginUsername"])) {
    if (checkMandatory("loginUsername", "email/username", "custErrors", "custFormVars") && emailCheck("loginUsername", "email/username", "custErrors", "custFormVars")) {
        // Check if the email address is already in use in
        //  the winestore
        $query = "SELECT * FROM users WHERE user_name = \n                '{$_SESSION["custFormVars"]["loginUsername"]}'";
        $result = $connection->query($query);
        if (DB::isError($result)) {
            trigger_error($result->getMessage(), E_USER_ERROR);
        }
예제 #7
0
 public function tracking(Varien_Event_Observer $observer)
 {
     //$trackingenable = Mage::getStoreConfig('trmtwiliosmsbridgeconfig/trmtwiliocustomergroup/trackingenable',Mage::app()->getStore());
     if (ISENABLED && CUSTOMERISENABLED) {
         $allowCountries = explode(",", SPECIFICCOUNTRY);
         //$order = $observer->getEvent()->getOrder();
         //$orderNumber = $order->getIncrementId();
         $shipment = $observer->getEvent()->getShipment();
         $order = $shipment->getOrder();
         //get store order was placed in
         $store = Mage::app()->getStore()->load($order->getStoreId());
         //do something with order - get the increment id:
         $orderNumber = $order->getIncrementId();
         $billingAddress = $order->getBillingAddress();
         $shippingAddress = $order->getShippingAddress();
         $countryToCode = array("93" => "AF", "355" => "AL", "213" => "DZ", "1684" => "AS", "376" => "AD", "244" => "AO", "1264" => "AI", "672" => "AQ", "1268" => "AG", "54" => "AR", "374" => "AM", "297" => "AW", "61" => "AU", "43" => "AT", "994" => "AZ", "1242" => "BS", "973" => "BH", "880" => "BD", "1246" => "BB", "375" => "BY", "32" => "BE", "501" => "BZ", "229" => "BJ", "1441" => "BM", "975" => "BT", "591" => "BO", "387" => "BA", "267" => "BW", "55" => "BR", "1284" => "VG", "673" => "BN", "359" => "BG", "226" => "BF", "95" => "MM", "257" => "BI", "855" => "KH", "237" => "CM", "1" => "CA", "238" => "CV", "1345" => "KY", "236" => "CF", "235" => "TD", "56" => "CL", "86" => "CN", "61" => "CX", "61" => "CC", "57" => "CO", "269" => "KM", "682" => "CK", "506" => "CR", "385" => "HR", "53" => "CU", "357" => "CY", "420" => "CZ", "243" => "CD", "45" => "DK", "253" => "DJ", "1767" => "DM", "1809" => "DO", "593" => "EC", "20" => "EG", "503" => "SV", "240" => "GQ", "291" => "ER", "372" => "EE", "251" => "ET", "500" => "FK", "298" => "FO", "679" => "FJ", "358" => "FI", "33" => "FR", "689" => "PF", "241" => "GA", "220" => "GM", "995" => "GE", "49" => "DE", "233" => "GH", "350" => "GI", "30" => "GR", "299" => "GL", "1473" => "GD", "1671" => "GU", "502" => "GT", "224" => "GN", "245" => "GW", "592" => "GY", "509" => "HT", "39" => "VA", "504" => "HN", "852" => "HK", "36" => "HU", "354" => "IS", "91" => "IN", "62" => "ID", "98" => "IR", "964" => "IQ", "353" => "IE", "44" => "IM", "972" => "IL", "39" => "IT", "225" => "CI", "1876" => "JM", "81" => "JP", "962" => "JO", "7" => "KZ", "254" => "KE", "686" => "KI", "965" => "KW", "996" => "KG", "856" => "LA", "371" => "LV", "961" => "LB", "266" => "LS", "231" => "LR", "218" => "LY", "423" => "LI", "370" => "LT", "352" => "LU", "853" => "MO", "389" => "MK", "261" => "MG", "265" => "MW", "60" => "MY", "960" => "MV", "223" => "ML", "356" => "MT", "692" => "MH", "222" => "MR", "230" => "MU", "262" => "YT", "52" => "MX", "691" => "FM", "373" => "MD", "377" => "MC", "976" => "MN", "382" => "ME", "1664" => "MA", "258" => "MZ", "264" => "NA", "674" => "NR", "977" => "NP", "31" => "NL", "599" => "AN", "687" => "NC", "64" => "NZ", "505" => "NI", "227" => "NE", "234" => "NG", "683" => "NU", "672" => "NF", "850" => "KP", "1670" => "MP", "47" => "NO", "968" => "OM", "92" => "PK", "680" => "PW", "507" => "PA", "675" => "PG", "595" => "PY", "51" => "PE", "63" => "PH", "870" => "PN", "48" => "PL", "351" => "PT", "1" => "PR", "974" => "QA", "242" => "CG", "40" => "RO", "7" => "RU", "250" => "RW", "590" => "BL", "290" => "SH", "1869" => "KN", "1758" => "LC", "1599" => "MF", "508" => "PM", "1784" => "VC", "685" => "WS", "378" => "SM", "239" => "ST", "966" => "SA", "221" => "SN", "381" => "RS", "248" => "SC", "232" => "SL", "65" => "SG", "421" => "SK", "386" => "SI", "677" => "SB", "252" => "SO", "27" => "ZA", "82" => "KR", "34" => "ES", "94" => "LK", "249" => "SD", "597" => "SR", "268" => "SZ", "46" => "SE", "41" => "CH", "963" => "SY", "886" => "TW", "992" => "TJ", "255" => "TZ", "66" => "TH", "670" => "TL", "228" => "TG", "690" => "TK", "676" => "TO", "1868" => "TT", "216" => "TN", "90" => "TR", "993" => "TM", "1649" => "TC", "688" => "TV", "256" => "UG", "380" => "UA", "971" => "AE", "44" => "GB", "1" => "US", "598" => "UY", "1340" => "VI", "998" => "UZ", "678" => "VU", "58" => "VE", "84" => "VN", "681" => "WF", "967" => "YE", "260" => "ZM", "263" => "ZW");
         function checkPhone($phone, $countryCode)
         {
             if (substr($phone, 0, strlen($countryCode)) === (string) $countryCode) {
                 return $phone;
             } else {
                 return $countryCode . $phone;
             }
         }
         function clean($string)
         {
             return preg_replace('/\\D/', '', $string);
         }
         //get country code and clean phone numbers
         $billingphone = clean($billingAddress->getTelephone());
         $billingCountryCode = array_search($billingAddress->getCountry(), $countryToCode);
         $billingphone = checkPhone($billingphone, $billingCountryCode);
         $shippingphone = $shippingAddress->getTelephone();
         $shippingCountryCode = array_search($shippingAddress->getCountry(), $countryToCode);
         $shippingphone = checkPhone($shippingphone, $shippingCountryCode);
         // get tracking information
         if (TRACKINGISENABLED) {
             $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')->setOrderFilter($order)->load();
             foreach ($shipmentCollection as $shipment) {
                 if ($shipment->getAllTracks()) {
                     $trackinginformation .= ' ' . Mage::helper('twiliosmsbridge')->__('Tracking #');
                 }
                 foreach ($shipment->getAllTracks() as $tracknum) {
                     $trackinginformation .= ' ' . $tracknum->getTitle() . ': ' . $tracknum->getNumber() . ' ';
                 }
             }
         }
         // end tracking information
         // Instantiate a new Twilio Rest Client
         $client = new Services_Twilio(ACCOUNTSID, AUTHTOKEN);
         $from = preg_replace("/[^0-9]/", "", TWILIONUMBER);
         //create recipients list
         $recipients = array();
         if (ALLOWSPECIFIC && in_array($billingAddress->getCountry(), $allowCountries) || !ALLOWSPECIFIC) {
             if (SENDTO == 'billing' || SENDTO == 'both') {
                 if (!in_array($recipients, $billingphone)) {
                     array_push($recipients, $billingphone);
                 }
             }
         }
         if (ALLOWSPECIFIC && in_array($shippingAddress->getCountry(), $allowCountries) || !ALLOWSPECIFIC) {
             if (SENDTO == 'shipping' || SENDTO == 'both') {
                 if (!in_array($recipients, $shippingphone)) {
                     array_push($recipients, $shippingphone);
                 }
             }
         }
         $body = $store->getName() . " " . Mage::helper('twiliosmsbridge')->__('shipped order #') . $orderNumber . $trackinginformation;
         foreach ($recipients as $recipient) {
             try {
                 $recipient = preg_replace("/[^0-9]/", "", $recipient);
                 // Send a new outgoing SMS */
                 $client->account->sms_messages->create($from, $recipient, $body);
                 $object = Mage::getModel('twiliosmsbridge/twiliosmsbridge');
                 $object->setTitle($orderNumber . 'sent to: ' . $recipient);
                 $object->setContent($body);
                 $object->setCreatedTime(now());
                 $object->save();
             } catch (Exception $e) {
             }
         }
     }
 }
예제 #8
0
 if ($_GET['type'] != 'phone' && $_GET['type'] != 'checkusername') {
     echo getJsonResponse(2, "get参数错误", null);
     exit;
 }
 $db = Db::getInstance(array('autocommit' => false));
 try {
     $db->connect();
 } catch (Exception $e) {
     echo getJsonResponse(1, '数据库连接错误', null);
     Log::error_log("数据库连接错误");
     exit;
 }
 $db->commit();
 if ($_GET['type'] == 'phone') {
     if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['sex']) && isset($_POST['phone']) && isset($_POST['school_id'])) {
         if (checkPhone($db, $_POST['phone'])) {
             echo getJsonResponse(2, 'phone已经注册过', null);
             $db->close();
             exit;
         }
         $_POST['username'] = trim($_POST['username']);
         if (strlen($_POST['username']) < 5 || strlen($_POST['username']) > 15) {
             echo getJsonResponse(2, 'username长度错误', null);
             $db->close();
             exit;
         }
         if (checkUserName($db, $_POST['username'])) {
             echo getJsonResponse(2, 'username已经注册过', null);
             $db->close();
             exit;
         }
예제 #9
0
  <input type="submit">
 </form>

<p>
	<a href="../home/home.html">Back To Home</a>
</p>

<?php 
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    # collect input data
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    if (!empty($phone) && !empty($email)) {
        $email = prepareInput($email);
        $phone = prepareInput($phone);
        if (checkPhone($phone) && checkEmail($email)) {
            error_reporting(E_ALL);
            $db_host = "localhost";
            $db_user = "******";
            $db_pass = "******";
            $db_name = "mysql";
            $con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
            // Check connection
            if (mysqli_connect_errno()) {
                echo "Failed to connect to MySQL: " . mysqli_connect_error();
            }
            $result = $con->query("SELECT * FROM MEMBERS WHERE Email='{$email}' AND Phone='{$phone}'");
            if (!$result) {
                die('Error: ' . mysqli_error($con));
            }
            $row = mysqli_fetch_assoc($result);
예제 #10
0
 function addContact()
 {
     $error = "";
     $contact = new Contact();
     if (isset($_POST['name']) && !empty($_POST['name'])) {
         $contact->c_name = $_POST['name'];
     } else {
         $error .= "Name ";
     }
     if (isset($_POST['email']) && !empty($_POST['email']) && checkEmail($_POST['email']) == true) {
         $contact->c_email = $_POST['email'];
     } else {
         $error .= "Email ";
     }
     if (isset($_POST['phone']) && checkPhone($_POST['phone']) == true) {
         $contact->c_phone = $_POST['phone'];
     } else {
         $error .= "Phone Number ";
     }
     if (isset($_POST['comment']) && !empty($_POST['comment'])) {
         $contact->c_comment = $_POST['comment'];
     } else {
         $error .= "No Comment ";
     }
     if ($error == "") {
         if ($contact->create()) {
             return 1;
         } else {
             return 2;
         }
     } else {
         return $error;
     }
 }