forked from CuteNews/cutenews-2.0
-
Notifications
You must be signed in to change notification settings - Fork 1
/
show_news.php
121 lines (97 loc) · 3.01 KB
/
show_news.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
<?php
if (!defined('SHOW_NEWS')) define('SHOW_NEWS', TRUE);
require_once (dirname(__FILE__).'/core/init.php');
// Quick Redirect
if (isset($_GET['cn_rewrite_url']) && $_GET['cn_rewrite_url'])
{
// Remove request string
unset($_GET['cn_rewrite_url']);
// Query
include CN_REWRITE;
die();
}
// plugin tells us: he is fork, stop
if ( hook('fork_news', false) )
{
return;
}
// Check including & init
check_direct_including('show_news.php');
global $PHP_SELF;
// Store GET
$bGET = $_GET;
// Get external control
list($subaction, $category, $nocategory, $ucat, $id) = GET('subaction, category, nocategory, ucat, id', 'GPG');
// Sanitize variables
$category = preg_replace('/\s/', '', $category);
$ucat = preg_replace('/\s/', '', $ucat);
cn_extrn_init();
hook('show_news/social_init');
// Decoding requested categories
list ($requested_cats, $is_in_category) = cn_get_requested_cats($category, $ucat, $nocategory);
// Allowed modules
$allow_add_comment = false;
$allow_full_story = false;
$allow_active_news = false;
$allow_comments = false;
// Short urls [only id]
if ($subaction == '' && $id)
{
$subaction = 'showfull';
}
// ID starts from 'c' symbol
if ($id[0] === '.')
{
$subaction = 'showcomments';
$_GET['id'] = $_POST['id'] = $id = substr($id, 1);
}
// Show news only is in category
if ($is_in_category && empty($CN_HALT))
{
// --- Determine what user want to do ---
hook('show_news/determs_before');
if (empty($static) and in_array($subaction, array("showcomments", "showfull", "addcomment", "only_comments")))
{
if ($subaction == "addcomment")
{
$allow_add_comment = true;
$allow_comments = true;
}
elseif ($subaction == "showcomments")
{
$allow_comments = true;
}
elseif ($subaction == "showfull")
{
$allow_full_story = true;
}
// Additional tuning
if (($subaction == "showcomments" || $allow_comments == true) && getoption('show_full_with_comments'))
{
$allow_full_story = true;
}
if ($subaction == "showfull" && getoption('show_comments_with_full'))
{
$allow_comments = true;
}
// For popup
if ($subaction == "only_comments")
{
$allow_comments = true;
$allow_full_story = false;
}
}
else
{
$allow_active_news = true;
}
hook('show_news/determs_after');
// Main operations
include SERVDIR . '/core/includes/dispatcher.php';
}
// Unset all used variables
unset ($dir, $sortby, $archive, $only_active, $no_prev, $no_next, $category, $nocat, $id);
unset ($template, $number, $start_from, $requested_cats, $reverse, $page_alias, $static, $subaction, $translate);
// Restore GET
$_GET = $bGET;
echo '<!-- News Powered by CuteNews: http://cutephp.com/ -->';