diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.dummyValid.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.dummyValid.php new file mode 100644 index 0000000..5b5038c --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.dummyValid.php @@ -0,0 +1,40 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * always return valid + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_dummyValid($value, $empty, &$params, &$formvars) { + return true; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isCCExpDate.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isCCExpDate.php new file mode 100644 index 0000000..355a148 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isCCExpDate.php @@ -0,0 +1,64 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + + /** + * test if a value is a valid credit card expiration date + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isCCExpDate($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + if(!preg_match('!^(\d+)\D+(\d+)$!', $value, $_match)) + return false; + + $_month = $_match[1]; + $_year = $_match[2]; + + if(strlen($_year) == 2) + $_year = substr(date('Y', time()),0,2) . $_year; + + $_month = (int) $_month; + $_year = (int) $_year; + + if($_month < 1 || $_month > 12) + return false; + if(date('Y',time()) > $_year) + return false; + + if(date('Y',time()) == $_year && date('m', time()) > $_month) + return false; + + return true; + +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isCCNum.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isCCNum.php new file mode 100644 index 0000000..35a13f4 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isCCNum.php @@ -0,0 +1,70 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + + /** + * test if a value is a valid credit card checksum + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isCCNum($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + // strip everything but digits + $value = preg_replace('!\D+!', '', $value); + + if (empty($value)) + return false; + + $_c_digits = preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY); + + $_max_digit = count($_c_digits)-1; + $_even_odd = $_max_digit % 2; + + $_sum = 0; + for ($_count=0; $_count <= $_max_digit; $_count++) { + $_digit = $_c_digits[$_count]; + if ($_even_odd) { + $_digit = $_digit * 2; + if ($_digit > 9) { + $_digit = substr($_digit, 1, 1) + 1; + } + } + $_even_odd = 1 - $_even_odd; + $_sum += $_digit; + } + $_sum = $_sum % 10; + if($_sum) + return false; + return true; + +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDate.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDate.php new file mode 100644 index 0000000..284768d --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDate.php @@ -0,0 +1,44 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid date (parsable by strtotime) + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isDate($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + $_ret = strtotime($value); + return $_ret != -1 && $_ret !== false; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateAfter.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateAfter.php new file mode 100644 index 0000000..324cbb0 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateAfter.php @@ -0,0 +1,61 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a date is later than another + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isDateAfter($value, $empty, &$params, &$formvars) { + + if(strlen($value) == 0) + return $empty; + + if(!isset($params['field2'])) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is missing."); + return false; + } + + $_date1 = strtotime($value); + $_date2 = strtotime($formvars[$params['field2']]); + + if($_date1 == -1 || !$_date1) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field' is not a valid date."); + return false; + } + if($_date2 == -1 || !$_date2) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is not a valid date."); + return false; + } + + return $_date1 > $_date2; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateBefore.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateBefore.php new file mode 100644 index 0000000..9a8b9b5 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateBefore.php @@ -0,0 +1,61 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a date is earlier than another + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isDateBefore($value, $empty, &$params, &$formvars) { + + if(strlen($value) == 0) + return $empty; + + if(!isset($params['field2'])) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is missing."); + return false; + } + + $_date1 = strtotime($value); + $_date2 = strtotime($formvars[$params['field2']]); + + if($_date1 == -1 || !$_date1) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field' is not a valid date."); + return false; + } + if($_date2 == -1 || !$_date2) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is not a valid date."); + return false; + } + + return $_date1 < $_date2; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateEqual.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateEqual.php new file mode 100644 index 0000000..ed0c1ac --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateEqual.php @@ -0,0 +1,61 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if two dates are equal + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isDateEqual($value, $empty, &$params, &$formvars) { + + if(strlen($value) == 0) + return $empty; + + if(!isset($params['field2'])) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is missing."); + return false; + } + + $_date1 = strtotime($value); + $_date2 = strtotime($formvars[$params['field2']]); + + if($_date1 == -1 || !$_date1) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field' is not a valid date."); + return false; + } + if($_date2 == -1 || !$_date2) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is not a valid date."); + return false; + } + + return $_date1 == $_date2; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateOnOrAfter.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateOnOrAfter.php new file mode 100644 index 0000000..ff94985 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateOnOrAfter.php @@ -0,0 +1,61 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a date is equal or later than another + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isDateOnOrAfter($value, $empty, &$params, &$formvars) { + + if(strlen($value) == 0) + return $empty; + + if(!isset($params['field2'])) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is missing."); + return false; + } + + $_date1 = strtotime($value); + $_date2 = strtotime($formvars[$params['field2']]); + + if($_date1 == -1 || !$_date1) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field' is not a valid date."); + return false; + } + if($_date2 == -1 || !$_date2) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is not a valid date."); + return false; + } + + return $_date1 >= $_date2; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateOnOrBefore.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateOnOrBefore.php new file mode 100644 index 0000000..0c1812d --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isDateOnOrBefore.php @@ -0,0 +1,61 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a date is equal or earlier than another + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isDateOnOrBefore($value, $empty, &$params, &$formvars) { + + if(strlen($value) == 0) + return $empty; + + if(!isset($params['field2'])) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is missing."); + return false; + } + + $_date1 = strtotime($value); + $_date2 = strtotime($formvars[$params['field2']]); + + if($_date1 == -1 || !$_date1) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field' is not a valid date."); + return false; + } + if($_date2 == -1 || !$_date2) { + trigger_error("SmartyValidate: [isDateAfter] parameter 'field2' is not a valid date."); + return false; + } + + return $_date1 <= $_date2; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isEmail.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isEmail.php new file mode 100644 index 0000000..3b8826a --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isEmail.php @@ -0,0 +1,56 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid e-mail address + * + * @param string $value + * the value being tested + * @param boolean $empty + * if field can be empty + * @param + * array params validate parameter values + * @param + * array formvars form var values + */ +function smarty_validate_criteria_isEmail($value, $empty, &$params, &$formvars) { + if (strlen($value) == 0) + return $empty; + + // in case value is several addresses separated by newlines + $_addresses = preg_split('![\n\r]+!', $value); + + foreach ($_addresses as $_address) { + $_is_valid = !(preg_match('!@.*@|\.\.|\,|\;!', $_address) || !preg_match('!^.+\@(\[?)[a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,}|[0-9]{1,})(\]?)$!', $_address)); + + if (!$_is_valid) + return false; + } + return true; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isEqual.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isEqual.php new file mode 100644 index 0000000..b83f24e --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isEqual.php @@ -0,0 +1,53 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid range + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isEqual($value, $empty, &$params, &$formvars) { + if(!isset($params['field2'])) { + trigger_error("SmartyValidate: [isEqual] parameter 'field2' is missing."); + return false; + } + if(strlen($value) == 0) + return $empty; + + if(strpos($params['field2'],'[') !== false && strpos($params['field2'],']') !== false) { + // pull apart array value + preg_match('!(\w+)\[(\w*)\]!',$params['field2'],$_match); + return $value == $formvars[$_match[1]][$_match[2]]; + } else { + return $value == $formvars[$params['field2']]; + } +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFileSize.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFileSize.php new file mode 100644 index 0000000..35cd87b --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFileSize.php @@ -0,0 +1,82 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid file size. + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isFileSize($value, $empty, &$params, &$formvars) { + + $_field = $params['field']; + $_max = isset($params['field2']) ? $params['field2'] : trim($params['max']); + + + if(!isset($_FILES[$_field])) + // nothing in the form + return false; + + if($_FILES[$_field]['error'] == 4) + // no file uploaded + return $empty; + + if(!isset($_max)) { + trigger_error("SmartyValidate: [isFileSize] 'max' attribute is missing."); + return false; + } + + if(!preg_match('!^(\d+)([bkmg](b)?)?$!i', $_max, $_match)) { + trigger_error("SmartyValidate: [isFileSize] 'max' attribute is invalid."); + return false; + } + + $_size = $_match[1]; + $_type = strtolower($_match[2]); + + switch($_type) { + case 'k': + $_maxsize = $_size * 1024; + break; + case 'm': + $_maxsize = $_size * 1024 * 1024; + break; + case 'g': + $_maxsize = $_size * 1024 * 1024 * 1024; + break; + case 'b': + default: + $_maxsize = $_size; + break; + } + + return $_FILES[$_field]['size'] <= $_maxsize; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFileType.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFileType.php new file mode 100644 index 0000000..8683690 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFileType.php @@ -0,0 +1,67 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid file type. This only checks the + * file extention, it does not test the actual file type. + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isFileType($value, $empty, &$params, &$formvars) { + + $_field = $params['field']; + $_type = isset($params['field2']) ? $params['field2'] : $params['type']; + + if(!isset($_FILES[$_field])) + // nothing in the form + return false; + + if($_FILES[$_field]['error'] == 4) + // no file uploaded + return $empty; + + if(!preg_match('!\.(\w+)$!i', $_FILES[$_field]['name'], $_match)) + // not valid filename + return false; + + $_file_ext = $_match[1]; + $_types = preg_split('![\s,]+!', $_type, -1, PREG_SPLIT_NO_EMPTY); + foreach($_types as $_key => $_val) { + $_types[$_key] = strtolower($_types[$_key]); + } + + if(!in_array(strtolower($_file_ext),$_types)) + // not valid file extention + return false; + + return true; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFloat.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFloat.php new file mode 100644 index 0000000..a9259c9 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isFloat.php @@ -0,0 +1,43 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a float + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isFloat($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + return preg_match('!^\d+\.\d+?$!', $value); +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isInt.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isInt.php new file mode 100644 index 0000000..66f76b1 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isInt.php @@ -0,0 +1,43 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is an integer + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isInt($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + return preg_match('!^\d+$!', $value); +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isLength.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isLength.php new file mode 100644 index 0000000..2273e8f --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isLength.php @@ -0,0 +1,64 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid range + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isLength($value, $empty, &$params, &$formvars) { + + if(isset($params['field2'])) { + $_min = $params['field2']; + } elseif(isset($params['min'])) { + $_min = $params['min']; + } else { + $_min = -1; + } + + if(isset($params['field3'])) { + $_max = $params['field3']; + } elseif(isset($params['max'])) { + $_max = $params['max']; + } else { + $_max = -1; + } + + $_length = strlen($value); + + if(($_min == -1 || $_length >= $_min) && ($_max == -1 || $_length <= $_max)) + return true; + elseif($_length == 0) + return $empty; + else + return false; +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isNumber.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isNumber.php new file mode 100644 index 0000000..fc20517 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isNumber.php @@ -0,0 +1,43 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid number (int of float) + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isNumber($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + return preg_match('!^-?\d+(\.\d+)?$!', $value); +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isPrice.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isPrice.php new file mode 100644 index 0000000..372454d --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isPrice.php @@ -0,0 +1,43 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a price + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isPrice($value, $empty, &$params, &$formvars) { + if(strlen($value) == 0) + return $empty; + + return preg_match('/^\d+(\.\d{1,2})?$/', $value); +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isRange.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isRange.php new file mode 100644 index 0000000..130de50 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isRange.php @@ -0,0 +1,63 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is a valid range + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isRange($value, $empty, &$params, &$formvars) { + + if(isset($params['field2'])) { + $_low = $params['field2']; + } elseif(isset($params['low'])) { + $_low = $params['low']; + } else { + trigger_error("SmartyValidate: [isRange] parameter 'low' is missing."); + return false; + } + + if(isset($params['field3'])) { + $_high = $params['field3']; + } elseif(isset($params['high'])) { + $_high = $params['high']; + } else { + trigger_error("SmartyValidate: [isRange] parameter 'high' is missing."); + return false; + } + + + if(strlen($value) == 0) + return $empty; + + return ($value >= $_low && $value <= $_high); +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isRegExp.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isRegExp.php new file mode 100644 index 0000000..d9d9b61 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.isRegExp.php @@ -0,0 +1,52 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + + /** + * test if a value is a valid regular expression match + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_isRegExp($value, $empty, &$params, &$formvars) { + if(isset($params['field2'])) { + $_exp = $params['field2']; + } elseif (isset($params['expression'])) { + $_exp = $params['expression']; + } else { + trigger_error("SmartyValidate: [isRegExp] parameter 'expression' is missing."); + return false; + + } + if(strlen($value) == 0) + return $empty; + + return (preg_match($_exp, $value)); +} + +?> diff --git a/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.notEmpty.php b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.notEmpty.php new file mode 100644 index 0000000..0809cc0 --- /dev/null +++ b/fp-includes/smarty-4.0.4/libs/plugins/validate_criteria.notEmpty.php @@ -0,0 +1,40 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @link http://www.phpinsider.com/php/code/SmartyValidate/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt + * @package SmartyValidate + */ + +/** + * test if a value is not empty + * + * @param string $value the value being tested + * @param boolean $empty if field can be empty + * @param array params validate parameter values + * @param array formvars form var values + */ +function smarty_validate_criteria_notEmpty($value, $empty, &$params, &$formvars) { + return strlen($value) > 0; +} + +?>