forked from PHPFusion/PHPFusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
208 lines (206 loc) · 8.51 KB
/
home.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
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: home.php
| Author: Chubatyj Vitalij (Rizado)
| Co-Author: Takács Ákos (Rimelek)
| Co-Author: Frederick MC Chan (Hien)
+--------------------------------------------------------+
| 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";
require_once THEMES."templates/header.php";
require_once THEMES."templates/global/home.php";
require_once INCLUDES."infusions_include.php";
include LOCALE.LOCALESET."homepage.php";
add_to_title($locale['home']);
add_breadcrumb(array("title"=>$locale['home'], "link"=>BASEDIR."home.php"));
$configs = array();
$configs[DB_NEWS] = array(
'select' => "SELECT
ns.news_id as id, ns.news_subject as title, ns.news_news as content,
ns.news_datestamp as datestamp, us.user_id, us.user_name,
us.user_status, nc.news_cat_id as cat_id, nc.news_cat_name as cat_name,
ns.news_image as image,
nc.news_cat_image as cat_image,
count(c1.comment_id) as comment_count,
count(r1.rating_id) as rating_count
FROM ".DB_NEWS." as ns
LEFT JOIN ".DB_NEWS_CATS." as nc ON nc.news_cat_id = ns.news_cat
LEFT JOIN ".DB_COMMENTS." as c1 on (c1.comment_item_id = ns.news_id and c1.comment_type = 'NS')
LEFT JOIN ".DB_RATINGS." as r1 on (r1.rating_item_id = ns.news_id AND r1.rating_type = 'NS')
INNER JOIN ".DB_USERS." as us ON ns.news_name = us.user_id
WHERE (".time()." > ns.news_start OR ns.news_start = 0)
AND (".time()." < ns.news_end OR ns.news_end = 0)
AND ".groupaccess('ns.news_visibility')." ".(multilang_table("NS") ? "AND news_language='".LANGUAGE."'" : "")."
group by ns.news_id
ORDER BY ns.news_datestamp DESC LIMIT 3",
'locale' => array(
'norecord' => $locale['home_0050'],
'blockTitle' => $locale['home_0000'],
),
'infSettings' => get_settings("news"),
'categoryLinkPattern' => INFUSIONS."news/news.php?cat_id={cat_id}",
'contentLinkPattern' => INFUSIONS."news/news.php?readmore={id}",
);
$configs[DB_ARTICLES] = array(
'select' => "SELECT
ar.article_id as id, ar.article_subject as title, ar.article_snippet as content,
ar.article_datestamp as datestamp, ac.article_cat_id as cat_id, ac.article_cat_name as cat_name,
us.user_id, us.user_name, us.user_status
FROM ".DB_ARTICLES." as ar
INNER JOIN ".DB_ARTICLE_CATS." as ac ON ac.article_cat_id = ar.article_cat
INNER JOIN ".DB_USERS." as us ON us.user_id = ar.article_name
WHERE ".groupaccess('ar.article_visibility')." ".(multilang_table("AR") ? "AND ac.article_cat_language='".LANGUAGE."'" : "")."
ORDER BY ar.article_datestamp DESC LIMIT 3",
'locale' => array(
'norecord' => $locale['home_0051'],
'blockTitle' => $locale['home_0001'],
),
'infSettings' => get_settings("article"),
'categoryLinkPattern' => INFUSIONS."articles/articles.php?cat_id={cat_id}",
'contentLinkPattern' => INFUSIONS."articles/articles.php?article_id={id}",
);
$configs[DB_BLOG] = array(
'select' => "SELECT
bl.blog_id as id, bl.blog_subject as title, bl.blog_blog as content,
bl.blog_datestamp as datestamp, us.user_id, us.user_name,
us.user_status, bc.blog_cat_id as cat_id, bc.blog_cat_name as cat_name,
bl.blog_image as image,
bc.blog_cat_image as cat_image,
count(c1.comment_id) as comment_count,
count(r1.rating_id) as rating_count
FROM ".DB_BLOG." as bl
LEFT JOIN ".DB_BLOG_CATS." as bc ON bc.blog_cat_id = bl.blog_cat
LEFT JOIN ".DB_COMMENTS." as c1 on (c1.comment_item_id = bl.blog_id and c1.comment_type = 'BL')
LEFT JOIN ".DB_RATINGS." as r1 on (r1.rating_item_id = bl.blog_id AND r1.rating_type = 'BL')
INNER JOIN ".DB_USERS." as us ON bl.blog_name = us.user_id
WHERE (".time()." > bl.blog_start OR bl.blog_start = 0)
AND (".time()." < bl.blog_end OR bl.blog_end = 0)
AND ".groupaccess('bl.blog_visibility')." ".(multilang_table("BL") ? "AND blog_language='".LANGUAGE."'" : "")."
group by bl.blog_id
ORDER BY bl.blog_datestamp DESC LIMIT 3",
'locale' => array(
'norecord' => $locale['home_0052'],
'blockTitle' => $locale['home_0002']
),
'infSettings' => get_settings("blog"),
'categoryLinkPattern' => INFUSIONS."blog/blog.php?cat_id={cat_id}",
'contentLinkPattern' => INFUSIONS."blog/blog.php?readmore={id}",
);
$configs[DB_DOWNLOADS] = array(
'select' => "SELECT
dl.download_id as id, dl.download_title as title, dl.download_description_short as content,
dl.download_datestamp as datestamp, dc.download_cat_id as cat_id, dc.download_cat_name as cat_name,
us.user_id, us.user_name, us.user_status,
dl.download_image as image,
count(c1.comment_id) as comment_count,
count(r1.rating_id) as rating_count
FROM ".DB_DOWNLOADS." dl
INNER JOIN ".DB_DOWNLOAD_CATS." dc ON dc.download_cat_id = dl.download_cat
INNER JOIN ".DB_USERS." us ON us.user_id = dl.download_user
LEFT JOIN ".DB_COMMENTS." as c1 on (c1.comment_item_id = dl.download_id and c1.comment_type = 'D')
LEFT JOIN ".DB_RATINGS." as r1 on (r1.rating_item_id = dl.download_id AND r1.rating_type = 'D')
WHERE ".groupaccess('dl.download_visibility')." ".(multilang_table("DL") ? "AND dc.download_cat_language='".LANGUAGE."'" : "")."
group by dl.download_id
ORDER BY dl.download_datestamp DESC LIMIT 3",
'locale' => array(
'norecord' => $locale['home_0053'],
'blockTitle' => $locale['home_0003']
),
'infSettings' => get_settings("downloads"),
'categoryLinkPattern' => DOWNLOADS."downloads.php?cat_id={cat_id}",
'contentLinkPattern' => DOWNLOADS."downloads.php?cat_id={cat_id}&download_id={id}",
);
$contents = array();
foreach ($configs as $table => $config) {
if (!db_exists($table)) {
continue;
}
$contents[$table] = array(
'data' => array(),
'colwidth' => 0,
'norecord' => $config['locale']['norecord'],
'blockTitle' => $config['locale']['blockTitle'],
'infSettings' => $config['infSettings']
);
$result = dbquery($config['select']);
$items_count = dbrows($result);
if (!$items_count) {
continue;
}
$contents[$table]['colwidth'] = floor(12/$items_count);
$data = array();
$count = 1;
while ($row = dbarray($result)) {
$keys = array_keys($row);
foreach ($keys as $i => $key) {
$keys[$i] = '{'.$key.'}';
}
$row['content'] = str_replace("../../images", IMAGES, $row['content']);
$pairs = array_combine($keys, array_values($row));
$cat = $row['cat_id'] ? "<a href='".strtr($config['categoryLinkPattern'], $pairs)."'>".$row['cat_name']."</a>" : $locale['home_0102'];
$data[$count] = array(
'cat' => $cat,
'url' => strtr($config['contentLinkPattern'], $pairs),
'title' => $row['title'],
'meta' => $locale['home_0105'].profile_link($row['user_id'], $row['user_name'], $row['user_status'])." ".showdate('newsdate', $row['datestamp']).$locale['home_0106'].$cat,
'content' => parse_textarea($row['content']),
'datestamp' => $row['datestamp'],
'cat_name' => $row['cat_name'],
);
/* Infusion Settings Readings */
switch ($table) {
case DB_NEWS:
if ($config['infSettings']['news_image_frontpage']) { // if it's 0 use uploaded photo, 1 always use category image
// go for cat image always
if ($row['cat_image']) {
$data[$count]['image'] = INFUSIONS."news/news_cats/".$row['cat_image'];
}
} else {
// go for image if available
if ($row['image'] || $row['cat_image']) {
if ($row['cat_image']) {
$data[$count]['image'] = INFUSIONS."news/news_cats/".$row['cat_image'];
}
if ($row['image']) {
$data[$count]['image'] = INFUSIONS."news/images/".$row['image'];
}
}
}
break;
case DB_BLOG:
if ($row['image'] || $row['cat_image']) {
if ($row['cat_image']) {
$data[$count]['image'] = INFUSIONS."blog/blog_cats/".$row['cat_image'];
}
if ($row['image']) {
$data[$count]['image'] = INFUSIONS."blog/images/".$row['image'];
}
}
break;
case DB_DOWNLOADS:
if ($row['image']) {
$data[$count]['image'] = INFUSIONS."downloads/images/".$row['image'];
}
// end switch
}
$count++;
}
$contents[$table]['data'] = $data;
}
if (!$contents) {
display_no_item();
} else {
display_home($contents);
}
require_once THEMES."templates/footer.php";