From fd1712a4270a4349dc4e5d620e7779fcf7ed86cf Mon Sep 17 00:00:00 2001 From: spiderr Date: Wed, 2 Jun 2021 15:23:00 -0400 Subject: clean up install for new includes/classes directory pathing --- BitInstaller.php | 729 -------------------------------------- create_config_inc.php | 256 ------------- get_databases_inc.php | 68 ---- includes/classes/BitInstaller.php | 729 ++++++++++++++++++++++++++++++++++++++ includes/create_config_inc.php | 256 +++++++++++++ includes/get_databases_inc.php | 68 ++++ includes/install_admin_inc.php | 80 +++++ includes/install_inc.php | 182 ++++++++++ install.php | 2 +- install_admin_inc.php | 80 ----- install_database.php | 2 +- install_inc.php | 184 ---------- install_packages.php | 2 +- migrate.php | 2 +- migrate_database.php | 4 +- process_sql.php | 34 -- templates/install_packages.tpl | 2 +- upgrade.php | 4 +- 18 files changed, 1324 insertions(+), 1360 deletions(-) delete mode 100644 BitInstaller.php delete mode 100644 create_config_inc.php delete mode 100644 get_databases_inc.php create mode 100644 includes/classes/BitInstaller.php create mode 100644 includes/create_config_inc.php create mode 100644 includes/get_databases_inc.php create mode 100644 includes/install_admin_inc.php create mode 100644 includes/install_inc.php delete mode 100644 install_admin_inc.php delete mode 100644 install_inc.php delete mode 100644 process_sql.php diff --git a/BitInstaller.php b/BitInstaller.php deleted file mode 100644 index bd636f9..0000000 --- a/BitInstaller.php +++ /dev/null @@ -1,729 +0,0 @@ -getWebServerUid(); - } - - /** - * loadAllUpgradeFiles load upgrade files from all packages that are installed - * - * @access public - * @return void - */ - function loadAllUpgradeFiles() { - foreach( array_keys( $this->mPackages ) as $pkg ) { - $this->loadUpgradeFiles( $pkg ); - } - } - - /** - * Minimal login just for install in case users tables have been modified - * - * @access public - * @return void - */ - function login( $pLogin, $pPassword, $pChallenge=NULL, $pResponse=NULL ) { - global $gBitUser; - - $isvalid = false; - - $loginCol = strpos( $pLogin, '@' ) ? 'email' : 'login'; - - if( $gBitUser->validate( $pLogin, $pPassword, $pChallenge, $pResponse ) ) { - $userInfo = $gBitUser->getUserInfo( array( $loginCol => $pLogin ) ); - - if( $userInfo['user_id'] != ANONYMOUS_USER_ID ) { - // User is valid and not due to change pass.. - $gBitUser->mUserId = $userInfo['user_id']; - $gBitUser->mInfo = $userInfo; - $gBitUser->loadPermissions( TRUE ); - - $sessionId = session_id(); - $gBitUser->sendSessionCookie( $sessionId ); - $gBitUser->updateSession( $sessionId ); - } - } - - return $gBitUser->isAdmin(); - } - - /** - * loadUpgradeFiles This will load all files in the dir /admin/upgrades/.php with a version greater than the one installed - * - * @param array $pPackage - * @access public - * @return void - */ - function loadUpgradeFiles( $pPackage ) { - if( !empty( $pPackage )) { - $dir = constant( strtoupper( $pPackage )."_PKG_PATH" )."admin/upgrades/"; - if( $this->isPackageActive( $pPackage ) && is_dir( $dir ) && $upDir = opendir( $dir )) { - while( FALSE !== ( $file = readdir( $upDir ))) { - if( is_file( $dir.$file )) { - $upVersion = str_replace( ".php", "", $file ); - // we only want to load files of versions that are greater than is installed - if( $this->validateVersion( $upVersion ) && version_compare( $this->getVersion( $pPackage ), $upVersion, '<' )) { - include_once( $dir.$file ); - } - } - } - } - } - } - - /** - * registerPackageUpgrade - * - * @param array $pParams Hash of information about upgrade - * @param string $pParams[package] Name of package that is upgrading - * @param string $pParams[version] Version of this upgrade - * @param string $pParams[description] Description of what the upgrade does - * @param string $pParams[post_upgrade] Textual note of stuff that needs to be observed after the upgrade - * @param array $pUpgradeHash Hash of update rules. See existing upgrades on how this works. - * @access public - * @return void - */ - function registerPackageUpgrade( $pParams, $pUpgradeHash = array() ) { - if( $this->verifyPackageUpgrade( $pParams )) { - $this->registerPackageVersion( $pParams['package'], $pParams['version'] ); - $this->mPackageUpgrades[$pParams['package']][$pParams['version']] = $pParams; - $this->mPackageUpgrades[$pParams['package']][$pParams['version']]['upgrade'] = $pUpgradeHash; - - // sort everything for a nice display - ksort( $this->mPackageUpgrades ); - uksort( $this->mPackageUpgrades[$pParams['package']], 'version_compare' ); - } - } - - /** - * verifyPackageUpgrade - * - * @param array $pParams Hash of information about upgrade - * @param string $pParams[package] Name of package that is upgrading - * @param string $pParams[version] Version of this upgrade - * @param string $pParams[description] Description of what the upgrade does - * @param string $pParams[post_upgrade] Textual note of stuff that needs to be observed after the upgrade - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function verifyPackageUpgrade( &$pParams ) { - if( empty( $pParams['package'] )) { - $this->mErrors['package'] = "Please provide a valid package name."; - } else { - $pParams['package'] = strtolower( $pParams['package'] ); - } - - if( empty( $pParams['version'] ) || !$this->validateVersion( $pParams['version'] )) { - $this->mErrors['version'] = "Please provide a valid version number."; - } elseif( empty( $this->mErrors ) && !empty( $this->mPackageUpgrades[$pParams['package']][$pParams['version']] )) { - $this->mErrors['version'] = "Please make sure you use a unique version number to register your new database changes."; - } - - if( empty( $pParams['description'] )) { - $this->mErrors['description'] = "Please add a brief description of what this upgrade is all about."; - } - - // since this should only show up when devs are working, we'll simply display the output: - if( !empty( $this->mErrors )) { - vd( $this->mErrors ); - bt(); - } - - return( count( $this->mErrors ) == 0 ); - } - - /** - * registerUpgrade - * - * @param array $pPackage - * @param array $pUpgradeHash - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function registerUpgrade( $pPackage, $pUpgradeHash ) { - $pPackage = strtolower( $pPackage ); // lower case for uniformity - if( !empty( $pUpgradeHash ) ) { - $this->mUpgrades[$pPackage] = $pUpgradeHash; - } - } - - /** - * display - * - * @param string $pTemplate - * @param string $pBrowserTitle - * @access public - * @return void - */ - function in_display( $pPackage, $pTemplate ) { - header( 'Content-Type: text/html; charset=utf-8' ); - if( ini_get( 'safe_mode' ) && ini_get( 'safe_mode_gid' )) { - umask( 0007 ); - } - // force the session to close *before* displaying. Why? Note this very important comment from http://us4.php.net/exec - session_write_close(); - - if( !empty( $pPackage ) ) { - $this->setBrowserTitle( $pPackage ); - } - global $gBitSmarty; - $gBitSmarty->verifyCompileDir(); - $gBitSmarty->display( $pTemplate ); - } - - /** - * isInstalled - * - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function isInstalled( $pPackage = 'kernel' ) { - return( !empty( $this->mPackages[$pPackage]['installed'] )); - } - - /** - * getWebServerUid set global wwwuser and wwwgroup - * - * @access public - * @return void - */ - function getWebServerUid() { - global $wwwuser, $wwwgroup; - $wwwuser = $wwwgroup = ''; - - if( is_windows() ) { - $wwwuser = 'SYSTEM'; - $wwwgroup = 'SYSTEM'; - } - - if( function_exists( 'posix_getuid' )) { - $user = @posix_getpwuid( @posix_getuid() ); - $group = @posix_getpwuid( @posix_getgid() ); - $wwwuser = $user ? $user['name'] : false; - $wwwgroup = $group ? $group['name'] : false; - } - - if( !$wwwuser ) { - $wwwuser = 'nobody (or the user account the web server is running under)'; - } - - if( !$wwwgroup ) { - $wwwgroup = 'nobody (or the group account the web server is running under)'; - } - } - - /** - * getTablePrefix - * - * @access public - * @return database adjusted table prefix - */ - function getTablePrefix() { - global $gBitDbType; - $ret = BIT_DB_PREFIX; - // avoid errors in ADONewConnection() (wrong database driver etc...) - // strip out some schema stuff - switch( $gBitDbType ) { - case "sybase": - // avoid database change messages - ini_set('sybct.min_server_severity', '11'); - break; - case "oci8": - case "postgres": - // Do a little prep work for postgres, no break, cause we want default case too - if( preg_match( '/\./', $ret ) ) { - // Assume we want to dump in a schema, so set the search path and nuke the prefix here. - $schema = preg_replace( '/`/', '"', substr( $ret, 0, strpos( $ret, '.' )) ); - $quote = strpos( $schema, '"' ); - if( $quote !== 0 ) { - $schema = '"'.$schema; - } - // set scope to current schema - $result = $this->mDb->query( "SET search_path TO $schema" ); - // return everything after the prefix - $ret = substr( BIT_DB_PREFIX, strrpos( BIT_DB_PREFIX, '`' ) + 1 ); - } - break; - } - return $ret; - } - - /** - * upgradePackage - * - * @param array $pPackage - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function upgradePackage( $pPackage ) { - if( !empty( $pPackage ) && !empty( $this->mUpgrades[$pPackage] )) { - return( $this->applyUpgrade( $pPackage, $this->mUpgrades[$pPackage] )); - } - } - - /** - * upgradePackageVersion - * - * @param array $pPackage - * @param array $pVersion - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function upgradePackageVersions( $pPackage ) { - if( !empty( $pPackage ) && !empty( $this->mPackageUpgrades[$pPackage] )) { - // make sure everything is in the right order - uksort( $this->mPackageUpgrades[$pPackage], 'upgrade_version_sort' ); - - foreach( array_keys( $this->mPackageUpgrades[$pPackage] ) as $version ) { - // version we are upgrading from - $this->mPackageUpgrades[$pPackage][$version]['from_version'] = $this->getVersion( $pPackage ); - - // apply upgrade - $errors[$version] = $this->applyUpgrade( $pPackage, $this->mPackageUpgrades[$pPackage][$version]['upgrade'] ); - if( !empty( $errors[$version] )) { - return $errors; - } else { - // if the upgrade ended without incidence, we store the package version. - // this way any successfully applied upgrade can only be applied once. - $this->storeVersion( $pPackage, $version ); - } - } - } - - return NULL; - } - - /** - * applyUpgrade - * - * @param array $pPackage - * @param array $pUpgradeHash - * @access public - * @return empty array on success, array with errors on failure - */ - function applyUpgrade( $pPackage, $pUpgradeHash ) { - global $gBitDb, $gBitDbType; - $ret = array(); - - if( !empty( $pUpgradeHash ) && is_array( $pUpgradeHash )) { - // set table prefixes and handle special case of sequence prefixes - $schemaQuote = strrpos( BIT_DB_PREFIX, '`' ); - $sequencePrefix = ( $schemaQuote ? substr( BIT_DB_PREFIX, $schemaQuote + 1 ) : BIT_DB_PREFIX ); - $tablePrefix = $this->getTablePrefix(); - $dict = NewDataDictionary( $gBitDb->mDb ); - $failedcommands = array(); - - for( $i = 0; $i < count( $pUpgradeHash ); $i++ ) { - if( !is_array( $pUpgradeHash[$i] ) ) { - vd( "[$pPackage][$i] is NOT an array" ); - vd( $pUpgradeHash[$i] ); - bt(); - die; - } - - $type = key( $pUpgradeHash[$i] ); - $step = &$pUpgradeHash[$i][$type]; - - switch( $type ) { - case 'DATADICT': - for( $j = 0; $j < count( $step ); $j++ ) { - $dd = &$step[$j]; - switch( key( $dd ) ) { - case 'CREATE': - foreach( $dd as $create ) { - foreach( array_keys( $create ) as $tableName ) { - $completeTableName = $tablePrefix.$tableName; - $sql = $dict->CreateTableSQL( $completeTableName, $create[$tableName], 'REPLACE' ); - if( $sql && ( $dict->ExecuteSQLArray( $sql, FALSE ) > 0 ) ) { - } else { - $errors[] = 'Failed to create '.$completeTableName; - $failedcommands[] = implode( " ", $sql ); - } - } - } - break; - case 'ALTER': - foreach( $dd as $alter ) { - foreach( array_keys( $alter ) as $tableName ) { - $completeTableName = $tablePrefix.$tableName; - $this->mDb->convertQuery( $completeTableName ); - foreach( $alter[$tableName] as $from => $flds ) { - if( is_string( $flds )) { - $sql = $dict->ChangeTableSQL( $completeTableName, $flds ); - } else { - $sql = $dict->ChangeTableSQL( $completeTableName, array( $flds )); - } - - if( $sql ) { - for( $sqlIdx = 0; $sqlIdx < count( $sql ); $sqlIdx++ ) { - $this->mDb->convertQuery( $sqlFoo ); - } - } - - if( $sql && $dict->ExecuteSQLArray( $sql, FALSE ) > 0 ) { - } else { - $errors[] = 'Failed to alter '.$completeTableName.' -> '.$alter[$tableName]; - $failedcommands[] = implode( " ", $sql ); - } - } - } - } - break; - case 'RENAMETABLE': - foreach( $dd as $rename ) { - foreach( array_keys( $rename ) as $tableName ) { - $completeTableName = $tablePrefix.$tableName; - if( $sql = @$dict->RenameTableSQL( $completeTableName, $tablePrefix.$rename[$tableName] ) ) { - foreach( $sql AS $query ) { - $this->mDb->query( $query ); - } - } else { - $errors[] = 'Failed to rename table '.$completeTableName.'.'.$rename[$tableName][0].' to '.$rename[$tableName][1]; - $failedcommands[] = implode( " ", $sql ); - } - } - } - break; - case 'RENAMECOLUMN': - foreach( $dd as $rename ) { - foreach( array_keys( $rename ) as $tableName ) { - $completeTableName = $tablePrefix.$tableName; - foreach( $rename[$tableName] as $from => $flds ) { - // MySQL needs the fields string, others do not. - // see http://phplens.com/lens/adodb/docs-datadict.htm - $to = substr( $flds, 0, strpos( $flds, ' ') ); - if( $sql = @$dict->RenameColumnSQL( $completeTableName, $from, $to, $flds ) ) { - foreach( $sql AS $query ) { - $this->mDb->query( $query ); - } - } else { - $errors[] = 'Failed to rename column '.$completeTableName.'.'.$rename[$tableName][0].' to '.$rename[$tableName][1]; - $failedcommands[] = implode( " ", $sql ); - } - } - } - } - break; - case 'CREATESEQUENCE': - foreach( $dd as $create ) { - foreach( $create as $sequence ) { - $this->mDb->CreateSequence( $sequencePrefix.$sequence ); - } - } - break; - case 'RENAMESEQUENCE': - foreach( $dd as $rename ) { - foreach( $rename as $from => $to ) { - if( $gBitDbType != 'mysql' || $this->mDb->tableExists( $tablePrefix.$from ) ) { - if( $id = $this->mDb->GenID( $from ) ) { - $this->mDb->DropSequence( $sequencePrefix.$from ); - $this->mDb->CreateSequence( $sequencePrefix.$to, $id ); - } else { - $errors[] = 'Failed to rename sequence '.$sequencePrefix.$from.' to '.$sequencePrefix.$to; - $failedcommands[] = implode( " ", $sql ); - } - } else { - $this->mDb->CreateSequence( $sequencePrefix.$to, $pUpgradeHash['sequences'][$to]['start'] ); - } - } - } - break; - case 'DROPSEQUENCE': - foreach( $dd as $drop ) { - foreach( $drop as $sequence ) { - $this->mDb->DropSequence( $sequencePrefix.$sequence ); - } - } - break; - case 'DROPCOLUMN': - foreach( $dd as $drop ) { - foreach( array_keys( $drop ) as $tableName ) { - $completeTableName = $tablePrefix.$tableName; - foreach( $drop[$tableName] as $col ) { - if( $sql = $dict->DropColumnSQL( $completeTableName, $col ) ) { - foreach( $sql AS $query ) { - $this->mDb->query( $query ); - } - } else { - $errors[] = 'Failed to drop column '.$completeTableName; - $failedcommands[] = implode( " ", $sql ); - } - } - } - } - break; - case 'DROPTABLE': - foreach( $dd as $drop ) { - foreach( $drop as $tableName ) { - $completeTableName = $tablePrefix.$tableName; - $sql = $dict->DropTableSQL( $completeTableName ); - if( $sql && $dict->ExecuteSQLArray( $sql ) > 0 ) { - } else { - $errors[] = 'Failed to drop table '.$completeTableName; - $failedcommands[] = implode( " ", $sql ); - } - } - } - break; - case 'CREATEINDEX': - foreach( $dd as $indices ) { - foreach( array_keys( $indices ) as $index ) { - $completeTableName = $tablePrefix.$indices[$index][0]; - if( $sql = $dict->CreateIndexSQL( $index, $completeTableName, $indices[$index][1], $indices[$index][2] ) ) { - foreach( $sql AS $query ) { - $this->mDb->query( $query ); - } - } else { - $errors[] = 'Failed to create index '.$index; - $failedcommands[] = implode( " ", $sql ); - } - } - } - break; - } - } - if( !empty( $sql ) ) $sql = null; - break; - case 'QUERY': - uksort( $step, 'upgrade_query_sort' ); - foreach( array_keys( $step ) as $dbType ) { - if( $dbType == 'MYSQL' && preg_match( '/mysql/', $gBitDbType )) { - $sql = $step[$dbType]; - unset( $step['SQL92'] ); - } elseif( $dbType == 'PGSQL' && preg_match( '/postgres/', $gBitDbType )) { - $sql = $step[$dbType]; - unset( $step['SQL92'] ); - } elseif( $dbType == 'SQL92' && !empty( $step['SQL92'] )) { - $sql = $step[$dbType]; - } - - if( !empty( $sql ) ) { - foreach( $sql as $query ) { - if( !$result = $this->mDb->query( $query )) { - $errors[] = 'Failed to execute SQL query'; - $failedcommands[] = implode( " ", $sql ); - } - } - $sql = NULL; - } - } - break; - case 'PHP': - eval( $step ); - break; - case 'POST': - $postSql[] = $step; - break; - } - } - - // turn on features that are turned on - // legacy stuff - if( $this->isFeatureActive( 'feature_'.$pPackage )) { - $this->storeConfig( 'package_'.$pPackage, 'y', KERNEL_PKG_NAME ); - } - - if( !empty( $failedcommands )) { - $ret['errors'] = $errors; - $ret['failedcommands'] = $failedcommands; - } - } - - return $ret; - } - - /** - * identifyBlobs - * - * @param array $result - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function identifyBlobs( $result ) { - $blobs = array(); - //echo "FieldCount: ".$result->FieldCount()."\n"; - for( $i = 0; $i < $result->FieldCount(); $i++ ) { - $field = $result->FetchField($i); - //echo $i."-".$field->name."-".$result->MetaType($field->type)."-".$field->max_length."\n"; - // check for blobs - if(( $result->MetaType( $field->type ) == 'B' ) || ( $result->MetaType( $field->type )=='X' && $field->max_length >= 16777215 )) - $blobs[] = $field->name; - } - return $blobs; - } - - /** - * convertBlobs enumerate blob fields and encoded - * - * @param string $gDb - * @param array $res - * @param array $blobs - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function convertBlobs( $gDb, &$res, $blobs ) { - foreach( $blobs as $blob ) { - $res[$blob] = $gDb->dbByteEncode( $res[$blob] ); - } - } - - /** - * hasAdminBlock - * - * @access public - * @return TRUE on success, FALSE on failure - * @deprecated i think this isn't used any more - */ - function hasAdminBlock() { - deprecated( "i think this isn't used anymore." ); - global $gBitUser; - // Let's find out if we are have admin perm or a root user - $ret = TRUE; - if( empty( $gBitUser ) || $gBitUser->isAdmin() ) { - $ret = FALSE; - } else { - // let's try to load up user_id - if successful, we know we have one. - $rootUser = new BitPermUser( 1 ); - $rootUser->load(); - if( !$rootUser->isValid() ) { - $ret = FALSE; - } - } - return $ret; - } -} - -/** - * check_session_save_path - * - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ -function check_session_save_path() { - global $errors; - if( ini_get( 'session.save_handler' ) == 'files' ) { - $save_path = ini_get( 'session.save_path' ); - - if( !is_dir( $save_path )) { - $errors .= "The directory '$save_path' does not exist or PHP is not allowed to access it (check session.save_path or open_basedir entries in php.ini).\n"; - } elseif( !bw_is_writeable( $save_path )) { - $errors .= "The directory '$save_path' is not writeable.\n"; - } - - if( $errors ) { - $save_path = static::tempdir(); - - if (is_dir($save_path) && bw_is_writeable($save_path)) { - ini_set('session.save_path', $save_path); - - $errors = ''; - } - } - } -} - -/** - * makeConnection - * - * @param string $gBitDbType - * @param string $gBitDbHost - * @param string $gBitDbUser - * @param string $gBitDbPassword - * @param string $gBitDbName - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ -function makeConnection( $gBitDbType, $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName ) { - $gDb = &ADONewConnection( $gBitDbType ); - if( !$gDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName )) { - echo $gDb->ErrorMsg()."\n"; - die; - } - global $gBitDbCaseSensitivity; - $gDb->mCaseSensitive = $gBitDbCaseSensitivity; - $gDb->SetFetchMode( ADODB_FETCH_ASSOC ); - return $gDb; -} - -/** - * upgrade_package_sort sort packages before they are upgraded - * - * @param string $a - * @param string $b - * @access public - * @return numeric sort direction - */ -function upgrade_package_sort( $a, $b ) { - global $gBitInstaller; - $aa = $gBitInstaller->mPackages[$a]; - $bb = $gBitInstaller->mPackages[$b]; - if(( $aa['required'] && $bb['required'] ) || ( !$aa['required'] && !$bb['required'] )) { - return 0; - } elseif( $aa['required'] && !$bb['required'] ) { - return -1; - } elseif( !$aa['required'] && $bb['required'] ) { - return 1; - } -} - -/** - * upgrade_version_sort sort upgrades based on version number - * - * @param string $a - * @param string $b - * @access public - * @return numeric sort direction - */ -function upgrade_version_sort( $a, $b ) { - return version_compare( $a, $b, '>' ); -} - -/** - * upgrade_query_sort sort queries that SQL92 queries are called last - * - * @param string $a - * @param string $b - * @access public - * @return numeric sort direction - */ -function upgrade_query_sort( $a, $b ) { - if( $a == 'SQL92' ) { - return 1; - } elseif( $b == 'SQL92' ) { - return -1; - } else { - return 0; - } -} - -?> diff --git a/create_config_inc.php b/create_config_inc.php deleted file mode 100644 index 9ae113c..0000000 --- a/create_config_inc.php +++ /dev/null @@ -1,256 +0,0 @@ - array( 'width' => 1024, 'height' => 1024 ), - 'large' => array( 'width' => 800, 'height' => 800 ), - 'medium' => array( 'width' => 400, 'height' => 400 ), - 'small' => array( 'width' => 160, 'height' => 160 ), - 'avatar' => array( 'width' => 100, 'height' => 100 ), - 'icon' => array( 'width' => 48, 'height' => 48 ), -); -*/"; - - if( substr( PHP_OS, 0, 3 ) == 'WIN' ) { - $filetowrite .= " - - -// Insert the absolute path to your php magic database. This is required for -// us to check and verify the mime type of uploaded files. This setting is only -// required on windows machines. -//define( 'PHP_MAGIC_PATH', 'C:\\Program Files\\PHP\\extras\\magic.mime' );"; - } - - if( defined( 'ROLE_MODEL' )) { - $filetowrite .= " - -define( 'LIBERTY_DEFAULT_MIME_HANDLER', 'mimeflatdefault' );"; - } - - $filetowrite .= " - - - /******************************************************\ - *************** Debugging Options **************** - \******************************************************/ - -// If you wish to force compiling of every page, you can set the next setting to -// TRUE. this will, however, severly impact performance since every page that is -// generated is generated afresh and the cache is recreated every time. -\$smarty_force_compile = FALSE; - - -// Setting TEMPLATE_DEBUG = TRUE will output in your -// templates, which will allow you to track all used templates in the HTML source -// of the page. This will also disable stripping of whitespace making it easier to -// read the templates. You will only see the effect of the strip changes by -// clearing out your cache or setting \$smarty_force_compile = TRUE; -// Note: be sure to set this to FALSE and clear out the cache once done since it -// will increase the page size by at least 10%. -//define( 'TEMPLATE_DEBUG', TRUE ); - -// If you want to go a step further with template debugging then this enables -// smarty's debugging console. A popup with a dump of all of the vars the -// template(s) have been passed. -\$smarty_debugging = FALSE; - - -// This statement will enable you to view all database queries made -//\$gDebug = TRUE; - - -// This will turn on ADODB performance monitoring and log all queries. This should -// not be enabled except when doing query analysis due to an overall performance -// drop. see kernel/admin/db_performance.php for statistics -//define( 'DB_PERFORMANCE_STATS', TRUE ); - -?>"; - fwrite( $fw, $filetowrite ); - fclose( $fw ); - } else { - print "UNABLE TO WRITE TO ".realpath( $config_file ); - } -} - -?> diff --git a/get_databases_inc.php b/get_databases_inc.php deleted file mode 100644 index 22f6310..0000000 --- a/get_databases_inc.php +++ /dev/null @@ -1,68 +0,0 @@ -assign( 'fbpath', $fbpath ); - if ( empty($gBitDbName) ) { $gBitDbName = 'bitweaver'; } - $gBitDbCaseSensitivity = FALSE; - if ( empty($gBitDbUser) ) { - $gBitDbUser = 'SYSDBA'; - $gBitDbPassword = 'masterkey'; - } -} -if( function_exists( 'sqlite_open' ) ) { - $dbtodsn['sqlite'] = 'SQLLite'; -} -$gBitSmarty->assignByRef('dbservers', $dbtodsn); - -$gBitSmarty->assign( 'gBitDbType', $gBitDbType ); -$gBitSmarty->assign( 'gBitDbHost', $gBitDbHost ); -$gBitSmarty->assign( 'gBitDbUser', $gBitDbUser ); -$gBitSmarty->assign( 'gBitDbPassword', $gBitDbPassword ); -$gBitSmarty->assign( 'gBitDbName', $gBitDbName ); -$gBitSmarty->assign( 'gBitDbCaseSensitivity', $gBitDbCaseSensitivity ); -$gBitSmarty->assign( 'db_prefix_bit', BIT_DB_PREFIX ); -$gBitSmarty->assign( 'bit_root_url', $bit_root_url ); -if( defined( 'AUTO_BUG_SUBMIT' ) ) { - $gBitSmarty->assign( 'auto_bug_submit', AUTO_BUG_SUBMIT ); -} - -$gBitSmarty->assign( 'gBitDbPassword_input', $gBitDbPassword ); -$gBitSmarty->assign( 'gBitDbPassword_print', preg_replace( '/./','•',$gBitDbPassword ) ); -?> diff --git a/includes/classes/BitInstaller.php b/includes/classes/BitInstaller.php new file mode 100644 index 0000000..7795403 --- /dev/null +++ b/includes/classes/BitInstaller.php @@ -0,0 +1,729 @@ +getWebServerUid(); + } + + /** + * loadAllUpgradeFiles load upgrade files from all packages that are installed + * + * @access public + * @return void + */ + function loadAllUpgradeFiles() { + foreach( array_keys( $this->mPackages ) as $pkg ) { + $this->loadUpgradeFiles( $pkg ); + } + } + + /** + * Minimal login just for install in case users tables have been modified + * + * @access public + * @return void + */ + function login( $pLogin, $pPassword, $pChallenge=NULL, $pResponse=NULL ) { + global $gBitUser; + + $isvalid = false; + + $loginCol = strpos( $pLogin, '@' ) ? 'email' : 'login'; + + if( $gBitUser->validate( $pLogin, $pPassword, $pChallenge, $pResponse ) ) { + $userInfo = $gBitUser->getUserInfo( array( $loginCol => $pLogin ) ); + + if( $userInfo['user_id'] != ANONYMOUS_USER_ID ) { + // User is valid and not due to change pass.. + $gBitUser->mUserId = $userInfo['user_id']; + $gBitUser->mInfo = $userInfo; + $gBitUser->loadPermissions( TRUE ); + + $sessionId = session_id(); + $gBitUser->sendSessionCookie( $sessionId ); + $gBitUser->updateSession( $sessionId ); + } + } + + return $gBitUser->isAdmin(); + } + + /** + * loadUpgradeFiles This will load all files in the dir /admin/upgrades/.php with a version greater than the one installed + * + * @param array $pPackage + * @access public + * @return void + */ + function loadUpgradeFiles( $pPackage ) { + if( !empty( $pPackage )) { + $dir = constant( strtoupper( $pPackage )."_PKG_PATH" )."admin/upgrades/"; + if( $this->isPackageActive( $pPackage ) && is_dir( $dir ) && $upDir = opendir( $dir )) { + while( FALSE !== ( $file = readdir( $upDir ))) { + if( is_file( $dir.$file )) { + $upVersion = str_replace( ".php", "", $file ); + // we only want to load files of versions that are greater than is installed + if( $this->validateVersion( $upVersion ) && version_compare( $this->getVersion( $pPackage ), $upVersion, '<' )) { + include_once( $dir.$file ); + } + } + } + } + } + } + + /** + * registerPackageUpgrade + * + * @param array $pParams Hash of information about upgrade + * @param string $pParams[package] Name of package that is upgrading + * @param string $pParams[version] Version of this upgrade + * @param string $pParams[description] Description of what the upgrade does + * @param string $pParams[post_upgrade] Textual note of stuff that needs to be observed after the upgrade + * @param array $pUpgradeHash Hash of update rules. See existing upgrades on how this works. + * @access public + * @return void + */ + function registerPackageUpgrade( $pParams, $pUpgradeHash = array() ) { + if( $this->verifyPackageUpgrade( $pParams )) { + $this->registerPackageVersion( $pParams['package'], $pParams['version'] ); + $this->mPackageUpgrades[$pParams['package']][$pParams['version']] = $pParams; + $this->mPackageUpgrades[$pParams['package']][$pParams['version']]['upgrade'] = $pUpgradeHash; + + // sort everything for a nice display + ksort( $this->mPackageUpgrades ); + uksort( $this->mPackageUpgrades[$pParams['package']], 'version_compare' ); + } + } + + /** + * verifyPackageUpgrade + * + * @param array $pParams Hash of information about upgrade + * @param string $pParams[package] Name of package that is upgrading + * @param string $pParams[version] Version of this upgrade + * @param string $pParams[description] Description of what the upgrade does + * @param string $pParams[post_upgrade] Textual note of stuff that needs to be observed after the upgrade + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function verifyPackageUpgrade( &$pParams ) { + if( empty( $pParams['package'] )) { + $this->mErrors['package'] = "Please provide a valid package name."; + } else { + $pParams['package'] = strtolower( $pParams['package'] ); + } + + if( empty( $pParams['version'] ) || !$this->validateVersion( $pParams['version'] )) { + $this->mErrors['version'] = "Please provide a valid version number."; + } elseif( empty( $this->mErrors ) && !empty( $this->mPackageUpgrades[$pParams['package']][$pParams['version']] )) { + $this->mErrors['version'] = "Please make sure you use a unique version number to register your new database changes."; + } + + if( empty( $pParams['description'] )) { + $this->mErrors['description'] = "Please add a brief description of what this upgrade is all about."; + } + + // since this should only show up when devs are working, we'll simply display the output: + if( !empty( $this->mErrors )) { + vd( $this->mErrors ); + bt(); + } + + return( count( $this->mErrors ) == 0 ); + } + + /** + * registerUpgrade + * + * @param array $pPackage + * @param array $pUpgradeHash + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function registerUpgrade( $pPackage, $pUpgradeHash ) { + $pPackage = strtolower( $pPackage ); // lower case for uniformity + if( !empty( $pUpgradeHash ) ) { + $this->mUpgrades[$pPackage] = $pUpgradeHash; + } + } + + /** + * display + * + * @param string $pTemplate + * @param string $pBrowserTitle + * @access public + * @return void + */ + function in_display( $pPackage, $pTemplate ) { + header( 'Content-Type: text/html; charset=utf-8' ); + if( ini_get( 'safe_mode' ) && ini_get( 'safe_mode_gid' )) { + umask( 0007 ); + } + // force the session to close *before* displaying. Why? Note this very important comment from http://us4.php.net/exec + session_write_close(); + + if( !empty( $pPackage ) ) { + $this->setBrowserTitle( $pPackage ); + } + global $gBitSmarty; + $gBitSmarty->verifyCompileDir(); + $gBitSmarty->display( $pTemplate ); + } + + /** + * isInstalled + * + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function isInstalled( $pPackage = 'kernel' ) { + return( !empty( $this->mPackages[$pPackage]['installed'] )); + } + + /** + * getWebServerUid set global wwwuser and wwwgroup + * + * @access public + * @return void + */ + function getWebServerUid() { + global $wwwuser, $wwwgroup; + $wwwuser = $wwwgroup = ''; + + if( is_windows() ) { + $wwwuser = 'SYSTEM'; + $wwwgroup = 'SYSTEM'; + } + + if( function_exists( 'posix_getuid' )) { + $user = @posix_getpwuid( @posix_getuid() ); + $group = @posix_getpwuid( @posix_getgid() ); + $wwwuser = $user ? $user['name'] : false; + $wwwgroup = $group ? $group['name'] : false; + } + + if( !$wwwuser ) { + $wwwuser = 'nobody (or the user account the web server is running under)'; + } + + if( !$wwwgroup ) { + $wwwgroup = 'nobody (or the group account the web server is running under)'; + } + } + + /** + * getTablePrefix + * + * @access public + * @return database adjusted table prefix + */ + function getTablePrefix() { + global $gBitDbType; + $ret = BIT_DB_PREFIX; + // avoid errors in ADONewConnection() (wrong database driver etc...) + // strip out some schema stuff + switch( $gBitDbType ) { + case "sybase": + // avoid database change messages + ini_set('sybct.min_server_severity', '11'); + break; + case "oci8": + case "postgres": + // Do a little prep work for postgres, no break, cause we want default case too + if( preg_match( '/\./', $ret ) ) { + // Assume we want to dump in a schema, so set the search path and nuke the prefix here. + $schema = preg_replace( '/`/', '"', substr( $ret, 0, strpos( $ret, '.' )) ); + $quote = strpos( $schema, '"' ); + if( $quote !== 0 ) { + $schema = '"'.$schema; + } + // set scope to current schema + $result = $this->mDb->query( "SET search_path TO $schema" ); + // return everything after the prefix + $ret = substr( BIT_DB_PREFIX, strrpos( BIT_DB_PREFIX, '`' ) + 1 ); + } + break; + } + return $ret; + } + + /** + * upgradePackage + * + * @param array $pPackage + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function upgradePackage( $pPackage ) { + if( !empty( $pPackage ) && !empty( $this->mUpgrades[$pPackage] )) { + return( $this->applyUpgrade( $pPackage, $this->mUpgrades[$pPackage] )); + } + } + + /** + * upgradePackageVersion + * + * @param array $pPackage + * @param array $pVersion + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function upgradePackageVersions( $pPackage ) { + if( !empty( $pPackage ) && !empty( $this->mPackageUpgrades[$pPackage] )) { + // make sure everything is in the right order + uksort( $this->mPackageUpgrades[$pPackage], 'upgrade_version_sort' ); + + foreach( array_keys( $this->mPackageUpgrades[$pPackage] ) as $version ) { + // version we are upgrading from + $this->mPackageUpgrades[$pPackage][$version]['from_version'] = $this->getVersion( $pPackage ); + + // apply upgrade + $errors[$version] = $this->applyUpgrade( $pPackage, $this->mPackageUpgrades[$pPackage][$version]['upgrade'] ); + if( !empty( $errors[$version] )) { + return $errors; + } else { + // if the upgrade ended without incidence, we store the package version. + // this way any successfully applied upgrade can only be applied once. + $this->storeVersion( $pPackage, $version ); + } + } + } + + return NULL; + } + + /** + * applyUpgrade + * + * @param array $pPackage + * @param array $pUpgradeHash + * @access public + * @return empty array on success, array with errors on failure + */ + function applyUpgrade( $pPackage, $pUpgradeHash ) { + global $gBitDb, $gBitDbType; + $ret = array(); + + if( !empty( $pUpgradeHash ) && is_array( $pUpgradeHash )) { + // set table prefixes and handle special case of sequence prefixes + $schemaQuote = strrpos( BIT_DB_PREFIX, '`' ); + $sequencePrefix = ( $schemaQuote ? substr( BIT_DB_PREFIX, $schemaQuote + 1 ) : BIT_DB_PREFIX ); + $tablePrefix = $this->getTablePrefix(); + $dict = NewDataDictionary( $gBitDb->mDb ); + $failedcommands = array(); + + for( $i = 0; $i < count( $pUpgradeHash ); $i++ ) { + if( !is_array( $pUpgradeHash[$i] ) ) { + vd( "[$pPackage][$i] is NOT an array" ); + vd( $pUpgradeHash[$i] ); + bt(); + die; + } + + $type = key( $pUpgradeHash[$i] ); + $step = &$pUpgradeHash[$i][$type]; + + switch( $type ) { + case 'DATADICT': + for( $j = 0; $j < count( $step ); $j++ ) { + $dd = &$step[$j]; + switch( key( $dd ) ) { + case 'CREATE': + foreach( $dd as $create ) { + foreach( array_keys( $create ) as $tableName ) { + $completeTableName = $tablePrefix.$tableName; + $sql = $dict->CreateTableSQL( $completeTableName, $create[$tableName], 'REPLACE' ); + if( $sql && ( $dict->ExecuteSQLArray( $sql, FALSE ) > 0 ) ) { + } else { + $errors[] = 'Failed to create '.$completeTableName; + $failedcommands[] = implode( " ", $sql ); + } + } + } + break; + case 'ALTER': + foreach( $dd as $alter ) { + foreach( array_keys( $alter ) as $tableName ) { + $completeTableName = $tablePrefix.$tableName; + $this->mDb->convertQuery( $completeTableName ); + foreach( $alter[$tableName] as $from => $flds ) { + if( is_string( $flds )) { + $sql = $dict->ChangeTableSQL( $completeTableName, $flds ); + } else { + $sql = $dict->ChangeTableSQL( $completeTableName, array( $flds )); + } + + if( $sql ) { + for( $sqlIdx = 0; $sqlIdx < count( $sql ); $sqlIdx++ ) { + $this->mDb->convertQuery( $sqlFoo ); + } + } + + if( $sql && $dict->ExecuteSQLArray( $sql, FALSE ) > 0 ) { + } else { + $errors[] = 'Failed to alter '.$completeTableName.' -> '.$alter[$tableName]; + $failedcommands[] = implode( " ", $sql ); + } + } + } + } + break; + case 'RENAMETABLE': + foreach( $dd as $rename ) { + foreach( array_keys( $rename ) as $tableName ) { + $completeTableName = $tablePrefix.$tableName; + if( $sql = @$dict->RenameTableSQL( $completeTableName, $tablePrefix.$rename[$tableName] ) ) { + foreach( $sql AS $query ) { + $this->mDb->query( $query ); + } + } else { + $errors[] = 'Failed to rename table '.$completeTableName.'.'.$rename[$tableName][0].' to '.$rename[$tableName][1]; + $failedcommands[] = implode( " ", $sql ); + } + } + } + break; + case 'RENAMECOLUMN': + foreach( $dd as $rename ) { + foreach( array_keys( $rename ) as $tableName ) { + $completeTableName = $tablePrefix.$tableName; + foreach( $rename[$tableName] as $from => $flds ) { + // MySQL needs the fields string, others do not. + // see http://phplens.com/lens/adodb/docs-datadict.htm + $to = substr( $flds, 0, strpos( $flds, ' ') ); + if( $sql = @$dict->RenameColumnSQL( $completeTableName, $from, $to, $flds ) ) { + foreach( $sql AS $query ) { + $this->mDb->query( $query ); + } + } else { + $errors[] = 'Failed to rename column '.$completeTableName.'.'.$rename[$tableName][0].' to '.$rename[$tableName][1]; + $failedcommands[] = implode( " ", $sql ); + } + } + } + } + break; + case 'CREATESEQUENCE': + foreach( $dd as $create ) { + foreach( $create as $sequence ) { + $this->mDb->CreateSequence( $sequencePrefix.$sequence ); + } + } + break; + case 'RENAMESEQUENCE': + foreach( $dd as $rename ) { + foreach( $rename as $from => $to ) { + if( $gBitDbType != 'mysql' || $this->mDb->tableExists( $tablePrefix.$from ) ) { + if( $id = $this->mDb->GenID( $from ) ) { + $this->mDb->DropSequence( $sequencePrefix.$from ); + $this->mDb->CreateSequence( $sequencePrefix.$to, $id ); + } else { + $errors[] = 'Failed to rename sequence '.$sequencePrefix.$from.' to '.$sequencePrefix.$to; + $failedcommands[] = implode( " ", $sql ); + } + } else { + $this->mDb->CreateSequence( $sequencePrefix.$to, $pUpgradeHash['sequences'][$to]['start'] ); + } + } + } + break; + case 'DROPSEQUENCE': + foreach( $dd as $drop ) { + foreach( $drop as $sequence ) { + $this->mDb->DropSequence( $sequencePrefix.$sequence ); + } + } + break; + case 'DROPCOLUMN': + foreach( $dd as $drop ) { + foreach( array_keys( $drop ) as $tableName ) { + $completeTableName = $tablePrefix.$tableName; + foreach( $drop[$tableName] as $col ) { + if( $sql = $dict->DropColumnSQL( $completeTableName, $col ) ) { + foreach( $sql AS $query ) { + $this->mDb->query( $query ); + } + } else { + $errors[] = 'Failed to drop column '.$completeTableName; + $failedcommands[] = implode( " ", $sql ); + } + } + } + } + break; + case 'DROPTABLE': + foreach( $dd as $drop ) { + foreach( $drop as $tableName ) { + $completeTableName = $tablePrefix.$tableName; + $sql = $dict->DropTableSQL( $completeTableName ); + if( $sql && $dict->ExecuteSQLArray( $sql ) > 0 ) { + } else { + $errors[] = 'Failed to drop table '.$completeTableName; + $failedcommands[] = implode( " ", $sql ); + } + } + } + break; + case 'CREATEINDEX': + foreach( $dd as $indices ) { + foreach( array_keys( $indices ) as $index ) { + $completeTableName = $tablePrefix.$indices[$index][0]; + if( $sql = $dict->CreateIndexSQL( $index, $completeTableName, $indices[$index][1], $indices[$index][2] ) ) { + foreach( $sql AS $query ) { + $this->mDb->query( $query ); + } + } else { + $errors[] = 'Failed to create index '.$index; + $failedcommands[] = implode( " ", $sql ); + } + } + } + break; + } + } + if( !empty( $sql ) ) $sql = null; + break; + case 'QUERY': + uksort( $step, 'upgrade_query_sort' ); + foreach( array_keys( $step ) as $dbType ) { + if( $dbType == 'MYSQL' && preg_match( '/mysql/', $gBitDbType )) { + $sql = $step[$dbType]; + unset( $step['SQL92'] ); + } elseif( $dbType == 'PGSQL' && preg_match( '/postgres/', $gBitDbType )) { + $sql = $step[$dbType]; + unset( $step['SQL92'] ); + } elseif( $dbType == 'SQL92' && !empty( $step['SQL92'] )) { + $sql = $step[$dbType]; + } + + if( !empty( $sql ) ) { + foreach( $sql as $query ) { + if( !$result = $this->mDb->query( $query )) { + $errors[] = 'Failed to execute SQL query'; + $failedcommands[] = implode( " ", $sql ); + } + } + $sql = NULL; + } + } + break; + case 'PHP': + eval( $step ); + break; + case 'POST': + $postSql[] = $step; + break; + } + } + + // turn on features that are turned on + // legacy stuff + if( $this->isFeatureActive( 'feature_'.$pPackage )) { + $this->storeConfig( 'package_'.$pPackage, 'y', KERNEL_PKG_NAME ); + } + + if( !empty( $failedcommands )) { + $ret['errors'] = $errors; + $ret['failedcommands'] = $failedcommands; + } + } + + return $ret; + } + + /** + * identifyBlobs + * + * @param array $result + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function identifyBlobs( $result ) { + $blobs = array(); + //echo "FieldCount: ".$result->FieldCount()."\n"; + for( $i = 0; $i < $result->FieldCount(); $i++ ) { + $field = $result->FetchField($i); + //echo $i."-".$field->name."-".$result->MetaType($field->type)."-".$field->max_length."\n"; + // check for blobs + if(( $result->MetaType( $field->type ) == 'B' ) || ( $result->MetaType( $field->type )=='X' && $field->max_length >= 16777215 )) + $blobs[] = $field->name; + } + return $blobs; + } + + /** + * convertBlobs enumerate blob fields and encoded + * + * @param string $gDb + * @param array $res + * @param array $blobs + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function convertBlobs( $gDb, &$res, $blobs ) { + foreach( $blobs as $blob ) { + $res[$blob] = $gDb->dbByteEncode( $res[$blob] ); + } + } + + /** + * hasAdminBlock + * + * @access public + * @return TRUE on success, FALSE on failure + * @deprecated i think this isn't used any more + */ + function hasAdminBlock() { + deprecated( "i think this isn't used anymore." ); + global $gBitUser; + // Let's find out if we are have admin perm or a root user + $ret = TRUE; + if( empty( $gBitUser ) || $gBitUser->isAdmin() ) { + $ret = FALSE; + } else { + // let's try to load up user_id - if successful, we know we have one. + $rootUser = new BitPermUser( 1 ); + $rootUser->load(); + if( !$rootUser->isValid() ) { + $ret = FALSE; + } + } + return $ret; + } +} + +/** + * check_session_save_path + * + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ +function check_session_save_path() { + global $errors; + if( ini_get( 'session.save_handler' ) == 'files' ) { + $save_path = ini_get( 'session.save_path' ); + + if( !is_dir( $save_path )) { + $errors .= "The directory '$save_path' does not exist or PHP is not allowed to access it (check session.save_path or open_basedir entries in php.ini).\n"; + } elseif( !bw_is_writeable( $save_path )) { + $errors .= "The directory '$save_path' is not writeable.\n"; + } + + if( $errors ) { + $save_path = tempdir(); + + if (is_dir($save_path) && bw_is_writeable($save_path)) { + ini_set('session.save_path', $save_path); + + $errors = ''; + } + } + } +} + +/** + * makeConnection + * + * @param string $gBitDbType + * @param string $gBitDbHost + * @param string $gBitDbUser + * @param string $gBitDbPassword + * @param string $gBitDbName + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ +function makeConnection( $gBitDbType, $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName ) { + $gDb = &ADONewConnection( $gBitDbType ); + if( !$gDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName )) { + echo $gDb->ErrorMsg()."\n"; + die; + } + global $gBitDbCaseSensitivity; + $gDb->mCaseSensitive = $gBitDbCaseSensitivity; + $gDb->SetFetchMode( ADODB_FETCH_ASSOC ); + return $gDb; +} + +/** + * upgrade_package_sort sort packages before they are upgraded + * + * @param string $a + * @param string $b + * @access public + * @return numeric sort direction + */ +function upgrade_package_sort( $a, $b ) { + global $gBitInstaller; + $aa = $gBitInstaller->mPackages[$a]; + $bb = $gBitInstaller->mPackages[$b]; + if(( $aa['required'] && $bb['required'] ) || ( !$aa['required'] && !$bb['required'] )) { + return 0; + } elseif( $aa['required'] && !$bb['required'] ) { + return -1; + } elseif( !$aa['required'] && $bb['required'] ) { + return 1; + } +} + +/** + * upgrade_version_sort sort upgrades based on version number + * + * @param string $a + * @param string $b + * @access public + * @return numeric sort direction + */ +function upgrade_version_sort( $a, $b ) { + return version_compare( $a, $b, '>' ); +} + +/** + * upgrade_query_sort sort queries that SQL92 queries are called last + * + * @param string $a + * @param string $b + * @access public + * @return numeric sort direction + */ +function upgrade_query_sort( $a, $b ) { + if( $a == 'SQL92' ) { + return 1; + } elseif( $b == 'SQL92' ) { + return -1; + } else { + return 0; + } +} + +?> diff --git a/includes/create_config_inc.php b/includes/create_config_inc.php new file mode 100644 index 0000000..9ae113c --- /dev/null +++ b/includes/create_config_inc.php @@ -0,0 +1,256 @@ + array( 'width' => 1024, 'height' => 1024 ), + 'large' => array( 'width' => 800, 'height' => 800 ), + 'medium' => array( 'width' => 400, 'height' => 400 ), + 'small' => array( 'width' => 160, 'height' => 160 ), + 'avatar' => array( 'width' => 100, 'height' => 100 ), + 'icon' => array( 'width' => 48, 'height' => 48 ), +); +*/"; + + if( substr( PHP_OS, 0, 3 ) == 'WIN' ) { + $filetowrite .= " + + +// Insert the absolute path to your php magic database. This is required for +// us to check and verify the mime type of uploaded files. This setting is only +// required on windows machines. +//define( 'PHP_MAGIC_PATH', 'C:\\Program Files\\PHP\\extras\\magic.mime' );"; + } + + if( defined( 'ROLE_MODEL' )) { + $filetowrite .= " + +define( 'LIBERTY_DEFAULT_MIME_HANDLER', 'mimeflatdefault' );"; + } + + $filetowrite .= " + + + /******************************************************\ + *************** Debugging Options **************** + \******************************************************/ + +// If you wish to force compiling of every page, you can set the next setting to +// TRUE. this will, however, severly impact performance since every page that is +// generated is generated afresh and the cache is recreated every time. +\$smarty_force_compile = FALSE; + + +// Setting TEMPLATE_DEBUG = TRUE will output in your +// templates, which will allow you to track all used templates in the HTML source +// of the page. This will also disable stripping of whitespace making it easier to +// read the templates. You will only see the effect of the strip changes by +// clearing out your cache or setting \$smarty_force_compile = TRUE; +// Note: be sure to set this to FALSE and clear out the cache once done since it +// will increase the page size by at least 10%. +//define( 'TEMPLATE_DEBUG', TRUE ); + +// If you want to go a step further with template debugging then this enables +// smarty's debugging console. A popup with a dump of all of the vars the +// template(s) have been passed. +\$smarty_debugging = FALSE; + + +// This statement will enable you to view all database queries made +//\$gDebug = TRUE; + + +// This will turn on ADODB performance monitoring and log all queries. This should +// not be enabled except when doing query analysis due to an overall performance +// drop. see kernel/admin/db_performance.php for statistics +//define( 'DB_PERFORMANCE_STATS', TRUE ); + +?>"; + fwrite( $fw, $filetowrite ); + fclose( $fw ); + } else { + print "UNABLE TO WRITE TO ".realpath( $config_file ); + } +} + +?> diff --git a/includes/get_databases_inc.php b/includes/get_databases_inc.php new file mode 100644 index 0000000..22f6310 --- /dev/null +++ b/includes/get_databases_inc.php @@ -0,0 +1,68 @@ +assign( 'fbpath', $fbpath ); + if ( empty($gBitDbName) ) { $gBitDbName = 'bitweaver'; } + $gBitDbCaseSensitivity = FALSE; + if ( empty($gBitDbUser) ) { + $gBitDbUser = 'SYSDBA'; + $gBitDbPassword = 'masterkey'; + } +} +if( function_exists( 'sqlite_open' ) ) { + $dbtodsn['sqlite'] = 'SQLLite'; +} +$gBitSmarty->assignByRef('dbservers', $dbtodsn); + +$gBitSmarty->assign( 'gBitDbType', $gBitDbType ); +$gBitSmarty->assign( 'gBitDbHost', $gBitDbHost ); +$gBitSmarty->assign( 'gBitDbUser', $gBitDbUser ); +$gBitSmarty->assign( 'gBitDbPassword', $gBitDbPassword ); +$gBitSmarty->assign( 'gBitDbName', $gBitDbName ); +$gBitSmarty->assign( 'gBitDbCaseSensitivity', $gBitDbCaseSensitivity ); +$gBitSmarty->assign( 'db_prefix_bit', BIT_DB_PREFIX ); +$gBitSmarty->assign( 'bit_root_url', $bit_root_url ); +if( defined( 'AUTO_BUG_SUBMIT' ) ) { + $gBitSmarty->assign( 'auto_bug_submit', AUTO_BUG_SUBMIT ); +} + +$gBitSmarty->assign( 'gBitDbPassword_input', $gBitDbPassword ); +$gBitSmarty->assign( 'gBitDbPassword_print', preg_replace( '/./','•',$gBitDbPassword ) ); +?> diff --git a/includes/install_admin_inc.php b/includes/install_admin_inc.php new file mode 100644 index 0000000..392fe76 --- /dev/null +++ b/includes/install_admin_inc.php @@ -0,0 +1,80 @@ +assign( 'next_step', $step ); + +if( !empty( $_REQUEST['admin_submit'] )) { + $mail = $errors = array(); + if( empty( $_REQUEST['login'] ) ) { + $errors['login'] = "You must specify an administrator name."; + } + if( empty( $_REQUEST['email'] ) ) { + $errors['email'] = "You must specify an email address."; + } else { + BitUser::verifyAnonEmail( $_REQUEST['email'], $errors ); + } + + if( $_REQUEST['password'] != $_REQUEST['pass_confirm'] ) { + $errors['password'] = "The passwords you entered do not match."; + $_REQUEST['password'] = ''; + } elseif( strlen( $_REQUEST['password'] ) < 4 ) { + $errors['password'] = "The administrator password has to be at least 4 characters."; + $_REQUEST['password'] = ''; + } + + if( empty( $errors )) { + $app = '_done'; + $gBitSmarty->assign( 'next_step', $step + 1 ); + $gBitSmarty->assign( 'pass_disp', preg_replace( '/./i','•',$_REQUEST['password'] ) ); + + // do a mailer check as well - we need to remove trailing options for the sendmail_path check + if( !empty( $_REQUEST['testemail'] )) { + if(( $mail_path = trim( preg_replace( "#\s+\-[a-zA-Z]+.*$#", "", ini_get( 'sendmail_path' )))) && is_file( $mail_path )) { + $to = $_REQUEST['email']; + $from = "bitweaver@".$_SERVER['SERVER_NAME']; + $subject = "bitweaver test email"; + $message = "Congratulations!\r\n". + "The email system on your server at ".$_SERVER['SERVER_NAME']." is working!\r\n\r\n". + "Thank you for trying bitweaver,\r\n". + "The bitweaver team.\r\n"; + $headers = "From: $from\r\n". + "Reply-To: $from\r\n". + "X-Mailer: PHP/".phpversion(); + + if( mail( $to, $subject, $message, $headers )) { + $mail['success'] = "We sent an email to $to."; + } else { + $mail['warning'] = "We have tried to send an email to $to and the mailing system on the server has not accepted the email."; + } + } else { + $mail['warning'] = "The email settings on your php server are not set up correctly. Please make sure to set a valid sendmail_path if you plan to send emails with bitweaver."; + } + } + } + + $_SESSION['real_name'] = $_REQUEST['real_name']; + $_SESSION['login'] = $_REQUEST['login']; + $_SESSION['password'] = $_REQUEST['password']; + $_SESSION['email'] = $_REQUEST['email']; + + $gBitSmarty->assign( 'mail', $mail ); + $gBitSmarty->assign( 'real_name', $_SESSION['real_name'] ); + $gBitSmarty->assign( 'login', $_SESSION['login'] ); + $gBitSmarty->assign( 'password', $_SESSION['password'] ); + $gBitSmarty->assign( 'pass_confirm', $_SESSION['password'] ); + $gBitSmarty->assign( 'email', $_SESSION['email'] ); + $gBitSmarty->assign( 'errors', $errors ); +} else { + $gBitSmarty->assign( 'user', ''); + $gBitSmarty->assign( 'email', 'admin@localhost'); +} +?> diff --git a/includes/install_inc.php b/includes/install_inc.php new file mode 100644 index 0000000..12706c3 --- /dev/null +++ b/includes/install_inc.php @@ -0,0 +1,182 @@ + $menu_step ) { + if( !isset( $menu_step['state'] ) ) { + if( !empty( $gBitDbType ) && $gBitUser->isAdmin() && !$_SESSION['first_install'] ) { + $pInstallFiles[$key]['state'] = 'complete'; + $pInstallFiles[$key]['icon'] = 'icon-ok'; + } else { + $pInstallFiles[$key]['state'] = 'uncompleted'; + $pInstallFiles[$key]['icon'] = 'spacer'; + } + } + } + + // assign all this work to the template + $gBitSmarty->assign( 'step', $pStep ); + $gBitSmarty->assign( 'menu_steps', $pInstallFiles ); + $gBitSmarty->assign( 'progress', ( ceil( 100 / ( count( $pInstallFiles ) ) * $done ) ) ); + + return $pInstallFiles; +} + +/** + * Global flag to indicate we are installing + */ +define( 'BIT_INSTALL', 'TRUE' ); +// Uncomment to switch to role team model ... +//define( 'ROLE_MODEL', 'TRUE' ); +global $gBitSmarty; + +// use relative path if no CONFIG_INC path specified - we know we are in installer here... +$config_file = empty($_SERVER['CONFIG_INC']) ? '../config/kernel/config_inc.php' : $_SERVER['CONFIG_INC']; +// We can't call clean_file_path here even though we would like to. +$config_file = (strpos($_SERVER["SERVER_SOFTWARE"],"IIS") ? str_replace( "/", "\\", $config_file) : $config_file); + +// DO THIS FIRST! Before we include any kernel stuff to avoid duplicate defines +if( isset( $_REQUEST['submit_db_info'] ) ) { + if ( $_REQUEST['db'] == "firebird" && empty( $gBitDbName ) ) { + { + // Should only be called when creating the datatabse + require_once("create_firebird_database.php"); + FirebirdCreateDB($_REQUEST['host'], $_REQUEST['user'], $_REQUEST['pass'], $_REQUEST['name'], $_REQUEST['fbpath']); + } + } + if ( empty( $gBitDbType ) ) { + $tmpHost = $_REQUEST['host']; + require_once( 'create_config_inc.php' ); + $createHash = array( + "gBitDbType" => $_REQUEST['db'], + "gBitDbHost" => $tmpHost, + "gBitDbUser" => $_REQUEST['user'], + "gBitDbPassword" => $_REQUEST['pass'], + "gBitDbName" => $_REQUEST['name'], + "gBitDbCaseSensitivity" => $_REQUEST['dbcase'], + "bit_db_prefix" => $_REQUEST['prefix'], + "bit_root_url" => $_REQUEST['baseurl'], + "auto_bug_submit" => !empty( $_REQUEST['auto_bug_submit'] ) ? 'TRUE' : 'FALSE', + "is_live" => !empty( $_REQUEST['is_live'] ) ? 'TRUE' : 'FALSE', + ); + create_config( $createHash ); + include( $config_file ); + } +} +require_once( '../kernel/includes/setup_inc.php' ); +require_once( INSTALL_PKG_CLASS_PATH.'BitInstaller.php' ); + +if ( defined( 'ROLE_MODEL' ) ) { + require_once( USERS_PKG_CLASS_PATH.'RoleUser.php' ); +} else { + require_once( USERS_PKG_CLASS_PATH.'BitUser.php' ); +} + +// set some preferences during installation +global $gBitInstaller, $gBitSystem, $gBitThemes; +$gBitInstaller = new BitInstaller(); + +// IF DB has not been created yet, then packages will not have been scanned yet. +// and even if they have been scanned, then they will only include active packages, +// not all packages. So we scan again here including all packages. +$gBitSystem->scanPackages( 'bit_setup_inc.php', TRUE, 'all', TRUE, TRUE ); + +$gBitInstaller->mPackages = $gBitSystem->mPackages; + +// we need this massive array available during install to work out if bitweaver has already been installed +// this array is so massive that it will kill system with too little memory allocated to php +$dbTables = $gBitInstaller->verifyInstalledPackages( 'all' ); + +// set prefs to display help during install +$gBitSystem->setConfig( 'site_online_help', 'y' ); +$gBitSystem->setConfig( 'site_form_help', 'y' ); +$gBitSystem->setConfig( 'site_help_popup', 'n' ); + +$commands = array(); +global $failedcommands; +$failedcommands = array(); +global $gBitLanguage; +$gBitLanguage->mLanguage = 'en'; + +// Empty SCRIPT_NAME and incorrect SCRIPT_NAME due to php-cgiwrap - wolff_borg +if( empty( $_SERVER['SCRIPT_NAME'] )) { + $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_URL']; +} + +if( empty( $_REQUEST['baseurl'] )) { + $bit_root_url = substr( $_SERVER['SCRIPT_NAME'], 0, strpos( $_SERVER['SCRIPT_NAME'], 'install/' )); +} else { + $bit_root_url = BIT_ROOT_URL; +} + +global $gBitUser; + +if( !empty( $_POST['signin'] ) ) { + $gBitInstaller->login( $_REQUEST['user'], $_REQUEST['pass'] ); +} elseif( !empty( $_COOKIE[$gBitUser->getSiteCookieName()] ) && ( $gBitUser->mUserId = $gBitUser->getUserIdFromCookieHash( $_COOKIE[$gBitUser->getSiteCookieName()] ))) { + $userInfo = $gBitUser->getUserInfo( array( 'user_id' => $gBitUser->mUserId ) ); + + if( $userInfo['user_id'] != ANONYMOUS_USER_ID ) { + // User is valid and not due to change pass.. + $gBitUser->mInfo = $userInfo; + $gBitUser->loadPermissions( TRUE ); + } +} + +// if we came from anywhere appart from some installer page, nuke all settings in the _SESSION and set first_install FALSE +if( + ( !isset( $_SESSION['first_install'] ) + || $_SESSION['first_install'] != TRUE ) + || ( isset( $_SESSION['upgrade'] ) && $_SESSION['upgrade'] != TRUE ) + || !isset( $_SERVER['HTTP_REFERER'] ) + || isset( $_SERVER['HTTP_REFERER'] ) && ( + ( !strpos( $_SERVER['HTTP_REFERER'],'install/install.php' )) + && ( !strpos( $_SERVER['HTTP_REFERER'],'install/upgrade.php' )) + && ( !strpos( $_SERVER['HTTP_REFERER'],'install/migrate.php' )) + ) +) { + if( !$gBitUser->isAdmin() ) { + $_SESSION = NULL; + } + unset( $_SESSION['upgrade'] ); + $_SESSION['first_install'] = FALSE; +} + +// this is needed because some pages display some additional information during a first install +$gBitSmarty->assign( 'first_install', $_SESSION['first_install'] ); +?> diff --git a/install.php b/install.php index 5997355..7377095 100644 --- a/install.php +++ b/install.php @@ -60,7 +60,7 @@ die; /** * required setup */ -require_once( 'install_inc.php' ); +require_once( 'includes/install_inc.php' ); // this variable will be appended to the template file called - useful for displaying messages after data input $app = ''; diff --git a/install_admin_inc.php b/install_admin_inc.php deleted file mode 100644 index 392fe76..0000000 --- a/install_admin_inc.php +++ /dev/null @@ -1,80 +0,0 @@ -assign( 'next_step', $step ); - -if( !empty( $_REQUEST['admin_submit'] )) { - $mail = $errors = array(); - if( empty( $_REQUEST['login'] ) ) { - $errors['login'] = "You must specify an administrator name."; - } - if( empty( $_REQUEST['email'] ) ) { - $errors['email'] = "You must specify an email address."; - } else { - BitUser::verifyAnonEmail( $_REQUEST['email'], $errors ); - } - - if( $_REQUEST['password'] != $_REQUEST['pass_confirm'] ) { - $errors['password'] = "The passwords you entered do not match."; - $_REQUEST['password'] = ''; - } elseif( strlen( $_REQUEST['password'] ) < 4 ) { - $errors['password'] = "The administrator password has to be at least 4 characters."; - $_REQUEST['password'] = ''; - } - - if( empty( $errors )) { - $app = '_done'; - $gBitSmarty->assign( 'next_step', $step + 1 ); - $gBitSmarty->assign( 'pass_disp', preg_replace( '/./i','•',$_REQUEST['password'] ) ); - - // do a mailer check as well - we need to remove trailing options for the sendmail_path check - if( !empty( $_REQUEST['testemail'] )) { - if(( $mail_path = trim( preg_replace( "#\s+\-[a-zA-Z]+.*$#", "", ini_get( 'sendmail_path' )))) && is_file( $mail_path )) { - $to = $_REQUEST['email']; - $from = "bitweaver@".$_SERVER['SERVER_NAME']; - $subject = "bitweaver test email"; - $message = "Congratulations!\r\n". - "The email system on your server at ".$_SERVER['SERVER_NAME']." is working!\r\n\r\n". - "Thank you for trying bitweaver,\r\n". - "The bitweaver team.\r\n"; - $headers = "From: $from\r\n". - "Reply-To: $from\r\n". - "X-Mailer: PHP/".phpversion(); - - if( mail( $to, $subject, $message, $headers )) { - $mail['success'] = "We sent an email to $to."; - } else { - $mail['warning'] = "We have tried to send an email to $to and the mailing system on the server has not accepted the email."; - } - } else { - $mail['warning'] = "The email settings on your php server are not set up correctly. Please make sure to set a valid sendmail_path if you plan to send emails with bitweaver."; - } - } - } - - $_SESSION['real_name'] = $_REQUEST['real_name']; - $_SESSION['login'] = $_REQUEST['login']; - $_SESSION['password'] = $_REQUEST['password']; - $_SESSION['email'] = $_REQUEST['email']; - - $gBitSmarty->assign( 'mail', $mail ); - $gBitSmarty->assign( 'real_name', $_SESSION['real_name'] ); - $gBitSmarty->assign( 'login', $_SESSION['login'] ); - $gBitSmarty->assign( 'password', $_SESSION['password'] ); - $gBitSmarty->assign( 'pass_confirm', $_SESSION['password'] ); - $gBitSmarty->assign( 'email', $_SESSION['email'] ); - $gBitSmarty->assign( 'errors', $errors ); -} else { - $gBitSmarty->assign( 'user', ''); - $gBitSmarty->assign( 'email', 'admin@localhost'); -} -?> diff --git a/install_database.php b/install_database.php index fb71fdb..31a94b9 100644 --- a/install_database.php +++ b/install_database.php @@ -10,7 +10,7 @@ */ $gBitSmarty->assign( 'next_step',$step ); -require_once( "get_databases_inc.php" ); +require_once( "includes/get_databases_inc.php" ); // next block checks if there is a config/kernel/config_inc.php and if we can connect through this. if( isset( $_REQUEST['submit_db_info'] )) { diff --git a/install_inc.php b/install_inc.php deleted file mode 100644 index 14c8b19..0000000 --- a/install_inc.php +++ /dev/null @@ -1,184 +0,0 @@ - $menu_step ) { - if( !isset( $menu_step['state'] ) ) { - if( !empty( $gBitDbType ) && $gBitUser->isAdmin() && !$_SESSION['first_install'] ) { - $pInstallFiles[$key]['state'] = 'complete'; - $pInstallFiles[$key]['icon'] = 'icon-ok'; - } else { - $pInstallFiles[$key]['state'] = 'uncompleted'; - $pInstallFiles[$key]['icon'] = 'spacer'; - } - } - } - - // assign all this work to the template - $gBitSmarty->assign( 'step', $pStep ); - $gBitSmarty->assign( 'menu_steps', $pInstallFiles ); - $gBitSmarty->assign( 'progress', ( ceil( 100 / ( count( $pInstallFiles ) ) * $done ) ) ); - - return $pInstallFiles; -} - -/** - * Global flag to indicate we are installing - */ -define( 'BIT_INSTALL', 'TRUE' ); -// Uncomment to switch to role team model ... -//define( 'ROLE_MODEL', 'TRUE' ); -global $gBitSmarty; - -// use relative path if no CONFIG_INC path specified - we know we are in installer here... -$config_file = empty($_SERVER['CONFIG_INC']) ? '../config/kernel/config_inc.php' : $_SERVER['CONFIG_INC']; -// We can't call clean_file_path here even though we would like to. -$config_file = (strpos($_SERVER["SERVER_SOFTWARE"],"IIS") ? str_replace( "/", "\\", $config_file) : $config_file); - -// DO THIS FIRST! Before we include any kernel stuff to avoid duplicate defines -if( isset( $_REQUEST['submit_db_info'] ) ) { - if ( $_REQUEST['db'] == "firebird" && empty( $gBitDbName ) ) { - { - // Should only be called when creating the datatabse - require_once("create_firebird_database.php"); - FirebirdCreateDB($_REQUEST['host'], $_REQUEST['user'], $_REQUEST['pass'], $_REQUEST['name'], $_REQUEST['fbpath']); - } - } - if ( empty( $gBitDbType ) ) { - $tmpHost = $_REQUEST['host']; - if ($_REQUEST['db'] == 'mssql' && get_magic_quotes_gpc() == 1) { // pull doubled up slashes from config - $tmpHost = stripslashes($tmpHost); - } - require_once( 'create_config_inc.php' ); - $createHash = array( - "gBitDbType" => $_REQUEST['db'], - "gBitDbHost" => $tmpHost, - "gBitDbUser" => $_REQUEST['user'], - "gBitDbPassword" => $_REQUEST['pass'], - "gBitDbName" => $_REQUEST['name'], - "gBitDbCaseSensitivity" => $_REQUEST['dbcase'], - "bit_db_prefix" => $_REQUEST['prefix'], - "bit_root_url" => $_REQUEST['baseurl'], - "auto_bug_submit" => !empty( $_REQUEST['auto_bug_submit'] ) ? 'TRUE' : 'FALSE', - "is_live" => !empty( $_REQUEST['is_live'] ) ? 'TRUE' : 'FALSE', - ); - create_config( $createHash ); - include( $config_file ); - } -} -require_once("../kernel/setup_inc.php"); -require_once( 'BitInstaller.php' ); -if ( defined( 'ROLE_MODEL' ) ) { - require_once( USERS_PKG_PATH.'includes/RoleUser.php' ); -} else { - require_once( USERS_PKG_PATH.'includes/BitUser.php' ); -} - -// set some preferences during installation -global $gBitInstaller, $gBitSystem, $gBitThemes; -$gBitInstaller = new BitInstaller(); - -// IF DB has not been created yet, then packages will not have been scanned yet. -// and even if they have been scanned, then they will only include active packages, -// not all packages. So we scan again here including all packages. -$gBitSystem->scanPackages( 'bit_setup_inc.php', TRUE, 'all', TRUE, TRUE ); - -$gBitInstaller->mPackages = $gBitSystem->mPackages; - -// we need this massive array available during install to work out if bitweaver has already been installed -// this array is so massive that it will kill system with too little memory allocated to php -$dbTables = $gBitInstaller->verifyInstalledPackages( 'all' ); - -// set prefs to display help during install -$gBitSystem->setConfig( 'site_online_help', 'y' ); -$gBitSystem->setConfig( 'site_form_help', 'y' ); -$gBitSystem->setConfig( 'site_help_popup', 'n' ); - -$commands = array(); -global $failedcommands; -$failedcommands = array(); -global $gBitLanguage; -$gBitLanguage->mLanguage = 'en'; - -// Empty SCRIPT_NAME and incorrect SCRIPT_NAME due to php-cgiwrap - wolff_borg -if( empty( $_SERVER['SCRIPT_NAME'] )) { - $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_URL']; -} - -if( empty( $_REQUEST['baseurl'] )) { - $bit_root_url = substr( $_SERVER['SCRIPT_NAME'], 0, strpos( $_SERVER['SCRIPT_NAME'], 'install/' )); -} else { - $bit_root_url = BIT_ROOT_URL; -} - -global $gBitUser; - -if( !empty( $_POST['signin'] ) ) { - $gBitInstaller->login( $_REQUEST['user'], $_REQUEST['pass'] ); -} elseif( !empty( $_COOKIE[$gBitUser->getSiteCookieName()] ) && ( $gBitUser->mUserId = $gBitUser->getUserIdFromCookieHash( $_COOKIE[$gBitUser->getSiteCookieName()] ))) { - $userInfo = $gBitUser->getUserInfo( array( 'user_id' => $gBitUser->mUserId ) ); - - if( $userInfo['user_id'] != ANONYMOUS_USER_ID ) { - // User is valid and not due to change pass.. - $gBitUser->mInfo = $userInfo; - $gBitUser->loadPermissions( TRUE ); - } -} - -// if we came from anywhere appart from some installer page, nuke all settings in the _SESSION and set first_install FALSE -if( - ( !isset( $_SESSION['first_install'] ) - || $_SESSION['first_install'] != TRUE ) - || ( isset( $_SESSION['upgrade'] ) && $_SESSION['upgrade'] != TRUE ) - || !isset( $_SERVER['HTTP_REFERER'] ) - || isset( $_SERVER['HTTP_REFERER'] ) && ( - ( !strpos( $_SERVER['HTTP_REFERER'],'install/install.php' )) - && ( !strpos( $_SERVER['HTTP_REFERER'],'install/upgrade.php' )) - && ( !strpos( $_SERVER['HTTP_REFERER'],'install/migrate.php' )) - ) -) { - if( !$gBitUser->isAdmin() ) { - $_SESSION = NULL; - } - unset( $_SESSION['upgrade'] ); - $_SESSION['first_install'] = FALSE; -} - -// this is needed because some pages display some additional information during a first install -$gBitSmarty->assign( 'first_install', $_SESSION['first_install'] ); -?> diff --git a/install_packages.php b/install_packages.php index a26cc61..807cae3 100644 --- a/install_packages.php +++ b/install_packages.php @@ -118,7 +118,7 @@ if( !empty( $_REQUEST['cancel'] ) ) { sort( $_REQUEST['packages'] ); // Need to unquote constraints. but this need replacing with a datadict function - require_once('../kernel/BitDbBase.php'); + require_once( KERNEL_PKG_CLASS_PATH.'BitDbBase.php'); $gBitKernelDb = new BitDb(); $gBitKernelDb->mType = $gBitDbType; diff --git a/migrate.php b/migrate.php index 0af2e90..38371e9 100644 --- a/migrate.php +++ b/migrate.php @@ -12,7 +12,7 @@ /** * required setup */ -require_once( 'install_inc.php' ); +require_once( 'includes/install_inc.php' ); // this variable will be appended to the template file called - useful for displaying messages after data input $app = ''; diff --git a/migrate_database.php b/migrate_database.php index df5767f..e2348aa 100644 --- a/migrate_database.php +++ b/migrate_database.php @@ -12,8 +12,8 @@ * Initialization */ $gBitSmarty->assign( 'next_step', $step ); -require_once( 'install_inc.php' ); -require_once( "get_databases_inc.php" ); +require_once( 'includes/install_inc.php' ); +require_once( 'includes/get_databases_inc.php' ); // set the maximum execution time to very high ini_set( "max_execution_time", "86400" ); diff --git a/process_sql.php b/process_sql.php deleted file mode 100644 index 23fbbdd..0000000 --- a/process_sql.php +++ /dev/null @@ -1,34 +0,0 @@ -Connect($gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName) ) { - process_sql_file( $argv[1], $gBitDbType, BIT_DB_PREFIX ); - } -} - -?> diff --git a/templates/install_packages.tpl b/templates/install_packages.tpl index 71905fe..ebf76b7 100644 --- a/templates/install_packages.tpl +++ b/templates/install_packages.tpl @@ -54,7 +54,7 @@ {if !$item.installed and !$item.required}
- + {forminput label="checkbox"} {$package|capitalize} {formhelp note=$item.info is_installer=1} diff --git a/upgrade.php b/upgrade.php index 5b3ff18..8c42fb6 100644 --- a/upgrade.php +++ b/upgrade.php @@ -15,7 +15,7 @@ /** * required setup */ -require_once( 'install_inc.php' ); +require_once( 'includes/install_inc.php' ); // this variable will be appended to the template file called - useful for displaying messages after data input $app = ''; @@ -72,4 +72,4 @@ $gBitSmarty->assign( 'section', 'Upgrade' ); $gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/upgrade_".$install_file[$step]['file'].$app.".tpl" ); $gBitInstaller->in_display( $install_file[$step]['name'], INSTALL_PKG_PATH.'templates/install.tpl' ); -?> \ No newline at end of file +?> -- cgit v1.3