Skip to content

Commit b3819e5

Browse files
committed
feat: improved checks for update error cases especially with rewriting
1 parent cdb61d5 commit b3819e5

File tree

2 files changed

+157
-153
lines changed

2 files changed

+157
-153
lines changed

phpmyfaq/.htaccess

Lines changed: 149 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
# @link https://www.phpmyfaq.de
1414
# @since 2004-11-13
1515

16+
DirectoryIndex index.php
17+
1618
# always follow the symlinks
17-
Options +FollowSymlinks -MultiViews -Indexes
19+
<IfModule mod_negotiation.c>
20+
Options +FollowSymlinks -MultiViews -Indexes
21+
</IfModule>
1822

1923
# X-Frame-Options to prevent clickjacking
2024
Header always append X-Frame-Options SAMEORIGIN
@@ -25,149 +29,148 @@ Header always append X-Frame-Options SAMEORIGIN
2529
Header set Pragma "no-cache"
2630
</filesMatch>
2731

28-
29-
# This has to be 'On'
30-
RewriteEngine On
31-
32-
<IfModule mod_fcgid.c>
33-
RewriteCond %{HTTP:Authorization} .
34-
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
32+
# Set mod_rewrite
33+
<IfModule mod_rewrite.c>
34+
# This has to be 'On'
35+
RewriteEngine On
36+
37+
<IfModule mod_fcgid.c>
38+
RewriteCond %{HTTP:Authorization} .
39+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
40+
</IfModule>
41+
42+
# the path to your phpMyFAQ installation
43+
RewriteBase /
44+
45+
# Error pages
46+
ErrorDocument 404 /index.php?action=404
47+
48+
# General pages
49+
RewriteRule addcontent.html$ index.php?action=add [L,QSA]
50+
RewriteRule show-categories.html$ index.php?action=show [L,QSA]
51+
RewriteRule ^(search|ask|open-questions|contact|glossary|overview|login|privacy)\.html$ index.php?action=$1 [L,QSA]
52+
53+
# start page
54+
RewriteRule ^index.html$ index.php [PT]
55+
56+
# a solution ID page
57+
RewriteCond %{REQUEST_URI} solution_id_([0-9]+)\.html$ [NC]
58+
RewriteRule ^solution_id_(.*)\.html$ index.php?solution_id=$1 [L,QSA]
59+
60+
# the bookmarks page
61+
RewriteRule ^bookmarks\.html$ index.php?action=bookmarks [L,QSA]
62+
63+
# phpMyFAQ faq record page
64+
RewriteRule content/([0-9]+)/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$ index.php?action=faq&cat=$1&id=$2&artlang=$3 [L,QSA]
65+
66+
# phpMyFAQ category page with page count
67+
RewriteRule category/([0-9]+)/([0-9]+)/(.+)\.htm(l?)$ index.php?action=show&cat=$1&seite=$2 [L,QSA]
68+
69+
# phpMyFAQ category page
70+
RewriteRule category/([0-9]+)/(.+)\.htm(l?)$ index.php?action=show&cat=$1 [L,QSA]
71+
72+
# phpMyFAQ news page
73+
RewriteRule news/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$ index.php?action=news&newsid=$1&newslang=$2 [L,QSA]
74+
75+
# phpMyFAQ sitemap
76+
RewriteRule sitemap/([^\/]+)/([a-z\-]+)\.htm(l?)$ index.php?action=sitemap&letter=$1&lang=$2 [L,QSA]
77+
78+
# phpMyFAQ Google sitemap
79+
RewriteRule sitemap.xml$ sitemap.xml.php [L]
80+
RewriteRule sitemap.gz$ sitemap.xml.php?gz=1 [L]
81+
RewriteRule sitemap.xml.gz$ sitemap.xml.php?gz=1 [L]
82+
83+
# phpMyFAQ tags page with page count
84+
RewriteRule tags/([0-9]+)/([0-9]+)/(.+)\.htm(l?)$ index.php?action=search&tagging_id=$1&seite=$2 [L,QSA]
85+
86+
# phpMyFAQ tags page
87+
RewriteRule tags/([0-9]+)/([^\/]+)\.htm(l?)$ index.php?action=search&tagging_id=$1 [L,QSA]
88+
89+
# User pages
90+
RewriteRule user/(ucp|bookmarks|request-removal|logout) index.php?action=$1 [L,QSA]
91+
92+
# Private APIs
93+
RewriteRule api/(autocomplete|bookmark/([0-9]+)) api/index.php [L,QSA]
94+
95+
# Setup APIs
96+
RewriteRule api/setup/(check|backup|update-database) api/index.php [L,QSA]
97+
98+
# Administration API
99+
RewriteRule admin/api/(.*) admin/api/index.php [L,QSA]
100+
101+
# REST API v2.0
102+
# * http://[...]/api/v2.0/<ACTION>
103+
RewriteRule api/v2.0/version api/index.php [L,QSA]
104+
RewriteRule api/v2.0/language api/index.php [L,QSA]
105+
RewriteRule api/v2.0/categories api/index.php [L,QSA]
106+
RewriteRule api/v2.0/searches/popular api/index.php [L,QSA]
107+
RewriteRule api/v2.0/search api/index.php [L,QSA]
108+
RewriteRule api/v2.0/tags api/index.php [L,QSA]
109+
RewriteRule api/v2.0/open-questions api/index.php [L,QSA]
110+
RewriteRule api/v2.0/comments/([0-9]+) api/index.php [L,QSA]
111+
RewriteRule api/v2.0/attachments/([0-9]+) api/index.php [L,QSA]
112+
RewriteRule api/v2.0/news api/index.php [L,QSA]
113+
RewriteRule api/v2.0/login api/index.php [L,QSA]
114+
RewriteRule api/v2.0/faqs/([0-9]+) api.php?action=faqs&categoryId=$1 [L,QSA]
115+
RewriteRule api/v2.0/faqs/popular api.php?action=faqs&filter=popular [L,QSA]
116+
RewriteRule api/v2.0/faqs/latest api.php?action=faqs&filter=latest [L,QSA]
117+
RewriteRule api/v2.0/faqs/sticky api.php?action=faqs&filter=sticky [L,QSA]
118+
RewriteRule api/v2.0/faqs/tags/([0-9]+) api.php?action=faqs&tagId=$1 [L,QSA]
119+
RewriteRule api/v2.0/faqs api.php?action=faqs [L,QSA]
120+
RewriteRule api/v2.0/faq/([0-9]+)/([0-9]+) api.php?action=faq&categoryId=$1&recordId=$2 [L,QSA]
121+
122+
# REST API v2.1
123+
# * http://[...]/api/v2.1/<ACTION>
124+
RewriteRule api/v2.1/version api/index.php [L,QSA]
125+
RewriteRule api/v2.1/language api/index.php [L,QSA]
126+
RewriteRule api/v2.1/categories api/index.php [L,QSA]
127+
RewriteRule api/v2.1/searches/popular api/index.php [L,QSA]
128+
RewriteRule api/v2.1/search api/index.php [L,QSA]
129+
RewriteRule api/v2.1/tags api/index.php [L,QSA]
130+
RewriteRule api/v2.1/open-questions api/index.php [L,QSA]
131+
RewriteRule api/v2.1/comments/([0-9]+) api/index.php [L,QSA]
132+
RewriteRule api/v2.1/attachments/([0-9]+) api/index.php [L,QSA]
133+
RewriteRule api/v2.1/news api/index.php [L,QSA]
134+
RewriteRule api/v2.1/login api/index.php [L,QSA]
135+
RewriteRule api/v2.1/faqs/([0-9]+) api.php?action=faqs&categoryId=$1 [L,QSA]
136+
RewriteRule api/v2.1/faqs/popular api.php?action=faqs&filter=popular [L,QSA]
137+
RewriteRule api/v2.1/faqs/latest api.php?action=faqs&filter=latest [L,QSA]
138+
RewriteRule api/v2.1/faqs/sticky api.php?action=faqs&filter=sticky [L,QSA]
139+
RewriteRule api/v2.1/faqs/tags/([0-9]+) api.php?action=faqs&tagId=$1 [L,QSA]
140+
RewriteRule api/v2.1/faqs api.php?action=faqs [L,QSA]
141+
RewriteRule api/v2.1/faq/([0-9]+)/([0-9]+) api.php?action=faq&categoryId=$1&recordId=$2 [L,QSA]
142+
RewriteRule api/v2.1/faq api.php?action=faq [L,QSA]
143+
RewriteRule api/v2.1/register api.php?action=register [L,QSA]
144+
RewriteRule api/v2.1/question api.php?action=question [L,QSA]
145+
146+
# REST API v2.2
147+
# * http://[...]/api/v2.2/<ACTION>
148+
RewriteRule api/v2.2/version api/index.php [L,QSA]
149+
RewriteRule api/v2.2/title api/index.php [L,QSA]
150+
RewriteRule api/v2.2/language api/index.php [L,QSA]
151+
RewriteRule api/v2.2/categories api/index.php [L,QSA]
152+
RewriteRule api/v2.2/category api.php?action=category [L,QSA]
153+
RewriteRule api/v2.2/groups api/index.php [L,QSA]
154+
RewriteRule api/v2.2/searches/popular api/index.php [L,QSA]
155+
RewriteRule api/v2.2/search api/index.php [L,QSA]
156+
RewriteRule api/v2.2/tags api/index.php [L,QSA]
157+
RewriteRule api/v2.2/open-questions api/index.php [L,QSA]
158+
RewriteRule api/v2.2/comments/([0-9]+) api/index.php [L,QSA]
159+
RewriteRule api/v2.2/attachments/([0-9]+) api/index.php [L,QSA]
160+
RewriteRule api/v2.2/news api/index.php [L,QSA]
161+
RewriteRule api/v2.2/login api/index.php [L,QSA]
162+
RewriteRule api/v2.2/faqs/([0-9]+) api.php?action=faqs&categoryId=$1 [L,QSA]
163+
RewriteRule api/v2.2/faqs/popular api.php?action=faqs&filter=popular [L,QSA]
164+
RewriteRule api/v2.2/faqs/latest api.php?action=faqs&filter=latest [L,QSA]
165+
RewriteRule api/v2.2/faqs/sticky api.php?action=faqs&filter=sticky [L,QSA]
166+
RewriteRule api/v2.2/faqs/tags/([0-9]+) api.php?action=faqs&tagId=$1 [L,QSA]
167+
RewriteRule api/v2.2/faqs api.php?action=faqs [L,QSA]
168+
RewriteRule api/v2.2/faq/([0-9]+)/([0-9]+) api.php?action=faq&categoryId=$1&recordId=$2 [L,QSA]
169+
RewriteRule api/v2.2/faq api.php?action=faq [L,QSA]
170+
RewriteRule api/v2.2/register api.php?action=register [L,QSA]
171+
RewriteRule api/v2.2/question api.php?action=question [L,QSA]
172+
173+
# REST API v3.0
174+
# * http://[...]/api/v3.0/<ACTION>
175+
RewriteRule api/v3.0/(.*) api/index.php [L,QSA]
35176
</IfModule>
36-
37-
# the path to your phpMyFAQ installation
38-
RewriteBase /
39-
40-
# Error pages
41-
ErrorDocument 404 /index.php?action=404
42-
43-
# General pages
44-
RewriteRule addcontent.html$ index.php?action=add [L,QSA]
45-
RewriteRule show-categories.html$ index.php?action=show [L,QSA]
46-
RewriteRule ^(search|ask|open-questions|contact|glossary|overview|login|privacy)\.html$ index.php?action=$1 [L,QSA]
47-
48-
# start page
49-
RewriteRule ^index.html$ index.php [PT]
50-
51-
# a solution id page
52-
RewriteCond %{REQUEST_URI} solution_id_([0-9]+)\.html$ [NC]
53-
RewriteRule ^solution_id_(.*)\.html$ index.php?solution_id=$1 [L,QSA]
54-
55-
# the bookmarks page
56-
RewriteCond %{REQUEST_URI} /bookmarks\.html$ [NC]
57-
RewriteRule ^(.*)$ index.php?action=bookmarks [L,QSA]
58-
59-
# PMF faq record page
60-
RewriteRule content/([0-9]+)/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$ index.php?action=faq&cat=$1&id=$2&artlang=$3 [L,QSA]
61-
62-
# PMF category page with page count
63-
RewriteRule category/([0-9]+)/([0-9]+)/(.+)\.htm(l?)$ index.php?action=show&cat=$1&seite=$2 [L,QSA]
64-
65-
# PMF category page
66-
RewriteRule category/([0-9]+)/(.+)\.htm(l?)$ index.php?action=show&cat=$1 [L,QSA]
67-
68-
# PMF news page
69-
RewriteRule news/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$ index.php?action=news&newsid=$1&newslang=$2 [L,QSA]
70-
71-
# PMF sitemap
72-
RewriteRule sitemap/([^\/]+)/([a-z\-]+)\.htm(l?)$ index.php?action=sitemap&letter=$1&lang=$2 [L,QSA]
73-
74-
# PMF Google sitemap
75-
RewriteRule sitemap.xml$ sitemap.xml.php [L]
76-
RewriteRule sitemap.gz$ sitemap.xml.php?gz=1 [L]
77-
RewriteRule sitemap.xml.gz$ sitemap.xml.php?gz=1 [L]
78-
79-
# PMF tags page with page count
80-
RewriteRule tags/([0-9]+)/([0-9]+)/(.+)\.htm(l?)$ index.php?action=search&tagging_id=$1&seite=$2 [L,QSA]
81-
82-
# PMF tags page
83-
RewriteRule tags/([0-9]+)/([^\/]+)\.htm(l?)$ index.php?action=search&tagging_id=$1 [L,QSA]
84-
85-
# User pages
86-
RewriteRule user/(ucp|bookmarks|request-removal|logout) index.php?action=$1 [L,QSA]
87-
88-
89-
# Private APIs
90-
RewriteRule api/(autocomplete|bookmark/([0-9]+)) api/index.php [L,QSA]
91-
92-
93-
# Setup APIs
94-
RewriteRule api/setup/(check|backup|update-database) api/index.php [L,QSA]
95-
96-
# Administration API
97-
RewriteRule admin/api/(.*) admin/api/index.php [L,QSA]
98-
99-
# REST API v2.0
100-
# * http://[...]/api/v2.0/<ACTION>
101-
RewriteRule api/v2.0/version api/index.php [L,QSA]
102-
RewriteRule api/v2.0/language api/index.php [L,QSA]
103-
RewriteRule api/v2.0/categories api/index.php [L,QSA]
104-
RewriteRule api/v2.0/searches/popular api/index.php [L,QSA]
105-
RewriteRule api/v2.0/search api/index.php [L,QSA]
106-
RewriteRule api/v2.0/tags api/index.php [L,QSA]
107-
RewriteRule api/v2.0/open-questions api/index.php [L,QSA]
108-
RewriteRule api/v2.0/comments/([0-9]+) api/index.php [L,QSA]
109-
RewriteRule api/v2.0/attachments/([0-9]+) api/index.php [L,QSA]
110-
RewriteRule api/v2.0/news api/index.php [L,QSA]
111-
RewriteRule api/v2.0/login api/index.php [L,QSA]
112-
RewriteRule api/v2.0/faqs/([0-9]+) api.php?action=faqs&categoryId=$1 [L,QSA]
113-
RewriteRule api/v2.0/faqs/popular api.php?action=faqs&filter=popular [L,QSA]
114-
RewriteRule api/v2.0/faqs/latest api.php?action=faqs&filter=latest [L,QSA]
115-
RewriteRule api/v2.0/faqs/sticky api.php?action=faqs&filter=sticky [L,QSA]
116-
RewriteRule api/v2.0/faqs/tags/([0-9]+) api.php?action=faqs&tagId=$1 [L,QSA]
117-
RewriteRule api/v2.0/faqs api.php?action=faqs [L,QSA]
118-
RewriteRule api/v2.0/faq/([0-9]+)/([0-9]+) api.php?action=faq&categoryId=$1&recordId=$2 [L,QSA]
119-
120-
# REST API v2.1
121-
# * http://[...]/api/v2.1/<ACTION>
122-
RewriteRule api/v2.1/version api/index.php [L,QSA]
123-
RewriteRule api/v2.1/language api/index.php [L,QSA]
124-
RewriteRule api/v2.1/categories api/index.php [L,QSA]
125-
RewriteRule api/v2.1/searches/popular api/index.php [L,QSA]
126-
RewriteRule api/v2.1/search api/index.php [L,QSA]
127-
RewriteRule api/v2.1/tags api/index.php [L,QSA]
128-
RewriteRule api/v2.1/open-questions api/index.php [L,QSA]
129-
RewriteRule api/v2.1/comments/([0-9]+) api/index.php [L,QSA]
130-
RewriteRule api/v2.1/attachments/([0-9]+) api/index.php [L,QSA]
131-
RewriteRule api/v2.1/news api/index.php [L,QSA]
132-
RewriteRule api/v2.1/login api/index.php [L,QSA]
133-
RewriteRule api/v2.1/faqs/([0-9]+) api.php?action=faqs&categoryId=$1 [L,QSA]
134-
RewriteRule api/v2.1/faqs/popular api.php?action=faqs&filter=popular [L,QSA]
135-
RewriteRule api/v2.1/faqs/latest api.php?action=faqs&filter=latest [L,QSA]
136-
RewriteRule api/v2.1/faqs/sticky api.php?action=faqs&filter=sticky [L,QSA]
137-
RewriteRule api/v2.1/faqs/tags/([0-9]+) api.php?action=faqs&tagId=$1 [L,QSA]
138-
RewriteRule api/v2.1/faqs api.php?action=faqs [L,QSA]
139-
RewriteRule api/v2.1/faq/([0-9]+)/([0-9]+) api.php?action=faq&categoryId=$1&recordId=$2 [L,QSA]
140-
RewriteRule api/v2.1/faq api.php?action=faq [L,QSA]
141-
RewriteRule api/v2.1/register api.php?action=register [L,QSA]
142-
RewriteRule api/v2.1/question api.php?action=question [L,QSA]
143-
144-
# REST API v2.2
145-
# * http://[...]/api/v2.2/<ACTION>
146-
RewriteRule api/v2.2/version api/index.php [L,QSA]
147-
RewriteRule api/v2.2/title api/index.php [L,QSA]
148-
RewriteRule api/v2.2/language api/index.php [L,QSA]
149-
RewriteRule api/v2.2/categories api/index.php [L,QSA]
150-
RewriteRule api/v2.2/category api.php?action=category [L,QSA]
151-
RewriteRule api/v2.2/groups api/index.php [L,QSA]
152-
RewriteRule api/v2.2/searches/popular api/index.php [L,QSA]
153-
RewriteRule api/v2.2/search api/index.php [L,QSA]
154-
RewriteRule api/v2.2/tags api/index.php [L,QSA]
155-
RewriteRule api/v2.2/open-questions api/index.php [L,QSA]
156-
RewriteRule api/v2.2/comments/([0-9]+) api/index.php [L,QSA]
157-
RewriteRule api/v2.2/attachments/([0-9]+) api/index.php [L,QSA]
158-
RewriteRule api/v2.2/news api/index.php [L,QSA]
159-
RewriteRule api/v2.2/login api/index.php [L,QSA]
160-
RewriteRule api/v2.2/faqs/([0-9]+) api.php?action=faqs&categoryId=$1 [L,QSA]
161-
RewriteRule api/v2.2/faqs/popular api.php?action=faqs&filter=popular [L,QSA]
162-
RewriteRule api/v2.2/faqs/latest api.php?action=faqs&filter=latest [L,QSA]
163-
RewriteRule api/v2.2/faqs/sticky api.php?action=faqs&filter=sticky [L,QSA]
164-
RewriteRule api/v2.2/faqs/tags/([0-9]+) api.php?action=faqs&tagId=$1 [L,QSA]
165-
RewriteRule api/v2.2/faqs api.php?action=faqs [L,QSA]
166-
RewriteRule api/v2.2/faq/([0-9]+)/([0-9]+) api.php?action=faq&categoryId=$1&recordId=$2 [L,QSA]
167-
RewriteRule api/v2.2/faq api.php?action=faq [L,QSA]
168-
RewriteRule api/v2.2/register api.php?action=register [L,QSA]
169-
RewriteRule api/v2.2/question api.php?action=question [L,QSA]
170-
171-
# REST API v3.0
172-
# * http://[...]/api/v3.0/<ACTION>
173-
RewriteRule api/v3.0/(.*) api/index.php [L,QSA]

