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