-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathajax.php
152 lines (135 loc) · 3.83 KB
/
ajax.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
<?php
/*
Viscacha - A bulletin board solution for easily managing your content
Copyright (C) 2004-2009 The Viscacha Project
Author: Matthias Mohr (et al.)
Publisher: The Viscacha Project, http://www.viscacha.org
Start Date: May 22, 2004
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, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
error_reporting(E_ALL);
define('SCRIPTNAME', 'ajax');
define('VISCACHA_CORE', '1');
define('TEMPSHOWLOG', 1);
include ("data/config.inc.php");
include ("classes/function.viscacha_frontend.php");
$my->p = $slog->Permissions();
$action = $gpc->get('action', str);
viscacha_header("Content-type: text/plain");
send_nocache_header();
($code = $plugins->load('ajax_start')) ? eval($code) : null;
// Schliesst oder oeffnet einen Beitrag mittels AJAX
if ($action == 'openclosethread') {
$result = $db->query("SELECT status, board FROM {$db->pre}topics WHERE id = '{$_GET['id']}'");
$row = $db->fetch_assoc($result);
$my->p = $slog->Permissions($row['board']);
$my->mp = $slog->ModPermissions($row['board']);
$request = 1;
if ($my->p['admin'] == 1 || $my->p['gmod'] == 1 || $my->mp[0] == 1) {
if ($row['status'] == 0) {
$db->query("UPDATE {$db->pre}topics SET status = '1' WHERE id = '{$_GET['id']}'");
if ($db->affected_rows() == 1) {
$request = 3;
}
}
else {
$db->query("UPDATE {$db->pre}topics SET status = '0' WHERE id = '{$_GET['id']}'");
if ($db->affected_rows() == 1) {
$request = 4;
}
}
}
else {
$request = 2;
}
echo $request;
}
elseif ($action == 'markforumread') {
$board = $gpc->get('id', int);
$my->p = $slog->Permissions($board);
if (!is_id($board) || $my->p['forum'] == 0) {
echo '0';
}
$slog->setForumRead($board);
$slog->updatelogged();
echo '1';
}
elseif ($action == 'doubleudata') {
if (strlen($_GET['name']) > 3) {
$request = 1;
if (!$my->vlogin) {
if (double_udata('name',$_GET['name']) == false) {
$request = 5;
}
else {
$request = 6;
}
}
echo $request;
}
else {
echo 8;
}
}
elseif ($action == 'searchmember') {
$request = 1;
if (strlen($_GET['name']) > 2) {
$result = $db->query('SELECT name FROM '.$db->pre.'user WHERE name LIKE "%'.$_GET['name'].'%" ORDER BY name ASC LIMIT 50');
$user = array();
while ($row = $db->fetch_assoc($result)) {
$user[] = $row['name'];
}
$request = implode(',', $gpc->prepare($user));
echo $request;
}
else {
echo 8;
}
}
elseif ($action == 'search') {
$search = $gpc->get('search', str);
if (strlen($search) > 2) {
$search = urldecode($search);
$search = preg_replace("/(\s){1,}/is"," ",$search);
$search = preg_replace("/\*{1,}/is",'*',$search);
$ignorewords = $lang->get_words();
$searchwords = splitWords($search);
$ignored = array();
foreach ($searchwords as $sw) {
$sw = trim($sw);
if ($sw[0] == '-') {
$sw2 = substr($sw, 1);
}
else {
$sw2 = $sw;
}
$sw2 = str_replace('*','',$sw2);
if (in_array(strtolower($sw2), $ignorewords) || strxlen($sw2) < $config['searchminlength']) {
$ignored[] = $sw2;
}
}
if (count($ignored) > 0) {
echo implode(',', $ignored);
}
else {
echo 1;
}
}
else {
echo 1;
}
}
($code = $plugins->load('ajax_end')) ? eval($code) : null;
$phpdoc->Out(0);
$db->close();
?>