phpmyfaq/assets/src/configuration/update.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ export const handleUpdateInformation = async () => {
4040
});
4141

4242
if (!response.ok) {
43-
let errorMessage = 'Network response was not ok.';
44-
if (response.status === 404) {
45-
errorMessage = 'The requested resource was not found on the server. Please check your server configuration.';
46-
} else if (response.status === 409) {
47-
errorMessage = 'Maintenance mode is not enabled. Please enable it first.';
48-
}
49-
throw new Error(errorMessage);
43+
let errorMessage = await response.json();
44+
45+
throw new Error(errorMessage.message);
5046
}
5147

5248
const button = document.getElementById('phpmyfaq-update-next-step-button');
@@ -56,6 +52,11 @@ export const handleUpdateInformation = async () => {
5652
button.classList.remove('disabled');
5753
button.disabled = false;
5854
} catch (errorMessage) {
55+
if (errorMessage instanceof SyntaxError) {
56+
errorMessage = 'The requested resource was not found on the server. Please check your server configuration.';
57+
} else {
58+
errorMessage = errorMessage.message;
59+
}
5960
const alert = document.getElementById('phpmyfaq-update-check-alert');
6061
const alertResult = document.getElementById('phpmyfaq-update-check-result');
6162

0 commit comments

Comments
 (0)