Passed
Push — development ( 0a99ba...11bc13 )
by Mirco
06:42 queued 04:07
created

settings-sample-vagrant.inc.php ➔ post_config()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 57
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 2
nop 0
dl 0
loc 57
rs 9.6818
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
1 ignored issue
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 226 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/***************************************************************************
3
 *  Unicode Reminder メモ
4
 *
5
 *  Sample settincs.inc.php file for a developer machine
6
 ***************************************************************************/
7
8
// installation paths
9
$dev_basepath = '/var/www/html/';
10
$dev_codepath = '*';
11
$dev_baseurl = 'http://local.team-opencaching.de';
12
13
// enable HTTPS
14
if (defined('HTTPS_ENABLED')) {
15
    $opt['page']['https']['mode'] = HTTPS_ENABLED;
16
}
17
18
// show blog and forum news on index.php
19
$debug_startpage_news = false;
20
21
// common developer system settings
22
require __DIR__ . '/settings-dev.inc.php';
23
24
// database access
25
$opt['db']['servername'] = 'localhost';
26
$opt['db']['username'] = 'root';
27
$opt['db']['password'] = 'root';
28
$opt['db']['pconnect'] = false;
29
30
$opt['db']['maintenance_user'] = 'root';
31
$opt['db']['maintenance_password'] = 'root';
32
33
// database names
34
$opt['db']['placeholder']['db'] = 'opencaching';
35
$opt['db']['placeholder']['tmpdb'] = 'octmp';
36
37
$opt['charset']['mysql'] = 'utf8mb4';
38
39
// only for local.team-opencaching.de usage
40
$opt['lib']['w3w']['apikey'] = 'X27PDW41';
41
42
// activate debug for vagrant system
43
// $opt['debug'] = true;
44
45
/* cookie or session
46
 *
47
 * SAVE_COOKIE            = only use cookies
48
 * SAVE_SESSION           = use php sessions
49
 *
50
 * to use SESSIONS set php.ini to session default values:
51
 *
52
 * session.auto_start = 0
53
 * session.use_cookies = 1
54
 * session.use_only_cookies = 0
55
 * session.cookie_lifetime = 0
56
 * session.cookie_path = "/"
57
 * session.cookie_domain = ""
58
 * session.cookie_secure = off
59
 * session.use_trans_sid = 0
60
 *
61
 * other parameters may be customized
62
 */
63
$opt['session']['mode'] = SAVE_COOKIE;
64
$opt['session']['cookiename'] = 'ocvagrant'; // only with SAVE_COOKIE
65
$opt['session']['path'] = '/';
66
$opt['session']['domain'] = 'local.team-opencaching.de';    // may be overwritten by $opt['domain'][...]['cookiedomain']
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
67
68
/* If the Referer was sent by the client and the substring was not found,
69
 * the embedded session id will be marked as invalid.
70
 * Only used with session.mode = SAVE_SESSION
71
 */
72
$opt['session']['check_referer'] = true;
73
74
// see http://forum.opencaching.de/index.php?topic=3031.msg38795#msg38795
75
$opt['session']['login_statistics'] = false;
76
77
/* Default locale and style
78
         *
79
         */
80
$opt['template']['default']['locale'] = 'DE';
81
$opt['template']['default']['style'] = 'ocstyle';
82
$opt['locale']['DE']['page']['subtitle1'] = 'Geocaching mit Opencaching';
83
$opt['locale']['DE']['page']['subtitle2'] = '';
84
$opt['page']['title'] = 'OPENCACHING.de';
85
$opt['page']['headoverlay'] = 'oc_head_alpha3_generic';
86
$opt['page']['teampic_url'] = 'https://www.opencaching.de/images/team/';
87
// data license settings
88
$opt['logic']['license']['disclaimer'] = true;
89
90
$opt['page']['banned_user_agents'] = ['Netsparker'];
91
92
// admin extensions
93
$opt['logic']['adminreports']['cachexternal']['OC-Clean'] = '';
94
$opt['logic']['adminreports']['external_maintainer']['url'] = '';
95
$opt['logic']['adminreports']['external_maintainer']['msg'] = '';
96
97
// email problems API for OCC
98
$opt['logic']['api']['email_problems']['key'] = '';
99
100
$opt['page']['banned_user_agents'] = ['Netsparker'];
101
102
/* other template options
103
         *
104
         */
105
$opt['page']['name'] = 'Geocaching mit Opencaching';
106
$opt['page']['max_logins_per_hour'] = 250;
107
$opt['mail']['from'] = '[email protected]';
108
109
/* data license options
110
 */
