summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2025-08-29 13:35:20 +0100
committerlsces <lester@lsces.co.uk>2025-08-29 13:35:20 +0100
commit96e95d3cfeed254b5cd37bf1c5990e747d299e76 (patch)
tree03b88b23fcb0df53993e8e1265b9bfcff40b97db
parent5852e4e2bd96c0c42e173e8c45799e4e943cb4e0 (diff)
downloadkernel-96e95d3cfeed254b5cd37bf1c5990e747d299e76.tar.gz
kernel-96e95d3cfeed254b5cd37bf1c5990e747d299e76.tar.bz2
kernel-96e95d3cfeed254b5cd37bf1c5990e747d299e76.zip
Kernel extras changes to cover uninitialized variables and style changes for PHP8.4
-rwxr-xr-x[-rw-r--r--]includes/ajax_file_browser_inc.php23
-rwxr-xr-xincludes/autoload.php31
-rwxr-xr-x[-rw-r--r--]includes/backups_lib.php16
-rwxr-xr-x[-rw-r--r--]includes/bit_error_inc.php82
-rwxr-xr-x[-rw-r--r--]includes/config_defaults_inc.php90
-rw-r--r--includes/kernel_lib.php891
-rwxr-xr-x[-rw-r--r--]includes/module_controls_inc.php13
-rwxr-xr-x[-rw-r--r--]includes/notification_lib.php86
-rwxr-xr-x[-rw-r--r--]includes/setup_inc.php109
-rwxr-xr-x[-rw-r--r--]includes/simple_form_functions_lib.php38
-rwxr-xr-x[-rw-r--r--]includes/upload_slot_inc.php2
11 files changed, 268 insertions, 1113 deletions
diff --git a/includes/ajax_file_browser_inc.php b/includes/ajax_file_browser_inc.php
index 61806ad..56dca12 100644..100755
--- a/includes/ajax_file_browser_inc.php
+++ b/includes/ajax_file_browser_inc.php
@@ -35,16 +35,16 @@
*
* NOTE: when you process the imported files, make sure you use realpath() to check of files are really in your 'jail'.
*/
-require_once( 'setup_inc.php' );
+require_once 'setup_inc.php';
// we need to set these global that we can include this file from functions
global $gBitThemes, $gBitSystem, $gBitSmarty;
if( !empty( $_REQUEST['ajax_path_conf'] ) && $gBitSystem->isFeatureActive( $_REQUEST['ajax_path_conf'] ) ) {
- $fileList = ajax_dir_list( $gBitSystem->getConfig( $_REQUEST['ajax_path_conf'] ), ( !empty( $_REQUEST['relpath'] ) ? $_REQUEST['relpath']."/" : NULL ));
+ $fileList = ajax_dir_list( $gBitSystem->getConfig( $_REQUEST['ajax_path_conf'] ), !empty( $_REQUEST['relpath'] ) ? $_REQUEST['relpath'] . "/" : null);
$gBitSmarty->assign( 'fileList', $fileList );
}
$gBitThemes->loadAjax( 'mochikit', array( 'Iter.js', 'DOM.js', 'Async.js' ));
-$gBitThemes->loadJavascript( KERNEL_PKG_PATH."scripts/BitFileBrowser.js", TRUE );
+$gBitThemes->loadJavascript( KERNEL_PKG_PATH."scripts/BitFileBrowser.js", true );
if( $gBitThemes->isAjaxRequest() ) {
$gBitSmarty->display( 'bitpackage:kernel/ajax_file_browser_inc.tpl' );
@@ -53,18 +53,18 @@ if( $gBitThemes->isAjaxRequest() ) {
/**
* ajax_dir_list
*
- * @param array $pDir Base directory
- * @param array $pRelPath relative path on top of base directory
+ * @param string $pDir Base directory
+ * @param string $pRelPath relative path on top of base directory
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
- */
-function ajax_dir_list( $pDir, $pRelPath = NULL ) {
+ * @return array
+ */
+function ajax_dir_list( $pDir, $pRelPath = null ) {
global $gBitSystem;
- $ret = $files = array();
+ $ret = $files = [];
if( !empty( $pDir ) && is_dir( $pDir.$pRelPath )) {
if( $handle = opendir( $pDir.$pRelPath )) {
- while( FALSE !== ( $file = readdir( $handle ))) {
+ while( false !== ( $file = readdir( $handle ))) {
if( !preg_match( "#^\.#",$file ) && is_readable( $pDir.$pRelPath.$file )) {
array_push( $files, $file );
}
@@ -99,5 +99,4 @@ function ajax_dir_list( $pDir, $pRelPath = NULL ) {
}
return $ret;
-}
-?>
+} \ No newline at end of file
diff --git a/includes/autoload.php b/includes/autoload.php
new file mode 100755
index 0000000..b0bca6b
--- /dev/null
+++ b/includes/autoload.php
@@ -0,0 +1,31 @@
+<?php
+
+/* Function autoload package classes */
+function class_autoload( $className ) {
+ // Split the class name into parts using the namespace separator
+ $parts = explode('\\', $className);
+ // if not Bitweaver namespace kick out
+ if ( !($parts[0] == 'Bitweaver') ) return;
+
+ // Ensure there are at least three parts (namespace, package, class)
+ if (count($parts) == 2) {
+ $parts[2] = $parts[1];
+ $parts[1] = 'kernel/includes/classes/';
+ } elseif ($parts[1] == 'Plugins' ) {
+ $parts[1] = 'themes/smartyplugins/';
+ } elseif (count($parts) <> 3) {
+ return;
+ } else {
+ $parts[1] .= '/includes/classes/';
+ }
+
+ $base_dir = BIT_ROOT_PATH . strtolower( $parts[1] );
+
+ $file = $base_dir . $parts[2] . '.php';
+
+ if (file_exists($file)) {
+ require $file;
+ }
+}
+
+spl_autoload_register('class_autoload'); \ No newline at end of file
diff --git a/includes/backups_lib.php b/includes/backups_lib.php
index 08d08fb..50df336 100644..100755
--- a/includes/backups_lib.php
+++ b/includes/backups_lib.php
@@ -1,4 +1,6 @@
<?php
+use Bitweaver\BitBase;
+
/**
* Database Backup Library
*
@@ -17,7 +19,7 @@ class BackupLib extends BitBase {
global $gBitDbType;
// Get the password before it's too late
$query = "select `hash` from `".BIT_DB_PREFIX."users_users` where `user_id`=?";
- $pwd = $this->mDb->getOne($query,array(ROOT_USER_ID));
+ $pwd = $this->mDb->getOne($query, [ ROOT_USER_ID ]);
switch ($gBitDbType) {
case "postgres":
@@ -32,7 +34,7 @@ class BackupLib extends BitBase {
$part = '';
while ($res = $result->fetchRow()) {
- list($key, $val) = each($res);
+ [ $key, $val ] = $res;
if (!strstr($val, 'babl')) {
// Now delete the table contents
@@ -42,7 +44,7 @@ class BackupLib extends BitBase {
}
// $query = "update `".BIT_DB_PREFIX."users_users` set `hash`=? where `login`=?";
-// $result = $this->mDb->query($query,array($pwd,'admin'));
+// $result = $this->mDb->query($query, [ pwd,'admin'] );
@$fp = fopen($filename, "rb");
if (!$fp) return false;
@@ -59,7 +61,7 @@ class BackupLib extends BitBase {
// $line = $this->RC4($pwd, $line);
// EXECUTE SQL SENTENCE HERE
- $result = $this->mDb->query($line,array());
+ $result = $this->mDb->query($line,[]);
}
fclose ($fp);
@@ -117,7 +119,7 @@ class BackupLib extends BitBase {
ini_set("max_execution_time", "3000");
$query = "select `hash` from `".BIT_DB_PREFIX."users_users` where `user_id`=?";
- $pwd = $this->mDb->getOne($query,array(ROOT_USER_ID));
+ $pwd = $this->mDb->getOne($query, [ ROOT_USER_ID ]);
@$fp = fopen($filename, "w");
if (!$fp)
@@ -136,7 +138,7 @@ class BackupLib extends BitBase {
$part = '';
while ($res = $result->fetchRow()) {
- list($key, $val) = each($res);
+ [ $key, $val ] = $res;
if (!strstr($val, 'babl')) {
// Now dump the table
@@ -183,5 +185,3 @@ class BackupLib extends BitBase {
}
$backuplib = new BackupLib();
-
-?>
diff --git a/includes/bit_error_inc.php b/includes/bit_error_inc.php
index 6fb1f7c..50abb69 100644..100755
--- a/includes/bit_error_inc.php
+++ b/includes/bit_error_inc.php
@@ -16,10 +16,15 @@
*/
/**
+ * required setup
+ */
+namespace Bitweaver;
+
+/**
* set error handling
*/
if( !defined( 'BIT_INSTALL' ) && !defined( 'ADODB_ERROR_HANDLER' ) ) {
- define( 'ADODB_ERROR_HANDLER', 'bitdb_error_handler' );
+ define( 'ADODB_ERROR_HANDLER', '\Bitweaver\bitdb_error_handler' );
}
/**
@@ -54,7 +59,7 @@ function bit_print_log( $pLogParams, $pLogMessages ) {
for( $i = 1; $i < func_num_args(); $i++ ) {
if( $pLogMessage = func_get_arg( $i ) ) {
- $errlines = explode( "\n", (is_array( $pLogMessage ) || is_object( $pLogMessage ) ? vc( $pLogMessage, FALSE ) : $pLogMessage) );
+ $errlines = explode( "\n", is_array( $pLogMessage ) || is_object( $pLogMessage ) ? vc( $pLogMessage, false ) : $pLogMessage);
foreach ($errlines as $txt) {
print "$virtualHost $remoteAddr $ident $userName $logTimestamp \"$scriptFilename\" $statusCode $executionTime \"$userAgent\" $pLogMessage\n";
}
@@ -67,7 +72,7 @@ function bit_print_log( $pLogParams, $pLogMessages ) {
function bit_error_log() {
for( $i = 0; $i < func_num_args(); $i++ ) {
if( $pLogMessage = func_get_arg( $i ) ) {
- $errlines = explode( "\n", (is_array( $pLogMessage ) || is_object( $pLogMessage ) ? vc( $pLogMessage, FALSE ) : $pLogMessage) );
+ $errlines = explode( "\n", is_array( $pLogMessage ) || is_object( $pLogMessage ) ? vc( $pLogMessage, false ) : $pLogMessage);
foreach ($errlines as $txt) {
error_log($txt);
}
@@ -95,37 +100,38 @@ if( !function_exists( 'eb' ) ) {
}
}
-function bit_error_email ( $pSubject, $pMessage, $pGlobalVars=array() ) {
+function bit_error_email ( $pSubject, $pMessage, $pGlobalVars=[] ) {
// You can prevent sending of error emails by adding define('ERROR_EMAIL', ''); in your config/kernel/config_inc.php
- $errorEmail = defined( 'ERROR_EMAIL' ) ? ERROR_EMAIL : (!empty( $_SERVER['SERVER_ADMIN'] ) ? $_SERVER['SERVER_ADMIN'] : NULL);
+ $errorEmail = defined( 'ERROR_EMAIL' ) ? ERROR_EMAIL : (!empty( $_SERVER['SERVER_ADMIN'] ) ? $_SERVER['SERVER_ADMIN'] : null);
$separator = "\n";
$indent = " ";
$parameters = '';
if( empty( $pGlobalVars ) ) {
- $pGlobalVars = array(
+ $pGlobalVars = [
'$_POST' => $_POST,
'$_GET' => $_GET,
'$_FILES' => $_FILES,
'$_COOKIE' => $_COOKIE,
- );
+ ];
}
foreach( $pGlobalVars as $global => $hash ) {
if( !empty( $hash )) {
- $parameters .= $separator.$global.': '.$separator.var_export( $hash, TRUE ).$separator;
+ $parameters .= $separator.$global.': '.$separator.var_export( $hash, true ).$separator;
}
}
$parameters = preg_replace( "/\n/", $separator.$indent, $parameters );
- mail( $errorEmail, $pSubject, $pMessage.$parameters.$separator.$separator.'$_SERVER: '.var_export( $_SERVER, TRUE ) );
+ mail( $errorEmail, $pSubject, $pMessage.$parameters.$separator.$separator.'$_SERVER: '.var_export( $_SERVER, true ) );
}
-function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=NULL ) {
+function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=null ) {
// error_reporting() === 0 if code was prepended with @
- $reportingLevel = error_reporting();
+
+ $reportingLevel = error_reporting();
if( $reportingLevel !== 0 && !strpos( $errfile, 'templates_c' ) ) {
$errType = 'Error';
- $isReported = TRUE;
+ $isReported = true;
switch ($errno) {
case E_ERROR: $errType = 'FATAL ERROR'; break;
case E_WARNING: $isReported = $reportingLevel & E_WARNING; $errType = 'WARNING'; break;
@@ -138,7 +144,6 @@ function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=NU
case E_USER_ERROR: $isReported = $reportingLevel & E_USER_ERROR; $errType = 'USER_ERROR'; break;
case E_USER_WARNING: $isReported = $reportingLevel & E_USER_WARNING; $errType = 'USER_WARNING'; break;
case E_USER_NOTICE: $isReported = $reportingLevel & E_USER_NOTICE; $errType = 'USER_NOTICE'; break;
- case E_STRICT: $isReported = $reportingLevel & E_STRICT; $errType = 'STRICT'; break;
case E_RECOVERABLE_ERROR: $isReported = $reportingLevel & E_RECOVERABLE_ERROR; $errType = 'RECOVERABLE_ERROR'; break;
case E_DEPRECATED: $isReported = $reportingLevel & E_DEPRECATED; $errType = 'DEPRECATED'; break;
case E_USER_DEPRECATED: $isReported = $reportingLevel & E_USER_DEPRECATED; $errType = 'USER_DEPRECATED'; break;
@@ -146,7 +151,7 @@ function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=NU
}
- $isReported = TRUE;
+ $isReported = true;
if( $isReported ) {
//eb( $isReported, $errType, $errno, $reportingLevel, $errfile );
$errorSubject = 'PHP '.$errType.' on '.php_uname( 'n' ).': '.$errstr;
@@ -166,10 +171,10 @@ function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=NU
}
}
}
- }
+ }
// Execute PHP's internal error handler
- return FALSE;
+ return false;
}
function bit_shutdown_handler() {
@@ -183,10 +188,10 @@ function bit_shutdown_handler() {
}
}
-register_shutdown_function('bit_shutdown_handler');
+register_shutdown_function('Bitweaver\bit_shutdown_handler');
-function bit_display_error( $pLogMessage, $pSubject, $pFatal = TRUE ) {
+function bit_display_error( $pLogMessage, $pSubject, $pFatal = true ) {
global $gBitSystem;
if( $pFatal ) {
@@ -208,7 +213,7 @@ function bit_display_error( $pLogMessage, $pSubject, $pFatal = TRUE ) {
<ul>
<li><a href='http://sourceforge.net/tracker/?func=add&amp;group_id=141358&amp;atid=749176'>Click here to log a bug</a>, if this appears to be an error with the application.</li>
<li><a href='".BIT_ROOT_URL."install/install.php'>Go here to begin the installation process</a>, if you haven't done so already.</li>
- <li>To hide this message, please <strong>set the IS_LIVE constant to TRUE</strong> in your config/kernel/config_inc.php file.</li>
+ <li>To hide this message, please <strong>set the IS_LIVE constant to true</strong> in your config/kernel/config_inc.php file.</li>
</ul>
<hr />
";
@@ -218,7 +223,7 @@ function bit_display_error( $pLogMessage, $pSubject, $pFatal = TRUE ) {
} else {
bit_error_email ( $pSubject, $pLogMessage );
if( defined( 'AUTO_BUG_SUBMIT' ) && AUTO_BUG_SUBMIT && !empty( $gBitSystem ) && $gBitSystem->isDatabaseValid() ) {
- mail( 'bugs@bitweaver.org',"$pSubject",$pLogMessage );
+ mail( 'support@rainbowdigitalmedia.uk',"$pSubject",$pLogMessage );
}
}
@@ -227,7 +232,7 @@ function bit_display_error( $pLogMessage, $pSubject, $pFatal = TRUE ) {
}
}
-function bit_error_string( $iDBParms = array() ) {
+function bit_error_string( $iDBParms = [] ) {
global $gBitDb;
global $gBitUser;
global $argv;
@@ -237,11 +242,7 @@ function bit_error_string( $iDBParms = array() ) {
$date = date("D M d H:i:s Y"); // [Tue Sep 24 12:19:20 2002] [error]
- if( is_a( $gBitUser, 'BitUser' ) ) {
- $acctStr = "ID: ".$gBitUser->mInfo['user_id']." - Login: ".$gBitUser->mInfo['login']." - e-mail: ".$gBitUser->mInfo['email'];
- } else {
- $acctStr = "User unknown";
- }
+ $acctStr = is_a( $gBitUser, 'BitUser' ) ? "ID: ".$gBitUser->mInfo['user_id']." - Login: ".$gBitUser->mInfo['login']." - e-mail: ".$gBitUser->mInfo['email'] : "User unknown";
$info = $indent."[ - ".BIT_MAJOR_VERSION.".".BIT_MINOR_VERSION.".".BIT_SUB_VERSION." ".BIT_LEVEL." - ] [ $date ]".$separator;
$info .= $indent."-----------------------------------------------------------------------------------------------".$separator;
@@ -253,7 +254,7 @@ function bit_error_string( $iDBParms = array() ) {
} elseif( !empty( $_SERVER['REQUEST_URI'] ) ) {
$uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
} elseif( !empty( $argv ) ) {
- $uri = implode( ' ', $argv );
+ $uri = \implode( ' ', $argv );
}
$info .= $indent."#### URL: ".$uri.$separator;
@@ -278,7 +279,7 @@ function bit_error_string( $iDBParms = array() ) {
}
}
- $errno = (!empty( $iDBParms['errno'] ) ? 'Errno: '.$iDBParms['errno'] : '');
+ $errno = !empty( $iDBParms['errno'] ) ? 'Errno: '.$iDBParms['errno'] : '';
if( !empty( $iDBParms['db_msg'] ) ) {
$info .= $indent."#### ERROR CODE: ".$errno." Message: ".$iDBParms['db_msg'];
}
@@ -322,7 +323,7 @@ function bit_stack( $pDepth = 999 ) {
break;
}
- $args = array();
+ $args = [];
for ($i=0; $i <= $tabs; $i++) {
$indent .= '}';
}
@@ -350,7 +351,7 @@ function bit_stack( $pDepth = 999 ) {
$s .= $sClass.$arr['function'].'('.implode(', ',$args).')';
}
$s .= "\n ".$indent;
- $s .= @sprintf(" LINE: %4d, %s", $arr['line'],$arr['file']);
+ $s .= @sprintf(" LINE: %4d, %s", !empty($arr['line']) ? $arr['line'] : 'none', !empty($arr['file']) ? $arr['file'] : 'none');
$indent = '';
}
$s .= "\n";
@@ -366,9 +367,8 @@ function vvd() {
}
// var dump variable in something nicely readable in web browser
-function vd( $pVar, $pGlobals=FALSE, $pDelay=FALSE ) {
+function vd( $pVar, $pGlobals=false, $pDelay=false ) {
global $gBitSystem;
-
ob_start();
if( $pGlobals ) {
print '<h2>$pVar</h2>';
@@ -405,13 +405,13 @@ function vd( $pVar, $pGlobals=FALSE, $pDelay=FALSE ) {
function vvc() {
$ret = '';
for( $i = 0; $i < func_num_args(); $i++ ) {
- $ret .= vc( func_get_arg( $i ), FALSE );
+ $ret .= vc( func_get_arg( $i ), false );
}
return $ret;
}
// var capture variable in something nicely readable in web browser
-function vc( $iVar, $pHtml=TRUE ) {
+function vc( $iVar, $pHtml=true ) {
ob_start();
if( is_object( $iVar ) ) {
if( isset( $iVar->mDb ) ) {
@@ -427,8 +427,8 @@ function vc( $iVar, $pHtml=TRUE ) {
var_dump( $iVar );
}
} elseif( $pHtml && !empty( $_SERVER['HTTP_USER_AGENT'] ) && $_SERVER['HTTP_USER_AGENT'] != 'cron' && ((is_object( $iVar ) && !empty( $iVar )) || is_array( $iVar )) ) {
- include_once( UTIL_PKG_INCLUDE_PATH.'dBug/dBug.php' );
- new dBug( $iVar, "", FALSE );
+ include_once UTIL_PKG_INCLUDE_PATH.'dBug/dBug.php';
+ new \dBug( $iVar, "", false );
} else {
print '<pre>';
if( is_object( $iVar ) ) {
@@ -454,15 +454,15 @@ function va( $iVar ) {
}
/**
- * bitdebug display an debug output when $gDebug is set to TRUE
+ * bitdebug display an debug output when $gDebug is set to true
*
- * @param array $pMessage Message to display
+ * @param string $pMessage Message to display
* @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ * @return void
*/
-function bitdebug( $pMessage ) {
+function bitdebug( string $pMessage ): void {
global $gDebug;
if( !empty( $gDebug )) {
echo "<pre>$pMessage</pre>";
}
-}
+} \ No newline at end of file
diff --git a/includes/config_defaults_inc.php b/includes/config_defaults_inc.php
index 72f201d..b6d92d4 100644..100755
--- a/includes/config_defaults_inc.php
+++ b/includes/config_defaults_inc.php
@@ -7,11 +7,14 @@
/**
* required setup
*/
+namespace Bitweaver;
+
+require_once BIT_ROOT_PATH.'kernel/includes/autoload.php';
// include the bitweaver configuration file - this needs to happen first
$config_file = empty( $_SERVER['CONFIG_INC'] ) ? BIT_ROOT_PATH.'config/kernel/config_inc.php' : $_SERVER['CONFIG_INC'];
if( file_exists( $config_file ) ) {
- include_once( $config_file );
+ include_once $config_file;
}
// when running scripts
@@ -19,7 +22,7 @@ global $gShellScript;
if( !empty( $gShellScript ) ) {
$siteName = 'localhost';
// keep notices quiet
- $serverDefaults = array(
+ $serverDefaults = [
'DOCUMENT_ROOT' => dirname( dirname( dirname( __FILE__ ) ) ),
'HTTP_HOST' => $siteName,
'HTTP_SERVER_VARS' => '',
@@ -27,14 +30,14 @@ if( !empty( $gShellScript ) ) {
'REMOTE_ADDR' => $siteName,
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => __FILE__,
- 'REQUEST_URI' => __FILE__,
+ 'REQUEST_URL' => __FILE__,
'SCRIPT_URI' => $_SERVER['SCRIPT_FILENAME'],
'SCRIPT_URL' => $_SERVER['SCRIPT_NAME'],
'SERVER_ADDR' => $siteName,
- 'SERVER_ADMIN' => 'root@'.$siteName,
+ 'SERVER_ADMIN' => 'support@'.$siteName,
'SERVER_NAME' => '',
'SERVER_PROTOCOL' => 'http',
- );
+ ];
foreach( $serverDefaults as $key=>$value ) {
if( empty( $_SERVER[$key] ) ) {
@@ -44,17 +47,17 @@ if( !empty( $gShellScript ) ) {
// Process some global arguments
global $gArgs, $argv;
- $gArgs = array();
+ $gArgs = [];
if( $argv ) {
foreach( $argv AS $arg ) {
$argKey = $arg;
if( strpos( $arg, '--' ) === 0 ) {
$argKey = substr( $arg, 2 );
}
- $argValue = TRUE;
+ $argValue = true;
if( strpos( $arg, '=' ) ) {
$argKey = substr( $arg, 2, strpos( $arg, '=' )-2 );
- $argValue = substr( $arg, (strpos( $arg, '=' ) +1) );
+ $argValue = substr( $arg, strpos( $arg, '=' ) +1);
}
switch( $argKey ) {
case 'debug':
@@ -74,7 +77,7 @@ if( !defined( 'BIT_DB_PREFIX' ) ) {
define( 'BIT_DB_PREFIX', '' );
}
if( !defined( 'BIT_CACHE_OBJECTS' ) ) {
- define( 'BIT_CACHE_OBJECTS', TRUE );
+ define( 'BIT_CACHE_OBJECTS', false );
}
if( !defined( 'BIT_QUERY_CACHE_TIME' ) ) {
define( 'BIT_QUERY_CACHE_TIME', 86400 );
@@ -88,11 +91,11 @@ if( !defined( 'DISPLAY_ERRORS' ) ) {
}
// name of session variable in browser cookie
if( !defined( 'BIT_SESSION_NAME' ) ) {
- define( 'BIT_SESSION_NAME', 'BWSESSION' );
+ define( 'BIT_SESSION_NAME', 'BWSESSION'); // '__Secure-BWSESSION' );
}
// define where errors are sent
if( !defined( 'BIT_PHP_ERROR_REPORTING' ) ) {
- define( 'BIT_PHP_ERROR_REPORTING', E_ALL & ~E_DEPRECATED & ~E_STRICT );
+ define( 'BIT_PHP_ERROR_REPORTING', E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING );
}
// don't change / set _IDs unless you know exactly what you are doing
if( !defined( 'ROOT_USER_ID' ) ) {
@@ -108,10 +111,10 @@ if( !defined( 'EVIL_EXTENSION_PATTERN' )) {
define( 'EVIL_EXTENSION_PATTERN', "#\.(htaccess|pl|php|php3|php4|phtml|py|cgi|asp|jsp|sh|shtml)$#i" );
}
-/* Uncomment to switch to role team model ...
+// Uncomment to switch to role team model ...
if( !defined( 'ROLE_MODEL' )) {
define( 'ROLE_MODEL', true );
-} */
+}
if( !defined( 'ANONYMOUS_TEAM_ID' ) ) {
define( 'ANONYMOUS_TEAM_ID', -1 );
@@ -119,7 +122,7 @@ if( !defined( 'ANONYMOUS_TEAM_ID' ) ) {
// Uncomment the following line if you require attachment and file id's to match the content id
// This is used to simplify content mamagment where fisheye and treasury content is used internally
-//define( 'LINKED_ATTACHMENTS', true );
+define( 'LINKED_ATTACHMENTS', true );
// Empty SCRIPT_NAME and incorrect SCRIPT_NAME due to php-cgiwrap - wolff_borg
if( empty( $_SERVER['SCRIPT_NAME'] ) ) {
$_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_URL'];
@@ -133,7 +136,7 @@ if( empty( $_SERVER['SCRIPT_NAME'] ) ) {
if( !defined( 'BIT_ROOT_URL' ) ) {
// version one which seems to only cause problems seldomly
preg_match( '/.*'.basename( dirname( dirname( __FILE__ ) ) ).'\//', $_SERVER['SCRIPT_NAME'], $match );
- $subpath = ( isset($match[0] ) ) ? $match[0] : '/';
+ $subpath = !empty($match[0] ) ? $match[0] : '/';
// version two which doesn't work well on it's own
if( $subpath == "/" ) {
$subpath = dirname( dirname( $_SERVER['SCRIPT_NAME'] ) );
@@ -173,10 +176,10 @@ if( substr_count( $_SERVER['HTTP_HOST'], '.' ) >= 2 ) {
// set the currect version of bitweaver
// if this version of bitweaver needs a visit to the installer, update the number in /bit_setup_inc.php
if( !defined( 'BIT_MAJOR_VERSION' ) ) {
- define( 'BIT_MAJOR_VERSION', '4' );
+ define( 'BIT_MAJOR_VERSION', '5' );
define( 'BIT_MINOR_VERSION', '0' );
- define( 'BIT_SUB_VERSION', '0' );
- define( 'BIT_LEVEL', '' ); // dev < alpha < beta < RC# < '' < pl
+ define( 'BIT_SUB_VERSION', '0' );
+ define( 'BIT_LEVEL', 'dev' ); // dev < alpha < beta < RC# < '' < pl
}
// When updating to certain versions of bitweaver, we need to force a visit to the installer to fix certain stuff in the database.
@@ -188,8 +191,6 @@ if( !defined( 'MIN_BIT_VERSION' ) ) {
// These defines have to happen FIRST because core classes depend on them.
// This means these packages *CANNOT* be renamed
define( 'INSTALL_PKG_PATH', BIT_ROOT_PATH.'install/' );
-define( 'INSTALL_PKG_INCLUDE_PATH', INSTALL_PKG_PATH.'includes/' );
-define( 'INSTALL_PKG_CLASS_PATH', INSTALL_PKG_INCLUDE_PATH.'classes/' );
define( 'INSTALL_PKG_URL', BIT_ROOT_URL.'install/' );
define( 'KERNEL_PKG_DIR', 'kernel' );
define( 'KERNEL_PKG_NAME', 'kernel' );
@@ -223,6 +224,9 @@ if( !defined( 'STORAGE_PKG_NAME' ) ) {
if( !defined( 'STORAGE_PKG_PATH' ) ) {
define( 'STORAGE_PKG_PATH', BIT_ROOT_PATH.'storage/' );
}
+if( !defined( 'STORAGE_PKG_URL' ) ) {
+ define( 'STORAGE_PKG_URL', BIT_ROOT_URL.'storage/' );
+}
if( !defined( 'STORAGE_PKG_INCLUDE_PATH' ) ) {
define( 'STORAGE_PKG_INCLUDE_PATH', STORAGE_PKG_PATH.'includes/' );
}
@@ -250,13 +254,13 @@ define( 'UTIL_PKG_CLASS_PATH', UTIL_PKG_INCLUDE_PATH.'classes/' );
define( 'UTIL_PKG_ADMIN_PATH', UTIL_PKG_PATH.'admin/' );
if( !defined( 'EXTERNAL_LIBS_PATH' ) ) {
- define( 'EXTERNAL_LIBS_PATH', BIT_ROOT_PATH.'config/externals/' );
+ define( 'EXTERNAL_LIBS_PATH', BIT_ROOT_PATH.'externals/' );
}
if( !defined( 'TEMP_PKG_PATH' ) ) {
- define( 'TEMP_PKG_PATH', sys_get_temp_dir().'/php/'.$_SERVER['HTTP_HOST'] ).'/';
+ define( 'TEMP_PKG_PATH', sys_get_temp_dir().'/php/'.$_SERVER['HTTP_HOST'] .'/');
if( !file_exists( TEMP_PKG_PATH ) ) {
- mkdir( TEMP_PKG_PATH, 2775, TRUE );
+ mkdir( TEMP_PKG_PATH, 2775, true );
}
}
@@ -266,13 +270,18 @@ if( empty( $gBitDbHost ) ) {
$gBitDbHost = 'localhost';
}
+// If you want to go a step further with template debugging then this enables
+// smarty's debugging console. A popup with a dump of all of the vars the
+// template(s) have been passed.
+$smarty_debugging = false;
+
// $gPreScan can be used to specify the order in which packages are scanned by
// 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
global $gPreScan;
if( empty( $gPreScan ) ) {
- $gPreScan = array( 'config', 'kernel', 'storage', 'liberty', 'themes', 'users' );
+ $gPreScan = [ 'config', 'kernel', 'storage', 'liberty', 'themes', 'users' ];
}
// here we set the default thumbsizes we use in bitweaver.
@@ -280,12 +289,29 @@ if( empty( $gPreScan ) ) {
// you can override these by populating this hash in your config/kernel/config_inc.php
global $gThumbSizes;
if( empty( $gThumbSizes )) {
- $gThumbSizes = array(
- 'large' => array( 'width' => 1200, 'height' => 900 ),
- 'medium' => array( 'width' => 800, 'height' => 600 ),
- 'small' => array( 'width' => 400, 'height' => 300 ),
- 'avatar' => array( 'width' => 200, 'height' => 150 ),
- 'icon' => array( 'width' => 100, 'height' => 100 ),
- );
+ $gThumbSizes = [
+ 'large' => [ 'width' => 1200, 'height' => 900 ],
+ 'medium' => [ 'width' => 800, 'height' => 600 ],
+ 'small' => [ 'width' => 400, 'height' => 300 ],
+ 'avatar' => [ 'width' => 200, 'height' => 150 ],
+ 'icon' => [ 'width' => 100, 'height' => 100 ],
+ ];
}
-?>
+
+function kernel_autoload( $className ) {
+ $prefix = 'Bitweaver\\';
+ $base_dir = __DIR__ . '/classes/';
+
+ $len = strlen($prefix);
+ if (strncmp($prefix, $className, $len) !== 0) {
+ return;
+ }
+
+ $relative_class = substr($className, $len);
+ $file = "$base_dir$relative_class.php";
+
+ if (file_exists($file)) {
+ require $file;
+ }
+}
+
diff --git a/includes/kernel_lib.php b/includes/kernel_lib.php
deleted file mode 100644
index 5405e53..0000000
--- a/includes/kernel_lib.php
+++ /dev/null
@@ -1,891 +0,0 @@
-<?php
-/**
- * @version $Header$
- * @package kernel
- * @subpackage functions
- */
-
-/** \brief substr with a utf8 string - works only with $start and $length positive or nuls
- * This function is the same as substr but works with multibyte
- * In a multybyte sequence, the first byte of a multibyte sequence that represents a non-ASCII character is always in the range 0xC0 to 0xFD
- * and it indicates how many bytes follow for this character.
- * All further bytes in a multibyte sequence are in the range 0x80 to 0xBF.
- */
-/**
- * Check mb_substr availability
- */
-if( function_exists( 'mb_substr' )) {
- mb_internal_encoding( "UTF-8" );
-} else {
- function mb_substr( $str, $start, $len = '', $encoding = "UTF-8" ) {
- $limit = strlen( $str );
- for( $s = 0; $start > 0;--$start ) {
- if( $s >= $limit ) {
- break;
- }
-
- if( $str[$s] <= "\x7F" ) {
- ++$s;
- } else {
- ++$s; // skip length
- while( $str[$s] >= "\x80" && $str[$s] <= "\xBF" ) {
- ++$s;
- }
- }
- }
- if( $len == '' ) {
- return substr( $str, $s );
- }
- else {
- // found the real end
- for( $e = $s; $len > 0; --$len ) {
- if( $e >= $limit ) {
- break;
- }
-
- if( $str[$e] <= "\x7F" ) {
- ++$e;
- } else {
- ++$e; //skip length
- while( $str[$e] >= "\x80" && $str[$e] <= "\xBF" && $e < $limit ) {
- ++$e;
- }
- }
- }
- }
- return substr( $str, $s, $e - $s );
- }
-}
-
-if( !function_exists( 'file_get_contents' )) {
- function file_get_contents( $pFile ) {
- ob_start();
-
- $retval = @readfile( $pFile );
-
- if( false !== $retval ) { // no readfile error
- $retval = ob_get_contents();
- }
-
- ob_end_clean();
- return $retval;
- }
-}
-
-/**
- * Return system defined temporary directory.
- * In Unix, this is usually /tmp
- * In Windows, this is usually c:\windows\temp or c:\winnt\temp
- *
- * @access public
- * @return system defined temporary directory.
- */
-function get_temp_dir() {
- static $tempdir;
- if( !$tempdir ) {
- global $gTempDir;
- if( !empty( $gTempDir ) ) {
- $tempdir = $gTempDir;
- } else {
- if( !is_windows() ) {
- $tempfile = tempnam((( @ini_get( 'safe_mode' ))
- ?( $_SERVER['DOCUMENT_ROOT'] . '/temp/' )
- :( FALSE )), 'foo' );
- $tempdir = dirname( $tempfile );
- @unlink( $tempfile );
- } else {
- $tempdir = getenv( "TMP" );
- }
- }
- }
- return $tempdir;
-}
-
-/**
- * is_windows
- *
- * @access public
- * @return TRUE if we are on windows, FALSE otherwise
- */
-function is_windows() {
- static $sWindows;
- if( !isset( $sWindows )) {
- $sWindows = substr( PHP_OS, 0, 3 ) == 'WIN';
- }
- return $sWindows;
-}
-
-/**
- * Determines if file exists and is non zero
- *
- * @param string $pFile target file
- * @access public
- * @return TRUE if file exists and is non zero, FALSE on failure
- */
-function file_valid( $pFile ) {
- return file_exists( $pFile ) && filesize( $pFile );
-}
-
-/**
- * Return an integer with a signed 32 bit max value
- *
- * @param int $pInt native PHP integer, may or may not be greater than 2^32
- * @access public
- * @return number less than 32
- */
-function int32( $pInt ) {
- return (int)$pInt & 0xFFFFFFFF;
-}
-
-/**
- * Recursively create directories
- *
- * @param array $pTarget target directory
- * @param float $pPerms octal permissions
- * @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
- */
-function mkdir_p( $pTarget, $pPerms = 0755 ) {
- // clean up input
- $pTarget = str_replace( "//", "/", trim( $pTarget ));
-
- if( empty( $pTarget ) || $pTarget == ';' || $pTarget == "/" ) {
- return FALSE;
- }
-
- if( ini_get( 'safe_mode' )) {
- $pTarget = preg_replace( '/^\/tmp/', $_SERVER['DOCUMENT_ROOT'].'/temp', $pTarget );
- }
-
- if( file_exists( $pTarget ) ) {
- return is_dir( $pTarget );
- }
-
- if( !is_windows() ) {
- if( substr( $pTarget, 0, 1 ) != '/' ) {
- $pTarget = "/$pTarget";
- }
-
- if( preg_match( '#\.\.#', $pTarget )) {
- bitdebug( "mkdir_p() - We don't allow '..' in path for security reasons: $pTarget" );
- return FALSE;
- }
- }
-
- $oldu = umask( 0 );
- @mkdir( $pTarget, $pPerms, TRUE );
- umask( $oldu );
- return TRUE;
-}
-
-/**
- * check to see if particular directories are wroteable by bitweaver
- * added check for Windows - wolff_borg - see http://bugs.php.net/bug.php?id=27609
- *
- * @param array $pPath path to file or dir
- * @access public
- * @return TRUE on success, FALSE on failure
- */
-function bw_is_writeable( $pPath ) {
- if( !is_windows() ) {
- return is_writeable( $pPath );
- } else {
- $writeable = FALSE;
- if( is_dir( $pPath )) {
- $rnd = rand();
- $writeable = @fopen( $pPath."/".$rnd, "a" );
- if( $writeable ) {
- fclose( $writeable );
- unlink( $pPath."/".$rnd );
- $writeable = TRUE;
- }
- } else {
- $writeable = @fopen( $pPath,"a" );
- if( $writeable ) {
- fclose( $writeable );
- $writeable = TRUE;
- }
- }
- return $writeable;
- }
-}
-
-/**
- * clean up an array of values and remove any dangerous html - particularly useful for cleaning up $_GET and $_REQUEST.
- * Turn off urldecode when detoxifying $_GET or $_REQUEST - these two are always urldecoded done by PHP itself (check docs).
- * If you urldecode $_GET twice there might be unexpected consequences (like page One%2BTwo --(PHP)--> One+Two --(you)--> One Two).
- *
- * @param array $pParamHash array to be cleaned
- * @param boolean $pHtml set true to escape HTML code as well
- * @param boolean $pUrldecode set true to urldecode as well
- * @access public
- * @return void
- */
-function detoxify( &$pParamHash, $pHtml = FALSE, $pUrldecode = TRUE) {
- if( !empty( $pParamHash ) && is_array( $pParamHash ) ) {
- foreach( $pParamHash as $key => $value ) {
- if( isset( $value ) && is_array( $value ) ) {
- detoxify( $value, $pHtml, $pUrldecode );
- } else {
- if( $pHtml ) {
- $newValue = $pUrldecode ? urldecode( $value ) : $value;
- $pParamHash[$key] = htmlspecialchars( ( $newValue ), ENT_NOQUOTES );
- } elseif( preg_match( "/<script[^>]*>/i", urldecode( $value ?? '' ) ) ) {
- unset( $pParamHash[$key] );
- }
- }
- }
- }
-}
-
-/**
- * file_name_to_title
- *
- * @param string $pFileName
- * @access public
- * @return clean file name that can be used as title
- */
-function file_name_to_title( $pFileName ) {
- if( preg_match( '/^[A-Z]:\\\/', $pFileName ) ) {
- // MSIE shit file names if passthrough via gigaupload, etc.
- // basename will not work - see http://us3.php.net/manual/en/function.basename.php
- $tmp = preg_split("[\\\]",$pFileName);
- $defaultName = $tmp[count($tmp) - 1];
- } elseif( strpos( '.', $pFileName ) ) {
- list( $defaultName, $ext ) = explode( '.', $pFileName );
- } else {
- $defaultName = $pFileName;
- }
- return( str_replace( '_', ' ', substr( $defaultName, 0, strrpos( $defaultName, '.' ) ) ) );
-}
-
-/**
- * path_to_url
- *
- * @param string $pPath Relative path starting in the bitweaver root directory
- * @access public
- * @return a valid url based on the given path
- */
-function storage_path_to_url( $pPath ) {
- global $gBitSystem;
- return( STORAGE_HOST_URI.STORAGE_PKG_URL.str_replace( '//', '/', str_replace( '+', '%20', str_replace( '%2F', '/', urlencode( $pPath )))));
-}
-
-/**
- * simple function to include in deprecated function calls. makes the developer replace with newer code
- *
- * @param array $pReplace code that needs replacing
- * @access public
- * @return void
- */
-function deprecated( $pReplace = NULL ) {
- $trace = debug_backtrace();
- if( !empty( $trace[1]['class'] )) {
- $function = $trace[1]['class']."::".$trace[1]['function'];
- } else {
- $function = $trace[1]['function'];
- }
- $out = "Deprecated function call:\n\tfunction: $function()\n\tfile: ".$trace[1]['file']."\n\tline: ".$trace[1]['line'];
-
- if( !empty( $pReplace ) ) {
- $out .= "\n\t".str_replace( "\n", "\n\t", $pReplace );
- }
-
- if( !defined( 'IS_LIVE' ) || IS_LIVE == FALSE ) {
- vd( $out, FALSE, TRUE );
- } else {
- error_log( $out );
- }
-}
-
-/**
- * Check that function is enabled on server.
- * @access public
- * @return TRUE if function is enabled on server, FALSE otherwise
- */
-function function_enabled ( $pName ) {
- static $disabled = NULL;
-
- if( $disabled == NULL ) {
- $functions = @ini_get( 'disable_functions' );
- $functions = str_replace( ' ', '', $functions );
- $disabled = explode( ',', $functions );
- }
-
- return !( in_array( $pName, $disabled ));
-}
-
-
-function verify_hex_color( $pColor ) {
- $ret = NULL;
-
- if( preg_match('/^#[a-f0-9]{6}$/i', $pColor) ) {
- $ret = $pColor;
- } elseif( preg_match('/^[a-f0-9]{6}$/i', $pColor)) {
- //Check for a hex color string without hash 'c1c2b4'
- $ret = '#' . $pColor;
- } elseif( preg_match('/^#[a-f0-9]{3}$/i', $pColor) ) {
- $ret = $pColor;
- } elseif( preg_match('/^[a-f0-9]{3}$/i', $pColor)) {
- //Check for a hex color string without hash 'fff'
- $ret = '#' . $pColor;
- }
- return $ret;
-}
-
-
-/**
- * html encode all characters
- * taken from: http://www.bbsinc.com/iso8859.html
- *
- * @param sting $pData string that might contain an email address
- * @access public
- * @return encoded email address
- * $note email regex taken from: http://www.regular-expressions.info/regexbuddy/email.html
- */
-define( 'EMAIL_ADDRESS_REGEX', '[-a-zA-Z0-9._%+]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,24}' );
-function encode_email_addresses( $pData ) {
- $trans = array(
- // Upper case
- 'A' => '&#065;',
- 'B' => '&#066;',
- 'C' => '&#067;',
- 'D' => '&#068;',
- 'E' => '&#069;',
- 'F' => '&#070;',
- 'G' => '&#071;',
- 'H' => '&#072;',
- 'I' => '&#073;',
- 'J' => '&#074;',
- 'K' => '&#075;',
- 'L' => '&#076;',
- 'M' => '&#077;',
- 'N' => '&#078;',
- 'O' => '&#079;',
- 'P' => '&#080;',
- 'Q' => '&#081;',
- 'R' => '&#082;',
- 'S' => '&#083;',
- 'T' => '&#084;',
- 'U' => '&#085;',
- 'V' => '&#086;',
- 'W' => '&#087;',
- 'X' => '&#088;',
- 'Y' => '&#089;',
- 'Z' => '&#090;',
-
- // lower case
- 'a' => '&#097;',
- 'b' => '&#098;',
- 'c' => '&#099;',
- 'd' => '&#100;',
- 'e' => '&#101;',
- 'f' => '&#102;',
- 'g' => '&#103;',
- 'h' => '&#104;',
- 'i' => '&#105;',
- 'j' => '&#106;',
- 'k' => '&#107;',
- 'l' => '&#108;',
- 'm' => '&#109;',
- 'n' => '&#110;',
- 'o' => '&#111;',
- 'p' => '&#112;',
- 'q' => '&#113;',
- 'r' => '&#114;',
- 's' => '&#115;',
- 't' => '&#116;',
- 'u' => '&#117;',
- 'v' => '&#118;',
- 'w' => '&#119;',
- 'x' => '&#120;',
- 'y' => '&#121;',
- 'z' => '&#122;',
-
- // digits
- '0' => '&#048;',
- '1' => '&#049;',
- '2' => '&#050;',
- '3' => '&#051;',
- '4' => '&#052;',
- '5' => '&#053;',
- '6' => '&#054;',
- '7' => '&#055;',
- '8' => '&#056;',
- '9' => '&#057;',
-
- // special chars
- '_' => '&#095;',
- '-' => '&#045;',
- '.' => '&#046;',
- '@' => '&#064;',
-
- //'[' => '&#091;',
- //']' => '&#093;',
- //'|' => '&#124;',
- //'{' => '&#123;',
- //'}' => '&#125;',
- //'~' => '&#126;',
- );
- preg_match_all( "!\b".EMAIL_ADDRESS_REGEX."\b!", $pData, $addresses );
- foreach( $addresses[0] as $address ) {
- $encoded = strtr( $address, $trans );
- $pData = preg_replace( "/\b".preg_quote( $address )."\b/", $encoded, $pData );
- }
-
- return $pData;
-}
-
-/**
- * validate email syntax
- * php include as a string
- *
- * @param $pEmail the file to include
- * @return a string with the results of the file
- **/
-function validate_email_syntax( $pEmail ) {
- return( preg_match( "!^".EMAIL_ADDRESS_REGEX."$!", trim( $pEmail )));
-}
-
-/**
- * get_include_contents -- handy function for getting the contents of a
- * php include as a string
- *
- * @param $pFile the file to include
- * @return a string with the results of the file
- **/
-function get_include_contents($pFile) {
- if( is_file( $pFile )) {
- ob_start();
- global $gContent, $gBitSystem, $gBitSmarty, $gLibertySystem, $gBitUser;
- include $pFile;
- $contents = ob_get_contents();
- ob_end_clean();
- return $contents;
- }
- return FALSE;
-}
-
-/**
- * Translate a string
- *
- * @param string $pString String that needs to be translated
- * @access public
- * @return void
- */
-function tra( $pString ) {
- global $gBitLanguage;
- return( $gBitLanguage->translate( $pString ) );
-}
-
-/**
- * recursively remove files and directories
- *
- * @param string $pPath directory we want to remove
- * @param boolean $pFollowLinks follow symlinks or not
- * @access public
- * @return TRUE on success, FALSE on failure
- */
-function unlink_r( $pPath, $pFollowLinks = FALSE ) {
- if( !empty( $pPath ) && is_dir( $pPath ) ) {
- if( $dir = opendir( $pPath ) ) {
- while( FALSE !== ( $entry = readdir( $dir ) ) ) {
- if( is_file( "$pPath/$entry" ) || ( !$pFollowLinks && is_link( "$pPath/$entry" ) ) ) {
- @unlink( "$pPath/$entry" );
- } elseif( is_dir( "$pPath/$entry" ) && $entry != '.' && $entry != '..' ) {
- unlink_r( "$pPath/$entry" ) ;
- }
- }
- closedir( $dir ) ;
- }
- return @rmdir( $pPath );
- }
-}
-
-/**
- * recursively copy the contents of a directory to a new location akin to copy -r
- *
- * @param array $pSource source directory
- * @param array $pTarget target directory
- * @access public
- * @return void
- */
-function copy_r( $pSource, $pTarget ) {
- if( is_dir( $pSource )) {
- @mkdir_p( $pTarget );
- $d = dir( $pSource );
-
- while( FALSE !== ( $entry = $d->read() )) {
- if( $entry == '.' || $entry == '..' ) {
- continue;
- }
-
- $source = $pSource.'/'.$entry;
- if( is_dir( $source )) {
- copy_r( $source, $pTarget.'/'.$entry );
- continue;
- }
- copy( $source, $pTarget.'/'.$entry );
- }
-
- $d->close();
- } else {
- copy( $pSource, $pTarget );
- }
-}
-
-/**
- * Fetch the contents of a file on a remote host
- *
- * @param string $pUrl url to file to fetch
- * @param boolean $pNoCurl skip the use of curl if this causes problems
- * @access public
- * @return FALSE on failure, contents of file on success
- */
-function bit_http_request( $pUrl, $pNoCurl = FALSE ) {
- global $gBitSystem;
- $ret = FALSE;
-
- if( !empty( $pUrl )) {
- $pUrl = trim( $pUrl );
-
- // rewrite url if sloppy # added a case for https urls
- if( !preg_match( "!^https?://!", $pUrl )) {
- $pUrl = "http://".$pUrl;
- }
-
- if( !preg_match("/^[-_a-zA-Z0-9:\/\.\?&;%=\+]*$/", $pUrl )) {
- return FALSE;
- }
-
- // try using curl first as it allows the use of a proxy
- if( !$pNoCurl && function_exists( 'curl_init' )) {
- $curl = curl_init();
- curl_setopt( $curl, CURLOPT_URL, $pUrl );
- curl_setopt( $curl, CURLOPT_HEADER, 0 );
- curl_setopt( $curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
- curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 1 );
- curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt( $curl, CURLOPT_TIMEOUT, 5 );
-
- // Proxy settings
- if( $gBitSystem->isFeatureActive( 'site_use_proxy' )) {
- curl_setopt( $curl, CURLOPT_PROXY, $gBitSystem->getConfig( 'site_proxy_host' ));
- curl_setopt( $curl, CURLOPT_PROXYPORT, $gBitSystem->getConfig( 'site_proxy_port' ));
- curl_setopt( $curl, CURLOPT_HTTPPROXYTUNNEL, 1);
- }
-
- $ret = curl_exec( $curl );
- curl_close( $curl );
- } else {
- // try using fsock now
- $parsed = parse_url( $pUrl );
- if( $fsock = @fsockopen( $parsed['host'], 80, $error['number'], $error['string'], 5 )) {
- @fwrite( $fsock, "GET ".$parsed['path'].( !empty( $parsed['query'] ) ? '?'.$parsed['query'] : '' )." HTTP/1.1\r\n" );
- @fwrite( $fsock, "HOST: {$parsed['host']}\r\n" );
- @fwrite( $fsock, "Connection: close\r\n\r\n" );
-
- $get_info = FALSE;
- while( !@feof( $fsock )) {
- if( $get_info ) {
- $ret .= @fread( $fsock, 1024 );
- } else {
- if( @fgets( $fsock, 1024 ) == "\r\n" ) {
- $get_info = TRUE;
- }
- }
- }
- @fclose( $fsock );
- if( !empty( $error['string'] )) {
- return FALSE;
- }
- }
- }
- }
-
- return $ret;
-}
-
-/**
- * Parse XML Attributes and return an array
- *
- * this function has a whopper of a RegEx.
- * I nabbed it from http://www.phpbuilder.com/annotate/message.php3?id=1000234 - XOXO spiderr
- *
- * @param array $pString XML type string of parameters
- * @access public
- * @return TRUE on success, FALSE on failure
- */
-function parse_xml_attributes( $pString ) {
- //$parameters = array( '', '' );
- $parameters = array();
- $regexp_str = "/([A-Za-z0-9_-]+)(?:\\s*=\\s*(?:(\"|\')((?:[\\\\].|[^\\\\]?)*?)(?:\\2)|([^=\\s]*)))?/";
- preg_match_all( $regexp_str, $pString, $matches, PREG_SET_ORDER );
- foreach( $matches as $key => $match ) {
- $attrib = $match[1];
- $value = $match[sizeof( $match )-1]; // The value can be at different indexes because of optional quotes, but we know it's always at the end.
- $value = preg_replace( "/\\\\(.)/","\\1",$value );
- $parameters[$attrib] = trim( $value, '\"' );
- }
- return $parameters;
-}
-
-/**
- * XML Entity Mandatory Escape Characters
- *
- * @param array $string
- * @param array $quote_style
- * @access public
- * @return TRUE on success, FALSE on failure
- */
-function xmlentities( $string, $quote_style=ENT_QUOTES ) {
- static $trans;
- if( !isset( $trans )) {
- $trans = get_html_translation_table( HTML_ENTITIES, $quote_style );
- foreach( $trans as $key => $value ) {
- $trans[$key] = '&#'.ord( $key ).';';
- }
-
- // dont translate the '&' in case it is part of &xxx;
- $trans[chr(38)] = '&';
- }
-
- // after the initial translation, _do_ map standalone '&' into '&#38;'
- return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/","&#38;" , strtr( $string, $trans ));
-}
-
-/**
- * Redirect to another page or site
- * @param string The url to redirect to
- */
-function bit_redirect( $pUrl, $pStatusCode=HttpStatusCodes::HTTP_FOUND ) {
- // Handle non-3xx codes separately
- if( $pStatusCode && isset( $errors[$pStatusCode] ) ) {
- header( HttpStatusCodes::httpHeaderFor( $pStatusCode ) );
- $pStatusCode = NULL;
- }
-
- global $gBitSystem;
- $gBitSystem->outputHeader();
-
- // clean up URL before executing it
- while( strstr( $pUrl, '&&' ) ) {
- $pUrl = str_replace( '&&', '&', $pUrl );
- }
-
- while( strstr( $pUrl, '&amp;&amp;' ) ) {
- $pUrl = str_replace( '&amp;&amp;', '&amp;', $pUrl );
- }
-
- // header locates should not have the &amp; in the address it breaks things
- while( strstr( $pUrl, '&amp;' ) ) {
- $pUrl = str_replace( '&amp;', '&', $pUrl );
- }
-
- if( $pStatusCode ) {
- header( 'Location: ' . $pUrl, TRUE, $pStatusCode );
- } else {
- header( 'Location: ' . $pUrl );
- }
- session_write_close();
- exit();
-}
-
-/**
- * array_diff_keys
- *
- * @access public
- */
-function array_diff_keys() {
- $args = func_get_args();
-
- $res = $args[0];
- if( !is_array( $res )) {
- return array();
- }
-
- for( $i = 1; $i < count( $args ); $i++ ) {
- if( !is_array( $args[$i] )) {
- continue;
- }
- foreach( $args[$i] as $key => $data ) {
- unset( $res[$key] );
- }
- }
- return $res;
-}
-
-/**
- * trim_array
- *
- * @param array $pArray
- * @access public
- */
-function trim_array( &$pArray ) {
- if( is_array( $pArray ) ) {
- foreach( array_keys( $pArray ) as $key ) {
- if( is_string( $pArray[$key] ) ) {
- $pArray[$key] = trim( $pArray[$key] );
- }
- }
- }
-}
-
-
-/**
- * ordinalize
- *
- * @param numeric $num Number to append th, st, nd, rd to - only makes sense when languages is english
- * @access public
- */
-function ordinalize( $num ) {
- $ord = '';
- if( is_numeric( $num ) ) {
- if( $num >= 11 and $num <= 19 ) {
- $ord = tra( "th" );
- } elseif( $num % 10 == 1 ) {
- $ord = tra( "st" );
- } elseif( $num % 10 == 2 ) {
- $ord = tra( "nd" );
- } elseif( $num % 10 == 3 ) {
- $ord = tra( "rd" );
- } else {
- $ord = tra( "th" );
- }
- }
-
- return $num.$ord;
-}
-
-/**
- * Cleans file path according to system we're on
- *
- * @param array $pPath
- * @access public
- * @return TRUE on success, FALSE on failure
- */
-function clean_file_path( $pPath ) {
- $pPath = (!empty($_SERVER["SERVER_SOFTWARE"]) && strpos($_SERVER["SERVER_SOFTWARE"],"IIS") ? str_replace( '\/', '\\', $pPath) : $pPath);
- return $pPath;
-}
-
-function httpScheme() {
- return 'http'.( ( isset($_SERVER['HTTPS'] ) && ( $_SERVER['HTTPS'] == 'on' ) ) ? 's' : '' );
-}
-
-function httpPrefix() {
- return httpScheme().'://'.$_SERVER['HTTP_HOST'];
-}
-
-/**
-* If an unrecoverable error has occurred, this method should be invoked. script exist occurs
-*
-* @param string $ pMsg error message to be displayed
-* @return none this function will DIE DIE DIE!!!
-* @access public
-*/
-function install_error( $pMsg = null ) {
- global $gBitDbType;
- // here we decide where to go. if there are no db settings yet, we go the welcome page.
- if( isset( $gBitDbType )) {
- $step = 1;
- } else {
- $step = 0;
- }
-
- header( "Location: ".httpPrefix().BIT_ROOT_URL."install/install.php?step=".$step );
- die;
-}
-
-/**
- * pear_check will check to see if a given PEAR module is installed
- *
- * @param string $pPearModule The name of the module in the format: Image/GraphViz.php
- * @access public
- * @return string with error message on failure, NULL on success
- */
-function pear_check( $pPearModule = NULL ) {
- if( !@include_once( "PEAR.php" )) {
- return tra( "PEAR is not installed." );
- } elseif( !empty( $pPearModule ) && !@include_once( $pPearModule )) {
- $module = str_replace( ".php", "", str_replace( "/", "_", $pPearModule ));
- return tra( "The PEAR plugin <strong>$module</strong> is not installed. Install it with '<strong>pear install $module</strong>' or use your distribution's package manager.");
- } else {
- return NULL;
- }
-}
-
-/**
- * A set of compare functions that can be used in conjunction with usort() type functions
- *
- * @param array $ar1
- * @param array $ar2
- * @access public
- * @return TRUE on success, FALSE on failure
- */
-function usort_by_title( $ar1, $ar2 ) {
- if( !empty( $ar1['title'] ) && !empty( $ar2['title'] ) ) {
- return strcasecmp( $ar1['title'], $ar2['title'] );
- } else {
- return 0;
- }
-}
-
-function compare_links( $ar1, $ar2 ) {
- return $ar1["links"] - $ar2["links"];
-}
-
-function compare_backlinks( $ar1, $ar2 ) {
- return $ar1["backlinks"] - $ar2["backlinks"];
-}
-
-function r_compare_links( $ar1, $ar2 ) {
- return $ar2["links"] - $ar1["links"];
-}
-
-function r_compare_backlinks( $ar1, $ar2 ) {
- return $ar2["backlinks"] - $ar1["backlinks"];
-}
-
-function compare_images( $ar1, $ar2 ) {
- return $ar1["images"] - $ar2["images"];
-}
-
-function r_compare_images( $ar1, $ar2 ) {
- return $ar2["images"] - $ar1["images"];
-}
-
-function compare_files( $ar1, $ar2 ) {
- return $ar1["files"] - $ar2["files"];
-}
-
-function r_compare_files( $ar1, $ar2 ) {
- return $ar2["files"] - $ar1["files"];
-}
-
-function compare_versions( $ar1, $ar2 ) {
- return $ar1["versions"] - $ar2["versions"];
-}
-
-function r_compare_versions( $ar1, $ar2 ) {
- return $ar2["versions"] - $ar1["versions"];
-}
-
-function compare_changed( $ar1, $ar2 ) {
- return $ar1["lastChanged"] - $ar2["lastChanged"];
-}
-
-function r_compare_changed( $ar1, $ar2 ) {
- return $ar2["lastChanged"] - $ar1["lastChanged"];
-}
-
-
-// ======================= deprecated functions =======================
-/**
- * @deprecated deprecated since version 2.1.0-beta
- */
-function chkgd2() {
- deprecated( 'Please use get_gd_version() instead' );
-}
-
-?>
diff --git a/includes/module_controls_inc.php b/includes/module_controls_inc.php
index 6815bf7..8604674 100644..100755
--- a/includes/module_controls_inc.php
+++ b/includes/module_controls_inc.php
@@ -16,21 +16,21 @@
/**
* Initialization
*/
-include_once( '../kernel/includes/setup_inc.php' );
+include_once '../kernel/includes/setup_inc.php';
if (!$gBitUser->hasPermission( 'p_tidbits_configure_modules' )) {
$gBitSmarty->assign('msg', tra("You dont have permission to use this feature"));
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
die;
}
/*if (!$gBitSystem->isFeatureActive( 'site_user_assigned_modules' ) && $check_req) {
$gBitSmarty->assign('msg', tra("This feature is disabled").": site_user_assigned_modules");
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
die;
}*/
if (!$gBitUser->isRegistered()) {
$gBitSmarty->assign('msg', tra("You must log in to use this feature"));
- $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
die;
}
@@ -69,8 +69,7 @@ if( isset( $_REQUEST['fMove'] ) && isset( $_REQUEST['fPackage'] ) && isset( $_
// Remove module movemet paramaters from an URL
// \todo What if 'mc_xxx' arg was not at the end? (if smbd fix URL by hands...)
// should I handle this very special (hack?) case?
-// $url = preg_replace('/(.*)(\?|&){1}(mc_up|mc_down|mc_move|mc_unassign)=[^&]*/','\1', $url);
+// $url = preg_replace('/(.*)(\?|&)[1](mc_up|mc_down|mc_move|mc_unassign)=[^&]*/','\1', $url);
// Fix locaton if parameter was removed...
-header('Location: '.$url);
-?>
+header('Location: '.$url); \ No newline at end of file
diff --git a/includes/notification_lib.php b/includes/notification_lib.php
index 4e8afd9..8b43a38 100644..100755
--- a/includes/notification_lib.php
+++ b/includes/notification_lib.php
@@ -14,6 +14,8 @@
* 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
*/
+namespace Bitweaver;
+use Bitweaver\KernelTools;
/**
* A library use to store email addresses registered for specific notification events.
@@ -28,74 +30,79 @@ class NotificationLib extends BitBase
{
/**
* Lists registered notification events
- * @param offset the location to begin listing from
- * @param max_records the maximum number of records returned
- * @param sort_mode the method of sorting used in the listing
- * @param find text used to filter listing
+ * @param string $offset the location to begin listing from
+ * @param int $max_records the maximum number of records returned
+ * @param string $sort_mode the method of sorting used in the listing
+ * @param string $find text used to filter listing
* @return array of registered notification events
*/
- function list_mail_events($offset, $max_records, $sort_mode, $find)
+ public function list_mail_events( string $offset, int $max_records, string $sort_mode, string $find): array
{
if ($find)
{
$findesc = '%' . strtoupper( $find ) . '%';
$mid = " where (UPPER(`event`) like ? or UPPER(`email`) like ?)";
- $bindvars=array($findesc,$findesc);
+ $bindvars=[$findesc,$findesc];
}
else
{
$mid = " ";
- $bindvars=array();
+ $bindvars=[];
}
$query = "select * from `".BIT_DB_PREFIX."mail_notifications` $mid order by ".$this->mDb->convertSortmode($sort_mode);
$query_cant = "select count(*) from `".BIT_DB_PREFIX."mail_notifications` $mid";
$result = $this->mDb->query($query,$bindvars,$max_records,$offset);
$cant = $this->mDb->getOne($query_cant,$bindvars);
- $ret = array();
+ $ret = [];
while ($res = $result->fetchRow())
{
$ret[] = $res;
}
- $retval = array();
+ $retval = [];
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
/**
* Adds an email address for a specified event notification
- * @param event the specified event
- * @param object the specified object
- * @param email the email to remove
- * @return array of the notification record
+ * @param string
+ * @param array
+ * @var string event the specified event
+ * @var string object the specified object
+ * @var string email the email to remove
+ * @param string
+ * @return void
*/
- function add_mail_event($event, $object, $email)
+ public function add_mail_event($event, $object, $email)
{
$query = "insert into `".BIT_DB_PREFIX."mail_notifications`(`event`,`object`,`email`) values(?,?,?)";
- $result = $this->mDb->query($query, array($event,$object,$email) );
+ $this->mDb->query( $query, [ 'event', $object, $email ] );
}
+
/**
* Removes an email address for a specified event notification
- * @param event the specified event
- * @param object the specified object
- * @param email the email to remove
+ * @param string $event the specified event
+ * @param string $object the specified object
+ * @param string $email the email to remove
+ * @return void
*/
- function remove_mail_event($event, $object, $email)
+ public function remove_mail_event(string $event, string $object, string $email): void
{
$query = "delete from `".BIT_DB_PREFIX."mail_notifications` where `event`=? and `object`=? and `email`=?";
- $result = $this->mDb->query($query,array($event,$object,$email));
+ $this->mDb->query($query, [$event,$object,$email] );
}
/**
* Retrieves the email addresses for a specific event
- * @param event the specified event
- * @param object the specified object
+ * @param string $event event the specified event
+ * @param string $object the specified object
* @return array of email addresses
*/
- function get_mail_events($event, $object)
+ public function get_mail_events( string $event, string $object): array
{
$query = "select `email` from `".BIT_DB_PREFIX."mail_notifications` where `event`=? and (`object`=? or `object`='*')";
- $result = $this->mDb->query($query, array($event,$object) );
- $ret = array();
+ $result = $this->mDb->query($query, [ $event, $object ] );
+ $ret = [];
while ($res = $result->fetchRow())
{
$ret[] = $res["email"];
@@ -105,18 +112,18 @@ class NotificationLib extends BitBase
/**
* Post changes to registered email addresses related to a change event
- * @param object number of the content item being updated
- * @param object content_type of the item
- * @param object the package that is being updated
- * @param object the name of the object
- * @param object the name of user making the change
- * @param object any comment added to the change
- * @param object the content of the change
+ * @param int $contentid number of the content item being updated
+ * @param string $type content_type of the item
+ * @param string $package the package that is being updated
+ * @param string $name the name of the object
+ * @param string $user the name of user making the change
+ * @param string $comment any comment added to the change
+ * @param string $data the content of the change
*
* @todo Improve the generic handling of the messages
* Param information probably needs to be passed as an array, or accessed from Content directly
*/
- function post_content_event($contentid, $type, $package, $name, $user, $comment, $data)
+ public function post_content_event( int $contentid, string $type, string $package, string $name, string $user, string $comment, string $data): void
{ global $gBitSystem;
$emails = $this->get_mail_events($package.'_page_changes', $type . $contentid);
@@ -130,19 +137,19 @@ class NotificationLib extends BitBase
$gBitSmarty->assign('mail_comment', $comment );
$gBitSmarty->assign('mail_last_version', 1);
$gBitSmarty->assign('mail_data', $data );
- $gBitSmarty->assign('mail_machine', httpPrefix());
+ $gBitSmarty->assign('mail_machine', KernelTools::httpPrefix());
$gBitSmarty->assign('mail_pagedata', $data );
$mail_data = $gBitSmarty->fetch('bitpackage:'.$package.'/'.$package.'_change_notification.tpl');
- @mail($email, $package . tra(' page'). ' ' . $name . ' ' . tra('changed'), $mail_data, "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n" );
+ @mail($email, $package . KernelTools::tra(' page'). ' ' . $name . ' ' . KernelTools::tra('changed'), $mail_data, "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n" );
}
}
/**
* Notifies registered list of eMail recipients of new user registrations
- * @param object name of the new user
+ * @param string name of the new user
*/
- function post_new_user_event( $user )
+ public function post_new_user_event( string $user ): void
{ global $gBitSystem, $gBitSmarty;
$emails = $this->get_mail_events('user_registers','*');
foreach($emails as $email) {
@@ -151,7 +158,7 @@ class NotificationLib extends BitBase
$gBitSmarty->assign('mail_site',$_SERVER["SERVER_NAME"]);
$mail_data = $gBitSmarty->fetch('bitpackage:users/new_user_notification.tpl');
- mail( $email, tra('New user registration'),$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n");
+ mail( $email, KernelTools::tra('New user registration'),$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n");
}
}
@@ -161,5 +168,4 @@ class NotificationLib extends BitBase
* @global NotificationLib Notification library
*/
global $notificationlib;
-$notificationlib = new NotificationLib();
-?>
+$notificationlib = new NotificationLib(); \ No newline at end of file
diff --git a/includes/setup_inc.php b/includes/setup_inc.php
index bcf6ae5..b34ab8e 100644..100755
--- a/includes/setup_inc.php
+++ b/includes/setup_inc.php
@@ -11,22 +11,24 @@
/**
* required setup
*/
+namespace Bitweaver;
+use Bitweaver\Plugins\ResourceBitpackage;
+use Bitweaver\Languages\BitLanguage;
$rootDir = dirname( dirname( dirname( __FILE__ ) ) );
-define( 'BIT_ROOT_PATH', empty( $_SERVER['VHOST_DIR'] ) ? $rootDir.'/' : $_SERVER['VHOST_DIR'].'/' );
+define( 'BIT_ROOT_PATH', empty( $_SERVER['DOCUMENT_ROOT'] ) ? $rootDir.'/' : $_SERVER['DOCUMENT_ROOT'].'/' );
// immediately die on request to hack our database
-if(( !empty( $_REQUEST['sort_mode'] ) && !is_array( $_REQUEST['sort_mode'] ) && strpos( $_REQUEST['sort_mode'], 'http' ) !== FALSE ) || ( !empty( $_REQUEST['PGV_BASE_DIRECTORY'] ) && strpos( $_REQUEST['PGV_BASE_DIRECTORY'], 'http' ) !== FALSE )) {
+if(( !empty( $_REQUEST['sort_mode'] ) && !is_array( $_REQUEST['sort_mode'] ) && strpos( $_REQUEST['sort_mode'], 'http' ) !== false ) || ( !empty( $_REQUEST['PGV_BASE_DIRECTORY'] ) && strpos( $_REQUEST['PGV_BASE_DIRECTORY'], 'http' ) !== false )) {
die;
}
-require_once( BIT_ROOT_PATH.'kernel/includes/config_defaults_inc.php' );
-require_once( KERNEL_PKG_INCLUDE_PATH.'bit_error_inc.php' );
-require_once( KERNEL_PKG_INCLUDE_PATH.'kernel_lib.php' );
-require_once( KERNEL_PKG_CLASS_PATH.'BitTimer.php' );
+require_once BIT_ROOT_PATH.'kernel/includes/config_defaults_inc.php';
+require_once KERNEL_PKG_INCLUDE_PATH.'bit_error_inc.php';
+use Bitweaver\KernelTools;
// set error reporting
-error_reporting( BIT_PHP_ERROR_REPORTING );
+error_reporting( E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING ); // BIT_PHP_ERROR_REPORTING ); //
if( ini_get( 'safe_mode' ) && ini_get( 'safe_mode_gid' )) {
umask( 0007 );
@@ -34,47 +36,33 @@ if( ini_get( 'safe_mode' ) && ini_get( 'safe_mode_gid' )) {
// clean up $_GET and make sure others are clean as well
if( !empty( $_GET ) && is_array( $_GET ) && empty( $gNoToxify ) ) {
- detoxify( $_GET, TRUE, FALSE );
+ KernelTools::detoxify( $_GET, true, false );
$_REQUEST = array_merge( $_REQUEST, $_GET );
}
-// Force a global ADODB db object so all classes share the same connection
-$dbClass = 'BitDbAdodb';
-if( !empty( $gBitSystem ) ) {
- switch( $gBitDbSystem ) {
- case 'pear':
- $dbClass = 'BitDbPear';
- break;
- default:
- $dbClass = 'BitDbAdodb';
- break;
- }
-}
-// the installer and select admin pages required DataDict to verify package installation
-global $gForceAdodb;
-if( !empty( $gForceAdodb )) {
- $dbClass = 'BitDbAdodb';
-}
-require_once( KERNEL_PKG_CLASS_PATH.$dbClass.'.php' );
-
// =================== Global Classes ===================
global $gBitDb;
-$gBitDb = new $dbClass();
+$gBitDb = new BitDbAdodb();
if( defined( 'QUERY_CACHE_ACTIVE' ) ) {
$gBitDb->setCaching();
}
-require_once( KERNEL_PKG_CLASS_PATH.'BitSystem.php' );
global $gBitSmarty, $gBitSystem;
// Per http://stackoverflow.com/a/14101767/268416 try to force gBitSystem to be among the last object to be destroyed, see BitSystem::__destruct() for details
-set_error_handler(function() use($gBitSystem) {});
+set_error_handler('\Bitweaver\bit_error_handler');
// make sure we only create one BitSmarty
if( !is_object( $gBitSmarty ) ) {
- $gBitSmarty = new BitSmarty();
+ $gBitSmarty = new Themes\BitSmarty();
+ // Load Bitweaver Plugins
+ $gBitSmarty->addExtension(new Themes\BitweaverExtension() );
// set the default handler
- $gBitSmarty->loadFilter( 'pre', 'tr' );
- // $gBitSmarty->loadFilter('output','trimwhitespace');
+ $gBitSmarty->addDefaultModifiers( [ 'add_link_ticket', 'tr' ] );
+ $gBitSmarty->registerResource( 'bitpackage', new ResourceBitpackage() );
+
+ if( isset( $_REQUEST['highlight'] ) ) {
+// $gBitSmarty->addDefaultModifiers( 'highlight' );
+ }
}
BitSystem::loadSingleton();
@@ -83,29 +71,27 @@ BitSystem::loadSingleton();
// we need to know about this before any other package is loaded to ensure that we can exclude stuff that isn't backwards compatible.
// BIT_INSTALL is set by the installer and LOGIN_VALIDATE is set in users/validate.php
if( !empty( $gBitSystem->mConfig ) && version_compare( MIN_BIT_VERSION, $gBitSystem->getVersion(), '>' ) && !( defined( 'BIT_INSTALL' ) || defined( 'LOGIN_VALIDATE' ))) {
- define( 'INSTALLER_FORCE', TRUE );
+ define( 'INSTALLER_FORCE', true );
}
BitSystem::prependIncludePath( UTIL_PKG_INCLUDE_PATH );
-BitSystem::prependIncludePath( EXTERNAL_LIBS_PATH.'pear/' );
+BitSystem::prependIncludePath( UTIL_PKG_INCLUDE_PATH.'pear/' );
-require_once( LANGUAGES_PKG_CLASS_PATH.'BitLanguage.php' );
BitLanguage::loadSingleton();
// collects information about the browser - needed for various browser specific theme settings
-require_once( UTIL_PKG_INCLUDE_PATH.'phpsniff/phpSniff.class.php' );
+require_once UTIL_PKG_INCLUDE_PATH.'phpsniff/phpSniff.class.php';
global $gSniffer;
-$gSniffer = new phpSniff;
+$gSniffer = new \phpSniff;
if( file_exists( ini_get( 'browscap' ) ) ) {
$browserInfo = array_merge( $gSniffer->_browser_info, get_browser( null, true ) );
- $gBitSmarty->assignByRef( 'gBrowserInfo', $browserInfo );
+ $gBitSmarty->assign( 'gBrowserInfo', $browserInfo );
} else {
- $gBitSmarty->assignByRef( 'gBrowserInfo', $gSniffer->_browser_info );
+ $gBitSmarty->assign( 'gBrowserInfo', $gSniffer->_browser_info );
}
// set various classes global
global $gBitUser, $gTicket, $userlib, $gBitDbType, $gLibertySystem;
-
if( $gBitSystem->isDatabaseValid() ) {
// output compression
@@ -126,7 +112,7 @@ if( $gBitSystem->isDatabaseValid() ) {
$root_url_count = strlen( BIT_ROOT_URL );
$root_path_count = strlen( BIT_ROOT_PATH );
$path_end = $root_path_count - $root_url_count;
- define( 'BIT_BASE_PATH', ( BIT_ROOT_URL == "/" ? BIT_ROOT_PATH : substr( BIT_ROOT_PATH, 0, $path_end ) . "/" ) );
+ define( 'BIT_BASE_PATH', BIT_ROOT_URL == "/" ? BIT_ROOT_PATH : substr( BIT_ROOT_PATH, 0, $path_end ) . "/" );
}
// Force full URI's for offline or exported content (newsletters, etc.)
@@ -136,25 +122,25 @@ if( $gBitSystem->isDatabaseValid() ) {
}
define( 'UTIL_PKG_URL', $root.'util/' );
define( 'LIBERTY_PKG_URL', $root.'liberty/' );
-
+
// load only installed and active packages
- $gBitSystem->scanPackages( 'includes/bit_setup_inc.php', TRUE, 'active', TRUE, TRUE );
+ $gBitSystem->scanPackages( 'bit_setup_inc.php', true, 'active', true, true );
$gBitSmarty->scanPackagePluginDirs();
-
+
if( file_exists( CONFIG_PKG_INCLUDE_PATH.'kernel/override_inc.php' ) ) {
// possible install specific customizations for multi-sites, staging sites, etc.
- require_once( CONFIG_PKG_PATH.'kernel/override_inc.php' );
+ require_once CONFIG_PKG_PATH.'kernel/override_inc.php';
}
// some plugins check for active packages, so we do this *after* package scanning
- $gBitSmarty->assignByRef( 'gBitSystem', $gBitSystem );
-
+ $gBitSmarty->assign( 'gBitSystem', $gBitSystem );
+
// some liberty plugins might need to run some functions.
// it's necessary that we call them early on after scanPackages() has been completed.
foreach( $gLibertySystem->getPluginFunctions( 'preload_function' ) as $func ) {
$func();
}
-
+
// TODO: XSS security check
if( !empty( $_REQUEST['tk'] ) && empty( $_SERVER['bot'] ) ) {
//$gBitUser->verifyTicket();
@@ -162,7 +148,7 @@ if( $gBitSystem->isDatabaseValid() ) {
}
// this will register and set up the dropdown menus and the application menus in modules
- require_once( THEMES_PKG_INCLUDE_PATH.'menu_register_inc.php' );
+ require_once THEMES_PKG_INCLUDE_PATH.'menu_register_inc.php';
// added for virtual hosting suport
if( !isset( $bitdomain )) {
@@ -184,12 +170,12 @@ if( $gBitSystem->isDatabaseValid() ) {
$_REQUEST['page'] = strip_tags( $_REQUEST['page'] );
}
global $gHideModules;
- $gBitSmarty->assignByRef( 'gHideModules', $gHideModules );
+ $gBitSmarty->assign( 'gHideModules', $gHideModules );
$keywords = $gBitSystem->getConfig( 'site_keywords' );
- $gBitSmarty->assignByRef( 'metaKeywords', $keywords );
+ $gBitSmarty->assign( 'metaKeywords', $keywords );
// =================== Kernel ===================
- //$gBitSmarty->assignByRef( "gBitSystemPackages", $gBitSystem->mPackages ); doesn't seem to be used - xing
+ //$gBitSmarty->assign( "gBitSystemPackages", $gBitSystem->mPackages ); doesn't seem to be used - xing
// check to see if admin has closed the site
if(( isset( $_SERVER['SCRIPT_URL'] ) && $_SERVER['SCRIPT_URL'] == USERS_PKG_URL.'validate.php' )) {
@@ -197,7 +183,7 @@ if( $gBitSystem->isDatabaseValid() ) {
}
if( empty($gShellScript) && $gBitSystem->isFeatureActive( 'site_closed' ) && !$gBitUser->hasPermission( 'p_access_closed_site' ) && !isset( $bypass_siteclose_check )) {
$_REQUEST['error'] = $gBitSystem->getConfig('site_closed_msg','&nbsp;');
- include( KERNEL_PKG_PATH . 'error_simple.php' );
+ include KERNEL_PKG_PATH . 'error_simple.php';
exit;
}
@@ -211,7 +197,7 @@ if( $gBitSystem->isDatabaseValid() ) {
$site_load_threshold = $gBitSystem->getConfig('site_load_threshold', 3);
if ($server_load > $site_load_threshold) {
$_REQUEST['error'] = $gBitSystem->getConfig('site_busy_msg', 'Server is currently too busy; please come back later.');
- include( KERNEL_PKG_PATH . 'error_simple.php' );
+ include KERNEL_PKG_PATH . 'error_simple.php';
exit;
}
}
@@ -219,7 +205,7 @@ if( $gBitSystem->isDatabaseValid() ) {
// if we are interactively translating the website, we force template caching on every page load.
if( $gBitSystem->isFeatureActive( 'i18n_interactive_translation' ) && $gBitUser->hasPermission( 'p_languages_edit' ) ) {
- $gBitSmarty->assignByRef( "gBitTranslationHash", $gBitTranslationHash );
+ $gBitSmarty->assign( "gBitTranslationHash", $gBitTranslationHash );
} else {
// this has to be done since the permission can't be checked in BitLanguage::translate() as it's called too soon by prefilter.tr
$gBitSystem->setConfig( 'i18n_interactive_translation', 'n' );
@@ -241,7 +227,7 @@ if( $gBitSystem->isDatabaseValid() ) {
if( defined( 'SECURE_BIT_BASE_URI' ) ) {
define( 'SECURE_BIT_BASE_URI', 'https://'.$host.($site_https_port!=443?$site_https_port:'') );
}
-
+
// we need this for backwards compatibility - use $gBitSystem->getPrerference( 'max_records' ) if you need it, or else the spanish inquisition will come and poke you with a soft cushion
$max_records = $gBitSystem->getConfig( "max_records", 10 );
@@ -256,13 +242,13 @@ if( $gBitSystem->isDatabaseValid() ) {
if( $site_http_port != 80 ) {
$http_login_url .= ':'.$site_http_port;
}
- $http_login_url .= $gBitSystem->getConfig( 'site_http_prefix', BIT_ROOT_URL ).USERS_PKG_URL.'login.php';
+ $http_login_url .= $gBitSystem->getConfig( 'site_http_prefix', BIT_ROOT_URL ).USERS_PKG_URL.'signin.php';
$https_login_url = 'https://'.$gBitSystem->getConfig( 'site_https_domain', $_SERVER['HTTP_HOST'] );
if( $site_https_port != 443 ) {
$https_login_url .= ':'.$site_https_port;
}
- $https_login_url .= $gBitSystem->getConfig( 'site_https_prefix', BIT_ROOT_URL ).USERS_PKG_URL.'login.php';
+ $https_login_url .= $gBitSystem->getConfig( 'site_https_prefix', BIT_ROOT_URL ).USERS_PKG_URL.'signin.php';
$gBitSystem->setConfig( 'http_login_url', $http_login_url );
if( $gBitSystem->isFeatureActive('site_https_login_required') ) {
@@ -279,7 +265,7 @@ if( $gBitSystem->isDatabaseValid() ) {
// if we have a valid user but their status is unsavory then completely cut them off from accessing the site
if( $gBitUser->getField('content_status_id') < 0 ){
$gBitSystem->scanPackages();
- $gBitSystem->fatalError( tra( 'Access Denied' )."!" );
+ $gBitSystem->fatalError( KernelTools::tra( 'Access Denied' )."!" );
}
}
@@ -287,5 +273,4 @@ if( $gBitSystem->isDatabaseValid() ) {
if( defined( 'INSTALLER_FORCE' )) {
$gBitSmarty->display( "bitpackage:kernel/force_installer.tpl" );
die;
-}
-?>
+} \ No newline at end of file
diff --git a/includes/simple_form_functions_lib.php b/includes/simple_form_functions_lib.php
index a20c282..a4a835e 100644..100755
--- a/includes/simple_form_functions_lib.php
+++ b/includes/simple_form_functions_lib.php
@@ -9,9 +9,9 @@
* Store or update an array of values
* @param $pArray an array of values to set
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function simple_set_configs( $pArray, $pPackageName = NULL ){
+function simple_set_configs( $pArray, $pPackageName = null ){
foreach( $pArray as $item => $data ) {
if( $data['type'] == 'numeric' ) {
simple_set_int( $item, $pPackageName );
@@ -27,14 +27,14 @@ function simple_set_configs( $pArray, $pPackageName = NULL ){
* Store or update a boolean value in the database - automatically collects data from $_REQUEST[$pFeature]
* @param $pFeature name of the parameter to be set in the database
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function simple_set_toggle( $pFeature, $pPackageName = NULL ) {
+function simple_set_toggle( $pFeature, $pPackageName = null ) {
// make function compatible with {html_checkboxes}
if( isset( $_REQUEST[$pFeature][0] ) ) {
$_REQUEST[$pFeature] = $_REQUEST[$pFeature][0];
}
- toggle_preference( $pFeature, ( isset( $_REQUEST[$pFeature] ) ? $_REQUEST[$pFeature] : NULL ), $pPackageName );
+ toggle_preference( $pFeature, ( isset( $_REQUEST[$pFeature] ) ? $_REQUEST[$pFeature] : null ), $pPackageName );
}
/**
@@ -42,12 +42,12 @@ function simple_set_toggle( $pFeature, $pPackageName = NULL ) {
* @param $pArray name of the array to check for features in
* @param $pFeatures feature to check
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function simple_set_toggle_array( $pArray, $pFeature, $pPackageName = NULL ) {
+function simple_set_toggle_array( $pArray, $pFeature, $pPackageName = null ) {
if (!empty($_REQUEST[$pArray]) && is_array($_REQUEST[$pArray])) {
$flipped = array_flip($_REQUEST[$pArray]);
- toggle_preference( $pFeature, ( isset( $flipped[$pFeature] ) ? 'y' : NULL ), $pPackageName );
+ toggle_preference( $pFeature, ( isset( $flipped[$pFeature] ) ? 'y' : null ), $pPackageName );
}
}
@@ -56,9 +56,9 @@ function simple_set_toggle_array( $pArray, $pFeature, $pPackageName = NULL ) {
* @param $pName name of the parameter to be set in the database
* @param $pValue set $pName to $pValue in kernel_prefs
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function toggle_preference( $pName, $pValue = NULL, $pPackageName = NULL ) {
+function toggle_preference( $pName, $pValue = null, $pPackageName = null ) {
global $_REQUEST, $gBitSystem, $gBitSmarty;
if( isset( $pValue ) && $pValue == "on" ) {
@@ -75,9 +75,9 @@ function toggle_preference( $pName, $pValue = NULL, $pPackageName = NULL ) {
* Store or update a value in the database - automatically collects data from $_REQUEST[$pFeature]
* @param $pFeature name of the parameter to be set in the database
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function simple_set_value( $pFeature, $pPackageName = NULL ) {
+function simple_set_value( $pFeature, $pPackageName = null ) {
global $_REQUEST, $gBitSystem, $gBitSmarty;
if( isset( $_REQUEST[$pFeature] ) ) {
$gBitSystem->storeConfig( $pFeature, $_REQUEST[$pFeature], $pPackageName );
@@ -89,9 +89,9 @@ function simple_set_value( $pFeature, $pPackageName = NULL ) {
* Store or update an integer in the database - automatically collects data from $_REQUEST[$pFeature]
* @param $pFeature name of the parameter to be set in the database
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function simple_set_int( $pFeature, $pPackageName = NULL ) {
+function simple_set_int( $pFeature, $pPackageName = null ) {
global $_REQUEST, $gBitSystem, $gBitSmarty;
if ( isset( $_REQUEST[$pFeature] ) && is_numeric( $_REQUEST[$pFeature] ) ) {
$gBitSystem->storeConfig( $pFeature, $_REQUEST[$pFeature], $pPackageName );
@@ -103,20 +103,20 @@ function simple_set_int( $pFeature, $pPackageName = NULL ) {
* Store or update a value in the database but assign it by reference to smarty - automatically collects data from $_REQUEST[$pFeature]
* @param $pFeature name of the parameter to be set in the database
* @param $pPackageName name of the package the feature belongs to
- * @return none
+ * @return void
*/
-function byref_set_value( $pFeature, $pPref = "", $pPackageName = NULL ) {
+function byref_set_value( $pFeature, $pPref = "", $pPackageName = null ) {
global $_REQUEST, $gBitSystem, $gBitSmarty;
if( isset( $_REQUEST[$pFeature] ) ) {
if( strlen( $pPref ) > 0 ) {
$gBitSystem->storeConfig( $pPref, $_REQUEST[$pFeature], $pPackageName );
// also assign the ref appareantly --gongo
- $gBitSmarty->assignByRef( $pPref, $_REQUEST[$pFeature] );
+ $gBitSmarty->assign( $pPref, $_REQUEST[$pFeature] );
} else {
$gBitSystem->storeConfig( $pFeature, $_REQUEST[$pFeature], $pPackageName );
}
- $gBitSmarty->assignByRef( $pFeature, $_REQUEST[$pFeature] );
+ $gBitSmarty->assign( $pFeature, $_REQUEST[$pFeature] );
}
}
@@ -128,7 +128,7 @@ function byref_set_value( $pFeature, $pPref = "", $pPackageName = NULL ) {
*/
function set_tab() {
global $_REQUEST,$gBitSmarty;
- $ret = FALSE;
+ $ret = false;
if( !empty( $_REQUEST ) ) {
foreach( array_keys( $_REQUEST ) as $item ) {
if( preg_match( "/TabSubmit/",$item ) ) {
diff --git a/includes/upload_slot_inc.php b/includes/upload_slot_inc.php
index f558942..b8252df 100644..100755
--- a/includes/upload_slot_inc.php
+++ b/includes/upload_slot_inc.php
@@ -8,7 +8,7 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
if( isset( $_REQUEST['upload_id'] ) && $gBitThemes->isAjaxRequest() ) {
echo $gBitSmarty->fetch( 'bitpackage:kernel/upload_slot_inc.tpl' );