Warning. Dolphin cannot work in safe mode'; exit; } //check mbstring if( !extension_loaded( 'mbstring' ) ) { echo 'Warning! Dolphin cannot work without mbstring extension. Please go to the Dolphin Troubleshooter and solve the problem.'; exit; } //check correct hostname \$aUrl = parse_url( \$site['url'] ); if( isset(\$_SERVER['HTTP_HOST']) and \$_SERVER['HTTP_HOST'] != \$aUrl['host'] and \$_SERVER['HTTP_HOST'] != \$aUrl['host'] . ':80' ) { header( "Location:http://{\$aUrl['host']}{\$_SERVER['REQUEST_URI']}" ); exit; } // check if install folder exists if ( 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.
EOJ; echo \$ret; exit(); } // set error reporting level 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'); //--- Ray Integration ---// require_once(\$dir['root'] . "ray/modules/global/inc/header.inc.php"); require_once(\$dir['root'] . "ray/modules/global/inc/content.inc.php"); //--- Ray Integration ---// ?> EOS; $aConf['periodicTempl'] = << "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 = $_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_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;' ); /*----------Vars----------------*/ /*------------------------------*/ $sAction = $_REQUEST['action']; $sError = ''; $cont = PageContent( $sError ); mb_internal_encoding('UTF-8'); echo PageHeader( $sAction, $sError ); echo $cont; echo PageFooter( $sAction ); function PageContent( &$sError ) { global $aConf, $permDirectories, $permFiles, $reversalDirectories, $reversalFiles; global $confFirst, $aDbConf, $aGeneral, $aRayFolders, $aRayFiles; $ret = ''; switch( $_REQUEST['action'] ) { case 'step7': $ret .= loadDolphin(); break; case 'step6': $dirName = ''; $fileName = ''; $errorMessage = ''; foreach ($reversalDirectories as $dir) { if ( isFullAccessible('../'.$dir) ) { //$passOk = false; $dirName .= '   ' . $dir . ';
'; } } if( strlen( $dirName ) ) { $sError = 'error'; $errorMessage .= 'Next directories have inappropriate permissions:
' . $dirName; } foreach ( $reversalFiles as $file ) { if ( isRWAccessible ('../'.$file) ) { //$passOk = false; $fileName .= '   ' . $file . ';
'; } } if( strlen( $fileName ) ) { $sError = 'error'; $errorMessage .= 'Next files have inappropriate permissions:
' . $fileName; } if( strlen( $errorMessage ) ) { $ret .= showPermissions ( $errorMessage ); } else { $ret .= loadDolphin(); } break; case 'step5': $ret .= showPermissions(); break; case 'step4': $errorMessage = ''; foreach ( $aGeneral as $key => $value ) { if ( !strlen($value['check']) ) continue; $funcbody = $value['check']; $func = create_function('$arg0', $funcbody); if ( !$func($_POST[$key]) ) { $errorMessage .= "Please, input valid data to {$value['name']} field
"; $error_arr[$key] = 1; $passOk = false; unset($_POST[$key]); } else $error_arr[$key] = 0; $config_arr[$key]['def'] = $_POST[$key]; } if( strlen( $errorMessage ) ) { $sError = 'error'; $ret .= installGeneralInfo( $errorMessage ); } else { $ret .= installFinish(); } break; case 'step3': $errorMessage = ''; foreach ( $aDbConf as $key => $value ) { if ( !strlen($value['check']) ) continue; $funcbody = $value['check']; $func = create_function('$arg0', $funcbody); if ( !$func($_POST[$key]) ) { $errorMessage .= "Please, input valid data to {$value['name']} field
"; $error_arr[$key] = 1; $passOk = false; unset($_POST[$key]); } else $error_arr[$key] = 0; $config_arr[$key]['def'] = $_POST[$key]; } if( strlen( $errorMessage ) ) { $sError = 'error'; $ret .= installDBConf( $errorMessage ); } else { $ret .= installGeneralInfo(); } break; case 'step2': $errorMessage = ''; foreach ( $confFirst as $key => $value ) { if ( !strlen($value['check']) ) continue; $funcbody = $value['check']; $func = create_function('$arg0', $funcbody); if ( !$func($_POST[$key]) ) { $errorMessage .= "Please, input valid data to {$value['name']} field
"; $error_arr[$key] = 1; $passOk = false; unset($_POST[$key]); } else $error_arr[$key] = 0; $config_arr[$key]['def'] = $_POST[$key]; } if( strlen( $errorMessage ) ) { $sError = 'error'; $ret .= installStepFirst( $errorMessage ); } else { $ret .= installDBConf(); } break; case 'step1': $dirName = ''; $errorMessage = ''; foreach ($permDirectories as $dir) { if ( !isFullAccessible('../'.$dir) ) { //$passOk = false; $dirName .= '   ' . $dir . ';
'; } } foreach ($aRayFolders as $dir) { if ( !isFullAccessible('../'.$dir) ) { //$passOk = false; $dirName .= '   ' . $dir . ';
'; } } if( strlen( $dirName ) ) { $sError = 'error'; $errorMessage .= 'Next directories have inappropriate permissions:
' . $dirName; } foreach ($permFiles as $file) { if ( !isRWAccessible('../'.$file) ) { //$passOk = false; $fileName .= '   ' . $file . ';
'; } } foreach( $aRayFiles as $file ) { if (strpos($file,'ffmpeg') === FALSE) { if ( !isRWAccessible('../'.$file) ) { //$passOk = false; $fileName .= '   ' . $file . ';
'; } } else { if ( !isFullAccessible('../'.$file) ) { //$passOk = false; $fileName .= '   ' . $file . ';
'; } } } if( strlen( $fileName ) ) { $sError = 'error'; $errorMessage .= 'Next files have inappropriate permissions:
' . $fileName; } if( strlen( $errorMessage ) ) { $ret .= PreInstall( $errorMessage ); } else { $ret .= installStepFirst(); } break; case 'preInstall': $ret .= PreInstall(); break; default: $ret .= StartInstall(); } return $ret; } function installFinish( $errorMessage = '' ) { global $aConf, $confFirst, $aDbConf, $aGeneral; global $reversalDirectories, $reversalFiles; $sAdminName = $_REQUEST['admin_username']; $sAdminPassword = $_REQUEST['admin_password']; $resRunSQL = RunSQL( $sAdminName, $sAdminPassword ); $sRet = ''; if( 'done' == $resRunSQL ) { $sRet = '
'; } else { $sRet = $resRunSQL; $sRet .= '
'; foreach( $_POST as $sKey => $sValue ) { if( $sKey != "action" ) $sRet .= ''; } $sRet .= '
'; return $sRet; } 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'] ); $ret = ''; $ret .= '
Cron Jobs
'; $ret .= '
'; $fp = fopen ( $aConf['dolFile'], 'w'); if ( $fp ) { fputs ( $fp, $aConf['headerTempl'] ); fclose ( $fp ); chmod( $aConf['dolFile'], 0666 ); //$ret .='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
'; $ret .= printInstallError( $text ); $trans = get_html_translation_table(HTML_ENTITIES); $templ = strtr($aConf['headerTempl'], $trans); $ret .= ''; } $fp = fopen ( $aConf['periodicFile'], 'w'); if ( $fp ) { fputs ( $fp, $aConf['periodicTempl'] ); fclose ( $fp ); chmod( $aConf['dolFile'], 0666 ); //$ret .='Config file was successfully written to ' . $aConf['periodicFile'] . '
'; $ret .= '
Please, setup Cron Jobs as specified below. Helpful info about Cron Jobs is available here.'; $ret .= '
'; $ret .= '
'; $aFileLines = file( $aConf['periodicFile'] ); foreach( $aFileLines as $sLine ) $ret .= $sLine . '
'; $ret .= '
'; } else { $text = 'Warning!!! can not get write access to config file ' . $aConf['periodicFile'] . '. Here is config file
'; $ret .= printInstallError( $text ); $trans = get_html_translation_table(HTML_ENTITIES); $templ = strtr($aConf['periodicTempl'], $trans); $ret .= ''; } @rewriteFile( '[path_to]', $_POST['dir_root'], $aConf['cmdFile'] ); @rewriteFile( '[path_to]', $_POST['dir_root'], $aConf['notifiesFile'] ); @rewriteFile( '[path_to]', $_POST['dir_root'], $aConf['cupidFile'] ); //@rewriteFile( '[path_to]', $_POST['dir_root'], $aConf['tagsFile'] ); @rewriteFile( '[path_to]', $_POST['dir_root'], $aConf['rayHeader'] ); $ret .= $sRet; $ret .= '
'; return $ret; } function showPermissions( $errorMessage='' ) { global $reversalDirectories, $reversalFiles; $ret .= '
Permissions Reversal
'; if( strlen( $errorMessage ) ) { $ret .= printInstallError( $errorMessage ); } $ret .= '
'; $ret .= '
'; $ret .= '
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.
'; $ret .= '
'; $i = 0; foreach($reversalDirectories as $dir) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = 'background-color:#fff;'; } $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $i ++; } $ret .= ' '; $i = 0; foreach($reversalFiles as $file) { $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; $dir = preg_replace("/install\/(index\.php$)/","",$str); if( file_exists( $dir . $file) ) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = 'background-color:#fff;'; } $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $i ++; } } $ret .= '
Directories Current Level Desired Level
' . $dir . ''; if ( isFullAccessible('../'.$dir) ) { $ret .= '' . getPermissions( '../' . $dir ) . 'Writable'; } else { $ret .= '' . getPermissions( '../' . $dir ) . 'Non-writable'; } $ret .= ''; $ret .= '755Non-writable'; $ret .= '
Files Current Level Desired Level
' . $file . ''; if ( isRWAccessible('../'.$file) ) { $ret .= '' . getPermissions( '../' . $file ) . 'Writable'; } else { $ret .= '' . getPermissions( '../' . $file ) . 'Non-writable'; } $ret .= ''; $ret .= '644Non-writable'; $ret .= '
'; $ret .= '
'; $ret .= '
'; return $ret; } function installGeneralInfo( $errorMessage = '' ) { global $aGeneral; $ret = ''; $ret .= '
Configuration
'; if( strlen( $errorMessage ) ) { $ret .= printInstallError( $errorMessage ); unset($_POST['site_title']); unset($_POST['site_email']); unset($_POST['notify_email']); unset($_POST['bug_report_email']); } $ret .= '
'; $ret .= createTable( $aGeneral ); $ret .= '
   
