forked from PHPFusion/PHPFusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweblinks.php
executable file
·96 lines (92 loc) · 4.42 KB
/
weblinks.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
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: weblinks.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
if (!db_exists(DB_WEBLINKS)) {
$_GET['code'] = 404;
require_once __DIR__.'/error.php';
exit;
}
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."weblinks.php";
include THEMES."templates/global/weblinks.php";
if (isset($_GET['weblink_id']) && isnum($_GET['weblink_id'])) {
$res = 0;
$data = dbarray(dbquery("SELECT weblink_url,weblink_cat, weblink_visibility FROM ".DB_WEBLINKS." WHERE weblink_id='".$_GET['weblink_id']."'"));
if (checkgroup($data['weblink_visibility'])) {
$res = 1;
$result = dbquery("UPDATE ".DB_WEBLINKS." SET weblink_count=weblink_count+1 WHERE weblink_id='".$_GET['weblink_id']."'");
redirect($data['weblink_url']);
}
if ($res == 0) {
redirect(FUSION_SELF);
}
}
add_to_title($locale['global_200'].$locale['400']);
add_breadcrumb(array('link'=>BASEDIR.'weblinks.php', 'title'=>$locale['400']));
if (!isset($_GET['cat_id']) || !isnum($_GET['cat_id'])) {
$info['item'] = array();
$result = dbquery("SELECT wc.weblink_cat_id, wc.weblink_cat_name, wc.weblink_cat_description
FROM ".DB_WEBLINK_CATS." wc
".(multilang_table("WL") ? "WHERE weblink_cat_language='".LANGUAGE."'" : "")."
ORDER BY weblink_cat_name");
$rows = dbrows($result);
$info['weblink_cat_rows'] = $rows;
if ($rows != 0) {
while ($data = dbarray($result)) {
$itemcount = dbcount("(weblink_id)", DB_WEBLINKS, "weblink_cat='".$data['weblink_cat_id']."' AND ".groupaccess('weblink_visibility'));
if ($itemcount > 0) {
$data['weblink_item'] = array('link'=>FUSION_SELF."?cat_id=".$data['weblink_cat_id'], 'name'=>$data['weblink_cat_name']);
$data['weblink_count'] = $itemcount;
$info['item'][$data['weblink_cat_id']] = $data;
}
}
}
render_weblinks($info);
} elseif (isset($_GET['cat_id']) && isnum($_GET['cat_id'])) {
$info = array();
$info['item'] = array();
$result = dbquery("SELECT weblink_cat_name, weblink_cat_sorting FROM
".DB_WEBLINK_CATS." ".(multilang_table("WL") ? "WHERE weblink_cat_language='".LANGUAGE."' AND" : "WHERE")." weblink_cat_id='".$_GET['cat_id']."'");
if (dbrows($result) != 0) {
$cdata = dbarray($result);
$info = $cdata;
add_to_title($locale['global_201'].$cdata['weblink_cat_name']);
add_breadcrumb(array('link'=>'', 'title'=>$cdata['weblink_cat_name']));
$max_rows = dbcount("(weblink_id)", DB_WEBLINKS, "weblink_cat='".$_GET['cat_id']."' AND ".groupaccess('weblink_visibility'));
$_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart']<= $max_rows ? $_GET['rowstart'] : 0;
if ($max_rows != 0) {
$result = dbquery("SELECT weblink_id, weblink_name, weblink_description, weblink_datestamp, weblink_count FROM ".DB_WEBLINKS." WHERE
".groupaccess('weblink_visibility')." AND weblink_cat='".$_GET['cat_id']."' ORDER BY ".$cdata['weblink_cat_sorting']." LIMIT ".$_GET['rowstart'].",".$settings['links_per_page']);
$numrows = dbrows($result);
$info['weblink_rows'] = $numrows;
$info['page_nav'] = $max_rows > $settings['links_per_page'] ? makepagenav($_GET['rowstart'], $settings['links_per_page'], $rows, 3, BASEDIR."weblinks.php?cat_id=".$_GET['cat_id']."&") : 0;
if (dbrows($result)>0) {
while ($data = dbarray($result)) {
$data['new'] = ($data['weblink_datestamp']+604800 > time()+($settings['timeoffset']*3600)) ? 1 : 0;
$data['weblink'] = array('link'=>BASEDIR."weblinks.php?cat_id=".$_GET['cat_id']."&weblink_id=".$data['weblink_id'], 'name'=>$data['weblink_name']);
$info['item'][$data['weblink_id']] = $data;
}
}
render_weblinks_item($info);
}
} else {
redirect(FUSION_SELF);
}
}
require_once THEMES."templates/footer.php";
?>