function formatProfessor($professor) { $professor = trim($professor); if ($professor == "STAFF") { return ""; } else { $profArray = explode(',', $professor); return ucname(trim($profArray[0])); } }
/** * Will be trigger, if call 'new class_name' * * @param string className **/ function loader($className) { //$util = new Util(); if ($className != 'JsonSerializable') { $className = ucname($className); $className = preg_replace('/_/', '-', $className); $fileName = PATH_BASE . str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php'; if (!empty($fileName)) { if (file_exists($fileName)) { include_once $fileName; } else { $route = new Route(); $route->redirect('/not-found'); } } } }
if (empty($errors)) { $username = $_POST['username_email']; $email = $_POST['username_email']; $password = $_POST['password']; $found_user = attempt_login($username, $password, $email); if ($found_user) { $user_id = $_SESSION["user_id"]; if ($_SESSION["user_type"] === "Admin" && $_SESSION["user_status"] === "Activated") { redirect("admin.php?id={$user_id}"); } else { $error_msg = "Sorry " . ucname($username) . ", your account is temporarily deactivated by the admin.<br>"; } if ($_SESSION["user_type"] === "Member" && $_SESSION["user_status"] === "Activated") { redirect("member.php?id={$user_id}"); } else { $error_msg = "Sorry " . ucname($username) . ", your account is temporarily deactivated by the admin.<br>"; } } else { if (!$found_user) { $error_msg = $_SESSION["error_msg"]; } } } } ?> <html> <body> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);
<?php /** * A PHP thing to convert the CityCycle XML into a really tiny but * non-standard JSON object. * I've abandoned this idea. */ function ucname($string) { $string = ucwords(strtolower($string)); foreach (array('-', '\'') as $delimiter) { if (strpos($string, $delimiter) !== false) { $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string))); } } return $string; } $cc = file_get_contents('citycycle.xml'); $cc = new SimpleXmlElement($cc); $out = array(); foreach ($cc->markers->marker as $marker) { $attr = $marker->attributes(); $out[] = array('n' => ucname($attr->name), 'ref' => (string) $attr->number, 'addr' => ucname($attr->address), 'lat' => (string) $attr->lat, 'lon' => (string) $attr->lng, 'open' => (string) $attr->open); } print json_encode($out);
$db->sfquery('SELECT * FROM login u JOIN info i ON u.user_id = i.user_id WHERE username = %s AND password = PASSWORD(%s)', array('username' => $_POST['username'], 'password' => $_POST['password'])); if ($db->numRows() > 0) { $db->fetchAssocRow(); $_SESSION['logged'] = true; $_SESSION['username'] = $row['username']; loggedIn(); } } catch (Exception $e) { echo $e->getMessage(); exit; } } if (isset($_POST['register'])) { $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $name = isset($_POST['name']) ? ucname($_POST['fullname']) : ''; $email = isset($_POST['email']) ? $_POST['email'] : ''; $hometown = isset($_POST['hometown']) ? $_POST['hometown'] : ''; $community = isset($_POST['city']) ? $_POST['city'] : ''; $gender = isset($_POST['gender']) ? $_POST['gender'] : ''; $bmonth = isset($_POST['bmonth']) ? $_POST['bmonth'] : ''; $bday = isset($_POST['bday']) ? $_POST['bday'] : ''; $byear = isset($_POST['byear']) ? $_POST['byear'] : ''; if (empty($community)) { $community = $hometown; } list($firstname, $middlename, $lastname) = split(' ', $name); if (!$lastname) { $lastname = $middlename; unset($middlename); }
protected static function processItemText($item) { $details = array(); if (preg_match('/Author\\:\\ \\;([^<]*)\\</', $item, $matches)) { $details['author'] = ucname(trim($matches[1])); } if (preg_match('/Edition\\:\\ \\;([^<]*)\\</', $item, $matches)) { $details['edition'] = trim($matches[1]); } if (preg_match('/src\\="(http[^"]+([X0-9]{10,13}|noBookImage)[^"]+?)"[^>]*?alt\\="([^"]+?)"/', $item, $matches)) { if (strpos($matches[1], 'noBookImage')) { $details['imageUrl'] = false; $details['isbn'] = null; } else { $details['imageUrl'] = trim($matches[1]); $details['isbn'] = Isbn::to13(Isbn::clean($matches[2])); } $details['title'] = titleCase(trim(html_entity_decode($matches[3]))); } $details['newPrice'] = $details['usedPrice'] = null; if (!strpos($item, 'Buy Digital') && preg_match('/buynewradio[^>]+?\\>\\s*?\\$([\\d\\.]+)/', $item, $matches)) { $details['newPrice'] = $matches[1]; } if (preg_match('/buyusedradio[^>]+?\\>\\s*?\\$([\\d\\.]+)/', $item, $matches)) { $details['usedPrice'] = $matches[1]; } if (preg_match('/ISBN:\\s*(?:\\ \\;)?(\\d{10,13})/', $item, $matches)) { $details['isbn'] = Isbn::to13(Isbn::clean($matches[1])); } // lowercase c in catEntry ensures that the rental item id is not selected, because it is like rentalCatEntry. // the new item id seems to always be exactly one less than the used // note: we don't use this as a unique identifier because we don't want to deal with which // is used and which is new, and because availability changes if (preg_match_all('/catEntryId_\\d+[^>]+?value\\="(\\d*)"/', $item, $matches)) { //$details['productId'] = count($matches[1] == 1) ? $matches[1][0] : call_user_func_array('min', $matches[1]); } $details['partNumber'] = null; $details['publisher'] = null; $details['isPackage'] = false; $details['components'] = array(); return $details; }
} else { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error = erreur('USER_VALID_EMAIL'); setFlash($error, "danger"); } else { if ($password != $repeatpassword) { $error = erreur('USER_SAME_PASSWORD'); setFlash($error, "danger"); } else { if (strlen(utf8_decode($password)) < 6) { $error = erreur('USER_PASSWORD_CARACT'); setFlash($error, "danger"); } else { /* Met en majuscule la 1ere lettre du prenom et nom */ $prenom = ucname($prenom); $nom = ucname($nom); /* Supprime accent etc.. pour le pseudo */ $nom_min = suppr_accents($nom); $prenom_min = suppr_accents($prenom); $pseudo = $prenom_min . "." . $nom_min; $prenomplusnom = $prenom . " " . $nom; try { /* On vérifie si pas déjà adresse mail */ $checkemail = $DB_con->prepare("SELECT * FROM users WHERE email=:email"); $checkemail->execute(array('email' => $email)); $row = $checkemail->fetch(PDO::FETCH_ASSOC); /* On vérifie si pas le même nom / prenom */ $checkuser = $DB_con->prepare("SELECT * FROM users WHERE prenomplusnom=:prenomplusnom"); $checkuser->execute(array('prenomplusnom' => $prenomplusnom)); $datedenaissance = $dobannee . "-" . $dobmois . "-" . $dobjour; $emailexist = $checkemail->rowCount();
error_reporting(0); require "functions.php"; require_once "databases.php"; navigation($user_id); $genderErr = $fnameErr = $lnameErr = $usernameErr = $emailErr = ""; $user_type = $gender = $fname = $lname = $username = $email = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["fname"])) { $errors["fnameErr"] = "First Name Is Required"; } else { $fname = test_input(ucname($_POST["fname"])); } if (empty($_POST["lname"])) { $errors["lnameErr"] = "Last Name Is Required"; } else { $lname = test_input(ucname($_POST["lname"])); // check if name only contains letters and whitespace if (!preg_match("/^[\\\\a-zA-Z\\']*\$/", $fname)) { $errors['fnameErr'] = "Only letters and white space allowed"; } } if (empty($_POST["id_no"])) { $errors["id_noErr"] = "ID Number Is Required"; } else { $id_no = test_input($_POST["id_no"]); // check if only contains numbers if (filter_var($id_no, FILTER_VALIDATE_INT) === false) { $errors["id_noErr"] = "Only Numbers Are Allowed"; } } if (empty($_POST["gender"])) {
<?php /** * A PHP thing to convert the CityCycle XML into a really tiny but * non-standard JSON object. * I've abandoned this idea. */ function ucname($string) { $string = ucwords(strtolower($string)); foreach (array('-', '\'') as $delimiter) { if (strpos($string, $delimiter) !== false) { $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string))); } } return $string; } $cc = file_get_contents('citycycle.xml'); $cc = new SimpleXmlElement($cc); $out = array('type' => 'FeatureCollection', 'features' => array()); foreach ($cc->markers->marker as $marker) { $attr = $marker->attributes(); $out['features'][] = array('id' => (string) $attr->number, 'type' => 'Feature', 'geometry' => array('type' => 'Point', 'coordinates' => array((double) $attr->lng, (double) $attr->lat)), 'properties' => array('description' => ucname($attr->address), 'category' => 'citycycle')); } print json_encode($out);
<html> <body> <p>Welcome</p> <?php $dbErr = ""; $db = ""; require "functions.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["db"])) { $dbErr = "Database Name is required <br>"; } else { $db = test_input(ucname($_POST["db"])); } } ?> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?> "> Database Name: <br> <?php echo $dbErr; ?> <br> <input type="text" name="db" value="<?php echo $db; ?> "> <input type="submit" name="submit" value="Install">
/** * @return an array of item metadata: productId, partNumber, isbn, title, author, * edition, publisher, imageUrl, usedPrice, newPrice, required */ protected static function getItemMetadata($itemText) { $details = array(); $productId = $partNumber = $isbn = $title = $author = $edition = $publisher = ""; $usedPrice = $newPrice = $required = $isPackage = $isComponent = ""; if (preg_match("/productId\\=(.+?)&/", $itemText, $matches)) { $details['productId'] = trim($matches[1]); } if (preg_match("/partNumber\\=(.+?)&/", $itemText, $matches)) { $details['partNumber'] = rtrim($matches[1], "&"); } if (preg_match("/ISBN\\:\\<\\/span\\>.+?(\\d+).+?\\</s", $itemText, $matches)) { $isbn = trim($matches[1]); $isbn = Isbn::validate($isbn) ? $isbn : ""; if ($isbn[0] == '2') { $isbn = ""; } $details['isbn'] = $isbn; } if (preg_match("/\\d{5}'\\stitle\\=\"(.+?)\"\\>.+?\\<img/s", $itemText, $matches)) { $details['title'] = titleCase(trim(htmlspecialchars_decode($matches[1], ENT_QUOTES))); } if (preg_match("/\\<span\\>Author:.*?\\<\\/span\\>(.+?)\\<\\/li/s", $itemText, $matches)) { $author = ucname(trim($matches[1])); $details['author'] = is_numeric($author) ? "" : $author; } if (preg_match("/Edition:\\<\\/span\\>(.+?)\\<br/", $itemText, $matches)) { $details['edition'] = strtolower(trim($matches[1])); } if (preg_match("/Publisher:\\<\\/span\\>(.+?)\\<br/", $itemText, $matches)) { $details['publisher'] = titleCase(trim($matches[1])); } if (preg_match("/Used.+?(\\d{1,3}\\.\\d{2})/s", $itemText, $matches)) { $details['usedPrice'] = $matches[1]; } if (preg_match("/New.+?(\\d{1,3}\\.\\d{2})/s", $itemText, $matches)) { $details['newPrice'] = $matches[1]; } if (strpos($itemText, "The price of the textbook is not yet available")) { $details['newPrice'] = $details['usedPrice'] = 0; } if (!$details['title'] && !$details['author']) { return false; } $details['imageUrl'] = ""; // todo $options = array("REQUIRED\\sPACKAGE", "RECOMMENDED\\sPACKAGE", "REQUIRED", "RECOMMENDED", "PACKAGE\\sCOMPONENT", "GO\\sTO\\sCLASS FIRST", "BOOKSTORE\\sRECOMMENDED"); preg_match("/" . implode('|', $options) . "/", $itemText, $matches); $required = trim($matches[0]); $details['isPackage'] = $required == "REQUIRED PACKAGE" || $required == "RECOMMENDED PACKAGE"; $details['isComponent'] = $required == "PACKAGE COMPONENT"; if ($required == "REQUIRED PACKAGE" || $required == "REQUIRED") { $required = SectionHasItem::REQUIRED; } else { if ($required == "RECOMMENDED PACKAGE" || $required == "RECOMMENDED") { $required = SectionHasItem::RECOMMENDED; } else { if ($required == "GO TO CLASS FIRST") { $required = SectionHasItem::GO_TO_CLASS_FIRST; } else { if ($required == "BOOKSTORE RECOMMENDED") { $required = SectionHasItem::BOOKSTORE_RECOMMENDED; } else { $required = SectionHasItem::REQUIRED; } } } } $details['requiredStatus'] = $required; return $details; }