Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d17b9051
authored
2015-02-05 16:47:15 -0500
by
Marty Penner
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Format and translate various methods/classes
1 parent
212a1099
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
388 additions
and
798 deletions
com/Auth/Auth.php
com/HTML/HTML.php
com/Notifications/Validation.php
com/Auth/Auth.php
View file @
d17b905
...
...
@@ -59,11 +59,11 @@ function login($username, $password, $remember = false) {
throw
new
LogicException
(
'Unable to login because headers have been sent'
);
}
$auth
=
_signon
(
Array
(
$auth
=
_signon
(
[
'user_login'
=>
esc_sql
(
$username
)
,
'user_password'
=>
esc_sql
(
$password
)
,
'remember'
=>
$remember
)
);
]
);
if
(
get_class
(
$auth
)
==
'WP_User'
)
{
// This is done to ensure the auth'd user is logged in; cookie is not yet readable, redirect needed
...
...
@@ -124,7 +124,7 @@ function logout() {
* @global $wpdb
* @see wpmu_signup_user
*/
function
register
(
$username
,
$email
,
$password
,
$meta
=
Array
()
)
{
function
register
(
$username
,
$email
,
$password
,
$meta
=
[]
)
{
global
$wpdb
;
require_once
(
ABSPATH
.
WPINC
.
DIRECTORY_SEPARATOR
.
'registration.php'
);
...
...
@@ -138,11 +138,11 @@ function register($username, $email, $password, $meta = Array()) {
*/
$wpdb
->
query
(
"DELETE FROM
{
$wpdb
->
signups
}
WHERE user_email='
$email
' AND active=0"
);
$user_data
=
Array
(
$user_data
=
[
'username'
=>
$username
,
'password'
=>
$password
,
'email'
=>
$email
)
;
]
;
$meta
[
'password'
]
=
$password
;
// array_filter($user_data, 'esc_sql');
...
...
@@ -158,7 +158,7 @@ function register($username, $email, $password, $meta = Array()) {
$key
=
substr
(
md5
(
time
()
.
rand
()
.
$email
),
0
,
16
);
$meta
=
serialize
(
$meta
);
$wpdb
->
insert
(
$wpdb
->
signups
,
Array
(
$wpdb
->
insert
(
$wpdb
->
signups
,
[
'domain'
=>
''
,
'path'
=>
''
,
'title'
=>
''
,
...
...
@@ -167,7 +167,7 @@ function register($username, $email, $password, $meta = Array()) {
'registered'
=>
current_time
(
'mysql'
,
true
),
'activation_key'
=>
$key
,
'meta'
=>
$meta
)
);
]
);
// do_action('ACTION_REGISTER'); ???
...
...
@@ -209,7 +209,7 @@ function activate($key, $password_validation = null) {
throw
new
Exception
(
'Unable to create user'
);
}
$wpdb
->
update
(
$wpdb
->
signups
,
Array
(
'active'
=>
1
,
'activated'
=>
current_time
(
'mysql'
,
true
)),
Array
(
'activation_key'
=>
$key
)
);
$wpdb
->
update
(
$wpdb
->
signups
,
[
'active'
=>
1
,
'activated'
=>
current_time
(
'mysql'
,
true
)],
[
'activation_key'
=>
$key
]
);
// $user_site = get_site_option('dashboard_blog', $current_site->blog_id);
if
(
function_exists
(
'add_user_to_blog'
))
{
...
...
@@ -240,16 +240,18 @@ class Validation extends Common\Validation {
*/
protected
function
username
(
$val
)
{
if
(
empty
(
$val
))
{
throw
new
Exception
(
'<li>
Username is blank
</li>'
);
throw
new
Exception
(
'<li>
'
.
__
(
'Username is blank'
,
CBV_DOMAIN
)
.
'
</li>'
);
}
require_once
(
ABSPATH
.
WPINC
.
DIRECTORY_SEPARATOR
.
'registration.php'
);
if
(
!
validate_username
(
$val
))
{
throw
new
Exception
(
'<li>Username must be at least 4 characters, letters and numbers only</li>'
);
throw
new
Exception
(
'<li>'
.
__
(
'Username must be at least 4 characters, letters and numbers only'
,
CBV_DOMAIN
)
.
'</li>'
);
}
if
(
username_exists
(
$val
))
{
throw
new
Exception
(
'<li>
Username already exists
</li>'
);
throw
new
Exception
(
'<li>
'
.
__
(
'Username already exists'
,
CBV_DOMAIN
)
.
'
</li>'
);
}
}
...
...
@@ -260,15 +262,19 @@ class Validation extends Common\Validation {
*/
protected
function
password
(
$val
)
{
if
(
empty
(
$val
))
{
throw
new
Exception
(
'<li>
Password can not be blank
</li>'
);
throw
new
Exception
(
'<li>
'
.
__
(
'Password can not be blank'
,
CBV_DOMAIN
)
.
'
</li>'
);
}
if
(
isset
(
$val
[
PASS_MAX_LEN
]))
{
throw
new
Exception
(
'<li>Password can not be longer than '
.
PASS_MAX_LEN
.
' characters.</li>'
);
throw
new
Exception
(
'<li>'
.
sprintf
(
__
(
'Password can not be longer than %d characters.'
,
CBV_DOMAIN
),
PASS_MAX_LEN
)
.
'</li>'
);
}
if
(
preg_match
(
'/(\\\\|\\\'|"| )+/i'
,
$val
))
{
throw
new
Exception
(
'<li>Password can not contain spaces, backslashes (\) or quotes</li>'
);
throw
new
Exception
(
'<li>'
.
__
(
'Password can not contain spaces, backslashes (\) or quotes'
,
CBV_DOMAIN
)
.
'</li>'
);
}
}
...
...
@@ -278,11 +284,11 @@ class Validation extends Common\Validation {
*/
protected
function
email
(
$val
)
{
if
(
!
(
boolean
)
filter_var
(
$val
,
FILTER_VALIDATE_EMAIL
))
{
throw
new
Exception
(
'<li>
Invalid email address
</li>'
);
throw
new
Exception
(
'<li>
'
.
__
(
'Invalid email address'
,
CBV_DOMAIN
)
.
'
</li>'
);
}
if
(
false
!==
email_exists
(
$val
))
{
throw
new
Exception
(
'<li>
Email address already registered</li>
'
);
throw
new
Exception
(
'<li>
'
.
__
(
'Email address already registered'
,
CBV_DOMAIN
)
.
' </li >
'
);
}
}
}
...
...
@@ -294,4 +300,3 @@ class Vars {
*/
public
static
$options
;
}
?>
\ No newline at end of file
...
...
com/HTML/HTML.php
View file @
d17b905
<?php
namespace
Tz\WordPress\Tools\HTML
;
function
select_opts
(
Array
$options
,
$selected
=
null
,
$echo
=
true
)
/**
* @param array $options
* @param null $selected
* @param bool $echo
*
* @return string
*/
function
selectOpts
(
array
$options
,
$selected
=
null
,
$echo
=
true
)
{
$return
=
''
;
...
...
@@ -23,40 +30,82 @@ function select_opts(Array $options, $selected = null, $echo = true)
}
}
function
select_opts_provinces
(
$selected
=
null
,
$echo
=
true
)
/**
* @param null $selected
*
* @return string
*/
function
selectOptsProvinces
(
$selected
=
null
)
{
$return
=
"<option>Select a State/Province</option>"
;
$return
=
'<option>'
.
__
(
'Select a State/Province'
,
CBV_DOMAIN
)
.
'</option>'
;
$return
.=
'<optgroup label="Canada">'
;
$return
.=
select
_o
pts
(
Vars
::
$provinces
[
'CA'
],
$selected
,
false
);
$return
.=
select
O
pts
(
Vars
::
$provinces
[
'CA'
],
$selected
,
false
);
$return
.=
'</optgroup>'
;
$return
.=
'<optgroup label="United States">'
;
$return
.=
select
_o
pts
(
Vars
::
$provinces
[
'US'
],
$selected
,
false
);
$return
.=
select
O
pts
(
Vars
::
$provinces
[
'US'
],
$selected
,
false
);
$return
.=
'</optgroup>'
;
$return
.=
'<optgroup label="Other">'
;
$return
.=
'<option value="other">
Outside Canada/USA
</option>'
;
$return
.=
'<option value="other">
'
.
__
(
'Outside Canada/USA'
,
CBV_DOMAIN
)
.
'
</option>'
;
$return
.=
'</optgroup>'
;
return
$return
;
}
function
select_opts_cards
(
$selected
=
null
,
$echo
=
true
)
/**
* @param null $selected
* @param bool $echo
*
* @return string
*/
function
selectOptsCards
(
$selected
=
null
,
$echo
=
true
)
{
return
select_opts
(
Vars
::
$creditcards
,
$selected
,
$echo
);
$cards
=
array_map
(
function
(
$card
)
{
return
tz_
(
$card
);
},
Vars
::
$creditcards
);
return
selectOpts
(
$cards
,
$selected
,
$echo
);
}
function
select_opts_states
(
$selected
=
null
,
$echo
=
true
)
/**
* @param null $selected
* @param bool $echo
*
* @return string
*/
function
selectOptsStates
(
$selected
=
null
,
$echo
=
true
)
{
return
select
_o
pts
(
Vars
::
$states
,
$selected
,
$echo
);
return
select
O
pts
(
Vars
::
$states
,
$selected
,
$echo
);
}
function
select_opts_prefixes
(
$selected
=
null
,
$echo
=
true
)
/**
* @param null $selected
* @param bool $echo
*
* @return string
*/
function
selectOptsPrefixes
(
$selected
=
null
,
$echo
=
true
)
{
return
select_opts
(
Vars
::
$prefixes
,
$selected
,
$echo
);
$prefixes
=
array_map
(
function
(
$prefix
)
{
return
tz_
(
$prefix
);
},
Vars
::
$prefixes
);
return
selectOpts
(
$prefixes
,
$selected
,
$echo
);
}
/**
* @param null $selected
*
* @return string
*/
function
selectOptsPrefixesNoBlank
(
$selected
=
null
)
{
$return
=
''
;
...
...
@@ -77,16 +126,42 @@ function selectOptsPrefixesNoBlank($selected = null)
return
$return
;
}
function
select_opts_countries
(
$selected
=
null
,
$echo
=
true
)
/**
* @param null $selected
* @param bool $echo
*
* @return string
*/
function
selectOptsCountries
(
$selected
=
null
,
$echo
=
true
)
{
return
select
_o
pts
(
Vars
::
$countries
,
$selected
,
$echo
);
return
select
O
pts
(
Vars
::
$countries
,
$selected
,
$echo
);
}
function
select_opts_securities
(
$selected
=
null
,
$echo
=
true
)
/**
* @param null $selected
* @param bool $echo
*
* @return string
*/
function
selectOptsSecurities
(
$selected
=
null
,
$echo
=
true
)
{
return
select_opts
(
Vars
::
$securities
,
$selected
,
$echo
);
$securities
=
array_map
(
function
(
$security
)
{
return
tz_
(
$security
);
},
Vars
::
$securities
);
return
selectOpts
(
$securities
,
$selected
,
$echo
);
}
/**
* @param $date
* @param string $format
*
* @return bool
* @throws \Exception
*/
function
validateDate
(
$date
,
$format
=
'YYYY-MM-DD'
)
{
switch
(
$format
)
{
...
...
@@ -123,34 +198,32 @@ function validateDate($date, $format = 'YYYY-MM-DD')
break
;
default
:
throw
new
Exception
(
"Invalid Date Format"
);
throw
new
\Exception
(
'Invalid Date Format'
);
}
return
checkdate
(
$m
,
$d
,
$y
);
}
function
validate
_creditcard
(
$cc_n
um
,
$type
)
function
validate
Creditcard
(
$ccN
um
,
$type
)
{
if
(
$type
==
"amex"
)
{
$pattern
=
"/^([34|37]
{
2})([0-9]{13
}
)$/"
;
//American Express
if
(
preg_match
(
$pattern
,
$cc
_n
um
))
{
if
(
preg_match
(
$pattern
,
$cc
N
um
))
{
$verified
=
true
;
}
else
{
$verified
=
false
;
}
}
elseif
(
$type
==
"mc"
)
{
$pattern
=
"/^([51|52|53|54|55]
{
2})([0-9]{14
}
)$/"
;
//Mastercard
if
(
preg_match
(
$pattern
,
$cc
_n
um
))
{
if
(
preg_match
(
$pattern
,
$cc
N
um
))
{
$verified
=
true
;
}
else
{
$verified
=
false
;
}
}
elseif
(
$type
==
"visa"
)
{
$pattern
=
"/^([4]
{
1})([0-9]{12,15
}
)$/"
;
//Visa
if
(
preg_match
(
$pattern
,
$cc
_n
um
))
{
if
(
preg_match
(
$pattern
,
$cc
N
um
))
{
$verified
=
true
;
}
else
{
$verified
=
false
;
...
...
@@ -248,7 +321,7 @@ function form_linked_dropdown(
jQuery("#'
.
$name
.
'").show();
var options = new
Array()
;
var options = new
[]
;
var select = document.getElementById("'
.
$name
.
'");
select.disabled = false;
while (select.firstChild)
...
...
@@ -349,7 +422,7 @@ if (!function_exists('formLinkedDropdownWithExtra')) {
jQuery("#'
.
$name
.
'_custom").attr("disabled", "disabled").hide();
jQuery("#'
.
$name
.
'").show();
var options =
new Ar
ray();
var options =
[]
ray();
var select = document.getElementById("'
.
$name
.
'");
select.disabled = false;
while (select.firstChild)
...
...
@@ -451,420 +524,3 @@ if (!function_exists('url_title')) {
return
trim
(
stripslashes
(
$str
));
}
}
class
Vars
{
public
static
$prefixes
=
[
''
=>
'-- select --'
,
'Mr.'
=>
'Mr.'
,
'Mrs.'
=>
'Mrs.'
,
'Ms.'
=>
'Ms.'
,
'Miss'
=>
'Miss'
,
'Master'
=>
'Master'
,
'Dr.'
=>
'Dr.'
,
'Prof.'
=>
'Prof.'
];
public
static
$company_types
=
[
'advisory_firm'
=>
"Advisory Firm"
,
'litigation_firm'
=>
"Litigation Firm"
,
'venture_capital_firm'
=>
"Venture Capital Firm"
,
'public_practice'
=>
"Public Practice"
,
'government'
=>
"Government"
,
''
=>
"None"
,
'accounting_firm'
=>
"Accounting Firm"
,
'special_valuation'
=>
"Special Valuation"
,
'investment_bank'
=>
"Investment Bank"
,
'academia'
=>
"Academia"
,
'financial_institution'
=>
"Financial Institution"
,
'pension_fund_co'
=>
"Pension Fund Management Company"
,
'mutual_fund_co'
=>
"Mutual Fund Management Company"
,
'merchant_bank'
=>
"Merchant Bank"
];
public
static
$countries
=
[
'CA'
=>
'Canada'
,
'US'
=>
'United States'
,
'MX'
=>
'Mexico'
,
'AF'
=>
'Afghanistan'
,
'AR'
=>
'Argentina'
,
'AX'
=>
'Åland Islands'
,
'AL'
=>
'Albania'
,
'DZ'
=>
'Algeria'
,
'AS'
=>
'American Samoa'
,
'AD'
=>
'Andorra'
,
'AO'
=>
'Angola'
,
'AI'
=>
'Anguilla'
,
'AQ'
=>
'Antarctica'
,
'AG'
=>
'Antigua and Barbuda'
,
'AM'
=>
'Armenia'
,
'AW'
=>
'Aruba'
,
'AU'
=>
'Australia'
,
'AT'
=>
'Austria'
,
'AZ'
=>
'Azerbaijan'
,
'BS'
=>
'Bahamas'
,
'BH'
=>
'Bahrain'
,
'BD'
=>
'Bangladesh'
,
'BB'
=>
'Barbados'
,
'BY'
=>
'Belarus'
,
'BE'
=>
'Belgium'
,
'BZ'
=>
'Belize'
,
'BJ'
=>
'Benin'
,
'BM'
=>
'Bermuda'
,
'BT'
=>
'Bhutan'
,
'BO'
=>
'Bolivia'
,
'BA'
=>
'Bosnia and Herzegovina'
,
'BW'
=>
'Botswana'
,
'BV'
=>
'Bouvet Island'
,
'BR'
=>
'Brazil'
,
'IO'
=>
'British Indian Ocean Territory'
,
'BN'
=>
'Brunei Darussalam'
,
'BG'
=>
'Bulgaria'
,
'BF'
=>
'Burkina Faso'
,
'BI'
=>
'Burundi'
,
'KH'
=>
'Cambodia'
,
'CM'
=>
'Cameroon'
,
'CV'
=>
'Cape Verde'
,
'KY'
=>
'Cayman Islands'
,
'CF'
=>
'Central African Republic'
,
'TD'
=>
'Chad'
,
'CL'
=>
'Chile'
,
'CN'
=>
'China'
,
'CX'
=>
'Christmas Island'
,
'CC'
=>
'Cocos (Keeling) Islands'
,
'CO'
=>
'Columbia'
,
'KM'
=>
'Comoros'
,
'CG'
=>
'Congo'
,
'CD'
=>
'Congo, The Democratic Republic'
,
'CK'
=>
'Cook Islands'
,
'CR'
=>
'Costa Rica'
,
'CI'
=>
'Cote d’Ivoire – Really Ivory Coast'
,
'HR'
=>
'Croatia'
,
'CU'
=>
'Cuba'
,
'CY'
=>
'Cyprus'
,
'CZ'
=>
'Czech Republic'
,
'DK'
=>
'Denmark'
,
'DJ'
=>
'Djibouti'
,
'DM'
=>
'Dominica'
,
'DO'
=>
'Dominican Republic'
,
'TL'
=>
'East Timor'
,
'EC'
=>
'Ecuador'
,
'EG'
=>
'Egypt'
,
'SV'
=>
'El Salvador'
,
'GQ'
=>
'Equatorial Guinea'
,
'ER'
=>
'Eritrea'
,
'EE'
=>
'Estonia'
,
'ET'
=>
'Ethiopia'
,
'FK'
=>
'Falkland Islands'
,
'FO'
=>
'Faroe Islands'
,
'FJ'
=>
'Fiji'
,
'FI'
=>
'Finland'
,
'FR'
=>
'France'
,
'GF'
=>
'French Guiana'
,
'PF'
=>
'French Polynesia'
,
'TF'
=>
'French Southern Territories'
,
'GA'
=>
'Gabon'
,
'GM'
=>
'Gambia'
,
'GE'
=>
'Georgia'
,
'DE'
=>
'Germany'
,
'GH'
=>
'Ghana'
,
'GI'
=>
'Gibraltar'
,
'GB'
=>
'Great Britain'
,
'GR'
=>
'Greece'
,
'GL'
=>
'Greenland'
,
'GD'
=>
'Grenada'
,
'GP'
=>
'Guadeloupe'
,
'GU'
=>
'Guam'
,
'GT'
=>
'Guatemala'
,
'GN'
=>
'Guinea'
,
'GW'
=>
'Guinea Bissau'
,
'GY'
=>
'Guyana'
,
'HT'
=>
'Haiti'
,
'HM'
=>
'Heard and McDonald Islands'
,
'HN'
=>
'Honduras'
,
'HK'
=>
'Hong Kong'
,
'HU'
=>
'Hungary'
,
'IS'
=>
'Iceland'
,
'IN'
=>
'India'
,
'ID'
=>
'Indonesia'
,
'IR'
=>
'Iran, Islamic Republic of'
,
'IQ'
=>
'Iraq'
,
'IE'
=>
'Ireland'
,
'IL'
=>
'Israel'
,
'IT'
=>
'Italy'
,
'JM'
=>
'Jamaica'
,
'JP'
=>
'Japan'
,
'JO'
=>
'Jordan'
,
'KZ'
=>
'Kazakhstan'
,
'KE'
=>
'Kenya'
,
'KI'
=>
'Kiribati'
,
'KP'
=>
"Korea, Democratic People's Republic"
,
'KR'
=>
'Korea, Republic of'
,
'KW'
=>
'Kuwait'
,
'KG'
=>
'Kyrgyzstan'
,
'LA'
=>
"Lao People's Democratic Republic"
,
'LV'
=>
'Latvia'
,
'LB'
=>
'Lebanon'
,
'LI'
=>
'Liechtenstein'
,
'LS'
=>
'Lesotho'
,
'LR'
=>
'Liberia'
,
'LY'
=>
'Libyan Arab Jamahiriya'
,
'LT'
=>
'Lithuania'
,
'LU'
=>
'Luxembourg'
,
'MO'
=>
'Macau'
,
'MK'
=>
'Macedonia'
,
'MG'
=>
'Madagascar'
,
'MW'
=>
'Malawi'
,
'MY'
=>
'Malaysia'
,
'MV'
=>
'Maldives'
,
'ML'
=>
'Mali'
,
'MT'
=>
'Malta'
,
'MH'
=>
'Marshall Islands'
,
'MQ'
=>
'Martinique'
,
'MR'
=>
'Mauritania'
,
'MU'
=>
'Mauritius'
,
'YT'
=>
'Mayotte'
,
'FM'
=>
"Micronesia, Federated States of"
,
'MD'
=>
'Moldova, Republic of'
,
'MC'
=>
'Monaco'
,
'MN'
=>
'Mongolia'
,
'MS'
=>
'Montserrat'
,
'MA'
=>
'Morocco'
,
'MZ'
=>
"Mozambique"
,
'MM'
=>
'Myanmar'
,
'NA'
=>
'Namibia'
,
'NR'
=>
'Nauru'
,
'NP'
=>
'Nepal'
,
'NL'
=>
'Netherlands'
,
'AN'
=>
'Netherlands Antilles'
,
'NC'
=>
'New Caledonia'
,
'NZ'
=>
'New Zealand'
,
'NI'
=>
'Nicaragua'
,
'NE'
=>
'Niger'
,
'NG'
=>
'Nigeria'
,
'NU'
=>
'Niue'
,
'NF'
=>
'Norfolk Island'
,
'MP'
=>
'Northern Mariana Islands'
,
'NO'
=>
"Norway"
,
'OM'
=>
'Oman'
,
'PK'
=>
'Pakistan'
,
'PW'
=>
'Palau'
,
'PS'
=>
'Palestinian Territory, Occupied'
,
'PA'
=>
'Panama'
,
'PG'
=>
'Papua New Guinea'
,
'PY'
=>
'Paraguay'
,
'PE'
=>
'Peru'
,
'PH'
=>
'Philippines'
,
'PN'
=>
'Pitcairn'
,
'PL'
=>
'Poland'
,
'PT'
=>
'Portugal'
,
'PR'
=>
'Puerto Rico'
,
'QA'
=>
'Qatar'
,
'RE'
=>
'Reunion'
,
'RO'
=>
'Romania'
,
'RU'
=>
'Russian Federation'
,
'RW'
=>
'Rwanda'
,
'KN'
=>
'Saint Kitts and Nevis'
,
'LC'
=>
'Saint Lucia'
,
'VC'
=>
'Saint Vincent and the Grenadines'
,
'WS'
=>
'Samoa'
,
'SM'
=>
'San Marino'
,
'ST'
=>
'Sao Tome and Principe'
,
'SA'
=>
'Saudi Arabia'
,
'SN'
=>
'Senegal'
,
'CS'
=>
'Serbia and Montenegro'
,
'SC'
=>
'Seychelles'
,
'SL'
=>
'Sierra Leone'
,
'SG'
=>
'Singapore'
,
'SK'
=>
'Slovakia'
,
'SI'
=>
'Slovenia'
,
'SB'
=>
'Solomon Islands'
,
'SO'
=>
'Somalia'
,
'ZA'
=>
'South Africa'
,
'GS'
=>
'South Georgia – South Sandwich Islands'
,
'ES'
=>
'Spain'
,
'LK'
=>
'Sri Lanka'
,
'SH'
=>
'St. Helena'
,
'PM'
=>
'St. Pierre and Miquelon'
,
'SD'
=>
'Sudan'
,
'SR'
=>
'Suriname'
,
'SJ'
=>
'Svalbard and Jan Mayen'
,
'SZ'
=>
'Swaziland'
,
'SE'
=>
'Sweden'
,
'CH'
=>
'Switzerland'
,
'SY'
=>
'Syrian Arab Republic'
,
'TW'
=>
'Taiwan'
,
'TJ'
=>
'Tajikistan'
,
'TZ'
=>
'Tanzania, United Republic of'
,
'TH'
=>
'Thailand'
,
'TG'
=>
'Togo'
,
'TK'
=>
'Tokelau'
,
'TO'
=>
'Tonga'
,
'TT'
=>
'Trinidad and Tobago'
,
'TN'
=>
'Tunisia'
,
'TR'
=>
'Turkey'
,
'TM'
=>
'Turkmenistan'
,
'TC'
=>
'Turks and Caicos Islands'
,
'TV'
=>
'Tuvalu'
,
'UG'
=>
'Uganda'
,
'UA'
=>
'Ukraine'
,
'AE'
=>
'United Arab Emirates'
,
'UM'
=>
'United States Minor Outlying Islands'
,
'UY'
=>
'Uruguay'
,
'UZ'
=>
'Uzbekistan'
,
'VU'
=>
'Vanuatu'
,
'VA'
=>
'Vatican City state'
,
'VE'
=>
'Venezuela'
,
'VN'
=>
'Viet Nam'
,
'VG'
=>
'Virgin Islands (British)'
,
'VI'
=>
'Virgin Islands (US)'
,
'WF'
=>
'Wallis and Futuna'
,
'EH'
=>
'Western Sahara'
,
'YE'
=>
'Yemen'
,
'ZM'
=>
'Zambia'
,
'ZW'
=>
'Zimbabwe'
];
public
static
$provinces
=
[
'CA'
=>
[
'AB'
=>
'Alberta'
,
'BC'
=>
'British Columbia'
,
'MB'
=>
'Manitoba'
,
'NB'
=>
'New Brunswick'
,
'NL'
=>
'Newfoundland and Labrador'
,
'NT'
=>
'Northwest Territories'
,
'NS'
=>
'Nova Scotia'
,
'NU'
=>
'Nunavut'
,
'PE'
=>
'Prince Edward Island'
,
'SK'
=>
'Saskatchewan'
,
'ON'
=>
'Ontario'
,
'QC'
=>
'Quebec'
,
'YT'
=>
'Yukon'
],
'US'
=>
[
'AL'
=>
'Alabama'
,
'AK'
=>
'Alaska'
,
'AZ'
=>
'Arizona'
,
'AR'
=>
'Arkansas'
,
'CA'
=>
'California'
,
'CO'
=>
'Colorado'
,
'CT'
=>
'Connecticut'
,
'DE'
=>
'Delaware'
,
'DC'
=>
'District of Columbia'
,
'FL'
=>
'Florida'
,
'GA'
=>
'Georgia'
,
'GU'
=>
'Guam'
,
'HI'
=>
'Hawaii'
,
'ID'
=>
'Idaho'
,
'IL'
=>
'Illinois'
,
'IN'
=>
'Indiana'
,
'IA'
=>
'Iowa'
,
'KS'
=>
'Kansas'
,
'KY'
=>
'Kentucky'
,
'LA'
=>
'Louisiana'
,
'ME'
=>
'Maine'
,
'MD'
=>
'Maryland'
,
'MA'
=>
'Massachusetts'
,
'MI'
=>
'Michigan'
,
'MN'
=>
'Minnesota'
,
'MS'
=>
'Mississippi'
,
'MO'
=>
'Missouri'
,
'MT'
=>
'Montana'
,
'NE'
=>
'Nebraska'
,
'NV'
=>
'Nevada'
,
'NH'
=>
'New Hampshire'
,
'NJ'
=>
'New Jersey'
,
'NM'
=>
'New Mexico'
,
'NY'
=>
'New York'
,
'NC'
=>
'North Carolina'
,
'ND'
=>
'North Dakota'
,
'OH'
=>
'Ohio'
,
'OK'
=>
'Oklahoma'
,
'OR'
=>
'Oregon'
,
'PA'
=>
'Pennsylvania'
,
'PR'
=>
'Puerto Rico'
,
'RI'
=>
'Rhode Island'
,
'SC'
=>
'South Carolina'
,
'SD'
=>
'South Dakota'
,
'TN'
=>
'Tennessee'
,
'TX'
=>
'Texas'
,
'UT'
=>
'Utah'
,
'VT'
=>
'Vermont'
,
'VA'
=>
'Virginia'
,
'VI'
=>
'Virgin Islands'
,
'WA'
=>
'Washington'
,
'WV'
=>
'West Virginia'
,
'WI'
=>
'Wisconsin'
,
'WY'
=>
'Wyoming'
]
];
public
static
$securities
=
[
'S01'
=>
"What is your Mother's maiden name?"
,
'S02'
=>
"Who was you childhood hero?"
,
'S03'
=>
"What is/was the name of your first pet?"
];
public
static
$creditcards
=
[
'visa'
=>
"Visa"
,
'mc'
=>
"MasterCard"
,
'amex'
=>
"American Express"
];
public
static
$states
=
[
'AL'
=>
'Alabama'
,
'AK'
=>
'Alaska'
,
'AZ'
=>
'Arizona'
,
'AR'
=>
'Arkansas'
,
'CA'
=>
'California'
,
'CO'
=>
'Colorado'
,
'CT'
=>
'Connecticut'
,
'DE'
=>
'Delaware'
,
'DC'
=>
'District of Columbia'
,
'FL'
=>
'Florida'
,
'GA'
=>
'Georgia'
,
'GU'
=>
'Guam'
,
'HI'
=>
'Hawaii'
,
'ID'
=>
'Idaho'
,
'IL'
=>
'Illinois'
,
'IN'
=>
'Indiana'
,
'IA'
=>
'Iowa'
,
'KS'
=>
'Kansas'
,
'KY'
=>
'Kentucky'
,
'LA'
=>
'Louisiana'
,
'ME'
=>
'Maine'
,
'MD'
=>
'Maryland'
,
'MA'
=>
'Massachusetts'
,
'MI'
=>
'Michigan'
,
'MN'
=>
'Minnesota'
,
'MS'
=>
'Mississippi'
,
'MO'
=>
'Missouri'
,
'MT'
=>
'Montana'
,
'NE'
=>
'Nebraska'
,
'NV'
=>
'Nevada'
,
'NH'
=>
'New Hampshire'
,
'NJ'
=>
'New Jersey'
,
'NM'
=>
'New Mexico'
,
'NY'
=>
'New York'
,
'NC'
=>
'North Carolina'
,
'ND'
=>
'North Dakota'
,
'OH'
=>
'Ohio'
,
'OK'
=>
'Oklahoma'
,
'OR'
=>
'Oregon'
,
'PA'
=>
'Pennyslvania'
,
'PR'
=>
'Puerto Rico'
,
'RI'
=>
'Rhode Island'
,
'SC'
=>
'South Carolina'
,
'SD'
=>
'South Dakota'
,
'TN'
=>
'Tennessee'
,
'TX'
=>
'Texas'
,
'UT'
=>
'Utah'
,
'VT'
=>
'Vermont'
,
'VA'
=>
'Virginia'
,
'VI'
=>
'Virgin Islands'
,
'WA'
=>
'Washington'
,
'WV'
=>
'West Virginia'
,
'WI'
=>
'Wisconsin'
,
'WY'
=>
'Wyoming'
];
}
...
...
com/Notifications/Validation.php
View file @
d17b905
<?php
namespace
Tz\WordPress\Tools\Notifications
;
error_reporting
(
E_ALL
^
E_DEPRECATED
);
error_reporting
(
E_ALL
^
E_DEPRECATED
);
use
Tz\WordPress\Tools
;
use
Tz\Common
;
use
Tz\WordPress\Tools
;
use
Tz\WordPress\Tools\Notifications
;
class
Validation
{
class
Validation
{
protected
$_field_data
=
array
();
protected
$_config_rules
=
array
();
protected
$_error_array
=
array
();
protected
$_error_messages
=
array
();
protected
$_field_data
=
[];
protected
$_config_rules
=
[];
protected
$_error_array
=
[];
protected
$_error_messages
=
[];
protected
$_error_prefix
=
'<div class="lblError">'
;
protected
$_error_suffix
=
'</div>'
;
protected
$error_string
=
''
;
protected
$_safe_form_data
=
FALSE
;
protected
$_safe_form_data
=
false
;
function
__construct
(
$rules
=
array
()
)
function
__construct
(
$rules
=
[]
)
{
// Validation rules can be stored in a config file.
$this
->
_config_rules
=
$rules
;
}
public
function
get_error_message
(
$key
)
{
$lang
=
array
();
public
function
get_error_message
(
$key
)
{
$lang
=
[];
$lang
[
'required'
]
=
"The %s field is required."
;
$lang
[
'isset'
]
=
"The %s field must have a value."
;
$lang
[
'valid_email'
]
=
"The %s field must contain a valid email address."
;
...
...
@@ -45,13 +46,11 @@ class Validation {
$lang
[
'is_natural'
]
=
"The %s field must contain only positive numbers."
;
$lang
[
'is_natural_no_zero'
]
=
"The %s field must contain a number greater than zero."
;
if
(
isset
(
$lang
[
$key
]))
{
return
$lang
[
$key
];
}
else
{
return
FALSE
;
return
false
;
}
}
...
...
@@ -64,42 +63,40 @@ class Validation {
* rules as input, validates the info, and stores it
*
* @access public
*
* @param mixed
* @param string
*
* @return void
*/
function
set_rules
(
$field
,
$label
=
''
,
$rules
=
''
)
{
// No reason to set rules if we have no POST data
if
(
count
(
$_POST
)
==
0
)
{
if
(
count
(
$_POST
)
==
0
)
{
return
;
}
// If an array was passed via the first parameter instead of indidual string
// values we cycle through it and recursively call this function.
if
(
is_array
(
$field
))
{
foreach
(
$field
as
$row
)
{
if
(
is_array
(
$field
))
{
foreach
(
$field
as
$row
)
{
// Houston, we have a problem...
if
(
!
isset
(
$row
[
'field'
])
OR
!
isset
(
$row
[
'rules'
]))
{
if
(
!
isset
(
$row
[
'field'
])
OR
!
isset
(
$row
[
'rules'
]))
{
continue
;
}
// If the field label wasn't passed we use the field name
$label
=
(
!
isset
(
$row
[
'label'
]))
?
$row
[
'field'
]
:
$row
[
'label'
];
$label
=
(
!
isset
(
$row
[
'label'
]))
?
$row
[
'field'
]
:
$row
[
'label'
];
// Here we go!
$this
->
set_rules
(
$row
[
'field'
],
$label
,
$row
[
'rules'
]);
}
return
;
}
// No fields? Nothing to do...
if
(
!
is_string
(
$field
)
OR
!
is_string
(
$rules
)
OR
$field
==
''
)
{
if
(
!
is_string
(
$field
)
OR
!
is_string
(
$rules
)
OR
$field
==
''
)
{
return
;
}
...
...
@@ -109,39 +106,34 @@ class Validation {
// Is the field name an array? We test for the existence of a bracket "[" in
// the field name to determine this. If it is an array, we break it apart
// into its components so that we can fetch the corresponding POST data later
if
(
strpos
(
$field
,
'['
)
!==
FALSE
AND
preg_match_all
(
'/\[(.*?)\]/'
,
$field
,
$matches
))
{
if
(
strpos
(
$field
,
'['
)
!==
false
AND
preg_match_all
(
'/\[(.*?)\]/'
,
$field
,
$matches
))
{
// Note: Due to a bug in current() that affects some versions
// of PHP we can not pass function call directly into it
$x
=
explode
(
'['
,
$field
);
$indexes
[]
=
current
(
$x
);
for
(
$i
=
0
;
$i
<
count
(
$matches
[
'0'
]);
$i
++
)
{
if
(
$matches
[
'1'
][
$i
]
!=
''
)
{
for
(
$i
=
0
;
$i
<
count
(
$matches
[
'0'
]);
$i
++
)
{
if
(
$matches
[
'1'
][
$i
]
!=
''
)
{
$indexes
[]
=
$matches
[
'1'
][
$i
];
}
}
$is_array
=
TRUE
;
}
else
{
$indexes
=
array
();
$is_array
=
FALSE
;
$is_array
=
true
;
}
else
{
$indexes
=
[];
$is_array
=
false
;
}
// Build our master array
$this
->
_field_data
[
$field
]
=
array
(
$this
->
_field_data
[
$field
]
=
[
'field'
=>
$field
,
'label'
=>
$label
,
'rules'
=>
$rules
,
'is_array'
=>
$is_array
,
'keys'
=>
$indexes
,
'postdata'
=>
NULL
,
'postdata'
=>
null
,
'error'
=>
''
)
;
]
;
}
// --------------------------------------------------------------------
...
...
@@ -153,15 +145,16 @@ class Validation {
* name has to match the function name that it corresponds to.
*
* @access public
*
* @param string
* @param string
*
* @return string
*/
function
set_message
(
$lang
,
$val
=
''
)
{
if
(
!
is_array
(
$lang
))
{
$lang
=
array
(
$lang
=>
$val
);
if
(
!
is_array
(
$lang
))
{
$lang
=
[
$lang
=>
$val
];
}
$this
->
_error_messages
=
array_merge
(
$this
->
_error_messages
,
$lang
);
...
...
@@ -175,8 +168,10 @@ class Validation {
* Permits a prefix/suffix to be added to each error message
*
* @access public
*
* @param string
* @param string
*
* @return void
*/
function
set_error_delimiters
(
$prefix
=
'<p>'
,
$suffix
=
'</p>'
)
...
...
@@ -193,23 +188,22 @@ class Validation {
* Gets the error message associated with a particular field
*
* @access public
*
* @param string the field name
*
* @return void
*/
function
error
(
$field
=
''
,
$prefix
=
''
,
$suffix
=
''
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
][
'error'
])
OR
$this
->
_field_data
[
$field
][
'error'
]
==
''
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
][
'error'
])
OR
$this
->
_field_data
[
$field
][
'error'
]
==
''
)
{
return
''
;
}
if
(
$prefix
==
''
)
{
if
(
$prefix
==
''
)
{
$prefix
=
$this
->
_error_prefix
;
}
if
(
$suffix
==
''
)
{
if
(
$suffix
==
''
)
{
$suffix
=
$this
->
_error_suffix
;
}
...
...
@@ -224,34 +218,31 @@ class Validation {
* Returns the error messages as a string, wrapped in the error delimiters
*
* @access public
*
* @param string
* @param string
*
* @return str
*/
function
error_string
(
$prefix
=
''
,
$suffix
=
''
)
{
// No errrors, validation passes!
if
(
count
(
$this
->
_error_array
)
===
0
)
{
if
(
count
(
$this
->
_error_array
)
===
0
)
{
return
''
;
}
if
(
$prefix
==
''
)
{
if
(
$prefix
==
''
)
{
$prefix
=
$this
->
_error_prefix
;
}
if
(
$suffix
==
''
)
{
if
(
$suffix
==
''
)
{
$suffix
=
$this
->
_error_suffix
;
}
// Generate the error string
$str
=
''
;
foreach
(
$this
->
_error_array
as
$val
)
{
if
(
$val
!=
''
)
{
foreach
(
$this
->
_error_array
as
$val
)
{
if
(
$val
!=
''
)
{
$str
.=
$prefix
.
$val
.
$suffix
.
"
\n
"
;
}
}
...
...
@@ -272,55 +263,43 @@ class Validation {
function
run
(
$group
=
''
)
{
// Do we even have any data to process? Mm?
if
(
count
(
$_POST
)
==
0
)
{
return
FALSE
;
if
(
count
(
$_POST
)
==
0
)
{
return
false
;
}
// Does the _field_data array containing the validation rules exist?
// If not, we look to see if they were assigned via a config file
if
(
count
(
$this
->
_field_data
)
==
0
)
{
if
(
count
(
$this
->
_field_data
)
==
0
)
{
// No validation rules? We're done...
if
(
count
(
$this
->
_config_rules
)
==
0
)
{
return
FALSE
;
if
(
count
(
$this
->
_config_rules
)
==
0
)
{
return
false
;
}
// Is there a validation rule for the particular URI being accessed?
$uri
=
(
$group
==
''
)
?
trim
(
$this
->
CI
->
uri
->
ruri_string
(),
'/'
)
:
$group
;
if
(
$uri
!=
''
AND
isset
(
$this
->
_config_rules
[
$uri
]))
{
if
(
$uri
!=
''
AND
isset
(
$this
->
_config_rules
[
$uri
]))
{
$this
->
set_rules
(
$this
->
_config_rules
[
$uri
]);
}
else
{
}
else
{
$this
->
set_rules
(
$this
->
_config_rules
);
}
// We're we able to set the rules correctly?
if
(
count
(
$this
->
_field_data
)
==
0
)
{
return
FALSE
;
if
(
count
(
$this
->
_field_data
)
==
0
)
{
return
false
;
}
}
// Cycle through the rules for each field, match the
// corresponding $_POST item and test for errors
foreach
(
$this
->
_field_data
as
$field
=>
$row
)
{
foreach
(
$this
->
_field_data
as
$field
=>
$row
)
{
// Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
// Depending on whether the field name is an array or a string will determine where we get it from.
if
(
$row
[
'is_array'
]
==
TRUE
)
{
if
(
$row
[
'is_array'
]
==
true
)
{
$this
->
_field_data
[
$field
][
'postdata'
]
=
$this
->
_reduce_array
(
$_POST
,
$row
[
'keys'
]);
}
else
{
if
(
isset
(
$_POST
[
$field
])
AND
$_POST
[
$field
]
!=
""
)
{
}
else
{
if
(
isset
(
$_POST
[
$field
])
AND
$_POST
[
$field
]
!=
""
)
{
$this
->
_field_data
[
$field
][
'postdata'
]
=
$_POST
[
$field
];
}
}
...
...
@@ -331,22 +310,20 @@ class Validation {
// Did we end up with any errors?
$total_errors
=
count
(
$this
->
_error_array
);
if
(
$total_errors
>
0
)
{
$this
->
_safe_form_data
=
TRUE
;
if
(
$total_errors
>
0
)
{
$this
->
_safe_form_data
=
true
;
}
// Now we need to re-set the POST data with the new, processed data
$this
->
_reset_post_array
();
// No errors, validation passes!
if
(
$total_errors
==
0
)
{
return
TRUE
;
if
(
$total_errors
==
0
)
{
return
true
;
}
// Validation fails
return
FALSE
;
return
false
;
}
// --------------------------------------------------------------------
...
...
@@ -355,28 +332,23 @@ class Validation {
* Traverse a multidimensional $_POST array index until the data is found
*
* @access private
*
* @param array
* @param array
* @param integer
*
* @return mixed
*/
function
_reduce_array
(
$array
,
$keys
,
$i
=
0
)
{
if
(
is_array
(
$array
))
{
if
(
isset
(
$keys
[
$i
]))
{
if
(
isset
(
$array
[
$keys
[
$i
]]))
{
$array
=
$this
->
_reduce_array
(
$array
[
$keys
[
$i
]],
$keys
,
(
$i
+
1
));
}
else
{
return
NULL
;
}
if
(
is_array
(
$array
))
{
if
(
isset
(
$keys
[
$i
]))
{
if
(
isset
(
$array
[
$keys
[
$i
]]))
{
$array
=
$this
->
_reduce_array
(
$array
[
$keys
[
$i
]],
$keys
,
(
$i
+
1
));
}
else
{
return
null
;
}
else
{
}
else
{
return
$array
;
}
}
...
...
@@ -394,47 +366,33 @@ class Validation {
*/
function
_reset_post_array
()
{
foreach
(
$this
->
_field_data
as
$field
=>
$row
)
{
if
(
!
is_null
(
$row
[
'postdata'
]))
{
if
(
$row
[
'is_array'
]
==
FALSE
)
{
if
(
isset
(
$_POST
[
$row
[
'field'
]]))
{
foreach
(
$this
->
_field_data
as
$field
=>
$row
)
{
if
(
!
is_null
(
$row
[
'postdata'
]))
{
if
(
$row
[
'is_array'
]
==
false
)
{
if
(
isset
(
$_POST
[
$row
[
'field'
]]))
{
$_POST
[
$row
[
'field'
]]
=
$this
->
prep_for_form
(
$row
[
'postdata'
]);
}
}
else
{
}
else
{
// start with a reference
$post_ref
=&
$_POST
;
// before we assign values, make a reference to the right POST key
if
(
count
(
$row
[
'keys'
])
==
1
)
{
if
(
count
(
$row
[
'keys'
])
==
1
)
{
$post_ref
=&
$post_ref
[
current
(
$row
[
'keys'
])];
}
else
{
foreach
(
$row
[
'keys'
]
as
$val
)
{
}
else
{
foreach
(
$row
[
'keys'
]
as
$val
)
{
$post_ref
=&
$post_ref
[
$val
];
}
}
if
(
is_array
(
$row
[
'postdata'
]))
{
$array
=
array
();
foreach
(
$row
[
'postdata'
]
as
$k
=>
$v
)
{
if
(
is_array
(
$row
[
'postdata'
]))
{
$array
=
[];
foreach
(
$row
[
'postdata'
]
as
$k
=>
$v
)
{
$array
[
$k
]
=
$this
->
prep_for_form
(
$v
);
}
$post_ref
=
$array
;
}
else
{
}
else
{
$post_ref
=
$this
->
prep_for_form
(
$row
[
'postdata'
]);
}
}
...
...
@@ -448,19 +406,19 @@ class Validation {
* Executes the Validation routines
*
* @access private
*
* @param array
* @param array
* @param mixed
* @param integer
*
* @return mixed
*/
function
_execute
(
$row
,
$rules
,
$postdata
=
NULL
,
$cycles
=
0
)
function
_execute
(
$row
,
$rules
,
$postdata
=
null
,
$cycles
=
0
)
{
// If the $_POST data is an array we will run a recursive call
if
(
is_array
(
$postdata
))
{
foreach
(
$postdata
as
$key
=>
$val
)
{
if
(
is_array
(
$postdata
))
{
foreach
(
$postdata
as
$key
=>
$val
)
{
$this
->
_execute
(
$row
,
$rules
,
$val
,
$cycles
);
$cycles
++
;
}
...
...
@@ -471,17 +429,13 @@ class Validation {
// --------------------------------------------------------------------
// If the field is blank, but NOT required, no further tests are necessary
$callback
=
FALSE
;
if
(
!
in_array
(
'required'
,
$rules
)
AND
is_null
(
$postdata
))
{
$callback
=
false
;
if
(
!
in_array
(
'required'
,
$rules
)
AND
is_null
(
$postdata
))
{
// Before we bail out, does the rule contain a callback?
if
(
preg_match
(
"/(callback_\w+)/"
,
implode
(
' '
,
$rules
),
$match
))
{
$callback
=
TRUE
;
$rules
=
(
array
(
'1'
=>
$match
[
1
]));
}
else
{
if
(
preg_match
(
"/(callback_\w+)/"
,
implode
(
' '
,
$rules
),
$match
))
{
$callback
=
true
;
$rules
=
([
'1'
=>
$match
[
1
]]);
}
else
{
return
;
}
}
...
...
@@ -489,22 +443,16 @@ class Validation {
// --------------------------------------------------------------------
// Isset Test. Typically this rule will only apply to checkboxes.
if
(
is_null
(
$postdata
)
AND
$callback
==
FALSE
)
{
if
(
in_array
(
'isset'
,
$rules
,
TRUE
)
OR
in_array
(
'required'
,
$rules
))
{
if
(
is_null
(
$postdata
)
AND
$callback
==
false
)
{
if
(
in_array
(
'isset'
,
$rules
,
true
)
OR
in_array
(
'required'
,
$rules
))
{
// Set the message type
$type
=
(
in_array
(
'required'
,
$rules
))
?
'required'
:
'isset'
;
if
(
!
isset
(
$this
->
_error_messages
[
$type
]))
{
if
(
FALSE
===
(
$line
=
$this
->
get_error_message
(
$type
)))
{
if
(
!
isset
(
$this
->
_error_messages
[
$type
]))
{
if
(
false
===
(
$line
=
$this
->
get_error_message
(
$type
)))
{
$line
=
'The field was not set'
;
}
}
else
{
}
else
{
$line
=
$this
->
_error_messages
[
$type
];
}
...
...
@@ -514,8 +462,7 @@ class Validation {
// Save the error message
$this
->
_field_data
[
$row
[
'field'
]][
'error'
]
=
$message
;
if
(
!
isset
(
$this
->
_error_array
[
$row
[
'field'
]]))
{
if
(
!
isset
(
$this
->
_error_array
[
$row
[
'field'
]]))
{
$this
->
_error_array
[
$row
[
'field'
]]
=
$message
;
}
}
...
...
@@ -526,53 +473,44 @@ class Validation {
// --------------------------------------------------------------------
// Cycle through each rule and run it
foreach
(
$rules
As
$rule
)
{
$_in_array
=
FALSE
;
foreach
(
$rules
As
$rule
)
{
$_in_array
=
false
;
// We set the $postdata variable with the current data in our master array so that
// each cycle of the loop is dealing with the processed data from the last cycle
if
(
$row
[
'is_array'
]
==
TRUE
AND
is_array
(
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
]))
{
if
(
$row
[
'is_array'
]
==
true
AND
is_array
(
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
]))
{
// We shouldn't need this safety, but just in case there isn't an array index
// associated with this cycle we'll bail out
if
(
!
isset
(
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
]))
{
if
(
!
isset
(
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
]))
{
continue
;
}
$postdata
=
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
];
$_in_array
=
TRUE
;
}
else
{
$_in_array
=
true
;
}
else
{
$postdata
=
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
];
}
// --------------------------------------------------------------------
// Is the rule a callback?
$callback
=
FALSE
;
if
(
substr
(
$rule
,
0
,
9
)
==
'callback_'
)
{
$callback
=
false
;
if
(
substr
(
$rule
,
0
,
9
)
==
'callback_'
)
{
$rule
=
substr
(
$rule
,
9
);
$callback
=
TRUE
;
$callback
=
true
;
}
// Strip the parameter (if exists) from the rule
// Rules can contain a parameter: max_length[5]
$param
=
FALSE
;
if
(
preg_match
(
"/(.*?)\[(.*?)\]/"
,
$rule
,
$match
))
{
$param
=
false
;
if
(
preg_match
(
"/(.*?)\[(.*?)\]/"
,
$rule
,
$match
))
{
$rule
=
$match
[
1
];
$param
=
$match
[
2
];
}
// Call the function that corresponds to the rule
if
(
$callback
===
TRUE
)
{
if
(
!
method_exists
(
$this
->
CI
,
$rule
))
{
if
(
$callback
===
true
)
{
if
(
!
method_exists
(
$this
->
CI
,
$rule
))
{
continue
;
}
...
...
@@ -580,37 +518,27 @@ class Validation {
$result
=
$this
->
CI
->
$rule
(
$postdata
,
$param
);
// Re-assign the result to the master data array
if
(
$_in_array
==
TRUE
)
{
if
(
$_in_array
==
true
)
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
else
{
}
else
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
// If the field isn't required and we just processed a callback we'll move on...
if
(
!
in_array
(
'required'
,
$rules
,
TRUE
)
AND
$result
!==
FALSE
)
{
if
(
!
in_array
(
'required'
,
$rules
,
true
)
AND
$result
!==
false
)
{
continue
;
}
}
else
{
if
(
!
method_exists
(
$this
,
$rule
))
{
}
else
{
if
(
!
method_exists
(
$this
,
$rule
))
{
// If our own wrapper function doesn't exist we see if a native PHP function does.
// Users can use any native PHP function call that has one param.
if
(
function_exists
(
$rule
))
{
if
(
function_exists
(
$rule
))
{
$result
=
$rule
(
$postdata
);
if
(
$_in_array
==
TRUE
)
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
else
{
if
(
$_in_array
==
true
)
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
else
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
}
...
...
@@ -620,35 +548,26 @@ class Validation {
$result
=
$this
->
$rule
(
$postdata
,
$param
);
if
(
$_in_array
==
TRUE
)
{
if
(
$_in_array
==
true
)
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
][
$cycles
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
else
{
}
else
{
$this
->
_field_data
[
$row
[
'field'
]][
'postdata'
]
=
(
is_bool
(
$result
))
?
$postdata
:
$result
;
}
}
// Did the rule test negatively? If so, grab the error.
if
(
$result
===
FALSE
)
{
if
(
!
isset
(
$this
->
_error_messages
[
$rule
]))
{
if
(
FALSE
===
(
$line
=
$this
->
get_error_message
(
$rule
)))
{
if
(
$result
===
false
)
{
if
(
!
isset
(
$this
->
_error_messages
[
$rule
]))
{
if
(
false
===
(
$line
=
$this
->
get_error_message
(
$rule
)))
{
$line
=
'Unable to access an error message corresponding to your field name.'
;
}
}
else
{
}
else
{
$line
=
$this
->
_error_messages
[
$rule
];
}
// Is the parameter we are inserting into the error message the name
// of another field? If so we need to grab its "field label"
if
(
isset
(
$this
->
_field_data
[
$param
])
AND
isset
(
$this
->
_field_data
[
$param
][
'label'
]))
{
if
(
isset
(
$this
->
_field_data
[
$param
])
AND
isset
(
$this
->
_field_data
[
$param
][
'label'
]))
{
$param
=
$this
->
_field_data
[
$param
][
'label'
];
}
...
...
@@ -658,8 +577,7 @@ class Validation {
// Save the error message
$this
->
_field_data
[
$row
[
'field'
]][
'error'
]
=
$message
;
if
(
!
isset
(
$this
->
_error_array
[
$row
[
'field'
]]))
{
if
(
!
isset
(
$this
->
_error_array
[
$row
[
'field'
]]))
{
$this
->
_error_array
[
$row
[
'field'
]]
=
$message
;
}
...
...
@@ -671,7 +589,6 @@ class Validation {
function
form_error
(
$field
=
''
,
$prefix
=
''
,
$suffix
=
''
)
{
return
$this
->
error
(
$field
,
$prefix
,
$suffix
);
}
...
...
@@ -686,21 +603,21 @@ class Validation {
* Translate a field name
*
* @access private
*
* @param string the field name
*
* @return string
*/
function
_translate_fieldname
(
$fieldname
)
{
// Do we need to translate the field name?
// We look for the prefix lang: to determine this
if
(
substr
(
$fieldname
,
0
,
5
)
==
'lang:'
)
{
if
(
substr
(
$fieldname
,
0
,
5
)
==
'lang:'
)
{
// Grab the variable
$line
=
substr
(
$fieldname
,
5
);
// Were we able to translate the field name? If not we use $line
if
(
FALSE
===
(
$fieldname
=
$this
->
get_error_message
(
$line
)))
{
if
(
false
===
(
$fieldname
=
$this
->
get_error_message
(
$line
)))
{
return
$line
;
}
}
...
...
@@ -717,14 +634,15 @@ class Validation {
* with, or, if that value doesn't exist, with the default
*
* @access public
*
* @param string the field name
* @param string
*
* @return mixed
*/
function
set_value
(
$field
=
''
,
$default
=
''
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
]))
{
if
(
!
isset
(
$this
->
_field_data
[
$field
]))
{
return
$default
;
}
...
...
@@ -740,34 +658,30 @@ class Validation {
* selected in the event of an error
*
* @access public
*
* @param string
* @param string
*
* @return string
*/
function
set_select
(
$field
=
''
,
$value
=
''
,
$default
=
FALSE
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
])
OR
!
isset
(
$this
->
_field_data
[
$field
][
'postdata'
]))
{
if
(
$default
===
TRUE
AND
count
(
$this
->
_field_data
)
===
0
)
function
set_select
(
$field
=
''
,
$value
=
''
,
$default
=
false
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
])
OR
!
isset
(
$this
->
_field_data
[
$field
][
'postdata'
]))
{
if
(
$default
===
true
AND
count
(
$this
->
_field_data
)
===
0
)
{
return
' selected="selected"'
;
}
return
''
;
}
$field
=
$this
->
_field_data
[
$field
][
'postdata'
];
if
(
is_array
(
$field
))
{
if
(
!
in_array
(
$value
,
$field
))
{
if
(
is_array
(
$field
))
{
if
(
!
in_array
(
$value
,
$field
))
{
return
''
;
}
}
else
{
if
((
$field
==
''
OR
$value
==
''
)
OR
(
$field
!=
$value
))
{
}
else
{
if
((
$field
==
''
OR
$value
==
''
)
OR
(
$field
!=
$value
))
{
return
''
;
}
}
...
...
@@ -784,34 +698,30 @@ class Validation {
* selected in the event of an error
*
* @access public
*
* @param string
* @param string
*
* @return string
*/
function
set_radio
(
$field
=
''
,
$value
=
''
,
$default
=
FALSE
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
])
OR
!
isset
(
$this
->
_field_data
[
$field
][
'postdata'
]))
{
if
(
$default
===
TRUE
AND
count
(
$this
->
_field_data
)
===
0
)
function
set_radio
(
$field
=
''
,
$value
=
''
,
$default
=
false
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
])
OR
!
isset
(
$this
->
_field_data
[
$field
][
'postdata'
]))
{
if
(
$default
===
true
AND
count
(
$this
->
_field_data
)
===
0
)
{
return
' checked="checked"'
;
}
return
''
;
}
$field
=
$this
->
_field_data
[
$field
][
'postdata'
];
if
(
is_array
(
$field
))
{
if
(
!
in_array
(
$value
,
$field
))
{
if
(
is_array
(
$field
))
{
if
(
!
in_array
(
$value
,
$field
))
{
return
''
;
}
}
else
{
if
((
$field
==
''
OR
$value
==
''
)
OR
(
$field
!=
$value
))
{
}
else
{
if
((
$field
==
''
OR
$value
==
''
)
OR
(
$field
!=
$value
))
{
return
''
;
}
}
...
...
@@ -828,34 +738,30 @@ class Validation {
* selected in the event of an error
*
* @access public
*
* @param string
* @param string
*
* @return string
*/
function
set_checkbox
(
$field
=
''
,
$value
=
''
,
$default
=
FALSE
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
])
OR
!
isset
(
$this
->
_field_data
[
$field
][
'postdata'
]))
{
if
(
$default
===
TRUE
AND
count
(
$this
->
_field_data
)
===
0
)
function
set_checkbox
(
$field
=
''
,
$value
=
''
,
$default
=
false
)
{
if
(
!
isset
(
$this
->
_field_data
[
$field
])
OR
!
isset
(
$this
->
_field_data
[
$field
][
'postdata'
]))
{
if
(
$default
===
true
AND
count
(
$this
->
_field_data
)
===
0
)
{
return
' checked="checked"'
;
}
return
''
;
}
$field
=
$this
->
_field_data
[
$field
][
'postdata'
];
if
(
is_array
(
$field
))
{
if
(
!
in_array
(
$value
,
$field
))
{
if
(
is_array
(
$field
))
{
if
(
!
in_array
(
$value
,
$field
))
{
return
''
;
}
}
else
{
if
((
$field
==
''
OR
$value
==
''
)
OR
(
$field
!=
$value
))
{
}
else
{
if
((
$field
==
''
OR
$value
==
''
)
OR
(
$field
!=
$value
))
{
return
''
;
}
}
...
...
@@ -869,18 +775,17 @@ class Validation {
* Required
*
* @access public
*
* @param string
*
* @return bool
*/
function
required
(
$str
)
{
if
(
!
is_array
(
$str
))
{
return
(
trim
(
$str
)
==
''
)
?
FALSE
:
TRUE
;
}
else
{
return
(
!
empty
(
$str
));
if
(
!
is_array
(
$str
))
{
return
(
trim
(
$str
)
==
''
)
?
false
:
true
;
}
else
{
return
(
!
empty
(
$str
));
}
}
...
...
@@ -890,20 +795,21 @@ class Validation {
* Match one field to another
*
* @access public
*
* @param string
* @param field
*
* @return bool
*/
function
matches
(
$str
,
$field
)
{
if
(
!
isset
(
$_POST
[
$field
]))
{
return
FALSE
;
if
(
!
isset
(
$_POST
[
$field
]))
{
return
false
;
}
$field
=
$_POST
[
$field
];
return
(
$str
!==
$field
)
?
FALSE
:
TRUE
;
return
(
$str
!==
$field
)
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -912,23 +818,23 @@ class Validation {
* Minimum Length
*
* @access public
*
* @param string
* @param value
*
* @return bool
*/
function
min_length
(
$str
,
$val
)
{
if
(
preg_match
(
"/[^0-9]/"
,
$val
))
{
return
FALSE
;
if
(
preg_match
(
"/[^0-9]/"
,
$val
))
{
return
false
;
}
if
(
function_exists
(
'mb_strlen'
))
{
return
(
mb_strlen
(
$str
)
<
$val
)
?
FALSE
:
TRUE
;
if
(
function_exists
(
'mb_strlen'
))
{
return
(
mb_strlen
(
$str
)
<
$val
)
?
false
:
true
;
}
return
(
strlen
(
$str
)
<
$val
)
?
FALSE
:
TRUE
;
return
(
strlen
(
$str
)
<
$val
)
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -937,23 +843,23 @@ class Validation {
* Max Length
*
* @access public
*
* @param string
* @param value
*
* @return bool
*/
function
max_length
(
$str
,
$val
)
{
if
(
preg_match
(
"/[^0-9]/"
,
$val
))
{
return
FALSE
;
if
(
preg_match
(
"/[^0-9]/"
,
$val
))
{
return
false
;
}
if
(
function_exists
(
'mb_strlen'
))
{
return
(
mb_strlen
(
$str
)
>
$val
)
?
FALSE
:
TRUE
;
if
(
function_exists
(
'mb_strlen'
))
{
return
(
mb_strlen
(
$str
)
>
$val
)
?
false
:
true
;
}
return
(
strlen
(
$str
)
>
$val
)
?
FALSE
:
TRUE
;
return
(
strlen
(
$str
)
>
$val
)
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -962,23 +868,23 @@ class Validation {
* Exact Length
*
* @access public
*
* @param string
* @param value
*
* @return bool
*/
function
exact_length
(
$str
,
$val
)
{
if
(
preg_match
(
"/[^0-9]/"
,
$val
))
{
return
FALSE
;
if
(
preg_match
(
"/[^0-9]/"
,
$val
))
{
return
false
;
}
if
(
function_exists
(
'mb_strlen'
))
{
return
(
mb_strlen
(
$str
)
!=
$val
)
?
FALSE
:
TRUE
;
if
(
function_exists
(
'mb_strlen'
))
{
return
(
mb_strlen
(
$str
)
!=
$val
)
?
false
:
true
;
}
return
(
strlen
(
$str
)
!=
$val
)
?
FALSE
:
TRUE
;
return
(
strlen
(
$str
)
!=
$val
)
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -987,12 +893,15 @@ class Validation {
* Valid Email
*
* @access public
*
* @param string
*
* @return bool
*/
function
valid_email
(
$str
)
{
return
(
!
preg_match
(
"/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]
{
2,6
}
$/ix"
,
$str
))
?
FALSE
:
TRUE
;
return
(
!
preg_match
(
"/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]
{
2,6
}
$/ix"
,
$str
))
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1001,25 +910,24 @@ class Validation {
* Valid Emails
*
* @access public
*
* @param string
*
* @return bool
*/
function
valid_emails
(
$str
)
{
if
(
strpos
(
$str
,
','
)
===
FALSE
)
{
if
(
strpos
(
$str
,
','
)
===
false
)
{
return
$this
->
valid_email
(
trim
(
$str
));
}
foreach
(
explode
(
','
,
$str
)
as
$email
)
{
if
(
trim
(
$email
)
!=
''
&&
$this
->
valid_email
(
trim
(
$email
))
===
FALSE
)
{
return
FALSE
;
foreach
(
explode
(
','
,
$str
)
as
$email
)
{
if
(
trim
(
$email
)
!=
''
&&
$this
->
valid_email
(
trim
(
$email
))
===
false
)
{
return
false
;
}
}
return
TRUE
;
return
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1028,7 +936,9 @@ class Validation {
* Validate IP Address
*
* @access public
*
* @param string
*
* @return string
*/
function
valid_ip
(
$ip
)
...
...
@@ -1042,12 +952,14 @@ class Validation {
* Alpha
*
* @access public
*
* @param string
*
* @return bool
*/
function
alpha
(
$str
)
{
return
(
!
preg_match
(
"/^([a-z])+$/i"
,
$str
))
?
FALSE
:
TRUE
;
return
(
!
preg_match
(
"/^([a-z])+$/i"
,
$str
))
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1056,12 +968,14 @@ class Validation {
* Alpha-numeric
*
* @access public
*
* @param string
*
* @return bool
*/
function
alpha_numeric
(
$str
)
{
return
(
!
preg_match
(
"/^([a-z0-9])+$/i"
,
$str
))
?
FALSE
:
TRUE
;
return
(
!
preg_match
(
"/^([a-z0-9])+$/i"
,
$str
))
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1070,12 +984,14 @@ class Validation {
* Alpha-numeric with underscores and dashes
*
* @access public
*
* @param string
*
* @return bool
*/
function
alpha_dash
(
$str
)
{
return
(
!
preg_match
(
"/^([-a-z0-9_-])+$/i"
,
$str
))
?
FALSE
:
TRUE
;
return
(
!
preg_match
(
"/^([-a-z0-9_-])+$/i"
,
$str
))
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1084,13 +1000,14 @@ class Validation {
* Numeric
*
* @access public
*
* @param string
*
* @return bool
*/
function
numeric
(
$str
)
{
return
(
bool
)
preg_match
(
'/^[\-+]?[0-9]*\.?[0-9]+$/'
,
$str
);
return
(
bool
)
preg_match
(
'/^[\-+]?[0-9]*\.?[0-9]+$/'
,
$str
);
}
// --------------------------------------------------------------------
...
...
@@ -1099,12 +1016,14 @@ class Validation {
* Is Numeric
*
* @access public
*
* @param string
*
* @return bool
*/
function
is_numeric
(
$str
)
{
return
(
!
is_numeric
(
$str
))
?
FALSE
:
TRUE
;
return
(
!
is_numeric
(
$str
))
?
false
:
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1113,12 +1032,14 @@ class Validation {
* Integer
*
* @access public
*
* @param string
*
* @return bool
*/
function
integer
(
$str
)
{
return
(
bool
)
preg_match
(
'/^[\-+]?[0-9]+$/'
,
$str
);
return
(
bool
)
preg_match
(
'/^[\-+]?[0-9]+$/'
,
$str
);
}
// --------------------------------------------------------------------
...
...
@@ -1127,12 +1048,14 @@ class Validation {
* Is a Natural number (0,1,2,3, etc.)
*
* @access public
*
* @param string
*
* @return bool
*/
function
is_natural
(
$str
)
{
return
(
bool
)
preg_match
(
'/^[0-9]+$/'
,
$str
);
return
(
bool
)
preg_match
(
'/^[0-9]+$/'
,
$str
);
}
// --------------------------------------------------------------------
...
...
@@ -1141,22 +1064,22 @@ class Validation {
* Is a Natural number, but not a zero (1,2,3, etc.)
*
* @access public
*
* @param string
*
* @return bool
*/
function
is_natural_no_zero
(
$str
)
{
if
(
!
preg_match
(
'/^[0-9]+$/'
,
$str
))
{
return
FALSE
;
if
(
!
preg_match
(
'/^[0-9]+$/'
,
$str
))
{
return
false
;
}
if
(
$str
==
0
)
{
return
FALSE
;
if
(
$str
==
0
)
{
return
false
;
}
return
TRUE
;
return
true
;
}
// --------------------------------------------------------------------
...
...
@@ -1168,12 +1091,14 @@ class Validation {
* as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045
*
* @access public
*
* @param string
*
* @return bool
*/
function
valid_base64
(
$str
)
{
return
(
bool
)
!
preg_match
(
'/[^a-zA-Z0-9\/\+=]/'
,
$str
);
return
(
bool
)
!
preg_match
(
'/[^a-zA-Z0-9\/\+=]/'
,
$str
);
}
// --------------------------------------------------------------------
...
...
@@ -1185,27 +1110,26 @@ class Validation {
* Special characters are converted.
*
* @access public
*
* @param string
*
* @return string
*/
function
prep_for_form
(
$data
=
''
)
{
if
(
is_array
(
$data
))
{
foreach
(
$data
as
$key
=>
$val
)
{
if
(
is_array
(
$data
))
{
foreach
(
$data
as
$key
=>
$val
)
{
$data
[
$key
]
=
$this
->
prep_for_form
(
$val
);
}
return
$data
;
}
if
(
$this
->
_safe_form_data
==
FALSE
OR
$data
===
''
)
{
if
(
$this
->
_safe_form_data
==
false
OR
$data
===
''
)
{
return
$data
;
}
return
str_replace
(
array
(
"'"
,
'"'
,
'<'
,
'>'
),
array
(
"'"
,
"""
,
'<'
,
'>'
)
,
stripslashes
(
$data
));
return
str_replace
([
"'"
,
'"'
,
'<'
,
'>'
],
[
"'"
,
"""
,
'<'
,
'>'
]
,
stripslashes
(
$data
));
}
// --------------------------------------------------------------------
...
...
@@ -1214,18 +1138,18 @@ class Validation {
* Prep URL
*
* @access public
*
* @param string
*
* @return string
*/
function
prep_url
(
$str
=
''
)
{
if
(
$str
==
'http://'
OR
$str
==
''
)
{
if
(
$str
==
'http://'
OR
$str
==
''
)
{
return
''
;
}
if
(
substr
(
$str
,
0
,
7
)
!=
'http://'
&&
substr
(
$str
,
0
,
8
)
!=
'https://'
)
{
if
(
substr
(
$str
,
0
,
7
)
!=
'http://'
&&
substr
(
$str
,
0
,
8
)
!=
'https://'
)
{
$str
=
'http://'
.
$str
;
}
...
...
@@ -1238,7 +1162,9 @@ class Validation {
* Strip Image Tags
*
* @access public
*
* @param string
*
* @return string
*/
function
strip_image_tags
(
$str
)
...
...
@@ -1252,7 +1178,9 @@ class Validation {
* XSS Clean
*
* @access public
*
* @param string
*
* @return string
*/
function
xss_clean
(
$str
)
...
...
@@ -1266,14 +1194,15 @@ class Validation {
* Convert PHP tags to entities
*
* @access public
*
* @param string
*
* @return string
*/
function
encode_php_tags
(
$str
)
{
return
str_replace
(
array
(
'<?php'
,
'<?PHP'
,
'<?'
,
'?>'
),
array
(
'<?php'
,
'<?PHP'
,
'<?'
,
'?>'
)
,
$str
);
return
str_replace
([
'<?php'
,
'<?PHP'
,
'<?'
,
'?>'
],
[
'<?php'
,
'<?PHP'
,
'<?'
,
'?>'
]
,
$str
);
}
}
// END Form Validation Class
...
...
Please
register
or
sign in
to post a comment