Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
544e36a4
Commit
544e36a4
authored
Aug 07, 2015
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update validation for answers/comments/profile
parent
ea166e4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
account.php
qa-include/pages/account.php
+1
-1
qa-filter-basic.php
qa-include/plugins/qa-filter-basic.php
+14
-9
No files found.
qa-include/pages/account.php
View file @
544e36a4
...
...
@@ -77,7 +77,7 @@
$inprofile
=
array
();
foreach
(
$userfields
as
$userfield
)
$inprofile
[
$userfield
[
'fieldid'
]]
=
qa_post_text
(
'field_'
.
$userfield
[
'fieldid'
]);
$inprofile
[
$userfield
[
'fieldid'
]]
=
qa_post_text
(
'field_'
.
$userfield
[
'fieldid'
]);
if
(
!
qa_check_form_security_code
(
'account'
,
qa_post_text
(
'code'
)))
$errors
[
'page'
]
=
qa_lang_html
(
'misc/form_security_again'
);
...
...
qa-include/plugins/qa-filter-basic.php
View file @
544e36a4
...
...
@@ -90,22 +90,23 @@ class qa_filter_basic
public
function
filter_answer
(
&
$answer
,
&
$errors
,
$question
,
$oldanswer
)
{
$this
->
validate_
length
(
$errors
,
'content'
,
@
$answer
[
'content'
]
,
0
,
QA_DB_MAX_CONTENT_LENGTH
);
// for storage
$this
->
validate_
length
(
$errors
,
'content'
,
@
$answer
[
'text'
],
qa_opt
(
'min_len_a_content'
),
null
);
// for display
$this
->
validate_
field_length
(
$errors
,
$answer
,
'content'
,
0
,
QA_DB_MAX_CONTENT_LENGTH
);
// for storage
$this
->
validate_
field_length
(
$errors
,
$answer
,
'text'
,
qa_opt
(
'min_len_a_content'
),
null
,
'content'
);
// for display
$this
->
validate_post_email
(
$errors
,
$answer
);
}
public
function
filter_comment
(
&
$comment
,
&
$errors
,
$question
,
$parent
,
$oldcomment
)
{
$this
->
validate_
length
(
$errors
,
'content'
,
@
$comment
[
'content'
]
,
0
,
QA_DB_MAX_CONTENT_LENGTH
);
// for storage
$this
->
validate_
length
(
$errors
,
'content'
,
@
$comment
[
'text'
],
qa_opt
(
'min_len_c_content'
),
null
);
// for display
$this
->
validate_
field_length
(
$errors
,
$comment
,
'content'
,
0
,
QA_DB_MAX_CONTENT_LENGTH
);
// for storage
$this
->
validate_
field_length
(
$errors
,
$comment
,
'text'
,
qa_opt
(
'min_len_a_content'
),
null
,
'content'
);
// for display
$this
->
validate_post_email
(
$errors
,
$comment
);
}
public
function
filter_profile
(
&
$profile
,
&
$errors
,
$user
,
$oldprofile
)
{
foreach
(
$profile
as
$field
=>
$value
)
$this
->
validate_length
(
$errors
,
$field
,
$value
,
0
,
QA_DB_MAX_PROFILE_CONTENT_LENGTH
);
foreach
(
$profile
as
$field
=>
$value
)
{
$this
->
validate_field_length
(
$errors
,
$profile
,
$field
,
0
,
QA_DB_MAX_CONTENT_LENGTH
);
}
}
...
...
@@ -136,17 +137,21 @@ class qa_filter_basic
* @param int $minlength
* @param int $maxlength
*/
private
function
validate_field_length
(
&
$errors
,
&
$post
,
$key
,
$minlength
,
$maxlength
)
private
function
validate_field_length
(
&
$errors
,
&
$post
,
$key
,
$minlength
,
$maxlength
,
$errorKey
=
null
)
{
if
(
!
$errorKey
)
{
$errorKey
=
$key
;
}
// skip the field is key not set (for example, 'title' when recategorizing questions)
if
(
array_key_exists
(
$key
,
$post
))
{
$length
=
qa_strlen
(
$post
[
$key
]);
if
(
$length
<
$minlength
)
{
$errors
[
$
k
ey
]
=
$minlength
==
1
?
qa_lang
(
'main/field_required'
)
:
qa_lang_sub
(
'main/min_length_x'
,
$minlength
);
$errors
[
$
errorK
ey
]
=
$minlength
==
1
?
qa_lang
(
'main/field_required'
)
:
qa_lang_sub
(
'main/min_length_x'
,
$minlength
);
}
else
if
(
isset
(
$maxlength
)
&&
(
$length
>
$maxlength
))
{
$errors
[
$
k
ey
]
=
qa_lang_sub
(
'main/max_length_x'
,
$maxlength
);
$errors
[
$
errorK
ey
]
=
qa_lang_sub
(
'main/max_length_x'
,
$maxlength
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment