source: trunk/install/index.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 48.4 KB
Line 
1<?php
2
3/***************************************************************************
4* Dolphin Smart Community Builder
5* -----------------
6* begin : Mon Mar 23 2006
7* copyright : (C) 2006 BoonEx Group
8* website : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21define('CHECK_DOLPHIN_REQUIREMENTS', 1); //Don`t recommend to skip this step
22if (defined('CHECK_DOLPHIN_REQUIREMENTS')) {
23 //check requirements
24 $aErrors = array();
25
26 $aErrors[] = (ini_get('register_globals') == 0) ? '' : '<font color="red">register_globals is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
27 $aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<font color="red">safe_mode is On, disable it</font>';
28 //$aErrors[] = (ini_get('allow_url_fopen') == 0) ? 'Off (warning, better keep this parameter in On to able register Dolphin' : '';
29 $aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? '<font color="red">PHP version too old, please update to PHP 5.2.0 at least</font>' : '';
30 $aErrors[] = (! extension_loaded( 'mbstring')) ? '<font color="red">mbstring extension not installed. <b>Warning!</b> Dolphin cannot work without <b>mbstring</b> extension.</font>' : '';
31 // $aErrors[] = (! function_exists('shell_exec')) ? '<font color="red">shell_exec function is unvailable. <b>Warning!</b> Dolphin cannot work without <b>shell_exec</b> function.</font>' : '';
32 $aErrors[] = (ini_get('short_open_tag') == 0) ? '<font color="red">short_open_tag is Off (must be On!)<b>Warning!</b> Dolphin cannot work without <b>short_open_tag</b>.</font>' : '';
33
34 if (version_compare(phpversion(), "5.2", ">") == 1) {
35 $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<font color="red">allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
36 };
37
38 $aErrors = array_diff($aErrors, array('')); //delete empty
39 if (count($aErrors)) {
40 $sErrors = implode(" <br /> ", $aErrors);
41 echo <<<EOF
42{$sErrors} <br />
43Please go to the <br />
44<a href="http://www.boonex.com/trac/dolphin/wiki/GenDolTShooter">Dolphin Troubleshooter</a> <br />
45and solve the problem.
46EOF;
47 exit;
48 }
49}
50
51if (version_compare(phpversion(), "5.3.0", ">=") == 1)
52 error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
53else
54 error_reporting(E_ALL & ~E_NOTICE);
55set_magic_quotes_runtime(0);
56ini_set('magic_quotes_sybase', 0);
57
58/*------------------------------*/
59/*----------Vars----------------*/
60 $aConf = array();
61 $aConf['release'] = '25.12.09';
62 $aConf['iVersion'] = '7.0';
63 $aConf['iPatch'] = '0';
64 $aConf['dolFile'] = '../inc/header.inc.php';
65 $aConf['confDir'] = '../inc/';
66 $aConf['headerTempl'] = <<<EOS
67<?
68
69/***************************************************************************
70* Dolphin Smart Community Builder
71* -----------------
72* begin : Mon Mar 23 2006
73* copyright : (C) 2006 BoonEx Group
74* website : http://www.boonex.com/
75* This file is part of Dolphin - Smart Community Builder
76*
77* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
78* http://creativecommons.org/licenses/by/3.0/
79*
80* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
81* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
82* See the Creative Commons Attribution 3.0 License for more details.
83* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
84* see license.txt file; if not, write to marketing@boonex.com
85***************************************************************************/
86
87\$site['ver'] = '{$aConf['iVersion']}';
88\$site['build'] = '{$aConf['iPatch']}';
89\$site['url'] = "%site_url%";
90\$admin_dir = "administration";
91\$iAdminPage = 0;
92\$site['url_admin'] = "{\$site['url']}\$admin_dir/";
93
94\$site['mediaImages'] = "{\$site['url']}media/images/";
95\$site['gallery'] = "{\$site['url']}media/images/gallery/";
96\$site['flags'] = "{\$site['url']}media/images/flags/";
97\$site['banners'] = "{\$site['url']}media/images/banners/";
98\$site['imagesPromo'] = "{\$site['url']}media/images/promo/";
99\$site['tmp'] = "{\$site['url']}tmp/";
100\$site['plugins'] = "{\$site['url']}plugins/";
101\$site['base'] = "{\$site['url']}templates/base/";
102
103\$site['bugReportMail'] = "%bug_report_email%";
104
105\$dir['root'] = "%dir_root%";
106\$dir['inc'] = "{\$dir['root']}inc/";
107\$dir['profileImage'] = "{\$dir['root']}media/images/profile/";
108
109\$dir['mediaImages'] = "{\$dir['root']}media/images/";
110\$dir['gallery'] = "{\$dir['root']}media/images/gallery/";
111\$dir['flags'] = "{\$dir['root']}media/images/flags/";
112\$dir['banners'] = "{\$dir['root']}media/images/banners/";
113\$dir['imagesPromo'] = "{\$dir['root']}media/images/promo/";
114\$dir['tmp'] = "{\$dir['root']}tmp/";
115\$dir['cache'] = "{\$dir['root']}cache/";
116\$dir['plugins'] = "{\$dir['root']}plugins/";
117\$dir['base'] = "{\$dir['root']}templates/base/";
118\$dir['classes'] = "{\$dir['inc']}classes/";
119
120\$video_ext = 'avi';
121\$MOGRIFY = "%dir_mogrify%";
122\$CONVERT = "%dir_convert%";
123\$COMPOSITE = "%dir_composite%";
124\$PHPBIN = "%dir_php%";
125
126\$db['host'] = '%db_host%';
127\$db['sock'] = '%db_sock%';
128\$db['port'] = '%db_port%';
129\$db['user'] = '%db_user%';
130\$db['passwd'] = '%db_password%';
131\$db['db'] = '%db_name%';
132
133define('BX_DOL_URL_ROOT', \$site['url']);
134define('BX_DOL_URL_ADMIN', \$site['url_admin']);
135define('BX_DOL_URL_PLUGINS', \$site['plugins']);
136define('BX_DOL_URL_MODULES', \$site['url'] . 'modules/' );
137define('BX_DOL_URL_CACHE_PUBLIC', \$site['url'] . 'cache_public/');
138
139define('BX_DIRECTORY_PATH_INC', \$dir['inc']);
140define('BX_DIRECTORY_PATH_ROOT', \$dir['root']);
141define('BX_DIRECTORY_PATH_BASE', \$dir['base']);
142define('BX_DIRECTORY_PATH_CACHE', \$dir['cache']);
143define('BX_DIRECTORY_PATH_CLASSES', \$dir['classes']);
144define('BX_DIRECTORY_PATH_PLUGINS', \$dir['plugins']);
145define('BX_DIRECTORY_PATH_DBCACHE', \$dir['cache']);
146define('BX_DIRECTORY_PATH_MODULES', \$dir['root'] . 'modules/' );
147define('BX_DIRECTORY_PATH_CACHE_PUBLIC', \$dir['root'] . 'cache_public/' );
148
149define('DATABASE_HOST', \$db['host']);
150define('DATABASE_SOCK', \$db['sock']);
151define('DATABASE_PORT', \$db['port']);
152define('DATABASE_USER', \$db['user']);
153define('DATABASE_PASS', \$db['passwd']);
154define('DATABASE_NAME', \$db['db']);
155
156
157define('CHECK_DOLPHIN_REQUIREMENTS', 1);
158if (defined('CHECK_DOLPHIN_REQUIREMENTS')) {
159 //check requirements
160 \$aErrors = array();
161
162 \$aErrors[] = (ini_get('register_globals') == 0) ? '' : '<font color="red">register_globals is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
163 \$aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<font color="red">safe_mode is On, disable it</font>';
164 //\$aErrors[] = (ini_get('allow_url_fopen') == 0) ? 'Off (warning, better keep this parameter in On to able register Dolphin' : '';
165 \$aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? '<font color="red">PHP version too old, please update to PHP 5.2.0 at least</font>' : '';
166 \$aErrors[] = (! extension_loaded( 'mbstring')) ? '<font color="red">mbstring extension not installed. <b>Warning!</b> Dolphin cannot work without <b>mbstring</b> extension.</font>' : '';
167
168 if (version_compare(phpversion(), "5.2", ">") == 1) {
169 \$aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<font color="red">allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
170 };
171
172 \$aErrors = array_diff(\$aErrors, array('')); //delete empty
173 if (count(\$aErrors)) {
174 \$sErrors = implode(" <br /> ", \$aErrors);
175 echo <<<EOF
176{\$sErrors} <br />
177Please go to the <br />
178<a href="http://www.boonex.com/trac/dolphin/wiki/GenDolTShooter">Dolphin Troubleshooter</a> <br />
179and solve the problem.
180EOF;
181 exit;
182 }
183}
184
185//check correct hostname
186\$aUrl = parse_url( \$site['url'] );
187if( isset(\$_SERVER['HTTP_HOST']) and 0 != strcasecmp(\$_SERVER['HTTP_HOST'], \$aUrl['host']) and 0 != strcasecmp(\$_SERVER['HTTP_HOST'], \$aUrl['host'] . ':80') )
188{
189 header( "Location:http://{\$aUrl['host']}{\$_SERVER['REQUEST_URI']}" );
190 exit;
191}
192
193// check if install folder exists
194if ( !defined ('BX_SKIP_INSTALL_CHECK') && file_exists( \$dir['root'] . 'install' ) )
195{
196 \$ret = <<<EOJ
197<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
198 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
199 <head>
200 <title>Dolphin Smart Community Builder Installed</title>
201 <link href="install/general.css" rel="stylesheet" type="text/css" />
202 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
203 </head>
204 <body>
205 <div id="main">
206 <div id="header">
207 <img src="install/images/boonex-logo.png" alt="" /></div>
208 <div id="content">
209 <div class="installed_pic">
210 <img alt="Dolphin Installed" src="install/images/dolphin_installed.jpg" />
211 </div>
212
213 <div class="installed_text">
214 Please, remove INSTALL directory from your server and reload this page to activate your community site.
215 </div>
216 <div class="installed_text">
217 NOTE: Once you remove this page you can safely <a href="administration/modules.php">install modules via Admin Panel</a>.
218 </div>
219 </body>
220 </html>
221EOJ;
222 echo \$ret;
223 exit();
224}
225
226// set error reporting level
227if (version_compare(phpversion(), "5.3.0", ">=") == 1)
228 error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
229else
230 error_reporting(E_ALL & ~E_NOTICE);
231set_magic_quotes_runtime(0);
232ini_set('magic_quotes_sybase', 0);
233
234// set default encoding for multibyte functions
235mb_internal_encoding('UTF-8');
236mb_regex_encoding('UTF-8');
237
238require_once(BX_DIRECTORY_PATH_INC . "security.inc.php");
239require_once(BX_DIRECTORY_PATH_ROOT . "flash/modules/global/inc/header.inc.php");
240require_once(BX_DIRECTORY_PATH_ROOT . "flash/modules/global/inc/content.inc.php");
241require_once(BX_DIRECTORY_PATH_CLASSES . "BxDolService.php");
242require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php');
243\$oZ = new BxDolAlerts('system', 'begin', 0);
244\$oZ->alert();
245?>
246EOS;
247
248 $aConf['periodicTempl'] = <<<EOS
249MAILTO=%site_email%<br />
250* * * * * cd %dir_root%periodic; %dir_php% -q cron.php<br />
251EOS;
252
253 $confFirst = array();
254 $confFirst['site_url'] = array(
255 name => "Site URL",
256 ex => "http://www.mydomain.com/path/",
257 desc => "Your site URL here (backslash at the end required)",
258 def => "http://",
259 def_exp => '
260 $str = "http://".$_SERVER[\'HTTP_HOST\'].$_SERVER[\'PHP_SELF\'];
261 return preg_replace("/install\/(index\.php$)/","",$str);',
262 check => 'return strlen($arg0) >= 10 ? true : false;'
263 );
264 $confFirst['dir_root'] = array(
265 name => "Directory root",
266 ex => "/path/to/your/script/files/",
267 desc => "Path to directory where your php script files stored.",
268 def_exp => '
269 $str = rtrim($_SERVER[\'DOCUMENT_ROOT\'], \'/\').$_SERVER[\'PHP_SELF\'];
270 return preg_replace("/install\/(index\.php$)/","",$str);',
271 check => 'return strlen($arg0) >= 1 ? true : false;'
272 );
273 $confFirst['dir_php'] = array(
274 name => "Path to php binary",
275 ex => "/usr/local/bin/php",
276 desc => "You should specify full path to your PHP interpreter here.",
277 def => "/usr/local/bin/php",
278 def_exp => "
279 if ( file_exists(\"/usr/local/bin/php\") ) return \"/usr/local/bin/php\";
280 \$fp = popen ( \"whereis php\", \"r\");
281 if ( \$fp )
282 {
283 \$s = fgets(\$fp);
284 \$s = sscanf(\$s, \"php: %s\");
285 if ( file_exists(\"\$s[0]\") ) return \"\$s[0]\";
286 }
287 return '';",
288 check => 'return strlen($arg0) >= 7 ? true : false;'
289 );
290 $confFirst['dir_mogrify'] = array(
291 name => "Path to mogrify",
292 ex => "/usr/local/bin/mogrify",
293 desc => "If mogrify binary doesn't exist please install <a href='http://www.imagemagick.org/'>ImageMagick</a>",
294 def => "/usr/local/bin/mogrify",
295 def_exp => "
296 if ( file_exists(\"/usr/X11R6/bin/mogrify\") ) return \"/usr/X11R6/bin/mogrify\";
297 if ( file_exists(\"/usr/local/bin/mogrify\") ) return \"/usr/local/bin/mogrify\";
298 if ( file_exists(\"/usr/bin/mogrify\") ) return \"/usr/bin/mogrify\";
299 if ( file_exists(\"/usr/local/X11R6/bin/mogrify\") ) return \"/usr/local/X11R6/bin/mogrify\";
300 if ( file_exists(\"/usr/bin/X11/mogrify\") ) return \"/usr/bin/X11/mogrify\";
301 return '';",
302 check => 'return strlen($arg0) >= 7 ? true : false;'
303 );
304 $confFirst['dir_convert'] = array(
305 name => "Path to convert",
306 ex => "/usr/local/bin/convert",
307 desc => "If convert binary doesn't exist please install <a href='http://www.imagemagick.org/'>ImageMagick</a>",
308 def => "/usr/local/bin/convert",
309 def_exp => "
310 if ( file_exists(\"/usr/X11R6/bin/convert\") ) return \"/usr/X11R6/bin/convert\";
311 if ( file_exists(\"/usr/local/bin/convert\") ) return \"/usr/local/bin/convert\";
312 if ( file_exists(\"/usr/bin/convert\") ) return \"/usr/bin/convert\";
313 if ( file_exists(\"/usr/local/X11R6/bin/convert\") ) return \"/usr/local/X11R6/bin/convert\";
314 if ( file_exists(\"/usr/bin/X11/convert\") ) return \"/usr/bin/X11/convert\";
315 return '';",
316 check => 'return strlen($arg0) >= 7 ? true : false;'
317 );
318 $confFirst['dir_composite'] = array(
319 name => "Path to composite",
320 ex => "/usr/local/bin/composite",
321 desc => "If composite binary doesn't exist please install <a href='http://www.imagemagick.org/'>ImageMagick</a>",
322 def => "/usr/local/bin/composite",
323 def_exp => "
324 if ( file_exists(\"/usr/X11R6/bin/composite\") ) return \"/usr/X11R6/bin/composite\";
325 if ( file_exists(\"/usr/local/bin/composite\") ) return \"/usr/local/bin/composite\";
326 if ( file_exists(\"/usr/bin/composite\") ) return \"/usr/bin/composite\";
327 if ( file_exists(\"/usr/local/X11R6/bin/composite\") ) return \"/usr/local/X11R6/bin/composite\";
328 if ( file_exists(\"/usr/bin/X11/composite\") ) return \"/usr/bin/X11/composite\";
329 return '';",
330 check => 'return strlen($arg0) >= 7 ? true : false;'
331 );
332
333 $aDbConf = array();
334 $aDbConf['sql_file'] = array(
335 name => "SQL file",
336 ex => "/home/dolphin/public_html/install/sql/vXX.sql",
337 desc => "SQL file location",
338 def => "./sql/vXX.sql",
339 def_exp => '
340 if ( !( $dir = opendir( "sql/" ) ) )
341 return "";
342 while (false !== ($file = readdir($dir)))
343 {
344 if ( substr($file,-3) != \'sql\' ) continue;
345 closedir( $dir );
346 return "./sql/$file";
347 }
348 closedir( $dir );
349 return "";',
350 check => 'return strlen($arg0) >= 4 ? true : false;'
351 );
352 $aDbConf['db_host'] = array(
353 name => "Database host name",
354 ex => "localhost",
355 desc => "Your MySQL database host name here.",
356 def => "localhost",
357 check => 'return strlen($arg0) >= 1 ? true : false;'
358 );
359 $aDbConf['db_port'] = array(
360 name => "Database host port number",
361 ex => "5506",
362 desc => "Leave blank or specify MySQL Database host port number.",
363 def => "",
364 check => ''
365 );
366 $aDbConf['db_sock'] = array(
367 name => "Database socket path",
368 ex => "/tmp/mysql50.sock",
369 desc => "Leave blank or specify MySQL Database socket path.",
370 def => "",
371 check => ''
372 );
373 $aDbConf['db_name'] = array(
374 name => "Database name",
375 ex => "YourDatabaseName",
376 desc => "Your MySQL database name here.",
377 check => 'return strlen($arg0) >= 1 ? true : false;'
378 );
379 $aDbConf['db_user'] = array(
380 name => "Database user",
381 ex => "YourName",
382 desc => "Your MySQL database read/write user name here.",
383 check => 'return strlen($arg0) >= 1 ? true : false;'
384 );
385 $aDbConf['db_password'] = array(
386 name => "Database password",
387 ex => "YourPassword",
388 desc => "Your MySQL database password here.",
389 check => 'return strlen($arg0) >= 0 ? true : false;'
390 );
391
392 $aGeneral = array();
393 $aGeneral['site_title'] = array(
394 name => "Site Title",
395 ex => "The Best Community",
396 desc => "The name of your site",
397 check => 'return strlen($arg0) >= 1 ? true : false;'
398 );
399 $aGeneral['site_desc'] = array(
400 name => "Site Description",
401 ex => "The place to find new friends, communicate and have fun.",
402 desc => "Meta description of your site",
403 check => 'return strlen($arg0) >= 1 ? true : false;'
404 );
405 $aGeneral['site_email'] = array(
406 name => "Site e-mail",
407 ex => "your@email.here",
408 desc => "Your site e-mail.",
409 check => 'return strlen($arg0) > 0 AND strstr($arg0,"@") ? true : false;'
410 );
411 $aGeneral['notify_email'] = array(
412 name => "Notify e-mail",
413 ex => "your@email.here",
414 desc => "Envelope \"From:\" address for notification messages",
415 check => 'return strlen($arg0) > 0 AND strstr($arg0,"@") ? true : false;'
416 );
417 $aGeneral['bug_report_email'] = array(
418 name => "Bug report email",
419 ex => "your@email.here",
420 desc => "Your email for receiving bug reports.",
421 check => 'return strlen($arg0) > 0 AND strstr($arg0,"@") ? true : false;'
422 );
423 $aGeneral['admin_username'] = array(
424 name => "Admin Username",
425 ex => "admin",
426 desc => "Specify the admin name here",
427 check => 'return strlen($arg0) >= 1 ? true : false;'
428 );
429 $aGeneral['admin_password'] = array(
430 name => "Admin Password",
431 ex => "dolphin",
432 desc => "Specify the admin password here",
433 check => 'return strlen($arg0) >= 1 ? true : false;'
434 );
435
436 $aNonDeletableModules = array(
437 'boonex/shared_photo/',
438 );
439
440 $aTemporalityWritableFolders = array(
441 'inc',
442 );
443
444/*----------Vars----------------*/
445/*------------------------------*/
446
447
448$sAction = $_REQUEST['action'];
449$sError = '';
450
451define('BX_SKIP_INSTALL_CHECK', true);
452// --------------------------------------------
453if ($sAction=='step6' || $sAction=='step7' || $sAction=='compile_languages') {
454 require_once('../inc/header.inc.php' );
455 require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
456 require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
457}
458// --------------------------------------------
459require_once('../inc/classes/BxDolIO.php');
460
461
462$sInstallPageContent = InstallPageContent( $sError );
463
464mb_internal_encoding('UTF-8');
465
466echo PageHeader( $sAction, $sError );
467echo $sInstallPageContent;
468echo PageFooter( $sAction );
469
470function InstallPageContent(&$sError) {
471 global $aConf, $confFirst, $aDbConf, $aGeneral;
472
473 $sRet = '';
474
475 switch ($_REQUEST['action']) {
476 case 'compile_languages':
477 performInstallLanguages();
478 $sRet .= 'Default Dolphin language was recompiled';
479 break;
480 /*case 'step8':
481 $sRet .= genMainDolphinPage();
482 break;
483
484 case 'step7':
485 $sInstallLog = '';
486 if ($_REQUEST['sub_action']=='install_modules') {
487 if (is_array($_POST['pathes']) && count($_POST['pathes'])>0) {
488 $oInstallerUi = new BxDolInstallerUi();
489 $sInstallLog = $oInstallerUi->actionInstall($_POST['pathes']);
490 }
491 }
492 $sRet .= genInstallModulesPage($sInstallLog);
493 break;*/
494
495 case 'step7':
496 $sRet .= genMainDolphinPage();
497 break;
498
499 case 'step6':
500 $sErrorMessage = checkPostInstallPermissions($sError);
501 $sRet .= (strlen($sErrorMessage)) ? genPostInstallPermissionTable($sErrorMessage) : genMainDolphinPage();
502 break;
503
504 case 'step5':
505 $sRet .= genPostInstallPermissionTable();
506 break;
507
508 case 'step4':
509 $sErrorMessage = checkConfigArray($aGeneral, $sError);
510 $sRet .= (strlen($sErrorMessage)) ? genSiteGeneralConfig($sErrorMessage) : genInstallationProcessPage();
511 break;
512
513 case 'step3':
514 $sErrorMessage = checkConfigArray($aDbConf, $sError);
515 $sErrorMessage .= CheckSQLParams();
516
517 $sRet .= (strlen($sErrorMessage)) ? genDatabaseConfig($sErrorMessage) : genSiteGeneralConfig();
518 break;
519
520 case 'step2':
521 $sErrorMessage = checkConfigArray($confFirst, $sError);
522 $sRet .= (strlen($sErrorMessage)) ? genPathCheckingConfig($sErrorMessage) : genDatabaseConfig();
523 break;
524
525 case 'step1':
526 $sErrorMessage = checkPreInstallPermission($sError);
527 $sRet .= (strlen($sErrorMessage)) ? genPreInstallPermissionTable($sErrorMessage) : genPathCheckingConfig();
528 break;
529
530 case 'preInstall':
531 $sRet .= genPreInstallPermissionTable();
532 break;
533
534 default:
535 $sRet .= StartInstall();
536 break;
537 }
538
539 return $sRet;
540}
541
542function performInstallLanguages() {
543 db_res("TRUNCATE TABLE `sys_localization_languages`");
544 db_res("TRUNCATE TABLE `sys_localization_keys`");
545 db_res("TRUNCATE TABLE `sys_localization_strings`");
546
547 if (!($sLangsDir = opendir(BX_DIRECTORY_PATH_ROOT . 'install/langs/')))
548 return;
549 while (false !== ($sFilename = readdir($sLangsDir))) {
550 if (substr($sFilename,-3) == 'php') {
551 //$sLangName = substr($sFilename,-6, 2);
552 unset($LANG);
553 unset($LANG_INFO);
554 require_once(BX_DIRECTORY_PATH_ROOT . 'install/langs/' . $sFilename);
555 walkThroughLanguage($LANG, $LANG_INFO);
556 }
557 }
558 closedir ($sLangsDir);
559 compileLanguage();
560}
561
562function walkThroughLanguage($aLanguage, $aLangInfo) {
563 $sLangName = $aLangInfo['Name'];
564 $sLangFlag = $aLangInfo['Flag'];
565 $sLangTitle = $aLangInfo['Title'];
566 $sInsertLanguageSQL = "INSERT INTO `sys_localization_languages` VALUES (NULL, '{$sLangName}', '{$sLangFlag}', '{$sLangTitle}')";
567 db_res($sInsertLanguageSQL);
568 $iLangKey = db_last_id();
569
570 foreach ($aLanguage as $sKey => $sValue) {
571 $sDqKey = str_replace("'", "''", $sKey);
572 $sDqValue = str_replace("'", "''", $sValue);
573
574 $iExistedKey = (int)db_value("SELECT `ID` FROM `sys_localization_keys` WHERE `Key`='{$sDqKey}'");
575 if ($iExistedKey>0) { //Key existed, no need insert key
576 } else {
577 $sInsertKeySQL = "INSERT INTO `sys_localization_keys` VALUES(NULL, 1, '{$sDqKey}')";
578 db_res($sInsertKeySQL);
579 $iExistedKey = db_last_id();
580 }
581
582 $sInsertValueSQL = "INSERT INTO `sys_localization_strings` VALUES({$iExistedKey}, {$iLangKey}, '{$sDqValue}');";
583 db_res($sInsertValueSQL);
584 }
585}
586
587function genInstallModulesPage($sErrorMessage = '') {
588 global $aNonDeletableModules;
589
590 $sCurPage = $_SERVER['PHP_SELF'];
591
592 if ($_REQUEST['sub_action']!='install_modules') {
593 performInstallLanguages();
594 }
595
596 $sErrors = printInstallError($sErrorMessage);
597
598 $oInstallerUi = new BxDolInstallerUi();
599 $aAdditionalInputs['hidden_sub_action'] = array(
600 'type' => 'hidden',
601 'name' => 'sub_action',
602 'value' => 'install_modules'
603 );
604 $aAdditionalInputs['hidden_action'] = array(
605 'type' => 'hidden',
606 'name' => 'action',
607 'value' => 'step7'
608 );
609
610 $sNotInstalled = $oInstallerUi->getNotInstalled($aAdditionalInputs /*, $aNonDeletableModules*/);
611
612 //module_not_install_form
613 $sSkipStep = '';
614 if ($_REQUEST['sub_action']=='install_modules') {
615 $sSkipStep = <<<EOF
616<div class="button_area_2">
617 <form action="{$sCurPage}" method="post">
618 <input id="button" type="image" src="images/skip.gif" />
619 <input type="hidden" name="action" value="step8" />
620 </form>
621</div>
622EOF;
623 }
624
625 return <<<EOF
626<div class="position">Modules.</div>
627{$sErrors}
628<div class="LeftRight">
629 <div class="clearBoth"></div>
630 <div class="left">&nbsp;</div>
631 <div class="right">
632
633 <script type="text/javascript">
634 <!--
635 function PerformInstall() {
636 var oForm = document.getElementById('module_not_install_form');
637 oForm.submit();
638 }
639 -->
640 </script>
641
642 {$sNotInstalled}
643 <div class="formKeeper1">
644 <div class="button_area_1">
645 <form action="{$sCurPage}" method="post">
646 <input id="button" type="image" src="images/next.gif" onclick="PerformInstall(); return false;" />
647 <input type="hidden" name="action" value="step8" />
648 </form>
649 </div>
650 {$sSkipStep}
651 </div>
652 </div>
653 <div class="clearBoth"></div>
654</div>
655EOF;
656}
657
658function genInstallationProcessPage($sErrorMessage = '') {
659 global $aConf, $confFirst, $aDbConf, $aGeneral;
660
661 $sAdminName = get_magic_quotes_gpc() ? stripslashes($_REQUEST['admin_username']) : $_REQUEST['admin_username'];
662 $sAdminPassword = get_magic_quotes_gpc() ? stripslashes($_REQUEST['admin_password']) : $_REQUEST['admin_password'];
663 $resRunSQL = RunSQL( $sAdminName, $sAdminPassword );
664
665 $sForm = '';
666
667 if ('done' == $resRunSQL) {
668 $sForm = '
669 <div class="formKeeper">
670 <form action="' . $_SERVER['PHP_SELF'] . '" method="post">
671 <input type="image" src="images/next.gif" />
672 <input type="hidden" name="action" value="step5" />
673 </form>
674 </div>
675 <div class="clearBoth"></div>';
676 } else {
677 $sForm = $resRunSQL . '
678 <div class="formKeeper">
679 <form action="' . $_SERVER['PHP_SELF'] . '" method="post">
680 <input type="image" src="images/back.gif" />';
681 foreach ($_POST as $sKey => $sValue) {
682 if ($sKey != "action")
683 $sForm .= '<input type="hidden" name="' . $sKey . '" value="' . $sValue . '" />';
684 }
685 $sForm .= '<input type="hidden" name="action" value="step2" />
686 </form>
687 </div>
688 <div class="clearBoth"></div>';
689 return $sForm;
690 }
691
692 foreach ($confFirst as $key => $val) {
693 $aConf['headerTempl'] = str_replace ("%$key%", $_POST[$key], $aConf['headerTempl']);
694 }
695 foreach ($aDbConf as $key => $val) {
696 $aConf['headerTempl'] = str_replace ("%$key%", $_POST[$key], $aConf['headerTempl']);
697 }
698 foreach ($aGeneral as $key => $val) {
699 $aConf['headerTempl'] = str_replace ("%$key%", $_POST[$key], $aConf['headerTempl']);
700 }
701
702 $aConf['periodicTempl'] = str_replace("%site_email%", $_POST['site_email'], $aConf['periodicTempl']);
703 $aConf['periodicTempl'] = str_replace("%dir_root%", $_POST['dir_root'], $aConf['periodicTempl']);
704 $aConf['periodicTempl'] = str_replace("%dir_php%", $_POST['dir_php'], $aConf['periodicTempl']);
705
706 $sInnerCode = '';
707 $fp = fopen($aConf['dolFile'], 'w');
708 if ($fp) {
709 fputs($fp, $aConf['headerTempl']);
710 fclose($fp);
711 chmod($aConf['dolFile'], 0666);
712 //$sInnerCode .='Config file was successfully written to <strong>' . $aConf['dolFile'] . '</strong><br />';
713 } else {
714 $text = 'Warning!!! can not get write access to config file ' . $aConf['dolFile'] . '. Here is config file</font><br>';
715 $sInnerCode .= printInstallError($text);
716 $trans = get_html_translation_table(HTML_ENTITIES);
717 $templ = strtr($aConf['headerTempl'], $trans);
718 $sInnerCode .= '<textarea cols="20" rows="10" class="headerTextarea">' . $aConf['headerTempl'] . '</textarea>';
719 }
720
721 $sInnerCode .= <<<EOF
722<div class="left">
723 Please, setup Cron Jobs as specified below. Helpful info about Cron Jobs is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall70#SettingupCronjobs">available here</a>.</div>
724 <div class="debug">
725 {$aConf['periodicTempl']}
726 </div>
727EOF;
728
729 return <<<EOF
730<div class="position">Cron Jobs</div>
731<div class="LeftRirght">
732 {$sInnerCode}{$sForm}
733</div>
734EOF;
735}
736
737function isAdmin() { return false; }
738
739// check of step 5
740function checkPostInstallPermissions(&$sError) {
741 global $aTemporalityWritableFolders;
742
743 $sFoldersErr = $sFilesErr = $sErrorMessage = '';
744
745 require_once('../inc/classes/BxDolAdminTools.php');
746 $oAdmTools = new BxDolAdminTools();
747 $oBxDolIO = new BxDolIO();
748
749 $aInstallDirsMerged = array_merge($aTemporalityWritableFolders, $oAdmTools->aPostInstallPermDirs);
750 foreach ($aInstallDirsMerged as $sFolder) {
751 if ($oBxDolIO->isWritable($sFolder)) {
752 $sFoldersErr .= '&nbsp;&nbsp;&nbsp;' . $sFolder . ';<br />';
753 }
754 }
755 if (strlen( $sFoldersErr)) {
756 $sError = 'error';
757 $sErrorMessage .= '<strong>Next directories have inappropriate permissions</strong>:<br />' . $sFoldersErr;
758 }
759 foreach ($oAdmTools->aPostInstallPermFiles as $sFile) {
760 if ($oBxDolIO->isWritable($sFile)) {
761 $sFilesErr .= '&nbsp;&nbsp;&nbsp;' . $sFile . ';<br /> ';
762 }
763 }
764 if (strlen($sFilesErr)) {
765 $sError = 'error';
766 $sErrorMessage .= '<strong>Next files have inappropriate permissions</strong>:<br />' . $sFilesErr;
767 }
768
769 return $sErrorMessage;
770}
771
772// step 5
773function genPostInstallPermissionTable($sErrorMessage = '') {
774 global $aTemporalityWritableFolders;
775
776 $sCurPage = $_SERVER['PHP_SELF'];
777 $sPostFolders = $sPostFiles = '';
778
779 $sErrors = printInstallError($sErrorMessage);
780
781 require_once('../inc/classes/BxDolAdminTools.php');
782 $oAdmTools = new BxDolAdminTools();
783 $oBxDolIO = new BxDolIO();
784
785 $aInstallDirsMerged = array_merge($aTemporalityWritableFolders, $oAdmTools->aPostInstallPermDirs);
786 $i = 0;
787 foreach($aInstallDirsMerged as $sFolder) {
788 $sStyleAdd = ( ($i%2) == 0 ) ? 'background-color:#ede9e9;' : 'background-color:#fff;';
789
790 $sEachFolder = ( $oBxDolIO->isWritable($sFolder) )
791 ? '<span class="unwritable">Writable</span>' : '<span class="writable">Non-writable</span>';
792
793 $sPostFolders .= <<<EOF
794<tr style="{$sStyleAdd}" class="cont">
795 <td>{$sFolder}</td>
796 <td class="span">
797 {$sEachFolder}
798 </td>
799 <td class="span">
800 <span class="desired">Non-writable</span>
801 </td>
802</tr>
803EOF;
804 $i++;
805 }
806
807 $i = 0;
808 foreach($oAdmTools->aPostInstallPermFiles as $sFile) {
809 $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
810 $sFolder = preg_replace("/install\/(index\.php$)/","",$str);
811
812 if (file_exists($sFolder . $sFile)) {
813 $sStyleAdd = ( ($i%2) == 0 ) ? 'background-color:#ede9e9;' : 'background-color:#fff;';
814
815 $sEachFile = ( $oBxDolIO->isWritable($sFile) )
816 ? '<span class="unwritable">Writable</span>'
817 : '<span class="writable">Non-writable</span>';
818
819 $sPostFiles .= <<<EOF
820<tr style="{$sStyleAdd}" class="cont">
821 <td>{$sFile}</td>
822 <td class="span">
823 {$sEachFile}
824 </td>
825 <td class="span">
826 <span class="desired">Non-writable</span>
827 </td>
828</tr>
829EOF;
830 $i++;
831 }
832 }
833
834 return <<<EOF
835<div class="position">Permissions Reversal</div>
836{$sErrors}
837<div class="LeftRight">
838 <div class="clearBoth"></div>
839 <div class="left">Now, when Dolphin completed installation, you should change permissions for some files to keep your site secure. Please, change permissions as specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall70#Permissions" target="_blank">available here</a>.</div>
840 <div class="right">
841 <table cellpadding="0" cellspacing="1" width="100%" border="0" style="background-color:silver;">
842 <tr class="head">
843 <td>Directories</td>
844 <td>Current Level</td>
845 <td>Desired Level</td>
846 </tr>
847 {$sPostFolders}
848 <tr class="head">
849 <td>Files</td>
850 <td>Current Level</td>
851 <td>Desired Level</td>
852 </tr>
853 {$sPostFiles}
854 </table>
855 <div class="formKeeper1">
856 <div class="button_area_1">
857 <form action="{$sCurPage}" method="post">
858 <input id="button" type="image" src="images/check.gif" />
859 <input type="hidden" name="action" value="step5" />
860 </form>
861 </div>
862 <div class="button_area_1">
863 <form action="{$sCurPage}" method="post">
864 <input id="button" type="image" src="images/next.gif" />
865 <input type="hidden" name="action" value="step6" />
866 </form>
867 </div>
868 <div class="button_area_2">
869 <form action="{$sCurPage}" method="post">
870 <input id="button" type="image" src="images/skip.gif" />
871 <input type="hidden" name="action" value="step7" />
872 </form>
873 </div>
874 </div>
875 </div>
876 <div class="clearBoth"></div>
877</div>
878EOF;
879}
880
881function genSiteGeneralConfig($sErrorMessage = '') {
882 global $aGeneral;
883
884 $sCurPage = $_SERVER['PHP_SELF'];
885 $sSGParamsTable = createTable($aGeneral);
886
887 $sErrors = '';
888 if (strlen($sErrorMessage)) {
889 $sErrors = printInstallError($sErrorMessage);
890 unset($_POST['site_title']);
891 unset($_POST['site_email']);
892 unset($_POST['notify_email']);
893 unset($_POST['bug_report_email']);
894 }
895
896 $sOldDataParams = '';
897 foreach($_POST as $postKey => $postValue) {
898 $sOldDataParams .= ('action' == $postKey || isset($aGeneral[$postKey])) ? '' : '<input type="hidden" name="' . $postKey . '" value="' . $postValue . '" />';
899 }
900
901 return <<<EOF
902<div class="position">Configuration</div>
903{$sErrors}
904<div class="LeftRirght">
905 <div class="clearBoth"></div>
906 <div class="left"></div>
907 <div class="right">
908 <form action="{$sCurPage}" method="post">
909 <table cellpadding="0" cellspacing="1" width="100%" border="0" style="background-color:silver;">
910 <tr class="head">
911 <td>&nbsp;</td>
912 <td>&nbsp;</td>
913 </tr>
914 {$sSGParamsTable}
915 </table>
916 <div class="formKeeper">
917 <input id="button" type="image" src="images/next.gif" />
918 <input type="hidden" name="action" value="step4" />
919 {$sOldDataParams}
920 </div>
921 </form>
922 </div>
923 <div class="clearBoth"></div>
924</div>
925EOF;
926}
927
928// check of config pages steps
929function checkConfigArray($aCheckedArray, &$sError) {
930 //$error_arr //It is like global variable
931 //$config_arr //It is like global variable, but non used
932
933 $sErrorMessage = '';
934
935 foreach ($aCheckedArray as $sKey => $sValue) {
936 if (! strlen($sValue['check'])) continue;
937
938 $funcbody = $sValue['check'];
939 $func = create_function('$arg0', $funcbody);
940
941 if (! $func($_POST[$sKey])) {
942 $sFieldErr = $sValue['name'];
943 $sErrorMessage .= "Please, input valid data to <b>{$sFieldErr}</b> field<br />";
944 $error_arr[$sKey] = 1;
945 unset($_POST[$sKey]);
946 } else
947 $error_arr[$sKey] = 0;
948
949 //$config_arr[$sKey]['def'] = $_POST[$sKey];
950 }
951
952 if (strlen($sErrorMessage)) {
953 $sError = 'error';
954 }
955
956 return $sErrorMessage;
957}
958
959function genDatabaseConfig($sErrorMessage = '') {
960 global $aDbConf;
961
962 $sCurPage = $_SERVER['PHP_SELF'];
963 $sDbParamsTable = createTable($aDbConf);
964
965 $sErrors = '';
966 if (strlen($sErrorMessage)) {
967 $sErrors = printInstallError($sErrorMessage);
968 unset($_POST['db_name']);
969 unset($_POST['db_user']);
970 unset($_POST['db_password']);
971 }
972
973 $sOldDataParams = '';
974 foreach($_POST as $postKey => $postValue) {
975 $sOldDataParams .= ('action' == $postKey || isset($aDbConf[$postKey])) ? '' : '<input type="hidden" name="' . $postKey . '" value="' . $postValue . '" />';
976 }
977
978 return <<<EOF
979<div class="position">Database</div>
980{$sErrors}
981<div class="LeftRirght">
982 <div class="clearBoth"></div>
983 <div class="left">
984 Please <a target="_blank" href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall70#Step2:CreateaDatabaseandaUser">create a database</a> and tell Dolphin about it.
985 </div>
986 <div class="right">
987 <form action="{$sCurPage}" method="post">
988 <table cellpadding="0" cellspacing="1" width="100%" border="0" style="background-color:silver;">
989 <tr class="head">
990 <td>&nbsp;</td>
991 <td>&nbsp;</td>
992 </tr>
993 {$sDbParamsTable}
994 </table>
995 <div class="formKeeper">
996 <input id="button" type="image" src="images/next.gif" />
997 <input type="hidden" name="action" value="step3" />
998 {$sOldDataParams}
999 </div>
1000 </form>
1001 </div>
1002 <div class="clearBoth"></div>
1003</div>
1004EOF;
1005}
1006
1007function genPathCheckingConfig($sErrorMessage = '') {
1008 global $aConf, $confFirst;
1009
1010 $sCurPage = $_SERVER['PHP_SELF'];
1011
1012 $sGDRes = (extension_loaded('gd')) ? '<span class="writable">GD library installed</span>'
1013 : '<span class="unwritable">GD library NOT installed</span>';
1014
1015 $sError = printInstallError( $sErrorMessage );
1016 $sPathsTable = createTable($confFirst);
1017
1018 return <<<EOF
1019<div class="position">Paths Check</div>
1020{$sError}
1021<div class="LeftRirght">
1022 <div class="clearBoth"></div>
1023 <div class="left">
1024 Dolphin checks general script paths.
1025 </div>
1026 <div class="right">
1027 <form action="{$sCurPage}" method="post">
1028 <table cellpadding="0" cellspacing="1" width="100%" border="0" style="background-color:silver;">
1029 <tr class="head">
1030 <td>&nbsp;</td>
1031 <td>&nbsp;</td>
1032 </tr>
1033 {$sPathsTable}
1034 <tr class="cont" style="background-color:#ede9e9;">
1035 <td>
1036 Check GD Installed
1037 </td>
1038 <td>
1039 {$sGDRes}
1040 </td>
1041 </tr>
1042 </table>
1043 <div class="formKeeper">
1044 <input id="button" type="image" src="images/next.gif" />
1045 <input type="hidden" name="action" value="step2" />
1046 </div>
1047 </form>
1048 </div>
1049 <div class="clearBoth"></div>
1050</div>
1051EOF;
1052}
1053
1054function checkPreInstallPermission(&$sError) {
1055 global $aTemporalityWritableFolders;
1056
1057 $sFoldersErr = $sFilesErr = $sErrorMessage = '';
1058
1059 $oBxDolIO = new BxDolIO();
1060
1061 require_once('../inc/classes/BxDolAdminTools.php');
1062 $oAdmTools = new BxDolAdminTools();
1063
1064 $aInstallDirsMerged = array_merge($aTemporalityWritableFolders, $oAdmTools->aInstallDirs);
1065 foreach ($aInstallDirsMerged as $sFolder) {
1066 if (! $oBxDolIO->isWritable($sFolder)) {
1067 $sFoldersErr .= '&nbsp;&nbsp;&nbsp;' . $sFolder . ';<br />';
1068 }
1069 }
1070
1071 foreach ($oAdmTools->aFlashDirs as $sFolder) {
1072 if (! $oBxDolIO->isWritable($sFolder)) {
1073 $sFoldersErr .= '&nbsp;&nbsp;&nbsp;' . $sFolder . ';<br />';
1074 }
1075 }
1076
1077 if( strlen( $sFoldersErr ) ) {
1078 $sError = 'error';
1079 $sErrorMessage .= '<strong>Next directories have inappropriate permissions</strong>:<br />' . $sFoldersErr;
1080 }
1081
1082 foreach ($oAdmTools->aInstallFiles as $sFile) {
1083 if (! $oBxDolIO->isWritable($sFile)) {
1084 $sFilesErr .= '&nbsp;&nbsp;&nbsp;' . $sFile . ';<br /> ';
1085 }
1086 }
1087
1088 foreach( $oAdmTools->aFlashFiles as $sFile ) {
1089 if (strpos($sFile,'ffmpeg') === false) {
1090 if (! $oBxDolIO->isWritable($sFile)) {
1091 $sFilesErr .= '&nbsp;&nbsp;&nbsp;' . $sFile . ';<br /> ';
1092 }
1093 } else {
1094 if (! $oBxDolIO->isExecutable($sFile)) {
1095 $sFilesErr .= '&nbsp;&nbsp;&nbsp;' . $sFile . ';<br /> ';
1096 }
1097 }
1098 }
1099
1100 if (strlen($sFilesErr)) {
1101 $sError = 'error';
1102 $sErrorMessage .= '<strong>Next files have inappropriate permissions</strong>:<br />' . $sFilesErr;
1103 }
1104
1105 return $sErrorMessage;
1106}
1107
1108// pre install
1109function genPreInstallPermissionTable($sErrorMessage = '') {
1110 global $aTemporalityWritableFolders;
1111
1112 $sCurPage = $_SERVER['PHP_SELF'];
1113 $sErrorMessage .= (ini_get('safe_mode') == 1 || ini_get('safe_mode') == 'On') ? "Please turn off <b>safe_mode</b> in your php.ini file configuration" : '';
1114 $sError = printInstallError($sErrorMessage);
1115
1116 require_once('../inc/classes/BxDolAdminTools.php');
1117 $oAdmTools = new BxDolAdminTools();
1118 $oAdmTools->aInstallDirs = array_merge($aTemporalityWritableFolders, $oAdmTools->aInstallDirs);
1119 $sPermTable = $oAdmTools->GenCommonCode();
1120 $sPermTable .= $oAdmTools->GenPermTable();
1121
1122 return <<<EOF
1123<div class="position">Permissions</div>
1124{$sError}
1125<div class="LeftRirght">
1126 <div class="clearBoth"></div>
1127 <div class="left">
1128 Dolphin needs special access for certain files and directories. Please, change permissions as specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall70#Permissions" target="_blank">available here</a>.
1129 </div>
1130 <div class="clear_both"></div>
1131 <div class="right">
1132 <script src="../plugins/jquery/jquery.js" type="text/javascript" language="javascript"></script>
1133 {$sPermTable}
1134 <div class="formKeeper">
1135 <div class="button_area_1">
1136 <form action="{$sCurPage}" method="post">
1137 <input id="button" type="image" src="images/check.gif" />
1138 <input type="hidden" name="action" value="preInstall" />
1139 </form>
1140 </div>
1141 <div class="button_area_2">
1142 <form action="{$sCurPage}" method="post">
1143 <input id="button" type="image" src="images/next.gif" />
1144 <input type="hidden" name="action" value="step1" />
1145 </form>
1146 </div>
1147 <div class="clearBoth"></div>
1148 </div>
1149 </div>
1150</div>
1151EOF;
1152}
1153
1154function StartInstall() {
1155 global $aConf;
1156
1157 return <<<EOF
1158<div class="install_pic">
1159 Dolphin {$aConf['iVersion']}.{$aConf['iPatch']}
1160</div>
1161
1162<div class="install_text">
1163 Thank you for choosing Dolphin Smart Community Builder!<br />
1164 Click the button below to create your own community.
1165</div>
1166
1167<div class="install_button">
1168 <form action="{$_SERVER['PHP_SELF']}" method="post">
1169 <input id="button" type="image" src="images/install.gif" />
1170 <input type="hidden" name="action" value="preInstall" />
1171 </form>
1172</div>
1173EOF;
1174}
1175
1176function genMainDolphinPage() {
1177 performInstallLanguages();
1178
1179 $sExistedAdminPass = db_value("SELECT `Password` FROM `Profiles` WHERE `ID`='1'");
1180
1181 $aUrl = parse_url($GLOBALS['site']['url']);
1182 $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';
1183 $sHost = '';
1184
1185 $iCookieTime = 0;
1186 setcookie("memberID", 1, $iCookieTime, $sPath, $sHost);
1187 $_COOKIE['memberID'] = 1;
1188 setcookie("memberPassword", $sExistedAdminPass, $iCookieTime, $sPath, $sHost, false, true /* http only */);
1189 $_COOKIE['memberPassword'] = $sExistedAdminPass;
1190
1191 return <<<EOF
1192<script type="text/javascript">
1193 window.location = "../index.php";
1194</script>
1195EOF;
1196}
1197
1198function PageHeader($sAction = '', $sError = '') {
1199 global $aConf;
1200
1201 $aActions = array(
1202 "startInstall" => "Dolphin Installation",
1203 "preInstall" => "Permissions",
1204 "step1" => "Paths",
1205 "step2" => "Database",
1206 "step3" => "Config",
1207 "step4" => "Cron Jobs",
1208 "step5" => "Permissions Reversal",
1209 "step6" => "Modules"
1210 );
1211
1212 if( !strlen( $sAction ) )
1213 $sAction = "startInstall";
1214
1215 $sActiveStyle = ($sAction == "step6") ? 'Active' : 'Inactive';
1216
1217 $iCounterCurrent = 1;
1218 $iCounterActive = 1;
1219
1220 foreach ($aActions as $sActionKey => $sActionValue) {
1221 if ($sAction != $sActionKey) {
1222 $iCounterActive++;
1223 } else
1224 break;
1225 }
1226
1227 if (strlen($sError))
1228 $iCounterActive--;
1229
1230 $sSubActions = '';
1231 foreach ($aActions as $sActionKey => $sActionValue) {
1232 if ($iCounterActive == $iCounterCurrent) {
1233 $sSubActions .= '<div id="topActive">' . $sActionValue . '</div>';
1234 } elseif (($iCounterActive - $iCounterCurrent) == -1) {
1235 $sSubActions .= '<img src="images/active_inactive.gif" /><div id="topInactive">' . $sActionValue . '</div><img src="images/inactive_inactive.gif" />';
1236 } elseif (($iCounterActive - $iCounterCurrent) == 1) {
1237 $sSubActions .= '<div id="topInactive">' . $sActionValue . '</div><img src="images/inactive_active.gif" />';
1238 } else {
1239 $sSubActions .= '<div id="topInactive">' . $sActionValue . '</div>';
1240 if ($sActionKey != "step6")
1241 $sSubActions .= '<img src="images/inactive_inactive.gif" />';
1242 }
1243 $iCounterCurrent++;
1244 }
1245
1246 return <<<EOF
1247<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1248 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
1249 <head>
1250 <title>Dolphin Smart Community Builder Installation Script</title>
1251 <link href="general.css" rel="stylesheet" type="text/css" />
1252 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1253 <script src="../inc/js/functions.js" type="text/javascript" language="javascript"></script>
1254 <!--[if lt IE 7.]>
1255 <script defer type="text/javascript" src="../inc/js/pngfix.js"></script>
1256 <![endif]-->
1257 </head>
1258 <body>
1259 <div id="main">
1260 <div id="topMenu{$sActiveStyle}">
1261 {$sSubActions}
1262 </div>
1263 <div id="header">
1264 <img src="images/boonex-logo.png" alt="" /></div>
1265 <div id="content">
1266EOF;
1267}
1268
1269function PageFooter($sAction) {
1270 $sAdminAdd = ($sAction) ? '<div id="footer"><img src="images/dolphin_transparent.jpg" alt="" /></div>' : '';
1271
1272 return <<<EOF
1273 </div>
1274 {$sAdminAdd}
1275 </div>
1276 </body>
1277</html>
1278EOF;
1279}
1280
1281function printInstallError($sText) {
1282 $sRet = (strlen($sText)) ? '<div class="error">' . $sText . '</div>' : '';
1283 return $sRet;
1284}
1285
1286function createTable($arr) {
1287 $ret = '';
1288 $i = '';
1289 foreach($arr as $key => $value) {
1290 $sStyleAdd = (($i%2) == 0) ? 'background-color:#ede9e9;' : 'background-color:#fff;';
1291
1292 $def_exp_text = "";
1293 if (strlen($value['def_exp'])) {
1294 $funcbody = $value['def_exp'];
1295 $func = create_function("", $funcbody);
1296 $def_exp = $func();
1297 if (strlen($def_exp)) {
1298 $def_exp_text = "&nbsp;<font color=green>found</font>";
1299 $value['def'] = $def_exp;
1300 } else {
1301 $def_exp_text = "&nbsp;<font color=red>not found</font>";
1302 }
1303 }
1304
1305 $st_err = ($error_arr[$key] == 1) ? ' style="background-color:#FFDDDD;" ' : '';
1306
1307 $ret .= <<<EOF
1308 <tr class="cont" style="{$sStyleAdd}">
1309 <td>
1310 <div>{$value['name']}</div>
1311 <div>Description:</div>
1312 <div>Example:</div>
1313 </td>
1314 <td>
1315 <div><input {$st_err} size="30" name="{$key}" value="{$value['def']}" /> {$def_exp_text}</div>
1316 <div>{$value['desc']}</div>
1317 <div style="font-style:italic;">{$value['ex']}</div>
1318 </td>
1319 </tr>
1320EOF;
1321 $i ++;
1322 }
1323
1324 return $ret;
1325}
1326
1327function rewriteFile($sCode, $sReplace, $sFile) {
1328 $ret = '';
1329 $fs = filesize($sFile);
1330 $fp = fopen($sFile, 'r');
1331 if ($fp) {
1332 $fcontent = fread($fp, $fs);
1333 $fcontent = str_replace($sCode, $sReplace, $fcontent);
1334 fclose($fp);
1335 $fp = fopen($sFile, 'w');
1336 if ($fp) {
1337 if (fputs($fp, $fcontent)) {
1338 $ret .= true;
1339 } else {
1340 $ret .= false;
1341 }
1342 fclose ( $fp );
1343 } else {
1344 $ret .= false;
1345 }
1346 } else {
1347 $ret .= false;
1348 }
1349 return $ret;
1350}
1351
1352function RunSQL($sAdminName, $sAdminPassword) {
1353 $aDbConf['host'] = $_POST['db_host'];
1354 $aDbConf['sock'] = $_POST['db_sock'];
1355 $aDbConf['port'] = $_POST['db_port'];
1356 $aDbConf['user'] = $_POST['db_user'];
1357 $aDbConf['passwd'] = $_POST['db_password'];
1358 $aDbConf['db'] = $_POST['db_name'];
1359
1360 $aDbConf['host'] .= ( $aDbConf['port'] ? ":{$aDbConf['port']}" : '' ) . ( $aDbConf['sock'] ? ":{$aDbConf['sock']}" : '' );
1361
1362 $pass = true;
1363 $errorMes = '';
1364 $filename = $_POST['sql_file'];
1365
1366 $vLink = @mysql_connect($aDbConf['host'], $aDbConf['user'], $aDbConf['passwd']);
1367
1368 if( !$vLink )
1369 return printInstallError( mysql_error() );
1370
1371 if (!mysql_select_db ($aDbConf['db'], $vLink))
1372 return printInstallError( $aDbConf['db'] . ': ' . mysql_error() );
1373
1374 mysql_query ("SET sql_mode = ''", $vLink);
1375
1376 if (! ($f = fopen ( $filename, "r" )))
1377 return printInstallError( 'Could not open file with sql instructions:' . $filename );
1378
1379 //Begin SQL script executing
1380 $s_sql = "";
1381 while ($s = fgets ( $f, 10240)) {
1382 $s = trim( $s ); //Utf with BOM only
1383
1384 if (! strlen($s)) continue;
1385 if (mb_substr($s, 0, 1) == '#') continue; //pass comments
1386 if (mb_substr($s, 0, 2) == '--') continue;
1387 if (substr($s, 0, 5) == "\xEF\xBB\xBF\x2D\x2D") continue;
1388
1389 $s_sql .= $s;
1390
1391 if (mb_substr($s, -1) != ';') continue;
1392
1393 $res = mysql_query($s_sql, $vLink);
1394 if (!$res)
1395 $errorMes .= 'Error while executing: ' . $s_sql . '<br />' . mysql_error() . '<hr />';
1396
1397 $s_sql = '';
1398 }
1399
1400 $sAdminNameDB = addslashes($sAdminName);
1401 $sSiteEmail = $_POST['site_email'];
1402 $sSaltDB = base64_encode(substr(md5(microtime()), 2, 6));
1403 $sAdminPasswordDB = sha1(md5($sAdminPassword) . $sSaltDB); // encryptUserPwd
1404 $sAdminQuery = "
1405 INSERT INTO `Profiles`
1406 (`NickName`, `Email`, `Password`, `Salt`, `Status`, `Role`, `DateReg`)
1407 VALUES
1408 ('{$sAdminNameDB}', '{$sSiteEmail}', '{$sAdminPasswordDB}', '{$sSaltDB}', 'Active', 3, NOW())
1409 ";
1410 mysql_query($sAdminQuery, $vLink);
1411
1412 if (!$res)
1413 $errorMes .= 'Error while executing: ' . $s_sql . '<br />' . mysql_error() . '<hr />';
1414
1415 fclose($f);
1416
1417 $enable_gd_value = extension_loaded('gd') ? 'on' : '';
1418 if (! (mysql_query ("UPDATE `sys_options` SET `VALUE`='{$enable_gd_value}' WHERE `Name`='enable_gd'", $vLink )))
1419 $ret .= "<font color=red><i><b>Error</b>:</i> ".mysql_error()."</font><hr>";
1420
1421 $sSiteTitle = $_POST['site_title'];
1422 $sSiteDesc = $_POST['site_desc'];
1423 $sSiteEmailNotify = $_POST['notify_email'];
1424 if ($sSiteEmail != '' && $sSiteTitle != '' && $sSiteEmailNotify != '') {
1425 if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteEmail}' WHERE `Name`='site_email'", $vLink)))
1426 $ret .= "<font color=red><i><b>Error</b>:</i> ".mysql_error($vLink)."</font><hr>";
1427 if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteTitle}' WHERE `Name`='site_title'", $vLink)))
1428 $ret .= "<font color=red><i><b>Error</b>:</i> ".mysql_error($vLink)."</font><hr>";
1429 if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteEmailNotify}' WHERE `Name`='site_email_notify'", $vLink)))
1430 $ret .= "<font color=red><i><b>Error</b>:</i> ".mysql_error($vLink)."</font><hr>";
1431 if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteDesc}' WHERE `Name`='MetaDescription'", $vLink)))
1432 $ret .= "<font color=red><i><b>Error</b>:</i> ".mysql_error($vLink)."</font><hr>";
1433 } else {
1434 $ret .= "<font color=red><i><b>Error</b>:</i> Don`t received POSTed site_email or site_title or site_email_notify</font><hr>";
1435 }
1436
1437 mysql_close($vLink);
1438
1439 $errorMes .= $ret;
1440
1441 if (strlen($errorMes)) {
1442 return printInstallError($errorMes);
1443 } else {
1444 return 'done';
1445 }
1446// return $ret."Truncating tables finished.<br>";
1447}
1448
1449function CheckSQLParams() {
1450 $aDbConf['host'] = $_POST['db_host'];
1451 $aDbConf['sock'] = $_POST['db_sock'];
1452 $aDbConf['port'] = $_POST['db_port'];
1453 $aDbConf['user'] = $_POST['db_user'];
1454 $aDbConf['passwd'] = $_POST['db_password'];
1455 $aDbConf['db'] = $_POST['db_name'];
1456
1457 $aDbConf['host'] .= ( $aDbConf['port'] ? ":{$aDbConf['port']}" : '' ) . ( $aDbConf['sock'] ? ":{$aDbConf['sock']}" : '' );
1458
1459 $vLink = @mysql_connect($aDbConf['host'], $aDbConf['user'], $aDbConf['passwd']);
1460
1461 if (!$vLink)
1462 return printInstallError(mysql_error());
1463
1464 if (!mysql_select_db ($aDbConf['db'], $vLink))
1465 return printInstallError($aDbConf['db'] . ': ' . mysql_error());
1466
1467 mysql_close($vLink);
1468}
1469
1470// set error reporting level
1471if (version_compare(phpversion(), "5.3.0", ">=") == 1)
1472 error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
1473else
1474 error_reporting(E_ALL & ~E_NOTICE);
1475
1476?>
Note: See TracBrowser for help on using the repository browser.