'; foreach($_POST as $postKey => $postValue) { if( 'action' == $postKey || isset( $aGeneral[$postKey] ) ) { $ret .= ''; } else { $ret .= ''; } } $ret .= '
'; $ret .= '
'; return $ret; } function installDBConf( $errorMessage = '') { global $aDbConf; $ret = ''; $ret .= '
Database
'; if( strlen( $errorMessage ) ) { $ret .= printInstallError( $errorMessage ); unset($_POST['db_name']); unset($_POST['db_user']); unset($_POST['db_password']); } $ret .= '
Please create a database and tell Dolphin about it.
'; $ret .= createTable( $aDbConf ); $ret .= '
   
'; foreach($_POST as $postKey => $postValue) { if( 'action' == $postKey || isset( $aDbConf[$postKey] ) ) { $ret .= ''; } else { $ret .= ''; } } $ret .= '
'; $ret .= '
'; return $ret; } function installStepFirst( $errorMessage = '' ) { global $aConf, $confFirst; /*-------------------------------*/ /*-------------------------------*/ $ret = ''; $ret .= '
Paths Check
'; if( strlen( $errorMessage ) ) { $ret .= printInstallError( $errorMessage ); } $ret .= '
'; $ret .= '
'; $ret .= '
'; $ret .= 'Dolphin checks general script paths.'; $ret .= '
'; $ret .= '
'; $ret .= ''; $ret .= createTable( $confFirst ); $ret .= ' '; $ret .= '
   
