register_globals is On (warning, you should have this param in Off state, or your site will unsafe)'; $aErrors[] = (ini_get('safe_mode') == 0) ? '' : 'safe_mode is On, disable it'; //$aErrors[] = (ini_get('allow_url_fopen') == 0) ? 'Off (warning, better keep this parameter in On to able register Dolphin' : ''; $aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? 'PHP version too old, please update to PHP 5.2.0 at least' : ''; $aErrors[] = (! extension_loaded( 'mbstring')) ? 'mbstring extension not installed. Warning! Dolphin cannot work without mbstring extension.' : ''; // $aErrors[] = (! function_exists('shell_exec')) ? 'shell_exec function is unvailable. Warning! Dolphin cannot work without shell_exec function.' : ''; $aErrors[] = (ini_get('short_open_tag') == 0) ? 'short_open_tag is Off (must be On!)Warning! Dolphin cannot work without short_open_tag.' : ''; if (version_compare(phpversion(), "5.2", ">") == 1) { $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : 'allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)'; }; $aErrors = array_diff($aErrors, array('')); //delete empty if (count($aErrors)) { $sErrors = implode("
", $aErrors); echo << Please go to the
Dolphin Troubleshooter
and solve the problem. EOF; exit; } } if (version_compare(phpversion(), "5.3.0", ">=") == 1) error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); else error_reporting(E_ALL & ~E_NOTICE); set_magic_quotes_runtime(0); ini_set('magic_quotes_sybase', 0); /*------------------------------*/ /*----------Vars----------------*/ $aConf = array(); $aConf['release'] = '25.12.09'; $aConf['iVersion'] = '7.0'; $aConf['iPatch'] = '0'; $aConf['dolFile'] = '../inc/header.inc.php'; $aConf['confDir'] = '../inc/'; $aConf['headerTempl'] = <<register_globals is On (warning, you should have this param in Off state, or your site will unsafe)'; \$aErrors[] = (ini_get('safe_mode') == 0) ? '' : 'safe_mode is On, disable it'; //\$aErrors[] = (ini_get('allow_url_fopen') == 0) ? 'Off (warning, better keep this parameter in On to able register Dolphin' : ''; \$aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? 'PHP version too old, please update to PHP 5.2.0 at least' : ''; \$aErrors[] = (! extension_loaded( 'mbstring')) ? 'mbstring extension not installed. Warning! Dolphin cannot work without mbstring extension.' : ''; if (version_compare(phpversion(), "5.2", ">") == 1) { \$aErrors[] = (ini_get('allow_url_include') == 0) ? '' : 'allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)'; }; \$aErrors = array_diff(\$aErrors, array('')); //delete empty if (count(\$aErrors)) { \$sErrors = implode("
", \$aErrors); echo << Please go to the
Dolphin Troubleshooter
and solve the problem. EOF; exit; } } //check correct hostname \$aUrl = parse_url( \$site['url'] ); if( isset(\$_SERVER['HTTP_HOST']) and 0 != strcasecmp(\$_SERVER['HTTP_HOST'], \$aUrl['host']) and 0 != strcasecmp(\$_SERVER['HTTP_HOST'], \$aUrl['host'] . ':80') ) { header( "Location:http://{\$aUrl['host']}{\$_SERVER['REQUEST_URI']}" ); exit; } // check if install folder exists if ( !defined ('BX_SKIP_INSTALL_CHECK') && file_exists( \$dir['root'] . 'install' ) ) { \$ret = << Dolphin Smart Community Builder Installed
Dolphin Installed
Please, remove INSTALL directory from your server and reload this page to activate your community site.
NOTE: Once you remove this page you can safely install modules via Admin Panel.
EOJ; echo \$ret; exit(); } // set error reporting level if (version_compare(phpversion(), "5.3.0", ">=") == 1) error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); else error_reporting(E_ALL & ~E_NOTICE); set_magic_quotes_runtime(0); ini_set('magic_quotes_sybase', 0); // set default encoding for multibyte functions mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); require_once(BX_DIRECTORY_PATH_INC . "security.inc.php"); require_once(BX_DIRECTORY_PATH_ROOT . "flash/modules/global/inc/header.inc.php"); require_once(BX_DIRECTORY_PATH_ROOT . "flash/modules/global/inc/content.inc.php"); require_once(BX_DIRECTORY_PATH_CLASSES . "BxDolService.php"); require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php'); \$oZ = new BxDolAlerts('system', 'begin', 0); \$oZ->alert(); ?> EOS; $aConf['periodicTempl'] = << * * * * * cd %dir_root%periodic; %dir_php% -q cron.php
EOS; $confFirst = array(); $confFirst['site_url'] = array( name => "Site URL", ex => "http://www.mydomain.com/path/", desc => "Your site URL here (backslash at the end required)", def => "http://", def_exp => ' $str = "http://".$_SERVER[\'HTTP_HOST\'].$_SERVER[\'PHP_SELF\']; return preg_replace("/install\/(index\.php$)/","",$str);', check => 'return strlen($arg0) >= 10 ? true : false;' ); $confFirst['dir_root'] = array( name => "Directory root", ex => "/path/to/your/script/files/", desc => "Path to directory where your php script files stored.", def_exp => ' $str = rtrim($_SERVER[\'DOCUMENT_ROOT\'], \'/\').$_SERVER[\'PHP_SELF\']; return preg_replace("/install\/(index\.php$)/","",$str);', check => 'return strlen($arg0) >= 1 ? true : false;' ); $confFirst['dir_php'] = array( name => "Path to php binary", ex => "/usr/local/bin/php", desc => "You should specify full path to your PHP interpreter here.", def => "/usr/local/bin/php", def_exp => " if ( file_exists(\"/usr/local/bin/php\") ) return \"/usr/local/bin/php\"; \$fp = popen ( \"whereis php\", \"r\"); if ( \$fp ) { \$s = fgets(\$fp); \$s = sscanf(\$s, \"php: %s\"); if ( file_exists(\"\$s[0]\") ) return \"\$s[0]\"; } return '';", check => 'return strlen($arg0) >= 7 ? true : false;' ); $confFirst['dir_mogrify'] = array( name => "Path to mogrify", ex => "/usr/local/bin/mogrify", desc => "If mogrify binary doesn't exist please install ImageMagick", def => "/usr/local/bin/mogrify", def_exp => " if ( file_exists(\"/usr/X11R6/bin/mogrify\") ) return \"/usr/X11R6/bin/mogrify\"; if ( file_exists(\"/usr/local/bin/mogrify\") ) return \"/usr/local/bin/mogrify\"; if ( file_exists(\"/usr/bin/mogrify\") ) return \"/usr/bin/mogrify\"; if ( file_exists(\"/usr/local/X11R6/bin/mogrify\") ) return \"/usr/local/X11R6/bin/mogrify\"; if ( file_exists(\"/usr/bin/X11/mogrify\") ) return \"/usr/bin/X11/mogrify\"; return '';", check => 'return strlen($arg0) >= 7 ? true : false;' ); $confFirst['dir_convert'] = array( name => "Path to convert", ex => "/usr/local/bin/convert", desc => "If convert binary doesn't exist please install ImageMagick", def => "/usr/local/bin/convert", def_exp => " if ( file_exists(\"/usr/X11R6/bin/convert\") ) return \"/usr/X11R6/bin/convert\"; if ( file_exists(\"/usr/local/bin/convert\") ) return \"/usr/local/bin/convert\"; if ( file_exists(\"/usr/bin/convert\") ) return \"/usr/bin/convert\"; if ( file_exists(\"/usr/local/X11R6/bin/convert\") ) return \"/usr/local/X11R6/bin/convert\"; if ( file_exists(\"/usr/bin/X11/convert\") ) return \"/usr/bin/X11/convert\"; return '';", check => 'return strlen($arg0) >= 7 ? true : false;' ); $confFirst['dir_composite'] = array( name => "Path to composite", ex => "/usr/local/bin/composite", desc => "If composite binary doesn't exist please install ImageMagick", def => "/usr/local/bin/composite", def_exp => " if ( file_exists(\"/usr/X11R6/bin/composite\") ) return \"/usr/X11R6/bin/composite\"; if ( file_exists(\"/usr/local/bin/composite\") ) return \"/usr/local/bin/composite\"; if ( file_exists(\"/usr/bin/composite\") ) return \"/usr/bin/composite\"; if ( file_exists(\"/usr/local/X11R6/bin/composite\") ) return \"/usr/local/X11R6/bin/composite\"; if ( file_exists(\"/usr/bin/X11/composite\") ) return \"/usr/bin/X11/composite\"; return '';", check => 'return strlen($arg0) >= 7 ? true : false;' ); $aDbConf = array(); $aDbConf['sql_file'] = array( name => "SQL file", ex => "/home/dolphin/public_html/install/sql/vXX.sql", desc => "SQL file location", def => "./sql/vXX.sql", def_exp => ' if ( !( $dir = opendir( "sql/" ) ) ) return ""; while (false !== ($file = readdir($dir))) { if ( substr($file,-3) != \'sql\' ) continue; closedir( $dir ); return "./sql/$file"; } closedir( $dir ); return "";', check => 'return strlen($arg0) >= 4 ? true : false;' ); $aDbConf['db_host'] = array( name => "Database host name", ex => "localhost", desc => "Your MySQL database host name here.", def => "localhost", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aDbConf['db_port'] = array( name => "Database host port number", ex => "5506", desc => "Leave blank or specify MySQL Database host port number.", def => "", check => '' ); $aDbConf['db_sock'] = array( name => "Database socket path", ex => "/tmp/mysql50.sock", desc => "Leave blank or specify MySQL Database socket path.", def => "", check => '' ); $aDbConf['db_name'] = array( name => "Database name", ex => "YourDatabaseName", desc => "Your MySQL database name here.", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aDbConf['db_user'] = array( name => "Database user", ex => "YourName", desc => "Your MySQL database read/write user name here.", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aDbConf['db_password'] = array( name => "Database password", ex => "YourPassword", desc => "Your MySQL database password here.", check => 'return strlen($arg0) >= 0 ? true : false;' ); $aGeneral = array(); $aGeneral['site_title'] = array( name => "Site Title", ex => "The Best Community", desc => "The name of your site", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aGeneral['site_desc'] = array( name => "Site Description", ex => "The place to find new friends, communicate and have fun.", desc => "Meta description of your site", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aGeneral['site_email'] = array( name => "Site e-mail", ex => "your@email.here", desc => "Your site e-mail.", check => 'return strlen($arg0) > 0 AND strstr($arg0,"@") ? true : false;' ); $aGeneral['notify_email'] = array( name => "Notify e-mail", ex => "your@email.here", desc => "Envelope \"From:\" address for notification messages", check => 'return strlen($arg0) > 0 AND strstr($arg0,"@") ? true : false;' ); $aGeneral['bug_report_email'] = array( name => "Bug report email", ex => "your@email.here", desc => "Your email for receiving bug reports.", check => 'return strlen($arg0) > 0 AND strstr($arg0,"@") ? true : false;' ); $aGeneral['admin_username'] = array( name => "Admin Username", ex => "admin", desc => "Specify the admin name here", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aGeneral['admin_password'] = array( name => "Admin Password", ex => "dolphin", desc => "Specify the admin password here", check => 'return strlen($arg0) >= 1 ? true : false;' ); $aNonDeletableModules = array( 'boonex/shared_photo/', ); $aTemporalityWritableFolders = array( 'inc', ); /*----------Vars----------------*/ /*------------------------------*/ $sAction = $_REQUEST['action']; $sError = ''; define('BX_SKIP_INSTALL_CHECK', true); // -------------------------------------------- if ($sAction=='step6' || $sAction=='step7' || $sAction=='compile_languages') { require_once('../inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); } // -------------------------------------------- require_once('../inc/classes/BxDolIO.php'); $sInstallPageContent = InstallPageContent( $sError ); mb_internal_encoding('UTF-8'); echo PageHeader( $sAction, $sError ); echo $sInstallPageContent; echo PageFooter( $sAction ); function InstallPageContent(&$sError) { global $aConf, $confFirst, $aDbConf, $aGeneral; $sRet = ''; switch ($_REQUEST['action']) { case 'compile_languages': performInstallLanguages(); $sRet .= 'Default Dolphin language was recompiled'; break; /*case 'step8': $sRet .= genMainDolphinPage(); break; case 'step7': $sInstallLog = ''; if ($_REQUEST['sub_action']=='install_modules') { if (is_array($_POST['pathes']) && count($_POST['pathes'])>0) { $oInstallerUi = new BxDolInstallerUi(); $sInstallLog = $oInstallerUi->actionInstall($_POST['pathes']); } } $sRet .= genInstallModulesPage($sInstallLog); break;*/ case 'step7': $sRet .= genMainDolphinPage(); break; case 'step6': $sErrorMessage = checkPostInstallPermissions($sError); $sRet .= (strlen($sErrorMessage)) ? genPostInstallPermissionTable($sErrorMessage) : genMainDolphinPage(); break; case 'step5': $sRet .= genPostInstallPermissionTable(); break; case 'step4': $sErrorMessage = checkConfigArray($aGeneral, $sError); $sRet .= (strlen($sErrorMessage)) ? genSiteGeneralConfig($sErrorMessage) : genInstallationProcessPage(); break; case 'step3': $sErrorMessage = checkConfigArray($aDbConf, $sError); $sErrorMessage .= CheckSQLParams(); $sRet .= (strlen($sErrorMessage)) ? genDatabaseConfig($sErrorMessage) : genSiteGeneralConfig(); break; case 'step2': $sErrorMessage = checkConfigArray($confFirst, $sError); $sRet .= (strlen($sErrorMessage)) ? genPathCheckingConfig($sErrorMessage) : genDatabaseConfig(); break; case 'step1': $sErrorMessage = checkPreInstallPermission($sError); $sRet .= (strlen($sErrorMessage)) ? genPreInstallPermissionTable($sErrorMessage) : genPathCheckingConfig(); break; case 'preInstall': $sRet .= genPreInstallPermissionTable(); break; default: $sRet .= StartInstall(); break; } return $sRet; } function performInstallLanguages() { db_res("TRUNCATE TABLE `sys_localization_languages`"); db_res("TRUNCATE TABLE `sys_localization_keys`"); db_res("TRUNCATE TABLE `sys_localization_strings`"); if (!($sLangsDir = opendir(BX_DIRECTORY_PATH_ROOT . 'install/langs/'))) return; while (false !== ($sFilename = readdir($sLangsDir))) { if (substr($sFilename,-3) == 'php') { //$sLangName = substr($sFilename,-6, 2); unset($LANG); unset($LANG_INFO); require_once(BX_DIRECTORY_PATH_ROOT . 'install/langs/' . $sFilename); walkThroughLanguage($LANG, $LANG_INFO); } } closedir ($sLangsDir); compileLanguage(); } function walkThroughLanguage($aLanguage, $aLangInfo) { $sLangName = $aLangInfo['Name']; $sLangFlag = $aLangInfo['Flag']; $sLangTitle = $aLangInfo['Title']; $sInsertLanguageSQL = "INSERT INTO `sys_localization_languages` VALUES (NULL, '{$sLangName}', '{$sLangFlag}', '{$sLangTitle}')"; db_res($sInsertLanguageSQL); $iLangKey = db_last_id(); foreach ($aLanguage as $sKey => $sValue) { $sDqKey = str_replace("'", "''", $sKey); $sDqValue = str_replace("'", "''", $sValue); $iExistedKey = (int)db_value("SELECT `ID` FROM `sys_localization_keys` WHERE `Key`='{$sDqKey}'"); if ($iExistedKey>0) { //Key existed, no need insert key } else { $sInsertKeySQL = "INSERT INTO `sys_localization_keys` VALUES(NULL, 1, '{$sDqKey}')"; db_res($sInsertKeySQL); $iExistedKey = db_last_id(); } $sInsertValueSQL = "INSERT INTO `sys_localization_strings` VALUES({$iExistedKey}, {$iLangKey}, '{$sDqValue}');"; db_res($sInsertValueSQL); } } function genInstallModulesPage($sErrorMessage = '') { global $aNonDeletableModules; $sCurPage = $_SERVER['PHP_SELF']; if ($_REQUEST['sub_action']!='install_modules') { performInstallLanguages(); } $sErrors = printInstallError($sErrorMessage); $oInstallerUi = new BxDolInstallerUi(); $aAdditionalInputs['hidden_sub_action'] = array( 'type' => 'hidden', 'name' => 'sub_action', 'value' => 'install_modules' ); $aAdditionalInputs['hidden_action'] = array( 'type' => 'hidden', 'name' => 'action', 'value' => 'step7' ); $sNotInstalled = $oInstallerUi->getNotInstalled($aAdditionalInputs /*, $aNonDeletableModules*/); //module_not_install_form $sSkipStep = ''; if ($_REQUEST['sub_action']=='install_modules') { $sSkipStep = <<
EOF; } return <<Modules.
{$sErrors}
 
{$sNotInstalled}
{$sSkipStep}
EOF; } function genInstallationProcessPage($sErrorMessage = '') { global $aConf, $confFirst, $aDbConf, $aGeneral; $sAdminName = get_magic_quotes_gpc() ? stripslashes($_REQUEST['admin_username']) : $_REQUEST['admin_username']; $sAdminPassword = get_magic_quotes_gpc() ? stripslashes($_REQUEST['admin_password']) : $_REQUEST['admin_password']; $resRunSQL = RunSQL( $sAdminName, $sAdminPassword ); $sForm = ''; if ('done' == $resRunSQL) { $sForm = '
'; } else { $sForm = $resRunSQL . '
'; foreach ($_POST as $sKey => $sValue) { if ($sKey != "action") $sForm .= ''; } $sForm .= '
'; return $sForm; } foreach ($confFirst as $key => $val) { $aConf['headerTempl'] = str_replace ("%$key%", $_POST[$key], $aConf['headerTempl']); } foreach ($aDbConf as $key => $val) { $aConf['headerTempl'] = str_replace ("%$key%", $_POST[$key], $aConf['headerTempl']); } foreach ($aGeneral as $key => $val) { $aConf['headerTempl'] = str_replace ("%$key%", $_POST[$key], $aConf['headerTempl']); } $aConf['periodicTempl'] = str_replace("%site_email%", $_POST['site_email'], $aConf['periodicTempl']); $aConf['periodicTempl'] = str_replace("%dir_root%", $_POST['dir_root'], $aConf['periodicTempl']); $aConf['periodicTempl'] = str_replace("%dir_php%", $_POST['dir_php'], $aConf['periodicTempl']); $sInnerCode = ''; $fp = fopen($aConf['dolFile'], 'w'); if ($fp) { fputs($fp, $aConf['headerTempl']); fclose($fp); chmod($aConf['dolFile'], 0666); //$sInnerCode .='Config file was successfully written to ' . $aConf['dolFile'] . '
'; } else { $text = 'Warning!!! can not get write access to config file ' . $aConf['dolFile'] . '. Here is config file
'; $sInnerCode .= printInstallError($text); $trans = get_html_translation_table(HTML_ENTITIES); $templ = strtr($aConf['headerTempl'], $trans); $sInnerCode .= ''; } $sInnerCode .= << Please, setup Cron Jobs as specified below. Helpful info about Cron Jobs is available here.
{$aConf['periodicTempl']}
EOF; return <<Cron Jobs
{$sInnerCode}{$sForm}
EOF; } function isAdmin() { return false; } // check of step 5 function checkPostInstallPermissions(&$sError) { global $aTemporalityWritableFolders; $sFoldersErr = $sFilesErr = $sErrorMessage = ''; require_once('../inc/classes/BxDolAdminTools.php'); $oAdmTools = new BxDolAdminTools(); $oBxDolIO = new BxDolIO(); $aInstallDirsMerged = array_merge($aTemporalityWritableFolders, $oAdmTools->aPostInstallPermDirs); foreach ($aInstallDirsMerged as $sFolder) { if ($oBxDolIO->isWritable($sFolder)) { $sFoldersErr .= '   ' . $sFolder . ';
'; } } if (strlen( $sFoldersErr)) { $sError = 'error'; $sErrorMessage .= 'Next directories have inappropriate permissions:
' . $sFoldersErr; } foreach ($oAdmTools->aPostInstallPermFiles as $sFile) { if ($oBxDolIO->isWritable($sFile)) { $sFilesErr .= '   ' . $sFile . ';
'; } } if (strlen($sFilesErr)) { $sError = 'error'; $sErrorMessage .= 'Next files have inappropriate permissions:
' . $sFilesErr; } return $sErrorMessage; } // step 5 function genPostInstallPermissionTable($sErrorMessage = '') { global $aTemporalityWritableFolders; $sCurPage = $_SERVER['PHP_SELF']; $sPostFolders = $sPostFiles = ''; $sErrors = printInstallError($sErrorMessage); require_once('../inc/classes/BxDolAdminTools.php'); $oAdmTools = new BxDolAdminTools(); $oBxDolIO = new BxDolIO(); $aInstallDirsMerged = array_merge($aTemporalityWritableFolders, $oAdmTools->aPostInstallPermDirs); $i = 0; foreach($aInstallDirsMerged as $sFolder) { $sStyleAdd = ( ($i%2) == 0 ) ? 'background-color:#ede9e9;' : 'background-color:#fff;'; $sEachFolder = ( $oBxDolIO->isWritable($sFolder) ) ? 'Writable' : 'Non-writable'; $sPostFolders .= << {$sFolder} {$sEachFolder} Non-writable EOF; $i++; } $i = 0; foreach($oAdmTools->aPostInstallPermFiles as $sFile) { $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; $sFolder = preg_replace("/install\/(index\.php$)/","",$str); if (file_exists($sFolder . $sFile)) { $sStyleAdd = ( ($i%2) == 0 ) ? 'background-color:#ede9e9;' : 'background-color:#fff;'; $sEachFile = ( $oBxDolIO->isWritable($sFile) ) ? 'Writable' : 'Non-writable'; $sPostFiles .= << {$sFile} {$sEachFile} Non-writable EOF; $i++; } } return <<Permissions Reversal {$sErrors}
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 available here.
{$sPostFolders} {$sPostFiles}
Directories Current Level Desired Level
Files Current Level Desired Level
EOF; } function genSiteGeneralConfig($sErrorMessage = '') { global $aGeneral; $sCurPage = $_SERVER['PHP_SELF']; $sSGParamsTable = createTable($aGeneral); $sErrors = ''; if (strlen($sErrorMessage)) { $sErrors = printInstallError($sErrorMessage); unset($_POST['site_title']); unset($_POST['site_email']); unset($_POST['notify_email']); unset($_POST['bug_report_email']); } $sOldDataParams = ''; foreach($_POST as $postKey => $postValue) { $sOldDataParams .= ('action' == $postKey || isset($aGeneral[$postKey])) ? '' : ''; } return <<Configuration {$sErrors}
{$sSGParamsTable}
   
{$sOldDataParams}
EOF; } // check of config pages steps function checkConfigArray($aCheckedArray, &$sError) { //$error_arr //It is like global variable //$config_arr //It is like global variable, but non used $sErrorMessage = ''; foreach ($aCheckedArray as $sKey => $sValue) { if (! strlen($sValue['check'])) continue; $funcbody = $sValue['check']; $func = create_function('$arg0', $funcbody); if (! $func($_POST[$sKey])) { $sFieldErr = $sValue['name']; $sErrorMessage .= "Please, input valid data to {$sFieldErr} field
"; $error_arr[$sKey] = 1; unset($_POST[$sKey]); } else $error_arr[$sKey] = 0; //$config_arr[$sKey]['def'] = $_POST[$sKey]; } if (strlen($sErrorMessage)) { $sError = 'error'; } return $sErrorMessage; } function genDatabaseConfig($sErrorMessage = '') { global $aDbConf; $sCurPage = $_SERVER['PHP_SELF']; $sDbParamsTable = createTable($aDbConf); $sErrors = ''; if (strlen($sErrorMessage)) { $sErrors = printInstallError($sErrorMessage); unset($_POST['db_name']); unset($_POST['db_user']); unset($_POST['db_password']); } $sOldDataParams = ''; foreach($_POST as $postKey => $postValue) { $sOldDataParams .= ('action' == $postKey || isset($aDbConf[$postKey])) ? '' : ''; } return <<Database {$sErrors}
Please create a database and tell Dolphin about it.
{$sDbParamsTable}
   
{$sOldDataParams}
EOF; } function genPathCheckingConfig($sErrorMessage = '') { global $aConf, $confFirst; $sCurPage = $_SERVER['PHP_SELF']; $sGDRes = (extension_loaded('gd')) ? 'GD library installed' : 'GD library NOT installed'; $sError = printInstallError( $sErrorMessage ); $sPathsTable = createTable($confFirst); return <<Paths Check {$sError}
Dolphin checks general script paths.
{$sPathsTable}
   
Check GD Installed {$sGDRes}
EOF; } function checkPreInstallPermission(&$sError) { global $aTemporalityWritableFolders; $sFoldersErr = $sFilesErr = $sErrorMessage = ''; $oBxDolIO = new BxDolIO(); require_once('../inc/classes/BxDolAdminTools.php'); $oAdmTools = new BxDolAdminTools(); $aInstallDirsMerged = array_merge($aTemporalityWritableFolders, $oAdmTools->aInstallDirs); foreach ($aInstallDirsMerged as $sFolder) { if (! $oBxDolIO->isWritable($sFolder)) { $sFoldersErr .= '   ' . $sFolder . ';
'; } } foreach ($oAdmTools->aFlashDirs as $sFolder) { if (! $oBxDolIO->isWritable($sFolder)) { $sFoldersErr .= '   ' . $sFolder . ';
'; } } if( strlen( $sFoldersErr ) ) { $sError = 'error'; $sErrorMessage .= 'Next directories have inappropriate permissions:
' . $sFoldersErr; } foreach ($oAdmTools->aInstallFiles as $sFile) { if (! $oBxDolIO->isWritable($sFile)) { $sFilesErr .= '   ' . $sFile . ';
'; } } foreach( $oAdmTools->aFlashFiles as $sFile ) { if (strpos($sFile,'ffmpeg') === false) { if (! $oBxDolIO->isWritable($sFile)) { $sFilesErr .= '   ' . $sFile . ';
'; } } else { if (! $oBxDolIO->isExecutable($sFile)) { $sFilesErr .= '   ' . $sFile . ';
'; } } } if (strlen($sFilesErr)) { $sError = 'error'; $sErrorMessage .= 'Next files have inappropriate permissions:
' . $sFilesErr; } return $sErrorMessage; } // pre install function genPreInstallPermissionTable($sErrorMessage = '') { global $aTemporalityWritableFolders; $sCurPage = $_SERVER['PHP_SELF']; $sErrorMessage .= (ini_get('safe_mode') == 1 || ini_get('safe_mode') == 'On') ? "Please turn off safe_mode in your php.ini file configuration" : ''; $sError = printInstallError($sErrorMessage); require_once('../inc/classes/BxDolAdminTools.php'); $oAdmTools = new BxDolAdminTools(); $oAdmTools->aInstallDirs = array_merge($aTemporalityWritableFolders, $oAdmTools->aInstallDirs); $sPermTable = $oAdmTools->GenCommonCode(); $sPermTable .= $oAdmTools->GenPermTable(); return <<Permissions {$sError}
Dolphin needs special access for certain files and directories. Please, change permissions as specified in the chart below. Helpful info about permissions is available here.
{$sPermTable}
EOF; } function StartInstall() { global $aConf; return << Dolphin {$aConf['iVersion']}.{$aConf['iPatch']}
Thank you for choosing Dolphin Smart Community Builder!
Click the button below to create your own community.
EOF; } function genMainDolphinPage() { performInstallLanguages(); $sExistedAdminPass = db_value("SELECT `Password` FROM `Profiles` WHERE `ID`='1'"); $aUrl = parse_url($GLOBALS['site']['url']); $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/'; $sHost = ''; $iCookieTime = 0; setcookie("memberID", 1, $iCookieTime, $sPath, $sHost); $_COOKIE['memberID'] = 1; setcookie("memberPassword", $sExistedAdminPass, $iCookieTime, $sPath, $sHost, false, true /* http only */); $_COOKIE['memberPassword'] = $sExistedAdminPass; return << window.location = "../index.php"; EOF; } function PageHeader($sAction = '', $sError = '') { global $aConf; $aActions = array( "startInstall" => "Dolphin Installation", "preInstall" => "Permissions", "step1" => "Paths", "step2" => "Database", "step3" => "Config", "step4" => "Cron Jobs", "step5" => "Permissions Reversal", "step6" => "Modules" ); if( !strlen( $sAction ) ) $sAction = "startInstall"; $sActiveStyle = ($sAction == "step6") ? 'Active' : 'Inactive'; $iCounterCurrent = 1; $iCounterActive = 1; foreach ($aActions as $sActionKey => $sActionValue) { if ($sAction != $sActionKey) { $iCounterActive++; } else break; } if (strlen($sError)) $iCounterActive--; $sSubActions = ''; foreach ($aActions as $sActionKey => $sActionValue) { if ($iCounterActive == $iCounterCurrent) { $sSubActions .= '
' . $sActionValue . '
'; } elseif (($iCounterActive - $iCounterCurrent) == -1) { $sSubActions .= '
' . $sActionValue . '
'; } elseif (($iCounterActive - $iCounterCurrent) == 1) { $sSubActions .= '
' . $sActionValue . '
'; } else { $sSubActions .= '
' . $sActionValue . '
'; if ($sActionKey != "step6") $sSubActions .= ''; } $iCounterCurrent++; } return << Dolphin Smart Community Builder Installation Script
{$sSubActions}
EOF; } function PageFooter($sAction) { $sAdminAdd = ($sAction) ? '' : ''; return << {$sAdminAdd}
EOF; } function printInstallError($sText) { $sRet = (strlen($sText)) ? '
' . $sText . '
' : ''; return $sRet; } function createTable($arr) { $ret = ''; $i = ''; foreach($arr as $key => $value) { $sStyleAdd = (($i%2) == 0) ? 'background-color:#ede9e9;' : 'background-color:#fff;'; $def_exp_text = ""; if (strlen($value['def_exp'])) { $funcbody = $value['def_exp']; $func = create_function("", $funcbody); $def_exp = $func(); if (strlen($def_exp)) { $def_exp_text = " found"; $value['def'] = $def_exp; } else { $def_exp_text = " not found"; } } $st_err = ($error_arr[$key] == 1) ? ' style="background-color:#FFDDDD;" ' : ''; $ret .= <<
{$value['name']}
Description:
Example:
{$def_exp_text}
{$value['desc']}
{$value['ex']}
EOF; $i ++; } return $ret; } function rewriteFile($sCode, $sReplace, $sFile) { $ret = ''; $fs = filesize($sFile); $fp = fopen($sFile, 'r'); if ($fp) { $fcontent = fread($fp, $fs); $fcontent = str_replace($sCode, $sReplace, $fcontent); fclose($fp); $fp = fopen($sFile, 'w'); if ($fp) { if (fputs($fp, $fcontent)) { $ret .= true; } else { $ret .= false; } fclose ( $fp ); } else { $ret .= false; } } else { $ret .= false; } return $ret; } function RunSQL($sAdminName, $sAdminPassword) { $aDbConf['host'] = $_POST['db_host']; $aDbConf['sock'] = $_POST['db_sock']; $aDbConf['port'] = $_POST['db_port']; $aDbConf['user'] = $_POST['db_user']; $aDbConf['passwd'] = $_POST['db_password']; $aDbConf['db'] = $_POST['db_name']; $aDbConf['host'] .= ( $aDbConf['port'] ? ":{$aDbConf['port']}" : '' ) . ( $aDbConf['sock'] ? ":{$aDbConf['sock']}" : '' ); $pass = true; $errorMes = ''; $filename = $_POST['sql_file']; $vLink = @mysql_connect($aDbConf['host'], $aDbConf['user'], $aDbConf['passwd']); if( !$vLink ) return printInstallError( mysql_error() ); if (!mysql_select_db ($aDbConf['db'], $vLink)) return printInstallError( $aDbConf['db'] . ': ' . mysql_error() ); mysql_query ("SET sql_mode = ''", $vLink); if (! ($f = fopen ( $filename, "r" ))) return printInstallError( 'Could not open file with sql instructions:' . $filename ); //Begin SQL script executing $s_sql = ""; while ($s = fgets ( $f, 10240)) { $s = trim( $s ); //Utf with BOM only if (! strlen($s)) continue; if (mb_substr($s, 0, 1) == '#') continue; //pass comments if (mb_substr($s, 0, 2) == '--') continue; if (substr($s, 0, 5) == "\xEF\xBB\xBF\x2D\x2D") continue; $s_sql .= $s; if (mb_substr($s, -1) != ';') continue; $res = mysql_query($s_sql, $vLink); if (!$res) $errorMes .= 'Error while executing: ' . $s_sql . '
' . mysql_error() . '
'; $s_sql = ''; } $sAdminNameDB = addslashes($sAdminName); $sSiteEmail = $_POST['site_email']; $sSaltDB = base64_encode(substr(md5(microtime()), 2, 6)); $sAdminPasswordDB = sha1(md5($sAdminPassword) . $sSaltDB); // encryptUserPwd $sAdminQuery = " INSERT INTO `Profiles` (`NickName`, `Email`, `Password`, `Salt`, `Status`, `Role`, `DateReg`) VALUES ('{$sAdminNameDB}', '{$sSiteEmail}', '{$sAdminPasswordDB}', '{$sSaltDB}', 'Active', 3, NOW()) "; mysql_query($sAdminQuery, $vLink); if (!$res) $errorMes .= 'Error while executing: ' . $s_sql . '
' . mysql_error() . '
'; fclose($f); $enable_gd_value = extension_loaded('gd') ? 'on' : ''; if (! (mysql_query ("UPDATE `sys_options` SET `VALUE`='{$enable_gd_value}' WHERE `Name`='enable_gd'", $vLink ))) $ret .= "Error: ".mysql_error()."
"; $sSiteTitle = $_POST['site_title']; $sSiteDesc = $_POST['site_desc']; $sSiteEmailNotify = $_POST['notify_email']; if ($sSiteEmail != '' && $sSiteTitle != '' && $sSiteEmailNotify != '') { if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteEmail}' WHERE `Name`='site_email'", $vLink))) $ret .= "Error: ".mysql_error($vLink)."
"; if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteTitle}' WHERE `Name`='site_title'", $vLink))) $ret .= "Error: ".mysql_error($vLink)."
"; if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteEmailNotify}' WHERE `Name`='site_email_notify'", $vLink))) $ret .= "Error: ".mysql_error($vLink)."
"; if (! (mysql_query("UPDATE `sys_options` SET `VALUE`='{$sSiteDesc}' WHERE `Name`='MetaDescription'", $vLink))) $ret .= "Error: ".mysql_error($vLink)."
"; } else { $ret .= "Error: Don`t received POSTed site_email or site_title or site_email_notify
"; } mysql_close($vLink); $errorMes .= $ret; if (strlen($errorMes)) { return printInstallError($errorMes); } else { return 'done'; } // return $ret."Truncating tables finished.
"; } function CheckSQLParams() { $aDbConf['host'] = $_POST['db_host']; $aDbConf['sock'] = $_POST['db_sock']; $aDbConf['port'] = $_POST['db_port']; $aDbConf['user'] = $_POST['db_user']; $aDbConf['passwd'] = $_POST['db_password']; $aDbConf['db'] = $_POST['db_name']; $aDbConf['host'] .= ( $aDbConf['port'] ? ":{$aDbConf['port']}" : '' ) . ( $aDbConf['sock'] ? ":{$aDbConf['sock']}" : '' ); $vLink = @mysql_connect($aDbConf['host'], $aDbConf['user'], $aDbConf['passwd']); if (!$vLink) return printInstallError(mysql_error()); if (!mysql_select_db ($aDbConf['db'], $vLink)) return printInstallError($aDbConf['db'] . ': ' . mysql_error()); mysql_close($vLink); } // set error reporting level if (version_compare(phpversion(), "5.3.0", ">=") == 1) error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); else error_reporting(E_ALL & ~E_NOTICE); ?>