$thedomain = "https://healthy-living.org"; $dbh=mysqli_connect ("localhost", "mylargi_yes", "outwest1@3$", "mylargi_mylargi") or die ('I cannot connect to the database.'); function is_email_valid($email) { return (!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email)) ? FALSE : TRUE; } function stripltb ($s) { trim ($s); return strlen($s); } function quote_smarts($value) { global $dbh; return $value = "'" . mysqli_real_escape_string($dbh,$value) . "'"; } function quote_smartn($value) { if (is_numeric($value)) return $value; else return 0; } $ip= $_SERVER['REMOTE_ADDR']; // if this ip has entered this page more than seven times in the last 10 minutes... then ignore $thetime = time() - 600; $query = "DELETE FROM `applications_last_10 minutes` WHERE thetime < '$thetime'"; mysqli_query ($dbh,$query); $thetime +=600; $query = "SELECT `ip`, `attempts`, `thetime` FROM `order_inserts_last_10 minutes` WHERE ip = '$ip'"; $searchresult = mysqli_query ($dbh,$query); if (mysqli_num_rows($searchresult)) { $row = mysqli_fetch_assoc($searchresult); $attempts = $row['attempts']; if ($attempts >= 8) exit(0); if ($attempts >= 4) send_mail ('MyLarginine', 'info@mylarginine.com', 'Kent Hinkson', 'kent@hinksons.net', "$attempts wholesale apply attempts", "ip ($ip) has wholesale applied too many times"); $attempts+=1; $query = "UPDATE `applications_last_10 minutes` SET attempts='$attempts',thetime='$thetime' where ip='$ip'"; mysqli_query($dbh,$query); } else { $query = "INSERT INTO `applications_last_10 minutes`(`ip`, `attempts`, `thetime`) VALUES ('$ip',1,'$thetime')"; mysqli_query($dbh,$query); } // get input $sub = $ses_tld = $_GET['ses_tld']; $submit = $_POST['submit']; $ip= $_SERVER['REMOTE_ADDR']; //get selected items from cookie $items_array = explode (",",$myses_items); foreach ($items_array as $item) { if (preg_match("/^qty(.*):(.*)$/",$item,$matches)) $items[$matches[1]] = $matches[2]; } if ($submit == 'Continue') { $first = $_POST['first']; $last = $_POST['last']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $province = $_POST['province']; $zip = $_POST['zip']; $country = $_POST['country']; $email = $_POST['email']; $email2 = $_POST['email2']; $phone = $_POST['phone']; $phone2 = $_POST['phone2']; $error = 0; if (1 > strlen ($first)) {$first_error = "Required";$error = 1;} if (2 > strlen ($last)) {$last_error = "Required";$error = 1;} $email = trim($email); $email2 = trim ($email2); if ($email != $email2) {$email_error = $email2_error = "Email addresses don't match";$error = 1;} if (!is_email_valid($email)) {$email_error = "$email is invalid";$error = 1;} if (!is_email_valid($email2)) {$email2_error = "$email2 is invalid";$error = 1;} if (10 > strlen($phone)) {$phone_error = "Invalid";$error = 1;} $lenphone2 = strlen($phone2); if ($lenphone2 > 0 && 10 > $lenphone2) {$phone2_error = "Invalid";$error = 1;} if (4 > strlen($address1)) {$address1_error = 'Required';$error = 1;} if (3 > strlen($city)) {$city_error = 'Required';$error = 1;} if (strlen($state) < 1 && strlen($province) < 1) {$state_error = 'Required';$error = 1;} $sx = $state."_selected"; $$sx = 'selected'; // $sx = $country."_selected"; // $$sx = 'selected'; if (3 > strlen($zip) && (strlen($state) == 2 || strlen($province) > 1) ) {$zip_error = 'Required';$error = 1;} if ($shipping == '') {$shipping_error = 'Required';$error = 1;} //if (strpos('-AB-BC-MB-NB-NL-NS-NT-NU-ON-PE-QC-SK-YT',$state) > 0 && $country != 'c') { $country_error = 'Inconsistent with state'; $error = 1; } if ( ($shipping == 'c' && $country != 'c') || ($shipping != 'c' && $country == 'c') ) { $country_error = '
Shipping inconsistent for country. Either go back and select a different shipping option or select a different country.
'; $error = 1;} if ($error == 0) { trim ($password); if (strlen($password) > 1) { $query = sprintf("INSERT IGNORE INTO customers (first,last,address1,address2,city,state,province,zip,country,email,phone,phone2,tld,password) values (%s,%s,%s,%s,%s,%s,%s,'$zip',%s,%s,%s,%s,%s,%s)", quote_smart($first), quote_smart($last), quote_smart($address1), quote_smart($address2), quote_smart($city), quote_smart($state), quote_smart($province), quote_smart($zip,2), quote_smart($country), quote_smart($email), quote_smart($phone), quote_smart($phone2), quote_smart($ses_tld), quote_smart($password)); $result = mysql_query($query,$dbh); $customerno = mysql_insert_id(); if (mysql_errno()) { $errors .= "There was a database error: " .mysql_error().$query; echo $errors; exit(0); } } $query = sprintf("INSERT IGNORE INTO Orders (business_name,contact_name,address1,address2,city,state,province,zip,country,email,phone,mob_phone, items,shipping,ip,tld,referral,ctimestamp,referer,customerno) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,NOW(),%s,%s)", quote_smarts($business_name), quote_smarts($contact_name), quote_smarts($address1), quote_smarts($address2), quote_smarts($city), quote_smarts($state), quote_smarts($province), quote_smarts($zip), quote_smarts($country), quote_smarts($email), quote_smarts($phone), quote_smarts($phone2), quote_smarts($myses_items), quote_smarts($shipping), quote_smarts($ip), quote_smarts($ses_tld), quote_smarts($referral), quote_smarts($referer), quote_smartn($customerno)); if (!mysqli_query($dbh,$query)) { $errors .= "There was a database error: " .mysqli_error($dbh).$query; echo $errors; exit(0); } $orderno = mysqli_insert_id($dbh); if ($error == 0) { header ("Location: $thedomain/~mylargi/html/cc_info.php?on=$orderno"); exit(0); } } } // list items on page if (isset($items)) { ksort ($items); reset ($items); $tot_item_qty = 0; while (list ($item_num,$item_qty) = each ($items)) { if ($item_num > 0 && $item_qty > 0) { $query = "SELECT * from items where id=$item_num"; $iresult = mysqli_query($dbh,$query); if (mysqli_errno($dbh)) die (mysqli_error($dbh)); if (mysqli_num_rows($iresult)>0) $irow = mysqli_fetch_assoc($iresult); if ($item_num == 101 || $item_num == 103 || $item_num == 104) { if ($item_qty > 1) $price = 39.95; else $price = 44.95; } elseif ($item_num == 102) { if ($item_qty > 1) $price = 29.95; else $price = 34.95; } else $price = $irow['price']; $price = number_format($price,2); $total_amt = number_format(($item_qty*$price),2); $sub_total += $total_amt; $shipping_weight += ($irow['weight']*$item_qty); $description = $irow['description']; mysqli_free_result($iresult); $tot_item_qty += $item_qty; $item_table .= "$description$item_qty$$price$$total_amt"; } } if ($shipping == 's') {} elseif ($shipping == 'p') {$shipping_price = 8.50 + ($tot_item_qty*1.50);$shipping_name = 'U.S. Mail Priority Shipping';} elseif ($shipping == 'f') {$shipping_price = 10.00 + ($tot_item_qty*2.0);$shipping_name = 'Fedex Ground Shipping';} elseif ($shipping == 'x') {$shipping_price =40.00 + ($tot_item_qty*5.0);$shipping_name = 'U.S. Mail Express Shipping';} else {$shipping_price = '0.00'; $shipping_name = 'Global Shipping (Shipping/Handling Price to be Added Later)';} $shipping_price = number_format($shipping_price,2); if ($shipping_price == '0.00') $shipping_price = 'not calculated yet'; $item_table .= "$shipping_name$$shipping_price"; $sub_total += $shipping_price; $total_total = number_format($sub_total,2); $item_table .= "Total without sales tax (If applicable, will be added later.)
If you wish to change your order, please go back to the previous page and reselect your items to purchase.$$total_total"; } ?>