author | Dan |
Tue, 11 Dec 2007 02:03:54 -0500 | |
changeset 0 | a09fb41e48d5 |
permissions | -rw-r--r-- |
0
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
1 |
<?php |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
2 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
3 |
/* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
4 |
* Nuggie |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
5 |
* Version 0.1 |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
6 |
* Copyright (C) 2007 Dan Fuhry |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
7 |
* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
10 |
* |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
13 |
*/ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
14 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
15 |
function page_Special_NuggieInstall() |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
16 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
17 |
global $db, $session, $paths, $template, $plugins; // Common objects |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
18 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
19 |
if ( getConfig('nuggie_installed') == '1' ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
20 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
21 |
die_friendly('Nuggie already installed', '<p>Nuggie is already installed - you can\'t reinstall it from here. To upgrade a Nuggie installation, use the upgrade tool.</p>'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
22 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
23 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
24 |
if ( $session->auth_level < USER_LEVEL_ADMIN ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
25 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
26 |
redirect(makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN), 'Login required', 'You need to be an administrator with elevated auth to install Nuggie. You will now be transferred to the login page.'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
27 |
exit; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
28 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
29 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
30 |
$mode = ( $x = $paths->getParam(0) ) ? $x : 'welcome'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
31 |
switch ( $mode ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
32 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
33 |
default: |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
34 |
die_friendly('Invalid action', '<p>Invalid installer action</p>'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
35 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
36 |
case 'welcome': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
37 |
$template->header(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
38 |
$q = $db->sql_query('SELECT group_id, group_name FROM ' . table_prefix . 'groups ORDER BY group_name ASC;'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
39 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
40 |
$db->_die('plugins/nuggie/install.php selecting group information'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
41 |
$groups = array(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
42 |
while ( (list($group_id, $group_name) = $db->fetchrow_num()) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
43 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
44 |
$groups[$group_id] = $group_name; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
45 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
46 |
?> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
47 |
<script type="text/javascript"> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
48 |
function nuggie_click(value) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
49 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
50 |
var theform = document.forms['nuggieinstall']; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
51 |
if ( !theform ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
52 |
return false; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
53 |
switch(value) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
54 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
55 |
case 'everyone': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
56 |
case 'noone': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
57 |
$('nuggieinstall_use_group').object.style.display = 'none'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
58 |
$('nuggieinstall_create_group').object.style.display = 'none'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
59 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
60 |
case 'use_group': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
61 |
$('nuggieinstall_use_group').object.style.display = 'block'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
62 |
$('nuggieinstall_create_group').object.style.display = 'none'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
63 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
64 |
case 'create_group': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
65 |
$('nuggieinstall_use_group').object.style.display = 'none'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
66 |
$('nuggieinstall_create_group').object.style.display = 'block'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
67 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
68 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
69 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
70 |
</script> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
71 |
<?php |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
72 |
echo '<form action="' . makeUrlNS('Special', 'NuggieInstall/install_base') . '" method="post" name="nuggieinstall">'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
73 |
echo '<h3>Welcome to Nuggie - the only blogging engine you\'ll ever need.</h3>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
74 |
echo '<p>Before you can start blogging, we\'ll need to perform a couple of short steps to set up Nuggie on your server. Since |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
75 |
you\'re running Nuggie on top of Enano, you won\'t need to re-enter database information – we just need to create a |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
76 |
few extra tables in your database.</p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
77 |
echo '<p>To get started, who would you like to give posting abilities to?</p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
78 |
echo '<p><label><input onclick="nuggie_click(this.value);" type="radio" name="blog_perms" value="everyone" checked="checked" /> Let everybody with an account create their own blog</label></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
79 |
echo '<p><label><input onclick="nuggie_click(this.value);" type="radio" name="blog_perms" value="use_group" /> Only people in the following group can have blogs:</label></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
80 |
echo '<p id="nuggieinstall_use_group" style="display: none; margin-left: 46px;"><select name="use_group_id">'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
81 |
foreach ( $groups as $group_id => $group_name ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
82 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
83 |
echo "<option value=\"$group_id\">" . htmlspecialchars($group_name) . "</option>"; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
84 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
85 |
echo '</select></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
86 |
echo '<p><label><input onclick="nuggie_click(this.value);" type="radio" name="blog_perms" value="create_group" /> Create a new group and only allow people in that group to have a blog:</label></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
87 |
echo '<p id="nuggieinstall_create_group" style="display: none; margin-left: 46px;">Group name: <input type="text" name="create_group_name" size="30" /><br /> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
88 |
<small>You\'ll be added to this group automatically.</small> |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
89 |
</p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
90 |
echo '<p><label><input onclick="nuggie_click(this.value);" type="radio" name="blog_perms" value="noone" /> Don\'t allow anyone to have a blog yet - I\'ll set up permissions myself. <small>(advanced)</small></label></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
91 |
echo '<p style="text-align: center;"><button><big>Next »</big></button></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
92 |
echo '</form>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
93 |
$template->footer(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
94 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
95 |
case 'install_base': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
96 |
if ( !file_exists( ENANO_ROOT . '/plugins/nuggie/schema.sql' ) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
97 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
98 |
die_friendly('Can\'t load schema file', '<p>Can\'t find the schema.sql file that should be in /plugins/nuggie. Check your Nuggie setup.</p>'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
99 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
100 |
$schema = @file_get_contents( ENANO_ROOT . '/plugins/nuggie/schema.sql' ); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
101 |
if ( empty($schema) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
102 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
103 |
die_friendly('Can\'t load schema file', '<p>Can\'t read the schema.sql file that should be in /plugins/nuggie. Check your file permissions.</p>'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
104 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
105 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
106 |
if ( !isset($_POST['blog_perms']) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
107 |
die('Missing essential form field'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
108 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
109 |
if ( !in_array($_POST['blog_perms'], array('everyone', 'use_group', 'create_group', 'noone')) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
110 |
die('You tried to hack the form'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
111 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
112 |
if ( $_POST['blog_perms'] == 'use_group' && strval(intval($_POST['use_group_id'])) !== $_POST['use_group_id'] ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
113 |
die('You tried to hack the form'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
114 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
115 |
if ( $_POST['blog_perms'] == 'create_group' && !isset($_POST['create_group_name']) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
116 |
die('You tried to hack the form'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
117 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
118 |
// |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
119 |
// PARSE SCHEMA |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
120 |
// |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
121 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
122 |
// Step 1: remove comments and blank lines |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
123 |
$schema = str_replace("\r", '', $schema); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
124 |
$schema = explode("\n", $schema); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
125 |
foreach ( $schema as $i => $_ ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
126 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
127 |
$line =& $schema[$i]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
128 |
$line = preg_replace('/--(.*)$/', '', $line); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
129 |
$line = trim($line); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
130 |
if ( empty($line) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
131 |
unset($schema[$i]); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
132 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
133 |
$schema = array_values($schema); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
134 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
135 |
// Step 2: Split into separate queries |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
136 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
137 |
$queries = array(''); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
138 |
$query =& $queries[0]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
139 |
foreach ( $schema as $line ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
140 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
141 |
if ( preg_match('/;$/', $line) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
142 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
143 |
$query .= "\n $line"; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
144 |
$queries[] = ''; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
145 |
unset($query); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
146 |
$query =& $queries[count($queries) - 1]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
147 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
148 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
149 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
150 |
$query .= "\n $line"; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
151 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
152 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
153 |
unset($query); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
154 |
foreach ( $queries as $i => $query ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
155 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
156 |
$query = trim($query); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
157 |
if ( empty($query) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
158 |
unset($queries[$i]); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
159 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
160 |
$queries[$i] = $query; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
161 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
162 |
$schema = array_values($queries); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
163 |
unset($queries, $query, $i); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
164 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
165 |
// Step 3: Assign variables |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
166 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
167 |
foreach ( $schema as $i => $_ ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
168 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
169 |
$sql =& $schema[$i]; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
170 |
$sql = str_replace('{{TABLE_PREFIX}}', table_prefix, $sql); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
171 |
unset($sql); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
172 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
173 |
unset($sql); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
174 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
175 |
// Step 4: Check queries |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
176 |
foreach ( $schema as $sql ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
177 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
178 |
if ( !$db->check_query($sql) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
179 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
180 |
die_friendly('Error during installation', '<p>DBAL rejected query citing syntax errors. This is probably a bug.</p>'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
181 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
182 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
183 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
184 |
// echo '<pre>' . htmlspecialchars(print_r($schema, true)) . '</pre>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
185 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
186 |
// Step 5: Install |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
187 |
foreach ( $schema as $sql ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
188 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
189 |
if ( !$db->sql_query($sql) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
190 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
191 |
$db->_die('Nuggie during mainstream installation'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
192 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
193 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
194 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
195 |
$template->header(true); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
196 |
echo '<h3>Base install complete</h3>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
197 |
echo '<p>The base install has completed. Please click Next to continue with the setup of ACL rules.</p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
198 |
echo '<form action="' . makeUrlNS('Special', 'NuggieInstall/install_acl') . '" method="post">'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
199 |
$group_name = htmlspecialchars($_POST['create_group_name']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
200 |
$group_name = str_replace('"', '"', $group_name); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
201 |
// This is SAFE! It's verified against a whitelist |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
202 |
echo '<input type="hidden" name="blog_perms" value="' . $_POST['blog_perms'] . '" />'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
203 |
echo "<input type=\"hidden\" name=\"use_group_id\" value=\"{$_POST['use_group_id']}\" />"; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
204 |
echo "<input type=\"hidden\" name=\"create_group_name\" value=\"{$group_name}\" />"; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
205 |
echo '<p style="text-align: center;"><button><big>Next »</big></button></p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
206 |
echo '</form>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
207 |
$template->footer(true); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
208 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
209 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
210 |
case 'install_acl': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
211 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
212 |
if ( !isset($_POST['blog_perms']) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
213 |
die('Missing essential form field'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
214 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
215 |
if ( !in_array($_POST['blog_perms'], array('everyone', 'use_group', 'create_group', 'noone')) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
216 |
die('You tried to hack the form'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
217 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
218 |
if ( $_POST['blog_perms'] == 'use_group' && strval(intval($_POST['use_group_id'])) !== $_POST['use_group_id'] ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
219 |
die('You tried to hack the form'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
220 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
221 |
if ( $_POST['blog_perms'] == 'create_group' && !isset($_POST['create_group_name']) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
222 |
die('You tried to hack the form'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
223 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
224 |
switch ( $_POST['blog_perms'] ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
225 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
226 |
case 'everyone': |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
227 |
$q = $db->sql_query('SELECT rules,rule_id FROM ' . table_prefix . 'acl WHERE target_type = ' . ACL_TYPE_GROUP . ' AND target_id = 1 AND page_id IS NULL AND namespace IS NULL;'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
228 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
229 |
$db->_die('Nuggie installer selecting existing ACL rules'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
230 |
if ( $db->numrows() < 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
231 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
232 |
// The rule doesn't exist, create it |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
233 |
$rule = $session->perm_to_string(array( |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
234 |
'nuggie_post' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
235 |
'nuggie_edit_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
236 |
'nuggie_edit_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
237 |
'nuggie_create_planet' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
238 |
'nuggie_publicize_planet' => AUTH_WIKIMODE, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
239 |
'nuggie_protect_planet' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
240 |
'nuggie_edit_planet_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
241 |
'nuggie_edit_planet_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
242 |
'nuggie_even_when_protected' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
243 |
'nuggie_see_non_public' => AUTH_DISALLOW |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
244 |
)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
245 |
$q = $db->sql_query('INSERT INTO ' . table_prefix . 'acl(rules, target_type, target_id, page_id, namespace)' . |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
246 |
"\n VALUES( '$rule', " . ACL_TYPE_GROUP . ", 1, NULL, NULL );"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
247 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
248 |
$db->_die('Nuggie installer setting up permissions'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
249 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
250 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
251 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
252 |
list($rule, $rule_id) = $db->fetchrow_num(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
253 |
$rule = $session->string_to_perm($rule); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
254 |
$rule = $session->acl_merge_complete($rule, array( |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
255 |
'nuggie_post' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
256 |
'nuggie_edit_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
257 |
'nuggie_edit_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
258 |
'nuggie_create_planet' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
259 |
'nuggie_publicize_planet' => AUTH_WIKIMODE, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
260 |
'nuggie_protect_planet' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
261 |
'nuggie_edit_planet_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
262 |
'nuggie_edit_planet_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
263 |
'nuggie_even_when_protected' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
264 |
'nuggie_see_non_public' => AUTH_DISALLOW |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
265 |
)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
266 |
$rule = $session->perm_to_string($rule); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
267 |
$q = $db->sql_query('UPDATE ' . table_prefix . 'acl' . |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
268 |
"\n SET rules='$rule'\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
269 |
. " WHERE rule_id = $rule_id;"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
270 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
271 |
$db->_die('Nuggie installer setting up permissions'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
272 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
273 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
274 |
case "create_group": |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
275 |
$group_name = $db->escape($_POST['create_group_name']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
276 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
277 |
$q = $db->sql_query('INSERT INTO ' . table_prefix . "groups ( group_name ) VALUES ( '$group_name' );"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
278 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
279 |
$db->_die('Nuggie installer creating group'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
280 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
281 |
$group_id = $db->insert_id(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
282 |
$q = $db->sql_query('INSERT INTO ' . table_prefix . "group_members( group_id, user_id ) VALUES ( $group_id, {$session->user_id} );"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
283 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
284 |
$db->_die('Nuggie installer adding user to new group'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
285 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
286 |
case "use_group": |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
287 |
if ( !isset($group_id) ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
288 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
289 |
$group_id = intval($_POST['use_group_id']); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
290 |
$q = $db->sql_query('SELECT group_name, group_id FROM ' . table_prefix . "groups WHERE group_id = $group_id;"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
291 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
292 |
$db->_die('Nuggie installer determining group information'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
293 |
if ( $db->numrows() < 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
294 |
die('Hacking attempt'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
295 |
list($group_name, $group_id) = $db->fetchrow_num(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
296 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
297 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
298 |
$q = $db->sql_query('SELECT rules,rule_id FROM ' . table_prefix . 'acl WHERE target_type = ' . ACL_TYPE_GROUP . " AND target_id = $group_id AND page_id IS NULL AND namespace IS NULL;"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
299 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
300 |
$db->_die('Nuggie installer selecting existing ACL rules'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
301 |
if ( $db->numrows() < 1 ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
302 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
303 |
// The rule doesn't exist, create it |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
304 |
$rule = $session->perm_to_string(array( |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
305 |
'nuggie_post' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
306 |
'nuggie_edit_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
307 |
'nuggie_edit_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
308 |
'nuggie_create_planet' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
309 |
'nuggie_publicize_planet' => AUTH_WIKIMODE, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
310 |
'nuggie_protect_planet' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
311 |
'nuggie_edit_planet_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
312 |
'nuggie_edit_planet_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
313 |
'nuggie_even_when_protected' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
314 |
'nuggie_see_non_public' => AUTH_DISALLOW |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
315 |
)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
316 |
$q = $db->sql_query('INSERT INTO ' . table_prefix . 'acl(rules, target_type, target_id, page_id, namespace)' . |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
317 |
"\n VALUES( '$rule', " . ACL_TYPE_GROUP . ", $group_id, NULL, NULL );"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
318 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
319 |
$db->_die('Nuggie installer setting up permissions'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
320 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
321 |
else |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
322 |
{ |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
323 |
list($rule, $rule_id) = $db->fetchrow_num(); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
324 |
$rule = $session->string_to_perm($rule); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
325 |
$rule = $session->acl_merge_complete($rule, array( |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
326 |
'nuggie_post' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
327 |
'nuggie_edit_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
328 |
'nuggie_edit_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
329 |
'nuggie_create_planet' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
330 |
'nuggie_publicize_planet' => AUTH_WIKIMODE, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
331 |
'nuggie_protect_planet' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
332 |
'nuggie_edit_planet_own' => AUTH_ALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
333 |
'nuggie_edit_planet_other' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
334 |
'nuggie_even_when_protected' => AUTH_DISALLOW, |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
335 |
'nuggie_see_non_public' => AUTH_DISALLOW |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
336 |
)); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
337 |
$rule = $session->perm_to_string($rule); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
338 |
$q = $db->sql_query('UPDATE ' . table_prefix . 'acl' . |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
339 |
"\n SET rules='$rule'\n" |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
340 |
. " WHERE rule_id = $rule_id;"); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
341 |
if ( !$q ) |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
342 |
$db->_die('Nuggie installer setting up permissions'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
343 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
344 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
345 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
346 |
case "noone": |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
347 |
// Don't touch permissions, let the webmaster handle it |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
348 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
349 |
default: |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
350 |
die('PHP = douche bag'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
351 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
352 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
353 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
354 |
// Mark it as installed to prevent installer module from loading |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
355 |
setConfig('nuggie_installed', '1'); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
356 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
357 |
$template->header(true); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
358 |
echo '<h3>Nuggie has been installed.</h3>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
359 |
echo '<p>You\'ve successfully installed Nuggie. Congratulations!</p>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
360 |
echo '<form action="' . makeUrlNS('Special', 'Preferences/Blog') . '" method="post">'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
361 |
echo '<p style="text-align: center;"><big><button>Start blogging »</button></big>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
362 |
echo '</form>'; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
363 |
$template->footer(true); |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
364 |
|
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
365 |
break; |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
366 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
367 |
} |
a09fb41e48d5
First commit! Woohoo! Basic status of things is in extended description.
Dan
parents:
diff
changeset
|
368 |