author | Dan |
Sun, 02 Dec 2007 16:00:10 -0500 | |
changeset 304 | e2cb5f1432c8 |
parent 228 | b0a4d179be85 |
parent 289 | 2b60c89dc27f |
child 313 | 854eecfada20 |
permissions | -rw-r--r-- |
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
1 |
<?php |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
2 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
3 |
/* |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
5 |
* Version 1.1.1 |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
6 |
* Copyright (C) 2006-2007 Dan Fuhry |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
7 |
* |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
10 |
* |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
13 |
*/ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
14 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
15 |
// fillusername should be done without the help of the rest of Enano - all we need is the DBAL |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
16 |
if ( isset($_GET['_mode']) && $_GET['_mode'] == 'fillusername' ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
17 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
18 |
// setup and load a very basic, specialized instance of the Enano API |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
19 |
function dc_here($m) { return false; } |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
20 |
function dc_dump($a, $g) { return false; } |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
21 |
function dc_watch($n) { return false; } |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
22 |
function dc_start_timer($u) { return false; } |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
23 |
function dc_stop_timer($m) { return false; } |
304 | 24 |
function microtime_float() |
25 |
{ |
|
26 |
list($usec, $sec) = explode(" ", microtime()); |
|
27 |
return ((float)$usec + (float)$sec); |
|
28 |
} |
|
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
29 |
// Determine directory (special case for development servers) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
30 |
if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
31 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
32 |
$filename = str_replace('/repo/', '/', __FILE__); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
33 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
34 |
else |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
35 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
36 |
$filename = __FILE__; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
37 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
38 |
define('ENANO_ROOT', dirname($filename)); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
39 |
require(ENANO_ROOT.'/includes/functions.php'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
40 |
require(ENANO_ROOT.'/includes/dbal.php'); |
209 | 41 |
require(ENANO_ROOT.'/includes/json.php'); |
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
42 |
$db = new mysql(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
43 |
$db->connect(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
44 |
|
209 | 45 |
// result is sent using JSON |
46 |
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); |
|
47 |
$return = Array( |
|
48 |
'mode' => 'success', |
|
49 |
'users_real' => Array() |
|
50 |
); |
|
51 |
||
52 |
// should be connected to the DB now |
|
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
53 |
$name = (isset($_GET['name'])) ? $db->escape($_GET['name']) : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
54 |
if ( !$name ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
55 |
{ |
209 | 56 |
$return = array( |
57 |
'mode' => 'error', |
|
58 |
'error' => 'Invalid URI' |
|
59 |
); |
|
60 |
die( $json->encode($return) ); |
|
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
61 |
} |
209 | 62 |
$allowanon = ( isset($_GET['allowanon']) && $_GET['allowanon'] == '1' ) ? '' : ' AND user_id > 1'; |
63 |
$q = $db->sql_query('SELECT username FROM '.table_prefix.'users WHERE lcase(username) LIKE lcase(\'%'.$name.'%\')' . $allowanon . ' ORDER BY username ASC;'); |
|
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
64 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
65 |
{ |
209 | 66 |
$return = array( |
67 |
'mode' => 'error', |
|
68 |
'error' => 'MySQL error selecting username data: '.addslashes(mysql_error()) |
|
69 |
); |
|
70 |
die( $json->encode($return) ); |
|
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
71 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
72 |
$i = 0; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
73 |
while($r = $db->fetchrow()) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
74 |
{ |
209 | 75 |
$return['users_real'][] = $r['username']; |
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
76 |
$i++; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
77 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
78 |
$db->free_result(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
79 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
80 |
// all done! :-) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
81 |
$db->close(); |
209 | 82 |
|
83 |
echo $json->encode( $return ); |
|
84 |
||
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
85 |
exit; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
86 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
87 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
88 |
require('includes/common.php'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
89 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
90 |
global $db, $session, $paths, $template, $plugins; // Common objects |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
91 |
if(!isset($_GET['_mode'])) die('This script cannot be accessed directly.'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
92 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
93 |
$_ob = ''; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
94 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
95 |
switch($_GET['_mode']) { |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
96 |
case "checkusername": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
97 |
echo PageUtils::checkusername($_GET['name']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
98 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
99 |
case "getsource": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
100 |
$p = ( isset($_GET['pagepass']) ) ? $_GET['pagepass'] : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
101 |
echo PageUtils::getsource($paths->page, $p); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
102 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
103 |
case "getpage": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
104 |
// echo PageUtils::getpage($paths->page, false, ( (isset($_GET['oldid'])) ? $_GET['oldid'] : false )); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
105 |
$revision_id = ( (isset($_GET['oldid'])) ? intval($_GET['oldid']) : 0 ); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
106 |
$page = new PageProcessor( $paths->cpage['urlname_nons'], $paths->namespace, $revision_id ); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
107 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
108 |
$pagepass = ( isset($_REQUEST['pagepass']) ) ? $_REQUEST['pagepass'] : ''; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
109 |
$page->password = $pagepass; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
110 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
111 |
$page->send(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
112 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
113 |
case "savepage": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
114 |
$summ = ( isset($_POST['summary']) ) ? $_POST['summary'] : ''; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
115 |
$minor = isset($_POST['minor']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
116 |
$e = PageUtils::savepage($paths->cpage['urlname_nons'], $paths->namespace, $_POST['text'], $summ, $minor); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
117 |
if($e=='good') |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
118 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
119 |
$page = new PageProcessor($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
120 |
$page->send(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
121 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
122 |
else |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
123 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
124 |
echo '<p>Error saving the page: '.$e.'</p>'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
125 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
126 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
127 |
case "protect": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
128 |
echo PageUtils::protect($paths->cpage['urlname_nons'], $paths->namespace, (int)$_POST['level'], $_POST['reason']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
129 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
130 |
case "histlist": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
131 |
echo PageUtils::histlist($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
132 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
133 |
case "rollback": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
134 |
echo PageUtils::rollback( (int)$_GET['id'] ); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
135 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
136 |
case "comments": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
137 |
$comments = new Comments($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
138 |
if ( isset($_POST['data']) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
139 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
140 |
$comments->process_json($_POST['data']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
141 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
142 |
else |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
143 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
144 |
die('{ "mode" : "error", "error" : "No input" }'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
145 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
146 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
147 |
case "rename": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
148 |
echo PageUtils::rename($paths->cpage['urlname_nons'], $paths->namespace, $_POST['newtitle']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
149 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
150 |
case "flushlogs": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
151 |
echo PageUtils::flushlogs($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
152 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
153 |
case "deletepage": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
154 |
$reason = ( isset($_POST['reason']) ) ? $_POST['reason'] : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
155 |
if ( empty($reason) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
156 |
die('Please enter a reason for deleting this page.'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
157 |
echo PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace, $reason); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
158 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
159 |
case "delvote": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
160 |
echo PageUtils::delvote($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
161 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
162 |
case "resetdelvotes": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
163 |
echo PageUtils::resetdelvotes($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
164 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
165 |
case "getstyles": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
166 |
echo PageUtils::getstyles($_GET['id']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
167 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
168 |
case "catedit": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
169 |
echo PageUtils::catedit($paths->cpage['urlname_nons'], $paths->namespace); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
170 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
171 |
case "catsave": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
172 |
echo PageUtils::catsave($paths->cpage['urlname_nons'], $paths->namespace, $_POST); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
173 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
174 |
case "setwikimode": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
175 |
echo PageUtils::setwikimode($paths->cpage['urlname_nons'], $paths->namespace, (int)$_GET['mode']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
176 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
177 |
case "setpass": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
178 |
echo PageUtils::setpass($paths->cpage['urlname_nons'], $paths->namespace, $_POST['password']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
179 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
180 |
case "fillusername": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
181 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
182 |
case "fillpagename": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
183 |
$name = (isset($_GET['name'])) ? $_GET['name'] : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
184 |
if(!$name) die('userlist = new Array(); namelist = new Array(); errorstring=\'Invalid URI\''); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
185 |
$nd = RenderMan::strToPageID($name); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
186 |
$c = 0; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
187 |
$u = Array(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
188 |
$n = Array(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
189 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
190 |
$name = sanitize_page_id($name); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
191 |
$name = str_replace('_', ' ', $name); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
192 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
193 |
for($i=0;$i<sizeof($paths->pages)/2;$i++) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
194 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
195 |
if( ( |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
196 |
preg_match('#'.preg_quote($name).'(.*)#i', $paths->pages[$i]['name']) || |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
197 |
preg_match('#'.preg_quote($name).'(.*)#i', $paths->pages[$i]['urlname']) || |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
198 |
preg_match('#'.preg_quote($name).'(.*)#i', $paths->pages[$i]['urlname_nons']) || |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
199 |
preg_match('#'.preg_quote(str_replace(' ', '_', $name)).'(.*)#i', $paths->pages[$i]['name']) || |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
200 |
preg_match('#'.preg_quote(str_replace(' ', '_', $name)).'(.*)#i', $paths->pages[$i]['urlname']) || |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
201 |
preg_match('#'.preg_quote(str_replace(' ', '_', $name)).'(.*)#i', $paths->pages[$i]['urlname_nons']) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
202 |
) && |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
203 |
( ( $nd[1] != 'Article' && $paths->pages[$i]['namespace'] == $nd[1] ) || $nd[1] == 'Article' ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
204 |
&& $paths->pages[$i]['visible'] |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
205 |
) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
206 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
207 |
$c++; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
208 |
$u[] = $paths->pages[$i]['name']; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
209 |
$n[] = $paths->pages[$i]['urlname']; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
210 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
211 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
212 |
if($c > 0) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
213 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
214 |
echo 'userlist = new Array(); namelist = new Array(); errorstring = false; '."\n"; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
215 |
for($i=0;$i<sizeof($u);$i++) // Can't use foreach because we need the value of $i and we need to use both $u and $n |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
216 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
217 |
echo "userlist[$i] = '".addslashes($n[$i])."';\n"; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
218 |
echo "namelist[$i] = '".addslashes(htmlspecialchars($u[$i]))."';\n"; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
219 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
220 |
} else { |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
221 |
die('userlist = new Array(); namelist = new Array(); errorstring=\'No page matches found.\''); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
222 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
223 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
224 |
case "preview": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
225 |
echo PageUtils::genPreview($_POST['text']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
226 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
227 |
case "pagediff": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
228 |
$id1 = ( isset($_GET['diff1']) ) ? (int)$_GET['diff1'] : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
229 |
$id2 = ( isset($_GET['diff2']) ) ? (int)$_GET['diff2'] : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
230 |
if(!$id1 || !$id2) { echo '<p>Invalid request.</p>'; $template->footer(); break; } |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
231 |
if(!preg_match('#^([0-9]+)$#', (string)$_GET['diff1']) || |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
232 |
!preg_match('#^([0-9]+)$#', (string)$_GET['diff2'] )) { echo '<p>SQL injection attempt</p>'; $template->footer(); break; } |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
233 |
echo PageUtils::pagediff($paths->cpage['urlname_nons'], $paths->namespace, $id1, $id2); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
234 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
235 |
case "jsres": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
236 |
die('// ERROR: this section is deprecated and has moved to includes/clientside/static/enano-lib-basic.js.'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
237 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
238 |
case "rdns": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
239 |
if(!$session->get_permissions('mod_misc')) die('Go somewhere else for your reverse DNS info!'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
240 |
$ip = $_GET['ip']; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
241 |
$rdns = gethostbyaddr($ip); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
242 |
if($rdns == $ip) echo 'Unable to get reverse DNS information. Perhaps the DNS server is down or the PTR record no longer exists.'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
243 |
else echo $rdns; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
244 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
245 |
case 'acljson': |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
246 |
$parms = ( isset($_POST['acl_params']) ) ? rawurldecode($_POST['acl_params']) : false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
247 |
echo PageUtils::acl_json($parms); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
248 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
249 |
case "change_theme": |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
250 |
if ( !isset($_POST['theme_id']) || !isset($_POST['style_id']) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
251 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
252 |
die('Invalid input'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
253 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
254 |
if ( !preg_match('/^([a-z0-9_-]+)$/i', $_POST['theme_id']) || !preg_match('/^([a-z0-9_-]+)$/i', $_POST['style_id']) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
255 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
256 |
die('Invalid input'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
257 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
258 |
if ( !file_exists(ENANO_ROOT . '/themes/' . $_POST['theme_id'] . '/css/' . $_POST['style_id'] . '.css') ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
259 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
260 |
die('Can\'t find theme file: ' . ENANO_ROOT . '/themes/' . $_POST['theme_id'] . '/css/' . $_POST['style_id'] . '.css'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
261 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
262 |
if ( !$session->user_logged_in ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
263 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
264 |
die('You must be logged in to change your theme'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
265 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
266 |
// Just in case something slipped through... |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
267 |
$theme_id = $db->escape($_POST['theme_id']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
268 |
$style_id = $db->escape($_POST['style_id']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
269 |
$e = $db->sql_query('UPDATE ' . table_prefix . "users SET theme='$theme_id', style='$style_id' WHERE user_id=$session->user_id;"); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
270 |
if ( !$e ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
271 |
die( $db->get_error() ); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
272 |
die('GOOD'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
273 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
274 |
case 'get_tags': |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
275 |
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
276 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
277 |
$ret = array('tags' => array(), 'user_level' => $session->user_level, 'can_add' => $session->get_permissions('tag_create')); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
278 |
$q = $db->sql_query('SELECT t.tag_id, t.tag_name, pg.pg_target IS NOT NULL AS used_in_acl, t.user FROM '.table_prefix.'tags AS t |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
279 |
LEFT JOIN '.table_prefix.'page_groups AS pg |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
280 |
ON ( ( pg.pg_type = ' . PAGE_GRP_TAGGED . ' AND pg.pg_target=t.tag_name ) OR ( pg.pg_type IS NULL AND pg.pg_target IS NULL ) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
281 |
WHERE t.page_id=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND t.namespace=\'' . $db->escape($paths->namespace) . '\';'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
282 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
283 |
$db->_die(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
284 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
285 |
while ( $row = $db->fetchrow() ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
286 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
287 |
$can_del = true; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
288 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
289 |
$perm = ( $row['user'] != $session->user_id ) ? |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
290 |
'tag_delete_other' : |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
291 |
'tag_delete_own'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
292 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
293 |
if ( $row['user'] == 1 && !$session->user_logged_in ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
294 |
// anonymous user trying to delete tag (hardcode blacklisted) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
295 |
$can_del = false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
296 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
297 |
if ( !$session->get_permissions($perm) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
298 |
$can_del = false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
299 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
300 |
if ( $row['used_in_acl'] == 1 && !$session->get_permissions('edit_acl') && $session->user_level < USER_LEVEL_ADMIN ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
301 |
$can_del = false; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
302 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
303 |
$ret['tags'][] = array( |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
304 |
'id' => $row['tag_id'], |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
305 |
'name' => $row['tag_name'], |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
306 |
'can_del' => $can_del, |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
307 |
'acl' => ( $row['used_in_acl'] == 1 ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
308 |
); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
309 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
310 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
311 |
echo $json->encode($ret); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
312 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
313 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
314 |
case 'addtag': |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
315 |
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
316 |
$resp = array( |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
317 |
'success' => false, |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
318 |
'error' => 'No error', |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
319 |
'can_del' => ( $session->get_permissions('tag_delete_own') && $session->user_logged_in ), |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
320 |
'in_acl' => false |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
321 |
); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
322 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
323 |
// first of course, are we allowed to tag pages? |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
324 |
if ( !$session->get_permissions('tag_create') ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
325 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
326 |
$resp['error'] = 'You are not permitted to tag pages.'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
327 |
die($json->encode($resp)); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
328 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
329 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
330 |
// sanitize the tag name |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
331 |
$tag = sanitize_tag($_POST['tag']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
332 |
$tag = $db->escape($tag); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
333 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
334 |
if ( strlen($tag) < 2 ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
335 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
336 |
$resp['error'] = 'Tags must consist of at least 2 alphanumeric characters.'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
337 |
die($json->encode($resp)); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
338 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
339 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
340 |
// check if tag is already on page |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
341 |
$q = $db->sql_query('SELECT 1 FROM '.table_prefix.'tags WHERE page_id=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND namespace=\'' . $db->escape($paths->namespace) . '\' AND tag_name=\'' . $tag . '\';'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
342 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
343 |
$db->_die(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
344 |
if ( $db->numrows() > 0 ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
345 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
346 |
$resp['error'] = 'This page already has this tag.'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
347 |
die($json->encode($resp)); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
348 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
349 |
$db->free_result(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
350 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
351 |
// tricky: make sure this tag isn't being used in some page group, and thus adding it could affect page access |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
352 |
$can_edit_acl = ( $session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN ); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
353 |
$q = $db->sql_query('SELECT 1 FROM '.table_prefix.'page_groups WHERE pg_type=' . PAGE_GRP_TAGGED . ' AND pg_target=\'' . $tag . '\';'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
354 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
355 |
$db->_die(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
356 |
if ( $db->numrows() > 0 && !$can_edit_acl ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
357 |
{ |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
358 |
$resp['error'] = 'This tag is used in an ACL page group, and thus can\'t be added to a page by people without administrator privileges.'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
359 |
die($json->encode($resp)); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
360 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
361 |
$resp['in_acl'] = ( $db->numrows() > 0 ); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
362 |
$db->free_result(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
363 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
364 |
// we're good |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
365 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'tags(tag_name,page_id,namespace,user) VALUES(\'' . $tag . '\', \'' . $db->escape($paths->cpage['urlname_nons']) . '\', \'' . $db->escape($paths->namespace) . '\', ' . $session->user_id . ');'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
366 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
367 |
$db->_die(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
368 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
369 |
$resp['success'] = true; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
370 |
$resp['tag'] = $tag; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
371 |
$resp['tag_id'] = $db->insert_id(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
372 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
373 |
echo $json->encode($resp); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
374 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
375 |
case 'deltag': |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
376 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
377 |
$tag_id = intval($_POST['tag_id']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
378 |
if ( empty($tag_id) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
379 |
die('Invalid tag ID'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
380 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
381 |
$q = $db->sql_query('SELECT t.tag_id, t.user, t.page_id, t.namespace, pg.pg_target IS NOT NULL AS used_in_acl FROM '.table_prefix.'tags AS t |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
382 |
LEFT JOIN '.table_prefix.'page_groups AS pg |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
383 |
ON ( pg.pg_id IS NULL OR ( pg.pg_target = t.tag_name AND pg.pg_type = ' . PAGE_GRP_TAGGED . ' ) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
384 |
WHERE t.tag_id=' . $tag_id . ';'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
385 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
386 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
387 |
$db->_die(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
388 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
389 |
if ( $db->numrows() < 1 ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
390 |
die('Could not find a tag with that ID'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
391 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
392 |
$row = $db->fetchrow(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
393 |
$db->free_result(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
394 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
395 |
if ( $row['page_id'] == $paths->cpage['urlname_nons'] && $row['namespace'] == $paths->namespace ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
396 |
$perms =& $session; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
397 |
else |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
398 |
$perms = $session->fetch_page_acl($row['page_id'], $row['namespace']); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
399 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
400 |
$perm = ( $row['user'] != $session->user_id ) ? |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
401 |
'tag_delete_other' : |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
402 |
'tag_delete_own'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
403 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
404 |
if ( $row['user'] == 1 && !$session->user_logged_in ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
405 |
// anonymous user trying to delete tag (hardcode blacklisted) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
406 |
die('You are not authorized to delete this tag.'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
407 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
408 |
if ( !$perms->get_permissions($perm) ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
409 |
die('You are not authorized to delete this tag.'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
410 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
411 |
if ( $row['used_in_acl'] == 1 && !$perms->get_permissions('edit_acl') && $session->user_level < USER_LEVEL_ADMIN ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
412 |
die('You are not authorized to delete this tag.'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
413 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
414 |
// We're good |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
415 |
$q = $db->sql_query('DELETE FROM '.table_prefix.'tags WHERE tag_id = ' . $tag_id . ';'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
416 |
if ( !$q ) |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
417 |
$db->_die(); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
418 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
419 |
echo 'success'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
420 |
|
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
421 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
422 |
case 'ping': |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
423 |
echo 'pong'; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
424 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
425 |
default: |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
426 |
die('Hacking attempt'); |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
427 |
break; |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
428 |
} |
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
|
429 |
|
0 | 430 |
?> |