Check GD Installed '; if ( extension_loaded( 'gd' ) ) { $ret .= 'GD library installed'; } else { $ret .= 'GD library NOT installed'; } $ret .= '
'; $ret .= '
'; $ret .= '
'; $ret .= '
'; return $ret; } function PreInstall( $errorMessage = '' ) { global $aConf, $permFiles, $permDirectories, $aRayFolders, $aRayFiles; if ( ini_get('safe_mode') == 1 || ini_get('safe_mode') == 'On' ) { $errorMessage .= "Please turn off safe_mode in your php.ini file configuration"; } $ret = ''; $ret .= '
Permissions
'; if( strlen( $errorMessage ) ) { $ret .= printInstallError( $errorMessage ); } $ret .= '
'; $ret .= '
'; $ret .= '
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.
'; $ret .= '
'; $ret .= '
'; $i = 0; asort( $permDirectories ); asort( $permFiles ); foreach($permDirectories as $dir) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = 'background-color:#fff;'; } $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $i ++; } $ret .= ' '; $i = 0; foreach($permFiles as $file) { $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; $dir = preg_replace("/install\/(index\.php$)/","",$str); if( file_exists( $dir . $file) ) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = 'background-color:#fff;'; } $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $i ++; } } $ret .= ''; $i = 0; foreach($aRayFolders as $dir) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = 'background-color:#fff;'; } $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $i ++; } $ret .= ' '; $i = 0; foreach( $aRayFiles as $file ) { $str = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; $dir = preg_replace("/install\/(index\.php$)/","",$str); if( file_exists( $dir . $file) ) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = 'background-color:#fff;'; } $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $ret .= ''; $i ++; } } $ret .= '
Directories Current Level Desired Level
' . $dir . ''; if ( isFullAccessible('../'.$dir) ) { $ret .= '' . getPermissions( '../' . $dir ) . 'Writable'; } else { $ret .= '' . getPermissions( '../' . $dir ) . 'Non-writable'; } $ret .= ''; $ret .= '777Writable'; $ret .= '
Files Current Level Desired Level
' . $file . ''; if ( isRWAccessible('../'.$file) ) { $ret .= '' . getPermissions( '../' . $file ) . 'Writable'; } else { $ret .= '' . getPermissions( '../' . $file ) . 'Non-writable'; } $ret .= ''; $ret .= '666Writable'; $ret .= '
Ray Folders Current Level Desired Level
' . $dir . ''; if ( isFullAccessible('../'.$dir) ) { $ret .= '' . getPermissions( '../' . $dir ) . 'Writable'; } else { $ret .= '' . getPermissions( '../' . $dir ) . 'Non-writable'; } $ret .= ''; $ret .= '777Writable'; $ret .= '
Ray Files Current Level Desired Level
' . $file . ''; if ( strpos($file,'ffmpeg') === FALSE ) { if ( isRWAccessible('../'.$file) ) { $ret .= '' . getPermissions( '../' . $file ) . 'Writable'; } else { $ret .= '' . getPermissions( '../' . $file ) . 'Non-writable'; } } else { if ( isFullAccessible('../'.$file) ) { $ret .= '' . getPermissions( '../' . $file ) . 'Executable'; } else { $ret .= '' . getPermissions( '../' . $file ) . 'Unexecutable'; $bError = TRUE; } } $ret .= ''; if ( strpos($file,'ffmpeg') === FALSE ) { $ret .= '666Writable'; } else { $ret .= '777Executable'; } $ret .= '
'; $ret .= '
'; $ret .= '
'; return $ret; } function StartInstall() { global $aConf; $ret .= '
'; $ret .= 'Dolphin ' . $aConf['iVersion'] . '.' . $aConf['iPatch']; $ret .= '
'; $ret .= '
'; $ret .= 'Thank you for choosing Dolphin Smart Community Builder!
'; $ret .= 'Click the button below to create your own community.'; $ret .= '
'; $ret .= '
'; $ret .= '
'; $ret .= ''; $ret .= ''; $ret .= '
'; $ret .= '
'; return $ret; } function loadDolphin() { $ret .= ''; return $ret; } function PageHeader( $sAction = '', $sError = '' ) { global $aConf; $aActions = array( "startInstall" => "Dolphin Installation", "preInstall" => "Permissions", "step1" => "Paths", "step2" => "Database", "step3" => "Configuration", "step4" => "Cron Jobs", "step5" => "Permissions Reversal" ); if( !strlen( $sAction ) ) $sAction = "startInstall"; $ret = << Dolphin Smart Community Builder Installation Script
EOJ; if( $sAction == "step5" ) $ret .= '
'; else $ret .= '
'; $iCounterCurrent = 1; $iCounterActive = 1; foreach ( $aActions as $sActionKey => $sActionValue ) { if( $sAction != $sActionKey ) { $iCounterActive++; } else break; } if( strlen( $sError ) ) $iCounterActive--; foreach ( $aActions as $sActionKey => $sActionValue ) { if( $iCounterActive == $iCounterCurrent ) { $ret .= '
'; $ret .= $sActionValue; $ret .= '
'; } elseif( ($iCounterActive - $iCounterCurrent) == -1 ) { $ret .= ''; $ret .= '
'; $ret .= $sActionValue; $ret .= '
'; $ret .= ''; } elseif( ($iCounterActive - $iCounterCurrent) == 1 ) { $ret .= '
'; $ret .= $sActionValue; $ret .= '
'; $ret .= ''; } else { $ret .= '
'; $ret .= $sActionValue; $ret .= '
'; if( $sActionKey != "step5" ) $ret .= ''; } $iCounterCurrent++; } $ret .= '
'; return $ret; } function PageFooter( $sAction ) { $ret = '
'; if( $sAction ) $ret .= ' '; $ret .= '
'; return $ret; } function printInstallError( $text ) { $ret .= '
'; $ret .= $text; $ret .= '
'; return $ret; } function getPermissions( $filename ) { clearstatcache(); $perms = fileperms($filename); $ret = substr( decoct( $perms ), -3 ); return $ret; } function isFullAccessible($filename) { clearstatcache(); $perms = fileperms($filename); return ($perms & 0x0004 && $perms & 0x0002 && $perms & 0x0001 && !($perms & 0x0200)) ? true : false; } function isRWAccessible($filename) { clearstatcache(); $perms = fileperms($filename); return ($perms & 0x0004 && $perms & 0x0002) ? true : false; } function createTable( $arr ) { $ret = ''; $i = ''; foreach($arr as $key => $value) { if( ($i%2) == 0 ) { $styleAdd = 'background-color:#ede9e9;'; } else { $styleAdd = '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"; } } if ( $error_arr[$key] == 1 ) { $st_err = ' style="background-color:#FFDDDD;" '; } else $st_err = ''; $ret .= '
' . $value['name'] . '
Description:
Example:
' . $def_exp_text . '
' . $value['desc'] . '
' . $value['ex'] . '
'; $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 ) { $db['host'] = $_POST['db_host']; $db['sock'] = $_POST['db_sock']; $db['port'] = $_POST['db_port']; $db['user'] = $_POST['db_user']; $db['passwd'] = $_POST['db_password']; $db['db'] = $_POST['db_name']; $db['host'] .= ( $db['port'] ? ":{$db['port']}" : '' ) . ( $db['sock'] ? ":{$db['sock']}" : '' ); $pass = true; $errorMes = ''; $filename = $_POST['sql_file']; $link = @mysql_connect ( $db['host'], $db['user'], $db['passwd'] ); if( !$link ) return printInstallError( mysql_error() ); //return ("Could not connect to MySQL server: " . mysql_error().""); if (!mysql_select_db ($db['db'], $link)) return printInstallError( $db['db'] . ': ' . mysql_error() ); //return ("Could not select database '{$db['db']}': " . mysql_error().""); if ( !($f = fopen ( $filename, "r" )) ) return printInstallError( 'Could not open file with sql instructions:' . $filename ); //return ("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, $link ); if ( !$res ) $errorMes .= 'Error while executing: ' . $s_sql . '
' . mysql_error() . '
'; $s_sql = ""; } mysql_query ( "UPDATE `Admins` SET `Name`='{$sAdminName}', `Password`=md5( '{$sAdminPassword}' ) WHERE `Name`='admin'", $link ); if ( !$res ) $errorMes .= 'Error while executing: ' . $s_sql . '
' . mysql_error() . '
'; fclose($f); $enable_gd_value = extension_loaded( 'gd' ) ? 'on' : ''; if ( !(mysql_query ( "UPDATE `GlParams` SET `VALUE`='$enable_gd_value' WHERE `Name`='enable_gd'", $link ) ) ) $ret .= "Error: ".mysql_error()."
"; mysql_close($link); $errorMes .= $ret; if( strlen( $errorMes ) ) { return printInstallError( $errorMes ); } else { return 'done'; } // return $ret."Truncating tables finished.
"; } // set error reporting level error_reporting(E_ALL & ~E_NOTICE); ?>