function checkData($address_id, $firstName, $lastName, $birthday, $email, $street, $town, $state, $tell, $zipcode) { $e_messageRaw = array(); $emailRegex = '/^[a-zA-Z0-9$]+[@]{1}[a-zA-Z]+[\\.]{1}[a-zA-Z]{2,3}$/'; $tellRegex = '/^[(]?[1]?[0-9]{3}[)]?[-]?[0-9]{3}[-]?[0-9]{4}$/'; $zipRegex = '/^[0-9]{5}$/'; $variables = array("Group ID" => $address_id, "First name" => $firstName, "Last name" => $lastName, "Birthday" => $birthday, "Street" => $street, "Town" => $town, "State" => $state); foreach ($variables as $key => $variable) { $e_messageRaw[] = checkEmpty($variable, $key); } if (!preg_match($emailRegex, $email)) { $e_messageRaw[] = "Email not valid!"; } if (!preg_match($tellRegex, $tell)) { $e_messageRaw[] = "Telephone is not valid!"; } if (!preg_match($zipRegex, $zipcode)) { $e_messageRaw[] = "Zipcode isn't valid!"; } $e_message = implode(', ', array_filter($e_messageRaw)); if (isset($e_message)) { return $e_message; } return false; }
function errorOnEmpty($item, $name) { global $event_tools_replace_on_data_error; if (checkEmpty($item)) { if ($event_tools_replace_on_data_error) { return "<span class=\"et-error-missing\">(" . $name . ")</span>"; } else { return "<span class=\"et-error-missing\">" . $item . "</span>"; } } else { return $item; } }
function validateTourdates($form) { global $db; if (checkEmpty($form['venue_name'])) { $msg = str_replace('field', _VENUE, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tour_city'])) { $msg = str_replace('field', _CITY, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tour_state'])) { $msg = str_replace('field', _LBL_STATE, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tour_country'])) { $msg = str_replace('field', _LBL_COUNTRY, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tourdate'])) { $msg = str_replace('field', _LBL_START_DATE, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tourdate'])) { $msg = _ALRT_SEL_STARTDATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } else { $showdate = validateDate($form['tourdate']); if ($showdate !== true) { $msg = $showdate . ' ' . _LBL_FOR . ' ' . _LBL_START_DATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (compareDate($form['tourdate'], date('m/d/Y'), 1)) { $msg = _ALRT_VALID_TOURDATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } } $date = getYearMonthDateSearch($form['tourdate'], "/", "-"); if (isset($form['tourdate_id'])) { $sql = 'SELECT AF_TOURDATE_ID FROM xebura_TOURDATE WHERE AF_TOURDATE_ARTIST_ID = \'' . $_SESSION['User_Account_Id'] . '\' AND (AF_TOURDATE_VENUE_ID = \'' . $form['venue'] . '\' OR (AF_TOURDATE_VENUE_NAME = \'' . $form['venue_name'] . '\' AND AF_TOURDATE_VENUE_CITY = \'' . $form['tour_city'] . '\' AND AF_TOURDATE_VENUE_STATE = \'' . $form['tour_state'] . '\' AND AF_TOURDATE_VENUE_COUNTRY = \'' . $form['tour_country'] . '\')) AND AF_TOURDATE_STARTDATE = \'' . $date . '\' AND AF_ARTIST_DISCOG_ID != \'' . $form['tourdate_id'] . '\''; } else { $sql = 'SELECT AF_TOURDATE_ID FROM xebura_TOURDATE WHERE AF_TOURDATE_ARTIST_ID = \'' . $_SESSION['User_Account_Id'] . '\' AND (AF_TOURDATE_VENUE_ID = \'' . $form['venue'] . '\' OR (AF_TOURDATE_VENUE_NAME = \'' . $form['venue_name'] . '\' AND AF_TOURDATE_VENUE_CITY = \'' . $form['tour_city'] . '\' AND AF_TOURDATE_VENUE_STATE = \'' . $form['tour_state'] . '\' AND AF_TOURDATE_VENUE_COUNTRY = \'' . $form['tour_country'] . '\')) AND AF_TOURDATE_STARTDATE = \'' . $date . '\''; } if ($db->query_affected_rows($sql) > 0) { $msg = _CHECK_DUPLICATE_TOURDATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } return true; }
echo '<center><span style="color:red;font-size:15pt">Invalid Email ID! Please Enter Again.</span></center>'; include "Register.html"; exit; } } } } } //Function to save entered values to database function saveToDB() { @mysql_connect("localhost", "root", "root") or die("Error connecting"); @mysql_select_db("userinfo") or die("Db not opened"); $Dname = $_POST['Dname']; $Dage = $_POST['Dage']; $Dgroup = $_POST['Dgroup']; $Daddress = $_POST['Daddress']; $Dcontact = $_POST['Dcontact']; $Demail = $_POST['Demail']; $Dpassword = md5($_POST['Dpassword']); $query = "\r\nINSERT INTO `userinfo`.`general` (\r\n`UserID` ,\r\n`Name` ,\r\n`Age` ,\r\n`BGroup` ,\r\n`Address` ,\r\n`Contact` ,\r\n`Email` ,\r\n`Password`\r\n)\r\nVALUES (\r\nNULL , '" . $Dname . "' , '" . $Dage . "' , '" . $Dgroup . "' , '" . $Daddress . "' , '" . $Dcontact . "' , '" . $Demail . "' , '" . $Dpassword . "');\r\n"; if (mysql_query($query)) { echo '<span style="font-size:20px">Thank You for Your Registration! Please Click Below To Login.<br>'; echo '<a href="Login.php">Click here to Login</a></span>'; } else { echo "An error occured while registration. Please try again."; } } checkEmpty(); validate(); saveToDB();
<!DOCTYPE html> <!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]--> <!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Dark Login Form</title> <link rel="stylesheet" href="css/style.css" type="text/css"> <!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> </head> <body> <?php if (isset($_POST["submit"])) { if (checkEmpty($_POST["user"]) || checkEmpty($_POST["pass"])) { // kiểm tra nếu rỗng thì khởi tạo biến để báo nhập username và password vào ngay tại input $error1 = 'placeholder="Please enter your username"'; $error2 = 'placeholder="Please enter your password"'; } elseif (checkLength($_POST["user"], 4, 10) || checkLength($_POST["pass"], 4, 10)) { // kiểm tra độ dài ký tự nếu quá ngắn hoặc quá dài thì khởi tạo biến để báo ngay tại input $error3 = 'placeholder="U must be between 4 and 10 characters"'; $error4 = 'placeholder="P must be between 4 and 10 characters"'; } else { $user = $_POST["user"]; $pass = md5($_POST["pass"]); // mã hóa password để đảm bảo bảo mật } if (isset($user) && isset($pass)) { $sql = 'SELECT * FROM thanh_vien WHERE tai_khoan = "' . $user . '" AND mat_khau = "' . $pass . '"'; // truy vấn
function updateAccountData() { if (checkEmpty()) { checkPassword(); } }
function compareDate($date1, $date2, $check_equal = 0) { if (!checkEmpty($date1) && !checkEmpty($date2)) { $date1Array = explode('/', $date1); $date2Array = explode('/', $date2); $date1 = $date1Array[2] . '-' . $date1Array[0] . '-' . $date1Array[1]; $date2 = $date2Array[2] . '-' . $date2Array[0] . '-' . $date2Array[1]; if ($check_equal == 1) { if ($date1 <= $date2) { return true; } else { return false; } } else { if ($date1 < $date2) { return true; } else { return false; } } } }
break; default: die('Unknown error'); break; } return $output; } $data = decodeJSON($data); // check we have everything function checkEmpty($name, $variable) { if (empty($variable)) { die("Variable " . $name . " has not been set!"); } } checkEmpty("root", $data); // standalone data if (empty($data["clockspeed"])) { $data["clockspeed"] = "0"; } if (empty($data["executable"])) { $data["executable"] = "unknown"; } if (empty($data["numcores"])) { $data["numcores"] = "0"; } // operating system data if (empty($data["OS"])) { $data["OS"] = "unknown"; } if (empty($data["platform"])) {
</h1> </div> </div> <?php $cur_date = date('Y'); if (isset($_POST['step1'])) { if (isset($_POST["annee"]) && !empty($_POST["annee"])) { $annee = $_POST["annee"]; } } if (isset($_POST['ajout_epreuve'])) { // Tableau des variables a verifier $checkList = array($_POST["ville_d"], $_POST["ville_a"], $_POST["distance"], $_POST["code_tdf_d"], $_POST["code_tdf_a"], $_POST["jour"], $_POST["cat_code"]); // Vérification vide if (checkEmpty($checkList)) { $_SESSION['flash'] = 'Tout les champs doivent etre remplis !'; header('location: ajout_epreuve.php'); } $ville_d = $_POST["ville_d"]; $ville_a = $_POST["ville_a"]; // Mise en forme des noms $ville_d = traitement_nom($ville_d); $ville_a = traitement_nom($ville_a); // Tableau verif des noms $checkList = array($ville_d, $ville_a); if (checkName($checkList)) { $_SESSION['flash'] = 'Les villes de départ et d\'arrivée sont mal écrites'; header('location: ajout_epreuve.php'); } $annee = $_POST["annee"];
} if ($cont == true) { continue; } $query = 'INSERT INTO recalls ( recall_number, year, manufacturer_recall_number, category_en, category_fr, make, model, units_affected, system_type_en, system_type_fr, notification_type_en, notification_type_fr, comment_en, comment_fr) VALUES (' . checkEmpty($deeper[0]) . ', ' . checkEmpty($deeper[1]) . ', "' . checkEmpty($deeper[2]) . '", "' . checkEmpty($deeper[3]) . '", "' . checkEmpty($deeper[4]) . '", "' . checkEmpty($deeper[5]) . '", "' . checkEmpty($deeper[6]) . '", ' . checkEmpty($deeper[7]) . ', "' . checkEmpty($deeper[8]) . '", "' . checkEmpty($deeper[9]) . '", "' . checkEmpty($deeper[10]) . '", "' . checkEmpty($deeper[11]) . '", "' . checkEmpty($deeper[12]) . '", "' . checkEmpty($deeper[13]) . '");'; // mysqli_query($db, $query); //check if any users have new vehicles added and send them a notification $query = 'SELECT * FROM users INNER JOIN user_vehicles ON users.id = user_vehicles.user_id WHERE user_vehicles.deleted = 0;'; $result = mysqli_query($db, $query); while ($row = mysqli_fetch_assoc($result)) { if (strtolower($row['year']) == strtolower($deeper[1]) && strtolower($row['make']) == strtolower($deeper[5]) && strtolower($row['model']) == strtolower($deeper[6])) { $msg = 'Hello ' . $row['username'] . ', your ' . $row['year'] . ' ' . $row['make'] . ' ' . $row['model'] . ' has been associated with a recall'; echo 'trying to send: ' . $msg; $message = array(); $reg_id = array(); $message['m'] = '{"greetMsg":"' . $msg . '"}'; $reg_id[0] = $row['push_id']; sendPushNotificationToGCM($reg_id, $message); // In case any of our lines are larger than 70 characters, we should use wordwrap() $msg = wordwrap($msg, 70, "\r\n");