diff options
46 files changed, 677 insertions, 741 deletions
diff --git a/create_firebird_database.php b/create_firebird_database.php index 7a98240..fe7e91a 100644..100755 --- a/create_firebird_database.php +++ b/create_firebird_database.php @@ -29,26 +29,20 @@ // if ($s_create_charset != 'NONE') { // NONE is the default character set -// $sql .= ' DEFAULT CHARACTER SET '.$s_create_charset; + $sql .= ' DEFAULT CHARACTER SET UTF8'; // } $sql .= ';'; $sql = str_replace("\r\n", "\n", $sql); $sql .= "\n"; - if( isset($_ENV["TMP"])) { - $tmp_name = $_ENV["TMP"].'/'.uniqid('').'.sql'; - } else { - $tmp_name = '/tmp/'.uniqid('').'.sql'; - } + $tmp_name = ( isset( $_SERVER["TMP"] ) ) ? $_SERVER["TMP"] . '/' . uniqid( '' ) . '.sql' : '/tmp/' . uniqid( '' ) . '.sql'; - if ($fp = fopen ($tmp_name, 'a')) { + if ($fp = fopen ($tmp_name, 'a+')) { fwrite($fp, $sql); fclose($fp); } - $command = sprintf('"%s" -i %s', $fbpath, $tmp_name ); + $command = sprintf('"%s" -u $user -p $pass -i %s', $fbpath, $tmp_name ); $result = exec($command); - } - -?>
\ No newline at end of file + }
\ No newline at end of file diff --git a/css/install.css b/css/install.css index 92f6856..6acd3d8 100644..100755 --- a/css/install.css +++ b/css/install.css @@ -174,4 +174,4 @@ ul#fixedpermlist,ul#fixedpermlist li {list-style-type:none} -/* vim: set ts=40: */ +/* vim: set ts=40: */
\ No newline at end of file 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( '/./','•',$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 diff --git a/index.php b/index.php index 3e305fe..ac3192f 100644..100755 --- a/index.php +++ b/index.php @@ -1,6 +1,4 @@ <?php // This is not a package. - header ("location: ../index.php"); - -?>
\ No newline at end of file + header ("location: ../index.php");
\ No newline at end of file diff --git a/install.php b/install.php index fd901c4..be27b22 100644..100755 --- a/install.php +++ b/install.php @@ -1,4 +1,7 @@ <?php + +use Bitweaver\Languages\BitLanguage; +use Bitweaver\Themes\BitThemes; /** * @version $Header$ * @package install @@ -24,7 +27,7 @@ if( !empty( $_REQUEST['step'] ) && $_REQUEST['step'] == 0 ) { if( get_cfg_var( 'memory_limit' ) !== FALSE && preg_replace( '/M/i','',get_cfg_var( 'memory_limit' )) < 15 ) { $dir = dirname( $_SERVER['SCRIPT_NAME'] ); // We don't use smarty to avoid using any memory since we already know there is a problem. - echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> + echo '<!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> @@ -65,10 +68,8 @@ require_once( 'includes/install_inc.php' ); if( $gBitInstaller->isInstalled() && is_object( $gBitUser ) ) { //$gBitUser->verifyAdmin(); } else { - require_once( THEMES_PKG_CLASS_PATH.'BitThemes.php' ); BitThemes::loadSingleton(); $gBitThemes->setStyle( 'basic' ); - require_once( LANGUAGES_PKG_CLASS_PATH.'BitLanguage.php' ); BitLanguage::loadSingleton(); } @@ -150,12 +151,12 @@ $install_file[$i]['name'] = 'Done'; //don't increment last $i since it's used later on // Needed for version number -$gBitSmarty->assignByRef( 'gBitSystem', $gBitSystem ); +$gBitSmarty->assign( 'gBitSystem', $gBitSystem ); if( !empty( $_POST['signin'] ) ) { $gBitUser->login( $_POST['user'], $_POST['pass'] ); if( !$gBitUser->isRegistered() ) { - $gBitSmarty->assign( 'error', current( $gBitUser->mErrors ) ); +// $gBitSmarty->assign( 'error', current( $gBitUser->mErrors ) ); } } @@ -163,6 +164,7 @@ if( !empty( $_POST['signin'] ) ) { if( !empty( $gBitDbType ) && !empty( $gBitInstaller->mPackages['users']['installed'] ) && !$gBitUser->isAdmin() && !$_SESSION['first_install'] ) { $install_file = 'login'; $gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/install_".$install_file.".tpl" ); + $gBitSmarty->assign( 'progress', 0 ); $gBitSmarty->display( INSTALL_PKG_PATH.'templates/install.tpl' ); die; } @@ -174,11 +176,10 @@ if( !strpos( $_SERVER['SCRIPT_NAME'],'install/install.php' ) ) { } // finally we are ready to include the actual php file -include_once( INSTALL_PKG_INCLUDE_PATH.'install_'.$install_file[$step]['file'].'.php' ); +include_once 'includes/install_'.$install_file[$step]['file'].'.php'; $install_file = set_menu( $install_file, $step ); -$gBitSmarty->assignByRef( 'gBitInstaller', $gBitInstaller ); +$gBitSmarty->assign( 'gBitInstaller', $gBitInstaller ); $gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/install_".$install_file[$step]['file'].$app.".tpl" ); $gBitInstaller->in_display( $install_file[$step]['name'], INSTALL_PKG_PATH.'templates/install.tpl' ); -?> diff --git a/migrate.php b/migrate.php index 38371e9..3df2c8c 100644..100755 --- a/migrate.php +++ b/migrate.php @@ -34,7 +34,7 @@ $install_file[$i]['name'] = 'Migration Complete'; // currently i can't think of a better way to secure the migrate pages // redirect to the installer if we aren't sent here by the installer and the migrate session variable hasn't been set -if( !isset( $_SESSION['migrate'] ) || $_SESSION['migrate'] != TRUE || +if( !isset( $_SESSION['migrate'] ) || $_SESSION['migrate'] != true || !isset( $_SERVER['HTTP_REFERER'] ) || isset( $_SERVER['HTTP_REFERER'] ) && ( ( !strpos( $_SERVER['HTTP_REFERER'],'install/install.php' ) ) && ( !strpos( $_SERVER['HTTP_REFERER'],'install/upgrade.php' ) ) && ( !strpos( $_SERVER['HTTP_REFERER'],'install/migrate.php' ) ) ) @@ -54,5 +54,3 @@ $gBitSmarty->assign( 'section', 'Upgrade' ); $gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/migrate_".$install_file[$step]['file'].$app.".tpl" ); $gBitInstaller->in_display( $install_file[$step]['name'], INSTALL_PKG_PATH.'templates/install.tpl' ); - -?> diff --git a/migrate_database.php b/migrate_database.php index e2348aa..b03f176 100644..100755 --- a/migrate_database.php +++ b/migrate_database.php @@ -11,9 +11,11 @@ /** * Initialization */ +namespace Bitweaver; + $gBitSmarty->assign( 'next_step', $step ); -require_once( 'includes/install_inc.php' ); -require_once( 'includes/get_databases_inc.php' ); +require_once 'includes/install_inc.php'; +require_once 'includes/get_databases_inc.php'; // set the maximum execution time to very high ini_set( "max_execution_time", "86400" ); @@ -35,7 +37,7 @@ if( isset( $_REQUEST['db_src'] ) ) { $gBitSmarty->assign( 'name_dst', $_REQUEST['name_dst'] ); $gBitSmarty->assign( 'prefix_dst', $_REQUEST['prefix_dst'] ); - $skip_tables = isset($_REQUEST['skip_tables']) ? $_REQUEST['skip_tables'] : array(); + $skip_tables = isset($_REQUEST['skip_tables']) ? $_REQUEST['skip_tables'] : []; $gBitSmarty->assign( 'skip_tables_select', $skip_tables ); $empty_tables = isset($_REQUEST['empty_tables']); $gBitSmarty->assign( 'empty_tables', $empty_tables ); @@ -47,8 +49,8 @@ if( isset( $_REQUEST['db_src'] ) ) { $gBitSmarty->assign( 'debug', $debug ); } else { //defaults - $gBitSmarty->assign( 'convert_blobs', TRUE ); - $gBitSmarty->assign( 'stop_on_errors', TRUE ); + $gBitSmarty->assign( 'convert_blobs', true ); + $gBitSmarty->assign( 'stop_on_errors', true ); } if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { @@ -62,7 +64,7 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { $gBitDbName = $_REQUEST['name_src']; $prefix_src = $_REQUEST['prefix_src']; if (testDatabase()) { - $gBitSmarty->assign( 'error_src', TRUE ); + $gBitSmarty->assign( 'error_src', true ); return; } else { $gDb_src = new BitDb(); @@ -71,7 +73,7 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { $tables_src = $gDb_src->MetaTables(); if (isset($_REQUEST['fUpdateTables'])) { - $gBitSmarty->assignByRef( 'skip_tables', $tables_src ); + $gBitSmarty->assign( 'skip_tables', $tables_src ); return; } @@ -83,44 +85,45 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { $gBitDbName = $_REQUEST['name_dst']; $prefix_dst = $_REQUEST['prefix_dst']; if (testDatabase()) { - $gBitSmarty->assign( 'error_dst', TRUE ); + $gBitSmarty->assign( 'error_dst', true ); return; } else { $gDb_dst = new BitDb(); } - require_once( 'create_config_inc.php' ); - $createHash = array( - "gBitDbType" => $_REQUEST['db_dst'], - "gBitDbHost" => $tmpHost, - "gBitDbUser" => $_REQUEST['user_dst'], - "gBitDbPassword" => $_REQUEST['pass_dst'], - "gBitDbName" => $_REQUEST['name_dst'], + require_once 'create_config_inc.php'; + $createHash = [ + "gBitDbType" => $_REQUEST['db_dst'], + "gBitDbHost" => $tmpHost, + "gBitDbUser" => $_REQUEST['user_dst'], + "gBitDbPassword" => $_REQUEST['pass_dst'], + "gBitDbName" => $_REQUEST['name_dst'], //"gBitDbCaseSensitivity" => $_REQUEST['dbcase'], - "bit_db_prefix" => $_REQUEST['prefix_dst'], - "bit_root_url" => $_REQUEST['baseurl'], - "auto_bug_submit" => isset( $_REQUEST['auto_bug_submit'] ) ? 'TRUE' : 'FALSE', - "is_live" => isset( $_REQUEST['is_live'] ) ? 'TRUE' : 'FALSE', - ); + "bit_db_prefix" => $_REQUEST['prefix_dst'], + "bit_root_url" => $_REQUEST['baseurl'], + "auto_bug_submit" => isset( $_REQUEST['auto_bug_submit'] ) ? 'true' : 'false', + "is_live" => isset( $_REQUEST['is_live'] ) ? 'true' : 'false', + ]; create_config( $createHash ); // init db connections //vd($gDb_src); //vd($gDb_dst);die; - if($debug) { + if ($debug) { $gDb_dst->debug(); } // list source tables list - $tables_src = array($tables_src[2]); - $tables_dst = getTables($gDb_dst); - print_r($tables_src);die; + $tables_src = [ $tables_src[2] ]; + $tables_dst = $gDb_dst->MetaTables( ); + print_r( $tables_src ); + die; - $table_schema = array(); + $table_schema = []; // iterate through source tables - foreach($tables_src as $table) { - if (array_search($table, $skip_tables) !== FALSE) { + foreach ( $tables_src as $table ) { + if (array_search( $table, $skip_tables ) !== false) { if ($debug) echo "Skipping $table<br>\n"; continue; @@ -128,46 +131,46 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { if ($debug) echo "Creating $table<br>\n"; - if ($empty_tables && $gDb_dst->tableExists($table)) - $gDb_dst->dropTables(array($table)); + if ($empty_tables && $gDb_dst->tableExists( $table )) + $gDb_dst->dropTables( [ $table ] ); $schema = $gDb_src->MetaColumns( $table, false, true ); $t = ""; $first = true; - foreach(array_keys($schema) as $col) { - $t .= (!$first) ? ",\n" : ""; + foreach ( array_keys( $schema ) as $col ) { + $t .= ( !$first ) ? ",\n" : ""; $x = $schema[$col]; $t .= $x->name . " "; - switch($x->type) { + switch ($x->type) { case "tinyint": case "int": - $i = abs(( ( (int)$x->max_length ^ 2) - 1 )); - $i = ($i == 5) ? 4 : $i; - $i = ($i == 0) ? 1 : $i; + $i = abs( ( (int) $x->max_length ^ 2 ) - 1 ); + $i = ( $i == 5 ) ? 4 : $i; + $i = ( $i == 0 ) ? 1 : $i; $t .= "I" . $i; break; case "double": $t .= "N"; break; - + case "varchar": case "char": case "enum": case "decimal": $t .= "C(" . $x->max_length . ")"; break; - + case "time": case "timestamp": case "datetime": $t .= "T"; break; - + case "date": $t .= "D"; break; - + case "blob": case "longblob": case "tinyblob": @@ -178,14 +181,14 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { $t .= "X"; break; default: - die(tra("No support for type '".$x->type."' - please log a bug at http://sf.net/projects/bitweaver")); + die( KernelTools::tra( "No support for type '" . $x->type . "' - please log a bug at http://sf.net/projects/bitweaver" ) ); } - $default = (!$x->binary) ? $x->has_default : false; - $t .= " " . ( ($x->unsigned) ? "UNSIGNED" : "" ) . " " - . ( ($x->not_null) ? "NOTNULL" : "" ) . " " - . ( ($x->auto_increment) ? "AUTO" : "" ) . " " - . ( ($x->primary_key) ? "PRIMARY" : "" ) . " " - . ( ($default) ? "DEFAULT ". $x->default_value : "" ); + $default = ( !$x->binary ) ? $x->has_default : false; + $t .= " " . ( $x->unsigned ? "UNSIGNED" : "" ) . " " + . ( $x->not_null ? "NOTNULL" : "" ) . " " + . ( $x->auto_increment ? "AUTO" : "" ) . " " + . ( $x->primary_key ? "PRIMARY" : "" ) . " " + . ( $default ? "DEFAULT " . $x->default_value : "" ); $table_schema[$table] = $t; $first = false; } @@ -195,43 +198,40 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { //vd($table_schema); //vd($indices); - $pOptions = array(); + $pOptions = []; if ($empty_tables) $pOptions[] = "REPLACE"; switch ($gDb_dst->mType) { case "mysql": - // SHOULD HANDLE INNODB so foreign keys are cool - XOXO spiderr - $pOptions['mysql'] = 'TYPE=INNODB'; + // SHOULD HANDLE INNODB so foreign keys are cool - XOXO spiderr + $pOptions['mysql'] = 'TYPE=INNODB'; default: //$pOptions[] = 'REPLACE'; } - $dict = NewDataDictionary($gDb_dst->mDb); + $dict = NewDataDictionary( $gDb_dst->mDb, 'firebird' ); $result = true; - foreach(array_keys($table_schema) AS $tableName) - { - $completeTableName = $prefix_dst.$tableName; - $sql = $dict->CreateTableSQL($completeTableName, $table_schema[$tableName], $pOptions); - if ($sql && ($dict->ExecuteSQLArray($sql) > 0)) - { + foreach ( array_keys( $table_schema ) as $tableName ) { + $completeTableName = $prefix_dst . $tableName; + $sql = $dict->CreateTableSQL( $completeTableName, $table_schema[$tableName], $pOptions ); + if ($sql && ( $dict->ExecuteSQLArray( $sql ) > 0 )) { // Success } - else - { + else { // Failure - array_push($gDb_dst->mFailed, $gDb_dst->mDb->ErrorMsg()); + array_push( $gDb_dst->mFailed, $gDb_dst->mDb->ErrorMsg() ); if ($stop_on_errors) break; } - foreach( array_keys( $indices ) as $index ) { - foreach( array_keys( $indices[$index] ) as $col) { - $completeTableName = $prefix_dst.$index; - $flds = implode(",", $indices[$index][$col]["columns"]); - $name = implode("_", $indices[$index][$col]["columns"]); - $sql = $dict->CreateIndexSQL( $index."_".$name, $completeTableName, $flds, (($indices[$index][$col]["unique"]) ? array("UNIQUE") : NULL) ); - if( $sql && ($dict->ExecuteSQLArray($sql) > 0)) + foreach ( array_keys( $indices ) as $index ) { + foreach ( array_keys( $indices[$index] ) as $col ) { + $completeTableName = $prefix_dst . $index; + $flds = implode( ",", $indices[$index][$col]["columns"] ); + $name = implode( "_", $indices[$index][$col]["columns"] ); + $sql = $dict->CreateIndexSQL( "{$index}_$name", $completeTableName, $flds, ( $indices[$index][$col]["unique"] ) ? [ "UNIQUE" ] : null ); + if ($sql && ($dict->ExecuteSQLArray($sql) > 0)) { // Success } else { @@ -279,8 +279,8 @@ if (isset($_REQUEST['fSubmitDatabase']) || isset($_REQUEST['fUpdateTables'])) { $results[]= "$table: migrated $q records".(($c > 0) ? "and converted $c blobs" : ""); } //vd($gDb_dst->mFailed);die; - $gBitSmarty->assignByRef( 'results', $results ); - $gBitSmarty->assignByRef( 'errors', $gDb_dst->mFailed ); + $gBitSmarty->assign( 'results', $results ); + $gBitSmarty->assign( 'errors', $gDb_dst->mFailed ); $app = "_done"; $gBitSmarty->assign( 'next_step', $step + 1 ); @@ -293,12 +293,11 @@ function testDatabase() { ini_set('sybct.min_server_severity', '11'); } - $gBitDb = &ADONewConnection($gBitDbType); + $gBitDb = ADONewConnection($gBitDbType); - if( !$gBitDb->Connect($gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName) ) { - return TRUE; + if( !$gBitDb->Connect($gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbType != 'pdo' ? $gBitDbName : NULL ) ) { + return true; } - return FALSE; + return false; } -?> diff --git a/migrate_final.php b/migrate_final.php index a79e39e..62b35f1 100644..100755 --- a/migrate_final.php +++ b/migrate_final.php @@ -14,7 +14,7 @@ $app = '_done'; $gBitSmarty->assign( 'next_step',$step ); if( isset( $_REQUEST['enter_bitweaver'] ) ) { - $_SESSION = NULL; + $_SESSION = null; header( 'Location: '.BIT_ROOT_URL ); die; } elseif( isset( $_REQUEST['continue_install'] ) ) { @@ -22,5 +22,4 @@ if( isset( $_REQUEST['enter_bitweaver'] ) ) { die; } else { $gBitSmarty->assign( 'next_step',$step ); -} -?> +}
\ No newline at end of file diff --git a/migrate_welcome.php b/migrate_welcome.php index 71834ac..5f2cdf4 100644..100755 --- a/migrate_welcome.php +++ b/migrate_welcome.php @@ -10,5 +10,4 @@ // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. // assign next step in installation process -$gBitSmarty->assign( 'next_step',$step + 1 ); -?> +$gBitSmarty->assign( 'next_step',$step + 1 );
\ No newline at end of file diff --git a/process_sql.php b/process_sql.php index c7c5d73..cd08952 100644..100755 --- a/process_sql.php +++ b/process_sql.php @@ -9,7 +9,9 @@ * Global flag to indicate we are installing * @ignore */ -define( 'BIT_INSTALL', 'TRUE' ); + +namespace Bitweaver; +define( 'BIT_INSTALL', 'true' ); global $failedcommands; // keep some crappy notices from spewing $_SERVER['HTTP_HOST'] = 'shell'; @@ -18,17 +20,15 @@ $_SERVER['SERVER_SOFTWARE'] = 'command_line'; /** * required setup */ -require_once( 'install_lib.php' ); -include("../kernel/includes/setup_inc.php"); +require_once 'includes/install_lib.php'; +include '../kernel/includes/setup_inc.php'; if( count( $argv ) < 2) { print "Please enter name of SQL file in db/ directory to process\n"; } else { // avoid errors in ADONewConnection() (wrong darabase driver etc...) - $gBitDb = &ADONewConnection($gBitDbType); - if( $gBitDb->Connect($gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName) ) { + $gBitDb = ADONewConnection($gBitDbType); + if( $gBitDb->Connect($gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbType != 'pdo' ? $gBitDbName : NULL ) ) { process_sql_file( $argv[1], $gBitDbType, BIT_DB_PREFIX ); } -} - -?> +}
\ No newline at end of file diff --git a/templates/install.tpl b/templates/install.tpl index 812b8d8..ee39d1f 100644..100755 --- a/templates/install.tpl +++ b/templates/install.tpl @@ -1,6 +1,4 @@ -{if ($gBrowserInfo.browser neq 'ie') or ($gBrowserInfo.browser eq 'ie' and $gBrowserInfo.maj_ver gt 7) } <?xml version="1.0" encoding="utf-8"?> -{/if} {strip} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -8,28 +6,23 @@ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> {* hidden from 4.x browsers: *} - @import "{$smarty.const.CONFIG_PKG_URL}themes/bootstrap/bootstrap.css"; + @import "{$smarty.const.THEMES_PKG_URL}css/colourstrap-full.css"; @import "{$smarty.const.INSTALL_PKG_URL}css/install.css"; </style> <title>Install Bitweaver - {$browserTitle}</title> <link rel="shortcut icon" href="{$smarty.const.INSTALL_PKG_URL}favicon.ico" type="image/x-icon" /> <link rel="icon" href="{$smarty.const.INSTALL_PKG_URL}favicon.ico" type="image/x-icon" /> - <script type="text/javascript">/* <![CDATA[ */ + <script>/* <![CDATA[ */ var bitCookiePath = "{$smarty.const.BIT_ROOT_URL}"; var bitCookieDomain = ""; var bitIconDir = "{$smarty.const.LIBERTY_PKG_URL}icons/"; var bitRootUrl = "{$smarty.const.BIT_ROOT_URL}"; /* ]]> */</script> - <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js"></script> - <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js"></script> - <script type="text/javascript" src="{$smarty.const.CONFIG_PKG_URL}themes/bootstrap/js/bootstrap.js"></script> - <script type="text/javascript" src="{$smarty.const.BIT_ROOT_URL}util/javascript/bitweaver.js"></script> - {* if $gBrowserInfo.browser eq 'ie'} - <!--[if lt IE 7]> - <script type="text/javascript" src="{$smarty.const.BIT_ROOT_URL}util/javascript/fixes/ie7/IE8.js"></script> - <![endif]--> - {/if *} + <script src= "{$smarty.const.THEMES_PKG_URL}js/jquery-3.7.1.js"></script> + <script src= "{$smarty.const.THEMES_PKG_URL}js/jquery-ui-14.1.js"></script> + <script src= "{$smarty.const.THEMES_PKG_URL}js/bootstrap.js"></script> + <script src= "{$smarty.const.THEMES_PKG_URL}js/bitweaver.js"></script> </head> <body id="step{$smarty.request.step}"> <header class="container"> @@ -47,7 +40,16 @@ <nav class="pull-right width60p" style="padding:10px 20px 0 0;"> <div class="pull-right"> - <a href="http://www.bitweaver.org/wiki/index.php?page={$section|default:"Install"}bitweaverDoc">{booticon iname="fa-question-circle"} Help</a> + <a href="http://www.bitweaver.org/wiki/index.php?page={$section|default:"Install"}bitweaverDoc"><i class="icon-question-sign"></i> Help</a> + </div> + + <div class="pull-right width50p" style="padding:0 10px;"> + <div class="progress"> + <div class="bar bar-success" style="width: {$progress|default:0}%;"></div> + </div> + </div> + <div class="pull-right"> + <em>{$section|default:"Install"} Progress</em> </div> </nav> </div> @@ -56,7 +58,7 @@ {foreach from=$menu_steps item=step key=key} <li class="{if $smarty.request.step == $key}active{/if}"> <a href="{$menu_path|default:$smarty.const.INSTALL_PKG_URL}{$menu_file|default:"install.php"}?step={$key}" {if $step.state eq 'uncompleted'}onclick="return false;"{/if}> - {if $step.icon}{booticon iname=$step.icon} {/if}{$step.name} + {if $step.icon}<i class="{$step.icon}"></i> {/if} {$step.name} </a> </li> {/foreach} @@ -74,9 +76,7 @@ </div> <footer class="container content-center"> - {if $gBitInstaller->isInstalled()} - {include file="bitpackage:kernel/bot_bar.tpl"} - {/if} + {include file="bitpackage:kernel/bot_bar.tpl"} </footer> </body> </html> diff --git a/templates/install_admin_inc.tpl b/templates/install_admin_inc.tpl index 47f4eeb..e0bb007 100644..100755 --- a/templates/install_admin_inc.tpl +++ b/templates/install_admin_inc.tpl @@ -5,7 +5,7 @@ <input type="hidden" name="step" value="{$next_step}" /> <div class="form-group"> - {formfeedback error=$errors.real_name} + {formfeedback error=$errors.real_name ?? ''} {formlabel label="Full Name" for="real_name"} {forminput} <input type="text" class="form-control" name="real_name" id="real_name" value="{$smarty.session.real_name|default:'Administrator'}" /> @@ -14,7 +14,7 @@ </div> <div class="form-group"> - {formfeedback error=$errors.login} + {formfeedback error=$errors.login ?? ''} {formlabel label="Admin login" for="login"} {forminput} <input type="text" class="form-control" name="login" id="login" value="{$smarty.session.login|default:'admin'}" /> @@ -23,10 +23,10 @@ </div> <div class="form-group"> - {formfeedback error=$errors.password} + {formfeedback error=$errors.password ?? ''} {formlabel label="Password" for="password"} {forminput} - <input type="password" class="form-control" name="password" id="password" maxlength="32" value="{$smarty.session.password}" /> + <input type="password" class="form-control" name="password" id="password" maxlength="32" value="{$smarty.session.password ?? ''}" /> {formhelp note="The administrator's password should be at least 4 characters in length."} {/forminput} </div> @@ -34,16 +34,16 @@ <div class="form-group"> {formlabel label="Re-enter password" for="pass_confirm"} {forminput} - <input type="password" class="form-control" name="pass_confirm" id="pass_confirm" maxlength="32" value="{$smarty.session.password}" /> + <input type="password" class="form-control" name="pass_confirm" id="pass_confirm" maxlength="32" value="{$smarty.session.password ?? ''}" /> {formhelp note="Please confirm the administrators password."} {/forminput} </div> <div class="form-group"> - {formfeedback error=$errors.email} + {formfeedback error=$errors.email ?? ''} {formlabel label="Email" for="email"} {forminput} - <input type="text" class="form-control" name="email" id="email" value="{$smarty.session.email}" /> + <input type="text" class="form-control" name="email" id="email" value="{$smarty.session.email ?? ''}" /> {formhelp note="Administrator email address, in case of site malfunction this email will be showen to users."} {/forminput} </div> @@ -52,7 +52,7 @@ {forminput} {forminput label="checkbox"} <input type="checkbox" name="testemail" id="testemail" value="y" checked="checked" /> - {tr}Test Email Transport{/tr} + Test Email Transport {/forminput} {formhelp note="Check this box to send a test email to the above address. This will let you know if the mailing system is working."} {/forminput} diff --git a/templates/install_admin_inc_done.tpl b/templates/install_admin_inc_done.tpl index 94605d9..1388d52 100644..100755 --- a/templates/install_admin_inc_done.tpl +++ b/templates/install_admin_inc_done.tpl @@ -10,7 +10,9 @@ <ul class="result"> {foreach from=$warning item=warn} <li class="warning"> - {booticon iname="fa-triangle-exclamation"} {$warn} + {booticon iname="icon-warning-sign" ipackage="icons" iexplain=warning} + + {$warn} </li> {/foreach} </div> @@ -55,7 +57,7 @@ {forminput} {if $mail.warning} {formfeedback error=$mail.warning} - {tr}You will have to consult your server adminstrator to fix this issue.{/tr} + You will have to consult your server adminstrator to fix this issue. {else} {formfeedback note="`$mail.success` Please check your inbox to confirm that the email was sent."} {/if} diff --git a/templates/install_beta1_beta2.tpl b/templates/install_beta1_beta2.tpl index ec52461..e58224c 100644..100755 --- a/templates/install_beta1_beta2.tpl +++ b/templates/install_beta1_beta2.tpl @@ -8,7 +8,7 @@ <p class="form-group">To upgrade CLYDE Beta 1 to CLYDE Beta 2, you need to upgrade your languages package.<br />We know we said we wouldn't make any rash schema changes, but we thought that since languages weren't working anyway, nobody could possibly loose data. We hope that this does not cause too great of a problem and we appologise for messing with the schema.<p> {foreach from=$schema key=package item=item} - {if $item.tables || $item.defaults} + {if $item.tables or $item.defaults} {if $package eq 'languages'} <div class="form-group"> <div class="formlabel"> diff --git a/templates/install_bit_settings.tpl b/templates/install_bit_settings.tpl index b369843..4152546 100644..100755 --- a/templates/install_bit_settings.tpl +++ b/templates/install_bit_settings.tpl @@ -35,19 +35,19 @@ {formlabel label="Home Page" for="bit_index"} {forminput} <select name="bit_index" id="bit_index" class="form-control"> - <option value="my_home"{if $bit_index eq 'my_home'} selected="selected"{/if}>{tr}My home{/tr}</option> + <option value="my_home"{if $bit_index eq 'my_home'} selected="selected"{/if}>My home</option> {if $smarty.const.ROLE_MODEL} - <option value="role_home"{if $bit_index eq 'role_home'} selected="selected"{/if}>{tr}Role home{/tr}</option> + <option value="role_home"{if $bit_index eq 'role_home'} selected="selected"{/if}>Role home</option> {else} - <option value="group_home"{if $bit_index eq 'group_home'} selected="selected"{/if}>{tr}Group home{/tr}</option> + <option value="group_home"{if $bit_index eq 'group_home'} selected="selected"{/if}>Group home</option> {/if} {foreach key=name item=package from=$schema } - {if $package.homeable && $package.installed} + {if $package.homeable and $package.installed} <option {if $package.name=='wiki'}selected="selected"{/if} value="{$package.name}">{$package.name}</option> {/if} {/foreach} {if $gBitSystem->isFeatureActive( 'users_custom_home' )} - <option value="users_custom_home"{if $bit_index eq $gBitSystem->getConfig('site_url_index')} selected="selected"{/if}>{tr}Custom home{/tr}</option> + <option value="users_custom_home"{if $bit_index eq $gBitSystem->getConfig('site_url_index')} selected="selected"{/if}>Custom home</option> {/if} </select> {formhelp note="Pick your site's homepage. This is where users will be redirected, when they access a link to your homepage. @@ -63,9 +63,9 @@ {formlabel label="Site Style" for="site_style"} {forminput} <select name="site_style" id="site_style" class="form-control"> - {foreach from=$stylesList item=s} + {* foreach from=$stylesList item=s} <option value="{$s.style}" {if $s.style eq "basic"}selected="selected"{/if}>{$s.style}</option> - {/foreach} + {/foreach *} </select> {formhelp note="Pick the look and feel style you wish to use. Custom styles can be added to the config/themes/ directory and then selected in the themes administration panel."} {/forminput} @@ -96,7 +96,7 @@ <div class="form-group"> {forminput} - <input type="submit" class="btn btn-primary" name="bit_settings" value="{tr}Set Preferences{/tr}" /> + <input type="submit" class="btn btn-primary" name="bit_settings" value="Set Preferences" /> {/forminput} </div> {/form} diff --git a/templates/install_cleanup.tpl b/templates/install_cleanup.tpl index af96f35..b1cf14d 100644..100755 --- a/templates/install_cleanup.tpl +++ b/templates/install_cleanup.tpl @@ -25,7 +25,7 @@ <ul> {foreach from=$package.tables item=table} <li> - <a style="float:right" href="#" onclick="BitBase.toggleElementDisplay('{$table.name}','block');return false">show table details</a> {$table.name}<br /> + <a style="float:right" href="#" onclick="\Bitweaver\BitBase.toggleElementDisplay('{$table.name}','block');return false">show table details</a> {$table.name}<br /> <div id="{$table.name}" style="display:none;"> <code>{$table.sql|nl2br}</code> </div> @@ -78,7 +78,7 @@ {legend legend="Fix Permissioning"} - {if $delPerms || $insPerms} + {if $delPerms or $insPerms} <p class="alert alert-block"> Some permissions require your attention. {if $insPerms} @@ -129,7 +129,7 @@ {/if} </table> {/if} - {if empty( $insPerms ) && empty( $delPerms )} + {if empty( $insPerms ) and empty( $delPerms )} <p class="alert alert-success"> The permissioning system in your installation is up to date and does not require any adjustments. Even though this is true, we recommend you visit the {smartlink ititle="Permission Maintenance" ipackage=users ifile="admin/permissions.php"} page at some point to ensure that all permissions are active. </p> @@ -178,7 +178,7 @@ </p> {/if} - {if $delPerms || $insPerms || $serviceList} + {if $delPerms or $insPerms or $serviceList} <div class="form-group"> {forminput} <input type="submit" class="btn btn-primary" name="resolve_conflicts" value="Resolve Issues" /> @@ -187,7 +187,7 @@ <div class="form-group"> {forminput label="checkbox"} - <input type="checkbox" name="debug" id="debug" value="true" /> {tr}Debug mode{/tr} + <input type="checkbox" name="debug" id="debug" value="true" /> Debug mode {formhelp note="Display SQL statements."} {/forminput} </div> diff --git a/templates/install_final_done.tpl b/templates/install_final_done.tpl index 812d479..6dad7c1 100644..100755 --- a/templates/install_final_done.tpl +++ b/templates/install_final_done.tpl @@ -29,7 +29,7 @@ </li> <li> <strong>bitweaver Configuration</strong> - <br />We urge you to look at your <kbd>config/kernel/config_inc.php</kbd> file. It has various useful settings for sites in production. One of these is the <strong>IS_LIVE</strong> parameter. Setting this to <strong>TRUE</strong> will prevent any visible bug reports and will therefore not display sensitive information to the user. + <br />We urge you to look at your <kbd>config/kernel/config_inc.php</kbd> file. It has various useful settings for sites in production. One of these is the <strong>IS_LIVE</strong> parameter. Setting this to <strong>true</strong> will prevent any visible bug reports and will therefore not display sensitive information to the user. </li> </ul> </div> diff --git a/templates/install_login.tpl b/templates/install_login.tpl index 8df50ac..64ec50c 100644..100755 --- a/templates/install_login.tpl +++ b/templates/install_login.tpl @@ -21,7 +21,7 @@ <div class="form-group"> {forminput} - <input type="submit" class="btn btn-primary" name="signin" value="{tr}Log in to {$gBitSystem->getConfig('site_title')|default:"this site"}{/tr}" /> + <input type="submit" class="btn btn-primary" name="signin" value="Log in to {$gBitSystem->getConfig('site_title')|default:"this site"}" /> {/forminput} </div> {/form} diff --git a/templates/install_packages.tpl b/templates/install_packages.tpl index ebf76b7..5c52d1f 100644..100755 --- a/templates/install_packages.tpl +++ b/templates/install_packages.tpl @@ -23,13 +23,13 @@ {* include required packages during first install *} {foreach from=$schema key=package item=item} - {if $item.required && !$item.installed} + {if $item.required|default:false and !$item.installed} <input type="hidden" name="packages[]" value="{$package}" /> {/if} {/foreach} {foreach from=$schema key=package item=item} - {if !$item.installed and !$item.required} + {if !$item.installed and !$item.required|default:false} {assign var=new_packages value=true} {/if} {/foreach} @@ -43,7 +43,7 @@ <div class="form-group"> {forminput label="checkbox"} - <script type="text/javascript">/* <![CDATA[ */ + <script>/* <![CDATA[ */ document.write("<input name=\"switcher\" id=\"switcher\" type=\"checkbox\" checked onclick=\"BitBase.switchCheckboxes(this.form.id,'packages[]','switcher')\" /> Batch (de)select all Packages and Services on this page"); /* ]]> */</script> {/forminput} @@ -51,14 +51,14 @@ <div class="bit-columns"> {foreach from=$schema key=package item=item} - {if !$item.installed and !$item.required} + {if !$item.installed and !$item.required|default:false} <div class="bit-column-cell"> <div class="well"> - <label class="control-label" for="{$package}">{biticon ipackage=$package iname="pkg_$package" iexplain=$package class="img-responsive"}</label> + <label class="control-label" for="{$package}">{biticon ipackage=$package iname="pkg_$package" iexplain=$package}</label> {forminput label="checkbox"} <input type="checkbox" name="packages[]" value="{$package}" id="{$package}" checked="checked" /> <strong>{$package|capitalize}</strong></label> - {formhelp note=$item.info is_installer=1} - {formhelp note="<strong>Location</strong>: `$item.url`"} + {formhelp note=$item.info|default:'' is_installer=1} + {formhelp note="<strong>Location</strong>: `$item.url|default:''`"} {formhelp package=$package} {/forminput} </div> @@ -69,7 +69,7 @@ {/legend} {elseif $first_install} <h2>Core System Installation</h2> - <p>{tr}Only the core required packages will be installed{/tr}</p> + <p>Only the core required packages will be installed</p> {else} <h2>No Additional Packages</h2> @@ -91,7 +91,7 @@ {/if} <div class="form-group"> {forminput label="checkbox"} - <input type="checkbox" name="debug" value="true" /> {tr}Debug mode{/tr} + <input type="checkbox" name="debug" value="true" /> Debug mode {formhelp note="Display SQL statements."} {/forminput} </div> @@ -143,14 +143,14 @@ <div class="bit-columns"> {foreach from=$schema key=package item=item} - {if $item.tables || $item.defaults} - {if $item.installed and !$item.required} + {if !empty($item.tables) or !empty($item.defaults)} + {if $item.installed and !$item.required|default:false} <div class="bit-column-cell well"> <label for="{$package}">{biticon ipackage=$package iname="pkg_$package" iexplain=$package}</label> {forminput label="checkbox"} <input type="checkbox" name="packages[]" value="{$package}" id="{$package}" /> <strong>{$package|capitalize}</strong> - {formhelp note=$item.info is_installer=1} - {formhelp note="<strong>Location</strong>: `$item.url`"} + {formhelp note=$item.info|default:'' is_installer=1} + {formhelp note="<strong>Location</strong>: `$item.url|default:''`"} {formhelp package=$package} {/forminput} </div> @@ -189,15 +189,15 @@ <div class="bit-columns"> {foreach from=$schema key=package item=item} - {if $item.required} + {if $item.required|default:false} <div class="bit-column-cell well"> <label class="control-label"> {biticon ipackage=$package iname="pkg_$package" iexplain=$package} </label> {forminput} <strong>{$package|capitalize}</strong> - {formhelp note=$item.info is_installer=1} - {formhelp note="<strong>Location</strong>: `$item.url`"} + {formhelp note=$item.info|default:'' is_installer=1} + {formhelp note="<strong>Location</strong>: `$item.url|default:''`"} {formhelp package=$package} {/forminput} </div> diff --git a/templates/install_packages_done.tpl b/templates/install_packages_done.tpl index 6599e05..9615202 100644..100755 --- a/templates/install_packages_done.tpl +++ b/templates/install_packages_done.tpl @@ -33,7 +33,7 @@ </div> {/if} - {if $packageList.install} + {if !empty($packageList.install)} <h2>Packages that were installed</h2> <ul> {foreach from=$packageList.install item=package} @@ -44,7 +44,7 @@ </ul> {/if} - {if $packageList.uninstall} + {if !empty($packageList.uninstall)} <div class="form-group"> {formlabel label="Packages that were uninstalled"} {forminput} @@ -59,7 +59,7 @@ </div> {/if} - {if $packageList.reinstall} + {if !empty($packageList.reinstall)} <div class="form-group"> {formlabel label="Packages that were reinstalled"} {forminput} diff --git a/templates/install_upgrade.tpl b/templates/install_upgrade.tpl index 861f4c8..3dd0601 100644..100755 --- a/templates/install_upgrade.tpl +++ b/templates/install_upgrade.tpl @@ -7,7 +7,7 @@ {if $packageUpgrades} <h2>Packages and their upgrades</h2> - <div class="alert alert-danger"><div class="pull-left">{booticon iname="fa-triangle-exclamation" style="font-size:3em;padding-right:20px;"}</div> You are about to run an upgrade which might make changes to your database. We <strong>strongly</strong> recommend that you back up your database (preferably carry out the entire <a class="external" href="http://www.bitweaver.org/wiki/bitweaverUpgrade#Generalproceduretoupgrade">backup procedure</a>).</div> + <div class="alert alert-danger"><div class="pull-left"><i class="icon-warning-sign" style="font-size:3em;padding-right:20px;"></i></div> You are about to run an upgrade which might make changes to your database. We <strong>strongly</strong> recommend that you back up your database (preferably carry out the entire <a class="external" href="http://www.bitweaver.org/wiki/bitweaverUpgrade#Generalproceduretoupgrade">backup procedure</a>).</div> {foreach from=$packageUpgrades item=upgrade key=package} {* users don't have the option to select what packages to upgrade since the code of the package is dependent on this upgrade <h3>{forminput label="checkbox"}<input type="checkbox" name="packages[]" value="{$package}" checked="checked" /> {$package}{/forminput}</h3> *} @@ -101,7 +101,7 @@ <tr class="{$class}"> <td>{$dep.requires|ucfirst}</td> <td>{$dep.required_version.min}</td> - <td>{$dep.required_version.max}</td> + <td>{$dep.required_version.max|default:''}</td> <td>{$dep.version.available}</td> <td> {if $dep.result == 'ok'} @@ -147,7 +147,7 @@ <p class="alert alert-block">At least one required package is in an unknown state. The upgrade may not work because of this. It is probably worth reinstalling the latest version of that package or contacting its developer.</p> {/if} - {if !$min_dep && !$max_dep && !$missing} + {if !$min_dep and !$max_dep and !$missing} <p class="alert alert-success">All package requirements have been met. You can proceed with the installation process.</p> {/if} {/if} diff --git a/templates/install_version.tpl b/templates/install_version.tpl index 46f045d..1935e2a 100644..100755 --- a/templates/install_version.tpl +++ b/templates/install_version.tpl @@ -27,10 +27,10 @@ <table class="table data"> - <caption>{tr}Available Permissions{/tr}</caption> + <caption>Available Permissions</caption> {capture assign=theader} <tr> - <th style="width:30%;">{tr}Permission{/tr}</th> + <th style="width:30%;">Permission</th> {foreach from=$allGroups item=group name=groups} <th> <abbr title="{$group.group_name}">{if $smarty.foreach.groups.total > 8}{$group.group_id}{else}{$group.group_name}{/if}</abbr> diff --git a/templates/install_welcome.tpl b/templates/install_welcome.tpl index 7045180..ad3d97a 100644..100755 --- a/templates/install_welcome.tpl +++ b/templates/install_welcome.tpl @@ -3,7 +3,9 @@ <div class="col-md-8"> <h1>Welcome to the Bitweaver Installer</h1> - <p class="alert alert-warning">Since this does not appear to be your first install, you can access various pages of the installer. To install new packages, please visit <strong><a href="install.php?step=3">Packages</a></strong>.</p> + {if $gBitUser->isAdmin()} + <p class="alert alert-block">Since this does not appear to be your first install, you can access various pages of the installer. To install new packages, please visit <strong><a href="install.php?step=3">Packages</a></strong>.</p> + {/if} <p>Thank you for choosing Bitweaver. This web content management system offers an unparalleled consonance of simplicity, performance, and flexibility. For questions, comments, and support, please visit <a class="external" href="http://www.bitweaver.org">bitweaver.org</a>. Help is available via <a class="external" href="http://www.bitweaver.org/">the forum</a> and via <a title="#bitweaver IRC Channel on freenode.net" class="external" href="http://www.bitweaver.org/wiki/Live+Support">#bitweaver chat</a>. Click to begin the install process:</p> @@ -11,9 +13,9 @@ <div class="form-group"> {forminput} - {if $gBitInstaller->isInstalled()} - <a class="btn btn-default" href="{$smart.const.INSTALL_PKG_URL}?step=4">Upgrade</a> <a class="btn btn-default" href="{$smart.const.INSTALL_PKG_URL}?step=3">Install Packages</a> - <a class="btn btn-danger pull-right" href="{$smart.const.INSTALL_PKG_URL}?step=1">Restart Installation</a> + {if $gBitUser->isAdmin()} + <a class="btn btn-default" href="{$smarty.const.INSTALL_PKG_URL}?step=4">Upgrade</a> <a class="btn" href="{$smarty.const.INSTALL_PKG_URL}?step=3">Install Packages</a> + <a class="btn btn-danger pull-right" href="{$smarty.const.INSTALL_PKG_URL}?step=1">Restart Installation</a> {else} <input type="hidden" name="step" value="{$next_step}" /> <input type="submit" class="btn btn-primary" name="install" value="Begin the install process" /> diff --git a/templates/migrate_database.tpl b/templates/migrate_database.tpl index bc7ff01..c213205 100644..100755 --- a/templates/migrate_database.tpl +++ b/templates/migrate_database.tpl @@ -73,7 +73,7 @@ {formlabel label="Source database name" for="name_src"} {forminput} <input type="text" class="form-control" name="name_src" id="name_src" value="{$name_src}" /> - { if ( $fbpath ) } + {if ( $fbpath )} {formhelp note="The name of the database where Bitweaver will create tables. You can create a Firebird alias for the Bitweaver database in aliases.conf and then use that aliase as the database name, or provide a full path and file name to create @@ -88,7 +88,7 @@ </div> <div class="form-group"> - { if ( $fbpath ) } + {if ( $fbpath )} {formhelp note="<strong>Do not use prefix with Firebird, as the field and table names are already up to 30 characters.</strong>"} {/if} {formlabel label="Source Database Prefix" for="prefix_src"} @@ -102,7 +102,7 @@ {/forminput} </div> - { if ( $fbpath ) } + {if ( $fbpath )} <div class="form-group"> {formlabel label="Firebird Installation Path" for="fbpath"} {forminput} @@ -184,7 +184,7 @@ {formlabel label="Destination database name" for="name_dst"} {forminput} <input type="text" class="form-control" name="name_dst" id="name_dst" value="{$gBitDbName}" /> - { if ( $fbpath ) } + {if ( $fbpath )} {formhelp note="The name of the database where Bitweaver will create tables. You can create a Firebird alias for the Bitweaver database in aliases.conf and then use that aliase as the database name, or provide a full path and file name to create @@ -199,7 +199,7 @@ </div> <div class="form-group"> - { if ( $fbpath ) } + {if ( $fbpath )} {formhelp note="<strong>Do not use prefix with Firebird, as the field and table names are already up to 30 characters.</strong>"} {/if} {formlabel label="Destination Database Prefix" for="prefix_dst"} @@ -213,7 +213,7 @@ {/forminput} </div> - { if ( $fbpath ) } + {if ( $fbpath )} <div class="form-group"> {formlabel label="Firebird installation path" for="fbpath"} {forminput} diff --git a/upgrade.php b/upgrade.php index 8c42fb6..a7d8c39 100644..100755 --- a/upgrade.php +++ b/upgrade.php @@ -15,7 +15,7 @@ /** * required setup */ -require_once( 'includes/install_inc.php' ); +require_once 'includes/install_inc.php'; // this variable will be appended to the template file called - useful for displaying messages after data input $app = ''; @@ -24,7 +24,7 @@ $app = ''; if( !isset( $_REQUEST['step'] ) ) { $_REQUEST['step'] = 0; } elseif( $_REQUEST['step'] == '0' ) { - $_SESSION['upgrade_r1'] = NULL; + $_SESSION['upgrade_r1'] = null; } $step = $_REQUEST['step']; @@ -44,7 +44,7 @@ $install_file[$i]['name'] = 'Upgrade Complete'; // currently i can't think of a better way to secure the upgrade pages // redirect to the installer if we aren't sent here by the installer and the upgrade session variable hasn't been set -if( !isset( $_SESSION['upgrade'] ) || $_SESSION['upgrade'] != TRUE || +if( !isset( $_SESSION['upgrade'] ) || $_SESSION['upgrade'] != true || !isset( $_SERVER['HTTP_REFERER'] ) || isset( $_SERVER['HTTP_REFERER'] ) && ( ( !strpos( $_SERVER['HTTP_REFERER'],'install/install.php' ) ) && ( !strpos( $_SERVER['HTTP_REFERER'],'install/upgrade.php' ) ) && ( !strpos( $_SERVER['HTTP_REFERER'],'install/migrate.php' ) ) ) @@ -56,7 +56,7 @@ if( !isset( $_SESSION['upgrade'] ) || $_SESSION['upgrade'] != TRUE || // if it was selected as storage type, we set a session var // for use in update_packages.php if( isset( $_REQUEST['use_innodb'] ) ) { - $_SESSION['use_innodb'] = TRUE; + $_SESSION['use_innodb'] = true; } /** @@ -71,5 +71,3 @@ $gBitSmarty->assign( 'section', 'Upgrade' ); $gBitSmarty->assign( 'install_file', INSTALL_PKG_PATH."templates/upgrade_".$install_file[$step]['file'].$app.".tpl" ); $gBitInstaller->in_display( $install_file[$step]['name'], INSTALL_PKG_PATH.'templates/install.tpl' ); - -?> diff --git a/upgrade_database.php b/upgrade_database.php index 76e4188..653bd5f 100644..100755 --- a/upgrade_database.php +++ b/upgrade_database.php @@ -9,7 +9,7 @@ * required setup */ $app = ''; -include_once( INSTALL_PKG_PATH.'install_database.php' ); +include_once( 'includes/install_database.php' ); // update the MySQL settings in the db server array if( function_exists( 'mysql_connect' ) ) { // check version of mysql server @@ -22,4 +22,3 @@ if( function_exists( 'mysql_connect' ) ) { } } $gBitSmarty->assign( 'include_template', INSTALL_PKG_PATH."templates/install_database".$app.".tpl" ); -?> diff --git a/upgrade_final.php b/upgrade_final.php index 6da3dff..03cb53c 100644..100755 --- a/upgrade_final.php +++ b/upgrade_final.php @@ -4,6 +4,7 @@ * @package install * @subpackage upgrade */ +namespace Bitweaver; // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See below for details and a complete list of authors. @@ -14,13 +15,12 @@ $app = '_done'; $gBitSmarty->assign( 'next_step', $step ); if( isset( $_REQUEST['enter_bitweaver'] ) ) { - $_SESSION = NULL; - bit_redirect( BIT_ROOT_URL ); + $_SESSION = null; + KernelTools::bit_redirect( BIT_ROOT_URL ); } elseif( isset( $_REQUEST['continue_install'] ) ) { - bit_redirect( INSTALL_PKG_URL.'install.php?step=5' ); + KernelTools::bit_redirect( INSTALL_PKG_URL.'install.php?step=5' ); } elseif( isset( $_REQUEST['resolve_conflicts'] ) ) { - bit_redirect( INSTALL_PKG_URL.'install.php?step=6' ); + KernelTools::bit_redirect( INSTALL_PKG_URL.'install.php?step=6' ); } else { $gBitSmarty->assign( 'next_step',$step ); } -?> diff --git a/upgrade_packages.php b/upgrade_packages.php index 8aea5ee..5098682 100644..100755 --- a/upgrade_packages.php +++ b/upgrade_packages.php @@ -61,12 +61,12 @@ $upgradePath = array ( $gBitSmarty->assign( 'upgradeFrom', $gUpgradeFrom ); $gBitSmarty->assign( 'upgradeTo', $gUpgradeTo ); -$upPackages = array(); +$upPackages = []; if( !empty( $_REQUEST['upgrade'] ) ) { if( isset( $upgradePath[$_REQUEST['upgrade_from']] ) ) { if( !empty( $gDebug ) || !empty( $_REQUEST['debug'] ) ) { - $gBitInstaller->mDb->debug(); + $gBitInstaller->debug(); } foreach( $upgradePath[$_REQUEST['upgrade_from']] as $from=>$to ) { @@ -74,7 +74,7 @@ if( !empty( $_REQUEST['upgrade'] ) ) { $gUpgradeFrom = $from; $gUpgradeTo = $to; - $gBitInstaller->scanPackages( 'admin/upgrade_inc.php', FALSE ); + $gBitInstaller->scanPackages( 'admin/upgrade_inc.php', false ); $firstPackages = array_flip( array( 'kernel', 'users', 'categories', 'liberty', 'wiki', 'blogs' ) ); $secondPackages = array_flip( $upgrading ); @@ -96,7 +96,7 @@ if( !empty( $_REQUEST['upgrade'] ) ) { } // If server supports InnoDB for MySql and selected for use // we traverse all tables in db after upgrade and change engine if needed - if( isset( $_SESSION['use_innodb'] ) && $_SESSION['use_innodb'] == TRUE ) { + if( isset( $_SESSION['use_innodb'] ) && $_SESSION['use_innodb'] == true ) { $rs = $gBitInstaller->mDb->Execute("SHOW TABLE STATUS"); while ( !$rs->EOF) { $row = $rs->GetRowAssoc(false); @@ -119,5 +119,4 @@ if( !empty( $_REQUEST['upgrade'] ) ) { $app = '_done'; $gBitSmarty->assign( 'next_step',$step + 1 ); -} -?> +}
\ No newline at end of file diff --git a/upgrade_welcome.php b/upgrade_welcome.php index 34d2b62..0724fa8 100644..100755 --- a/upgrade_welcome.php +++ b/upgrade_welcome.php @@ -16,5 +16,4 @@ if( ini_get( "max_execution_time" ) != 86400 ) { } // assign next step in installation process -$gBitSmarty->assign( 'next_step', $step + 1 ); -?> +$gBitSmarty->assign( 'next_step', $step + 1 );
\ No newline at end of file |
