-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrecord.php
123 lines (95 loc) · 3.44 KB
/
record.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
<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of Nevertable .
# Copyright (c) 2004 Francois Guillet and contributors. All rights
# reserved.
#
# Nevertable 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, or
# (at your option) any later version.
#
# Nevertable is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Nevertable; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ***** END LICENSE BLOCK *****
define('ROOT_PATH', "./");
define('NVRTBL', 1);
include_once ROOT_PATH ."config.inc.php";
include_once ROOT_PATH ."includes/common.php";
include_once ROOT_PATH ."includes/classes.php";
//args process
$args = get_arguments($_POST, $_GET);
$table = new Nvrtbl();
try {
/* Configuration of page title */
$tpl_params = array(
"title" => "Record",
);
/* test si le record existe, et le charge. */
$replay_id = $args['id'];
if (empty($replay_id))
throw new Exception("URL error.");
if (!empty($args['comuser_id']))
{
$comuser = new User($table->db);
$comuser->LoadFromId($args['comuser_id']);
}
else if (isset($args['post']))
{
if (!Auth::Check(get_userlevel_by_name("member")))
throw new Exception($lang['NOT_MEMBER']);
if ( empty($args['content']) )
throw new Exception($lang['COMMENTS_ERR_EMPTY_CONTENT']);
$com = new Comment($table->db);
$content = GetContentFromPost($args['content']);
$com->SetFields(array(
"replay_id" => $args['id'],
"user_id" => $_SESSION['user_id'],
"content" => $content)
);
$com->Insert();
$tpl_params = array("redirect" => "record.php?id=".$args['id']);
$tpl_params['message_array'] = array($lang['GUI_UPDATE_OK']);
$table->template->Show('redirect', $tpl_params);
}
else if (isset($args['comdel']))
{
if (!Auth::Check(get_userlevel_by_name("moderator")))
throw new Exception($lang['NOT_MODERATOR']);
if (empty($args['com_id']))
throw new Exception("URL error");
$com = new Comment($table->db);
$com->LoadFromId($args['com_id']);
$com->Purge();
$tpl_params = array("redirect" => "record.php?id=".$args['id']);
$tpl_params['message_array'] = array($lang['GUI_UPDATE_OK']);
$table->template->Show('redirect', $tpl_params);
}
else
{
$total = $table->db->helper->CountRecordComments($replay_id);
if ($config['comments_limit'] > 0)
$tpl_params['nb_pages'] = ceil($total / $config['comments_limit']);
else
$tpl_params['nb_pages']=1;
/* Point to last page */
if ($args['page'] == "last")
$args['page'] = $tpl_params['nb_pages'];
$tpl_params['page'] = empty($args['page']) ? 1 : $args['page'];
$tpl_params['comments_res'] = $table->db->helper->GetComments($args);
$tpl_params['record_fields'] = $table->db->helper->GetRecordFields($replay_id);
$tpl_params['total'] = $total;
$table->template->Show("record", $tpl_params);
}
}
catch (Exception $ex) {
$table->template->Show('error', array("exception" => $ex));
}
$table->Close();