]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - g
exit_disabled --> exit_project_disabled
[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 ini_set("memory_limit", "256M");
45
46 // Disable compression, seems needed to get all the messages.
47 $no_gz_buffer=true;
48
49 require_once('../../../common/include/env.inc.php');
50 require_once $gfcommon.'include/pre.php';
51 require_once $gfplugins.'wiki/common/wikiconfig.class.php';
52
53 html_use_jquery();
54 if (forge_get_config('use_jquery_form_navigate')) {
55         use_javascript('/scripts/jquery-formnavigate/jquery.FormNavigate-min.js');
56 }
57
58 if (isset($group_id) && $group_id) {
59         if (! isset($project) || ! $project) {
60                 $project = group_get_object($group_id);
61         }
62 } elseif(isset($project) && is_object($project)) {
63         $group_id = $project->getID();
64 }
65
66 if (! isset($group_id) || ! isset($project)) {
67     exit_no_group();
68 } else if (!($project->usesPlugin("wiki"))) {
69     exit_project_disabled('home');
70 } else {
71
72     global $robots;
73
74     $robots = "noindex,nofollow";
75
76     $group_name = $project->getUnixName();
77     $group_public_name = $project->getPublicName();
78
79     $is_external = method_exists($project, 'getIsExternal') && $project->getIsExternal();
80
81     $wc = new WikiConfig($group_id);
82
83     define('VIRTUAL_PATH', '/wiki/g/'.$group_name);
84     define('PAGE_PREFIX', '_g'.$group_id.'_');
85
86     // We have to use a smaller value than Phpwiki due to page prefix
87     define('MAX_PAGENAME_LENGTH', 92);
88
89     define('THEME', 'fusionforge');
90
91     // For FusionForge, we create some specific pages, located in the theme
92     // except for project "help"
93     if ($group_name == "help") {
94         define('WIKI_PGSRC', 'pgsrc');
95     } else {
96         define('WIKI_PGSRC', 'themes/fusionforge/pgsrc');
97     }
98
99     define('FUSIONFORGE', true);
100
101     define('PATH_INFO_PREFIX', '/'.$group_name . '/');
102     define('USE_PATH_INFO', true);
103
104     define('WIKI_NAME', $group_name);
105
106     define('DISABLE_MARKUP_WIKIWORD', $wc->getWikiConfig('DISABLE_MARKUP_WIKIWORD'));
107
108     define('NUM_SPAM_LINKS', 20 * ($wc->getWikiConfig('NUM_SPAM_LINKS')));
109
110     define('ENABLE_RATEIT', $wc->getWikiConfig('ENABLE_RATEIT'));
111
112     define('UPLOAD_FILE_PATH', '/opt/groups/'.WIKI_NAME.'/www/uploads/');
113     // define('UPLOAD_DATA_PATH', SERVER_URL . '/www/'.WIKI_NAME.'/uploads/');
114     if ($project->isPublic()) {
115         define('UPLOAD_DATA_PATH', '/www/'.WIKI_NAME.'/uploads/');
116     } else {
117         define('UPLOAD_DATA_PATH', '/wiki/view.php/'.WIKI_NAME.'/uploads/');
118     }
119
120     // Do not use a directory per user but only one (per project)
121     define('UPLOAD_USERDIR', false);
122
123     // Use black list of extensions instead of white list
124     define('DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS', true);
125
126     // Get the maximum upload filesize from PHP config
127     define('MAX_UPLOAD_SIZE', octets(ini_get('upload_max_filesize')));
128
129     // Disable access log (already in Apache & FusionForge).
130     define('ACCESS_LOG_SQL', 0);
131
132     define('DEBUG', (forge_get_config('installation_environment') != 'production'));
133
134     // Postgresql
135     define('DATABASE_TYPE', 'SQL');
136     // Dummy value (to avoid warning in SystemInfo plugin)
137     define('DATABASE_DSN', 'pgsql://localhost/user_phpwiki');
138
139     // Disable VACUUM (they are performed every night)
140     define('DATABASE_OPTIMISE_FREQUENCY', 0);
141
142     // TBD: the name should be taken from FusionForge
143     // define('ADMIN_USER', 'ACOS Forge Administrator');
144     define('ADMIN_USER', 'The PhpWiki programming team');
145     // Dummy value
146     define('ADMIN_PASSWD', 'xxx');
147
148     // Allow ".svg" and ".swf" as extensions
149     define('INLINE_IMAGES', 'png|jpg|jpeg|gif|svg|swf');
150
151     // Allow <div> and <span> in wiki code
152     define('ENABLE_MARKUP_DIVSPAN', true);
153
154     // Disable ENABLE_ACDROPDOWN, it creates a <style> in the <body> (illegal)
155     define('ENABLE_ACDROPDOWN', false);
156     define('ENABLE_AJAX', false);
157
158     define('TOOLBAR_PAGELINK_PULLDOWN', false);
159     define('TOOLBAR_TEMPLATE_PULLDOWN', false);
160     define('TOOLBAR_IMAGE_PULLDOWN', true);
161
162     // Enable external pages
163     define('ENABLE_EXTERNAL_PAGES', $is_external);
164
165     // Let all revisions be stored. Default since 1.3.11
166     define('MAJOR_MIN_KEEP', 2147483647);
167     define('MINOR_MIN_KEEP', 2147483647);
168     define('MAJOR_MAX_AGE', 2147483647);
169     define('MAJOR_KEEP', 2147483647);
170     define('MINOR_MAX_AGE', 2147483647);
171     define('MINOR_KEEP', 2147483647);
172     define('AUTHOR_MAX_AGE', 2147483647);
173     define('AUTHOR_KEEP', 2147483647);
174     define('AUTHOR_MIN_AGE', 2147483647);
175     define('AUTHOR_MAX_KEEP', 2147483647);
176
177     //
178     // Define access rights for the wiki.
179     //
180
181     // Do not allow anon users to edit pages
182     define('ALLOW_ANON_EDIT', false);
183
184     // Do not allow fake user
185     define('ALLOW_BOGO_LOGIN', false);
186
187     // A dedicated auth has been created to get auth from FusionForge
188     $USER_AUTH_ORDER = array("FusionForge");
189     define('USER_AUTH_ORDER', 'FusionForge');
190     define('USER_AUTH_POLICY', 'strict');
191
192     define('EXTERNAL_LINK_TARGET', '_top');
193
194     // Override the default configuration for CONSTANTS before index.php
195     $LC_ALL = language_name_to_locale_code(choose_language_from_context());
196     $LANG   = preg_replace('/_.*/', '', $LC_ALL);
197
198     // We use a local interwiki map file
199     define('INTERWIKI_MAP_FILE', 'themes/fusionforge/interwiki.map');
200
201     define('DEFAULT_WIKI_PAGES', "");
202
203     define('DBAUTH_AUTH_CHECK', "SELECT IF(passwd='\$password',1,0) as ok FROM plugin_wiki_pref WHERE userid='\$userid'");
204     define('DBAUTH_AUTH_USER_EXISTS', "SELECT userid FROM plugin_wiki_pref WHERE userid='\$userid'");
205     define('DBAUTH_AUTH_CREATE', "INSERT INTO plugin_wiki_pref (passwd,userid) VALUES ('\$password','\$userid')");
206     define('DBAUTH_PREF_SELECT', "SELECT prefs FROM plugin_wiki_pref WHERE userid='\$userid'");
207     define('DBAUTH_PREF_UPDATE', "UPDATE plugin_wiki_pref SET prefs='\$pref_blob' WHERE userid='\$userid'");
208     define('DBAUTH_PREF_INSERT', "INSERT INTO plugin_wiki_pref (prefs,userid) VALUES ('\$pref_blob','\$userid')");
209     define('DBAUTH_IS_MEMBER', "SELECT userid FROM plugin_wiki_pref WHERE userid='\$userid' AND groupname='\$groupname'");
210     define('DBAUTH_GROUP_MEMBERS', "SELECT userid FROM plugin_wiki_pref WHERE groupname='\$groupname'");
211     define('DBAUTH_USER_GROUPS', "SELECT groupname FROM plugin_wiki_pref WHERE userid='\$userid'");
212
213     define('USE_DB_SESSION', true);
214
215     define('USE_BYTEA', true);
216
217     define('ENABLE_REVERSE_DNS', false);
218
219     // Web DAV location
220     define('DEFAULT_DUMP_DIR', "/opt/groups/".$group_name."/wikidump/");
221     define('HTML_DUMP_DIR', "/opt/groups/".$group_name."/wikidumphtml/");
222
223     define('COMPRESS_OUTPUT', false);
224
225     define('CACHE_CONTROL', "NO_CACHE");
226
227     $lg = language_name_to_locale_code(forge_get_config('default_language'));
228     $lg = preg_replace('/_.*/', '', $lg);
229     define('DEFAULT_LANGUAGE', $lg);
230
231     define('DISABLE_GETIMAGESIZE', true);
232
233     // If the user is logged in, let the Wiki know
234     if (session_loggedin()) {
235         $user = session_get_user();
236         if ($user && is_object($user) && !$user->isError() && $user->isActive()) {
237             $user_name = $user->getRealName();
238             $_SESSION['user_id'] = $user_name;
239             $_SERVER['PHP_AUTH_USER'] = $user_name;
240         }
241     } else {
242         // clear out the globals, just in case...
243     }
244
245     // Load the default configuration.
246     require_once(dirname(__FILE__).'/lib/prepend.php');
247     require_once(dirname(__FILE__).'/lib/IniConfig.php');
248     IniConfig(dirname(__FILE__)."/config/config-default.ini");
249
250     // Override the default configuration for VARIABLES after index.php:
251     // E.g. Use another DB:
252     $DBParams['dbtype'] = 'SQL';
253     $DBParams['dsn']    = 'ffpgsql://' . forge_get_config('database_user') . ':' .
254         forge_get_config('database_password') . '@' . forge_get_config('database_host') .'/' . forge_get_config('database_name');
255
256     $DBParams['prefix'] = "plugin_wiki_";
257
258     // Start the wiki
259     include dirname(__FILE__).'/lib/main.php';
260 }
261
262 /**
263  * Return a number of octets from a string like "300M"
264  */
265 function octets($val) {
266     $val = trim($val);
267     $last = strtolower($val[strlen($val)-1]);
268     switch($last) {
269         // The 'G' modifier is available since PHP 5.1.0
270         case 'g':
271             $val *= 1024;
272         case 'm':
273             $val *= 1024;
274         case 'k':
275             $val *= 1024;
276     }
277     return $val;
278 }
279 ?>