]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - g
Better error message: use exit_no_group
[SourceForge/phpwiki.git] / g
1 <?php // -*-php-*- $Id$
2
3 /*
4  * Copyright (C) 2008-2010 Alcatel-Lucent
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 */
22
23 /*
24  * Standard Alcatel-Lucent disclaimer for contributing to open source
25  *
26  * "The Configuration File ("Contribution") has not been tested and/or
27  * validated for release as or in products, combinations with products or
28  * other commercial use. Any use of the Contribution is entirely made at
29  * the user's own responsibility and the user can not rely on any features,
30  * functionalities or performances Alcatel-Lucent has attributed to the
31  * Contribution.
32  *
33  * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34  * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36  * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37  * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38  * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40  * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41  * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
42  * ALONE BASIS."
43  */
44
45 ini_set("memory_limit", "64M");
46
47 // Disable compression, seems needed to get all the messages.
48 $no_gz_buffer=true;
49
50 require_once('../../env.inc.php');
51 require_once $gfwww.'include/pre.php';
52 require_once $gfplugins.'wiki/common/wikiconfig.class.php';
53
54 if (!$group_id || !$project) {
55      exit_no_group();
56 } else if (!($project->usesPlugin("wiki"))) {
57     exit_error("Wiki plugin not activated in project", $project->getPublicName());
58 } else {
59
60     $group_name = $project->getUnixName();
61     $group_public_name = $project->getPublicName();
62     $is_external = $project->getIsExternal();
63
64     $wc = new WikiConfig($group_id);
65
66     define('VIRTUAL_PATH', '/wiki/g/'.$group_name);
67     define('PAGE_PREFIX', '_g'.$group_id.'_');
68
69     define('THEME', 'gforge');
70
71     // For Gforge, we create some specific pages, located in the theme
72     // except for project "help"
73     if ($group_name == "help") {
74         define('WIKI_PGSRC', 'pgsrc/');
75     } else {
76         define('WIKI_PGSRC', 'themes/gforge/pgsrc/');
77     }
78
79     define('GFORGE', true);
80
81     define('PATH_INFO_PREFIX', '/'.$group_name . '/');
82     define('USE_PATH_INFO', true);
83
84     define('WIKI_NAME', $group_name);
85
86     define('DISABLE_MARKUP_WIKIWORD', $wc->getWikiConfig('DISABLE_MARKUP_WIKIWORD'));
87
88     define('NUM_SPAM_LINKS', 20 * ($wc->getWikiConfig('NUM_SPAM_LINKS')));
89
90     define('ENABLE_RATEIT', $wc->getWikiConfig('ENABLE_RATEIT'));
91
92     define('UPLOAD_FILE_PATH', '/opt/groups/'.WIKI_NAME.'/www/uploads/');
93     // define('UPLOAD_DATA_PATH', SERVER_URL . '/www/'.WIKI_NAME.'/uploads/');
94     define('UPLOAD_DATA_PATH', '/www/'.WIKI_NAME.'/uploads/');
95
96     // Do not use a directory per user but only one (per project)
97     define('UPLOAD_USERDIR', false);
98
99     // Use black list of extensions instead of white list
100     define('DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS', true);
101
102     // Get the maximum upload filesize from PHP config
103     define('MAX_UPLOAD_SIZE', octets(ini_get('upload_max_filesize')));
104
105     // GForge is UTF-8, so use the same.
106     define('CHARSET', 'UTF-8');
107
108     // Disable access log (already in apache & gforge).
109     define('ACCESS_LOG_SQL', 0);
110
111     define('DEBUG', ($sys_install_type != 'production'));
112     // define('_DEBUG_LOGIN', true);
113
114     // Postgresql
115     define('DATABASE_TYPE', 'SQL');
116     // Dummy value (to avoid warning in SystemInfo plugin)
117     define('DATABASE_DSN', 'pgsql://localhost/user_phpwiki');
118
119     // Disable VACUUM (they are performed every night)
120     define('DATABASE_OPTIMISE_FREQUENCY', 0);
121
122     // TBD: the name should be taken from Gforge
123     // define('ADMIN_USER', 'ACOS Forge Administrator');
124     define('ADMIN_USER', 'The PhpWiki programming team');
125     // Dummy value
126     define('ADMIN_PASSWD', 'xxx');
127
128     // Allow ".svg" as extension
129     define('INLINE_IMAGES', 'png|jpg|jpeg|gif|svg');
130
131     // Allow parsing of headers for CreateToc
132     define('TOC_FULL_SYNTAX', true);
133
134     // Allow <div> and <span> in wiki code
135     define('ENABLE_MARKUP_DIVSPAN', true);
136
137     // Disable ENABLE_ACDROPDOWN, it creates a <style> in the <body> (illegal)
138     define('ENABLE_ACDROPDOWN', false);
139     define('ENABLE_AJAX', false);
140
141     define('TOOLBAR_PAGELINK_PULLDOWN', false);
142     define('TOOLBAR_TEMPLATE_PULLDOWN', false);
143     define('TOOLBAR_IMAGE_PULLDOWN', true);
144
145     // Disable WYSIWYG
146     define('ENABLE_WYSIWYG', false);
147     define('WYSIWYG_BACKEND', 'tinymce');
148     define('WYSIWYG_DEFAULT_PAGETYPE_HTML', false);
149
150     // Disable public pages
151     define('ENABLE_PAGE_PUBLIC', false);
152
153     // Enable external pages
154     define('ENABLE_EXTERNAL_PAGES', $is_external);
155
156     // Let all revisions be stored. Default since 1.3.11
157     define('MAJOR_MIN_KEEP', 2147483647);
158     define('MINOR_MIN_KEEP', 2147483647);
159     define('MAJOR_MAX_AGE', 2147483647);
160     define('MAJOR_KEEP', 2147483647);
161     define('MINOR_MAX_AGE', 2147483647);
162     define('MINOR_KEEP', 2147483647);
163     define('AUTHOR_MAX_AGE', 2147483647);
164     define('AUTHOR_KEEP', 2147483647);
165     define('AUTHOR_MIN_AGE', 2147483647);
166     define('AUTHOR_MAX_KEEP', 2147483647);
167
168     //
169     // Define access rights for the wiki.
170     //
171
172     // Allow anonymous user to view the pages.
173     define('ALLOW_ANON_USER', true);
174
175     // Do not allow anon users to edit pages
176     define('ALLOW_ANON_EDIT', false);
177
178     // Do not allow fake user
179     define('ALLOW_BOGO_LOGIN', false);
180     define('ALLOW_USER_PASSWORDS', true);
181
182     // A dedicated auth has been created to get auth from GForge
183     $USER_AUTH_ORDER = array("GForge");
184     define('USER_AUTH_ORDER', 'GForge');
185     define('USER_AUTH_POLICY', 'strict');
186
187     define('EXTERNAL_LINK_TARGET', '_top');
188
189     // Override the default configuration for CONSTANTS before index.php
190     $LANG='en'; $LC_ALL='en_US';
191
192     // We use a local interwiki map file
193     define('INTERWIKI_MAP_FILE', 'themes/gforge/interwiki.map');
194
195     define('DEFAULT_WIKI_PAGES', "");
196
197     define('DBAUTH_AUTH_CHECK', "SELECT IF(passwd='\$password',1,0) as ok FROM plugin_wiki_pref WHERE userid='\$userid'");
198     define('DBAUTH_AUTH_USER_EXISTS', "SELECT userid FROM plugin_wiki_pref WHERE userid='\$userid'");
199     define('DBAUTH_AUTH_CREATE', "INSERT INTO plugin_wiki_pref (passwd,userid) VALUES ('\$password','\$userid')");
200     define('DBAUTH_PREF_SELECT', "SELECT prefs FROM plugin_wiki_pref WHERE userid='\$userid'");
201     define('DBAUTH_PREF_UPDATE', "UPDATE plugin_wiki_pref SET prefs='\$pref_blob' WHERE userid='\$userid'");
202     define('DBAUTH_PREF_INSERT', "INSERT INTO plugin_wiki_pref (prefs,userid) VALUES ('\$pref_blob','\$userid')");
203     define('DBAUTH_IS_MEMBER', "SELECT userid FROM plugin_wiki_pref WHERE userid='\$userid' AND groupname='\$groupname'");
204     define('DBAUTH_GROUP_MEMBERS', "SELECT userid FROM plugin_wiki_pref WHERE groupname='\$groupname'");
205     define('DBAUTH_USER_GROUPS', "SELECT groupname FROM plugin_wiki_pref WHERE userid='\$userid'");
206
207     define('USE_DB_SESSION', true);
208
209     define('USE_BYTEA', true);
210
211     define('ENABLE_SPAMBLOCKLIST', false);
212
213     define('ENCRYPTED_PASSWD', true);
214
215     define('ENABLE_REVERSE_DNS', false);
216
217     define('ZIPDUMP_AUTH', false);
218
219     define('ENABLE_RAW_HTML', true);
220
221     define('ENABLE_RAW_HTML_LOCKEDONLY', true);
222
223     define('ENABLE_RAW_HTML_SAFE', true);
224
225     define('STRICT_MAILABLE_PAGEDUMPS', false);
226
227     // Perhaps propose Web DAV location ?
228     define('DEFAULT_DUMP_DIR', "");
229     define('HTML_DUMP_DIR', "");
230     define('HTML_DUMP_SUFFIX', ".html");
231
232     define('MINOR_EDIT_TIMEOUT', 604800);
233
234     define('COMPRESS_OUTPUT', false);
235
236     define('CACHE_CONTROL', "NO_CACHE");
237
238     define('CACHE_CONTROL_MAX_AGE', 600);
239
240     define('COOKIE_EXPIRATION_DAYS', 365);
241
242     define('GROUP_METHOD', "WIKIPAGE");
243
244     define('DBAUTH_AUTH_CRYPT_METHOD', "plain");
245
246     define('DEFAULT_LANGUAGE', "en");
247
248     define('DISABLE_GETIMAGESIZE', true);
249
250     define('ENABLE_EDIT_TOOLBAR', true);
251
252     // If the user is logged in, let the Wiki know
253     if (session_loggedin()){
254         // let php do it's session stuff too!
255         //ini_set('session.save_handler', 'files');
256         // session_start();
257         $user = session_get_user();
258
259         if ($user && is_object($user) && !$user->isError() && $user->isActive()) {
260             $user_name = $user->getRealName();
261             $_SESSION['user_id'] = $user_name;
262             $_SERVER['PHP_AUTH_USER'] = $user_name;
263             $HTTP_SERVER_VARS['PHP_AUTH_USER'] = $user_name;
264         }
265     } else {
266         // clear out the globals, just in case...
267     }
268
269     // Load the default configuration.
270     include dirname(__FILE__).'/index.php';
271
272     // Override the default configuration for VARIABLES after index.php:
273     // E.g. Use another DB:
274     $DBParams['dbtype'] = 'SQL';
275     $DBParams['dsn']    = 'ffpgsql://' . $sys_dbuser . ':' .
276         $sys_dbpasswd . '@' . $sys_dbhost .'/' . $sys_dbname;
277
278     $DBParams['prefix'] = "plugin_wiki_";
279
280     // Start the wiki
281     include dirname(__FILE__).'/lib/main.php';
282 }
283
284 /**
285  * Return a number of octets from a string like "300M"
286  */
287 function octets($val) {
288     $val = trim($val);
289     $last = strtolower($val[strlen($val)-1]);
290     switch($last) {
291         // The 'G' modifier is available since PHP 5.1.0
292         case 'g':
293             $val *= 1024;
294         case 'm':
295             $val *= 1024;
296         case 'k':
297             $val *= 1024;
298     }
299     return $val;
300 }
301 ?>