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
deb08e2d
Commit
deb08e2d
authored
Jan 14, 2017
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (various Code_Sniffer suggestions)
parent
03b45775
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
67 additions
and
51 deletions
+67
-51
qa-config-example.php
qa-config-example.php
+0
-1
Metadata.php
qa-include/Q2A/Util/Metadata.php
+1
-1
Usage.php
qa-include/Q2A/Util/Usage.php
+4
-11
answer.php
qa-include/ajax/answer.php
+3
-2
format.php
qa-include/app/format.php
+5
-2
page.php
qa-include/app/page.php
+14
-8
hotness.php
qa-include/db/hotness.php
+1
-1
install.php
qa-include/db/install.php
+4
-2
account.php
qa-include/pages/account.php
+1
-1
admin-stats.php
qa-include/pages/admin/admin-stats.php
+0
-0
question-view.php
qa-include/pages/question-view.php
+2
-1
reset.php
qa-include/pages/reset.php
+1
-1
qa-filter-basic.php
qa-include/plugins/qa-filter-basic.php
+1
-1
qa-base.php
qa-include/qa-base.php
+2
-1
qa-check-lang.php
qa-include/qa-check-lang.php
+16
-9
qa-install.php
qa-include/qa-install.php
+0
-0
external-users-joomla.php
qa-include/util/external-users-joomla.php
+0
-0
string.php
qa-include/util/string.php
+1
-1
qa-recaptcha-captcha.php
qa-plugin/recaptcha-captcha/qa-recaptcha-captcha.php
+1
-1
AppFormatTest.php
qa-tests/AppFormatTest.php
+0
-0
BaseTest.php
qa-tests/BaseTest.php
+6
-6
qa-theme.php
qa-theme/SnowFlat/qa-theme.php
+4
-1
No files found.
qa-config-example.php
View file @
deb08e2d
...
...
@@ -196,4 +196,3 @@
And lastly... if you want to, you can predefine any constant from qa-db-maxima.php in this
file to override the default setting. Just make sure you know what you're doing!
*/
qa-include/Q2A/Util/Metadata.php
View file @
deb08e2d
...
...
@@ -45,7 +45,7 @@ class Q2A_Util_Metadata
* @param string $url URL linking to a metadata.json file
* @return array The metadata fetched from the file
*/
public
function
fetchFromUrl
(
$url
,
$type
=
'Plugin'
)
public
function
fetchFromUrl
(
$url
,
$type
=
'Plugin'
)
{
$contents
=
qa_retrieve_url
(
$url
);
$metadata
=
$this
->
getArrayFromJson
(
$contents
);
...
...
qa-include/Q2A/Util/Usage.php
View file @
deb08e2d
...
...
@@ -107,6 +107,8 @@ class Q2A_Util_Usage
public
function
output
()
{
$totaldelta
=
$this
->
delta
(
$this
->
startUsage
,
$this
->
getCurrent
());
$stages
=
$this
->
stages
;
$stages
[
'total'
]
=
$totaldelta
;
?>
<style>
.debug-table
{
border-collapse
:
collapse
;
width
:
auto
;
margin
:
20px
auto
;
}
...
...
@@ -153,13 +155,7 @@ class Q2A_Util_Usage
</tr>
</thead>
<tbody>
<?php
$stages
=
$this
->
stages
;
$stages
[
'total'
]
=
$totaldelta
;
foreach
(
$stages
as
$stage
=>
$stagedelta
)
:
?>
<?php
foreach
(
$stages
as
$stage
=>
$stagedelta
)
:
?>
<tr>
<td
class=
"row-heading"
>
<?php
echo
ucfirst
(
$stage
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%.1f'
,
$stagedelta
[
'clock'
]
*
1000
);
?>
</td>
...
...
@@ -175,9 +171,7 @@ class Q2A_Util_Usage
<td>
<?php
echo
sprintf
(
'%dk'
,
$stagedelta
[
'ram'
]
/
1024
);
?>
</td>
<td>
<?php
echo
sprintf
(
'%d%%'
,
$stagedelta
[
'ram'
]
?
(
$stagedelta
[
'ram'
]
*
100
/
$totaldelta
[
'ram'
])
:
0
);
?>
</td>
</tr>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</tbody>
</table>
...
...
@@ -215,5 +209,4 @@ class Q2A_Util_Usage
return
$delta
;
}
}
qa-include/ajax/answer.php
View file @
deb08e2d
...
...
@@ -80,10 +80,11 @@ if (@$question['basetype'] == 'Q' && !isset($question['closedbyid']) && !qa_user
$countanswers
=
$question
[
'acount'
]
+
1
;
if
(
$countanswers
==
1
)
if
(
$countanswers
==
1
)
{
echo
qa_lang_html
(
'question/1_answer_title'
)
.
"
\n
"
;
else
}
else
{
echo
qa_lang_html_sub
(
'question/x_answers_title'
,
$countanswers
)
.
"
\n
"
;
}
// Send back the HTML
...
...
qa-include/app/format.php
View file @
deb08e2d
...
...
@@ -1788,11 +1788,13 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor
}
else
{
$haschildren
=
false
;
foreach
(
$navcategories
as
$navcategory
)
// check if it has any children
foreach
(
$navcategories
as
$navcategory
)
{
// check if it has any children
if
(
!
strcmp
(
$navcategory
[
'parentid'
],
$categoryid
))
{
$haschildren
=
true
;
break
;
}
}
if
(
!
$haschildren
)
$keycategoryids
[
$categoryid
]
=
true
;
// show this category if it has no children
...
...
@@ -2004,13 +2006,14 @@ function qa_load_theme_class($theme, $template, $content, $request)
'QA_HTML_THEME_LAYER_URLTOROOT'
=>
"'"
.
qa_path_to_root
()
.
$layer
[
'urltoroot'
]
.
"'"
,
);
foreach
(
$searchwordreplace
as
$searchword
=>
$replace
)
foreach
(
$searchwordreplace
as
$searchword
=>
$replace
)
{
if
(
preg_match_all
(
'/\W('
.
preg_quote
(
$searchword
,
'/'
)
.
')\W/im'
,
$layerphp
,
$matches
,
PREG_PATTERN_ORDER
|
PREG_OFFSET_CAPTURE
))
{
$searchmatches
=
array_reverse
(
$matches
[
1
]);
// don't use preg_replace due to complication of escaping replacement phrase
foreach
(
$searchmatches
as
$searchmatch
)
$layerphp
=
substr_replace
(
$layerphp
,
$replace
,
$searchmatch
[
1
],
strlen
(
$searchmatch
[
0
]));
}
}
// echo '<pre style="text-align:left;">'.htmlspecialchars($layerphp).'</pre>'; // to debug munged code
...
...
qa-include/app/page.php
View file @
deb08e2d
...
...
@@ -268,23 +268,24 @@ function qa_output_content($qa_content)
// Slide down notifications
if
(
!
empty
(
$qa_content
[
'notices'
]))
if
(
!
empty
(
$qa_content
[
'notices'
]))
{
foreach
(
$qa_content
[
'notices'
]
as
$notice
)
{
$qa_content
[
'script_onloads'
][]
=
array
(
"qa_reveal(document.getElementById("
.
qa_js
(
$notice
[
'id'
])
.
"), 'notice');"
,
);
}
}
// Handle maintenance mode
if
(
qa_opt
(
'site_maintenance'
)
&&
(
$requestlower
!=
'login'
))
{
if
(
qa_get_logged_in_level
()
>=
QA_USER_LEVEL_ADMIN
)
{
if
(
!
isset
(
$qa_content
[
'error'
]))
if
(
!
isset
(
$qa_content
[
'error'
]))
{
$qa_content
[
'error'
]
=
strtr
(
qa_lang_html
(
'admin/maintenance_admin_only'
),
array
(
'^1'
=>
'<a href="'
.
qa_path_html
(
'admin/general'
)
.
'">'
,
'^2'
=>
'</a>'
,
));
}
}
else
{
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'misc/site_in_maintenance'
);
...
...
@@ -319,15 +320,18 @@ function qa_output_content($qa_content)
$script
=
array
(
'<script>'
);
if
(
isset
(
$qa_content
[
'script_var'
]))
foreach
(
$qa_content
[
'script_var'
]
as
$var
=>
$value
)
if
(
isset
(
$qa_content
[
'script_var'
]))
{
foreach
(
$qa_content
[
'script_var'
]
as
$var
=>
$value
)
{
$script
[]
=
'var '
.
$var
.
' = '
.
qa_js
(
$value
)
.
';'
;
}
}
if
(
isset
(
$qa_content
[
'script_lines'
]))
if
(
isset
(
$qa_content
[
'script_lines'
]))
{
foreach
(
$qa_content
[
'script_lines'
]
as
$scriptlines
)
{
$script
[]
=
''
;
$script
=
array_merge
(
$script
,
$scriptlines
);
}
}
$script
[]
=
'</script>'
;
...
...
@@ -739,11 +743,12 @@ function qa_content_prepare($voting = false, $categoryids = null)
'label'
=>
qa_lang_html
(
'main/nav_updates'
),
);
if
(
!
empty
(
$userlinks
[
'logout'
]))
if
(
!
empty
(
$userlinks
[
'logout'
]))
{
$qa_content
[
'navigation'
][
'user'
][
'logout'
]
=
array
(
'url'
=>
qa_html
(
@
$userlinks
[
'logout'
]),
'label'
=>
qa_lang_html
(
'main/nav_logout'
),
);
}
if
(
!
QA_FINAL_EXTERNAL_USERS
)
{
$source
=
qa_get_logged_in_source
();
...
...
@@ -751,7 +756,7 @@ function qa_content_prepare($voting = false, $categoryids = null)
if
(
strlen
(
$source
))
{
$loginmodules
=
qa_load_modules_with
(
'login'
,
'match_source'
);
foreach
(
$loginmodules
as
$module
)
foreach
(
$loginmodules
as
$module
)
{
if
(
$module
->
match_source
(
$source
)
&&
method_exists
(
$module
,
'logout_html'
))
{
ob_start
();
$module
->
logout_html
(
qa_path
(
'logout'
,
array
(),
qa_opt
(
'site_url'
)));
...
...
@@ -759,6 +764,7 @@ function qa_content_prepare($voting = false, $categoryids = null)
}
}
}
}
$notices
=
qa_db_get_pending_result
(
'notices'
);
foreach
(
$notices
as
$notice
)
...
...
qa-include/db/hotness.php
View file @
deb08e2d
...
...
@@ -35,7 +35,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* @param bool $viewincrement
* @return mixed
*/
function
qa_db_hotness_update
(
$firstpostid
,
$lastpostid
=
null
,
$viewincrement
=
false
)
function
qa_db_hotness_update
(
$firstpostid
,
$lastpostid
=
null
,
$viewincrement
=
false
)
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
...
...
qa-include/db/install.php
View file @
deb08e2d
...
...
@@ -641,13 +641,14 @@ function qa_db_check_tables()
$datacount
=
0
;
$datamissing
=
0
;
foreach
(
$definitions
as
$rawname
=>
$definition
)
foreach
(
$definitions
as
$rawname
=>
$definition
)
{
if
(
qa_db_add_table_prefix
(
$rawname
)
==
(
QA_MYSQL_TABLE_PREFIX
.
$rawname
))
{
$datacount
++
;
if
(
isset
(
$missing
[
$rawname
]))
$datamissing
++
;
}
}
if
(
$datacount
==
$datamissing
&&
$datamissing
==
count
(
$missing
))
return
'non-users-missing'
;
...
...
@@ -1548,7 +1549,7 @@ function qa_db_upgrade_tables()
// Perform any necessary recalculations, as determined by upgrade steps
foreach
(
$keyrecalc
as
$state
=>
$dummy
)
foreach
(
$keyrecalc
as
$state
=>
$dummy
)
{
while
(
$state
)
{
set_time_limit
(
60
);
...
...
@@ -1559,6 +1560,7 @@ function qa_db_upgrade_tables()
qa_db_upgrade_progress
(
qa_recalc_get_message
(
$state
));
}
}
}
...
...
qa-include/pages/account.php
View file @
deb08e2d
...
...
@@ -168,7 +168,7 @@ else {
qa_logged_in_user_flush
();
}
}
else
if
(
qa_clicked
(
'dosaveprofile'
)
&&
$pending_confirmation
)
{
}
elseif
(
qa_clicked
(
'dosaveprofile'
)
&&
$pending_confirmation
)
{
// only allow user to update email if they are not confirmed yet
$inemail
=
qa_post_text
(
'email'
);
...
...
qa-include/pages/admin/admin-stats.php
View file @
deb08e2d
qa-include/pages/question-view.php
View file @
deb08e2d
...
...
@@ -36,7 +36,7 @@ function qa_page_q_load_as($question, $childposts)
{
$answers
=
array
();
foreach
(
$childposts
as
$postid
=>
$post
)
foreach
(
$childposts
as
$postid
=>
$post
)
{
switch
(
$post
[
'type'
])
{
case
'A'
:
case
'A_HIDDEN'
:
...
...
@@ -44,6 +44,7 @@ function qa_page_q_load_as($question, $childposts)
$answers
[
$postid
]
=
$post
;
break
;
}
}
return
$answers
;
}
...
...
qa-include/pages/reset.php
View file @
deb08e2d
...
...
@@ -153,7 +153,7 @@ if (strlen($emailHandle) > 0) {
// User input wrong code so show field with error
$fields
[
'code'
][
'error'
]
=
qa_lang
(
'users/email_code_wrong'
);
}
}
else
if
(
qa_clicked
(
'donext'
))
{
}
elseif
(
qa_clicked
(
'donext'
))
{
// If user submitted the form with an empty code
$fields
[
'code'
][
'error'
]
=
qa_lang
(
'users/email_code_wrong'
);
}
...
...
qa-include/plugins/qa-filter-basic.php
View file @
deb08e2d
...
...
@@ -157,7 +157,7 @@ class qa_filter_basic
if
(
$length
<
$minlength
)
{
$errors
[
$errorKey
]
=
$minlength
==
1
?
qa_lang
(
'main/field_required'
)
:
qa_lang_sub
(
'main/min_length_x'
,
$minlength
);
}
else
if
(
isset
(
$maxlength
)
&&
(
$length
>
$maxlength
))
{
}
elseif
(
isset
(
$maxlength
)
&&
(
$length
>
$maxlength
))
{
$errors
[
$errorKey
]
=
qa_lang_sub
(
'main/max_length_x'
,
$maxlength
);
}
}
...
...
qa-include/qa-base.php
View file @
deb08e2d
...
...
@@ -219,7 +219,8 @@ function qa_initialize_constants_1()
}
else
{
$res
=
$str1
^
$str2
;
$ret
=
0
;
for
(
$i
=
strlen
(
$res
)
-
1
;
$i
>=
0
;
$i
--
)
$ret
|=
ord
(
$res
[
$i
]);
for
(
$i
=
strlen
(
$res
)
-
1
;
$i
>=
0
;
$i
--
)
$ret
|=
ord
(
$res
[
$i
]);
return
!
$ret
;
}
}
...
...
qa-include/qa-check-lang.php
View file @
deb08e2d
...
...
@@ -53,10 +53,11 @@ function get_phrase_substitutions($phrase)
{
$substitutions
=
array
();
if
(
preg_match_all
(
'/\^(([0-9]+)|([a-z_]+)|)/'
,
$phrase
,
$matches
))
if
(
preg_match_all
(
'/\^(([0-9]+)|([a-z_]+)|)/'
,
$phrase
,
$matches
))
{
foreach
(
$matches
[
0
]
as
$match
)
{
@
$substitutions
[
$match
]
++
;
}
}
return
$substitutions
;
}
...
...
@@ -125,23 +126,26 @@ output_finish_includes();
foreach
(
$definite
as
$key
=>
$valuecount
)
{
foreach
(
$valuecount
as
$value
=>
$count
)
{
if
(
!@
$defined
[
$key
][
$value
])
if
(
!@
$defined
[
$key
][
$value
])
{
output_lang_issue
(
$key
,
$value
,
'used by '
.
$count
.
' file/s but not defined'
);
}
}
}
foreach
(
$defined
as
$key
=>
$valuecount
)
{
foreach
(
$valuecount
as
$value
=>
$count
)
{
if
(
!@
$definite
[
$key
][
$value
]
&&
!@
$probable
[
$key
][
$value
]
&&
!@
$possible
[
$value
])
if
(
!@
$definite
[
$key
][
$value
]
&&
!@
$probable
[
$key
][
$value
]
&&
!@
$possible
[
$value
])
{
output_lang_issue
(
$key
,
$value
,
'defined but apparently not used'
);
}
}
}
foreach
(
$backmap
as
$phrase
=>
$where
)
{
if
(
count
(
$where
)
>
1
)
if
(
count
(
$where
)
>
1
)
{
foreach
(
$where
as
$onewhere
)
{
output_lang_issue
(
$onewhere
[
'prefix'
],
$onewhere
[
'key'
],
'contains the shared phrase "'
.
$phrase
.
'"'
,
false
);
}
}
}
require_once
QA_INCLUDE_DIR
.
'app/admin.php'
;
...
...
@@ -179,13 +183,13 @@ foreach ($languages as $code => $language) {
foreach
(
$langdefined
as
$key
=>
$valuecount
)
{
foreach
(
$valuecount
as
$value
=>
$count
)
{
if
(
!@
$defined
[
$key
][
$value
])
if
(
!@
$defined
[
$key
][
$value
])
{
output_lang_issue
(
$key
,
$value
,
'defined but not in US English files'
);
elseif
(
!
$langdifferent
[
$key
][
$value
])
}
elseif
(
!
$langdifferent
[
$key
][
$value
])
{
output_lang_issue
(
$key
,
$value
,
'identical to US English files'
,
false
);
else
}
else
{
foreach
(
$substitutions
[
$key
][
$value
]
as
$substitution
=>
$subcount
)
{
if
(
!@
$langsubstitutions
[
$key
][
$value
][
$substitution
])
output_lang_issue
(
$key
,
$value
,
'omitted the substitution '
.
$substitution
);
...
...
@@ -194,6 +198,7 @@ foreach ($languages as $code => $language) {
}
}
}
}
foreach
(
$defined
as
$key
=>
$valuecount
)
{
$showaserror
=
!
((
$key
==
'admin'
)
||
(
$key
==
'options'
)
||
(
$code
==
'en-GB'
));
...
...
@@ -202,16 +207,18 @@ foreach ($languages as $code => $language) {
if
(
count
(
$langdefined
[
$key
])
<
(
count
(
$valuecount
)
/
2
))
{
// only a few phrases defined
output_lang_issue
(
$key
,
null
,
'few translations provided so will use US English defaults'
,
$showaserror
);
}
else
}
else
{
foreach
(
$valuecount
as
$value
=>
$count
)
{
if
(
!@
$langdefined
[
$key
][
$value
])
{
output_lang_issue
(
$key
,
$value
,
'undefined so will use US English defaults'
,
$showaserror
);
$langnewphrases
[
$key
][
$value
]
=
$english
[
$key
][
$value
];
}
}
}
else
}
}
else
{
output_lang_issue
(
$key
,
null
,
'no translations provided so will use US English defaults'
,
$showaserror
);
}
}
foreach
(
$langnewphrases
as
$prefix
=>
$phrases
)
{
echo
'<h2>'
.
$language
.
' phrases to add to <code>qa-lang/'
.
$code
.
'/qa-lang-'
.
$prefix
.
'.php</code>:</h2>'
;
...
...
qa-include/qa-install.php
View file @
deb08e2d
qa-include/util/external-users-joomla.php
View file @
deb08e2d
qa-include/util/string.php
View file @
deb08e2d
...
...
@@ -773,7 +773,7 @@ function qa_strtolower($string)
* @param int $length
* @return mixed|string
*/
function
qa_substr
(
$string
,
$start
,
$length
=
2147483647
)
function
qa_substr
(
$string
,
$start
,
$length
=
2147483647
)
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
...
...
qa-plugin/recaptcha-captcha/qa-recaptcha-captcha.php
View file @
deb08e2d
...
...
@@ -139,7 +139,7 @@ class qa_recaptcha_captcha
if
(
ini_get
(
'allow_url_fopen'
))
$recaptcha
=
new
ReCaptcha
(
qa_opt
(
'recaptcha_private_key'
));
else
$recaptcha
=
new
ReCaptcha
(
qa_opt
(
'recaptcha_private_key'
)
,
new
ReCaptchaSocketPostRequestMethod
());
$recaptcha
=
new
ReCaptcha
(
qa_opt
(
'recaptcha_private_key'
),
new
ReCaptchaSocketPostRequestMethod
());
$remoteIp
=
qa_remote_ip_address
();
$userResponse
=
qa_post_text
(
'g-recaptcha-response'
);
...
...
qa-tests/AppFormatTest.php
View file @
deb08e2d
qa-tests/BaseTest.php
View file @
deb08e2d
...
...
@@ -16,16 +16,16 @@ class BaseTest extends PHPUnit_Framework_TestCase
public
function
test__convert_to_bytes
()
{
$this
->
assertSame
(
102400
,
convert_to_bytes
(
'k'
,
100
));
$this
->
assertSame
(
104857600
,
convert_to_bytes
(
'm'
,
100
));
$this
->
assertSame
(
102400
,
convert_to_bytes
(
'k'
,
100
));
$this
->
assertSame
(
104857600
,
convert_to_bytes
(
'm'
,
100
));
$this
->
assertSame
(
107374182400
,
convert_to_bytes
(
'g'
,
100
));
$this
->
assertSame
(
102400
,
convert_to_bytes
(
'K'
,
100
));
$this
->
assertSame
(
104857600
,
convert_to_bytes
(
'M'
,
100
));
$this
->
assertSame
(
102400
,
convert_to_bytes
(
'K'
,
100
));
$this
->
assertSame
(
104857600
,
convert_to_bytes
(
'M'
,
100
));
$this
->
assertSame
(
107374182400
,
convert_to_bytes
(
'G'
,
100
));
$this
->
assertSame
(
100
,
convert_to_bytes
(
''
,
100
));
$this
->
assertSame
(
1048576
,
convert_to_bytes
(
'k'
,
1024
));
$this
->
assertSame
(
100
,
convert_to_bytes
(
''
,
100
));
$this
->
assertSame
(
1048576
,
convert_to_bytes
(
'k'
,
1024
));
}
public
function
test__qa_q_request
()
...
...
qa-theme/SnowFlat/qa-theme.php
View file @
deb08e2d
...
...
@@ -411,7 +411,10 @@ class qa_html_theme extends qa_html_theme_base
* @since Snow 1.4
* @param type $q_item
*/
public
function
view_count
(
$q_item
)
{}
public
function
view_count
(
$q_item
)
{
// do nothing
}
/**
* Add view counter to question view
...
...
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