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
3699ec82
Commit
3699ec82
authored
Sep 19, 2018
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version checks now return JSON
parent
ff847ff0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
18 deletions
+35
-18
qa-admin.js
qa-content/qa-admin.js
+11
-6
version.php
qa-include/ajax/version.php
+24
-12
No files found.
qa-content/qa-admin.js
View file @
3699ec82
...
...
@@ -149,13 +149,18 @@ function qa_admin_click(target)
function
qa_version_check
(
uri
,
version
,
elem
,
isCore
)
{
var
params
=
{
uri
:
uri
,
version
:
version
,
isCore
:
isCore
};
qa_ajax_post
(
'version'
,
{
uri
:
uri
,
version
:
version
,
isCore
:
isCore
},
function
(
response
)
{
if
(
response
.
result
===
'error'
)
{
alert
(
response
.
error
.
message
);
qa_ajax_post
(
'version'
,
params
,
function
(
lines
)
{
if
(
lines
[
0
]
==
'1'
)
document
.
getElementById
(
elem
).
innerHTML
=
lines
[
1
]
;
}
return
;
}
document
.
getElementById
(
elem
).
innerHTML
=
response
.
html
;
}
,
1
);
}
...
...
qa-include/ajax/version.php
View file @
3699ec82
...
...
@@ -23,28 +23,35 @@ require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
if
(
qa_get_logged_in_level
()
<
QA_USER_LEVEL_ADMIN
)
{
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
.
qa_lang_html
(
'admin/no_privileges'
);
$response
=
array
(
'result'
=>
'error'
,
'error'
=>
array
(
'message'
=>
qa_lang_html
(
'admin/no_privileges'
),
),
);
echo
json_encode
(
$response
);
return
;
}
$uri
=
qa_post_text
(
'uri'
);
$version
=
qa_post_text
(
'version'
);
$isCore
=
qa_post_text
(
'isCore'
)
===
"true"
;
$isCore
=
qa_post_text
(
'isCore'
)
===
'true'
;
if
(
$isCore
)
{
$contents
=
qa_retrieve_url
(
$uri
);
if
(
strlen
(
$contents
)
>
0
)
{
if
(
qa_qa_version_below
(
$contents
))
{
$
r
esponse
=
$
versionR
esponse
=
'<a href="https://github.com/q2a/question2answer/releases" style="color:#d00;">'
.
qa_lang_html_sub
(
'admin/version_get_x'
,
qa_html
(
'v'
.
$contents
))
.
'</a>'
;
}
else
{
$
r
esponse
=
qa_html
(
$contents
);
// Output the current version number
$
versionR
esponse
=
qa_html
(
$contents
);
// Output the current version number
}
}
else
{
$
r
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
$
versionR
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
}
}
else
{
$metadataUtil
=
new
Q2A_Util_Metadata
();
...
...
@@ -53,28 +60,33 @@ if ($isCore) {
if
(
strlen
(
@
$metadata
[
'version'
])
>
0
)
{
if
(
strcmp
(
$metadata
[
'version'
],
$version
))
{
if
(
qa_qa_version_below
(
@
$metadata
[
'min_q2a'
]))
{
$
r
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_q2a'
),
array
(
$
versionR
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_q2a'
),
array
(
'^1'
=>
qa_html
(
'v'
.
$metadata
[
'version'
]),
'^2'
=>
qa_html
(
$metadata
[
'min_q2a'
]),
));
}
elseif
(
qa_php_version_below
(
@
$metadata
[
'min_php'
]))
{
$
r
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_php'
),
array
(
$
versionR
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_php'
),
array
(
'^1'
=>
qa_html
(
'v'
.
$metadata
[
'version'
]),
'^2'
=>
qa_html
(
$metadata
[
'min_php'
]),
));
}
else
{
$
r
esponse
=
qa_lang_html_sub
(
'admin/version_get_x'
,
qa_html
(
'v'
.
$metadata
[
'version'
]));
$
versionR
esponse
=
qa_lang_html_sub
(
'admin/version_get_x'
,
qa_html
(
'v'
.
$metadata
[
'version'
]));
if
(
strlen
(
@
$metadata
[
'uri'
]))
{
$
response
=
'<a href="'
.
qa_html
(
$metadata
[
'uri'
])
.
'" style="color:#d00;">'
.
$r
esponse
.
'</a>'
;
$
versionResponse
=
'<a href="'
.
qa_html
(
$metadata
[
'uri'
])
.
'" style="color:#d00;">'
.
$versionR
esponse
.
'</a>'
;
}
}
}
else
{
$
r
esponse
=
qa_lang_html
(
'admin/version_latest'
);
$
versionR
esponse
=
qa_lang_html
(
'admin/version_latest'
);
}
}
else
{
$
r
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
$
versionR
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
}
}
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
.
$response
;
$response
=
array
(
'result'
=>
'success'
,
'html'
=>
$versionResponse
,
);
echo
json_encode
(
$response
);
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