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