1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
<?php
/*
Copyright (c) 2001 - 2005 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*!
@header INIT file
Take care of our init grunt work so we don't scatter paths
all over the place.
*/
// Set the Error level manualy... I'm to lazy to fix notices
error_reporting(E_ALL ^ E_NOTICE);
// This makes this file nolonger need customization
// the config file is in the same dir as this (init.php) file.
$ampache_path = dirname(__FILE__);
$prefix = realpath($ampache_path . "/../");
$configfile = "$prefix/config/ampache.cfg.php";
require_once($prefix . "/lib/general.lib.php");
/*********************STOP EDITING*********************************/
/*
Check to see if this is Http or https
*/
if ($_SERVER['HTTPS'] == 'on') {
$http_type = "https://";
}
else {
$http_type = "http://";
}
/*
See if the Config File Exists if it doesn't
then go ahead and move them over to the install
script
*/
if (!file_exists($configfile)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/install.php";
header ("Location: $link");
exit();
}
/*
Try to read the config file, if it fails give them
an explanation
*/
if (!$results = read_config($configfile,0)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php";
header ("Location: $link");
exit();
}
// Cheat a little to setup the extra vars needed by libglue
//FIXME: Untile we have a config updater force stream as allowed playback method
if (!$results['conf']['allow_stream_playback']) {
$results['conf']['allow_stream_playback'] = "true";
}
$results['conf']['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['conf']['web_path'];
$results['conf']['version'] = '3.3.2-Alpha4 (Build 005)';
$results['conf']['catalog_file_pattern']= 'mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx';
$results['libglue']['local_table'] = 'session';
$results['libglue']['local_sid'] = 'id';
$results['libglue']['local_expirecol'] = 'expire';
$results['libglue']['local_usercol'] = 'username';
$results['libglue']['local_typecol'] = 'type';
$results['libglue']['local_datacol'] = 'value';
$results['libglue']['mysql_table'] = 'user';
$results['libglue']['mysql_usercol'] = 'username';
$results['libglue']['mysql_passwdcol'] = 'password';
$results['libglue']['local_dbh_name'] = 'local_dbh';
$results['libglue']['auth_methods'] = 'mysql';
$results['libglue']['user_username'] = 'username';
$results['libglue']['mysql_fields'] = 'username,fullname,email,access,offset_limit';
$results['libglue']['mysql_host'] = $results['libglue']['local_host'];
$results['libglue']['mysql_db'] = $results['libglue']['local_db'];
$results['libglue']['mysql_username'] = $results['libglue']['local_username'];
$results['libglue']['mysql_user'] = $results['libglue']['local_username'];
$results['libglue']['mysql_passwd'] = $results['libglue']['local_pass'];
$results['libglue']['mysql_pass'] = $results['libglue']['local_pass'];
$results['libglue']['mysql_passcol'] = 'password';
$results['libglue']['dbh'] = $results['libglue']['local_dbh_name'];
$results['libglue']['auth_page'] = $results['conf']['web_path'];
$results['libglue']['login_page'] = $results['conf']['web_path'] . "/login.php";
$results['conf']['http_port'] = $_SERVER['SERVER_PORT'];
if (!$results['conf']['prefix']) {
$results['conf']['prefix'] = $prefix;
}
if (!$results['libglue']['stop_auth']) {
$results['libglue']['stop_auth'] = $results['conf']['prefix'] . "/modules/libglue/gone.fishing";
}
if (!$results['libglue']['libglue_path']) {
$results['libglue']['libglue_path']= $results['conf']['prefix'] . "/modules/libglue";
}
if (!$results['conf']['http_port']) {
$results['conf']['http_port'] = '80';
}
if (!$results['conf']['site_charset']) {
$results['conf']['site_charset'] = "iso-8859-1";
}
if (!$results['conf']['log_path']) {
$results['conf']['log_path'] = '/tmp';
}
if (!$results['conf']['ellipse_threshold_album']) {
$results['conf']['ellipse_threshold_album'] = 27;
}
if (!$results['conf']['ellipse_threshold_artist']) {
$results['conf']['ellipse_threshold_artist'] = 27;
}
if (!$results['conf']['ellipse_threshold_title']) {
$results['conf']['ellipse_threshold_title'] = 27;
}
/* Temp Fixes */
$results['conf'] = fix_preferences($results['conf']);
// Setup Static Arrays
libglue_param($results['libglue']);
conf($results['conf']);
// Libglue Requires
require_once(libglue_param('libglue_path') . "/auth.php");
require_once(libglue_param('libglue_path') . "/session.php");
require_once(libglue_param('libglue_path') . "/dbh.php");
// Librarys
require_once(conf('prefix') . "/lib/album.lib.php");
require_once(conf('prefix') . "/lib/artist.lib.php");
require_once(conf('prefix') . "/lib/song.php");
require_once(conf('prefix') . "/lib/search.php");
require_once(conf('prefix') . "/lib/preferences.php");
require_once(conf('prefix') . "/lib/rss.php");
require_once(conf('prefix') . "/lib/log.lib.php");
require_once(conf('prefix') . "/lib/mpd.php");
require_once(conf('prefix') . "/lib/ui.lib.php");
require_once(conf('prefix') . "/lib/gettext.php");
require_once(conf('prefix') . "/lib/batch.lib.php");
require_once(conf('prefix') . "/lib/themes.php");
require_once(conf('prefix') . "/lib/stream.lib.php");
require_once(conf('prefix') . "/modules/lib.php");
require_once(conf('prefix') . "/modules/admin.php");
require_once(conf('prefix') . "/modules/catalog.php");
require_once(conf('prefix') . "/lib/upload.php");
// Modules (These are conditionaly included depending upon config values)
require_once(conf('prefix') . "/modules/id3/audioinfo.class.php");
require_once(conf('prefix') . "/modules/amazon/Snoopy.class.php");
require_once(conf('prefix') . "/modules/amazon/AmazonSearchEngine.class.php");
require_once(conf('prefix') . "/lib/xmlrpc.php");
require_once(conf('prefix') . "/modules/xmlrpc/xmlrpc.inc");
if (conf('allow_slim_playback')) {
require_once(conf('prefix') . "/modules/slimserver/slim.class.php");
}
if (conf('allow_mpd_playback')) {
require_once(conf('prefix') . "/modules/mpd/mpd.class.php");
}
if (conf('allow_xmms2_playback')) {
require_once(conf('prefix') . "/modules/xmms2/xmms2.class.php");
}
if (conf('ratings')) {
require_once(conf('prefix') . '/lib/class/rating.class.php');
require_once(conf('prefix') . '/lib/rating.lib.php');
}
// Classes
require_once(conf('prefix') . "/lib/class/catalog.class.php");
require_once(conf('prefix') . "/lib/class/stream.class.php");
require_once(conf('prefix') . "/lib/class/playlist.class.php");
require_once(conf('prefix') . "/lib/class/song.class.php");
require_once(conf('prefix') . "/lib/class/view.class.php");
require_once(conf('prefix') . "/lib/class/update.class.php");
require_once(conf('prefix') . "/lib/class/user.class.php");
require_once(conf('prefix') . "/lib/class/album.class.php");
require_once(conf('prefix') . "/lib/class/artist.class.php");
require_once(conf('prefix') . "/lib/class/access.class.php");
require_once(conf('prefix') . "/lib/class/error.class.php");
require_once(conf('prefix') . "/lib/class/genre.class.php");
/* Some Libglue Hacks */
$array['dbh_name'] = 'stupid_pos';
$array['stupid_pos'] = check_sess_db('local');
libglue_param($array);
/* End Libglue Hacks */
/* Set a new Error Handler */
$old_error_handler = set_error_handler("ampache_error_handler");
/* Check their PHP Vars to make sure we're cool here */
if ($results['conf']['memory_limit'] < 16) {
$results['conf']['memory_limit'] = 16;
}
set_memory_limit($results['conf']['memory_limit']);
if (ini_get('short_open_tag') != "On") {
ini_set (short_open_tag, "On");
}
// Check Session GC mojo, increase if need be
$gc_probability = @ini_get('session.gc_probability');
$gc_divisor = @ini_get('session.gc_divisor');
if (!$gc_divisor) {
$gc_divisor = '100';
}
if (!$gc_probability) {
$gc_probability = '1';
}
// Force GC on 1:5 page loads
if (($gc_divisor / $gc_probability) > 5) {
$new_gc_probability = $gc_divisor * .2;
ini_set('session.gc_probability',$new_gc_probability);
}
/* END Set PHP Vars */
/* Overwrite them with the DB preferences */
set_site_preferences();
/* Seed the random number */
srand((double) microtime() * 1000003);
// If we don't want a session
if (!isset($no_session) AND conf('use_auth')) {
if (!check_session()) { logout(); exit(); }
init_preferences();
set_theme();
$user = new User($_SESSION['userdata']['username']);
$user->set_preferences();
$user->update_last_seen();
}
if (!conf('use_auth')) {
$auth['success'] = 1;
$auth['info']['username'] = '-1';
$auth['info']['fullname'] = "Ampache User";
$auth['info']['id'] = -1;
$auth['info']['access'] = "admin";
$auth['info']['offset_limit'] = 50;
if (!check_session()) { make_local_session_only($auth); }
$user = new User(-1);
$user->fullname = $auth['info']['fullname'];
$user->offset_limit = $auth['info']['offset_limit'];
$user->username = $auth['info']['username'];
$user->access = $auth['info']['access'];
$_SESSION['userdata']['access'] = $auth['info']['access'];
$_SESSION['userdata']['username'] = $auth['info']['username'];
$_SESSION['userdata']['offset_limit'] = $auth['info']['offset_limit'];
$user->set_preferences();
init_preferences();
set_theme();
}
// Load gettext mojo
load_gettext();
/* Set CHARSET */
header ("Content-Type: text/html; charset=" . conf('site_charset'));
/* Clean up a bit */
unset($array);
unset($results);
/* Setup the flip class */
flip_class(array('odd','even'));
/* Setup the Error Class */
$error = new Error();
$theme = get_theme(conf('theme_name'));
if (! preg_match('/update\.php/', $_SERVER['PHP_SELF'])) {
$update = new Update();
if ($update->need_update()) {
header("Location: " . conf('web_path') . "/update.php");
exit();
}
}
unset($update);
?>
|