forked from npds/npds_dune
/
links.php
executable file
·595 lines (542 loc) · 27.4 KB
/
links.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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
<?php
/************************************************************************/
/* DUNE by NPDS */
/* =========================== */
/* */
/* Based on PhpNuke 4.x source code */
/* */
/* This version name NPDS Copyright (c) 2001-2019 by Philippe Brunier */
/* */
/* New Links.php Module with SFORM extentions */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (strstr($ModPath,'..') || strstr($ModStart,'..') || stristr($ModPath, 'script') || stristr($ModPath, 'cookie') || stristr($ModPath, 'iframe') || stristr($ModPath, 'applet') || stristr($ModPath, 'object') || stristr($ModPath, 'meta') || stristr($ModStart, 'script') || stristr($ModStart, 'cookie') || stristr($ModStart, 'iframe') || stristr($ModStart, 'applet') || stristr($ModStart, 'object') || stristr($ModStart, 'meta'))
die();
global $links_DB, $NPDS_Prefix;
include_once("modules/$ModPath/links.conf.php");
if ($links_DB=='') $links_DB=$NPDS_Prefix;
function menu() {
global $ModPath, $ModStart, $links_anonaddlinklock,$op;
$ad_l='';$ne_l='';$in_l='';
if($op=='NewLinks') $ne_l='active'; else $ne_l='';
if($op=='AddLink') $ad_l='active'; else $ad_l='';
if($op=='') $in_l='active'; else $in_l='';
echo '
<ul class="nav nav-tabs mb-3">
<li class="nav-item"><a class="nav-link '.$in_l.'" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'" >'.translate("Index").'</a></li>';
if (autorisation($links_anonaddlinklock))
echo '
<li class="nav-item" ><a class="nav-link '.$ad_l.'" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=AddLink" >'.translate("Ajouter").'</a></li>';
echo '
<li class="nav-item"><a class="nav-link '.$ne_l.'" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=NewLinks" >'.translate("Nouveautés").'</a></li>
<li class="nav-item"><a class="nav-link " href="#linksearchblock">'.translate("Recherche").'</a></li>
</ul>';
}
function SearchForm() {
global $ModPath, $ModStart, $NPDS_Prefix, $links_topic;
echo '
<div class="card card-body mb-3" id="linksearchblock">
<h3 class="mb-3">'.translate("Recherche").'</h3>
<form action="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=search" method="post">';
if ($links_topic) {
echo '
<div class="mb-3 row">
<label class="col-form-label col-sm-4" for="topicL" >'.translate("Sélectionner un sujet").'</label>
<div class="col-sm-8">
<select class="form-select" id="topicL" name="topicL">';
$toplist = sql_query("SELECT topicid, topictext FROM ".$NPDS_Prefix."topics ORDER BY topictext");
echo '
<option value="">'.translate("Tous les sujets").'</option>';
while (list($topicid, $topics) = sql_fetch_row($toplist)) {
echo '
<option value="'.$topicid.'">'.$topics.'</option>';
}
echo '
</select>
</div>
</div>';
}
echo '
<div class="mb-3 row">
<label class="col-form-label col-sm-4" for="query">'.translate("Votre requête").'</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="query" name="query" />
</div>
</div>
<div class="mb-3 row">
<div class="col-sm-8 ms-sm-auto">
<button class="btn btn-primary" type="submit">'.translate("Recherche").'</button>
</div>
</div>
</form>
</div>';
}
function mainheader() {
menu();//
}
function autorise_mod($lid,$aff) {
global $ModPath, $ModStart, $links_DB, $NPDS_Prefix, $user, $admin;
if ($admin) {
$Xadmin = base64_decode($admin);
$Xadmin = explode(':', $Xadmin);
$result = sql_query("SELECT radminsuper FROM ".$NPDS_Prefix."authors WHERE aid='$Xadmin[0]'");
list($radminsuper) = sql_fetch_row($result);
if ($radminsuper==1) {// faut remettre le controle des droits probablement pour les admin qui ont le droit link ??!!
if ($aff)
echo '<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=modifylinkrequest&lid='.$lid.'&author=-9" title="'.translate("Modifier").'" data-bs-toggle="tooltip"><i class="fa fa-edit fa-lg"></i></a>';
return(true);
}
} elseif ($user!='') {
global $cookie;
$resultX=sql_query("SELECT submitter FROM ".$links_DB."links_links WHERE submitter='$cookie[1]' AND lid='$lid'");
list($submitter) = sql_fetch_row($resultX);
if ($submitter==$cookie[1]) {
if ($aff)
echo '<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=modifylinkrequest&lid='.$lid.'&author='.$cookie[1].'" title="'.translate("Modifier").'" data-bs-toggle="tooltip" ><i class="fa fa-edit fa-lg"></i></a>';
return(true);
} else
return(false);
} else
return(false);
}
function index() {
global $ModPath, $ModStart, $links_DB;
include ("modules/$ModPath/links.conf.php");
include("header.php");
// Include cache manager
global $SuperCache;
if ($SuperCache) {
$cache_obj = new cacheManager();
$cache_obj->startCachingPage();
} else
$cache_obj = new SuperCacheEmpty();
if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
$mainlink = 'in_l';
menu($mainlink);
$filen="modules/$ModPath/links.ban_01.php";
if (file_exists($filen)) {include($filen);}
echo '
<table class="table table-bordered table-striped table-hover">';
$result=sql_query("SELECT cid, title, cdescription FROM ".$links_DB."links_categories ORDER BY title");
if ($result) {
while (list($cid, $title, $cdescription) = sql_fetch_row($result)) {
$cresult = sql_query("SELECT lid FROM ".$links_DB."links_links WHERE cid='$cid'");
$cnumrows = sql_num_rows($cresult);
echo '
<tr>
<td>
<h4><a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlink&cid='.$cid.'">'.aff_langue($title).'</a> <span class="badge bg-secondary float-end">'.$cnumrows.'</span></h4>';
categorynewlinkgraphic($cid);
if ($cdescription)
echo '
<p>'.aff_langue($cdescription).'</p>';
$result2 = sql_query("SELECT sid, title FROM ".$links_DB."links_subcategories WHERE cid='$cid' ORDER BY title $subcat_limit");
while (list($sid, $stitle) = sql_fetch_row($result2)) {
$cresult3 = sql_query("SELECT lid FROM ".$links_DB."links_links WHERE sid='$sid'");
$cnumrows= sql_num_rows($cresult3);
echo '
<h5 class="ms-4"><a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'">'.aff_langue($stitle).'</a> <span class="badge bg-secondary float-end">'.$cnumrows.'</span></h5>';
}
echo '
</td>
</tr>';
}
}
echo '
</table>';
$result=sql_query("SELECT lid FROM ".$links_DB."links_links");
if ($result) {
$numrows = sql_num_rows($result);
echo '
<p class="lead" align="center"><span>'.translate("Il y a").' <b>'.$numrows.'</b> '.translate("Liens").'
<span class="btn btn-danger btn-sm" title="'.translate("Les nouveaux liens de cette catégorie ajoutés aujourd'hui").'" data-bs-toggle="tooltip" >N</span>
<span class="btn btn-success btn-sm" title="'.translate("Les nouveaux liens ajoutés dans cette catégorie dans les 3 derniers jours").'" data-bs-toggle="tooltip" >N</span>
<span class="btn btn-primary btn-sm" title="'.translate("Les nouveaux Liens ajoutés dans cette catégorie cette semaine").'" data-bs-toggle="tooltip" >N</span>
</p>';
}
SearchForm();
}
if ($SuperCache)
$cache_obj->endCachingPage();
global $admin;
if ($admin) {
$result = sql_query("SELECT requestid FROM ".$links_DB."links_modrequest WHERE brokenlink=1");
if ($result) {
$totalbrokenlinks = sql_num_rows($result);
$result2 = sql_query("SELECT requestid FROM ".$links_DB."links_modrequest WHERE brokenlink=0");
$totalmodrequests = sql_num_rows($result2);
$result = sql_query("SELECT lid FROM ".$links_DB."links_newlink");
$num = sql_num_rows($result);
echo '
<p class="lead p-2 text-center border rounded bg-light">
<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'/admin"><i class="fa fa-cogs fa-2x me-2 align-middle" title="Admin" data-bs-toggle="tooltip"></i></a> '.translate("Liens").' :
<span class="badge bg-danger ms-2" title="'.translate("Lien(s) en attente de validation").'" data-bs-toggle="tooltip">'.$num.'</span>
<span class="badge bg-danger ms-2" title="'.translate("Liens cassés rapportés par un ou plusieurs utilisateurs").'" data-bs-toggle="tooltip">'.$totalbrokenlinks.'</span>
<span class="badge bg-danger ms-2" title="'.translate("Proposition de modification").'" data-bs-toggle="tooltip">'.$totalmodrequests.'</span>';
if($links_DB!='') echo 'Ref Tables => <strong>'.$links_DB.'</strong>';
echo '
</p>';
} else
echo "<p align=\"center\"><span> -: [ <a href=\"modules.php?ModStart=create_tables&ModPath=$ModPath/admin/\">".translate("Créer")."</a> Tables : $links_DB ] :-</span></p>";
}
include("footer.php");
}
function FooterOrderBy($cid, $sid, $orderbyTrans, $linkop) {
global $ModPath, $ModStart;
echo '<p align="center"><span class="">'.translate("Classement").' : ';
if ($linkop=="viewlink") {
echo translate("Titre").' (<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlink&cid='.$cid.'&orderby=titleA"><i class="fas fa-sort-alpha-down"></i>A</a>\<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlink&cid='.$cid.'&orderby=titleD">D</a>)
'.translate("Date").' (<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlink&cid='.$cid.'&orderby=dateA">A</a>\<a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlink&cid='.$cid.'&orderby=dateD">D</a>)';
} else {
echo translate("Titre").' <a class="me-3" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'&orderby=titleA"><i class="fas fa-sort-alpha-down fa-lg align-middle"></i></a><a class="me-3" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'&orderby=titleD"><i class="fas fa-sort-alpha-down-alt fa-lg align-middle"></i></a>
'.translate("Date").' <a class="me-3" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'&orderby=dateA"><i class="fas fa-sort-numeric-down fa-lg align-middle"></i></a><a class="me-3" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'&orderby=dateD"><i class="fas fa-sort-numeric-down-alt fa-lg align-middle"></i></a>';
}
echo '<br />'.translate("Sites classés par").' : <strong>'.$orderbyTrans.'</strong></span></p>';
/*
echo '
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
'.translate("Classement").'
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">'.translate("Titre").'<i class="ms-2 fas fa-sort-alpha-down fa-lg align-middle"></i></a>
<a class="dropdown-item" href="#">'.translate("Titre").'<i class="ms-2 fas fa-sort-alpha-down-alt fa-lg align-middle"></i></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">'.translate("Date").'<i class="fas fa-sort-numeric-down fa-lg align-middle"></i></a>
<a class="dropdown-item" href="#">'.translate("Date").'<i class="fas fa-sort-numeric-down-alt fa-lg align-middle"></i></a>
</div>
</div>';
*/
}
function viewlink($cid, $min, $orderby, $show) {
global $ModPath, $ModStart, $links_DB, $admin, $perpage;
include('functions.php');
include("header.php");
// Include cache manager
global $SuperCache;
if ($SuperCache) {
$cache_obj = new cacheManager();
$cache_obj->startCachingPage();
}
else
$cache_obj = new SuperCacheEmpty();
if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
if (!isset($max)) $max=$min+$perpage;
mainheader();
settype($affsouscat,'string');
$filen="modules/$ModPath/links.ban_02.php";
if (file_exists($filen)) {include($filen);}
$result=sql_query("SELECT title FROM ".$links_DB."links_categories WHERE cid='$cid'");
list($title) = sql_fetch_row($result);
echo '
<h3 class="mb-3">'.aff_langue($title).'</h3>';
$subresult=sql_query("SELECT sid, title FROM ".$links_DB."links_subcategories WHERE cid='$cid' ORDER BY title");
$numrows = sql_num_rows($subresult);
settype($numrows_lst,'integer');
$affsouscat .= '
<ul class="list-group">
<li class="list-group-item "><h4 class="w-100">'.translate("Sous-catégories").'<span class="badge bg-secondary float-end"> '.$numrows.'</span></h4></li>';
while(list($sid, $title) = sql_fetch_row($subresult)) {
$result2 = sql_query("SELECT lid FROM ".$links_DB."links_links WHERE sid='$sid'");
$numrows_lst=sql_num_rows($result2);
$affsouscat .= '
<li class="list-group-item list-group-item-action justify-content-between align-self-start"><a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'">'.aff_langue($title).'</a></li>';
}
$affsouscat .= '
</ul>';
if ($numrows != 0)
echo $affsouscat;
$orderbyTrans = convertorderbytrans($orderby);
settype($min,"integer");
settype($perpage,"integer");
$result=sql_query("SELECT lid, url, title, description, date, hits, topicid_card, cid, sid FROM ".$links_DB."links_links WHERE cid='$cid' AND sid=0 ORDER BY $orderby LIMIT $min,$perpage");
$fullcountresult=sql_query("SELECT lid, title, description, date, hits FROM ".$links_DB."links_links WHERE cid='$cid' AND sid=0");
$totalselectedlinks = sql_num_rows($fullcountresult);
echo "<br />\n";
$link_fiche_detail='';
include_once("modules/$ModPath/links-view.php");
$orderby = convertorderbyout($orderby);
//Calculates how many pages exist. Which page one should be on, etc...
$linkpagesint = ($totalselectedlinks / $perpage);
$linkpageremainder = ($totalselectedlinks % $perpage);
if ($linkpageremainder != 0) {
$linkpages = ceil($linkpagesint);
if ($totalselectedlinks < $perpage)
$linkpageremainder = 0;
} else
$linkpages = $linkpagesint;
$nbPages = ceil($totalselectedlinks/$perpage);
$current = 1;
if ($min >= 1)
$current=$min/$perpage;
else if ($min < 1)
$current=0;
else
$current = $nbPages;
$start=($current*$perpage);
echo paginate('modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlink&cid='.$cid.'&min=', '&orderby='.$orderby.'&show='.$perpage, $nbPages, $current, $adj=3, $perpage, $start);
if (isset($sid)) FooterOrderBy($cid, $sid, $orderbyTrans, 'viewlink');
SearchForm();
}
if ($SuperCache)
$cache_obj->endCachingPage();
include("footer.php");
}
function viewslink($sid, $min, $orderby, $show) {
global $ModPath, $ModStart, $links_DB, $admin, $perpage;
$perpage =2;//# to test debug
include("header.php");
include_once('functions.php');
// Include cache manager
global $SuperCache;
if ($SuperCache) {
$cache_obj = new cacheManager();
$cache_obj->startCachingPage();
}
else
$cache_obj = new SuperCacheEmpty();
if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
mainheader();
$filen="modules/$ModPath/links.ban_03.php";
if (file_exists($filen)) include($filen);
if (!isset($max)) $max=$min+$perpage;
$result = sql_query("SELECT cid, title FROM ".$links_DB."links_subcategories WHERE sid='$sid'");
list($cid, $stitle) = sql_fetch_row($result);
$result2 = sql_query("SELECT cid, title FROM ".$links_DB."links_categories WHERE cid='$cid'");
list($cid, $title) = sql_fetch_row($result2);
echo "<table class=\"table table-bordered\"><tr><td class=\"header\">\n";
echo "<a href=\"modules.php?ModStart=$ModStart&ModPath=$ModPath\" class=\"box\">".translate("Index")."</a> / <a href=\"modules.php?ModStart=$ModStart&ModPath=$ModPath&op=viewlink&cid=$cid\" class=\"box\">".aff_langue($title)."</a> / ".aff_langue($stitle);
echo "</td></tr></table>";
$orderbyTrans = convertorderbytrans($orderby);
settype($min,'integer');
settype($perpage,'integer');
$result=sql_query("SELECT lid, url, title, description, date, hits, topicid_card, cid, sid FROM ".$links_DB."links_links WHERE sid='$sid' ORDER BY $orderby LIMIT $min,$perpage");
$fullcountresult=sql_query("SELECT lid, title, description, date, hits FROM ".$links_DB."links_links WHERE sid='$sid'");
$totalselectedlinks = sql_num_rows($fullcountresult);
echo "<br />\n";
$link_fiche_detail='';
include_once("modules/$ModPath/links-view.php");
// echo "<br />\n";
$orderby = convertorderbyout($orderby);
$nbPages = ceil($totalselectedlinks/$perpage);
$current = 1;
if ($min >= 1)
$current=$min/$perpage;
else if ($min < 1)
$current=0;
else
$current = $nbPages;
$start=($current*$perpage);
echo paginate('modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewslink&sid='.$sid.'&min=', '&orderby='.$orderby.'&show='.$show, $nbPages, $current, $adj=3, $perpage, $start);
FooterOrderBy($cid, $sid, $orderbyTrans, "viewslink");
}
if ($SuperCache)
$cache_obj->endCachingPage();
include("footer.php");
}
function fiche_detail ($Xlid) {
global $ModPath, $ModStart;
include("header.php");
// Include cache manager
global $SuperCache;
if ($SuperCache) {
$cache_obj = new cacheManager();
$cache_obj->startCachingPage();
}
else
$cache_obj = new SuperCacheEmpty();
if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
settype($xlid,'integer');
$browse_key=$Xlid;
$link_fiche_detail="fiche_detail";
$inter='cid';
include ("modules/sform/links/link_detail.php");
}
if ($SuperCache)
$cache_obj->endCachingPage();
include("footer.php");
}
function categorynewlinkgraphic($cat) {
global $OnCatNewLink, $locale, $links_DB;
if ($OnCatNewLink=='1') {
$newresult = sql_query("SELECT date FROM ".$links_DB."links_links WHERE cid='$cat' ORDER BY date DESC LIMIT 1");
list($time)=sql_fetch_row($newresult);
if (isset($ime)) {
setlocale (LC_TIME, aff_langue($locale));
preg_match('#^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$#', $time, $datetime);
$count = round((time()- mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]))/86400,0);
popgraphics($count);
}
}
}
function popgraphics($count) {
if ($count<1) echo '<span class="btn btn-danger btn-sm float-end" title="'.translate("Les nouveaux liens de cette catégorie ajoutés aujourd'hui").'" data-bs-toggle="tooltip" data-bs-placement="left">N</span>';
if ($count<=3 && $count>=1) echo '<span class="btn btn-success btn-sm float-end" title="'.translate("Les nouveaux liens ajoutés dans cette catégorie dans les 3 derniers jours").'" data-bs-toggle="tooltip" data-bs-placement="left">N</span>';
if ($count<=7 && $count>3) echo '<span class="btn btn-infos btn-sm float-end" title="'.translate("Les nouveaux Liens ajoutés dans cette catégorie cette semaine").'" data-bs-toggle="tooltip" data-bs-placement="left">N</span>';
}
function newlinkgraphic($datetime, $time) {
global $locale;
setlocale (LC_TIME, aff_langue($locale));
preg_match('#^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$#', $time, $datetime);
$count = round((time()- mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]))/86400,0);
popgraphics($count);
}
function detecteditorial($lid, $ttitle) {
global $ModPath, $ModStart, $links_DB;
$resulted2 = sql_query("SELECT adminid FROM ".$links_DB."links_editorials WHERE linkid='$lid'");
$recordexist = sql_num_rows($resulted2);
if ($recordexist != 0) echo '<a class="me-3" href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=viewlinkeditorial&lid='.$lid.'&ttitle='.$ttitle.'"><i class="far fa-sticky-note fa-lg" title="'.translate("EDITO").'" data-bs-toggle="tooltip"></i></a>';
}
//Reusable Link Sorting Functions
function convertorderbyin($orderby) {
$orderbyIn = 'title ASC';
if ($orderby == 'titleA') $orderbyIn = 'title ASC';
if ($orderby == 'dateA') $orderbyIn = 'date ASC';
if ($orderby == 'titleD') $orderbyIn = 'title DESC';
if ($orderby == 'dateD') $orderbyIn = 'date DESC';
return $orderbyIn;
}
function convertorderbytrans($orderby) {
$orderbyTrans = translate("Title (A to Z)");
if ($orderby == 'title ASC') $orderbyTrans = translate("Titre (de A à Z)");
if ($orderby == 'title DESC') $orderbyTrans = translate("Titre (de Z à A)");
if ($orderby == 'date ASC') $orderbyTrans = translate("Date (les plus vieux liens en premier)");
if ($orderby == 'date DESC') $orderbyTrans = translate("Date (les liens les plus récents en premier)");
return $orderbyTrans;
}
function convertorderbyout($orderby) {
$orderbyOut = 'titleA';
if ($orderby == 'title ASC') $orderbyOut = 'titleA';
if ($orderby == 'date ASC') $orderbyOut = 'dateA';
if ($orderby == 'title DESC') $orderbyOut = 'titleD';
if ($orderby == 'date DESC') $orderbyOut = 'dateD';
return $orderbyOut;
}
function visit($lid) {
global $links_DB;
sql_query("UPDATE ".$links_DB."links_links SET hits=hits+1 WHERE lid='$lid'");
$result = sql_query("SELECT url FROM ".$links_DB."links_links WHERE lid='$lid'");
list($url) = sql_fetch_row($result);
Header("Location: $url");
}
function viewlinkeditorial($lid, $ttitle) {
global $ModPath, $ModStart, $links_DB;
include("header.php");
mainheader();
$result2 = sql_query("SELECT url FROM ".$links_DB."links_links WHERE lid='$lid'");
list($url) = sql_fetch_row($result2);
$result=sql_query("SELECT adminid, editorialtimestamp, editorialtext, editorialtitle FROM ".$links_DB."links_editorials WHERE linkid = '$lid'");
$recordexist = sql_num_rows($result);
$displaytitle = stripslashes($ttitle);
echo '
<div class="card card-body">
<h3>'.translate("EDITO").' :
<span class="text-muted">'.aff_langue($displaytitle).'</span>';
if ($url!='')
echo '
<span class="float-end"><a href="modules.php?ModStart='.$ModStart.'&ModPath='.$ModPath.'&op=visit&lid='.$lid.'" target="_blank" title="'.translate("Visiter ce site web").'" data-bs-toggle="tooltip" data-bs-placement="left"><i class="fas fa-external-link-alt"></i></a></span>';
echo '
</h3>';
if ($recordexist!= 0) {
while (list($adminid, $editorialtimestamp, $editorialtext, $editorialtitle)=sql_fetch_row($result)) {
$editorialtitle = stripslashes($editorialtitle); $editorialtext = stripslashes($editorialtext);
$formatted_date=formatTimestamp($editorialtimestamp);
echo '
<h4>'.aff_langue($editorialtitle).'</h4>
<p><span class="text-muted small">'.translate("Editorial par").' '.$adminid.' - '.$formatted_date.'</span></p>
<hr/>'.aff_langue($editorialtext);
}
}
else
echo '<p class="text-center">'.translate("Aucun édito n'est disponible pour ce site").'</p><br />';
echo '
</div>';
sql_free_result();
include("footer.php");
}
function formatTimestampShort($time) {
global $datetime, $locale, $gmt;
setlocale (LC_TIME, aff_langue($locale));
preg_match('#^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$#', $time, $datetime);
$datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4]+(integer)$gmt,$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
if (cur_charset!='utf-8')
$datetime = ucfirst($datetime);
return($datetime);
}
settype($op,'string');
switch ($op) {
case 'menu':
menu($mainlink);
break;
case 'AddLink':
include_once("modules/$ModPath/links-1.php");
AddLink();
break;
case 'Add':
include_once("modules/$ModPath/links-1.php");
settype($asb_question,'string');
settype($asb_reponse,'string');
Add($title, $url, $name, $cat, $xtext, $email, $topicL, $asb_question, $asb_reponse);
break;
case 'NewLinks':
include_once("modules/$ModPath/links-2.php");
if (!isset($newlinkshowdays)) {$newlinkshowdays = 7;}
NewLinks($newlinkshowdays);
break;
case 'NewLinksDate':
include_once("modules/$ModPath/links-2.php");
NewLinksDate($selectdate);
break;
case 'viewlink':
settype($show,'string');
if (!isset($min)) $min=0;
if (isset($orderby)) $orderby = convertorderbyin($orderby); else $orderby = "title ASC";
viewlink($cid, $min, $orderby, $show);
break;
case 'viewslink':
if (!isset($min)) $min=0;
if (isset($orderby)) $orderby = convertorderbyin($orderby); else $orderby = "title ASC";
if (isset($show)) $perpage = $show; else $show=$perpage;
viewslink($sid, $min, $orderby, $show);
break;
case 'brokenlink':
include_once("modules/$ModPath/links-3.php");
brokenlink($lid);
break;
case 'brokenlinkS':
include_once("modules/$ModPath/links-3.php");
brokenlinkS($lid, $modifysubmitter);
break;
case 'modifylinkrequest':
include_once("modules/$ModPath/links-3.php");
settype($modifylinkrequest_adv_infos,'string');
modifylinkrequest($lid, $modifylinkrequest_adv_infos, $author);
break;
case 'modifylinkrequestS':
include_once("modules/$ModPath/links-3.php");
modifylinkrequestS($lid, $cat, $title, $url, $xtext, $modifysubmitter, $topicL);
break;
case 'visit':
visit($lid);
break;
case 'search':
include_once("modules/$ModPath/links-1.php");
$offset=10;
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$offset;
links_search($query, $topicL, $min, $max, $offset);
break;
case 'viewlinkeditorial':
viewlinkeditorial($lid, $ttitle);
break;
case 'fiche_detail':
fiche_detail ($lid);
break;
default:
index();
break;
}
?>