111
$opt['logic']['license']['admin'] = false;
112
113
/* Sponsoring advertisements
114
 * (plain HTML)
115
 */
116
$opt['page']['sponsor']['topright'] = ''; // '<div class="site-slogan" style="background-image: url(resource2/ocstyle/images/darkbluetransparent.png);"><div style="width: 100%; text-align: left;"><p class="search"><a href="http://www.wanderjugend.de" target="_blank"><img border="0" align="right" style="margin-left: 10px;" src="resource2/ocstyle/images/dwj.gif" width="40px" height="20px" alt="... die outdoororientierte Jugendorganisation des Deutschen Wanderverbandes" /></a> Unterst&uuml;tzt und gef&ouml;rdert durch<br />die Deutsche Wanderjugend</p> </div></div>';
117
$opt['page']['sponsor']['bottom'] = 'Driven by the Opencaching Community';
118
$opt['page']['sponsor']['popup'] = ''; // '<table><tr><td width="265" style="text-align:right"><font size="1">Unterstützt und gef&ouml;rdert durch<br />die Deutsche Wanderjugend</font></td><td width="40"><img src="images/dwj.gif" border="0" alt="" align="left" /></td></tr></table>';
119
120
121
/* phpbb news integration (index.php)
122
 */
123
$opt['cron']['phpbbtopics']['url'] = 'http://forum.opencaching.de';
124
$opt['cron']['phpbbtopics']['forumids'] = [];
125
$opt['cron']['phpbbtopics']['name'] = 'forum.opencaching.de';
126
$opt['cron']['phpbbtopics']['link'] = 'http://forum.opencaching.de';
127
128
/* Well known node id's - required for synchronization
129
 * 1 Opencaching Deutschland (www.opencaching.de)
130
 * 2 Opencaching Polen (www.opencaching.pl)
131
 * 3 Opencaching Tschechien (www.opencaching.cz)
132
 * 4 Local Development
133
 * 5 Opencaching Entwicklung Deutschland (devel.opencaching.de)
134
 */
135
$opt['logic']['node']['id'] = 5;
136
137
/* pregenerated waypoint list for new caches
138
 * - Waypoint prefix (OC, OP, OZ ... AA=local development)
139
 * - When pool contains less than min_count, generation process starts
140
 *   and fills up the pool until max_count is reached.
141
 */
142
$opt['logic']['waypoint_pool']['prefix'] = 'OC';
143
$opt['logic']['waypoint_pool']['min_count'] = 1000;
144
$opt['logic']['waypoint_pool']['max_count'] = 2000;
145
// chars used for waypoints. Remember to reinstall triggers and clear cache_waypoint_pool after changing
146
$opt['logic']['waypoint_pool']['valid_chars'] = '0123456789ABCDEF';
147
// fill_gaps = true: search for gaps between used waypoints and fill up these gaps
148
//                   (fill_gaps is slow and CPU intensive on database server. For
149
//                    productive servers you may want to generate some waypoints
150
//                    without fill_gaps first)
151
// fill_gaps = false: continue with the last waypoint
152
$opt['logic']['waypoint_pool']['fill_gaps'] = false;
153
154
/* cracklib-check for users passwords enabled?
155
 * (requires php extension crack_check)
156
 */
157
$opt['logic']['cracklib'] = false;
158
159
/* News configuration
160
         *
161
         * filename to the include file containing the newscontent
162
         * (RSS format)
163
         * if no filename is given, the own news-code is used
164
         * (table news and newstopic.php)
165
         *
166
         * you have to correct entries in table sys_menu and
167
         * lang/de/stdtyle/lib/menu.php respectivly
168
         */
169
$opt['news']['include'] = 'http://blog.opencaching.de/feed/';
170
$opt['news']['count'] = 8;
171
$opt['news']['timeout'] = 10;
172
173
/* current forum topcis on start page
174
 * requires url to be a vaild rss feed
175
 * -> show the number of 'count' topics from rss feed
176
 */
177
$opt['forum']['url'] = 'http://forum.opencaching.de/index.php?action=.xml;type=rss;limit=50';
178
$opt['forum']['count'] = 10;
179
$opt['forum']['timeout'] = 10;
180
181
/* Wiki news on the 404 page
182
 */
183
$opt['wikinews']['timeout'] = 10;
184
185
// redirect news.php to the following url
186
$opt['news']['redirect'] = 'http://blog.opencaching.de';
187
188
$opt['page']['showdonations'] = true;
189
$opt['page']['showsocialmedia'] = true;
190
191
192
/*
193
         * configure infos on 404.php
194
         */
