summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-04-05 15:29:16 +0100
committerlsces <lester@lsces.co.uk>2026-04-05 15:29:16 +0100
commit516dfc95fcd3558e4dc205f2a2b87b44bf47c4a8 (patch)
tree4e5bff0c166142bcd0f1841a3ad6ff14bcd1c260 /includes
parenta285cd4a2b73315a874627faa9d28ddb538f26da (diff)
downloadinstall-516dfc95fcd3558e4dc205f2a2b87b44bf47c4a8.tar.gz
install-516dfc95fcd3558e4dc205f2a2b87b44bf47c4a8.tar.bz2
install-516dfc95fcd3558e4dc205f2a2b87b44bf47c4a8.zip
It does help if you stage changes from the right machine. This is the rework of the installer for namespace and php8.4
Diffstat (limited to 'includes')
-rwxr-xr-x[-rw-r--r--]includes/classes/BitInstaller.php149
-rwxr-xr-x[-rw-r--r--]includes/create_config_inc.php47
-rwxr-xr-x[-rw-r--r--]includes/get_databases_inc.php26
-rwxr-xr-x[-rw-r--r--]includes/install_admin_inc.php9
-rwxr-xr-x[-rw-r--r--]includes/install_beta1_beta2.php3
-rwxr-xr-x[-rw-r--r--]includes/install_bit_settings.php24
-rwxr-xr-x[-rw-r--r--]includes/install_checks.php297
-rwxr-xr-x[-rw-r--r--]includes/install_cleanup.php80
-rwxr-xr-x[-rw-r--r--]includes/install_database.php7
-rwxr-xr-x[-rw-r--r--]includes/install_database_reset.php5
-rwxr-xr-x[-rw-r--r--]includes/install_datapump.php7
-rwxr-xr-x[-rw-r--r--]includes/install_final.php3
-rwxr-xr-x[-rw-r--r--]includes/install_inc.php70
-rwxr-xr-x[-rw-r--r--]includes/install_options.php3
-rwxr-xr-x[-rw-r--r--]includes/install_packages.php256
-rwxr-xr-x[-rw-r--r--]includes/install_upgrade.php5
-rwxr-xr-x[-rw-r--r--]includes/install_version.php15
-rwxr-xr-x[-rw-r--r--]includes/install_welcome.php3
18 files changed, 479 insertions, 530 deletions
diff --git a/includes/classes/BitInstaller.php b/includes/classes/BitInstaller.php
index 7795403..d183aaa 100644..100755
--- a/includes/classes/BitInstaller.php
+++ b/includes/classes/BitInstaller.php
@@ -3,7 +3,11 @@
* @version $Header$
* @package install
*/
+namespace Bitweaver\Install;
+use Bitweaver\BitSystem;
+use Bitweaver\BitDb;
+use Bitweaver\KernelTools;
/**
* @package install
*/
@@ -15,7 +19,7 @@ class BitInstaller extends BitSystem {
* @var array
* @access public
*/
- var $mPackageUpgrades = array();
+ public $mPackageUpgrades = [];
/**
* mRequirements
@@ -23,13 +27,15 @@ class BitInstaller extends BitSystem {
* @var array
* @access public
*/
- var $mRequirements = array();
+ public $mRequirements = [];
+
+ public $mPrefs;
/**
* Initiolize BitInstaller
* @access public
*/
- function __construct() {
+ public function __construct() {
parent::__construct();
$this->getWebServerUid();
}
@@ -40,7 +46,7 @@ class BitInstaller extends BitSystem {
* @access public
* @return void
*/
- function loadAllUpgradeFiles() {
+ public function loadAllUpgradeFiles() {
foreach( array_keys( $this->mPackages ) as $pkg ) {
$this->loadUpgradeFiles( $pkg );
}
@@ -50,9 +56,9 @@ class BitInstaller extends BitSystem {
* Minimal login just for install in case users tables have been modified
*
* @access public
- * @return void
+ * @return boolean
*/
- function login( $pLogin, $pPassword, $pChallenge=NULL, $pResponse=NULL ) {
+ public function login( $pLogin, $pPassword, $pChallenge=NULL, $pResponse=NULL ) {
global $gBitUser;
$isvalid = false;
@@ -80,11 +86,11 @@ class BitInstaller extends BitSystem {
/**
* loadUpgradeFiles This will load all files in the dir <pckage>/admin/upgrades/<version>.php with a version greater than the one installed
*
- * @param array $pPackage
+ * @param string $pPackage
* @access public
* @return void
*/
- function loadUpgradeFiles( $pPackage ) {
+ public function loadUpgradeFiles( $pPackage ) {
if( !empty( $pPackage )) {
$dir = constant( strtoupper( $pPackage )."_PKG_PATH" )."admin/upgrades/";
if( $this->isPackageActive( $pPackage ) && is_dir( $dir ) && $upDir = opendir( $dir )) {
@@ -113,7 +119,7 @@ class BitInstaller extends BitSystem {
* @access public
* @return void
*/
- function registerPackageUpgrade( $pParams, $pUpgradeHash = array() ) {
+ public function registerPackageUpgrade( $pParams, $pUpgradeHash = array() ) {
if( $this->verifyPackageUpgrade( $pParams )) {
$this->registerPackageVersion( $pParams['package'], $pParams['version'] );
$this->mPackageUpgrades[$pParams['package']][$pParams['version']] = $pParams;
@@ -134,9 +140,9 @@ class BitInstaller extends BitSystem {
* @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
+ * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
- function verifyPackageUpgrade( &$pParams ) {
+ public function verifyPackageUpgrade( &$pParams ) {
if( empty( $pParams['package'] )) {
$this->mErrors['package'] = "Please provide a valid package name.";
} else {
@@ -155,8 +161,8 @@ class BitInstaller extends BitSystem {
// since this should only show up when devs are working, we'll simply display the output:
if( !empty( $this->mErrors )) {
- vd( $this->mErrors );
- bt();
+ \Bitweaver\vd( $this->mErrors );
+ \Bitweaver\bt();
}
return( count( $this->mErrors ) == 0 );
@@ -165,12 +171,12 @@ class BitInstaller extends BitSystem {
/**
* registerUpgrade
*
- * @param array $pPackage
+ * @param string $pPackage
* @param array $pUpgradeHash
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return void
*/
- function registerUpgrade( $pPackage, $pUpgradeHash ) {
+ public function registerUpgrade( $pPackage, $pUpgradeHash ) {
$pPackage = strtolower( $pPackage ); // lower case for uniformity
if( !empty( $pUpgradeHash ) ) {
$this->mUpgrades[$pPackage] = $pUpgradeHash;
@@ -185,7 +191,7 @@ class BitInstaller extends BitSystem {
* @access public
* @return void
*/
- function in_display( $pPackage, $pTemplate ) {
+ public 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 );
@@ -205,9 +211,9 @@ class BitInstaller extends BitSystem {
* isInstalled
*
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
- function isInstalled( $pPackage = 'kernel' ) {
+ public function isInstalled( $pPackage = 'kernel' ) {
return( !empty( $this->mPackages[$pPackage]['installed'] ));
}
@@ -217,11 +223,11 @@ class BitInstaller extends BitSystem {
* @access public
* @return void
*/
- function getWebServerUid() {
+ public function getWebServerUid() {
global $wwwuser, $wwwgroup;
$wwwuser = $wwwgroup = '';
- if( is_windows() ) {
+ if( KernelTools::is_windows() ) {
$wwwuser = 'SYSTEM';
$wwwgroup = 'SYSTEM';
}
@@ -246,9 +252,9 @@ class BitInstaller extends BitSystem {
* getTablePrefix
*
* @access public
- * @return database adjusted table prefix
+ * @return string database adjusted table prefix
*/
- function getTablePrefix() {
+ public function getTablePrefix() {
global $gBitDbType;
$ret = BIT_DB_PREFIX;
// avoid errors in ADONewConnection() (wrong database driver etc...)
@@ -281,25 +287,26 @@ class BitInstaller extends BitSystem {
/**
* upgradePackage
*
- * @param array $pPackage
+ * @param string $pPackage
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return array|boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
- function upgradePackage( $pPackage ) {
+ public function upgradePackage( $pPackage ) {
if( !empty( $pPackage ) && !empty( $this->mUpgrades[$pPackage] )) {
- return( $this->applyUpgrade( $pPackage, $this->mUpgrades[$pPackage] ));
+ return $this->applyUpgrade( $pPackage, $this->mUpgrades[$pPackage] );
}
+ return false;
}
/**
* upgradePackageVersion
*
- * @param array $pPackage
+ * @param string $pPackage
* @param array $pVersion
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return array|null errors will contain reason for failure
*/
- function upgradePackageVersions( $pPackage ) {
+ public 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' );
@@ -320,34 +327,34 @@ class BitInstaller extends BitSystem {
}
}
- return NULL;
+ return null;
}
/**
* applyUpgrade
*
- * @param array $pPackage
+ * @param string $pPackage
* @param array $pUpgradeHash
* @access public
- * @return empty array on success, array with errors on failure
+ * @return array empty array on success, array with errors on failure
*/
- function applyUpgrade( $pPackage, $pUpgradeHash ) {
+ public function applyUpgrade( $pPackage, $pUpgradeHash ) {
global $gBitDb, $gBitDbType;
- $ret = array();
+ $ret = [];
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();
+ $dict = NewDataDictionary( $gBitDb->mDb, 'firebird' );
+ $failedcommands = [];
for( $i = 0; $i < count( $pUpgradeHash ); $i++ ) {
if( !is_array( $pUpgradeHash[$i] ) ) {
- vd( "[$pPackage][$i] is NOT an array" );
- vd( $pUpgradeHash[$i] );
- bt();
+ \Bitweaver\vd( "[$pPackage][$i] is NOT an array" );
+ \Bitweaver\vd( $pUpgradeHash[$i] );
+ \Bitweaver\bt();
die;
}
@@ -378,11 +385,9 @@ class BitInstaller extends BitSystem {
$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 ));
- }
+ $sql = ( is_string( $flds ) )
+ ? $dict->ChangeTableSQL( $completeTableName, $flds )
+ : $dict->ChangeTableSQL( $completeTableName, [ $flds ] );
if( $sql ) {
for( $sqlIdx = 0; $sqlIdx < count( $sql ); $sqlIdx++ ) {
@@ -565,12 +570,12 @@ class BitInstaller extends BitSystem {
/**
* identifyBlobs
*
- * @param array $result
+ * @param object $result
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return array
*/
- function identifyBlobs( $result ) {
- $blobs = array();
+ public function identifyBlobs( $result ) {
+ $blobs = [];
//echo "FieldCount: ".$result->FieldCount()."\n";
for( $i = 0; $i < $result->FieldCount(); $i++ ) {
$field = $result->FetchField($i);
@@ -585,49 +590,24 @@ class BitInstaller extends BitSystem {
/**
* convertBlobs enumerate blob fields and encoded
*
- * @param string $gDb
+ * @param BitDb $gDb
* @param array $res
* @param array $blobs
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return void
*/
- function convertBlobs( $gDb, &$res, $blobs ) {
+ public 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
+ * @return void
*/
function check_session_save_path() {
global $errors;
@@ -636,14 +616,14 @@ function check_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 )) {
+ } elseif( !KernelTools::bw_is_writeable( $save_path )) {
$errors .= "The directory '$save_path' is not writeable.\n";
}
if( $errors ) {
- $save_path = tempdir();
+ $save_path = KernelTools::get_temp_dir();
- if (is_dir($save_path) && bw_is_writeable($save_path)) {
+ if (is_dir($save_path) && KernelTools::bw_is_writeable($save_path)) {
ini_set('session.save_path', $save_path);
$errors = '';
@@ -661,10 +641,10 @@ function check_session_save_path() {
* @param string $gBitDbPassword
* @param string $gBitDbName
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return \ADOConnection
*/
function makeConnection( $gBitDbType, $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName ) {
- $gDb = &ADONewConnection( $gBitDbType );
+ $gDb = ADONewConnection( $gBitDbType );
if( !$gDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName )) {
echo $gDb->ErrorMsg()."\n";
die;
@@ -694,6 +674,7 @@ function upgrade_package_sort( $a, $b ) {
} elseif( !$aa['required'] && $bb['required'] ) {
return 1;
}
+ return 0;
}
/**
@@ -725,5 +706,3 @@ function upgrade_query_sort( $a, $b ) {
return 0;
}
}
-
-?>
diff --git a/includes/create_config_inc.php b/includes/create_config_inc.php
index 9ae113c..82a537d 100644..100755
--- a/includes/create_config_inc.php
+++ b/includes/create_config_inc.php
@@ -12,17 +12,17 @@
/**
* create configuration file
*
- * @param string $pParamHash['gBitDbType']
- * @param string $pParamHash['gBitDbHost']
- * @param string $pParamHash['gBitDbUser']
- * @param string $pParamHash['gBitDbPassword']
- * @param string $pParamHash['gBitDbName']
- * @param numeric $pParamHash['gBitDbCaseSensitivity']
- * @param string $pParamHash['bit_db_prefix']
- * @param string $pParamHash['bit_root_url']
- * @param boolean $pParamHash['auto_bug_submit']
- * @param boolean $pParamHash['is_live']
- * @access public
+ *
+ * @param array $pParamHash
+ * @var string $pParamHash['gBitDbHost']
+ * @var string $pParamHash['gBitDbUser']
+ * @var string $pParamHash['gBitDbPassword']
+ * @var string $pParamHash['gBitDbName']
+ * @var numeric $pParamHash['gBitDbCaseSensitivity']
+ * @var string $pParamHash['bit_db_prefix']
+ * @var string $pParamHash['bit_root_url']
+ * @var boolean $pParamHash['auto_bug_submit']
+ * @var boolean $pParamHash['is_live']
* @return void
*/
function create_config( $pParamHash ) {
@@ -176,20 +176,20 @@ define( 'BIT_ROOT_URL', '$bit_root_url' );
// the kernel. In the example provided below, the kernel package is processed
// first, followed by the users and liberty packages. Any packages not specified
// in \$gPreScan are processed in the traditional order
-//\$gPreScan = array( 'kernel', 'storage', 'liberty', 'themes', 'users' );
+//\$gPreScan = [ 'kernel', 'storage', 'liberty', 'themes', 'users' ];
// \$gThumbSizes defines the image thumbnail sizes that will be autogenerated when
// images are uploaded and processed. The example provided shows the default sizes
// that are used. You can add as many sizes as you want if you override the default.
/*
-\$gThumbSizes = array(
- 'extra-large' => 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 ),
-);
+\$gThumbSizes = [
+ 'extra-large' => [ 'width' => 1024, 'height' => 1024 ],
+ 'large' => [ 'width' => 800, 'height' => 800 ],
+ 'medium' => [ 'width' => 400, 'height' => 400 ],
+ 'small' => [ 'width' => 160, 'height' => 160 ],
+ 'avatar' => [ 'width' => 100, 'height' => 100 ],
+ 'icon' => [ 'width' => 48, 'height' => 48 ],
+];
*/";
if( substr( PHP_OS, 0, 3 ) == 'WIN' ) {
@@ -244,13 +244,10 @@ define( 'LIBERTY_DEFAULT_MIME_HANDLER', 'mimeflatdefault' );";
// 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 );
}
-}
-
-?>
+} \ No newline at end of file
diff --git a/includes/get_databases_inc.php b/includes/get_databases_inc.php
index 22f6310..ffc8bc7 100644..100755
--- a/includes/get_databases_inc.php
+++ b/includes/get_databases_inc.php
@@ -1,4 +1,6 @@
<?php
+
+use Bitweaver\KernelTools;
/**
* check what db servers are available and display them accordingly - only seems to work with *nix
*
@@ -6,7 +8,7 @@
* @subpackage functions
*/
$gBitDbCaseSensitivity = TRUE;
-$dbtodsn = array();
+$dbtodsn = [];
if( function_exists( 'mysql_connect' ) ) {
$dbtodsn['mysql'] = 'MySQL';
}
@@ -33,10 +35,21 @@ if( function_exists( 'fbird_connect' ) ) {
$dbtodsn['firebird'] = 'Firebird';
if ( !empty($_REQUEST['fbpath']) ) $fbpath = $_REQUEST['fbpath'];
if ( empty($fbpath) ) {
- if ( is_windows() )
- $fbpath = 'c:\Program Files\Firebird\Firebird_2_1\bin\isql';
- else
- $fbpath = '/opt/firebird/bin/isql';
+ $fbpath = ( KernelTools::is_windows() ) ? 'c:\Program Files\Firebird\Firebird_5\bin\isql' : '/opt/firebird/bin/isql';
+ }
+ $gBitSmarty->assign( 'fbpath', $fbpath );
+ if ( empty($gBitDbName) ) { $gBitDbName = 'bitweaver'; }
+ $gBitDbCaseSensitivity = FALSE;
+ if ( empty($gBitDbUser) ) {
+ $gBitDbUser = 'SYSDBA';
+ $gBitDbPassword = 'masterkey';
+ }
+}
+if( extension_loaded( 'pdo_firebird' ) ) {
+ $dbtodsn['pdo'] = 'PDO Firebird';
+ if ( !empty($_REQUEST['fbpath']) ) $fbpath = $_REQUEST['fbpath'];
+ if ( empty($fbpath) ) {
+ $fbpath = ( KernelTools::is_windows() ) ? 'c:\Program Files\Firebird\Firebird_5\bin\isql' : '/opt/firebird/bin/isql';
}
$gBitSmarty->assign( 'fbpath', $fbpath );
if ( empty($gBitDbName) ) { $gBitDbName = 'bitweaver'; }
@@ -49,7 +62,7 @@ if( function_exists( 'fbird_connect' ) ) {
if( function_exists( 'sqlite_open' ) ) {
$dbtodsn['sqlite'] = 'SQLLite';
}
-$gBitSmarty->assignByRef('dbservers', $dbtodsn);
+$gBitSmarty->assign('dbservers', $dbtodsn);
$gBitSmarty->assign( 'gBitDbType', $gBitDbType );
$gBitSmarty->assign( 'gBitDbHost', $gBitDbHost );
@@ -65,4 +78,3 @@ if( defined( 'AUTO_BUG_SUBMIT' ) ) {
$gBitSmarty->assign( 'gBitDbPassword_input', $gBitDbPassword );
$gBitSmarty->assign( 'gBitDbPassword_print', preg_replace( '/./','&bull;',$gBitDbPassword ) );
-?>
diff --git a/includes/install_admin_inc.php b/includes/install_admin_inc.php
index 392fe76..711358c 100644..100755
--- a/includes/install_admin_inc.php
+++ b/includes/install_admin_inc.php
@@ -1,4 +1,6 @@
<?php
+
+use Bitweaver\Users\RoleUser;
/**
* @version $Header$
* @package install
@@ -13,14 +15,14 @@
$gBitSmarty->assign( 'next_step', $step );
if( !empty( $_REQUEST['admin_submit'] )) {
- $mail = $errors = array();
+ $mail = $errors = [];
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 );
+ RoleUser::verifyAnonEmail( $_REQUEST['email'], $errors );
}
if( $_REQUEST['password'] != $_REQUEST['pass_confirm'] ) {
@@ -76,5 +78,4 @@ if( !empty( $_REQUEST['admin_submit'] )) {
} else {
$gBitSmarty->assign( 'user', '');
$gBitSmarty->assign( 'email', 'admin@localhost');
-}
-?>
+} \ No newline at end of file
diff --git a/includes/install_beta1_beta2.php b/includes/install_beta1_beta2.php
index 163fd0b..f184a33 100644..100755
--- a/includes/install_beta1_beta2.php
+++ b/includes/install_beta1_beta2.php
@@ -12,5 +12,4 @@
/**
* required setup
*/
-require_once( INSTALL_PKG_PATH.'install_packages.php' );
-?>
+require_once 'includes/install_packages.php';
diff --git a/includes/install_bit_settings.php b/includes/install_bit_settings.php
index fa7d8eb..67feb9d 100644..100755
--- a/includes/install_bit_settings.php
+++ b/includes/install_bit_settings.php
@@ -26,41 +26,38 @@ function simple_set_value( $package, $feature ) {
}
// pass all package data to template
-$gBitSmarty->assignByRef( 'schema', $gBitInstaller->mPackages );
+$gBitSmarty->assign( 'schema', $gBitInstaller->mPackages );
// settings that aren't just toggles
-$formInstallValues = array(
+$formInstallValues = [
'bit_index' => 'kernel',
'kernel_server_name' => 'kernel',
'site_title' => 'kernel',
'site_slogan' => 'kernel',
'bitlanguage' => 'languages',
-);
+];
-$processors = array();
+$processors = [];
if( extension_loaded( 'gd' ) ) {
$processors['gd'] = '<strong>GD Library</strong> [php-gd]';
}
if( extension_loaded( 'imagick' ) ) {
$processors['imagick'] = '<strong>Image Magick</strong> [php-imagick] - recommended';
}
-if( extension_loaded( 'magickwand' ) ) {
- $processors['magickwand'] = '<strong>MagickWand</strong> [php-magickwand] - highly recommended';
-}
if( count( $processors ) > 0 ) {
$gBitSmarty->assign( 'processors', $processors );
$formInstallValues['image_processor'] = 'liberty';
}
// list of available site styles
-$subDirs = array( 'style_info', 'alternate' );
-$stylesList = $gBitThemes->getStylesList( NULL, NULL, $subDirs );
-$gBitSmarty->assignByRef( "stylesList", $stylesList );
+$subDirs = [ 'style_info', 'alternate' ];
+$stylesList = $gBitThemes->getStylesList( '', TRUE, $subDirs );
+$gBitSmarty->assign( "stylesList", $stylesList );
// get list of available languages
-$languages = array();
+$languages = [];
$languages = $gBitLanguage->listLanguages();
-$gBitSmarty->assignByRef("languages",$languages );
+$gBitSmarty->assign("languages",$languages );
// process form
if( isset( $_REQUEST['bit_settings'] ) ) {
@@ -92,7 +89,7 @@ if( isset( $_REQUEST['bit_settings'] ) ) {
// get list of foreign packages that are ready to be installed
// @TODO this isn't working yet, since the info stuff isn't read from schema_inc.php on this page
-$foreign_packages = array();
+$foreign_packages = [];
foreach( $gBitSystem->mPackages as $package ) {
if( isset( $package['info']['install'] ) ) {
$foreign_packages[] = $package;
@@ -102,4 +99,3 @@ if ( defined( 'ROLE_MODEL' ) ) {
$gBitSmarty->assign( "role_model", TRUE );
}
$gBitSmarty->assign( "foreign_packages", $foreign_packages );
-?>
diff --git a/includes/install_checks.php b/includes/install_checks.php
index 641a05a..465b94a 100644..100755
--- a/includes/install_checks.php
+++ b/includes/install_checks.php
@@ -1,4 +1,6 @@
<?php
+
+use Bitweaver\KernelTools;
/**
* @version $Header$
* @package install
@@ -19,8 +21,8 @@ foreach( $check_settings as $type => $checks ) {
}
if( !isset( $_SERVER['HTTP_REFERER'] ) ) {
- $gBitSmarty->assign( "http_referer_error", TRUE );
- $error = TRUE;
+ $gBitSmarty->assign( "http_referer_error", true );
+ $error = true;
}
/**
@@ -28,169 +30,164 @@ if( !isset( $_SERVER['HTTP_REFERER'] ) ) {
*/
function check_settings() {
global $gBitSmarty, $error, $warning;
- $config_file = clean_file_path( empty( $_SERVER['CONFIG_INC'] ) ? BIT_ROOT_PATH.'config/kernel/config_inc.php' : $_SERVER['CONFIG_INC'] );
+ $config_file = KernelTools::clean_file_path( empty( $_SERVER['CONFIG_INC'] ) ? BIT_ROOT_PATH.'config/kernel/config_inc.php' : $_SERVER['CONFIG_INC'] );
$i = 0;
// required settings - if not met, are passed into the array $reqd
// PHP system checks
- $phpvers = '4.3.0';
+ $phpvers = '8.3.0';
if( phpversion() < $phpvers ) {
$required[$i]['note'] = '<strong>PHP version</strong> should be greater than <strong>'.$phpvers.'</strong>.<br />Your installed version of PHP is <strong>'.phpversion().'</strong>.';
- $required[$i]['passed'] = FALSE;
+ $required[$i]['passed'] = false;
} else {
$required[$i]['note'] = '<strong>PHP version</strong> is greater than <strong>'.$phpvers.'</strong>.<br />Your installed version of PHP is <strong>'.phpversion().'</strong>.';
- $required[$i]['passed'] = TRUE;
+ $required[$i]['passed'] = true;
}
// check file and directory permissisions
$i++;
- if( @file_exists( $config_file ) && @bw_is_writeable( $config_file ) ) {
+ if( @file_exists( $config_file ) && @KernelTools::bw_is_writeable( $config_file ) ) {
$required[$i]['note'] = 'The Bitweaver configuration file is available and the file is writeable:<br /><code>'.$config_file.'</code>';
- $required[$i]['passed'] = TRUE;
- } elseif( @file_exists( $config_file ) && !@bw_is_writeable( $config_file ) ) {
- $required[$i]['note'] = 'The Bitweaver configuration file is available but the file is not writeable. Please execute something like:<br /><code>chmod 777 '.$config_file.'<br>chcon unconfined_u:object_r:httpd_sys_rw_content_t:s0 '.$config_file.'</code>';
- $required[$i]['passed'] = FALSE;
+ $required[$i]['passed'] = true;
+ } elseif( @file_exists( $config_file ) && !@KernelTools::bw_is_writeable( $config_file ) ) {
+ $required[$i]['note'] = 'The Bitweaver configuration file is available but the file is not writeable. Please execute something like:<br /><code>chmod 777 '.$config_file.'</code>';
+ $required[$i]['passed'] = false;
} else {
$required[$i]['note'] = 'The Bitweaver configuration file is not available. Please execute something like:<br /><code>touch '.$config_file.';<br />chmod 777 '.$config_file.'</code>';
- $required[$i]['passed'] = FALSE;
+ $required[$i]['passed'] = false;
}
$i++;
- $dir_check = array(
- 'storage' => defined( 'STORAGE_PKG_PATH' ) ? STORAGE_PKG_PATH : BIT_ROOT_PATH.'storage',
- 'temp' => defined( 'TEMP_PKG_PATH' ) ? TEMP_PKG_PATH : sys_get_temp_dir().'/bitweaver/'.$_SERVER['SERVER_NAME'],
- );
+ $dir_check = [
+ 'storage' => defined( 'STORAGE_PKG_PATH' ) ? STORAGE_PKG_PATH : BIT_ROOT_PATH . 'storage',
+ 'temp' => defined( 'TEMP_PKG_PATH' ) ? TEMP_PKG_PATH : sys_get_temp_dir() . '/bitweaver/' . $_SERVER['SERVER_NAME'],
+ ];
foreach( $dir_check as $name => $d ) {
// final attempt to create the required directories
- @mkdir( $d,0644 );
- if( @is_dir( $d ) && bw_is_writeable( $d ) ) {
+// @mkdir( $d,0644 );
+ if( @is_dir( $d ) && KernelTools::bw_is_writeable( $d ) ) {
$required[$i]['note'] = "The $name directory is available and it is writeable.<br /><code>$d</code>";
- $required[$i]['passed'] = TRUE;
- } elseif( @is_dir( $d ) && !bw_is_writeable( $d ) ) {
+ $required[$i]['passed'] = true;
+ } elseif( @is_dir( $d ) && !KernelTools::bw_is_writeable( $d ) ) {
$required[$i]['note'] = "The $name directory is available but it is not writeable.<br />Please execute something like:<br /><code>chmod -R 777 $d</code>";
- $required[$i]['passed'] = FALSE;
+ $required[$i]['passed'] = false;
} else {
$required[$i]['note'] = "The $name directory is not available and we cannot create it automaticalliy.<br />Please execute something like:<br /><code>mkdir -m 777 $d</code>";
- $required[$i]['passed'] = FALSE;
+ $required[$i]['passed'] = false;
}
$i++;
}
foreach( $required as $r ) {
if( !$r['passed'] ) {
- $error = TRUE;
+ $error = true;
}
}
// check extensions
- $php_ext = array(
- 'zlib' => '<a class="external" href="http://www.zlib.net/">The zlib compression libraries</a> are used to pack and unpack compressed files such as .zip files.',
- 'gd' => '<a class="external" href="http://www.boutell.com/gd/">GD Libraries</a> are used to manipulate images. Bitweaver uses these libraries to create thumbnails and convert images from one format to another. If you are running Red Hat or Fedora Core, you can try: <kbd>yum install php-gd</kbd>. The GD libaries are quite limited and <em>don\'t support</em> a number of image formats including <em>.bmp</em>. If you are planning on uploading and using a lot of images, we recommend you use one of the other image processors.',
- 'imagick' => 'ImageMagick supports a multitude of different image and video formats and <em>can be used instead of the GD Libraries</em>. Using these libraries will allow you to upload most image formats without any difficulties. For installation help, please view <a class="external" href="http://www.bitweaver.org/wiki/ImageMagick">ImageMagick and MagickWand installation instructions</a> or visit the <a class="external" href="http://www.imagemagick.org">ImageMagick homepage</a>.',
- 'magickwand' => 'MagickWand is a newer PHP extension for ImageMagick. For installation help, please view Bitweaver\'s: <a class="external" href="http://www.bitweaver.org/wiki/ImageMagick">ImageMagick and MagickWand installation instructions</a> or visit the <a class="external" href="http://www.imagemagick.org">ImageMagick homepage</a>.',
-// 'eAccelerator' => '<a class="external" href="http://eaccelerator.net">eAccelerator</a> increases the efficiency of PHP by caching and optimising queries. Using this extension will greatly increase your server\'s performance and reduce the memory needed to run Bitweaver.',
+ $php_ext = [
+ 'zlib' => '<a class="external" href="http://www.zlib.net/">The zlib compression libraries</a> are used to pack and unpack compressed files such as .zip files.',
+ 'gd' => '<a class="external" href="http://www.boutell.com/gd/">GD Libraries</a> are used to manipulate images. Bitweaver uses these libraries to create thumbnails and convert images from one format to another. If you are running Red Hat or Fedora Core, you can try: <kbd>yum install php-gd</kbd>. The GD libaries are quite limited and <em>don\'t support</em> a number of image formats including <em>.bmp</em>. If you are planning on uploading and using a lot of images, we recommend you use one of the other image processors.',
+ 'imagick' => 'ImageMagick supports a multitude of different image and video formats and <em>can be used instead of the GD Libraries</em>. Using these libraries will allow you to upload most image formats without any difficulties. For installation help, please view <a class="external" href="http://www.bitweaver.org/wiki/ImageMagick">ImageMagick and MagickWand installation instructions</a> or visit the <a class="external" href="http://www.imagemagick.org">ImageMagick homepage</a>.',
+ 'magickwand' => 'MagickWand is a newer PHP extension for ImageMagick. For installation help, please view Bitweaver\'s: <a class="external" href="http://www.bitweaver.org/wiki/ImageMagick">ImageMagick and MagickWand installation instructions</a> or visit the <a class="external" href="http://www.imagemagick.org">ImageMagick homepage</a>.',
// 'ffmpeg' => '<a class="external" href="http://ffmpeg-php.sourceforge.net/">ffmpeg-php</a> is an extension that will allow you to better process uploaded videos. This extension requires ffmpeg to be installed on your server as well.',
- );
+ ];
foreach( $php_ext as $ext => $note ) {
- $extensions[$ext]['note'] = 'The extension <strong>'.$ext.'</strong> is ';
+ $extensions[$ext]['note'] = "The extension <strong>$ext</strong> is ";
if( extension_loaded( $ext ) ) {
- $extensions[$ext]['passed'] = TRUE;
+ $extensions[$ext]['passed'] = true;
} else {
$extensions[$ext]['note'] .= 'not ';
- $extensions[$ext]['passed'] = FALSE;
+ $extensions[$ext]['passed'] = false;
}
- $extensions[$ext]['note'] .= 'available.<br />'.$note;
+ $extensions[$ext]['note'] .= "available.<br />$note";
}
// disable one of the imagick / magickwand warnings
- if( $extensions['magickwand']['passed'] == TRUE && $extensions['imagick']['passed'] == FALSE ) {
+ if( $extensions['magickwand']['passed'] == true && $extensions['imagick']['passed'] == false ) {
unset( $extensions['imagick'] );
- } elseif( $extensions['imagick']['passed'] == TRUE && $extensions['magickwand']['passed'] == FALSE ) {
+ } elseif( $extensions['imagick']['passed'] == true && $extensions['magickwand']['passed'] == false ) {
unset( $extensions['magickwand'] );
}
// make sure we show the worning flag if there is a need for it
foreach( $extensions as $info ) {
if( !$info['passed'] ) {
- $warning = TRUE;
+ $warning = true;
}
}
// output has to be verbose that we can catch the output of the shell_exec
// using --help, -h or --version should make applications output something to stdout - this is no guarantee though, bunzip2 doesn't...
- $execs = array(
- 'tar' => array(
- 'command' => 'tar -xvf',
- 'dest_params' => '-C',
- 'testfile' => 'test.tar',
- 'note' => '<strong>Tarball</strong> is a common archiving format on Linux and <a class="external" href="http://www.gnu.org/software/tar/">tar</a> is used to extract .tar files. For windows use <a class="external" href="http://gnuwin32.sourceforge.net/downlinks/libarchive.php">bsdtar</a> from gnuwin32 ( See <a class="external" href="http://www.bitweaver.org/wiki/Windows+installation+notes">Windows notes for installation help</a> ).',
- ),
- 'bzip2' => array(
- 'command' => 'tar -jvxf',
- 'dest_params' => '-C',
- 'testfile' => 'test.tar.bz2',
- 'note' => '<strong>Bzip</strong> is a common compression format on Linux and <a class="external" href="http://www.bzip.org/">bzip2</a> is used to extract .bz2 and in combination with tar .tar.bz2 file. ( For windows see bsdtar above. )',
- ),
- 'gzip' => array(
- 'command' => 'tar -zvxf',
- 'dest_params' => '-C',
- 'testfile' => 'test.tar.gz',
- 'note' => '<strong>Gzip</strong> is a common compression format on Linux and <a class="external" href="http://www.gnu.org/software/gzip/gzip.html">gzip</a> is used to extract .gz and in combination with tar .tar.gz file. ( For windows see bsdtar above. )',
- ),
- 'unzip' => array(
- 'command' => 'unzip -v',
- 'dest_params' => '-d',
- 'testfile' => 'test.zip',
- 'note' => '<strong>Zip</strong> is a common compression format on all operating systems and <a class="external" href="http://www.info-zip.org/">unzip</a> is used to extract .zip files.',
- ),
- 'unrar' => array(
- 'command' => 'unrar x',
- 'dest_params' => '',
- 'testfile' => 'test.rar',
- 'note' => '<strong>Rar</strong> is a common compression format on all operating systems and <a class="external" href="http://www.rarlab.com/rar_add.htm">unrar</a> is used to extract .rar files.',
- ),
- 'gs' => array(
- 'command' => 'gs --version',
- 'note' => '<a class="external" href="http://www.cs.wisc.edu/~ghost/">GhostScript</a> is an interpreter for the PostScript language and for PDF and is used to create PDF previews when uploading PDF files to Fisheye. If you do not have this installed, previews of PDF files will not be generated on upload. If you have difficulties with GhostScript, please try installing a different version. Bitweaver was successfully tested with versions 7.5, 8.15.4, 8.5, 8.54. There where difficulties with version 8.1.',
- 'result' => 'Your version of GhostScript: ',
- ),
- 'graphviz' => array(
- 'command' => 'dot -V',
- 'note' => '<a class="external" href="http://www.graphviz.org/">Graphviz</a> is a way of representing structural information as diagrams of abstract graphs and networks and visualizing that representation. It is used by the {graphviz} Liberty plugin and you only need to install it if you intend to enable that plugin.<br /><em>The Pear::Image_Graphviz plugin is required as well.</em>',
- 'result' => 'Your version of Graphviz: ',
- ),
-// 'ffmpeg' => array(
-// 'command' => 'ffmpeg',
-// 'note' => '<a class="external" href="http://ffmpeg.mplayerhq.hu/">ffmpeg</a> is a hyper fast video and audio encoder that supports many common formats. If you are planning on uploading video and audio files, it\'s recommend that you install this application.',
-// ),
+ $execs = [
+ 'tar' => [
+ 'command' => 'tar -xvf',
+ 'dest_params' => '-C',
+ 'testfile' => 'test.tar',
+ 'note' => '<strong>Tarball</strong> is a common archiving format on Linux and <a class="external" href="http://www.gnu.org/software/tar/">tar</a> is used to extract .tar files. For windows use <a class="external" href="http://gnuwin32.sourceforge.net/downlinks/libarchive.php">bsdtar</a> from gnuwin32 ( See <a class="external" href="http://www.bitweaver.org/wiki/Windows+installation+notes">Windows notes for installation help</a> ).',
+ ],
+ 'bzip2' => [
+ 'command' => 'tar -jvxf',
+ 'dest_params' => '-C',
+ 'testfile' => 'test.tar.bz2',
+ 'note' => '<strong>Bzip</strong> is a common compression format on Linux and <a class="external" href="http://www.bzip.org/">bzip2</a> is used to extract .bz2 and in combination with tar .tar.bz2 file. ( For windows see bsdtar above. )',
+ ],
+ 'gzip' => [
+ 'command' => 'tar -zvxf',
+ 'dest_params' => '-C',
+ 'testfile' => 'test.tar.gz',
+ 'note' => '<strong>Gzip</strong> is a common compression format on Linux and <a class="external" href="http://www.gnu.org/software/gzip/gzip.html">gzip</a> is used to extract .gz and in combination with tar .tar.gz file. ( For windows see bsdtar above. )',
+ ],
+ 'unzip' => [
+ 'command' => 'unzip -v',
+ 'dest_params' => '-d',
+ 'testfile' => 'test.zip',
+ 'note' => '<strong>Zip</strong> is a common compression format on all operating systems and <a class="external" href="http://www.info-zip.org/">unzip</a> is used to extract .zip files.',
+ ],
+ 'unrar' => [
+ 'command' => 'unrar x',
+ 'dest_params' => '',
+ 'testfile' => 'test.rar',
+ 'note' => '<strong>Rar</strong> is a common compression format on all operating systems and <a class="external" href="http://www.rarlab.com/rar_add.htm">unrar</a> is used to extract .rar files.',
+ ],
+ 'gs' => [
+ 'command' => 'gs --version',
+ 'note' => '<a class="external" href="http://www.cs.wisc.edu/~ghost/">GhostScript</a> is an interpreter for the PostScript language and for PDF and is used to create PDF previews when uploading PDF files to Fisheye. If you do not have this installed, previews of PDF files will not be generated on upload. If you have difficulties with GhostScript, please try installing a different version. Bitweaver was successfully tested with versions 7.5, 8.15.4, 8.5, 8.54. There where difficulties with version 8.1.',
+ 'result' => 'Your version of GhostScript: ',
+ ],
+ 'graphviz' => [
+ 'command' => 'dot -V',
+ 'note' => '<a class="external" href="http://www.graphviz.org/">Graphviz</a> is a way of representing structural information as diagrams of abstract graphs and networks and visualizing that representation. It is used by the {graphviz} Liberty plugin and you only need to install it if you intend to enable that plugin.<br /><em>The Pear::Image_Graphviz plugin is required as well.</em>',
+ 'result' => 'Your version of Graphviz: ',
+ ],
+ 'ffmpeg' => [
+ 'command' => 'ffmpeg',
+ 'note' => '<a class="external" href="http://ffmpeg.mplayerhq.hu/">ffmpeg</a> is a hyper fast video and audio encoder that supports many common formats. If you are planning on uploading video and audio files, it\'s recommend that you install this application.',
+ ],
// 'unstuff' => array(
// 'params' => '-xf',
// 'testfile' => 'test.tar',
// 'note' => 'Unstuff is a common compression format on Mac and <strong>unstuff</strong> is used to extract .sit files.',
// ),
- );
+ ];
foreach( $execs as $exe => $app ) {
$executables[$exe]['note'] = 'The application <strong>'.$exe.'</strong> is ';
- if( !empty( $app['testfile'] ) && is_readable( $file = INSTALL_PKG_PATH.'testfiles/'.$app['testfile'] )) {
- $command = $app['command'].' "'.$file.'" '.$app['dest_params'].' "'.TEMP_PKG_PATH.'"';
- } else {
- $command = $app['command'];
- }
+ $command = ( !empty( $app['testfile'] ) && is_readable( $file = INSTALL_PKG_PATH . 'testfiles/' . $app['testfile'] ) ) ? $app['command'] . ' "' . $file . '" ' . $app['dest_params'] . ' "' . TEMP_PKG_PATH . '"' : $app['command'];
if( get_php_setting( 'safe_mode' ) == 'OFF' && $shellResults[$exe] = shell_exec( $command .' 2> '.TEMP_PKG_PATH.'output' ) ) {
- @unlink( TEMP_PKG_PATH.'test.txt' );
- $executables[$exe]['passed'] = TRUE;
+// @unlink( TEMP_PKG_PATH.'test.txt' );
+ $executables[$exe]['passed'] = true;
} elseif ( $shellResults[$exe] = join("", file(TEMP_PKG_PATH.'output')) ) {
if ( strpos( $shellResults[$exe], 'command' ) and strpos( $shellResults[$exe], 'not' ) ) {
$executables[$exe]['note'] .= 'not ';
- $executables[$exe]['passed'] = FALSE;
+ $executables[$exe]['passed'] = false;
$shellResults[$exe] = "";
} else {
- @unlink( TEMP_PKG_PATH.'test.txt' );
- $executables[$exe]['passed'] = TRUE;
+// @unlink( TEMP_PKG_PATH.'test.txt' );
+ $executables[$exe]['passed'] = true;
}
} else {
$executables[$exe]['note'] .= 'not ';
- $executables[$exe]['passed'] = FALSE;
+ $executables[$exe]['passed'] = false;
}
$executables[$exe]['note'] .= 'available.<br />'.$app['note'];
if( !empty( $app['result'] ) && !empty( $shellResults[$exe] )) {
@@ -200,62 +197,58 @@ function check_settings() {
// PEAR checks
- $pears = array(
- 'PEAR' => array(
- 'path' => 'PEAR.php',
- 'note' => 'This check indicates if PEAR is installed and available. To make use of PEAR extensions, you need to make sure that PEAR is installed and the include_path is set in your php.ini file.',
- ),
- 'Auth' => array(
+ $pears = [
+ 'PEAR' => [
+ 'path' => 'PEAR.php',
+ 'note' => 'This check indicates if PEAR is installed and available. To make use of PEAR extensions, you need to make sure that PEAR is installed and the include_path is set in your php.ini file.',
+ ],
+ 'Auth' => [
'path' => 'Auth/Auth.php',
'note' => 'This will allow you to use the PEAR::Auth package to authenticate users on your website.',
'install_command' => 'pear install --onlyreqdeps Auth;',
- ),
- 'Text_Wiki' => array(
+ ],
+ 'Text_Wiki' => [
'path' => 'Text/Wiki.php',
'note' => 'Having PEAR::Text_Wiki installed will make more wiki format parsers available. The following parsers will be recognised and used: Text_Wiki_BBCode, Text_Wiki_Cowiki, Text_Wiki_Creole, Text_Wiki_Doku, Text_Wiki_Mediawiki, Text_Wiki_Tiki',
'install_command' => 'pear install --onlyreqdeps Text_Wiki_BBCode Text_Wiki_Cowiki Text_Wiki_Creole Text_Wiki_Doku Text_Wiki_Mediawiki Text_Wiki_Tiki;',
- ),
- 'Text_Diff' => array(
+ ],
+ 'Text_Diff' => [
'path' => 'Text/Diff.php',
'note' => 'PEAR::Text_Diff makes inline diffing of content available.',
'install_command' => 'pear install --onlyreqdeps Text_Diff;',
- ),
- 'Image_Graphviz' => array(
+ ],
+ 'Image_Graphviz' => [
'path' => 'Image/GraphViz.php',
'note' => 'Pear::Image_Graphviz makes the {graphviz} plugin available. With it you can draw maps of how your Wiki pages are linked to each other. This can be used for informational purposes or a site-map. It requires the application graphviz to be installed on your server as well.',
'install_command' => 'pear install --onlyreqdeps Image_Graphviz;',
- ),
- 'HTMLPurifier' => array(
- 'path' => 'HTMLPurifier.php',
- 'note' => 'HTMLPurifier is an advanced system for defending against Cross Site Scripting (XSS) attacks and ensuring that all code on your site is standards compliant. It is highly recommended if you are going to allow HTML submission to your site. It is not required if you are only going to allow the input of a Wiki format like Tikiwiki or BBcode. You also need to enable it in the Liberty plugins administration after installation. See <a class="external" href="http://www.bitweaver.org/wiki/HTMLPurifier">http://www.bitweaver.org/wiki/HTMLPurifier</a> and <a class = "external" href = "http: // htmlpurifier.org">http://htmlpurifier.org</a> for more information.',
- 'install_command' => 'pear channel-discover htmlpurifier.org;<br />pear install hp/HTMLPurifier;',
- ),
- 'HTTP_Download' => array(
+ ],
+// 'HTMLPurifier' => [
+// 'path' => 'HTMLPurifier.php',
+// 'note' => 'HTMLPurifier is an advanced system for defending against Cross Site Scripting (XSS) attacks and ensuring that all code on your site is standards compliant. It is highly recommended if you are going to allow HTML submission to your site. It is not required if you are only going to allow the input of a Wiki format like Tikiwiki or BBcode. You also need to enable it in the Liberty plugins administration after installation. See <a class="external" href="http://www.bitweaver.org/wiki/HTMLPurifier">http://www.bitweaver.org/wiki/HTMLPurifier</a> and <a class = "external" href = "http: // htmlpurifier.org">http://htmlpurifier.org</a> for more information.',
+// 'install_command' => 'pear channel-discover htmlpurifier.org;<br />pear install hp/HTMLPurifier;',
+// ],
+ 'HTTP_Download' => [
'path' => 'HTTP/Download.php',
'note' => 'Treasury - the file manager of Bitweaver - can make use of PEAR::HTTP_Download to provide more reliable downloads and download resume support when using a download manager.',
'install_command' => 'pear install --alldeps HTTP_Download;',
- ),
- );
+ ],
+ ];
foreach( $pears as $pear => $info ) {
- if( $pear == 'PEAR' ) {
- $pearexts[$pear]['note'] = '<strong>'.$pear.'</strong> is ';
- } else {
- $pearexts[$pear]['note'] = 'The extension <strong>PEAR::'.$pear.'</strong> is ';
- }
+ $pearexts[$pear]['note'] = ( $pear == 'PEAR' ) ? "<strong>$pear</strong> is " : "The extension <strong>PEAR::$pear</strong> is ";
- if( @include_once( $info['path'] )) {
- $pearexts[$pear]['passed'] = TRUE;
+ if ( @include_once( $info['path'] )) {
+ $pearexts[$pear]['passed'] = true;
} else {
$pearexts[$pear]['note'] .= 'not ';
- $pearexts[$pear]['passed'] = FALSE;
+ $pearexts[$pear]['passed'] = false;
}
$pearexts[$pear]['original_note'] = $info['note'];
$pearexts[$pear]['note'] .= 'available.<br />';
$pearexts[$pear]['note'] .= $info['note'];
- if( !empty( $info['install_command'] ) && $pearexts[$pear]['passed'] == FALSE ) {
+ if( !empty( $info['install_command'] ) && $pearexts[$pear]['passed'] == false ) {
$pearexts[$pear]['note'] .= '<br /><em>Install using this command:</em><br /><code>'.$info['install_command'].'</code>';
}
}
@@ -263,50 +256,47 @@ function check_settings() {
$i = 0;
// recommended php toggles - these don't need explicit explanations on how to rectify them
// start with special cases
- $recommended[$i] = array( 'Memory Limit','memory_limit','shouldbe' => 'at least 16M', 'actual' => get_cfg_var( 'memory_limit' ) );
+ $recommended[$i] = [ 'Memory Limit', 'memory_limit', 'shouldbe' => 'at least 16M', 'actual' => get_cfg_var( 'memory_limit' ) ];
if( preg_replace( '/M/i','',get_cfg_var( 'memory_limit' ) ) > 15 ) {
- $recommended[$i]['passed'] = TRUE;
+ $recommended[$i]['passed'] = true;
} else {
- $recommended[$i]['passed'] = FALSE;
- $gBitSmarty->assign( 'memory_warning', TRUE );
+ $recommended[$i]['passed'] = false;
+ $gBitSmarty->assign( 'memory_warning', true );
}
$i++;
// now continue with easy toggle checks
- $php_rec_toggles = array(
- array( 'Safe Mode','safe_mode','shouldbe' => 'OFF', ),
- array( 'Display Errors','display_errors','shouldbe' => 'OFF' ),
- array( 'File Uploads','file_uploads','shouldbe' => 'ON' ),
- array( 'Magic Quotes GPC','magic_quotes_gpc','shouldbe' => 'OFF' ),
- array( 'Magic Quotes Runtime','magic_quotes_runtime','shouldbe' => 'OFF' ),
- array( 'Magic Quotes Sybase','magic_quotes_sybase','shouldbe' => 'OFF' ),
- array( 'Register Globals','register_globals','shouldbe' => 'OFF' ),
- array( 'Output Buffering','output_buffering','shouldbe' => 'OFF' ),
- array( 'Session auto start','session.auto_start','shouldbe' => 'OFF' ),
- );
+ $php_rec_toggles = [
+ [ 'Display Errors', 'display_errors', 'shouldbe' => 'OFF' ],
+ [ 'File Uploads', 'file_uploads', 'shouldbe' => 'ON' ],
+ [ 'Output Buffering', 'output_buffering', 'shouldbe' => 'OFF' ],
+ [ 'Session auto start', 'session.auto_start', 'shouldbe' => 'OFF' ],
+ [ 'Log Errors', 'log_errors', 'shouldbe' => 'ON' ],
+ [ 'Session Cookie HttpOnly', 'session.cookie_httponly', 'shouldbe' => 'ON' ],
+ [ 'Session Cookie Secure', 'session.cookie_secure', 'shouldbe' => 'ON' ],
+ ];
foreach( $php_rec_toggles as $php_rec_toggle ) {
$php_rec_toggle['actual'] = get_php_setting( $php_rec_toggle[1] );
- if( get_php_setting( $php_rec_toggle[1] ) == $php_rec_toggle['shouldbe'] ) {
- $php_rec_toggle['passed'] = TRUE;
- } else {
- $php_rec_toggle['passed'] = FALSE;
- }
+ $php_rec_toggle['passed'] = ( get_php_setting( $php_rec_toggle[1] ) == $php_rec_toggle['shouldbe'] ) ? true : false;
$recommended[] = $php_rec_toggle;
$i++;
}
// settings that are useful to know about
- $php_ini_gets = array(
- array( '<strong>Maximum post size</strong> restricts the size of files uploaded using a form. <br />Recommended: at least <strong>8M</strong>.', 'post_max_size' ),
- array( '<strong>Upload max filesize</strong> is related to maximim post size and will also limit the size of uploads. <br />Recommended: at least <strong>8M</strong>.', 'upload_max_filesize' ),
- array( '<strong>Maximum execution time</strong> is related to time outs in PHP. It affects database upgrades and backups. <br />Recommended: <strong>60</strong>.', 'max_execution_time' ),
- );
+ $php_ini_gets = [
+ [ '<strong>Maximum post size</strong> restricts the size of files uploaded using a form. <br />Recommended: at least <strong>8M</strong>.', 'post_max_size' ],
+ [ '<strong>Upload max filesize</strong> is related to maximim post size and will also limit the size of uploads. <br />Recommended: at least <strong>8M</strong>.', 'upload_max_filesize' ],
+ [ '<strong>Maximum execution time</strong> is related to time outs in PHP. It affects database upgrades and backups. <br />Recommended: <strong>60</strong>.', 'max_execution_time' ],
+ ];
foreach( $php_ini_gets as $php_ini_get ) {
$value = ini_get( $php_ini_get[1] );
- if( $value == 1 ) {
- $value = "On";
- } elseif( $value == 0 ) {
- $value = "Off";
+ switch ($value) {
+ case 1:
+ $value = "On";
+ break;
+ case 0:
+ $value = "Off";
+ break;
}
$show[$php_ini_get[1]] = $php_ini_get[0]."<br /><strong>{$php_ini_get[1]}</strong> is set to <strong>$value</strong>";
@@ -328,4 +318,3 @@ function get_php_setting( $val ) {
$r = ( ini_get( $val ) == '1' ? 1 : 0 );
return $r ? 'ON' : 'OFF';
}
-?>
diff --git a/includes/install_cleanup.php b/includes/install_cleanup.php
index e7e9085..f45a9ef 100644..100755
--- a/includes/install_cleanup.php
+++ b/includes/install_cleanup.php
@@ -10,7 +10,7 @@ $gBitSmarty->assign( 'next_step', $step );
$schema = $gBitInstaller->mPackages;
ksort( $schema );
-$gBitSmarty->assignByRef( 'schema', $schema );
+$gBitSmarty->assign( 'schema', $schema );
@@ -31,12 +31,8 @@ while( !$result->EOF ) {
foreach( $result->fields as $r ) {
$bitPerms[$result->fields['perm_name']][] = $r;
}
- if ( defined( 'ROLE_MODEL' ) ) {
- $bitPerms[$result->fields['perm_name']]['sql'][] = "DELETE FROM `".BIT_DB_PREFIX."users_role_permissions` WHERE `perm_name`='".$result->fields['perm_name']."'";
- } else {
- $bitPerms[$result->fields['perm_name']]['sql'][] = "DELETE FROM `".BIT_DB_PREFIX."users_group_permissions` WHERE `perm_name`='".$result->fields['perm_name']."'";
- }
- $bitPerms[$result->fields['perm_name']]['sql'][] = "DELETE FROM `".BIT_DB_PREFIX."users_permissions` WHERE `perm_name`='".$result->fields['perm_name']."'";
+ $bitPerms[$result->fields['perm_name']]['sql'][] = ( defined( 'ROLE_MODEL' ) ) ? "DELETE FROM `" . BIT_DB_PREFIX . "users_role_permissions` WHERE `perm_name`='" . $result->fields['perm_name'] . "'" : "DELETE FROM `" . BIT_DB_PREFIX . "users_group_permissions` WHERE `perm_name`='" . $result->fields['perm_name'] . "'";
+ $bitPerms[$result->fields['perm_name']]['sql'][] = "DELETE FROM `" . BIT_DB_PREFIX . "users_permissions` WHERE `perm_name`='" . $result->fields['perm_name'] . "'";
$result->MoveNext();
}
@@ -44,11 +40,11 @@ while( !$result->EOF ) {
// update these without consulting the user. this is purely backend stuff, has
// no outcome on the site itself but determines what the default permission
// level is. the user can never modify these settings.
-foreach( array_keys( $gBitInstaller->mPermHash ) as $perm ) {
+foreach ( array_keys( $gBitInstaller->mPermHash ) as $perm ) {
// permission level is stored in [2]
- $bindVars = array();
- if( !empty( $bitPerms[$perm] ) && $gBitInstaller->mPermHash[$perm][2] != $bitPerms[$perm][2] ) {
- $query = "UPDATE `".BIT_DB_PREFIX."users_permissions` SET `perm_level` = ? WHERE `perm_name` = ?";
+ $bindVars = [];
+ if (!empty( $bitPerms[$perm] ) && $gBitInstaller->mPermHash[$perm][2] != $bitPerms[$perm][2]) {
+ $query = "UPDATE `" . BIT_DB_PREFIX . "users_permissions` SET `perm_level` = ? WHERE `perm_name` = ?";
$bindVars[] = $gBitInstaller->mPermHash[$perm][2];
$bindVars[] = $perm;
$gBitInstaller->mDb->query( $query, $bindVars );
@@ -57,25 +53,23 @@ foreach( array_keys( $gBitInstaller->mPermHash ) as $perm ) {
// compare both perm arrays with each other and work out what permissions need
// to be added and which ones removed
-$insPerms = $delPerms = array();
-foreach( array_keys( $gBitInstaller->mPermHash ) as $perm ) {
- if( !in_array( $perm, array_keys( $bitPerms ))) {
- if( $gBitInstaller->isInstalled( $gBitInstaller->mPermHash[$perm][3] )) {
+$insPerms = $delPerms = [];
+foreach ( array_keys( $gBitInstaller->mPermHash ) as $perm ) {
+ if (!in_array( $perm, array_keys( $bitPerms ) )) {
+ if ($gBitInstaller->isInstalled( $gBitInstaller->mPermHash[$perm][3] )) {
$insPerms[$perm] = $gBitInstaller->mPermHash[$perm];
}
}
}
-foreach( array_keys( $bitPerms ) as $perm ) {
- if( !in_array( $perm, array_keys( $gBitInstaller->mPermHash ) ) ) {
+foreach ( array_keys( $bitPerms ) as $perm ) {
+ if (!in_array( $perm, array_keys( $gBitInstaller->mPermHash ) )) {
$delPerms[$perm] = $bitPerms[$perm];
}
}
$gBitSmarty->assign( 'delPerms', $delPerms );
$gBitSmarty->assign( 'insPerms', $insPerms );
-
-
// ===================== Services =====================
// check if we have installed more than one service of any given type
// DEPRECATED - this check never really made sense. The original purpose
@@ -85,7 +79,7 @@ $gBitSmarty->assign( 'insPerms', $insPerms );
// service type. This could revert back with time. For now this is commented
// out.
/*
-$serviceList = array();
+$serviceList = [];
if( !empty( $gLibertySystem->mServices ) ) {
foreach( $gLibertySystem->mServices as $service_name => $service ) {
if( count( $service ) > 1 ) {
@@ -95,34 +89,25 @@ if( !empty( $gLibertySystem->mServices ) ) {
}
*/
-
-
// ===================== Process Form =====================
// create missing tables if possible
-if( !empty( $_REQUEST['create_tables'] ) && !empty( $dbIntegrity )) {
- $gBitInstallDb = &ADONewConnection( $gBitDbType );
+if (!empty( $_REQUEST['create_tables'] ) && !empty( $dbIntegrity )) {
+ $gBitInstallDb = ADONewConnection( $gBitDbType );
- if( $gBitInstallDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName )) {
- $dict = NewDataDictionary( $gBitInstallDb );
+ if ($gBitInstallDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbType != 'pdo' ? $gBitDbName : NULL )) {
+ $dict = NewDataDictionary( $gBitInstallDb, 'firebird' );
- if( !$gBitInstaller->mDb->getCaseSensitivity() ) {
+ if (!$gBitInstaller->mDb->getCaseSensitivity()) {
$dict->connection->nameQuote = '';
}
- if( !empty( $gDebug ) || !empty( $_REQUEST['debug'] )) {
+ if (!empty( $gDebug ) || !empty( $_REQUEST['debug'] )) {
$gBitInstallDb->debug = 99;
}
// If we use MySql check which storage engine to use
- if( isset( $_SESSION['use_innodb'] ) ){
- if( $_SESSION['use_innodb'] == TRUE ) {
- $build = array('NEW', 'MYSQL' => 'ENGINE=INNODB');
- } else {
- $build = array('NEW', 'MYSQL' => 'ENGINE=MYISAM');
- }
- } else {
- $build = 'NEW';
- }
+ $build = isset( $_SESSION['use_innodb'] )
+ ? ( ( $_SESSION['use_innodb'] == true ) ? [ 'NEW', 'MYSQL' => 'ENGINE=INNODB' ] : [ 'NEW', 'MYSQL' => 'ENGINE=MYISAM' ] ) : 'NEW';
$tablePrefix = $gBitInstaller->getTablePrefix();
foreach( $dbIntegrity as $package => $info ) {
@@ -145,8 +130,8 @@ if( !empty( $_REQUEST['resolve_conflicts'] ) ) {
$gBitInstallDb->debug = 99;
}
// === Permissions
- $fixedPermissions = array();
- $permMap = array();
+ $fixedPermissions = [];
+ $permMap = [];
$permMap['basic'] = ANONYMOUS_TEAM_ID;
$permMap['registered'] = 3;
$permMap['editors'] = 2;
@@ -167,7 +152,7 @@ if( !empty( $_REQUEST['resolve_conflicts'] ) ) {
if ( defined( 'ROLE_MODEL' ) ) {
$gBitUser->assignPermissionToRole( $perm, $permMap[$insPerms[$perm][2]] );
} else {
- $gBitUser->assignPermissionToGroup( $perm, $permMap[$insPerms[$perm][2]] );
+ $gBitUser->assignPermissionToRole( $perm, $permMap[$insPerms[$perm][2]] );
}
}
}
@@ -176,10 +161,10 @@ if( !empty( $_REQUEST['resolve_conflicts'] ) ) {
$gBitSmarty->assign( 'fixedPermissions', $fixedPermissions );
// === Services
- $deActivated = array();
+ $deActivated = [];
foreach( $serviceList as $service ) {
foreach( array_keys( $service ) as $package ) {
- $packages = !empty( $_REQUEST['packages'] ) ? $_REQUEST['packages'] : array();
+ $packages = !empty( $_REQUEST['packages'] ) ? $_REQUEST['packages'] : [];
if( !in_array( $package, $packages )) {
$gBitSystem->storeConfig( 'package_'.$package, 'n', KERNEL_PKG_NAME );
$deActivated[] = $package;
@@ -211,25 +196,24 @@ $gBitSmarty->assign( 'dbIntegrity', $dbIntegrity );
*/
function install_check_database_integrity( $pDbTables ) {
global $gBitInstaller;
- $ret = array();
+ $ret = [];
if( !empty( $pDbTables['missing'] ) && is_array( $pDbTables['missing'] )) {
foreach( array_keys( $pDbTables['missing'] ) as $package ) {
// we can't use the 'installed' flag in $gBitInstaller->mPackages[$package] because that is set to 'not installed' as soon as a table is missing
if( count( $gBitInstaller->mPackages[$package]['tables'] ) > count( $pDbTables['missing'][$package] )) {
// at least one table is missing
- $ret[$package] = array(
+ $ret[$package] = [
'name' => ucfirst( $gBitInstaller->mPackages[$package]['name'] ),
'required' => $gBitInstaller->mPackages[$package]['required'],
- );
+ ];
foreach( $pDbTables['missing'][$package] as $table ) {
- $ret[$package]['tables'][$table] = array(
+ $ret[$package]['tables'][$table] = [
'name' => $table,
'sql' => $gBitInstaller->mPackages[$package]['tables'][$table],
- );
+ ];
}
}
}
}
return $ret;
}
-?>
diff --git a/includes/install_database.php b/includes/install_database.php
index 5dd7838..07d24e2 100644..100755
--- a/includes/install_database.php
+++ b/includes/install_database.php
@@ -10,7 +10,7 @@
*/
$gBitSmarty->assign( 'next_step',$step );
-require_once( "includes/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'] )) {
@@ -29,7 +29,7 @@ if( isset( $_REQUEST['submit_db_info'] )) {
$gBitDb = ADONewConnection( $gBitDbType );
- if( $gBitDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName )) {
+ if( $gBitDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbType != 'pdo' ? $gBitDbName : NULL )) {
// display success page when done
$app = '_done';
$gBitSmarty->assign( 'next_step',$step + 1 );
@@ -74,5 +74,4 @@ if( isset( $_REQUEST['submit_db_info'] )) {
$error = TRUE;
}
}
-}
-?>
+} \ No newline at end of file
diff --git a/includes/install_database_reset.php b/includes/install_database_reset.php
index fbbc383..7a3f234 100644..100755
--- a/includes/install_database_reset.php
+++ b/includes/install_database_reset.php
@@ -11,7 +11,7 @@
// assign next step in installation process
$gBitSmarty->assign( 'next_step',$step );
-//vd($_REQUEST);
+
if( isset( $_REQUEST['continue_install'] ) ) {
header( 'Location: '.INSTALL_PKG_URL.'install.php?step='.( $step + 1 ) );
} elseif( isset( $_REQUEST['reset_config_inc'] ) ) {
@@ -21,5 +21,4 @@ if( isset( $_REQUEST['continue_install'] ) ) {
fclose( $fw );
}
header( 'Location: '.INSTALL_PKG_URL.'install.php' );
-}
-?>
+} \ No newline at end of file
diff --git a/includes/install_datapump.php b/includes/install_datapump.php
index 70f3dab..2806d3d 100644..100755
--- a/includes/install_datapump.php
+++ b/includes/install_datapump.php
@@ -14,7 +14,7 @@ $gBitSmarty->assign( 'next_step',$step );
$gBitUser->mUserId = ROOT_USER_ID;
-$pumpList = array();
+$pumpList = [];
foreach( array_keys( $gBitSystem->mPackages ) as $package ) {
if( $gBitInstaller->isPackageActive( $package ) ) {
$file = constant( strtoupper( $package ).'_PKG_PATH' ).'admin/pump_'.$package.'_inc.php';
@@ -29,7 +29,7 @@ $gBitSmarty->assign( 'pumpList', $pumpList );
* datapump setup
*/
if( isset( $_REQUEST['fSubmitDataPump'] ) ) {
- $pumpedData = array();
+ $pumpedData = [];
if( !empty( $_REQUEST['pump_package'] ) ) {
foreach( $_REQUEST['pump_package'] as $package ) {
if( $gBitInstaller->isPackageActive( $package ) ) {
@@ -51,5 +51,4 @@ if( isset( $_REQUEST['fSubmitDataPump'] ) ) {
$gBitSmarty->assign( 'next_step',$goto );
header( "Location: ".INSTALL_PKG_URL."install.php?step=$goto" );
die;
-}
-?>
+} \ No newline at end of file
diff --git a/includes/install_final.php b/includes/install_final.php
index 315bfd5..9478135 100644..100755
--- a/includes/install_final.php
+++ b/includes/install_final.php
@@ -9,5 +9,4 @@
$app = '_done';
if( !empty( $_SESSION['first_install'] ) ) {
$_SESSION = NULL;
-}
-?>
+} \ No newline at end of file
diff --git a/includes/install_inc.php b/includes/install_inc.php
index b1028f8..6da72b9 100644..100755
--- a/includes/install_inc.php
+++ b/includes/install_inc.php
@@ -1,4 +1,9 @@
<?php
+
+use Bitweaver\BitSystem;
+use Bitweaver\Plugins\ResourceBitpackage;
+use Bitweaver\Themes\BitSmarty;
+use Bitweaver\Themes\BitweaverExtension;
/**
* @version $Header$
* @package install
@@ -18,32 +23,33 @@ function set_menu( $pInstallFiles, $pStep ) {
// here we set up the menu
for( $done = 0; $done < $pStep; $done++ ) {
$pInstallFiles[$done]['state'] = 'complete';
- $pInstallFiles[$done]['icon'] = 'fa-check';
+ $pInstallFiles[$done]['icon'] = 'icon-ok';
}
// if the page is done, we can display the menu item as done and increase the progress bar
if( $failedcommands || !empty( $error ) ) {
$pInstallFiles[$pStep]['state'] = 'error';
- $pInstallFiles[$pStep]['icon'] = 'fa-octagon-exclamation';
+ $pInstallFiles[$pStep]['icon'] = 'dialog-error';
} elseif( !empty( $warning ) ) {
$pInstallFiles[$pStep]['state'] = 'warning';
- $pInstallFiles[$pStep]['icon'] = 'fa-triangle-exclamation';
+ $pInstallFiles[$pStep]['icon'] = 'dialog-warning';
} elseif( $app == "_done" ) {
$pInstallFiles[$pStep]['state'] = 'complete';
- $pInstallFiles[$pStep]['icon'] = 'fa-check';
+ $pInstallFiles[$pStep]['icon'] = 'icon-ok';
$done++;
} else {
$pInstallFiles[$pStep]['state'] = 'current';
- $pInstallFiles[$pStep]['icon'] = 'fa-angle-right';
+ $pInstallFiles[$pStep]['icon'] = 'media-playback-start';
}
foreach( $pInstallFiles as $key => $menu_step ) {
if( !isset( $menu_step['state'] ) ) {
if( !empty( $gBitDbType ) && $gBitUser->isAdmin() && !$_SESSION['first_install'] ) {
$pInstallFiles[$key]['state'] = 'complete';
- $pInstallFiles[$key]['icon'] = 'fa-check';
+ $pInstallFiles[$key]['icon'] = 'icon-ok';
} else {
$pInstallFiles[$key]['state'] = 'uncompleted';
+ $pInstallFiles[$key]['icon'] = 'spacer';
}
}
}
@@ -51,6 +57,7 @@ function set_menu( $pInstallFiles, $pStep ) {
// 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;
}
@@ -60,27 +67,30 @@ function set_menu( $pInstallFiles, $pStep ) {
*/
define( 'BIT_INSTALL', 'TRUE' );
// Uncomment to switch to role team model ...
-//define( 'ROLE_MODEL', 'TRUE' );
+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);
+$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 ) ) {
+ if ( $_REQUEST['db'] == "firebird" || $_REQUEST['db'] == "pdo" && 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']);
+ require_once "create_firebird_database.php";
+ FirebirdCreateDB($_REQUEST['db'] == "pdo" ? "localhost" : $_REQUEST['host'], $_REQUEST['user'], $_REQUEST['pass'], $_REQUEST['name'], $_REQUEST['fbpath']);
}
}
if ( empty( $gBitDbType ) ) {
$tmpHost = $_REQUEST['host'];
- require_once( 'create_config_inc.php' );
- $createHash = array(
+ if ($_REQUEST['db'] == 'mssql') { // pull doubled up slashes from config
+ $tmpHost = stripslashes($tmpHost);
+ }
+ require_once 'create_config_inc.php';
+ $createHash = [
"gBitDbType" => $_REQUEST['db'],
"gBitDbHost" => $tmpHost,
"gBitDbUser" => $_REQUEST['user'],
@@ -89,21 +99,21 @@ if( isset( $_REQUEST['submit_db_info'] ) ) {
"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',
- );
+ "auto_bug_submit" => !empty( $_REQUEST['auto_bug_submit'] ) ? 'true' : 'false',
+ "is_live" => !empty( $_REQUEST['is_live'] ) ? 'true' : 'false',
+ ];
create_config( $createHash );
- include( $config_file );
+ include $config_file;
}
}
-require_once( '../kernel/includes/setup_inc.php' );
-require_once( INSTALL_PKG_CLASS_PATH.'BitInstaller.php' );
+require_once '../kernel/includes/setup_inc.php';
+use \Bitweaver\Install\BitInstaller;
-if ( defined( 'ROLE_MODEL' ) ) {
- require_once( USERS_PKG_CLASS_PATH.'RoleUser.php' );
+/* if ( defined( 'ROLE_MODEL' ) ) {
+ use Bitweaver\Users\RoleUser;
} else {
- require_once( USERS_PKG_CLASS_PATH.'BitUser.php' );
-}
+ use Bitweaver\Users\BitUser;
+} */
// set some preferences during installation
global $gBitInstaller, $gBitSystem, $gBitThemes;
@@ -125,9 +135,9 @@ $gBitSystem->setConfig( 'site_online_help', 'y' );
$gBitSystem->setConfig( 'site_form_help', 'y' );
$gBitSystem->setConfig( 'site_help_popup', 'n' );
-$commands = array();
+$commands = [];
global $failedcommands;
-$failedcommands = array();
+$failedcommands = [];
global $gBitLanguage;
$gBitLanguage->mLanguage = 'en';
@@ -136,18 +146,16 @@ 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;
-}
+$bit_root_url = empty( $_REQUEST['baseurl'] )
+ ? substr( $_SERVER['SCRIPT_NAME'], 0, strpos( $_SERVER['SCRIPT_NAME'], 'install/' ))
+ : BIT_ROOT_URL;
global $gBitUser;
if( !empty( $_POST['signin'] ) ) {
$gBitInstaller->login( $_REQUEST['user'], $_REQUEST['pass'] );
} elseif( is_object( $gBitUser ) && !empty( $_COOKIE[$gBitUser->getSiteCookieName()] ) && ( $gBitUser->mUserId = $gBitUser->getUserIdFromCookieHash( $_COOKIE[$gBitUser->getSiteCookieName()] ))) {
- $userInfo = $gBitUser->getUserInfo( array( 'user_id' => $gBitUser->mUserId ) );
+ $userInfo = $gBitUser->getUserInfo( [ 'user_id' => $gBitUser->mUserId ] );
if( $userInfo['user_id'] != ANONYMOUS_USER_ID ) {
// User is valid and not due to change pass..
diff --git a/includes/install_options.php b/includes/install_options.php
index aab0529..f4a93d1 100644..100755
--- a/includes/install_options.php
+++ b/includes/install_options.php
@@ -9,7 +9,7 @@
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
-//$gBitSmarty->assign( 'next_step',$step );
+$gBitSmarty->assign( 'next_step',$step );
if( isset( $_REQUEST['upgrade'] ) ) {
$_SESSION['upgrade'] = TRUE;
$_SESSION['first_install'] = TRUE;
@@ -34,4 +34,3 @@ if( isset( $_REQUEST['upgrade'] ) ) {
} else {
$gBitSmarty->assign( 'next_step',$step );
}
-?>
diff --git a/includes/install_packages.php b/includes/install_packages.php
index e8e63c7..052c29d 100644..100755
--- a/includes/install_packages.php
+++ b/includes/install_packages.php
@@ -1,4 +1,9 @@
<?php
+
+use Bitweaver\BitDb;
+use Bitweaver\Users\BitPermUser;
+use Bitweaver\Users\RolePermUser;
+
/**
* @version $Header$
* @package install
@@ -25,7 +30,7 @@ $gBitSmarty->assign( 'next_step', $step );
// pass all package data to template
$schema = $gBitInstaller->mPackages;
ksort( $schema );
-$gBitSmarty->assignByRef( 'schema', $schema );
+$gBitSmarty->assign( 'schema', $schema );
// confirm that we have all the admin data in the session before proceeding
if( !empty( $_REQUEST['packages'] ) && in_array( 'users', $_REQUEST['packages'] ) && ( empty( $_SESSION['login'] ) || empty( $_SESSION['password'] ) || empty( $_SESSION['email'] ) ) ) {
@@ -38,7 +43,7 @@ if( !empty( $_REQUEST['cancel'] ) ) {
header( 'Location: '.INSTALL_PKG_URL.'install.php?step='.( $step + 1 ) );
} elseif( !empty( $_REQUEST['packages'] ) && is_array( $_REQUEST['packages'] ) && !empty( $_REQUEST['method'] ) && !empty( $_REQUEST['submit_packages'] ) ) {
// shorthand for the actions we are supposed to perform during an unistall or re-install
- $removeActions = !empty( $_REQUEST['remove_actions'] ) ? $_REQUEST['remove_actions'] : array();
+ $removeActions = !empty( $_REQUEST['remove_actions'] ) ? $_REQUEST['remove_actions'] : [];
// Override reinstall/uninstall flag
if ( $_REQUEST['submit_packages'] == 'Install Packages' ) $_REQUEST['method'] = 'install';
@@ -70,7 +75,7 @@ if( !empty( $_REQUEST['cancel'] ) ) {
}
// by now $method should be populated with something
- if( $gBitInstallDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName ) && !empty( $method ) ) {
+ if( $gBitInstallDb->Connect( $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbType != 'pdo' ? $gBitDbName : NULL ) && !empty( $method ) ) {
if ( $_SESSION['first_install'] && $gBitDbType == 'firebird' ) {
// Leave commented for present, new installations on Firebird should use FB2.1.x and above which have an internal function library
// $result = $gBitInstallDb->Execute( "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'" );
@@ -79,7 +84,7 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$tablePrefix = $gBitInstaller->getTablePrefix();
- $dict = NewDataDictionary( $gBitInstallDb );
+ $dict = NewDataDictionary( $gBitInstallDb, 'firebird' );
if( !$gBitInstaller->mDb->getCaseSensitivity() ) {
// set nameQuote to blank
@@ -109,7 +114,7 @@ if( !empty( $_REQUEST['cancel'] ) ) {
}
}
- $sqlArray = array();
+ $sqlArray = [];
//error_reporting( E_ALL );
// packages are sorted alphabetically. but we really need a /etc/rc.d/rc.3 style loading precidence!
@@ -118,14 +123,14 @@ if( !empty( $_REQUEST['cancel'] ) ) {
sort( $_REQUEST['packages'] );
// Need to unquote constraints. but this need replacing with a datadict function
- require_once( KERNEL_PKG_CLASS_PATH.'BitDbBase.php');
+
$gBitKernelDb = new BitDb();
$gBitKernelDb->mType = $gBitDbType;
// ---------------------- 1. ----------------------
// let's generate all the tables's
$gBitInstallDb->StartTrans();
- $uninstalledPackages = array();
+ $uninstalledPackages = [];
// get a list of packages to install maintained gScanOrder from mPackages
foreach( array_keys( $gBitInstaller->mPackages ) as $p ) {
if( in_array( $p, $_REQUEST['packages'] ) ) {
@@ -136,16 +141,16 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$maxLoop = count( $uninstalledPackages ) * count( $uninstalledPackages );
$i = 0;
- $installedPackages = array();
+ $installedPackages = [];
foreach( array_keys( $gBitInstaller->mPackages ) as $key ) {
- if( !empty( $gBitInstaller->mPackages[$package]['installed'] ) ) {
+ if( !empty( $gBitInstaller->mPackages[$key]['installed'] ) ) {
array_push( $installedPackages, $package );
}
}
do {
$package = array_shift( $uninstalledPackages );
- $dependentPackages = (!empty( $gBitInstaller->mPackages[$package]['info']['dependencies'] ) ? explode( ',', $gBitInstaller->mPackages[$package]['info']['dependencies'] ) : array());
+ $dependentPackages = (!empty( $gBitInstaller->mPackages[$package]['info']['dependencies'] ) ? explode( ',', $gBitInstaller->mPackages[$package]['info']['dependencies'] ) : []);
$dependentsInstalled = array_intersect( $dependentPackages, $installedPackages );
$dependentsUninstalled = array_intersect( $dependentPackages, $uninstalledPackages );
if( !empty( $dependentPackages ) && (count( $dependentsUninstalled ) + count( $dependentsInstalled )) != count( $dependentPackages ) ) {
@@ -156,37 +161,32 @@ if( !empty( $_REQUEST['cancel'] ) ) {
unset( $build );
// work out what we're going to do with this package
if ( $method == 'install' && $_SESSION['first_install'] ) {
- $build = array( 'NEW' );
+ $build = [ 'NEW' ];
} elseif( $method == "install" && empty( $gBitInstaller->mPackages[$package]['installed'] )) {
- $build = array( 'NEW' );
+ $build = [ 'NEW' ];
} elseif( $method == "reinstall" && !empty( $gBitInstaller->mPackages[$package]['installed'] ) && in_array( 'tables', $removeActions )) {
// only set $build if we want to reset the tables - this allows us to reset a package to it's starting values without deleting any content
- $build = array( 'REPLACE' );
+ $build = [ 'REPLACE' ];
} elseif( $method == "uninstall" && !empty( $gBitInstaller->mPackages[$package]['installed'] ) && in_array( 'tables', $removeActions )) {
- $build = array( 'DROP' );
+ $build = [ 'DROP' ];
}
// If we use MySql and not DROP anything
// set correct storage engine to use
if( isset( $_SESSION['use_innodb'] ) && isset( $build ) && $build['0'] != 'DROP' ){
- if( $_SESSION['use_innodb'] == TRUE) {
- $build = array_merge($build, array('MYSQL' => 'ENGINE=INNODB'));
- } else {
- $build = array_merge($build, array('MYSQL' => 'ENGINE=MYISAM'));
- }
+ $build = ( $_SESSION['use_innodb'] == true ) ? [ ...$build, 'MYSQL' => 'ENGINE=INNODB' ] : [ ...$build, 'MYSQL' => 'ENGINE=MYISAM' ];
}
// Install tables - $build is empty when we don't pick tables, when un / reinstalling packages
- if( !empty( $gBitInstaller->mPackages[$package]['tables'] ) && is_array( $gBitInstaller->mPackages[$package]['tables'] ) && !empty( $build )) {
- foreach( array_keys( $gBitInstaller->mPackages[$package]['tables'] ) as $tableName ) {
- $completeTableName = $tablePrefix.$tableName;
+ if (!empty( $gBitInstaller->mPackages[$package]['tables'] ) && is_array( $gBitInstaller->mPackages[$package]['tables'] ) && !empty( $build )) {
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['tables'] ) as $tableName ) {
+ $completeTableName = $tablePrefix . $tableName;
// in case prefix has backticks for schema
$sql = $dict->CreateTableSQL( $completeTableName, $gBitInstaller->mPackages[$package]['tables'][$tableName], $build );
- // Uncomment this line to see the create sql
- for( $sqlIdx = 0; $sqlIdx < count( $sql ); $sqlIdx++ ) {
+ for ( $sqlIdx = 0; $sqlIdx < count( $sql ); $sqlIdx++ ) {
$gBitKernelDb->convertQuery( $sql[$sqlIdx] );
}
- if( $sql && $dict->ExecuteSQLArray( $sql ) <= 1) {
- $errors[] = 'Failed to create table '.$completeTableName;
- $failedcommands[] = implode(" ", $sql);
+ if ($sql && $dict->ExecuteSQLArray( $sql ) <= 1) {
+ $errors[] = 'Failed to create table ' . $completeTableName;
+ $failedcommands[] = implode( " ", $sql );
}
}
}
@@ -197,26 +197,25 @@ if( !empty( $_REQUEST['cancel'] ) ) {
}
$i++;
- } while( !empty( $uninstalledPackages ) && $i < $maxLoop );
+ } while ( !empty( $uninstalledPackages ) && $i < $maxLoop );
- if( $i > $maxLoop ) {
+ if ($i > $maxLoop) {
$errors[] = 'Infinite loop detected';
}
-
// ---------------------- 2. ----------------------
// install additional constraints
- foreach( array_keys( $gBitInstaller->mPackages ) as $package ) {
- if( in_array( $package, $_REQUEST['packages'] ) && ($method == 'install' || $method == 'reinstall' )
- && !empty( $gBitInstaller->mPackages[$package]['constraints'] ) && is_array( $gBitInstaller->mPackages[$package]['constraints'] ) ) {
- foreach( array_keys($gBitInstaller->mPackages[$package]['constraints']) as $tableName ) {
- $completeTableName = $tablePrefix.$tableName;
- foreach( array_keys($gBitInstaller->mPackages[$package]['constraints'][$tableName]) as $constraintName ) {
- $sql = 'ALTER TABLE `'.$completeTableName.'` ADD CONSTRAINT `'.$constraintName.'` '.$gBitInstaller->mPackages[$package]['constraints'][$tableName][$constraintName];
- $gBitKernelDb->convertQuery($sql);
+ foreach ( array_keys( $gBitInstaller->mPackages ) as $package ) {
+ if (in_array( $package, $_REQUEST['packages'] ) && ( $method == 'install' || $method == 'reinstall' )
+ && !empty( $gBitInstaller->mPackages[$package]['constraints'] ) && is_array( $gBitInstaller->mPackages[$package]['constraints'] )) {
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['constraints'] ) as $tableName ) {
+ $completeTableName = $tablePrefix . $tableName;
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['constraints'][$tableName] ) as $constraintName ) {
+ $sql = 'ALTER TABLE `' . $completeTableName . '` ADD CONSTRAINT `' . $constraintName . '` ' . $gBitInstaller->mPackages[$package]['constraints'][$tableName][$constraintName];
+ $gBitKernelDb->convertQuery( $sql );
$ret = $gBitInstallDb->Execute( $sql );
- if ( $ret === false ) {
- $errors[] = 'Failed to add constraint '.$constraintName.' to table '.$completeTableName;
+ if ($ret === false) {
+ $errors[] = 'Failed to add constraint ' . $constraintName . ' to table ' . $completeTableName;
$failedcommands[] = $sql;
}
}
@@ -224,66 +223,60 @@ if( !empty( $_REQUEST['cancel'] ) ) {
}
}
-
-
// ---------------------- 3. ----------------------
// let's generate all the indexes, and sequences
- foreach( array_keys( $gBitInstaller->mPackages ) as $package ) {
- if( in_array( $package, $_REQUEST['packages'] ) ) {
+ foreach ( array_keys( $gBitInstaller->mPackages ) as $package ) {
+ if (in_array( $package, $_REQUEST['packages'] )) {
// set prefix
$schemaQuote = strrpos( BIT_DB_PREFIX, '`' );
- $sequencePrefix = ( $schemaQuote ? substr( BIT_DB_PREFIX, $schemaQuote + 1 ) : BIT_DB_PREFIX );
+ $sequencePrefix = ( $schemaQuote ? substr( BIT_DB_PREFIX, $schemaQuote + 1 ) : BIT_DB_PREFIX );
- if( $method == 'install' || ( $method == 'reinstall' && in_array( 'tables', $removeActions ))) {
+ if ($method == 'install' || ( $method == 'reinstall' && in_array( 'tables', $removeActions ) )) {
// Install Indexes
- if( isset( $gBitInstaller->mPackages[$package]['indexes'] ) && is_array( $gBitInstaller->mPackages[$package]['indexes'] ) ) {
- foreach( array_keys( $gBitInstaller->mPackages[$package]['indexes'] ) as $tableIdx ) {
- $completeTableName = $sequencePrefix.$gBitInstaller->mPackages[$package]['indexes'][$tableIdx]['table'];
+ if (isset( $gBitInstaller->mPackages[$package]['indexes'] ) && is_array( $gBitInstaller->mPackages[$package]['indexes'] )) {
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['indexes'] ) as $tableIdx ) {
+ $completeTableName = $sequencePrefix . $gBitInstaller->mPackages[$package]['indexes'][$tableIdx]['table'];
$sql = $dict->CreateIndexSQL( $tableIdx, $completeTableName, $gBitInstaller->mPackages[$package]['indexes'][$tableIdx]['cols'], $gBitInstaller->mPackages[$package]['indexes'][$tableIdx]['opts'] );
- if( $sql && $dict->ExecuteSQLArray( $sql ) <= 1) {
- $errors[] = 'Failed to create index '.$tableIdx." on ".$completeTableName;
- $failedcommands[] = implode(" ", $sql);
+ if ($sql && $dict->ExecuteSQLArray( $sql ) <= 1) {
+ $errors[] = 'Failed to create index ' . $tableIdx . " on " . $completeTableName;
+ $failedcommands[] = implode( " ", $sql );
}
}
}
- if( $method == 'reinstall' && in_array( 'tables', $removeActions )) {
- if( isset( $gBitInstaller->mPackages[$package]['sequences'] ) && is_array( $gBitInstaller->mPackages[$package]['sequences'] ) ) {
- foreach( array_keys( $gBitInstaller->mPackages[$package]['sequences'] ) as $sequenceIdx ) {
- $sql = $gBitInstallDb->DropSequence( $sequencePrefix.$sequenceIdx );
+ if ($method == 'reinstall' && in_array( 'tables', $removeActions )) {
+ if (isset( $gBitInstaller->mPackages[$package]['sequences'] ) && is_array( $gBitInstaller->mPackages[$package]['sequences'] )) {
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['sequences'] ) as $sequenceIdx ) {
+ $sql = $gBitInstallDb->DropSequence( $sequencePrefix . $sequenceIdx );
if (!$sql) {
- $errors[] = 'Failed to drop sequence '.$sequencePrefix.$sequenceIdx;
- $failedcommands[] = "DROP SEQUENCE ".$sequencePrefix.$sequenceIdx;
+ $errors[] = 'Failed to drop sequence ' . $sequencePrefix . $sequenceIdx;
+ $failedcommands[] = "DROP SEQUENCE " . $sequencePrefix . $sequenceIdx;
}
}
}
}
- if( isset( $gBitInstaller->mPackages[$package]['sequences'] ) && is_array( $gBitInstaller->mPackages[$package]['sequences'] ) ) {
+ if (isset( $gBitInstaller->mPackages[$package]['sequences'] ) && is_array( $gBitInstaller->mPackages[$package]['sequences'] )) {
// If we use InnoDB for MySql we need this to get sequence tables created correctly.
- if( isset( $_SESSION['use_innodb'] ) ) {
- if( $_SESSION['use_innodb'] == TRUE ) {
- $gBitInstallDb->_genSeqSQL = "create table %s (id int not null) ENGINE=INNODB";
- } else {
- $gBitInstallDb->_genSeqSQL = "create table %s (id int not null) ENGINE=MYISAM";
- }
+ if (isset( $_SESSION['use_innodb'] )) {
+ $gBitInstallDb->_genSeqSQL = ( $_SESSION['use_innodb'] == true ) ? "create table %s (id int not null) ENGINE=INNODB" : "create table %s (id int not null) ENGINE=MYISAM";
}
- foreach( array_keys( $gBitInstaller->mPackages[$package]['sequences'] ) as $sequenceIdx ) {
- $sql = $gBitInstallDb->CreateSequence( $sequencePrefix.$sequenceIdx, $gBitInstaller->mPackages[$package]['sequences'][$sequenceIdx]['start'] );
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['sequences'] ) as $sequenceIdx ) {
+ $sql = $gBitInstallDb->CreateSequence( $sequencePrefix . $sequenceIdx, $gBitInstaller->mPackages[$package]['sequences'][$sequenceIdx]['start'] );
if (!$sql) {
- $errors[] = 'Failed to create sequence '.$sequencePrefix.$sequenceIdx;
- $failedcommands[] = "CREATE SEQUENCE ".$sequencePrefix.$sequenceIdx." START ".$gBitInstaller->mPackages[$package]['sequences'][$sequenceIdx]['start'];
+ $errors[] = "Failed to create sequence $sequencePrefix$sequenceIdx";
+ $failedcommands[] = "CREATE SEQUENCE " . $sequencePrefix . $sequenceIdx . " START " . $gBitInstaller->mPackages[$package]['sequences'][$sequenceIdx]['start'];
}
}
}
} elseif( $method == 'uninstall' && in_array( 'tables', $removeActions )) {
- if( isset( $gBitInstaller->mPackages[$package]['sequences'] ) && is_array( $gBitInstaller->mPackages[$package]['sequences'] ) ) {
- foreach( array_keys( $gBitInstaller->mPackages[$package]['sequences'] ) as $sequenceIdx ) {
- $sql = $gBitInstallDb->DropSequence( $sequencePrefix.$sequenceIdx );
+ if (isset( $gBitInstaller->mPackages[$package]['sequences'] ) && is_array( $gBitInstaller->mPackages[$package]['sequences'] )) {
+ foreach ( array_keys( $gBitInstaller->mPackages[$package]['sequences'] ) as $sequenceIdx ) {
+ $sql = $gBitInstallDb->DropSequence( $sequencePrefix . $sequenceIdx );
if (!$sql) {
- $errors[] = 'Failed to drop sequence '.$sequencePrefix.$sequenceIdx;
- $failedcommands[] = "DROP SEQUENCE ".$sequencePrefix.$sequenceIdx;
+ $errors[] = 'Failed to drop sequence ' . $sequencePrefix . $sequenceIdx;
+ $failedcommands[] = "DROP SEQUENCE " . $sequencePrefix . $sequenceIdx;
}
}
}
@@ -295,31 +288,25 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$gBitInstaller->mPrefs = '';
$gBitInstaller->loadConfig();
-
-
// ---------------------- 4. ----------------------
// manipulate the data in kernel_config
$gBitInstaller->mDb->StartTrans();
- foreach( array_keys( $gBitInstaller->mPackages ) as $package ) {
- if( in_array( $package, $_REQUEST['packages'] ) ) {
+ foreach ( array_keys( $gBitInstaller->mPackages ) as $package ) {
+ if (in_array( $package, $_REQUEST['packages'] )) {
// remove all the requested settings - this is a bit tricky and might require some more testing
// Remove settings if requested
- if( in_array( 'settings', $removeActions ) ) {
+ if (in_array( 'settings', $removeActions )) {
// get a list of permissions used by this package
- $query = "SELECT `perm_name` FROM `".$tablePrefix."users_permissions` WHERE `package`=?";
- $perms = $gBitInstaller->mDb->getCol( $query, array( $package ));
+ $query = "SELECT `perm_name` FROM `" . $tablePrefix . "users_permissions` WHERE `package`=?";
+ $perms = $gBitInstaller->mDb->getCol( $query, [ $package ] );
// we deal with liberty_content_permissions below
- if ( defined( 'ROLE_MODEL' ) ) {
- $tables = array( 'users_role_permissions', 'users_permissions' );
- } else {
- $tables = array( 'users_group_permissions', 'users_permissions' );
- }
- foreach( $tables as $table ) {
- foreach( $perms as $perm ) {
+ $tables = ( defined( 'ROLE_MODEL' ) ) ? [ 'users_role_permissions', 'users_permissions' ] : [ 'users_group_permissions', 'users_permissions' ];
+ foreach ( $tables as $table ) {
+ foreach ( $perms as $perm ) {
$delete = "
- DELETE FROM `".$tablePrefix.$table."`
+ DELETE FROM `" . $tablePrefix.$table."`
WHERE `perm_name`=?";
- $ret = $gBitInstaller->mDb->query( $delete, array( $perm ) );
+ $ret = $gBitInstaller->mDb->query( $delete, [ $perm ] );
if (!$ret) {
$errors[] = "Error deleting permission ". $perm;
$failedcommands[] = $delete." ".$perm;
@@ -328,12 +315,12 @@ if( !empty( $_REQUEST['cancel'] ) ) {
}
// list of tables where we store package specific settings
- $tables = array( 'kernel_config' );
+ $tables = [ 'kernel_config' ];
foreach( $tables as $table ) {
$delete = "
DELETE FROM `".$tablePrefix.$table."`
WHERE `package`=? OR `config_name` LIKE ?";
- $ret = $gBitInstaller->mDb->query( $delete, array( $package, $package."%" ));
+ $ret = $gBitInstaller->mDb->query( $delete, [ $package, "$package%" ]);
if (!$ret) {
$errors[] = "Error deleting confgis for package ". $package;
$failedcommands[] = $delete." ".$package;
@@ -349,35 +336,35 @@ if( !empty( $_REQUEST['cancel'] ) ) {
if( $contentType['handler_package'] == $package ) {
// first we get a list of content_ids which we can use to scan various tables without content_type_guid column for data
$query = "SELECT `content_id` FROM `".$tablePrefix."liberty_content` WHERE `content_type_guid`=?";
- $rmContentIds = $gBitInstaller->mDb->getCol( $query, array( $contentType['content_type_guid'] ));
+ $rmContentIds = $gBitInstaller->mDb->getCol( $query, [ $contentType['content_type_guid'] ]);
// list of core tables where bitweaver might store relevant data
// firstly, we delete using the content ids
// order is important due to the constraints set in the schema
- $tables = array(
+ $tables = [
'liberty_aliases' => 'content_id',
'liberty_structures' => 'content_id',
'liberty_content_hits' => 'content_id',
'liberty_content_history' => 'content_id',
'liberty_content_prefs' => 'content_id',
'liberty_content_links' => 'to_content_id',
- 'liberty_content_links' => 'from_content_id',
+ 'liberty_content_from_links' => 'from_content_id',
'liberty_process_queue' => 'content_id',
'liberty_content_permissions' => 'content_id',
- 'users_favorites_map' => 'favorite_content_id'
+ 'users_favorites_map' => 'favorite_content_id',
// This table needs to be fixed to use content_id instead of page_id
//'liberty_copyrights' => 'content_id',
// liberty comments are tricky. should we remove comments linked to the content being deleted?
// makes sense to me but only if boards are not installed - xing
//'liberty_comments' => 'root_id',
- );
+ ];
foreach( $rmContentIds as $contentId ) {
foreach( $tables as $table => $column ) {
$delete = "
DELETE FROM `".$tablePrefix.$table."`
WHERE `$column`=?";
- $ret = $gBitInstaller->mDb->query( $delete, array( $contentId ));
+ $ret = $gBitInstaller->mDb->query( $delete, [ $contentId ]);
if (!$ret) {
$errors[] = "Error deleting from ". $tablePrefxi.$table;
$failedcommands[] = $delete." ".$contentId;
@@ -393,15 +380,15 @@ if( !empty( $_REQUEST['cancel'] ) ) {
// secondly, we delete using the content type guid
// order is important due to the constraints set in the schema
- $tables = array(
+ $tables = [
'liberty_content',
- 'liberty_content_types'
- );
+ 'liberty_content_types',
+ ];
foreach( $tables as $table ) {
$delete = "
DELETE FROM `".$tablePrefix.$table."`
WHERE `content_type_guid`=?";
- $ret = $gBitInstaller->mDb->query( $delete, array( $contentType['content_type_guid'] ));
+ $ret = $gBitInstaller->mDb->query( $delete, [ $contentType['content_type_guid'] ]);
if (!$ret) {
$errors[] = "Error deleting content type";
$failedcommands[] = $delete." ".$contentType['content_type_guid'];
@@ -439,7 +426,7 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$gBitInstaller->loadConfig();
- $gBitInstaller->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."kernel_config` WHERE `package`=?", array( $package ) );
+ $gBitInstaller->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."kernel_config` WHERE `package`=?", [ $package ] );
// ---------------------- 5. ----------------------
// run the defaults through afterwards so we can be sure all tables needed have been created
foreach( array_keys( $gBitInstaller->mPackages ) as $package ) {
@@ -477,9 +464,9 @@ if( !empty( $_REQUEST['cancel'] ) ) {
// register all content types for installed packages
foreach( $gBitInstaller->mContentClasses as $package => $classes ){
if ( $gBitInstaller->isPackageInstalled( $package ) ){
- foreach ( $classes as $objectClass=>$classFile ){
- require_once( $classFile );
- $tempObject = new $objectClass();
+ foreach ( $classes as $key => $objectClass ) {
+ $class = "\\Bitweaver\\".ucfirst($package)."\\$key";
+ $tempObject = new $class();
}
}
}
@@ -510,14 +497,15 @@ if( !empty( $_REQUEST['cancel'] ) ) {
// Installing users has some special things to take care of here and needs a separate check.
if( in_array( 'users', $_REQUEST['packages'] ) ) {
// Creating 'root' user has id=1. phpBB starts with user_id=2, so this is a hack to keep things in sync
- $storeHash = array(
+ $storeHash = [
'real_name' => 'Root',
'login' => 'root',
'password' => $_SESSION['password'],
'email' => 'root@localhost',
- 'pass_due' => FALSE,
- 'user_id' => ROOT_USER_ID
- );
+ 'pass_due' => false,
+ 'registration_ip' => $_SERVER['REMOTE_ADDR'],
+ 'user_id' => ROOT_USER_ID,
+ ];
// now let's set up some default data. Group_id's are hardcoded in users/schema_inc defaults
if ( defined( 'ROLE_MODEL' ) ) {
$rootUser = new RolePermUser();
@@ -525,8 +513,8 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$gBitUser->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."users_roles` (`user_id`, `role_id`, `role_name`,`role_desc`) VALUES ( ".ROOT_USER_ID.", 1, 'Administrators','Site operators')" );
$rootUser->addUserToRole( ROOT_USER_ID, 1 );
} else {
- vd( 'Errors in root user store:'.PHP_EOL );
- vd( $rootUser->mErrors );
+ \Bitweaver\vd( 'Errors in root user store:'.PHP_EOL );
+ \Bitweaver\vd( $rootUser->mErrors );
}
$gBitSystem->storeConfig( 'user_class', 'RolePermUser', USERS_PKG_NAME );
$gBitUser->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."users_roles` (`user_id`, `role_id`, `role_name`,`role_desc`) VALUES ( ".ROOT_USER_ID.", ".ANONYMOUS_TEAM_ID.", 'Anonymous','Public users not logged')" );
@@ -539,8 +527,8 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$gBitUser->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."users_groups` (`user_id`, `group_id`, `group_name`,`group_desc`) VALUES ( ".ROOT_USER_ID.", 1, 'Administrators','Site operators')" );
$rootUser->addUserToGroup( ROOT_USER_ID, 1 );
} else {
- vd( 'Errors in root user store:'.PHP_EOL );
- vd( $rootUser->mErrors );
+ \Bitweaver\vd( 'Errors in root user store:'.PHP_EOL );
+ \Bitweaver\vd( $rootUser->mErrors );
}
$gBitUser->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."users_groups` (`user_id`, `group_id`, `group_name`,`group_desc`) VALUES ( ".ROOT_USER_ID.", ".ANONYMOUS_GROUP_ID.", 'Anonymous','Public users not logged')" );
$gBitUser->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."users_groups` (`user_id`, `group_id`, `group_name`,`group_desc`) VALUES ( ".ROOT_USER_ID.", 2, 'Managers','Site Managers')" );
@@ -553,15 +541,16 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$gBitUser->assignLevelPermissions( 1, 'admin' );
// Create 'Anonymous' user has id= -1 just like phpBB
- $storeHash = array(
- 'real_name' => 'Guest',
- 'login' => 'guest',
- 'password' => $_SESSION['password'],
- 'email' => 'guest@localhost',
- 'pass_due' => FALSE,
- 'user_id' => ANONYMOUS_USER_ID,
- 'default_role_id' => ANONYMOUS_TEAM_ID
- );
+ $storeHash = [
+ 'real_name' => 'Guest',
+ 'login' => 'guest',
+ 'password' => $_SESSION['password'],
+ 'email' => 'guest@localhost',
+ 'pass_due' => false,
+ 'registration_ip' => $_SERVER['REMOTE_ADDR'],
+ 'user_id' => ANONYMOUS_USER_ID,
+ 'default_role_id' => ANONYMOUS_TEAM_ID,
+ ];
if ( defined( 'ROLE_MODEL' ) ) {
$anonUser = new RolePermUser();
if( $anonUser->store( $storeHash ) ) {
@@ -581,13 +570,15 @@ if( !empty( $_REQUEST['cancel'] ) ) {
}
// Create 'Admin' user has id= 2
- $storeHash = array(
+ $storeHash = [
'real_name' => $_SESSION['real_name'],
'login' => $_SESSION['login'],
'password' => $_SESSION['password'],
'email' => $_SESSION['email'],
- 'pass_due' => FALSE
- );
+ 'registration_ip' => $_SERVER['REMOTE_ADDR'],
+ 'user_id' => 2,
+ 'pass_due' => false,
+ ];
if ( defined( 'ROLE_MODEL' ) ) {
$adminUser = new RolePermUser();
if( $adminUser->store( $storeHash ) ) {
@@ -596,7 +587,7 @@ if( !empty( $_REQUEST['cancel'] ) ) {
// set admin role as default
$adminUser->storeUserDefaultRole( $adminUser->mUserId, 1 );
} else {
- vd( $adminUser->mErrors ); die;
+ \Bitweaver\vd( $adminUser->mErrors ); die;
}
} else {
$adminUser = new BitPermUser();
@@ -606,15 +597,15 @@ if( !empty( $_REQUEST['cancel'] ) ) {
// set admin group as default
$adminUser->storeUserDefaultGroup( $adminUser->mUserId, 1 );
} else {
- vd( $adminUser->mErrors ); die;
+ \Bitweaver\vd( $adminUser->mErrors ); die;
}
}
// kill admin info in $_SESSION
-// unset( $_SESSION['real_name'] );
-// unset( $_SESSION['login'] );
-// unset( $_SESSION['password'] );
-// unset( $_SESSION['email'] );
+ unset( $_SESSION['real_name'] );
+ unset( $_SESSION['login'] );
+ unset( $_SESSION['password'] );
+ unset( $_SESSION['email'] );
}
}
@@ -648,4 +639,3 @@ if( !empty( $_REQUEST['cancel'] ) ) {
$gBitSmarty->assign( 'next_step', $step + 1 );
$app = '_done';
}
-?>
diff --git a/includes/install_upgrade.php b/includes/install_upgrade.php
index 6243aef..7ccfbf1 100644..100755
--- a/includes/install_upgrade.php
+++ b/includes/install_upgrade.php
@@ -7,7 +7,7 @@
$gBitSmarty->assign( 'next_step', $step );
-$errors = $success = array();
+$errors = $success = [];
// load up all available package upgrades that we have
$gBitInstaller->loadAllUpgradeFiles();
@@ -43,5 +43,4 @@ $gBitSmarty->assign( 'requirementsMap', $gBitInstaller->drawRequirementsGraph( F
$gBitSmarty->assign( 'packageUpgrades', $gBitInstaller->mPackageUpgrades );
$gBitSmarty->assign( 'schema', $gBitInstaller->mPackages );
$gBitSmarty->assign( 'success', $success );
-$gBitSmarty->assign( 'errors', $errors );
-?>
+$gBitSmarty->assign( 'errors', $errors ); \ No newline at end of file
diff --git a/includes/install_version.php b/includes/install_version.php
index caf9708..5a97442 100644..100755
--- a/includes/install_version.php
+++ b/includes/install_version.php
@@ -1,4 +1,6 @@
<?php
+
+use Bitweaver\KernelTools;
/**
* @version $Header$
* @package install
@@ -17,10 +19,10 @@ if( version_compare( $gBitSystem->getBitVersion(), $gBitSystem->getVersion(), '=
// updating to version 2.1.0-beta
if( version_compare( '2.1.0-beta', $gBitSystem->getVersion(), '>' )) {
// get a list of all groups and their permissions
- $listHash = array(
- 'only_root_groups' => TRUE,
- 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : 'group_name_asc'
- );
+ $listHash = [
+ 'only_root_groups' => true,
+ 'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : 'group_name_asc'
+ ];
$allGroups = $gBitUser->getAllGroups( $listHash );
$allPerms = $gBitUser->getGroupPermissions( $_REQUEST );
@@ -49,7 +51,7 @@ if( version_compare( '2.1.0-beta', $gBitSystem->getVersion(), '>' )) {
if( !empty( $_REQUEST['update_version'] )) {
if( !empty( $upToDate ) || !empty( $_REQUEST['skip'] )) {
// if we're already up to date, we'll simply move on to the next page
- bit_redirect( $_SERVER['SCRIPT_NAME']."?step=".++$step );
+ KernelTools::bit_redirect( $_SERVER['SCRIPT_NAME']."?step=".++$step );
} else {
// set the version of bitweaver in the database
if( $gBitSystem->storeVersion( NULL, $gBitSystem->getBitVersion() )) {
@@ -58,5 +60,4 @@ if( !empty( $_REQUEST['update_version'] )) {
$app = '_done';
}
}
-}
-?>
+} \ No newline at end of file
diff --git a/includes/install_welcome.php b/includes/install_welcome.php
index 7736563..81d215e 100644..100755
--- a/includes/install_welcome.php
+++ b/includes/install_welcome.php
@@ -15,5 +15,4 @@ if( !empty( $_REQUEST['install'] ) ) {
header( 'Location: http'.((!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS'] != 'off')?'s':'').'://'.$_SERVER['HTTP_HOST'].INSTALL_PKG_URL.'install.php?step='.( $step + 1 ) );
die;
}
-$gBitSmarty->assign( 'next_step',$step );
-?>
+$gBitSmarty->assign( 'next_step',$step ); \ No newline at end of file