Skip to content
Browse files

Deleted Files manually

  • Loading branch information...
1 parent 7752195 commit 00b0f2fbc8e3a97e1cb43e8c466338ab599876cb @joshmfrankel committed Mar 5, 2012
View
146 classes/Validator/AbstractValidator.php
@@ -1,146 +0,0 @@
-<?php
-
-/**
- * Abstract Validator
- *
- * An abstract base class for all validator classes
- *
- * @author Josh Frankel <joshmfrankel@gmail.com>
- * @abstract
- * @copyright 2011-2012
- * @version 0.8
- */
-abstract class AbstractValidator {
-
- /**
- * validate abstract function
- *
- * @abstract
- * @param mixed $val The input value
- * @return bool
- */
- public abstract function validate($val);
-
- /**
- * sanitize abstract function
- *
- * @abstract
- * @param mixed $val The input value
- * @return mixed
- */
- public abstract function sanitize($val);
-
-
-
- ///////////////////
- // COMMON METODS //
- ///////////////////
-
- /**
- * Factory Pattern method
- *
- * Instantiates new validator objects based on the type
- * of input to validate
- *
- * @static
- * @param string $className The class name or type of input to validate
- * @return Validator class of specified type
- */
- public static function factory($className) {
-
-
- switch ($className) {
-
- case 'text':
-
- $className = 'String_Validator';
-
- break;
- case 'email':
-
- $className = 'Email_Validator';
-
- break;
-
- case 'tel':
-
- /**
- * @todo Add a class for telephone numbers.
- * Should extend Number_Validator
- */
- $className = 'String_Validator';
-
- break;
-
- case 'radio':
- case 'checkbox':
-
- /**
- * @todo Add a class for checkboxes and radio buttons
- */
- $className = 'String_Validator';
-
- break;
-
- case 'range':
- case 'number':
-
- $className = 'Number_Validator';
-
- break;
-
- default:
-
- break;
- }
-
-
- return new $className;
- }
-
- /**
- * isEqual
- *
- * @param string $val1 The first value to evaluate
- * @param string $val2 The second value to evaluate
- * @return boolean
- */
- public function isEqual($val1, $val2) {
- return ($val1 === $val2 ? TRUE : FALSE);
- }
-
- /**
- * validatedByRegex
- *
- * @param string $regex The regex string to match the value against
- * @param string $val The input string
- * @return int preg_match will return 1 on match or 0 on no match
- */
- public function validateByRegex($regex, $val) {
- return preg_match($regex, $val);
- }
-
- /**
- * isGreaterThan
- *
- * @param int $min The minimum accepted value
- * @param int $val The input value
- * @return boolean
- */
- public function isGreaterThan($min, $val) {
- return ($val > $min ? TRUE : FALSE);
- }
-
- /**
- * isGreaterThan
- *
- * @param int $max The maximum accepted value
- * @param int $val The input value
- * @return boolean
- */
- public function isLessThan($max, $val) {
- return ($val < $max ? TRUE : FALSE);
- }
-}
-
-?>
View
24 classes/Validator/Email_Validator.php
@@ -1,24 +0,0 @@
-<?php
-
- /**
- * Email_Validator.php
- *
- * @author Josh Frankel
- * @version 0.1
- *
- **/
- class Email_Validator extends AbstractValidator{
-
-
- public function validate($val) {
- return filter_var($val, FILTER_VALIDATE_EMAIL);
- }
-
- public function sanitize($val) {
- return filter_var($val, FILTER_VALIDATE_EMAIL);
- }
-
-
- }
-
-?>
View
24 classes/Validator/Number_Validator.php
@@ -1,24 +0,0 @@
-<?php
-
- /**
- * Text_Validator.php
- *
- * @author Josh Frankel
- * @version 0.1
- *
- **/
- class Number_Validator extends AbstractValidator{
-
-
- public function validate($val) {
- return filter_var($val, FILTER_VALIDATE_INT);
- }
-
- public function sanitize($val) {
- return filter_var($val, FILTER_SANITIZE_NUMBER_INT);
- }
-
-
- }
-
-?>
View
24 classes/Validator/String_Validator.php
@@ -1,24 +0,0 @@
-<?php
-
- /**
- * Text_Validator.php
- *
- * @author Josh Frankel
- * @version 0.1
- *
- **/
- class String_Validator extends AbstractValidator{
-
-
- public function validate($val) {
- return (!is_null($val) && strlen($val) != 0 ? TRUE : FALSE);
- }
-
- public function sanitize($val) {
- return filter_var($val, FILTER_SANITIZE_STRING);
- }
-
-
- }
-
-?>
View
81 classes/Validator/Validator.php
@@ -1,81 +0,0 @@
-<?php
-
-/**
- * Validator
- *
- * A validator class for html5 forms
- *
- * @author Joshua Frankel <joshmfrankel@gmail.com>
- * @see http://www.joshmfrankel.com
- * @copyright 2012
- * @version 0.1a
- *
- */
-class Validator {
-
-
- /**
- * Constructor
- */
- public function __construct() {
-
- }
-
- /**
- * Number Validation and Sanitization
- *
- * Returns a boolean value to show if TRUE or FALSE
- *
- * @param int $val
- * @return boolean
- */
- public function validateNumber($val) {
- return filter_var($val, FILTER_VALIDATE_INT);
- }
-
- public function validateMinNumber($val, $min) {
- return ($val > $min ? TRUE : FALSE);
- }
- public function validateMaxNumber($val, $max) {
- return ($val < $max ? TRUE : FALSE);
- }
-
- public function sanitizeNumber($val) {
- return filter_var($val, FILTER_SANITIZE_NUMBER_INT);
- }
-
- /**
- * Email Validation and Sanitization
- *
- * @param int $val
- * @return boolean
- */
- public function validateEmail($val) {
- return filter_var($val, FILTER_VALIDATE_EMAIL);
- }
-
- public function sanitizeEmail($val) {
- return filter_var($val, FILTER_VALIDATE_EMAIL);
- }
-
- /**
- * Text Validation and Sanitization
- * @note yes they use the same method for a reason
- */
- public function validateText($val) {
- return filter_var($val, FILTER_SANITIZE_STRING);
- }
-
- public function sanitizeText($val) {
- return filter_var($val, FILTER_SANITIZE_STRING);
- }
-
- /**
- * @todo Compare function for passwords
- * and hidden pasphrases
- */
-
-
-}
-
-?>
View
190 classes/Validator/class.form_input.php
@@ -1,190 +0,0 @@
-<?php
-
-/**
- * Form Input class
- *
- * A validator class for html5 forms
- *
- * @author Joshua Frankel <joshmfrankel@gmail.com>
- * @see http://www.joshmfrankel.com
- * @copyright 2012
- * @version 0.1a
- *
- */
-
-class Form_Input extends Validator{
-
- /**
- * Private Variables
- */
- private $_referer;
- private $_inputArray = array();
- private $_html;
- private $_index;
-
- /**
- * Constructor
- */
- public function __construct() {
- require_once('plugins/phpSimpleDom/simple_html_dom.php');
-
- $this->_referer = $_SERVER['HTTP_REFERER'];
- $this->_html = new simple_html_dom();
- $this->_html->load_file($this->_referer);
-
- $this->buildInput();
- //$this->start();
- }
-
- /**
- * buildInputArray method
- *
- * Builds an array of data from the previously submitted form
- * @return void
- *
- * @todo add image support
- */
- private function buildInput(){
-
- $x = 0;
-
- foreach($this->_html->find('input[type!=submit]') as $element) {
-
- /**
- * @todo find better way of filtering both submit and hidden fields
- */
- if($element->type != 'hidden') {
-
- //Force the required attribute to contain a value
- if(!$element->required) {
- $element->required = FALSE;
- }
-
- //Build the array with proper attributes
- $this->_inputArray[$x]['name'] = $element->name;
- $this->_inputArray[$x]['type'] = $element->type;
-
- /**
- * Special cases for the number and range types
- */
- if($element->type == 'number' || $element->type == 'range'){
- if($element->min){
- $this->_inputArray[$x]['min'] = $element->min;
- }
-
- if($element->max){
- $this->_inputArray[$x]['max'] = $element->max;
- }
- }
-
- /**
- * Regex pattern attribute
- */
- if($element->pattern) {
- $this->_inputArray[$x]['pattern'] = $element->pattern;
- }
-
- /**
- * HTML5 data attribute
- * data-validate contains a special validator parameter
- */
- if(isset($element->attr['data-validate']))
- $this->_inputArray[$x]['special'] = $element->attr['data-validate'];
-
- /**
- * Other Attributes
- */
- $this->_inputArray[$x]['value'] = $_POST[$element->name];
- $this->_inputArray[$x]['required'] = $element->required;
-
- $x++;
- }
- }
-
- //set the index based off the number of iterations
- $this->setIndex();
-
- }
-
- private function setIndex() {
- $this->_index = count($this->_inputArray);
- }
-
- public function getRawResults() {
- return $this->_inputArray;
- }
-
- public function getErrors() {
-
- }
-
- public function start() {
-
-
- $Validator = new Validator();
-
- for($i = 0; $i < $this->_index; $i++) {
- switch ($this->_inputArray[$i]['type']) {
-
- case 'text':
- $this->_inputArray[$i]['isValid'] = $Validator->validateText($this->_inputArray[$i]['value']);
-
- if($this->_inputArray[$i]['isValid']) {
- $this->_inputArray[$i]['sanitizedValue'] = $Validator->sanitizeText($this->_inputArray[$i]['value']);
- }
-
- break;
-
- case 'email':
- $this->_inputArray[$i]['isValid'] = $Validator->validateEmail($this->_inputArray[$i]['value']);
-
- if($this->_inputArray[$i]['isValid']) {
- $this->_inputArray[$i]['sanitizedValue'] = $Validator->sanitizeEmail($this->_inputArray[$i]['value']);
- }
-
- break;
-
- case 'tel':
- /**
- * @todo add regex for telephone validation
- */
- break;
-
- case 'number':
-
- /**
- * @todo if first digit is 0 then trim
- */
- $this->_inputArray[$i]['isValid'] = $Validator->validateNumber($this->_inputArray[$i]['value']);
-
- //if there is a min attribute and the isValid flag is not FALSE
- if($this->_inputArray[$i]['min'] && $this->_inputArray[$i]['isValid']) {
- $this->_inputArray[$i]['isValid'] = $Validator->validateMinNumber($this->_inputArray[$i]['value'], $this->_inputArray[$i]['min']);
- }
-
- //if there is a max attribute and the isValid flag is not FALSE
- if($this->_inputArray[$i]['max'] && $this->_inputArray[$i]['isValid']) {
- $this->_inputArray[$i]['isValid'] = $Validator->validateMaxNumber($this->_inputArray[$i]['value'], $this->_inputArray[$i]['max']);
- }
-
- /**
- * SANITIZE
- * if the value is valid then sanitize the input
- * and store it in the sanitizedValue element
- */
- if($this->_inputArray[$i]['isValid']) {
- $this->_inputArray[$i]['sanitizedValue'] = $Validator->sanitizeNumber($this->_inputArray[$i]['value']);
- }
- break;
-
- default:
- # code...
- break;
- }
-
- }
- }
-
-}
-
-?>
View
23 demo.php
@@ -1,23 +0,0 @@
-<?php
-
- function __autoload($class_name) {
- require_once 'classes/Validator/' . $class_name . '.php';
- }
-
- $input = new String_Validator();
-
- $var = NULL;
- $output = $input->validate($var);
-
- if($output) {
- echo 'TRUE';
- } else {
- echo 'FALSE';
- }
-
- echo '<pre>';
- print_r($output);
- echo '</pre>';
-
-
-?>
View
74 index.html
@@ -1,74 +0,0 @@
-<<<<<<< HEAD
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <link rel="stylesheet" media="all" type="text/css" href="css/stylesheets/style.css"/>
- <title></title>
- </head>
- <body>
- <script type="text/javascript">
- alert('NO JS');
- </script>
-
- <section>
- <h1>This is the title</h1>
- <p>
- A paragraph of descriptive text for this section. It is very interesting.
- A paragraph of descriptive text for this section. It is very interesting.
- A paragraph of descriptive text for this section. It is very interesting.
- A paragraph of descriptive text for this section. It is very interesting.
- </p>
- </section>
-
-
- <!-- Form test -->
- <form name="testForm" action="doValidate.php" method="post">
-
- <label for="formFirstName">First Name: </label>
- <input type="text" name="firstname" id="formFirstName"/>
-
- <label for="formLastName">Last Name: </label>
- <input type="text" name="lastname" id="formLastName" />
-
- <input type="hidden" name="hiddenField" id="formHidden" value="hid"/>
-
- <label for="formPhone">Phone: </label>
- <input type="tel" name="phone" id="formPhone" required/>
-
- <label for="formCountry">Country: </label>
- <input type="text" name="country" id="formCountry" pattern="[A-z]{3}" />
-
- <label for="formZip">Zip Code: </label>
- <input type="number" name="zip" id="formZip" min="10000" max="99999" class="zipcode" required/>
-
- <label for="formGender">Gender: </label>
- <input type="checkbox" name="gender" id="formGender"/>
-
- <input type="submit" name="formSubmit" />
- </form>
-
-
- <!-- Float image to right of text -->
- <section style="width:600px;">
- <p>
- <img style="float:right;" alt="image" src="http://www.mediatehawaii.org/wp-content/uploads/placeholder.jpg" width="200"/>
- Duis aute irure dolor sed do eiusmod tempor incididunt in reprehenderit in voluptate. Cupidatat non proident, ut labore et dolore magna aliqua. Sunt in culpa quis nostrud exercitation excepteur sint occaecat. Mollit anim id est laborum.
- </p>
- </section>
-
-
- </body>
-</html>
-=======
-<?php
-
- function __autoload($class_name) {
- require_once 'classes/Validator/class.' . $class_name . '.php';
- }
-
- $input = new String_Validator();
- $input->isEqual('hi', 'hi');
-
-?>
->>>>>>> c8057618aba53434365656a5792a09ddf3d1a617

0 comments on commit 00b0f2f

Please sign in to comment.
Something went wrong with that request. Please try again.