195
$opt['page']['404']['test.opencaching.de'] = [
196
    'blog' => [
197
        'show' => true,
198
        'feedurl' => $opt['news']['include'],
199
        'url' => $opt['news']['redirect'],
200
    ],
201
    'forum' => [
202
        'show' => true,
203
        'feedurl' => $opt['forum']['url'],
204
        'url' => 'http://forum.opencaching.de',
205
    ],
206
    'wiki' => [
207
        'show' => true,
208
        'feedurl' => 'http://wiki.opencaching.de/index.php/Spezial:Neue_Seiten?feed=rss',
209
        'url' => 'http://wiki.opencaching.de',
210
    ],
211
    'newcaches' => [
212
        'show' => true,
213
        'url' => 'http://test.opencaching.de',
214
    ],
215
];
216
217
218
/* domain specific configuration
219
 * will be loaded when all standard include files are processed
220
 * (db-connection exists, menu is loaded, user login validated etc.)
221
 * Take caution on caching issues (!)
222
 */
223
224
$opt['map']['towns']['enable'] = true;  // for releasing v14
225
226
define('MNU_INFO', 1015);
227
define('MNU_TEAMBLOG', 1016);
228
define('MNU_FORUM', 1017);
229
define('MNU_CHAT', 1018);
230
define('MNU_GEOKRETY', 1019);
231
define('MNU_API', 1020);
232
233
function post_config()
0 ignored issues
show
Coding Style introduced by
post_config uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
234
{
235
    global $opt, $menuitem, $tpl, $translate;
236
237
    $domain = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
238
    if ($domain == '') {
239
        return;
240
    }
241
242
    $menuitem[MNU_INFO] = [
243
        'title' => $translate->t('Help', '', '', ''),
244
        'menustring' => $translate->t('Help', '', '', ''),
245
        'authlevel' => 0,
246
        'href' => 'http://' . $domain . '/articles.php?page=helpindex&wiki',
247
        'visible' => 1,
248
        'sublevel' => 1
249
    ];
250
    $menuitem[0]['subitems'][] = MNU_INFO;
251
252
    config_domain_test_opencaching_de();
253
254
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
255
        $menuitem[MNU_CHAT] = array('title' => 'Chat/IRC',
256
                                    'menustring' => 'Chat/IRC',
257
                                    'authlevel' => 0,
258
                                    'href' => 'webchat.php',
259
                                    'visible' => 1,
260
                                    'sublevel' => 1
261
                                   );
262
        $menuitem[0]['subitems'][] = MNU_CHAT;
263
    */
264
265
    // geokrety menu contains the language
266
    $menuitem[MNU_GEOKRETY] = [
267
        'title' => 'Geokrety',
268
        'menustring' => 'Geokrety',
269
        'authlevel' => 0,
270
        'href' => 'http://www.geokrety.org/index.php?lang=' . urlencode(
271
                $opt['geokrety']['locales'][$opt['template']['locale']]
272
            ),
273
        'target' => 'target="_blank"',
274
        'visible' => 1,
275
        'sublevel' => 1
276
    ];
277
    $menuitem[0]['subitems'][] = MNU_GEOKRETY;
278
279
    $menuitem[MNU_API] = [
280
        'title' => 'API',
281
        'menustring' => 'API',
282
        'authlevel' => 0,
283
        'href' => 'http://local.team-opencaching.de/okapi',
284
        # OKAPI does not support https yet
285
        'visible' => 1,
286
        'sublevel' => 1
287
    ];
288
    $menuitem[0]['subitems'][] = MNU_API;
289
}
290
291
function config_domain_test_opencaching_de()
292
{
293
    global $opt, $menuitem, $login, $translate;
294
295
    $opt['page']['headoverlay'] = 'oc_head_alpha3';
296
    $opt['cms']['login'] = 'http://wiki.opencaching.de/index.php/Login';
297
298
    /* add additional main menu links
299
     */
300
    $menuitem[MNU_TEAMBLOG] = [
301
        'title' => 'Teamblog',
302
        'menustring' => 'Teamblog',
303
        'authlevel' => 0,
304
        'href' => 'http://blog.opencaching.de/',
305
        'visible' => 1,
306
        'sublevel' => 1
307
    ];
308
    $menuitem[MNU_FORUM] = [
309
        'title' => 'Forum',
310
        'menustring' => 'Forum',
311
        'authlevel' => 0,
312
        'href' => 'http://forum.opencaching.de',
313
        'visible' => 1,
314
        'sublevel' => 1
315
    ];
316
    $menuitem[0]['subitems'][] = MNU_TEAMBLOG;
317
    $menuitem[0]['subitems'][] = MNU_FORUM;
318
}
319