-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.php
398 lines (374 loc) · 17.9 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php if(!defined('PLX_ROOT')) exit;
# Control du token du formulaire
plxToken::validateFormToken($_POST);
# Liste des langues disponibles et prises en charge par le plugin
$aLangs = array($plxAdmin->aConf['default_lang']);
# Si le plugin plxMyMultiLingue est installé on filtre sur les langues utilisées
# On garde par défaut le fr si aucune langue sélectionnée dans plxMyMultiLingue
if(defined('PLX_MYMULTILINGUE')) {
$langs = plxMyMultiLingue::_Langs();
$multiLangs = empty($langs) ? array() : explode(',', $langs);
$aLangs = $multiLangs;
}
#onglet ouvert par défaut
$tab='#onglet-0';
# si maj
if(!empty($_POST)) {
if(isset($_POST['#onglet-1'])) $tab='#onglet-1';
if(isset($_POST['#onglet-2'])) $tab='#onglet-2';
if(isset($_POST['#onglet-3'])) $tab='#onglet-3';
if(isset($_POST['#onglet-4'])) $tab='#onglet-4';
if(isset($_POST['#onglet-5'])) $tab='#onglet-5';
if(isset($_POST['#onglet-6'])) $tab='#onglet-6';
if(isset($_POST['#onglet-7'])) $tab='#onglet-7';
if(isset($_POST['#onglet-8'])) $tab='#onglet-8';
if(isset($_POST['#onglet-9'])) $tab='#onglet-9';
if(isset($_POST['#onglet-10'])) $tab='#onglet-10';
# add any more if needed
if(!file_exists(PLX_ROOT.'robots.txt')) touch(PLX_ROOT.'robots.txt');
if(!file_exists(PLX_ROOT.'humans.txt')) touch(PLX_ROOT.'humans.txt');
if (class_exists('plxMySearch')&& $plxAdmin->plxPlugins->aPlugins['plxMySearch']->getParam('method') == 'get' && $plxAdmin->aConf['urlrewriting']) {
$plxMotor = plxMotor::getInstance();
$mysearch = $plxAdmin->plxPlugins->aPlugins['plxMySearch'];
$plxPlugin->setParam('openSearchAdult', $_POST['openSearchAdult'], 'string');
$plxPlugin->setParam('openSearchON', $_POST['openSearchON'], 'numeric');
}
$plxPlugin->setParam('ogON', $_POST['ogON'], 'numeric');
$plxPlugin->setParam('twON', $_POST['twON'], 'numeric');
$plxPlugin->setParam('ldAS', $_POST['ldAS'], 'string');
$plxPlugin->setParam('ldON', $_POST['ldON'], 'numeric');
if(version_compare(PLX_VERSION, '5.9.0', "<")) {
$plxPlugin->setParam('canON', $_POST['canON'], 'numeric');
$plxPlugin->setParam('canType', $_POST['canType'], 'numeric');
}
$plxPlugin->setParam('removeCat', $_POST['removeCat'], 'string');
$plxPlugin->setParam('removeStat', $_POST['removeStat'], 'string');
$plxPlugin->setParam('exArtLinkON', $_POST['exArtLinkON'], 'numeric');
$plxPlugin->setParam('prevNextON', $_POST['prevNextON'], 'numeric');
$plxPlugin->setParam('send404ON', $_POST['send404ON'], 'numeric');
$plxPlugin->setParam('cloneMode', $_POST['cloneMode'], 'string');
/* EXEMPLES
$plxPlugin->setParam('str', $_POST['str'], 'string');
$plxPlugin->setParam('cdata', $_POST['cdata'], 'cdata');
*/
# sauvegarde données modifiées
$plxPlugin->saveParams();
if($_POST['robotsTxt'] != file_get_contents(PLX_ROOT.'robots.txt')) {
file_put_contents(PLX_ROOT.'robots.txt',$_POST['robotsTxt']);
}
if($_POST['humansTxt'] != file_get_contents(PLX_ROOT.'humans.txt')) {
file_put_contents(PLX_ROOT.'humans.txt',$_POST['humansTxt']);
}
if($_POST['htaccess'] !== file_get_contents(PLX_ROOT.'.htaccess')) {
file_put_contents(PLX_ROOT.'.htaccess',$_POST['htaccess']);
}
# renvoi sur la page aprés traitement
header('Location: parametres_plugin.php?p='.basename(__DIR__).$tab);
exit;
}
#initialisation variables
$var['removeCat'] = $plxPlugin->getParam('removeCat') =='' ? '' : $plxPlugin->getParam('removeCat');
$var['removeStat'] = $plxPlugin->getParam('removeStat') =='' ? '' : $plxPlugin->getParam('removeStat');
$var['openSearchON'] = $plxPlugin->getParam('openSearchON') =='' ? 0 : $plxPlugin->getParam('openSearchON');
$var['openSearchAdult'] = $plxPlugin->getParam('openSearchAdult') =='' ? 'false' : $plxPlugin->getParam('openSearchAdult');
$var['twON'] = $plxPlugin->getParam('twON') =='' ? 0 : $plxPlugin->getParam('twON');
$var['ldAS'] = $plxPlugin->getParam('ldAS') =='' ? '' : $plxPlugin->getParam('ldAS');
$var['ldON'] = $plxPlugin->getParam('ldON') =='' ? 0 : $plxPlugin->getParam('ldON');
$var['ogON'] = $plxPlugin->getParam('ogON') =='' ? 0 : $plxPlugin->getParam('ogON');
$var['canON'] = $plxPlugin->getParam('canON') =='' ? 1 : $plxPlugin->getParam('canON');
$var['canType'] = $plxPlugin->getParam('canType') =='' ? 0 : $plxPlugin->getParam('canType');
$var['exArtLinkON'] = $plxPlugin->getParam('exArtLinkON') =='' ? 0 : $plxPlugin->getParam('exArtLinkON');
$var['prevNextON'] = $plxPlugin->getParam('prevNextON') =='' ? 0 : $plxPlugin->getParam('prevNextON');
$var['send404ON'] = $plxPlugin->getParam('send404ON') =='' ? 0 : $plxPlugin->getParam('send404ON');
$var['cloneMode'] = $plxPlugin->getParam('cloneMode') =='' ? 0 : $plxPlugin->getParam('cloneMode');
?>
<!-- formulaire -->
<h3><?php $plxPlugin->lang('L_CONFIG') ?></h3>
<div id="onglets">
<form id="form_<?= basename(__DIR__) ?>" action="parametres_plugin.php?p=<?= basename(__DIR__) ?>" method="post" class="<?= basename(__DIR__) ?>">
<?php if(version_compare(PLX_VERSION, '5.9.0', "<")) { ?>
<div class="onglet" data-title="URL canonique" class="<?php if($tab== '#onglet-0') echo 'active'; ?>">
<h4>canonical</h4>
<fieldset>
<legend>URLs</legend>
<p>
<label for="canON" ><?php $plxPlugin->lang('L_ACTIVATE') ?> :</label>
<?php plxUtils::printSelect('canON',array('1'=>L_YES,'0'=>L_NO),$var['canON']); ?>
</p>
<!--<p>
<label for="canType" ><?php $plxPlugin->lang('L_KEEP_NATIVE') ?> :</label>
<?php plxUtils::printSelect('canType',array('1'=>L_YES,'0'=>L_NO),$var['canType']); ?>
</p>
<p>
<?php $plxPlugin->lang('L_INFO_REWRITE') ?>
</p>-->
</fieldset>
</div>
<?php } ?>
<div class="onglet" data-title="sitemap" class="<?php if($tab== '#onglet-1') echo 'active'; ?>">
<h4>exclusion du sitemap</h4>
<fieldset>
<legend><?php $plxPlugin->lang('L_EXCLUDE_SITEMAP'); ?></legend>
<?php // a lie avec met no index no follow ?>
<div class="flex">
<label for="removeCat" class="flex">
<span><?php $plxPlugin->lang('L_REMOVE_SITEMAP_CATEGORY'); ?></span>
<?php plxUtils::printInput('removeCat',$plxPlugin->getParam('removeCat'),'text','') ?>
</label>
<details>
<summary><?php $plxPlugin->lang('L_LIST_CATEGORY'); ?></summary>
<ul>
<?php
foreach($plxAdmin->aCats as $Cat_num => $Cat_info) {
if($Cat_info['active']==1) {
echo '<li>N°<b>'.$Cat_num.'</b> - '. $Cat_info['name'].'</li>'.PHP_EOL;
}
}
?>
</ul>
</details>
</div>
<div class="flex">
<label for="removeStat" class="flex">
<span><?php $plxPlugin->lang('L_REMOVE_SITEMAP_STATIC'); ?></span>
<?php plxUtils::printInput('removeStat',$plxPlugin->getParam('removeStat'),'text','') ?>
</label>
<details><summary><?php $plxPlugin->lang('L_LIST_STATIC'); ?></summary>
<ul>
<?php
foreach($plxAdmin->aStats as $stat_num => $stat_info) {
if($stat_info['active']==1) {
echo '<li>N°<b>'.$stat_num.'</b> - '. $stat_info['name'].'</li>'.PHP_EOL;
}
}
?>
</ul>
</details>
</div>
</fieldset>
<div style="font-size:0.8em;max-width:60vw;margin:0.5em auto;display:flex;gap:1rem;align-items:center;" class="warning"><b class="help" style="padding:0 0.5em;">?</b><div><?php $plxPlugin->lang('L_EXCLUDE_SITEMAP_HELP'); ?></div>
</div>
</div>
<div class="onglet" data-title="open graph">
<h4>meta OG</h4>
<fieldset>
<legend><?php $plxPlugin->lang('L_ACTIVATE') ?> metas OpenGraph</legend>
<p>
<label for="ogON" ><?php $plxPlugin->lang('L_ACTIVATE') ?> :</label>
<?php plxUtils::printSelect('ogON',array('1'=>L_YES,'0'=>L_NO),$var['ogON']); ?>
</p>
</fieldset>
<div class="warning" style="display:flex;gap:0.15rem;"><b class="help">?</b> :<a href="https://fr.wikipedia.org/wiki/Open_Graph_Protocol" target="_blank">wikipedia</a>.</div>
</div>
<div class="onglet" data-title="json ld">
<h4>Json LD</h4>
<fieldset>
<legend><?php $plxPlugin->lang('L_ACTIVATE') ?> json metas</legend>
<p>
<label for="ldON" ><?php $plxPlugin->lang('L_ACTIVATE') ?> :</label>
<?php plxUtils::printSelect('ldON',array('1'=>L_YES,'0'=>L_NO),$var['ldON']); ?>
</p>
</fieldset>
<fieldset>
<legend><?php $plxPlugin->lang('L_ADD') ?> <?php $plxPlugin->lang('L_ADD_SAMEAS') ?> : </legend>
<p>
<label for="ldAS"><?php $plxPlugin->lang('L_ACCOUNT') ?> :</label>
<input type="text" id="sameAs" >
<button type="button" id="addAs"><?php $plxPlugin->lang('L_ADD') ?></button>
</p>
<input type="hidden" id="ldAS" name="ldAS" value="<?= $var['ldAS'] ?>">
<p><?php $plxPlugin->lang('L_LIST_SAMEAS')?></p>
<div id="listNetwork"></div>
<script>
const addAs = document.querySelector("#addAs");
const sameAs = document.querySelector("#sameAs");
const sameAsLinks = document.querySelector("#ldAS");
const ListNetwork = document.querySelector('#listNetwork')
addAs.addEventListener("click", modifyList);
function modifyList() {
let ploder = "";
if (sameAsLinks.value != "") {
ploder = " , ";
}
if (sameAs.value.trim() != "") {
sameAsLinks.value = sameAsLinks.value + ploder + sameAs.value.trim();
sameAs.value = "";
}
showList();
}
function showList() {
ListNetwork.innerHTML='';
let values=sameAsLinks.value.trim();
let SocialNetworks = values.split(" , ");
if (SocialNetworks.length > 0 && SocialNetworks[0] !="") {
const ul = document.createElement("ul");
SocialNetworks.forEach(function(item) {
const li = document.createElement('li');
li.textContent=item;
const anc = document.createElement('a');
anc.textContent='X';
anc.setAttribute('onClick','sameAsLinks.value=delItem(\''+item+'\');showList(sameAsLinks.value);');
anc.setAttribute('title','delete');
li.append(anc);
ul.append(li);
});
ListNetwork.append(ul);
}
else {
ListNetwork.innerHTML='0';
}
}
function delItem(value) {
let SocialNetworks = sameAsLinks.value.split(" , ");
return SocialNetworks.filter(function (e) {
return e != value;
});
}
showList();
</script>
</fieldset>
<div class="warning"><a href="https://validator.schema.org/" target="_blank">Validator schema.org</a> - <a href="https://fr.wikipedia.org/wiki/JSON-LD">Wikipedia</a> -<a href="https://support.google.com/webmasters/answer/3069489?hl=fr">Google Support</a></div>
</div>
<div class="onglet" data-title="twitter card">
<h4>meta twitter card</h4>
<fieldset>
<legend><?php $plxPlugin->lang('L_ACTIVATE') ?> meta twitter</legend>
<p>
<label for="twON" ><?php $plxPlugin->lang('L_ACTIVATE') ?> :</label>
<?php plxUtils::printSelect('twON',array('1'=>L_YES,'0'=>L_NO),$var['twON']); ?>
</p>
</fieldset>
</div>
<div class="onglet" data-title="robots txt">
<h4>fichier robots.txt</h4>
<fieldset>
<legend>edition</legend>
<textarea name="robotsTxt"style="width:100%" ><?php if(file_exists(PLX_ROOT.'robots.txt')){echo file_get_contents(PLX_ROOT.'robots.txt');}?></textarea>
<div class="warning" style="display:flex;gap:0.15rem;"><b class="help">?</b> :<a href="https://fr.wikipedia.org/wiki/Protocole_d%27exclusion_des_robots" target="_blank">wikipedia</a>.</div>
</fieldset>
</div>
<!-- opensearch si plugin plxMySearch actif configuré en $_GET -->
<?php if (class_exists('plxMySearch')&& $plxAdmin->plxPlugins->aPlugins['plxMySearch']->getParam('method') == 'get' && $plxAdmin->aConf['urlrewriting']) {
$plxMotor = plxMotor::getInstance();
$mysearch = $plxAdmin->plxPlugins->aPlugins['plxMySearch'];
?>
<div class="onglet" data-title="Open Search">
<fieldset>
<legend>Votre formulaire de recherche dans le navigateur du visiteur</legend>
<p><label for="openSearchON"><?php $plxPlugin->lang('L_ACTIVATE') ?> :</label><?php plxUtils::printSelect('openSearchON',array('1'=>L_YES,'0'=>L_NO),$var['openSearchON']); ?></p>
<p><label for="openSearchAdult"><?php $plxPlugin->lang('L_ADULT_CONTENT') ?> :</label>
<?php plxUtils::printSelect('openSearchAdult',array('true'=>L_YES,'false'=>L_NO),$var['openSearchAdult']); ?></p>
<?php if($var['openSearchON'] === '1') {
if(!file_exists(PLX_ROOT.'opensearch.xml')) {
touch(PLX_ROOT.'opensearch.xml');
$xml= '<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>'.$plxMotor->aConf['title'].'</ShortName>
<Description>'. $plxMotor->aConf['description'].'</Description>
<Image type="image/x-icon">favicon.ico</Image>
<Image type="image/png" height="32" width="32">'. $plxMotor->urlRewrite('plugins/plxMySearch/icon.png') .'</Image>
<AdultContent>'.$var['openSearchAdult'] .'</AdultContent>
<Language>'.$plxMotor->aConf['default_lang'].'</Language>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" method="get" template="'.$plxMotor->urlRewrite('?'.$mysearch->getParam('url')).'?searchfield={searchTerms}"/>
</OpenSearchDescription>';
file_put_contents(PLX_ROOT.'opensearch.xml',$xml);
}?>
<p><?php $plxPlugin->lang('L_PREVIEW_OPENSEARCH') ?></p>
<textarea style="width:100%;min-height:auto;" rows="11" readonly><?php echo file_get_contents(PLX_ROOT.'opensearch.xml')?></textarea>
<?php }
else {
if(file_exists(PLX_ROOT.'opensearch.xml')) {
unlink(PLX_ROOT.'opensearch.xml');
}
}
?>
</fieldset>
</div>
<?php } ?>
<div class="onglet" data-title="humans txt" >
<h4>humans.txt</h4>
<fieldset>
<legend>edition</legend>
<textarea name="humansTxt"style="width:100%" ><?php if(file_exists(PLX_ROOT.'humans.txt')){echo file_get_contents(PLX_ROOT.'humans.txt');}else{echo ' _ _ _ _ _ _ __ _ _ ____
+-+-+-+-+-+-+-+-+-+-+
|h|u|m|a|n|s|.|t|x|t|
+-+-+-+-+-+-+-+-+-+-+
';}?></textarea>
<div class="warning" style="display:flex;gap:0.15rem;"><b class="help">?</b> :<a href="https://fr.wikipedia.org/wiki/Humans.txt" target="_blank">wikipedia</a>.</div>
</fieldset>
</div>
<div class="onglet" data-title="Extra">
<h4>page Article</h4>
<fieldset>
<legend><?php $plxPlugin->lang('L_EXCLUDE_SELF_LINKS') ?></legend>
<p>
<label for="exArtLinkON" ><?php $plxPlugin->lang('L_EXCLUDE') ?> :</label>
<?php plxUtils::printSelect('exArtLinkON',array('1'=>L_YES,'0'=>L_NO),$var['exArtLinkON']); ?>
</p>
</fieldset>
<fieldset>
<legend><?php $plxPlugin->lang('L_LINK_PREV_NEXT') ?></legend>
<p>
<label for="prevNextON" ><?php $plxPlugin->lang('L_PRINT_PREV_NEXT') ?> :</label>
<?php plxUtils::printSelect('prevNextON',array('1'=>L_YES,'0'=>L_NO),$var['prevNextON']); ?>
</p>
</fieldset>
<h4><?php $plxPlugin->lang('L_ADD_EXTRA_MODE_FILTER') ?></h4>
<fieldset>
<legend><?php $plxPlugin->lang('L_SEND_404') ?></legend>
<p>
<label for="send404ON" ><?php $plxPlugin->lang('L_SEND_UNKNOWN_T_404') ?> :</label>
<?php plxUtils::printSelect('send404ON',array('1'=>L_YES,'0'=>L_NO),$var['send404ON']); ?>
</p>
<label><?php echo $plxPlugin->lang('L_ADD_EXTRA_MODE'); ?></label>
<?php
plxUtils::printInput('cloneMode',$plxPlugin->getParam('cloneMode'),'text','20-255');
?>
</p>
</fieldset>
</div>
<div class="onglet" data-title=".htaccess" >
<h4>HTACCESS</h4>
<fieldset>
<legend>edition</legend>
<textarea name="htaccess" id="htaccess" style="width:100%" ><?php if(file_exists(PLX_ROOT.'.htaccess')){echo file_get_contents(PLX_ROOT.'.htaccess');}
else{echo '# aucun fichier .htaccess decouvert à la racine de votre site! ';}?></textarea>
</fieldset>
<div class="warning blue">
<p>Les mises en cache de vos fichiers dans le navigateur de vos visiteurs peuvent améliorer le temps de chargement des pages de votre site.
Voici un exemple proposé par <u><a href="https://leblogduwebmaster.fr/" target="_blank">Christophe</a></u></p>
<pre style="margin:0.5em;border:inset blue;padding:0.25em;color:darkgreen;background:white;"><code><IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# HTML
ExpiresByType text/html "access plus 0 seconds"
# JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
</IfModule></code></pre>
</div>
</div>
<p class="in-action-bar">
<?php echo plxToken::getTokenPostMethod() ?>
<input type="submit" name="submit" value="<?php $plxPlugin->lang('L_SAVE') ?>" />
</p>
</form>
<script src="<?= PLX_ROOT.'plugins/'.basename(__DIR__)?>/js/onglets.js"></script>
<script>
let txtB = document.querySelector('[name="humansTxt"]');
let txtC = document.querySelector('[name="robotsTxt"]');
let contentB = txtB.innerHTML;
let contentC = txtC.innerHTML;
function escapeRegex(string) {
return string.replace(/[\\]/g, '\\$&');
}
(function() {
txtB.innerHTML= escapeRegex(contentB);
txtC.innerHTML= escapeRegex(contentC);
}())
</script>
<link rel="stylesheet" href="<?= PLX_ROOT.'plugins/'.basename(__DIR__)?>/css/admin.css" media="screen">