diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:54:15 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:54:15 +0100 |
| commit | 189c836dcb564eb07560f50e46b3944b2df05a03 (patch) | |
| tree | aa82dc82e6b604bd416fbba3cb6b1136d5d26df0 | |
| parent | ab6c159fad476d20d3f0c1de202b00cb989bda09 (diff) | |
| download | kernel-189c836dcb564eb07560f50e46b3944b2df05a03.tar.gz kernel-189c836dcb564eb07560f50e46b3944b2df05a03.tar.bz2 kernel-189c836dcb564eb07560f50e46b3944b2df05a03.zip | |
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 files changed, 1489 insertions, 1539 deletions
diff --git a/.gitignore b/.gitignore index 45f8873..45f8873 100644..100755 --- a/.gitignore +++ b/.gitignore diff --git a/admin/admin_features_inc.php b/admin/admin_features_inc.php index 6ebadc3..26ae098 100755 --- a/admin/admin_features_inc.php +++ b/admin/admin_features_inc.php @@ -123,7 +123,7 @@ if( !empty( $_REQUEST['change_prefs'] ) ) { "site_short_time_format", "site_long_datetime_format", "site_short_datetime_format", - "bit_index" + "bit_index", ]; foreach( $refValue as $britem ) { diff --git a/admin/admin_notifications.php b/admin/admin_notifications.php index 51cc7d7..7b201f1 100755 --- a/admin/admin_notifications.php +++ b/admin/admin_notifications.php @@ -15,13 +15,13 @@ include_once KERNEL_PKG_INCLUDE_PATH.'notification_lib.php'; $gBitSystem->verifyPermission( 'p_admin' ); if (isset($_REQUEST["add"])) { - + if (isset($_REQUEST["email"]) && !empty($_REQUEST["email"])) $notificationlib->add_mail_event($_REQUEST["event"], ['*'], $_REQUEST["email"]); } if (isset($_REQUEST["removeevent"])) { - + $notificationlib->remove_mail_event($_REQUEST["removeevent"], $_REQUEST["object"], $_REQUEST["email"]); } @@ -63,4 +63,4 @@ $gBitSmarty->assign('admin_mail', $admin_mail); $gBitSmarty->assign('cuser_mail', $cuser_mail); // Display the template -$gBitSystem->display( 'bitpackage:kernel/admin_notifications.tpl', null, array( 'display_mode' => 'admin' )); +$gBitSystem->display( 'bitpackage:kernel/admin_notifications.tpl', null, [ 'display_mode' => 'admin' ]); diff --git a/admin/admin_packages_inc.php b/admin/admin_packages_inc.php index 11faa4c..83bfddf 100755 --- a/admin/admin_packages_inc.php +++ b/admin/admin_packages_inc.php @@ -11,14 +11,14 @@ $fPackage = &$_REQUEST['fPackage']; // emulate register_globals # rescan to include all packages, installed and not installed $gBitSystem->scanPackages( - 'bit_setup_inc.php', true, 'all', true, true + 'bit_setup_inc.php', true, 'all', true, true, ); // make a copy of mPackages - expensive, but this is low use code if( !empty( $_REQUEST['features'] ) ) { $pkgArray = $gBitSystem->mPackages; - foreach( array_keys( $pkgArray ) as $pkgKey ) { + foreach( array_keys( $pkgArray ) as $pkgKey ) { $pkg = $pkgArray[$pkgKey]; if( !empty( $pkg['name'] )) { $pkgName = strtolower( $pkg['name'] ); diff --git a/admin/admin_server_inc.php b/admin/admin_server_inc.php index 98630cd..4bb947b 100755 --- a/admin/admin_server_inc.php +++ b/admin/admin_server_inc.php @@ -10,19 +10,19 @@ $processForm = set_tab(); if( $processForm ) { - $pref_toggles = array( + $pref_toggles = [ "site_hidden", "site_closed", "site_use_load_threshold", "site_use_proxy", - "site_store_session_db" - ); + "site_store_session_db", + ]; foreach( $pref_toggles as $item ) { simple_set_toggle( $item, KERNEL_PKG_NAME ); } - $pref_simple_values = array( + $pref_simple_values = [ "kernel_server_name", "site_sender_email", "site_proxy_host", @@ -31,20 +31,20 @@ if( $processForm ) { "site_load_threshold", "site_busy_msg", "site_closed_msg", - "storage_host" - ); + "storage_host", + ]; foreach( $pref_simple_values as $item ) { simple_set_value( $item, KERNEL_PKG_NAME ); } - $pref_byref_values = array( + $pref_byref_values = [ "site_title", "site_slogan", "site_description", "site_notice", "site_error_title", - ); + ]; foreach( $pref_byref_values as $item ) { $_REQUEST['site_description'] = substr( $_REQUEST['site_description'], 0, 180 ); @@ -69,7 +69,7 @@ if( $processForm ) { $gBitSystem->getConfig( 'site_keywords' ). $gBitSystem->getConfig( 'site_keywords_1' ). $gBitSystem->getConfig( 'site_keywords_2' ). - $gBitSystem->getConfig( 'site_keywords_3' ) + $gBitSystem->getConfig( 'site_keywords_3' ), ); } diff --git a/admin/admin_system.php b/admin/admin_system.php index e474581..31a1d53 100755 --- a/admin/admin_system.php +++ b/admin/admin_system.php @@ -6,6 +6,7 @@ // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. namespace Bitweaver\Liberty; + require_once '../../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; use Bitweaver\Nexus\Nexus; @@ -136,7 +137,6 @@ $gBitSmarty->assign( 'feedback', $feedback ); $gBitSystem->display( 'bitpackage:kernel/admin_system.tpl', KernelTools::tra( "System Cache" ) , [ 'display_mode' => 'admin' ] ); - // {{{ Functions /** * du diff --git a/admin/apc.php b/admin/apc.php index 1886d07..c28db79 100755 --- a/admin/apc.php +++ b/admin/apc.php @@ -58,7 +58,6 @@ defaults('GRAPH_SIZE',200); // Image size ////////// END OF DEFAULT CONFIG AREA ///////////////////////////////////////////////////////////// - // "define if not defined" function defaults($d,$v) { if (!defined($d)) define($d,$v); // or just @define(...) @@ -80,7 +79,7 @@ define('OB_USER_CACHE',2); define('OB_VERSION_CHECK',3); // check validity of input variables -$vardom=array( +$vardom=[ 'OB' => '/^\d+$/', // operational mode switch 'CC' => '/^[01]$/', // clear cache requested 'DU' => '/^.*$/', // Delete User Key @@ -94,14 +93,14 @@ $vardom=array( 'SORT1' => '/^[AHSMCDTZ]$/', // first sort key 'SORT2' => '/^[DA]$/', // second sort key 'AGGR' => '/^\d+$/', // aggregation by dir level - 'SEARCH' => '~^[a-zA-Z0-9/_.-]*$~' // aggregation by dir level -); + 'SEARCH' => '~^[a-zA-Z0-9/_.-]*$~', // aggregation by dir level +]; // cache scope -$scope_list=array( +$scope_list=[ 'A' => 'cache_list', - 'D' => 'deleted_list' -); + 'D' => 'deleted_list', +]; // handle POST and GET requests if (empty($_REQUEST)) { @@ -170,9 +169,9 @@ if (!USE_AUTHENTICATION) { EOB; exit; - } else { - $AUTHENTICATED=1; } + $AUTHENTICATED=1; + } } @@ -201,25 +200,25 @@ header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 function duration($ts) { - global $time; - $years = (int)((($time - $ts)/(7*86400))/52.177457); - $rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400)); - $weeks = (int)(($rem)/(7*86400)); - $days = (int)(($rem)/86400) - $weeks*7; - $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24; - $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60; - $str = ''; - if($years==1) $str .= "$years year, "; - if($years>1) $str .= "$years years, "; - if($weeks==1) $str .= "$weeks week, "; - if($weeks>1) $str .= "$weeks weeks, "; - if($days==1) $str .= "$days day,"; - if($days>1) $str .= "$days days,"; - if($hours == 1) $str .= " $hours hour and"; - if($hours>1) $str .= " $hours hours and"; - if($mins == 1) $str .= " 1 minute"; - else $str .= " $mins minutes"; - return $str; + global $time; + $years = (int)((($time - $ts)/(7*86400))/52.177457); + $rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400)); + $weeks = (int)(($rem)/(7*86400)); + $days = (int)(($rem)/86400) - $weeks*7; + $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24; + $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60; + $str = ''; + if($years==1) $str .= "$years year, "; + if($years>1) $str .= "$years years, "; + if($weeks==1) $str .= "$weeks week, "; + if($weeks>1) $str .= "$weeks weeks, "; + if($days==1) $str .= "$days day,"; + if($days>1) $str .= "$days days,"; + if($hours == 1) $str .= " $hours hour and"; + if($hours>1) $str .= " $hours hours and"; + if($mins == 1) $str .= " 1 minute"; + else $str .= " $mins minutes"; + return $str; } // create graphics @@ -237,7 +236,6 @@ if (isset($MYREQUEST['IMG'])) $r=$diameter/2; $w=deg2rad((360+$start+($end-$start)/2)%360); - if (function_exists("imagefilledarc")) { // exists only if GD 2.0.1 is avaliable imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE); @@ -300,7 +298,7 @@ if (isset($MYREQUEST['IMG'])) $px=$x+40*2; $py=($placeindex-15)*12+6; } else { - $px=$x+40*2+100*intval(($placeindex-15)/15); + $px=$x+40*2+100*(int) (($placeindex-15)/15); $py=($placeindex%15)*12+6; } imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2); @@ -313,7 +311,6 @@ if (isset($MYREQUEST['IMG'])) } } - $size = GRAPH_SIZE; // image size if ($MYREQUEST['IMG']==3) $image = imagecreate(2*$size+150, $size+10); @@ -349,7 +346,7 @@ if (isset($MYREQUEST['IMG'])) if( ($angle_to*360) - ($angle_from*360) >= 1) { fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); if (($angle_to-$angle_from)>0.05) { - array_push($string_placement, array($angle_from,$angle_to)); + array_push($string_placement, [$angle_from,$angle_to]); } } $angle_from = $angle_to; @@ -359,7 +356,7 @@ if (isset($MYREQUEST['IMG'])) if( ($angle_to*360) - ($angle_from*360) >= 1) { fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green); if (($angle_to-$angle_from)>0.05) { - array_push($string_placement, array($angle_from,$angle_to)); + array_push($string_placement, [$angle_from,$angle_to]); } } $angle_from = $angle_to; @@ -370,7 +367,7 @@ if (isset($MYREQUEST['IMG'])) if(($angle_to+$fuzz)>1) $angle_to = 1; fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); if (($angle_to-$angle_from)>0.05) { - array_push($string_placement, array($angle_from,$angle_to)); + array_push($string_placement, [$angle_from,$angle_to]); } } } @@ -404,18 +401,18 @@ if (isset($MYREQUEST['IMG'])) if($block['offset']!=$ptr) { // Used block $h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s; if ($h>0) { - $j++; + $j++; if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j); - else fill_box($image,$x,$y,50,$h,$col_black,$col_red); - } + else fill_box($image,$x,$y,50,$h,$col_black,$col_red); + } $y+=$h; } $h=(GRAPH_SIZE-5)*($block['size'])/$s; if ($h>0) { - $j++; + $j++; if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j); else fill_box($image,$x,$y,50,$h,$col_black,$col_green); - } + } $y+=$h; $ptr = $block['offset']+$block['size']; } @@ -445,7 +442,7 @@ if (isset($MYREQUEST['IMG'])) // pretty printer for byte values // function bsize($s) { - foreach (array('','K','M','G') as $i => $k) { + foreach (['','K','M','G'] as $i => $k) { if ($s < 1024) break; $s/=1024; } @@ -502,11 +499,10 @@ function block_sort($array1, $array2) { if ($array1['offset'] > $array2['offset']) { return 1; - } else { - return -1; } -} + return -1; +} ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> @@ -741,7 +737,6 @@ echo <<<EOB </ol> EOB; - // CONTENT echo <<<EOB <div class=content> @@ -772,7 +767,7 @@ case OB_HOST_STATS: $apcversion = phpversion('apcu'); $phpversion = phpversion(); $number_vars = $cache['num_entries']; - $size_vars = bsize($cache['mem_size']); + $size_vars = bsize($cache['mem_size']); $i=0; echo <<< EOB <div class="info div1"><h2>General Cache Information</h2> @@ -874,9 +869,9 @@ EOB; ++$nseg; } $ptr = $block['offset'] + $block['size']; - /* Only consider blocks <5M for the fragmentation % */ - if($block['size']<(5*1024*1024)) $fragsize+=$block['size']; - $freetotal+=$block['size']; + /* Only consider blocks <5M for the fragmentation % */ + if($block['size']<(5*1024*1024)) $fragsize+=$block['size']; + $freetotal+=$block['size']; } $freeseg += count($mem['block_lists'][$i]); } @@ -898,28 +893,27 @@ EOB; </td> </tr> EOB; - if(isset($mem['adist'])) { - foreach($mem['adist'] as $i=>$v) { - $cur = pow(2,$i); $nxt = pow(2,$i+1)-1; - if($i==0) $range = "1"; - else $range = "$cur - $nxt"; - echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n"; - } - } - echo <<<EOB + if(isset($mem['adist'])) { + foreach($mem['adist'] as $i=>$v) { + $cur = pow(2,$i); $nxt = pow(2,$i+1)-1; + if($i==0) $range = "1"; + else $range = "$cur - $nxt"; + echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n"; + } + } + echo <<<EOB </tbody></table> </div> EOB; break; - // ----------------------------------------------- // User Cache Entries // ----------------------------------------------- case OB_USER_CACHE: if (!$AUTHENTICATED) { - echo '<div class="error">You need to login to see the user values here!<br/> <br/>'; + echo '<div class="error">You need to login to see the user values here!<br/> <br/>'; put_login_link("Login now!"); echo '</div>'; break; @@ -964,7 +958,7 @@ EOB; '<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>', '<option value=0 ',$MYREQUEST['COUNT']=='0' ? ' selected':'','>All</option>', '</select>', - ' Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>', + ' Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>', ' <input type=submit value="GO!">', '</form></div>'; @@ -973,8 +967,8 @@ EOB; // regular expression subpattern. $MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i'; if (preg_match($MYREQUEST['SEARCH'], 'test') === false) { - echo '<div class="error">Error: enter a valid regular expression as a search query.</div>'; - break; + echo '<div class="error">Error: enter a valid regular expression as a search query.</div>'; + break; } } @@ -1028,45 +1022,45 @@ EOB; // output list $i=0; foreach($list as $k => $entry) { - if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) { + if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) { $sh=md5($entry["info"]); - $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8'); - echo - '<tr id="key-'. $sh .'" class=tr-',$i%2,'>', - "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"#key-". $sh ."\">",$field_value,'</a></td>', - '<td class="td-n center">',$entry['num_hits'],'</td>', - '<td class="td-n right">',$entry['mem_size'],'</td>', - '<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>', - '<td class="td-n center">',date(DATE_FORMAT,$entry['mtime']),'</td>', - '<td class="td-n center">',date(DATE_FORMAT,$entry['creation_time']),'</td>'; + $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8'); + echo + '<tr id="key-'. $sh .'" class=tr-',$i%2,'>', + "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"#key-". $sh ."\">",$field_value,'</a></td>', + '<td class="td-n center">',$entry['num_hits'],'</td>', + '<td class="td-n right">',$entry['mem_size'],'</td>', + '<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>', + '<td class="td-n center">',date(DATE_FORMAT,$entry['mtime']),'</td>', + '<td class="td-n center">',date(DATE_FORMAT,$entry['creation_time']),'</td>'; - if($fieldname=='info') { - if($entry['ttl']) - echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>'; - else - echo '<td class="td-n center">None</td>'; - } - if ($entry['deletion_time']) { + if($fieldname=='info') { + if($entry['ttl']) + echo '<td class="td-n center">'.$entry['ttl'].' seconds</td>'; + else + echo '<td class="td-n center">None</td>'; + } + if ($entry['deletion_time']) { - echo '<td class="td-last center">', date(DATE_FORMAT,$entry['deletion_time']), '</td>'; - } else if ($MYREQUEST['OB'] == OB_USER_CACHE) { + echo '<td class="td-last center">', date(DATE_FORMAT,$entry['deletion_time']), '</td>'; + } else if ($MYREQUEST['OB'] == OB_USER_CACHE) { - echo '<td class="td-last center">'; - echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldkey]), '">Delete Now</a>]'; - echo '</td>'; - } else { - echo '<td class="td-last center"> </td>'; - } - echo '</tr>'; + echo '<td class="td-last center">'; + echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldkey]), '">Delete Now</a>]'; + echo '</td>'; + } else { + echo '<td class="td-last center"> </td>'; + } + echo '</tr>'; if ($sh == $MYREQUEST["SH"]) { echo '<tr>'; echo '<td colspan="7"><pre>'.htmlentities(print_r(apcu_fetch($entry['info']), 1)).'</pre></td>'; echo '</tr>'; } - $i++; - if ($i == $MYREQUEST['COUNT']) - break; - } + $i++; + if ($i == $MYREQUEST['COUNT']) + break; + } } } else { @@ -1097,10 +1091,10 @@ case OB_VERSION_CHECK: </tr> EOB; if (defined('PROXY')) { - $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) ); - $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt); + $ctxt = stream_context_create( [ 'http' => [ 'proxy' => PROXY, 'request_fulluri' => True ] ] ); + $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt); } else { - $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss"); + $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss"); } if (!$rss) { echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>'; diff --git a/admin/backup.php b/admin/backup.php index 2db3548..6333e31 100755 --- a/admin/backup.php +++ b/admin/backup.php @@ -8,6 +8,7 @@ // Initialization namespace Bitweaver; + require_once '../../kernel/includes/setup_inc.php'; require_once KERNEL_PKG_INCLUDE_PATH.'backups_lib.php'; @@ -20,7 +21,7 @@ $backupPath = STORAGE_PKG_PATH."backups/$bitdomain"; KernelTools::mkdir_p( $backupPath ); if (isset($_REQUEST["generate"])) { - + $filename = md5($gBitSystem->genPass()). '.sql'; $backuplib->backup_database( $backupPath.$filename ); @@ -29,26 +30,26 @@ if (isset($_REQUEST["generate"])) { $gBitSmarty->assign('restore', 'n'); if (isset($_REQUEST["restore"])) { - + $gBitSmarty->assign('restore', 'y'); $gBitSmarty->assign('restorefile', basename($_REQUEST["restore"])); } if (isset($_REQUEST["rrestore"])) { - + $backuplib->restore_database( $backupPath.basename($_REQUEST["rrestore"])); } if (isset($_REQUEST["remove"])) { - + $filename = $backupPath.basename($_REQUEST["remove"]); unlink ($filename); } if (isset($_REQUEST["upload"])) { - + if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) { $fp = fopen($_FILES['userfile1']['tmp_name'], "r"); @@ -91,5 +92,4 @@ closedir ($h); $gBitSmarty->assign('backups', $backups); $gBitSmarty->assign('bitdomain', $bitdomain); - -$gBitSystem->display( 'bitpackage:kernel/backup.tpl', KernelTools::tra( 'Backups') , array( 'display_mode' => 'admin' )); +$gBitSystem->display( 'bitpackage:kernel/backup.tpl', KernelTools::tra( 'Backups') , [ 'display_mode' => 'admin' ]); diff --git a/admin/db_performance.php b/admin/db_performance.php index 26f2088..dc81a48 100755 --- a/admin/db_performance.php +++ b/admin/db_performance.php @@ -1,6 +1,7 @@ <?php namespace Bitweaver; - require_once '../../kernel/includes/setup_inc.php'; + +require_once '../../kernel/includes/setup_inc.php'; if (!$gBitUser->isAdmin()) { $gBitSmarty->assign('msg', KernelTools::tra("You dont have permission to use this feature")); diff --git a/admin/index.php b/admin/index.php index 367a62f..976caa0 100755 --- a/admin/index.php +++ b/admin/index.php @@ -20,7 +20,7 @@ if( !empty( $_REQUEST["page"] )) { // only admins may use this page $gBitSystem->verifyPermission( 'p_'.$page.'_admin' ); - + if( preg_match( '/\.php/', $page )) { $adminPage = $page; } else { @@ -61,7 +61,7 @@ if( !empty( $_REQUEST["page"] )) { $gBitSmarty->assign( 'adminFile', $adminFile ); $gBitSmarty->assign( 'page', $page ); $gBitSystem->setBrowserTitle( preg_replace( '/_/', ' ', $page )." Settings" ); - + include_once $adminPage; // Spiderr - a bit hackish, but need to force preferences refresh diff --git a/admin/list_cache.php b/admin/list_cache.php index 3794e9e..1c5230a 100755 --- a/admin/list_cache.php +++ b/admin/list_cache.php @@ -74,8 +74,7 @@ if ($offset > 0) { $gBitSmarty->assign('listpages', $listpages["data"]); //print_r($listpages["data"]); - // Display the template -$gBitSystem->display( 'bitpackage:kernel/list_cache.tpl', null, array( 'display_mode' => 'list' )); +$gBitSystem->display( 'bitpackage:kernel/list_cache.tpl', null, [ 'display_mode' => 'list' ]); ?> diff --git a/admin/remote_backup.php b/admin/remote_backup.php index d33f896..503596c 100755 --- a/admin/remote_backup.php +++ b/admin/remote_backup.php @@ -15,12 +15,12 @@ require_once '../../kernel/includes/setup_inc.php'; include_once 'lib/backups/backupslib.php'; if(isset($_REQUEST["generate"])) { - if(isset($_REQUEST["my_word"]) && - $_REQUEST["my_word"] == "YOUR PASSWORD FOR BACKUPS HERE" ) { - $filename = md5($gBitSystem->genPass()).'.sql'; - $backuplib->backup_database("backups/$bitdomain$filename"); - echo "Done"; - } + if(isset($_REQUEST["my_word"]) && + $_REQUEST["my_word"] == "YOUR PASSWORD FOR BACKUPS HERE" ) { + $filename = md5($gBitSystem->genPass()).'.sql'; + $backuplib->backup_database("backups/$bitdomain$filename"); + echo "Done"; + } } die; diff --git a/admin/schema_inc.php b/admin/schema_inc.php index b6acc58..c9cd76c 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -102,7 +102,7 @@ $gBitInstaller->registerModules( $moduleHash ); // ### Default UserPermissions $gBitInstaller->registerUserPermissions( KERNEL_PKG_NAME, [ [ 'p_admin' , 'Can manage users groups and permissions and all aspects of site management' , 'admin' , KERNEL_PKG_NAME ], - [ 'p_access_closed_site' , 'Can access site when closed' , 'admin' , KERNEL_PKG_NAME ] + [ 'p_access_closed_site' , 'Can access site when closed' , 'admin' , KERNEL_PKG_NAME ], ] ); // Package requirements diff --git a/admin/sitemaps.php b/admin/sitemaps.php index d785f7d..38ace36 100755 --- a/admin/sitemaps.php +++ b/admin/sitemaps.php @@ -8,7 +8,6 @@ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details */ - // Initialization require_once '../../kernel/includes/setup_inc.php'; @@ -9,8 +9,9 @@ * required setup */ namespace Bitweaver; + require_once '../kernel/includes/setup_inc.php'; // Display the template $gBitSmarty->assign( 'msg', strip_tags( $_REQUEST["error"] )); -$gBitSystem->display( 'error.tpl' , KernelTools::tra( 'Error' ), array( 'display_mode' => 'display' )); +$gBitSystem->display( 'error.tpl' , KernelTools::tra( 'Error' ), [ 'display_mode' => 'display' ]); diff --git a/error_simple.php b/error_simple.php index 887d06e..d6a17ad 100644 --- a/error_simple.php +++ b/error_simple.php @@ -25,7 +25,7 @@ <?php if (isset($_REQUEST['error']) and !is_null($_REQUEST['error'])) { if( $gBitSystem->isFeatureActive( 'site_closed' )){ - echo $_REQUEST['error']; + echo $_REQUEST['error']; } else { echo strip_tags($_REQUEST['error']); } diff --git a/icons/index.php b/icons/index.php index 3e305fe..c0437d0 100644 --- a/icons/index.php +++ b/icons/index.php @@ -1,4 +1,4 @@ -<?php +<?php // This is not a package. header ("location: ../index.php"); diff --git a/icons/pkg_kernel.gif b/icons/pkg_kernel.gif Binary files differindex f5f40d0..f5f40d0 100644..100755 --- a/icons/pkg_kernel.gif +++ b/icons/pkg_kernel.gif diff --git a/icons/pkg_kernel.png b/icons/pkg_kernel.png Binary files differindex dffbc2a..dffbc2a 100644..100755 --- a/icons/pkg_kernel.png +++ b/icons/pkg_kernel.png diff --git a/icons/pkg_layout.gif b/icons/pkg_layout.gif Binary files differindex 52e3c14..52e3c14 100644..100755 --- a/icons/pkg_layout.gif +++ b/icons/pkg_layout.gif diff --git a/icons/pkg_layout.png b/icons/pkg_layout.png Binary files differindex 0ebb410..0ebb410 100644..100755 --- a/icons/pkg_layout.png +++ b/icons/pkg_layout.png diff --git a/includes/ajax_file_browser_inc.php b/includes/ajax_file_browser_inc.php index 56dca12..860775f 100755 --- a/includes/ajax_file_browser_inc.php +++ b/includes/ajax_file_browser_inc.php @@ -43,7 +43,7 @@ if( !empty( $_REQUEST['ajax_path_conf'] ) && $gBitSystem->isFeatureActive( $_REQ $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->loadAjax( 'mochikit', [ 'Iter.js', 'DOM.js', 'Async.js' ]); $gBitThemes->loadJavascript( KERNEL_PKG_PATH."scripts/BitFileBrowser.js", true ); if( $gBitThemes->isAjaxRequest() ) { @@ -57,7 +57,7 @@ if( $gBitThemes->isAjaxRequest() ) { * @param string $pRelPath relative path on top of base directory * @access public * @return array - */ + */ function ajax_dir_list( $pDir, $pRelPath = null ) { global $gBitSystem; $ret = $files = []; @@ -74,13 +74,13 @@ function ajax_dir_list( $pDir, $pRelPath = null ) { $relFile = $pRelPath.$i; $file = realpath( $pDir.$relFile ); if( strpos( $file, $pDir ) === 0 ) { - $info = array( + $info = [ 'name' => $i, 'relpath' => $relFile, 'indent' => ( count( explode( '/', $relFile )) * 10 ), 'size' => filesize( $file ), 'mtime' => filemtime( $file ), - ); + ]; if( is_dir( $file )) { $ret['dir'][$i] = $info; } elseif( !preg_match( EVIL_EXTENSION_PATTERN, $file )) { @@ -93,9 +93,9 @@ function ajax_dir_list( $pDir, $pRelPath = null ) { } if( empty( $ret )) { - $ret['file'][] = array( + $ret['file'][] = [ 'indent' => ( count( explode( '/', $pRelPath )) * 10 ), - ); + ]; } return $ret; diff --git a/includes/autoload.php b/includes/autoload.php index b0bca6b..8c62bbd 100755 --- a/includes/autoload.php +++ b/includes/autoload.php @@ -12,7 +12,7 @@ function class_autoload( $className ) { $parts[2] = $parts[1]; $parts[1] = 'kernel/includes/classes/'; } elseif ($parts[1] == 'Plugins' ) { - $parts[1] = 'themes/smartyplugins/'; + $parts[1] = 'themes/smartyplugins/'; } elseif (count($parts) <> 3) { return; } else { diff --git a/includes/bit_error_inc.php b/includes/bit_error_inc.php index 3e55b13..a2689a8 100755 --- a/includes/bit_error_inc.php +++ b/includes/bit_error_inc.php @@ -57,27 +57,27 @@ function bit_print_log( $pLogParams, $pLogMessages ) { $executionTime = BitBase::getParameter( $pLogParams, 'exectime', '-' ); $logTimestamp = BitBase::getParameter( $pLogParams, 'timestamp', date( '[d/M/Y:H:i:s O]' ) ); - for( $i = 1; $i < func_num_args(); $i++ ) { - if( $pLogMessage = func_get_arg( $i ) ) { + 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); - foreach ($errlines as $txt) { + foreach ($errlines as $txt) { print "$virtualHost $remoteAddr $ident $userName $logTimestamp \"$scriptFilename\" $statusCode $executionTime \"$userAgent\" $pLogMessage\n"; } } else { print "$virtualHost $remoteAddr $ident $userName $logTimestamp \"$scriptFilename\" $statusCode $executionTime \"$userAgent\"\n"; } - } + } } function bit_error_log() { - for( $i = 0; $i < func_num_args(); $i++ ) { - if( $pLogMessage = func_get_arg( $i ) ) { + 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); - foreach ($errlines as $txt) { - error_log($txt); + foreach ($errlines as $txt) { + error_log($txt); } } - } + } error_log( 'SCRIPT_URI: '.BitBase::getParameter( $_SERVER, 'SCRIPT_URI', 'OUTPUT' )."\n".bit_stack( 5 ) ); } @@ -126,13 +126,13 @@ function bit_error_email ( $pSubject, $pMessage, $pGlobalVars=[] ) { } function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=null ) { - // error_reporting() === 0 if code was prepended with @ + // error_reporting() === 0 if code was prepended with @ - $reportingLevel = error_reporting(); - if( $reportingLevel !== 0 && !strpos( $errfile, 'templates_c' ) ) { + $reportingLevel = error_reporting(); + if( $reportingLevel !== 0 && !strpos( $errfile, 'templates_c' ) ) { $errType = 'Error'; $isReported = true; - switch ($errno) { + switch ($errno) { case E_ERROR: $errType = 'FATAL ERROR'; break; case E_WARNING: $isReported = $reportingLevel & E_WARNING; $errType = 'WARNING'; break; case E_PARSE: $isReported = $reportingLevel & E_PARSE; $errType = 'PARSE'; break; @@ -147,17 +147,17 @@ function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=nu 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; - default: $errType = 'Error '.$errno; break; + default: $errType = 'Error '.$errno; break; - } + } if( $isReported ) { //eb( $isReported, $errType, $errno, $reportingLevel, $errfile ); $errorSubject = 'PHP '.$errType.' on '.php_uname( 'n' ).': '.$errstr; - $errorString = $errType." [#$errno]: $errstr \n in $errfile on line $errline\n\n".bit_error_string( array( 'errno'=>$errno, 'db_msg'=>$errType ) ); + $errorString = $errType." [#$errno]: $errstr \n in $errfile on line $errline\n\n".bit_error_string( [ 'errno'=>$errno, 'db_msg'=>$errType ] ); if( \defined( 'IS_LIVE' ) && IS_LIVE ) { if( \defined( 'ERROR_EMAIL' ) ) { - // Send an e-mail to the administrator + // Send an e-mail to the administrator bit_error_email( $errorSubject, $errorString ); } else { error_log( $errorString ); @@ -170,10 +170,10 @@ function bit_error_handler ( $errno, $errstr, $errfile, $errline, $errcontext=nu } } } - } + } - // Execute PHP's internal error handler - return false; + // Execute PHP's internal error handler + return false; } function bit_shutdown_handler() { @@ -189,7 +189,6 @@ function bit_shutdown_handler() { register_shutdown_function('Bitweaver\bit_shutdown_handler'); - function bit_display_error( $pLogMessage, $pSubject, $pFatal = true ) { global $gBitSystem; @@ -335,7 +334,7 @@ function bit_stack( $pDepth = 999 ) { if (\is_null($v) ) { $args[] = 'null'; } elseif (\is_array($v)) { $args[] = 'Array['.\sizeof($v).']'; - } elseif (\is_object($v)) { $args[] = 'Object:'.\get_class($v); + } elseif (\is_object($v)) { $args[] = 'Object:'.$v::class; } elseif (\is_bool($v)) { $args[] = $v ? 'true' : 'false'; } else { $v = (string) @$v; @@ -360,9 +359,9 @@ function bit_stack( $pDepth = 999 ) { // variable argument var dump function vvd() { - for( $i = 0; $i < \func_num_args(); $i++ ) { - vd( func_get_arg( $i ) ); - } + for( $i = 0; $i < \func_num_args(); $i++ ) { + vd( func_get_arg( $i ) ); + } } // var dump variable in something nicely readable in web browser @@ -403,9 +402,9 @@ function vd( $pVar, $pGlobals=false, $pDelay=false ) { // variable argument var dump function vvc() { $ret = ''; - for( $i = 0; $i < func_num_args(); $i++ ) { - $ret .= vc( func_get_arg( $i ), false ); - } + for( $i = 0; $i < func_num_args(); $i++ ) { + $ret .= vc( func_get_arg( $i ), false ); + } return $ret; } @@ -426,7 +425,7 @@ 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'; + include_once UTIL_PKG_INCLUDE_PATH.'dBug/dBug.php'; new \dBug( $iVar, "", false ); } else { print '<pre>'; @@ -444,7 +443,6 @@ function vc( $iVar, $pHtml=true ) { return "$ret\n"; } - function va( $iVar ) { $dbg = var_export($iVar, 1); $dbg = highlight_string( "<?\n$dbg\n?>", 1); diff --git a/includes/classes/BitBase.php b/includes/classes/BitBase.php index 243ffdf..8dbe815 100755 --- a/includes/classes/BitBase.php +++ b/includes/classes/BitBase.php @@ -26,12 +26,10 @@ namespace Bitweaver; define( 'STORAGE_BINARY', 1 ); define( 'STORAGE_IMAGE', 2 ); - interface BitCacheable { - public function getCacheKey(); + public function getCacheKey(); } - /** * Virtual base class (as much as one can have such things in PHP) for all * derived bitweaver classes that require database access. @@ -106,7 +104,6 @@ abstract class BitBase { protected $mPreventCache = true; - public const int CACHE_STATE_NONE = 0; public const int CACHE_STATE_DELETE = -1; public const int CACHE_STATE_ADDED = 1; @@ -216,9 +213,9 @@ abstract class BitBase { if( $ret = apcu_fetch( static::getCacheUuidFromKey( $pCacheKey, $pContentTypeGuid ) ) ) { $ret->mCacheObject = true; //vd( 'LOAD SUCCESS '.get_class( $ret ).' ' .$ret->getField( 'content_id' ) ); - } else { -//vd( 'LOAD FAILED' ); } +//vd( 'LOAD FAILED' ); + } return $ret; @@ -283,9 +280,9 @@ abstract class BitBase { return $isRefresh; } - final public static function getClass() { - return get_called_class(); - } + final public static function getClass() { + return get_called_class(); + } public function getConfig( string $pName, string $pDefault = '' ) { global $gBitSystem; @@ -385,14 +382,14 @@ abstract class BitBase { return false; } if( is_array( $pId )) { - foreach( $pId as $id ) { - if( (is_int( $id ) || ctype_digit( (string) $id ) || (is_numeric( $id ) ? intval( $id ) == $id : false)) ) { + foreach( $pId as $id ) { + if( (is_int( $id ) || ctype_digit( (string) $id ) || (is_numeric( $id ) ? (int) $id == $id : false)) ) { return false; } } return true; } - return !empty( $pId ) && (is_int( $pId ) || ctype_digit( $pId ) || is_numeric( $pId )) && ($pId < 0x7FFFFFFF) && (intval( $pId ) == $pId); + return !empty( $pId ) && (is_int( $pId ) || ctype_digit( $pId ) || is_numeric( $pId )) && ($pId < 0x7FFFFFFF) && ((int) $pId == $pId); } /** @@ -525,7 +522,7 @@ abstract class BitBase { $pListHash['find'] = !empty( $pListHash["find"] ) ? $pListHash["find"] : null; $gBitSmarty->assign( 'find', $pListHash['find'] ); - $pListHash['date'] = isset( $_REQUEST['date'] ) ? $_REQUEST['date'] : $gBitSystem->getUTCTime(); + $pListHash['date'] = $_REQUEST['date'] ?? $gBitSystem->getUTCTime(); if( empty( $pListHash['load_comments'] )) { $pListHash['load_comments'] = false; @@ -559,7 +556,6 @@ abstract class BitBase { return false; } - /** * Updates results from any getList function to provide the control set * displaying in the smarty template diff --git a/includes/classes/BitCache.php b/includes/classes/BitCache.php index 73c22b3..e132cde 100755 --- a/includes/classes/BitCache.php +++ b/includes/classes/BitCache.php @@ -9,7 +9,6 @@ */ namespace Bitweaver; -use Bitweaver\KernelTools; class BitCache { /** @@ -52,9 +51,9 @@ class BitCache { public function getCacheFile( $pFile ) { if( !empty( $pFile )) { return $this->mFolder."/".$pFile; - } else { - return false; } + return false; + } /** @@ -84,9 +83,9 @@ class BitCache { $isModified = filemtime( $this->getCacheFile( $pFile )) < $pModTime; } return empty( $isModified ); - } else { - return false; } + return false; + } /** diff --git a/includes/classes/BitDate.php b/includes/classes/BitDate.php index ad0b870..01bc26d 100755 --- a/includes/classes/BitDate.php +++ b/includes/classes/BitDate.php @@ -10,7 +10,7 @@ */ namespace Bitweaver; - + /** * BitDate * @@ -72,15 +72,15 @@ class BitDate { // Recompute offset each request in case DST kicked in if ( $display_tz == "Local" && isset($_COOKIE["tz_offset"])) - $this->display_offset = intval($_COOKIE["tz_offset"]); + $this->display_offset = (int) ($_COOKIE["tz_offset"]); else if ( $display_tz == "Fixed" ) - $this->display_offset = $gBitUser->getPreference( 'site_display_timezone', 0 ); + $this->display_offset = $gBitUser->getPreference( 'site_display_timezone', 0 ); if ( version_compare( phpversion(), "5.1.0", ">=" ) and !is_numeric( $this->display_offset ) ) { $dateTimeZoneUser = new \DateTimeZone( $this->display_offset ); $dtNow = new \DateTime( "now" ); $this->display_offset = $dateTimeZoneUser->getOffset( $dtNow ); } - return $this->display_offset; + return $this->display_offset; } /** @@ -91,7 +91,7 @@ class BitDate { */ public function getDisplayDateFromUTC($_timestamp) { global $gBitUser; - + if ( $gBitUser->getPreference('site_display_utc', "Local") == "Fixed" && class_exists( 'DateTime' ) ) { date_default_timezone_set( $gBitUser->getPreference( 'site_display_timezone', 'UTC' ) ); $dateTimeUser = is_numeric( $_timestamp ) @@ -100,9 +100,9 @@ class BitDate { $dateTimeUserZone = new \DateTimeZone( $gBitUser->getPreference( 'site_display_timezone', 'UTC' ) ); return strtotime( $dateTimeUser->format(DATE_ATOM) ) + timezone_offset_get( $dateTimeUserZone, $dateTimeUser ); - } else { - return $this->getTimestampFromISO($_timestamp) + $this->display_offset; } + return $this->getTimestampFromISO($_timestamp) + $this->display_offset; + } /** @@ -113,7 +113,7 @@ class BitDate { */ public function getUTCFromDisplayDate($_timestamp) { global $gBitUser; - + if ( $gBitUser->getPreference('site_display_utc', "Local") == "Fixed" ) { date_default_timezone_set( $gBitUser->getPreference( 'site_display_timezone', 'UTC' ) ); $dateTimeUser = is_numeric( $_timestamp ) @@ -122,9 +122,9 @@ class BitDate { $dateTimeUserZone = new \DateTimeZone( $gBitUser->getPreference( 'site_display_timezone', 'UTC' ) ); return strtotime( $dateTimeUser->format(DATE_ATOM) ) - timezone_offset_get( $dateTimeUserZone, $dateTimeUser ); - } else { - return $this->getTimestampFromISO($_timestamp) - $this->display_offset; } + return $this->getTimestampFromISO($_timestamp) - $this->display_offset; + } /** @@ -188,21 +188,21 @@ class BitDate { */ public function getTimestampFromISO( $iso_date, $reverse = false ) { $ret = 0; - if ( is_numeric($iso_date) ) { + if ( is_numeric($iso_date) ) { $ret = $iso_date; } else if ( $reverse ) { // Input d.m.y, h:m:s if (preg_match( "|^([0-9]{1,2})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{3,4}), ?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,8}))?|", - $iso_date, $rr)) + $iso_date, $rr, )) $ret = !isset($rr[5]) ? $this->gmmktime(0,0,0,$rr[2],$rr[1],$rr[3]) : $ret = @$this->gmmktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[1],$rr[3]); - } else { + } else { // Input y.m.d h:m:s if (preg_match( "|^([0-9]{3,4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", - $iso_date, $rr)) + $iso_date, $rr, )) $ret = !isset($rr[5]) ? $this->gmmktime(0,0,0,$rr[2],$rr[3],$rr[1]) : $ret = @$this->gmmktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); @@ -226,7 +226,7 @@ class BitDate { Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). */ - $greg_correction = $year <= 1582 + $greg_correction = $year <= 1582 ? ($year < 1582 || ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15))) ? 3: 0) : 0; if($month > 2) @@ -256,12 +256,12 @@ class BitDate { */ public function weekOfYear($year, $month, $day) { - $iso = $this->gregorianToISO($year, $month, $day); - $parts = explode('-',$iso); - $week_number = intval($parts[1]); - if ( $week_number == 0 ) $week_number = 53; - return $week_number; - } + $iso = $this->gregorianToISO($year, $month, $day); + $parts = explode('-',$iso); + $week_number = (int) ($parts[1]); + if ( $week_number == 0 ) $week_number = 53; + return $week_number; + } /** * Checks for leap year, returns true if it is. No 2-digit year check. Also @@ -423,7 +423,7 @@ class BitDate { 1630 => -10729324800, 1620 => -11044944000, 1610 => -11360476800, - 1600 => -11676096000 + 1600 => -11676096000, ]; if ($is_gmt) $origd = $d; @@ -523,7 +523,6 @@ class BitDate { ]; } - $dow = adodb_dow($year,$month,$day); return [ @@ -555,7 +554,7 @@ class BitDate { if ($d !== false) { if (!preg_match( "|^([0-9]{3,4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", - $d, $rr)) return $this->date($fmt,false,$is_gmt); + $d, $rr, )) return $this->date($fmt,false,$is_gmt); if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt); @@ -568,7 +567,6 @@ class BitDate { return $this->date($fmt,$d,$is_gmt); } - /** * Return formatted date based on timestamp $d * @param string Format of date output @@ -756,10 +754,9 @@ class BitDate { $min = intval($min); $sec = intval($sec); */ - $mon = intval($mon); - $day = intval($day); - $year = intval($year); - + $mon = (int) $mon; + $day = (int) $day; + $year = (int) $year; $year = $this->year_digit_check($year); @@ -772,7 +769,7 @@ class BitDate { $mon += 12; $year -= 1; } - + $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; @@ -838,9 +835,9 @@ class BitDate { public function strtotime($time, $now=null) { - if ($now == null) + if ($now == null) return strtotime($time); - else + return strtotime($time, $now); } @@ -852,11 +849,11 @@ class BitDate { $formatter = new \IntlDateFormatter('en_GB', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE); if ((abs($ls) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range if (!defined('ADODB_NO_NEGATIVE_TS') || $ls >= 0) // if windows, must be +ve integer - return $is_gmt ? @$formatter->format($ls) : @$formatter->format($ls); + return $is_gmt ? @$formatter->format($ls) : @$formatter->format($ls); } if (empty($ADODB_DATE_LOCALE)) { - $tstr = strtoupper($formatter->format(time())); // 30 Dec 1970, 1 am + $tstr = strtoupper($formatter->format(time())); // 30 Dec 1970, 1 am $sep = substr($tstr,2,1); $hasAM = strrpos($tstr,'M') !== false; @@ -954,7 +951,7 @@ class BitDate { */ // Transcribed to PHP by Jesus M. Castagnetto (blame him if it is fubared ;-) public function gregorianToISO($year, $month, $day) { - $mnth = array (0,31,59,90,120,151,181,212,243,273,304,334); + $mnth = [0,31,59,90,120,151,181,212,243,273,304,334]; if ($month == 0) { $year--; $month = 12; @@ -969,11 +966,11 @@ class BitDate { // find Jan 1 weekday (monday = 1, sunday = 7) $yy = ($year - 1) % 100; $c = ($year - 1) - $yy; - $g = $yy + intval($yy/4); - $jan1_weekday = 1 + intval(($c / 100 % 4 * 5 + $g) % 7); + $g = $yy + (int) ($yy/4); + $jan1_weekday = 1 + (int) (($c / 100 % 4 * 5 + $g) % 7); // weekday for year-month-day $h = $day_of_year_number + ($jan1_weekday - 1) - 1; - $weekday = 1 + intval(($h - 1) % 7); + $weekday = 1 + (int) (($h - 1) % 7); // find if Y M D falls in YearNumber Y-1, WeekNumber 52 or if ($day_of_year_number <= (8 - $jan1_weekday) && $jan1_weekday > 4){ $yearnumber = $year - 1; @@ -993,7 +990,7 @@ class BitDate { if ($yearnumber == $year) { $j = $day_of_year_number + (7 - $weekday) + ($jan1_weekday - 1); //$weeknumber = intval($j / 7) + 1; // kludge!!! - JMC - $weeknumber = intval($j / 7); // kludge!!! - JMC + $weeknumber = (int) ($j / 7); // kludge!!! - JMC if ($jan1_weekday > 4) { $weeknumber--; } @@ -1021,7 +1018,7 @@ class BitDate { $absoffset = abs($offset /= 60000); $plusminus = $offset < 0 ? '-' : '+'; - $gmtoff = sprintf("GMT%1s%02d:%02d", $plusminus, $absoffset / 60, $absoffset - intval($absoffset / 60) * 60); + $gmtoff = sprintf("GMT%1s%02d:%02d", $plusminus, $absoffset / 60, $absoffset - (int) ($absoffset / 60) * 60); $tzlongshort = $tz['longname'] . ' (' . $tz['shortname'] . ')'; $timezone_options[$tz_key] = sprintf('%-28.28s: %-36.36s %s', $tz_key, $tzlongshort, $gmtoff); } @@ -1076,7 +1073,7 @@ class BitDate { } $colon = $no_colon ? '' : ':'; - $mins = intval(($secs + 30) / 60); + $mins = (int) (($secs + 30) / 60); return sprintf("%s%02d%s%02d", $sign, $mins / 60, $colon, $mins % 60); } @@ -1207,7 +1204,7 @@ class BitDate { $timeZonesArray = [ 'GMT' => [ - 'GMT' => +0 // GMT + 'GMT' => +0, // GMT ], 'North America' => [ 'NST' => -3.5, // Newfoundland Standard Time @@ -1225,7 +1222,7 @@ class BitDate { 'AKST' => -9, // Alaska Standard Time 'AKDT' => -8, // Alaska Daylight Time 'HAST' => -10, // Hawaii-Aleutian Standard Time - 'HADT' => -9 // Hawaii-Aleutian Daylight Time + 'HADT' => -9, // Hawaii-Aleutian Daylight Time ], 'Australia' => [ 'NFT' => +11.5, // Norfolk (Island) Time @@ -1245,7 +1242,7 @@ class BitDate { 'CET' => +1, // Central European Time 'CEST' => +2, // Central European Summer Time 'EET' => +2, // Eastern European Time - 'EEST' => +3 // Eastern European Summer Time + 'EEST' => +3, // Eastern European Summer Time ], 'Military' => [ 'Z' => +0, // Zulu Time Zone @@ -1272,7 +1269,7 @@ class BitDate { 'I' => +9, // India Time Zone 'K' => +10, // Kilo Time Zone 'L' => +11, // Lima Time Zone - 'M' => +12 // Mike Time Zone + 'M' => +12, // Mike Time Zone ], ]; @@ -1285,7 +1282,7 @@ class BitDate { $retval = date( 'Y-m-d h:i:sa', $timeStamp + 3600 * $netDiff ); } - return $retval; + return $retval; } // end function calculateTimeZoneDate() diff --git a/includes/classes/BitDb.php b/includes/classes/BitDb.php index 51a1f75..8fc47d7 100755 --- a/includes/classes/BitDb.php +++ b/includes/classes/BitDb.php @@ -15,8 +15,7 @@ */ namespace Bitweaver; - use \Bitweaver\KernelTools; - + /** * ensure your AdoDB install is a subdirectory off your include path */ @@ -29,7 +28,6 @@ define( 'BIT_MAX_RECORDS', -1 ); global $gNumQueries; $gNumQueries = 0; - /** * This class is used for database access and provides a number of functions to help * with database portability. @@ -414,7 +412,6 @@ class BitDb { return []; } - /** Executes the SQL and returns all elements of the first column as a 1-dimensional array. The recordset is discarded for you automatically. If an error occurs, false is returned. * See AdoDB GetCol() function for more detail. * @param string pQuery the SQL query. Use backticks (`) to quote all table @@ -517,8 +514,8 @@ class BitDb { * at the location identified in updateId which holds a name and value entry * @param string updateTable Name of the table to be updated * @param array updateData Array of data to be changed. Array keys provide the field names - * If an array key contains an '=' it will assumed to already be properly quoted. - * This allows use of keys like this: `column_name` = `column_name` + ? + * If an array key contains an '=' it will assumed to already be properly quoted. + * This allows use of keys like this: `column_name` = `column_name` + ? * @param array updateId Array identifying the record to update. * Array key 'name' provide the field name, and 'value' the record key * @return array Error status of the insert @@ -781,7 +778,7 @@ class BitDb { */ public function OffsetDate( $pDays, $pColumn=null ) { // PURE VIRTUAL - return; + } /** Converts backtick (`) quotes to the appropriate quote for the @@ -834,9 +831,9 @@ class BitDb { $sql .= $this->convertSortmodeOneItem( $sortMode ); } return $sql; - } else { - return $this->convertSortmodeOneItem( $pSortMode ); } + return $this->convertSortmodeOneItem( $pSortMode ); + } /** @@ -969,8 +966,8 @@ class BitDb { global $gBitDbType; switch ( $gBitDbType ) { case "postgres": - $search = array(chr(92), chr(0), chr(39)); - $replace = array('\\\134', '\\\000', '\\\047'); + $search = [chr(92), chr(0), chr(39)]; + $replace = ['\\\134', '\\\000', '\\\047']; $ret = str_replace($search, $replace, $pData); break; default: @@ -1053,7 +1050,6 @@ class BitDb { return defined( 'ADVANCED_PGSQL' ); } - /** * determine current version of the databse * @return # hash including 'description', 'version' full string, 'major', 'minor', and 'revsion' @@ -1067,19 +1063,18 @@ class BitDb { return $ret; } - /** * Compatibility function for DBs with case insensitive searches * (like MySQL, see: http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html) * How to use: - * AND ".$this->mDb->getCaseLessColumn('lc.title')." = 'page title' - * The reason all this matters is that huge performane difference between: + * AND ".$this->mDb->getCaseLessColumn('lc.title')." = 'page title' + * The reason all this matters is that huge performane difference between: * where title = 'PAGE TITLE' * and * where UPPER(tittle) = 'PAGE TITTLE' - * The latter version will not make use of the index on page title (at least for MySQl) - * while the first vesion will use the index. In a case insensitive search DB (MySQL) both - * forms of the query will give the same results, the only difference being the preformance. + * The latter version will not make use of the index on page title (at least for MySQl) + * while the first vesion will use the index. In a case insensitive search DB (MySQL) both + * forms of the query will give the same results, the only difference being the preformance. * Spiderr suggested this solution and suppled the code below */ public function getCaselessColumn( $pColumn ) { diff --git a/includes/classes/BitDbAdodb.php b/includes/classes/BitDbAdodb.php index b45816d..bdc8efa 100755 --- a/includes/classes/BitDbAdodb.php +++ b/includes/classes/BitDbAdodb.php @@ -100,7 +100,7 @@ class BitDbAdodb extends BitDb { public function createTables( array $pTables, array $pOptions = [] ): bool { // If server support InnoDB for MySql set the selected engine if( isset( $_SESSION['use_innodb'] )) { - $pOptions = $_SESSION['use_innodb'] == true + $pOptions = $_SESSION['use_innodb'] == true ? [ ...$pOptions, 'MYSQL' => 'ENGINE=INNODB'] : [ ...$pOptions, 'MYSQL' => 'ENGINE=MYISAM']; } @@ -170,7 +170,7 @@ class BitDbAdodb extends BitDb { public function qstr( string $pStr ): string { return $this->mDb->qstr( $pStr ); } - + /** * Returns SUBSTRING function appropiate for database. * @return string using AdoDB->substr property @@ -194,7 +194,7 @@ class BitDbAdodb extends BitDb { */ public function random() { return $this->mDb->random; - + } /** Queries the database, returning an error if one occurs, rather @@ -211,8 +211,8 @@ class BitDbAdodb extends BitDb { */ public function queryError( string $pQuery, string &$pError, ?array $pValues = null, int $pNumRows = -1, int $pOffset = -1 ): array { $this->convertQuery( $pQuery ); - $result = $pNumRows == -1 && $pOffset == -1 - ? $this->mDb->Execute($pQuery, $pValues) + $result = $pNumRows == -1 && $pOffset == -1 + ? $this->mDb->Execute($pQuery, $pValues) : $this->mDb->SelectLimit($pQuery, $pNumRows, $pOffset, $pValues); if( !$result ) { @@ -252,8 +252,8 @@ class BitDbAdodb extends BitDb { } $result = $numrows == BIT_QUERY_DEFAULT && $offset == BIT_QUERY_DEFAULT - ? ( !$this->isCachingActive() || $pCacheTime == BIT_QUERY_DEFAULT - ? $this->mDb->Execute( $query, $values ) + ? ( !$this->isCachingActive() || $pCacheTime == BIT_QUERY_DEFAULT + ? $this->mDb->Execute( $query, $values ) : $this->mDb->CacheExecute( $pCacheTime, $query, $values ) ) : ( !$this->isCachingActive() || $pCacheTime == BIT_QUERY_DEFAULT ? $this->mDb->SelectLimit( $query, $numrows, $offset, $values ) @@ -308,7 +308,7 @@ class BitDbAdodb extends BitDb { } $this->queryStart(); $this->convertQuery( $pQuery ); - $result = !$this->isCachingActive() || $pCacheTime == BIT_QUERY_DEFAULT + $result = !$this->isCachingActive() || $pCacheTime == BIT_QUERY_DEFAULT ? $this->mDb->GetAll( $pQuery, $pValues ) : $this->mDb->CacheGetAll($pCacheTime, $pQuery, $pValues ); //count the number of queries made @@ -641,7 +641,7 @@ function bitdb_error_handler( $dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConne 'errno'=>$errno, 'db_msg'=>$errmsg, 'sql'=>$p1, - 'p2'=>$p2 + 'p2'=>$p2, ]; $logString = bit_error_string( $dbParams ); @@ -660,7 +660,7 @@ function bitdb_error_handler( $dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConne * 3 message is appended to the file destination */ error_log( $logString,0 ); - $subject = isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : 'BITWEAVER'; + $subject = $_SERVER['SERVER_NAME'] ?? 'BITWEAVER'; $fatal = false; if(( $fn == 'EXECUTE' ) && ( $thisConnection->MetaError() != -5 ) && (empty( $gBitDb ) || $gBitDb->isFatalActive()) ) { diff --git a/includes/classes/BitDbPear.php b/includes/classes/BitDbPear.php index 0230542..6fdcddc 100755 --- a/includes/classes/BitDbPear.php +++ b/includes/classes/BitDbPear.php @@ -40,20 +40,20 @@ class BitDbPear extends BitDb if( empty( $pPearDsn ) ) { global $gBitDbType, $gBitDbUser, $gBitDbPassword, $gBitDbHost, $gBitDbName; - $pPearDsn = array( + $pPearDsn = [ 'phptype' => $gBitDbType, 'username' => $gBitDbUser, 'password' => $gBitDbPassword , 'database' => $gBitDbHost.'/'.$gBitDbName, - ); + ]; } if( empty( $pPearOptions ) ) { - $pPearOptions = array( + $pPearOptions = [ 'debug' => 2, 'persistent' => false, 'portability' => DB_PORTABILITY_ALL, - ); + ]; } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'bit_pear_login_error' ); @@ -63,11 +63,11 @@ class BitDbPear extends BitDb if( PEAR::isError( $this->mDb ) ) { $this->mErrors['db_connect'] = $this->mDb->getDebugInfo(); } else { - + $this->mDb->setFetchMode( DB_FETCHMODE_ASSOC ); // Default to autocommit unless StartTrans is called $this->mDb->autoCommit( TRUE ); - + $this->mType = $pPearDsn['phptype']; $this->mName = $pPearDsn['database']; } @@ -182,7 +182,7 @@ class BitDbPear extends BitDb * @todo not currently used anywhere */ - function getCol( $pQuery, $pValues=array(), $pTrim=FALSE ) + function getCol( $pQuery, $pValues=[], $pTrim=FALSE ) { if( empty( $this->mDb ) ) { return FALSE; @@ -238,7 +238,7 @@ class BitDbPear extends BitDb * @param pFirst2Cols if set to true, only returns the first two columns * @return the associative array, or false if an error occurs */ - function getAssoc( $pQuery, $pValues=array(), $pForceArray=FALSE, $pFirst2Cols=FALSE, $pCacheTime=BIT_QUERY_DEFAULT ) + function getAssoc( $pQuery, $pValues=[], $pForceArray=FALSE, $pFirst2Cols=FALSE, $pCacheTime=BIT_QUERY_DEFAULT ) { if( empty( $this->mDb ) ) { return FALSE; @@ -431,7 +431,7 @@ class BitDbPear extends BitDb */ function MetaTables( $ttype = false, $showSchema = false, $mask=false ) { error_log( '$gForceAdodb = TRUE; is needed on the page: '.$_SERVER['SCRIPT_FILENAME'] ); - return array(); + return []; } /** @@ -445,11 +445,11 @@ class BitDbPear extends BitDb // This function will handle all errors function bit_pear_error_handler( $error_obj ) { $bindVars = !empty( $error_obj->backtrace[0]['object']->backtrace[2]['object']->_data ) ? $error_obj->backtrace[0]['object']->backtrace[2]['object']->_data : NULL; - $dbParams = array( + $dbParams = [ 'errno' => $error_obj->getCode(), 'db_msg'=> $error_obj->getMessage(), 'sql'=> $error_obj->getDebugInfo()." ('".implode( "','", $bindVars )."')", - ); + ]; $logString = bit_error_string( $dbParams ); bit_display_error( $logString, $dbParams['db_msg'] ); diff --git a/includes/classes/BitLogger.php b/includes/classes/BitLogger.php index 28a52af..b0da3da 100644 --- a/includes/classes/BitLogger.php +++ b/includes/classes/BitLogger.php @@ -57,7 +57,7 @@ class BitLogger { self::WARNING, self::NOTICE, self::INFO, - self::DEBUG + self::DEBUG, ]; // Validate log level diff --git a/includes/classes/BitMailer.php b/includes/classes/BitMailer.php index 8d40c50..9ef0e6a 100755 --- a/includes/classes/BitMailer.php +++ b/includes/classes/BitMailer.php @@ -29,7 +29,6 @@ /** * Initialization */ -use Bitweaver\KernelTools; use Bitweaver\Liberty\LibertyBase; /** @@ -48,15 +47,15 @@ use Bitweaver\Liberty\LibertyBase; * $pBody - The Body of the Email * $pRecipients - An associative array with keys for email and optionally login and real_name **/ - function sendEmail($pSubject, $pBody, $pRecipients, $pHeaders=array() ){ + function sendEmail($pSubject, $pBody, $pRecipients, $pHeaders=[] ){ global $gBitSystem; $message = $pHeaders; $message['subject'] = $pSubject; - if( is_string( $pBody ) ){ - $message['message'] = $pBody; - }elseif( is_array( $pBody ) ){ - $message = array_merge( $message, $pBody ); - } + if( is_string( $pBody ) ){ + $message['message'] = $pBody; + }elseif( is_array( $pBody ) ){ + $message = array_merge( $message, $pBody ); + } $mailer = $this->buildMailer($message); if( is_string( $pRecipients ) ) { @@ -148,5 +147,4 @@ use Bitweaver\Liberty\LibertyBase; return $mailer; } - } diff --git a/includes/classes/BitSystem.php b/includes/classes/BitSystem.php index 5b6bb5f..034912c 100755 --- a/includes/classes/BitSystem.php +++ b/includes/classes/BitSystem.php @@ -18,10 +18,9 @@ */ namespace Bitweaver; + use Bitweaver\Users\BitHybridAuthManager; use Bitweaver\Wiki\BitPage; -use Bitweaver\KernelTools; -use Bitweaver\Users\RolePermUser; /** * required setup @@ -102,11 +101,11 @@ class BitSystem extends BitSingleton { public$mRequirements = []; public $mServerTimestamp; public $mTimer; - + // Output http status public $mHttpStatus = HttpStatusCodes::HTTP_OK; - protected static $singleton = null; + protected static $singleton = null; protected static function getSingleInstance() { return static::$singleton; } @@ -191,8 +190,6 @@ class BitSystem extends BitSingleton { return $ret; } - - /** * Load all preferences and store them in $this->mConfig * @@ -411,11 +408,10 @@ class BitSystem extends BitSingleton { mail($pMailHash['email'], $pMailHash['subject'].' '.$_SERVER["SERVER_NAME"], $pMailHash['body'], - "From: ".$fromEmail."\r\nContent-type: text/plain;charset=utf-8\r\n$extraHeaders" + "From: ".$fromEmail."\r\nContent-type: text/plain;charset=utf-8\r\n$extraHeaders", ); } - /** * Set the http status, most notably for 404 not found for deleted content * @@ -426,7 +422,6 @@ class BitSystem extends BitSingleton { $this->mHttpStatus = $pHttpStatus; } - public function outputHeader() { // Add the user to an apache ENV variable so it can be logged, like: // LogFormat "%V %h %l %{USERID}e %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Cookie}n\"" combinedcookie @@ -486,7 +481,7 @@ class BitSystem extends BitSingleton { public function display( $pMid, $pBrowserTitle = null, $pOptionsHash = [] ) { global $gBitSmarty, $gBitThemes, $gContent; $gBitSmarty->verifyCompileDir(); - + $this->outputHeader(); if( $this->mHttpStatus != 200 ) { // error_log( "HTTP/1.0 ".HttpStatusCodes::getMessageForCode( $this->mHttpStatus )." http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ); @@ -520,7 +515,7 @@ class BitSystem extends BitSingleton { } if( !empty( $pBrowserTitle )) { - $this->setBrowserTitle( $pBrowserTitle ); + $this->setBrowserTitle( $pBrowserTitle ); } // populate meta description with something useful so you are not penalized/ignored by web crawlers @@ -550,7 +545,6 @@ class BitSystem extends BitSingleton { $this->postDisplay( $pMid ); } - // === preDisplay /** * Take care of any processing that needs to happen just before the template is displayed @@ -858,7 +852,7 @@ class BitSystem extends BitSingleton { if( $pFeatureName ) { $featureValue = $this->getConfig($pFeatureName); $ret = empty($setting) - ? !empty( $featureValue ) && ( $featureValue != 'n' ) + ? !empty( $featureValue ) && ( $featureValue != 'n' ) : !empty( $featureValue ) && ( $featureValue == $setting ); } return $ret; @@ -929,10 +923,10 @@ class BitSystem extends BitSingleton { if( !defined( $pkgDefine )) { $pkgPath = BIT_ROOT_PATH . basename( $path ) . '/'; define( $pkgDefine, $pkgPath ); - $arrayHash = [ - $pkgName.'_PKG_INCLUDE_PATH' => BIT_ROOT_PATH . basename( $path ) . '/includes/', + $arrayHash = [ + $pkgName.'_PKG_INCLUDE_PATH' => BIT_ROOT_PATH . basename( $path ) . '/includes/', $pkgName.'_PKG_CLASS_PATH' => BIT_ROOT_PATH . basename( $path ) . '/includes/classes/', - $pkgName.'_PKG_ADMIN_PATH' => BIT_ROOT_PATH . basename( $path ) . '/admin/' + $pkgName.'_PKG_ADMIN_PATH' => BIT_ROOT_PATH . basename( $path ) . '/admin/', ]; foreach( $arrayHash as $defName => $defPath ) { if( !defined( $defName )) { @@ -961,7 +955,7 @@ class BitSystem extends BitSingleton { $pkgDefine = $pkgName.'_PKG_NAME'; if( !defined( $pkgDefine )) { define( $pkgDefine, $name ); - $this->mPackages[$pkgNameKey]['activatable'] = isset( $pRegisterHash['activatable'] ) ? $pRegisterHash['activatable'] : true; + $this->mPackages[$pkgNameKey]['activatable'] = $pRegisterHash['activatable'] ?? true; } $this->mPackages[$pkgNameKey]['name'] = $name; @@ -1031,9 +1025,9 @@ class BitSystem extends BitSingleton { $pMenuHash['menu_title'] = $this->getConfig( $pkg.'_menu_text', !empty( $pMenuHash['menu_title'] ) ? $pMenuHash['menu_title'] - : ucfirst( constant( strtoupper( $pkg ).'_PKG_DIR' ))); - $pMenuHash['menu_position'] = $this->getConfig( $pkg.'_menu_position', - $pMenuHash['menu_position'] ?? ''); + : ucfirst( constant( strtoupper( $pkg ).'_PKG_DIR' )), ); + $pMenuHash['menu_position'] = $this->getConfig( $pkg.'_menu_position', + $pMenuHash['menu_position'] ?? '', ); $this->mAppMenu[$menuType][$pkg] = $pMenuHash; } else { @@ -1044,7 +1038,7 @@ class BitSystem extends BitSingleton { 'index_url' => $pTitleUrl, 'menu_template' => $pMenuTemplate, 'admin_panel' => $pAdminPanel, - 'style' => 'display:' . ( empty( $pMenuTitle ) || ( isset( $_COOKIE[$pMenuHash . 'menu'] ) && ( $_COOKIE[$pMenuHash . 'menu'] == 'o' ) ) ? 'block;' : 'none;' ) + 'style' => 'display:' . ( empty( $pMenuTitle ) || ( isset( $_COOKIE[$pMenuHash . 'menu'] ) && ( $_COOKIE[$pMenuHash . 'menu'] == 'o' ) ) ? 'block;' : 'none;' ), ]; } uasort( $this->mAppMenu[$menuType], 'Bitweaver\bit_system_menu_sort' ); @@ -1183,7 +1177,7 @@ class BitSystem extends BitSingleton { if( !empty( $gPreScan ) && \is_array( $gPreScan )) { // gPreScan may hold a list of packages that must be loaded first foreach( $gPreScan as $pkgDir ) { - $loadPkgs[] = $pkgDir; + $loadPkgs[] = $pkgDir; } } // load lib configs @@ -1198,10 +1192,9 @@ class BitSystem extends BitSingleton { // load the list of pkgs in the right order foreach( $loadPkgs as $loadPkg ) { - $this->loadPackage( $loadPkg, $pScanFile, $pAutoRegister, $pOnce ); + $this->loadPackage( $loadPkg, $pScanFile, $pAutoRegister, $pOnce ); } - if( !defined( 'BIT_STYLES_PATH' ) && defined( 'THEMES_PKG_PATH' )) { define( 'BIT_STYLES_PATH', THEMES_PKG_PATH.'styles/' ); } @@ -1301,8 +1294,8 @@ class BitSystem extends BitSingleton { $users_homepage = $gBitUser->getPreference( 'users_homepage' ); if( isset( $users_homepage ) && !empty( $users_homepage )) { $home = [ 'title' => $users_homepage]; - $url = strpos($users_homepage, '/') === false - ? BitPage::getDisplayUrlFromHash( $home ) + $url = strpos($users_homepage, '/') === false + ? BitPage::getDisplayUrlFromHash( $home ) : $users_homepage; } } @@ -1340,7 +1333,7 @@ class BitSystem extends BitSingleton { if( strpos( $url, 'http://' ) === false ) { $url = preg_replace( "#//#", "/", $url ); } - + return $url; } // === setOnloadScript @@ -1403,7 +1396,7 @@ class BitSystem extends BitSingleton { global $gBitSmarty; if( !empty( $pListInfo['total_pages'] ) && !empty( $pListInfo['page_records'] ) ) { $relTags = ""; - $baseUrl = isset( $pListInfo['url'] ) ? $pListInfo['url'] : $_SERVER['SCRIPT_URL']; + $baseUrl = $pListInfo['url'] ?? $_SERVER['SCRIPT_URL']; if( !empty( $pListInfo['query_string'] ) ) { $pageUrl = $baseUrl.'?'.$pListInfo['query_string']; @@ -1460,7 +1453,7 @@ class BitSystem extends BitSingleton { */ public function setCanonicalLink( $pRelativeUrl ) { global $gBitSmarty; - $baseUri = defined( 'CANONICAL_BASE_URI' ) ? CANONICAL_BASE_URI : BIT_BASE_URI; + $baseUri = defined( 'CANONICAL_BASE_URI' ) ? CANONICAL_BASE_URI : BIT_BASE_URI; $gBitSmarty->assign( 'canonicalLink', $baseUri.$pRelativeUrl ); } @@ -1572,7 +1565,6 @@ class BitSystem extends BitSingleton { return [ $ret, $verifyMime ]; } - // === verifyMimeType /** * given a file, return the mime type @@ -1585,8 +1577,8 @@ class BitSystem extends BitSingleton { $mime = null; if( file_exists( $pFile ) && filesize( $pFile ) ) { if( function_exists( 'finfo_open' ) ) { - $finfo = KernelTools::is_windows() && defined( 'PHP_MAGIC_PATH' ) && is_readable( PHP_MAGIC_PATH ) - ? finfo_open( FILEINFO_MIME, PHP_MAGIC_PATH ) + $finfo = KernelTools::is_windows() && defined( 'PHP_MAGIC_PATH' ) && is_readable( PHP_MAGIC_PATH ) + ? finfo_open( FILEINFO_MIME, PHP_MAGIC_PATH ) : finfo_open( FILEINFO_MIME ); $mime = finfo_file( $finfo, $pFile ); finfo_close( $finfo ); @@ -1693,12 +1685,12 @@ class BitSystem extends BitSingleton { $docroot = BIT_ROOT_PATH; $serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? ''; - + if( stripos( $serverSoftware, 'nginx' ) !== false ) { $this->setConfig( 'site_server_type', 'nginx' ); } elseif( stripos( $serverSoftware, 'apache' ) !== false ) { // Check if mod_xsendfile is actually loaded - if( function_exists( 'apache_get_modules' ) && + if( function_exists( 'apache_get_modules' ) && \in_array( 'mod_xsendfile', apache_get_modules() )) { $this->setConfig( 'site_server_type', 'apache_xsendfile' ); } else { @@ -1929,7 +1921,7 @@ class BitSystem extends BitSingleton { $this->mPermHash[$perm[0]] = $perm; $this->mPermHash[$perm[0]]['sql'] = "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `perm_level`, `package`) VALUES ('$perm[0]', '$perm[1]', '$perm[2]', '$perm[3]')"; $this->registerSchemaDefault( $pPackagedir, - "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `perm_level`, `package`) VALUES ('$perm[0]', '$perm[1]', '$perm[2]', '$perm[3]')"); + "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `perm_level`, `package`) VALUES ('$perm[0]', '$perm[1]', '$perm[2]', '$perm[3]')", ); } } @@ -1944,7 +1936,7 @@ class BitSystem extends BitSingleton { public function registerConfig( $pPackagedir, $pPreferences ) { foreach( $pPreferences as $pref ) { $this->registerSchemaDefault( $pPackagedir, - "INSERT INTO `".BIT_DB_PREFIX."kernel_config`(`package`,`config_name`,`config_value`) VALUES ('$pref[0]', '$pref[1]','$pref[2]')"); + "INSERT INTO `".BIT_DB_PREFIX."kernel_config`(`package`,`config_name`,`config_value`) VALUES ('$pref[0]', '$pref[1]','$pref[2]')", ); } } @@ -2382,7 +2374,7 @@ class BitSystem extends BitSingleton { 'color' => $edgecolor, 'fontcolor' => $edgecolor, 'label' => $label, - ]) + ]), ); } @@ -2391,7 +2383,7 @@ class BitSystem extends BitSingleton { } else { return $graph->fetch( $pFormat, $pCommand ); } - } + } return false; } @@ -2622,7 +2614,7 @@ class BitSystem extends BitSingleton { $error['number'] = 0; $error['string'] = $data = ''; -// https://www.bitweaver.org/bitversion.txt is no longer available +// https://www.bitweaver.org/bitversion.txt is no longer available // cache the bitversion.txt file locally and update only once a day // if you don't have a connection to bitweaver.org, you can set a cronjob to 'touch' this file once a day to avoid waiting for a timeout. /* if( !is_file( TEMP_PKG_PATH.'bitversion.txt' ) || ( time() - filemtime( TEMP_PKG_PATH.'bitversion.txt' )) > 86400 ) { diff --git a/includes/classes/HttpStatusCodes.php b/includes/classes/HttpStatusCodes.php index 0479ea7..434ee9f 100755 --- a/includes/classes/HttpStatusCodes.php +++ b/includes/classes/HttpStatusCodes.php @@ -10,7 +10,7 @@ */ namespace Bitweaver; - + class HttpStatusCodes { // [Informational 1xx] const HTTP_CONTINUE = 100; @@ -59,8 +59,8 @@ class HttpStatusCodes { const HTTP_SERVICE_UNAVAILABLE = 503; const HTTP_GATEWAY_TIMEOUT = 504; const HTTP_VERSION_NOT_SUPPORTED = 505; - - private static $messages = array( + + private static $messages = [ // [Informational 1xx] 100=>'100 Continue', 101=>'101 Switching Protocols', @@ -106,20 +106,20 @@ class HttpStatusCodes { 502=>'502 Bad Gateway', 503=>'503 Service Unavailable', 504=>'504 Gateway Timeout', - 505=>'505 HTTP Version Not Supported' - ); - + 505=>'505 HTTP Version Not Supported', + ]; + public static function httpHeaderFor($code) { return 'HTTP/1.1 ' . static::$messages[$code]; } public static function getMessageForCode($code) { return static::$messages[$code]; } - + public static function isError($code) { return is_numeric($code) && $code >= static::HTTP_BAD_REQUEST; } - + public static function canHaveBody($code) { return // True if not in 100s diff --git a/includes/classes/KernelTools.php b/includes/classes/KernelTools.php index e08b474..3d454dd 100755 --- a/includes/classes/KernelTools.php +++ b/includes/classes/KernelTools.php @@ -5,822 +5,819 @@ * @subpackage functions */ namespace Bitweaver; + define( 'EMAIL_ADDRESS_REGEX', '[-a-zA-Z0-9._%+]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}' ); class KernelTools { - public function __construct() { - mb_internal_encoding( "UTF-8" ); + public function __construct() { + mb_internal_encoding( "UTF-8" ); + + } - } + /** + * 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 bool|string system defined temporary directory. + */ + public static function get_temp_dir():bool|string { + static $tempdir; + if( !$tempdir ) { + global $gTempDir; + if( !empty( $gTempDir ) ) { + $tempdir = $gTempDir; + } else { + if( !KernelTools::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; + } - /** - * 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 bool|string system defined temporary directory. - */ - public static function get_temp_dir():bool|string { - static $tempdir; - if( !$tempdir ) { - global $gTempDir; - if( !empty( $gTempDir ) ) { - $tempdir = $gTempDir; - } else { - if( !KernelTools::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 bool true if we are on windows, false otherwise + */ + public static function is_windows(): bool { + static $sWindows; + if( !isset( $sWindows )) { + $sWindows = substr( PHP_OS, 0, 3 ) == 'WIN'; + } + return $sWindows; + } - /** - * is_windows - * - * @access public - * @return bool true if we are on windows, false otherwise - */ - public static function is_windows(): bool { - 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 bool true if file exists and is non zero, false on failure + */ + public static function file_valid( $pFile ) { + return file_exists( $pFile ) && filesize( $pFile ); + } - /** - * Determines if file exists and is non zero - * - * @param string $pFile target file - * @access public - * @return bool true if file exists and is non zero, false on failure - */ - public static 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 + */ + public static function int32( $pInt ) { + return (int)$pInt & 0xFFFFFFFF; + } - /** - * 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 - */ - public static function int32( $pInt ) { - return (int)$pInt & 0xFFFFFFFF; - } + /** + * Recursively create directories + * + * @param string $pTarget target directory + * @param float $pPerms octal permissions + * @access public + * @return bool true on success, false on failure - mErrors will contain reason for failure + */ + public static function mkdir_p( string $pTarget, float $pPerms = 0755 ): bool { + // clean up input + $pTarget = str_replace( "//", "/", trim( $pTarget )); - /** - * Recursively create directories - * - * @param string $pTarget target directory - * @param float $pPerms octal permissions - * @access public - * @return bool true on success, false on failure - mErrors will contain reason for failure - */ - public static function mkdir_p( string $pTarget, float $pPerms = 0755 ): bool { - // clean up input - $pTarget = str_replace( "//", "/", trim( $pTarget )); + if( empty( $pTarget ) || $pTarget == ';' || $pTarget == "/" ) { + return false; + } - if( empty( $pTarget ) || $pTarget == ';' || $pTarget == "/" ) { - return false; - } + if( ini_get( 'safe_mode' )) { + $pTarget = preg_replace( '/^\/tmp/', $_SERVER['DOCUMENT_ROOT'].'/temp', $pTarget ); + } - if( ini_get( 'safe_mode' )) { - $pTarget = preg_replace( '/^\/tmp/', $_SERVER['DOCUMENT_ROOT'].'/temp', $pTarget ); - } + if( file_exists( $pTarget ) ) { + return is_dir( $pTarget ); + } - if( file_exists( $pTarget ) ) { - return is_dir( $pTarget ); - } + if( !KernelTools::is_windows() ) { + if( substr( $pTarget, 0, 1 ) != '/' ) { + $pTarget = "/$pTarget"; + } - if( !KernelTools::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 ); - 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; + } - 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 string $pPath path to file or dir + * @access public + * @return bool true on success, false on failure + */ + public static function bw_is_writeable( $pPath ): bool { + if( !KernelTools::is_windows() ) { + return is_writeable( $pPath ); + } + $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; - /** - * 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 string $pPath path to file or dir - * @access public - * @return bool true on success, false on failure - */ - public static function bw_is_writeable( $pPath ): bool { - if( !KernelTools::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 bool $pHtml set true to escape HTML code as well - * @param bool $pUrldecode set true to urldecode as well - * @access public - * @return void - */ - public static function detoxify( array &$pParamHash, bool $pHtml = false, bool $pUrldecode = true): void { - if( !empty( $pParamHash ) && is_array( $pParamHash ) ) { - foreach( $pParamHash as $key => $value ) { - if( isset( $value ) && is_array( $value ) ) { - KernelTools::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] ); - } - } - } - } - } + /** + * 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 bool $pHtml set true to escape HTML code as well + * @param bool $pUrldecode set true to urldecode as well + * @access public + * @return void + */ + public static function detoxify( array &$pParamHash, bool $pHtml = false, bool $pUrldecode = true): void { + if( !empty( $pParamHash ) && is_array( $pParamHash ) ) { + foreach( $pParamHash as $key => $value ) { + if( isset( $value ) && is_array( $value ) ) { + KernelTools::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 string clean file name that can be used as title - */ - public static function file_name_to_title( $pFileName ): string { - 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, '.' ) ) ); - } + /** + * file_name_to_title + * + * @param string $pFileName + * @access public + * @return string clean file name that can be used as title + */ + public static function file_name_to_title( $pFileName ): string { + 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 string A valid url based on the given path - */ - public static 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 )))); - } + /** + * path_to_url + * + * @param string $pPath Relative path starting in the bitweaver root directory + * @access public + * @return string A valid url based on the given path + */ + public static 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 string $pReplace code that needs replacing - * @return void - */ - public static function deprecated( ?string $pReplace = null ): void { - $trace = debug_backtrace(); - $function = !empty( $trace[1]['class'] ) ? $trace[1]['class']."::".$trace[1]['function'] : $trace[1]['function']; - $out = "Deprecated function call:\n\tfunction: $function()\n\tfile: ".$trace[1]['file']."\n\tline: ".$trace[1]['line']; + /** + * simple function to include in deprecated function calls. makes the developer replace with newer code + * + * @param string $pReplace code that needs replacing + * @return void + */ + public static function deprecated( ?string $pReplace = null ): void { + $trace = debug_backtrace(); + $function = !empty( $trace[1]['class'] ) ? $trace[1]['class']."::".$trace[1]['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( !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 ); - } - } + 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 bool true if function is enabled on server, false otherwise - */ - public static function function_enabled ( $pName ) { - static $disabled = null; + /** + * Check that function is enabled on server. + * @access public + * @return bool true if function is enabled on server, false otherwise + */ + public static function function_enabled ( $pName ) { + static $disabled = null; - if( $disabled == null ) { - $functions = @ini_get( 'disable_functions' ); - $functions = str_replace( ' ', '', $functions ); - $disabled = explode( ',', $functions ); - } + if( $disabled == null ) { + $functions = @ini_get( 'disable_functions' ); + $functions = str_replace( ' ', '', $functions ); + $disabled = explode( ',', $functions ); + } - return !( in_array( $pName, $disabled )); - } + return !( in_array( $pName, $disabled )); + } + public static function verify_hex_color( $pColor ) { + $ret = null; - public static 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; - } + 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 string $pData string that might contain an email address + * @access public + * @return string encoded email address + * $note email regex taken from: http://www.regular-expressions.info/regexbuddy/email.html + */ + public static function encode_email_addresses( $pData ) { + $trans = [ + // Upper case + 'A' => 'A', + 'B' => 'B', + 'C' => 'C', + 'D' => 'D', + 'E' => 'E', + 'F' => 'F', + 'G' => 'G', + 'H' => 'H', + 'I' => 'I', + 'J' => 'J', + 'K' => 'K', + 'L' => 'L', + 'M' => 'M', + 'N' => 'N', + 'O' => 'O', + 'P' => 'P', + 'Q' => 'Q', + 'R' => 'R', + 'S' => 'S', + 'T' => 'T', + 'U' => 'U', + 'V' => 'V', + 'W' => 'W', + 'X' => 'X', + 'Y' => 'Y', + 'Z' => 'Z', - /** - * html encode all characters - * taken from: http://www.bbsinc.com/iso8859.html - * - * @param string $pData string that might contain an email address - * @access public - * @return string encoded email address - * $note email regex taken from: http://www.regular-expressions.info/regexbuddy/email.html - */ - public static function encode_email_addresses( $pData ) { - $trans = [ - // Upper case - 'A' => 'A', - 'B' => 'B', - 'C' => 'C', - 'D' => 'D', - 'E' => 'E', - 'F' => 'F', - 'G' => 'G', - 'H' => 'H', - 'I' => 'I', - 'J' => 'J', - 'K' => 'K', - 'L' => 'L', - 'M' => 'M', - 'N' => 'N', - 'O' => 'O', - 'P' => 'P', - 'Q' => 'Q', - 'R' => 'R', - 'S' => 'S', - 'T' => 'T', - 'U' => 'U', - 'V' => 'V', - 'W' => 'W', - 'X' => 'X', - 'Y' => 'Y', - 'Z' => 'Z', + // lower case + 'a' => 'a', + 'b' => 'b', + 'c' => 'c', + 'd' => 'd', + 'e' => 'e', + 'f' => 'f', + 'g' => 'g', + 'h' => 'h', + 'i' => 'i', + 'j' => 'j', + 'k' => 'k', + 'l' => 'l', + 'm' => 'm', + 'n' => 'n', + 'o' => 'o', + 'p' => 'p', + 'q' => 'q', + 'r' => 'r', + 's' => 's', + 't' => 't', + 'u' => 'u', + 'v' => 'v', + 'w' => 'w', + 'x' => 'x', + 'y' => 'y', + 'z' => 'z', - // lower case - 'a' => 'a', - 'b' => 'b', - 'c' => 'c', - 'd' => 'd', - 'e' => 'e', - 'f' => 'f', - 'g' => 'g', - 'h' => 'h', - 'i' => 'i', - 'j' => 'j', - 'k' => 'k', - 'l' => 'l', - 'm' => 'm', - 'n' => 'n', - 'o' => 'o', - 'p' => 'p', - 'q' => 'q', - 'r' => 'r', - 's' => 's', - 't' => 't', - 'u' => 'u', - 'v' => 'v', - 'w' => 'w', - 'x' => 'x', - 'y' => 'y', - 'z' => 'z', + // digits + '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5', + '6' => '6', + '7' => '7', + '8' => '8', + '9' => '9', - // digits - '0' => '0', - '1' => '1', - '2' => '2', - '3' => '3', - '4' => '4', - '5' => '5', - '6' => '6', - '7' => '7', - '8' => '8', - '9' => '9', + // special chars + '_' => '_', + '-' => '-', + '.' => '.', + '@' => '@', - // special chars - '_' => '_', - '-' => '-', - '.' => '.', - '@' => '@', + //'[' => '[', + //']' => ']', + //'|' => '|', + //'{' => '{', + //'}' => '}', + //'~' => '~', + ]; + 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 ); + } - //'[' => '[', - //']' => ']', - //'|' => '|', - //'{' => '{', - //'}' => '}', - //'~' => '~', - ]; - 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; + } - return $pData; - } + /** + * validate email syntax + * php include as a string + * + * @param $pEmail the file to include + * @return string A string with the results of the file + **/ + public static function validate_email_syntax( $pEmail ) { + return preg_match( "!^".EMAIL_ADDRESS_REGEX."$!", trim( $pEmail )); + } - /** - * validate email syntax - * php include as a string - * - * @param $pEmail the file to include - * @return string A string with the results of the file - **/ - public static 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 string A string with the results of the file + **/ + public static 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; + } - /** - * get_include_contents -- handy function for getting the contents of a - * php include as a string - * - * @param $pFile the file to include - * @return string A string with the results of the file - **/ - public static 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 string + */ + public static function tra( $pString ) { + global $gBitLanguage; + return $gBitLanguage->translate( $pString ); + } - /** - * Translate a string - * - * @param string $pString String that needs to be translated - * @access public - * @return string - */ - public static 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 bool true on success, false on failure + */ + public static 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 != '..' ) { + KernelTools::unlink_r( "$pPath/$entry" ) ; + } + } + closedir( $dir ) ; + } + return @rmdir( $pPath ); + } + return false; + } - /** - * recursively remove files and directories - * - * @param string $pPath directory we want to remove - * @param boolean $pFollowLinks follow symlinks or not - * @access public - * @return bool true on success, false on failure - */ - public static 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 != '..' ) { - KernelTools::unlink_r( "$pPath/$entry" ) ; - } - } - closedir( $dir ) ; - } - return @rmdir( $pPath ); - } - return false; - } + /** + * recursively copy the contents of a directory to a new location akin to copy -r + * + * @param string $pSource source directory + * @param string $pTarget target directory + * @access public + * @return void + */ + public static function copy_r( $pSource, $pTarget ) { + if( is_dir( $pSource )) { + @KernelTools::mkdir_p( $pTarget ); + $d = dir( $pSource ); - /** - * recursively copy the contents of a directory to a new location akin to copy -r - * - * @param string $pSource source directory - * @param string $pTarget target directory - * @access public - * @return void - */ - public static function copy_r( $pSource, $pTarget ) { - if( is_dir( $pSource )) { - @KernelTools::mkdir_p( $pTarget ); - $d = dir( $pSource ); + while( false !== ( $entry = $d->read() )) { + if( $entry == '.' || $entry == '..' ) { + continue; + } - while( false !== ( $entry = $d->read() )) { - if( $entry == '.' || $entry == '..' ) { - continue; - } + $source = $pSource.'/'.$entry; + if( is_dir( $source )) { + KernelTools::copy_r( $source, $pTarget.'/'.$entry ); + continue; + } + copy( $source, $pTarget.'/'.$entry ); + } - $source = $pSource.'/'.$entry; - if( is_dir( $source )) { - KernelTools::copy_r( $source, $pTarget.'/'.$entry ); - continue; - } - copy( $source, $pTarget.'/'.$entry ); - } + $d->close(); + } else { + copy( $pSource, $pTarget ); + } + } - $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 + */ + public static function bit_http_request( $pUrl, $pNoCurl = false ) { + global $gBitSystem; + $ret = false; - /** - * 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 - */ - public static function bit_http_request( $pUrl, $pNoCurl = false ) { - global $gBitSystem; - $ret = false; + if( !empty( $pUrl )) { + $pUrl = trim( $pUrl ); - if( !empty( $pUrl )) { - $pUrl = trim( $pUrl ); + // rewrite url if sloppy # added a case for https urls + if( !preg_match( "!^https?://!", $pUrl )) { + $pUrl = "http://".$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; + } - 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 ); - // 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); + } - // 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" ); - $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; + } + } + } + } - $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; + } - 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 string $pString XML type string of parameters + * @access public + * @return array + */ + public static function parse_xml_attributes( string $pString ): array { + //$parameters = [ '', '' ]; + $parameters = []; + $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; + } - /** - * 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 string $pString XML type string of parameters - * @access public - * @return array - */ - public static function parse_xml_attributes( string $pString ): array { - //$parameters = [ '', '' ]; - $parameters = []; - $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 string $string + * @param int $quote_style + * @access public + * @return string + */ + public static function xmlentities( string $string, int $quote_style=ENT_QUOTES ): string { + static $trans; + if( !isset( $trans )) { + $trans = get_html_translation_table( HTML_ENTITIES, $quote_style ); + foreach( $trans as $key => $value ) { + $trans[$key] = '&#'.ord( $key ).';'; + } - /** - * XML Entity Mandatory Escape Characters - * - * @param string $string - * @param int $quote_style - * @access public - * @return string - */ - public static function xmlentities( string $string, int $quote_style=ENT_QUOTES ): string { - 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)] = '&'; + } - // dont translate the '&' in case it is part of &xxx; - $trans[chr(38)] = '&'; - } + // after the initial translation, _do_ map standalone '&' into '&' + return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/","&" , strtr( $string, $trans )); + } - // after the initial translation, _do_ map standalone '&' into '&' - return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/","&" , strtr( $string, $trans )); - } + /** + * Redirect to another page or site + * @param string The url to redirect to + */ + public static function bit_redirect( $pUrl, $pStatusCode=HttpStatusCodes::HTTP_FOUND ) { + // Handle non-3xx codes separately + if( $pStatusCode && isset( $errors[$pStatusCode] ) ) { + header( HttpStatusCodes::httpHeaderFor( $pStatusCode ) ); + $pStatusCode = null; + } - /** - * Redirect to another page or site - * @param string The url to redirect to - */ - public static 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 $gBitUser; + if( is_object( $gBitUser ) ) { + // apache_setenv( 'USERID', $gBitUser->getField('login', '-'), true ); + } - global $gBitUser; - if( is_object( $gBitUser ) ) { - // apache_setenv( 'USERID', $gBitUser->getField('login', '-'), true ); - } + // clean up URL before executing it + while( strstr( $pUrl, '&&' ) ) { + $pUrl = str_replace( '&&', '&', $pUrl ); + } - // clean up URL before executing it - while( strstr( $pUrl, '&&' ) ) { - $pUrl = str_replace( '&&', '&', $pUrl ); - } + while( strstr( $pUrl, '&&' ) ) { + $pUrl = str_replace( '&&', '&', $pUrl ); + } - while( strstr( $pUrl, '&&' ) ) { - $pUrl = str_replace( '&&', '&', $pUrl ); - } + // header locates should not have the & in the address it breaks things + while( strstr( $pUrl, '&' ) ) { + $pUrl = str_replace( '&', '&', $pUrl ); + } - // header locates should not have the & in the address it breaks things - while( strstr( $pUrl, '&' ) ) { - $pUrl = str_replace( '&', '&', $pUrl ); - } - - if( $pStatusCode ) { - header( 'Location: ' . $pUrl, true, $pStatusCode ); - } else { - header( 'Location: ' . $pUrl ); - } - session_write_close(); - exit(); - } + if( $pStatusCode ) { + header( 'Location: ' . $pUrl, true, $pStatusCode ); + } else { + header( 'Location: ' . $pUrl ); + } + session_write_close(); + exit(); + } - /** - * array_diff_keys - * - * @access public - */ - public static function array_diff_keys() { - $args = func_get_args(); + /** + * array_diff_keys + * + * @access public + */ + public static function array_diff_keys() { + $args = func_get_args(); - $res = $args[0]; - if( !is_array( $res )) { - return []; - } + $res = $args[0]; + if( !is_array( $res )) { + return []; + } - for( $i = 1; $i < count( $args ); $i++ ) { - if( !is_array( $args[$i] )) { - continue; - } - foreach( $args[$i] as $key => $data ) { - unset( $res[$key] ); - } - } - return $res; - } + 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 - */ - public static function trim_array( &$pArray ) { - if( is_array( $pArray ) ) { - foreach( array_keys( $pArray ) as $key ) { - if( is_string( $pArray[$key] ) ) { - $pArray[$key] = trim( $pArray[$key] ); - } - } - } - } + /** + * trim_array + * + * @param array $pArray + * @access public + */ + public static 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 + */ + public static function ordinalize( $num ) { + $ord = ''; + if( is_numeric( $num ) ) { + if( $num >= 11 and $num <= 19 ) { + $ord = KernelTools::tra( "th" ); + } elseif( $num % 10 == 1 ) { + $ord = KernelTools::tra( "st" ); + } elseif( $num % 10 == 2 ) { + $ord = KernelTools::tra( "nd" ); + } elseif( $num % 10 == 3 ) { + $ord = KernelTools::tra( "rd" ); + } else { + $ord = KernelTools::tra( "th" ); + } + } - /** - * ordinalize - * - * @param numeric $num Number to append th, st, nd, rd to - only makes sense when languages is english - * @access public - */ - public static function ordinalize( $num ) { - $ord = ''; - if( is_numeric( $num ) ) { - if( $num >= 11 and $num <= 19 ) { - $ord = KernelTools::tra( "th" ); - } elseif( $num % 10 == 1 ) { - $ord = KernelTools::tra( "st" ); - } elseif( $num % 10 == 2 ) { - $ord = KernelTools::tra( "nd" ); - } elseif( $num % 10 == 3 ) { - $ord = KernelTools::tra( "rd" ); - } else { - $ord = KernelTools::tra( "th" ); - } - } + return $num.$ord; + } - return $num.$ord; - } + /** + * Cleans file path according to system we're on + * + * @param string $pPath + * @access public + * @return string + */ + public static function clean_file_path( string $pPath ): string { + $pPath = !empty($_SERVER["SERVER_SOFTWARE"]) && strpos($_SERVER["SERVER_SOFTWARE"],"IIS") ? str_replace( '\/', '\\', $pPath) : $pPath; + return $pPath; + } - /** - * Cleans file path according to system we're on - * - * @param string $pPath - * @access public - * @return string - */ - public static function clean_file_path( string $pPath ): string { - $pPath = !empty($_SERVER["SERVER_SOFTWARE"]) && strpos($_SERVER["SERVER_SOFTWARE"],"IIS") ? str_replace( '\/', '\\', $pPath) : $pPath; - return $pPath; - } + public static function httpScheme() { + return 'http'.( ( isset($_SERVER['HTTPS'] ) && ( $_SERVER['HTTPS'] == 'on' ) ) ? 's' : '' ); + } - public static function httpScheme() { - return 'http'.( ( isset($_SERVER['HTTPS'] ) && ( $_SERVER['HTTPS'] == 'on' ) ) ? 's' : '' ); - } + public static function httpPrefix() { + return KernelTools::httpScheme().'://'.$_SERVER['HTTP_HOST']; + } - public static function httpPrefix() { - return KernelTools::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 void this function will DIE DIE DIE!!! + * @access public + */ + public static 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. + $step = isset( $gBitDbType ) ? 1 : 0; - /** - * If an unrecoverable error has occurred, this method should be invoked. script exist occurs - * - * @param string $ pMsg error message to be displayed - * @return void this function will DIE DIE DIE!!! - * @access public - */ - public static 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. - $step = isset( $gBitDbType ) ? 1 : 0; + header( "Location: ".KernelTools::httpPrefix().BIT_ROOT_URL."install/install.php?step=".$step ); + die; + } - header( "Location: ".KernelTools::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 + */ + public static function pear_check( $pPearModule = null ) { + if( !@include_once "PEAR.php") { + return KernelTools::tra( "PEAR is not installed." ); + } elseif( !empty( $pPearModule ) && !@include_once $pPearModule ) { + $module = str_replace( ".php", "", str_replace( "/", "_", $pPearModule )); + return KernelTools::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."); + } + return null; - /** - * 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 - */ - public static function pear_check( $pPearModule = null ) { - if( !@include_once "PEAR.php") { - return KernelTools::tra( "PEAR is not installed." ); - } elseif( !empty( $pPearModule ) && !@include_once $pPearModule ) { - $module = str_replace( ".php", "", str_replace( "/", "_", $pPearModule )); - return KernelTools::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 bool true on success, false on failure - */ - public static function usort_by_title( $ar1, $ar2 ) { - if( !empty( $ar1['title'] ) && !empty( $ar2['title'] ) ) { - return strcasecmp( $ar1['title'], $ar2['title'] ); - } else { - return 0; - } - } + /** + * A set of compare functions that can be used in conjunction with usort() type functions + * + * @param array $ar1 + * @param array $ar2 + * @access public + * @return bool true on success, false on failure + */ + public static function usort_by_title( $ar1, $ar2 ) { + if( !empty( $ar1['title'] ) && !empty( $ar2['title'] ) ) { + return strcasecmp( $ar1['title'], $ar2['title'] ); + } + return 0; - public static function compare_links( $ar1, $ar2 ) { - return $ar1["links"] - $ar2["links"]; - } + } - public static function compare_backlinks( $ar1, $ar2 ) { - return $ar1["backlinks"] - $ar2["backlinks"]; - } + public static function compare_links( $ar1, $ar2 ) { + return $ar1["links"] - $ar2["links"]; + } - public static function r_compare_links( $ar1, $ar2 ) { - return $ar2["links"] - $ar1["links"]; - } + public static function compare_backlinks( $ar1, $ar2 ) { + return $ar1["backlinks"] - $ar2["backlinks"]; + } - public static function r_compare_backlinks( $ar1, $ar2 ) { - return $ar2["backlinks"] - $ar1["backlinks"]; - } + public static function r_compare_links( $ar1, $ar2 ) { + return $ar2["links"] - $ar1["links"]; + } - public static function compare_images( $ar1, $ar2 ) { - return $ar1["images"] - $ar2["images"]; - } + public static function r_compare_backlinks( $ar1, $ar2 ) { + return $ar2["backlinks"] - $ar1["backlinks"]; + } - public static function r_compare_images( $ar1, $ar2 ) { - return $ar2["images"] - $ar1["images"]; - } + public static function compare_images( $ar1, $ar2 ) { + return $ar1["images"] - $ar2["images"]; + } - public static function compare_files( $ar1, $ar2 ) { - return $ar1["files"] - $ar2["files"]; - } + public static function r_compare_images( $ar1, $ar2 ) { + return $ar2["images"] - $ar1["images"]; + } - public static function r_compare_files( $ar1, $ar2 ) { - return $ar2["files"] - $ar1["files"]; - } + public static function compare_files( $ar1, $ar2 ) { + return $ar1["files"] - $ar2["files"]; + } - public static function compare_versions( $ar1, $ar2 ) { - return $ar1["versions"] - $ar2["versions"]; - } + public static function r_compare_files( $ar1, $ar2 ) { + return $ar2["files"] - $ar1["files"]; + } - public static function r_compare_versions( $ar1, $ar2 ) { - return $ar2["versions"] - $ar1["versions"]; - } + public static function compare_versions( $ar1, $ar2 ) { + return $ar1["versions"] - $ar2["versions"]; + } - public static function compare_changed( $ar1, $ar2 ) { - return $ar1["lastChanged"] - $ar2["lastChanged"]; - } + public static function r_compare_versions( $ar1, $ar2 ) { + return $ar2["versions"] - $ar1["versions"]; + } - public static function r_compare_changed( $ar1, $ar2 ) { - return $ar2["lastChanged"] - $ar1["lastChanged"]; - } + public static function compare_changed( $ar1, $ar2 ) { + return $ar1["lastChanged"] - $ar2["lastChanged"]; + } + public static function r_compare_changed( $ar1, $ar2 ) { + return $ar2["lastChanged"] - $ar1["lastChanged"]; + } - // ======================= deprecated functions ======================= - /** - * @deprecated deprecated since version 2.1.0-beta - */ - public static function chkgd2() { - KernelTools::deprecated( 'Please use get_gd_version() instead' ); - } + // ======================= deprecated functions ======================= + /** + * @deprecated deprecated since version 2.1.0-beta + */ + public static function chkgd2() { + KernelTools::deprecated( 'Please use get_gd_version() instead' ); + } }
\ No newline at end of file diff --git a/includes/config_defaults_inc.php b/includes/config_defaults_inc.php index d674433..12b58e7 100755 --- a/includes/config_defaults_inc.php +++ b/includes/config_defaults_inc.php @@ -225,7 +225,7 @@ 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/' ); + define( 'STORAGE_PKG_URL', BIT_ROOT_URL.'storage/' ); } if( !defined( 'STORAGE_PKG_INCLUDE_PATH' ) ) { define( 'STORAGE_PKG_INCLUDE_PATH', STORAGE_PKG_PATH.'includes/' ); @@ -237,7 +237,6 @@ if( !defined( 'STORAGE_PKG_ADMIN_PATH' ) ) { define( 'STORAGE_PKG_ADMIN_PATH', STORAGE_PKG_PATH.'admin/' ); } - define( 'THEMES_PKG_PATH', BIT_ROOT_PATH.'themes/' ); define( 'THEMES_PKG_INCLUDE_PATH', THEMES_PKG_PATH.'includes/' ); define( 'THEMES_PKG_CLASS_PATH', THEMES_PKG_INCLUDE_PATH.'classes/' ); diff --git a/includes/cron_setup_inc.php b/includes/cron_setup_inc.php index a7bcf50..0cdbaff 100644 --- a/includes/cron_setup_inc.php +++ b/includes/cron_setup_inc.php @@ -8,4 +8,3 @@ $_SERVER['REQUEST_URI'] = 'cron'; $_SERVER['REMOTE_ADDR'] = 'cron'; $_SERVER['HTTP_HOST'] = ''; - diff --git a/includes/module_controls_inc.php b/includes/module_controls_inc.php index 8604674..4faf340 100755 --- a/includes/module_controls_inc.php +++ b/includes/module_controls_inc.php @@ -20,7 +20,7 @@ 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, [ 'display_mode' => 'display' ]); die; } /*if (!$gBitSystem->isFeatureActive( 'site_user_assigned_modules' ) && $check_req) { @@ -30,7 +30,7 @@ if (!$gBitUser->hasPermission( 'p_tidbits_configure_modules' )) { }*/ 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, [ 'display_mode' => 'display' ]); die; } @@ -38,7 +38,7 @@ $url = $_SERVER["HTTP_REFERER"]; // global $debugger; // $debugger->msg('Module control clicked: '.$check_req); - // Make defaults if user still ot configure modules for himself + // Make defaults if user still ot configure modules for himself // if (!$usermoduleslib->user_has_assigned_modules($user)) // $usermoduleslib->create_user_assigned_modules($user); diff --git a/includes/notification_lib.php b/includes/notification_lib.php index 8b43a38..a9d3082 100755 --- a/includes/notification_lib.php +++ b/includes/notification_lib.php @@ -15,7 +15,6 @@ * 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,104 +27,104 @@ use Bitweaver\KernelTools; */ class NotificationLib extends BitBase { - /** - * Lists registered notification events - * @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 - */ - 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=[$findesc,$findesc]; - } - else - { - $mid = " "; - $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 = []; - while ($res = $result->fetchRow()) - { - $ret[] = $res; - } - $retval = []; - $retval["data"] = $ret; - $retval["cant"] = $cant; - return $retval; - } - /** - * Adds an email address for a specified event notification - * @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 - */ - public function add_mail_event($event, $object, $email) - { - $query = "insert into `".BIT_DB_PREFIX."mail_notifications`(`event`,`object`,`email`) values(?,?,?)"; - $this->mDb->query( $query, [ 'event', $object, $email ] ); - } + /** + * Lists registered notification events + * @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 + */ + 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=[$findesc,$findesc]; + } + else + { + $mid = " "; + $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 = []; + while ($res = $result->fetchRow()) + { + $ret[] = $res; + } + $retval = []; + $retval["data"] = $ret; + $retval["cant"] = $cant; + return $retval; + } + /** + * Adds an email address for a specified event notification + * @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 + */ + public function add_mail_event($event, $object, $email) + { + $query = "insert into `".BIT_DB_PREFIX."mail_notifications`(`event`,`object`,`email`) values(?,?,?)"; + $this->mDb->query( $query, [ 'event', $object, $email ] ); + } - /** - * Removes an email address for a specified event notification - * @param string $event the specified event - * @param string $object the specified object - * @param string $email the email to remove - * @return void - */ - 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`=?"; - $this->mDb->query($query, [$event,$object,$email] ); - } + /** + * Removes an email address for a specified event notification + * @param string $event the specified event + * @param string $object the specified object + * @param string $email the email to remove + * @return void + */ + 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`=?"; + $this->mDb->query($query, [$event,$object,$email] ); + } + + /** + * Retrieves the email addresses for a specific event + * @param string $event event the specified event + * @param string $object the specified object + * @return array of email addresses + */ + 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, [ $event, $object ] ); + $ret = []; + while ($res = $result->fetchRow()) + { + $ret[] = $res["email"]; + } + return $ret; + } - /** - * Retrieves the email addresses for a specific event - * @param string $event event the specified event - * @param string $object the specified object - * @return array of email addresses - */ - 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, [ $event, $object ] ); - $ret = []; - while ($res = $result->fetchRow()) - { - $ret[] = $res["email"]; - } - return $ret; - } + /** + * Post changes to registered email addresses related to a change event + * @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 + */ + public function post_content_event( int $contentid, string $type, string $package, string $name, string $user, string $comment, string $data): void + { global $gBitSystem; - /** - * Post changes to registered email addresses related to a change event - * @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 - */ - 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); foreach ($emails as $email) { @@ -145,11 +144,11 @@ class NotificationLib extends BitBase } } - /** - * Notifies registered list of eMail recipients of new user registrations - * @param string name of the new user - */ - public function post_new_user_event( string $user ): void + /** + * Notifies registered list of eMail recipients of new user registrations + * @param string name of the new user + */ + public function post_new_user_event( string $user ): void { global $gBitSystem, $gBitSmarty; $emails = $this->get_mail_events('user_registers','*'); foreach($emails as $email) { diff --git a/includes/setup_inc.php b/includes/setup_inc.php index 5ccbe51..ebe4767 100755 --- a/includes/setup_inc.php +++ b/includes/setup_inc.php @@ -12,6 +12,7 @@ * required setup */ namespace Bitweaver; + use Bitweaver\Plugins\ResourceBitpackage; use Bitweaver\Languages\BitLanguage; @@ -25,7 +26,6 @@ if(( !empty( $_REQUEST['sort_mode'] ) && !is_array( $_REQUEST['sort_mode'] ) && 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 ); @@ -127,7 +127,7 @@ if( $gBitSystem->isDatabaseValid() ) { $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'; @@ -135,13 +135,13 @@ if( $gBitSystem->isDatabaseValid() ) { // some plugins check for active packages, so we do this *after* package scanning $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(); @@ -215,10 +215,10 @@ if( $gBitSystem->isDatabaseValid() ) { // All of the below deals with HTTPS - perhaps we should move this to a separate file if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) { $site_http_port = 80; - $site_https_port = isset( $_SERVER['SERVER_PORT'] ) ? $_SERVER['SERVER_PORT'] : 443; + $site_https_port = $_SERVER['SERVER_PORT'] ?? 443; } else { $site_https_port = 443; - $site_http_port = isset( $_SERVER['SERVER_PORT'] ) ? $_SERVER['SERVER_PORT'] : 80; + $site_http_port = $_SERVER['SERVER_PORT'] ?? 80; } if( !$site_https_port = $gBitSystem->getConfig( 'site_https_port', $site_https_port ) ) { @@ -228,7 +228,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 ); diff --git a/includes/simple_form_functions_lib.php b/includes/simple_form_functions_lib.php index a4c87e2..f49b8e2 100755 --- a/includes/simple_form_functions_lib.php +++ b/includes/simple_form_functions_lib.php @@ -12,15 +12,15 @@ * @return void */ function simple_set_configs( $pArray, $pPackageName = null ){ - foreach( $pArray as $item => $data ) { - if( $data['type'] == 'numeric' ) { - simple_set_int( $item, $pPackageName ); - } elseif( $data['type'] == 'toggle' ) { - simple_set_toggle( $item, $pPackageName ); - } elseif( $data['type'] == 'input' ) { - simple_set_value( $item, $pPackageName ); - } - } + foreach( $pArray as $item => $data ) { + if( $data['type'] == 'numeric' ) { + simple_set_int( $item, $pPackageName ); + } elseif( $data['type'] == 'toggle' ) { + simple_set_toggle( $item, $pPackageName ); + } elseif( $data['type'] == 'input' ) { + simple_set_value( $item, $pPackageName ); + } + } } /** @@ -34,7 +34,7 @@ function simple_set_toggle( $pFeature, $pPackageName = null ) { if( isset( $_REQUEST[$pFeature][0] ) ) { $_REQUEST[$pFeature] = $_REQUEST[$pFeature][0]; } - toggle_preference( $pFeature, ( isset( $_REQUEST[$pFeature] ) ? $_REQUEST[$pFeature] : null ), $pPackageName ); + toggle_preference( $pFeature, ( $_REQUEST[$pFeature] ?? null ), $pPackageName ); } /** diff --git a/modules/help_mod_adsense.tpl b/modules/help_mod_adsense.tpl index 2410fff..2410fff 100644..100755 --- a/modules/help_mod_adsense.tpl +++ b/modules/help_mod_adsense.tpl diff --git a/modules/help_mod_package_menu.tpl b/modules/help_mod_package_menu.tpl index d18aae1..d18aae1 100644..100755 --- a/modules/help_mod_package_menu.tpl +++ b/modules/help_mod_package_menu.tpl diff --git a/modules/help_mod_powered_by.tpl b/modules/help_mod_powered_by.tpl index 93a657d..93a657d 100644..100755 --- a/modules/help_mod_powered_by.tpl +++ b/modules/help_mod_powered_by.tpl diff --git a/modules/help_mod_time.tpl b/modules/help_mod_time.tpl index adb19a5..adb19a5 100644..100755 --- a/modules/help_mod_time.tpl +++ b/modules/help_mod_time.tpl diff --git a/modules/mod_adsense.tpl b/modules/mod_adsense.tpl index 7fc4f94..7fc4f94 100644..100755 --- a/modules/mod_adsense.tpl +++ b/modules/mod_adsense.tpl diff --git a/modules/mod_bottom_bar.tpl b/modules/mod_bottom_bar.tpl index 2094d3a..2094d3a 100644..100755 --- a/modules/mod_bottom_bar.tpl +++ b/modules/mod_bottom_bar.tpl diff --git a/modules/mod_package_icons.tpl b/modules/mod_package_icons.tpl index 2c56911..2c56911 100644..100755 --- a/modules/mod_package_icons.tpl +++ b/modules/mod_package_icons.tpl diff --git a/modules/mod_package_menu.tpl b/modules/mod_package_menu.tpl index 63a0524..63a0524 100644..100755 --- a/modules/mod_package_menu.tpl +++ b/modules/mod_package_menu.tpl diff --git a/modules/mod_server_stats.tpl b/modules/mod_server_stats.tpl index 39dbd47..39dbd47 100644..100755 --- a/modules/mod_server_stats.tpl +++ b/modules/mod_server_stats.tpl diff --git a/modules/mod_side_menu.php b/modules/mod_side_menu.php index 5ea75bd..9119fd8 100755 --- a/modules/mod_side_menu.php +++ b/modules/mod_side_menu.php @@ -32,7 +32,7 @@ if( !$gStructure and $gContent ) { if( $gStructure and !empty($gStructure->mInfo['structure_path']) ) { $secondbox = 0; $tree = 1; - $gStructure->mInfo['structure_path'][0]['structure_id']; + $gStructure->mInfo['structure_path'][0]['structure_id']; if( $gStructure->mInfo['parent']['structure_id'] == 4 ) $sidebox = $gStructure->mInfo['content_id'] - 3; elseif( $gStructure->mInfo['parent']['content_id'] > 4 ) $sidebox = $gStructure->mInfo['parent']['content_id'] - 3; else $sidebox = 1; @@ -44,7 +44,7 @@ if( $gStructure and !empty($gStructure->mInfo['structure_path']) ) { $secondmenu = $gStructure->buildTreeToc( $secondbox ); $gBitSmarty->assign( 'secondmenu', $secondmenu[0]['sub'] ); } - } + } } else { $gStructure = new LibertyStructure( 1 ); $menu = $gStructure->buildTreeToc( 1 ); diff --git a/modules/mod_site_title.tpl b/modules/mod_site_title.tpl index 5449511..5449511 100644..100755 --- a/modules/mod_site_title.tpl +++ b/modules/mod_site_title.tpl diff --git a/modules/mod_top_menu.tpl b/modules/mod_top_menu.tpl index 9020a0a..9020a0a 100644..100755 --- a/modules/mod_top_menu.tpl +++ b/modules/mod_top_menu.tpl diff --git a/modules/mod_twitter_feed.tpl b/modules/mod_twitter_feed.tpl index 62442e5..62442e5 100644..100755 --- a/modules/mod_twitter_feed.tpl +++ b/modules/mod_twitter_feed.tpl diff --git a/scripts/BitFileBrowser.js b/scripts/BitFileBrowser.js index 6348591..6348591 100644..100755 --- a/scripts/BitFileBrowser.js +++ b/scripts/BitFileBrowser.js diff --git a/templates/admin_include_anchors.tpl b/templates/admin_include_anchors.tpl index 8123826..8123826 100644..100755 --- a/templates/admin_include_anchors.tpl +++ b/templates/admin_include_anchors.tpl diff --git a/templates/backup.tpl b/templates/backup.tpl index 6a49f7d..6a49f7d 100644..100755 --- a/templates/backup.tpl +++ b/templates/backup.tpl diff --git a/templates/dynamic.tpl b/templates/dynamic.tpl index bda0e61..bda0e61 100644..100755 --- a/templates/dynamic.tpl +++ b/templates/dynamic.tpl diff --git a/templates/feedback_inc.tpl b/templates/feedback_inc.tpl index 5534b67..5534b67 100644..100755 --- a/templates/feedback_inc.tpl +++ b/templates/feedback_inc.tpl diff --git a/templates/footer.tpl b/templates/footer.tpl index 802620e..802620e 100644..100755 --- a/templates/footer.tpl +++ b/templates/footer.tpl diff --git a/templates/footer_inc.tpl b/templates/footer_inc.tpl index 802620e..802620e 100644..100755 --- a/templates/footer_inc.tpl +++ b/templates/footer_inc.tpl diff --git a/templates/json_output.tpl b/templates/json_output.tpl index e44f84f..e44f84f 100644..100755 --- a/templates/json_output.tpl +++ b/templates/json_output.tpl diff --git a/templates/list_cache.tpl b/templates/list_cache.tpl index b819269..b819269 100644..100755 --- a/templates/list_cache.tpl +++ b/templates/list_cache.tpl diff --git a/templates/minifind.tpl b/templates/minifind.tpl index 48fcc79..48fcc79 100644..100755 --- a/templates/minifind.tpl +++ b/templates/minifind.tpl diff --git a/templates/navbar.tpl b/templates/navbar.tpl index 326dec7..326dec7 100644..100755 --- a/templates/navbar.tpl +++ b/templates/navbar.tpl diff --git a/templates/poptop.tpl b/templates/poptop.tpl index e69de29..e69de29 100644..100755 --- a/templates/poptop.tpl +++ b/templates/poptop.tpl diff --git a/templates/side_bar.tpl b/templates/side_bar.tpl index c7657fb..c7657fb 100644..100755 --- a/templates/side_bar.tpl +++ b/templates/side_bar.tpl diff --git a/templates/sitemap.tpl b/templates/sitemap.tpl index 6fa3582..6fa3582 100644..100755 --- a/templates/sitemap.tpl +++ b/templates/sitemap.tpl diff --git a/templates/upload_slot_inc.tpl b/templates/upload_slot_inc.tpl index 2fafc01..2fafc01 100644..100755 --- a/templates/upload_slot_inc.tpl +++ b/templates/upload_slot_inc.tpl diff --git a/templates/view_cache.tpl b/templates/view_cache.tpl index ea1a840..ea1a840 100644..100755 --- a/templates/view_cache.tpl +++ b/templates/view_cache.tpl diff --git a/test/README.smarty_filter_tests b/test/README.smarty_filter_tests index 5d50271..5d50271 100644..100755 --- a/test/README.smarty_filter_tests +++ b/test/README.smarty_filter_tests diff --git a/test/TestBitCache.php b/test/TestBitCache.php index cdfe860..490dafd 100644 --- a/test/TestBitCache.php +++ b/test/TestBitCache.php @@ -2,60 +2,60 @@ require_once('bit_setup_inc.php'); class TestBitCache extends UnitTestCase { - - var $test; - var $name ="TestBitCache"; - function TestBitCache() - { - // global $gBitCache; - $this->test = new BitCache(); - ## This test can not be performed in the constructor in simpleTest - # $this->assertTrue(is_object($this->test), 'Error during initialisation'); - if (!is_object($this->test)) { - $this = NULL; + var $test; + var $name ="TestBitCache"; + + function TestBitCache() + { + // global $gBitCache; + $this->test = new BitCache(); + ## This test can not be performed in the constructor in simpleTest + # $this->assertTrue(is_object($this->test), 'Error during initialisation'); + if (!is_object($this->test)) { + $this = NULL; return; - } - - } - - function testGetNonexistentCachedItem() - { - $this->assertNull($this->test->getCached("TestBitCache")); - } - - function testIsNonexistentItemCached() - { - $this->assertFalse($this->test->isCached("TestBitCache")); - } + } + + } + + function testGetNonexistentCachedItem() + { + $this->assertNull($this->test->getCached("TestBitCache")); + } + + function testIsNonexistentItemCached() + { + $this->assertFalse($this->test->isCached("TestBitCache")); + } + + function testRemoveNonexistentCachedItem() + { + $this->test->removeCached("TestBitCache"); + $this->assertFalse($this->test->isCached("TestBitCache")); + } + + function testSetCachedItem() + { + $this->test->setCached("TestBitCache", "123"); + $this->assertTrue($this->test->isCached("TestBitCache")); + } + + function testGetCachedItem() + { + $this->assertEqual($this->test->getCached("TestBitCache"), "123"); + } - function testRemoveNonexistentCachedItem() - { - $this->test->removeCached("TestBitCache"); - $this->assertFalse($this->test->isCached("TestBitCache")); - } - - function testSetCachedItem() - { - $this->test->setCached("TestBitCache", "123"); - $this->assertTrue($this->test->isCached("TestBitCache")); - } - - function testGetCachedItem() - { - $this->assertEqual($this->test->getCached("TestBitCache"), "123"); - } - - function testIsItemCached() - { - $this->assertTrue($this->test->isCached("TestBitCache")); - } + function testIsItemCached() + { + $this->assertTrue($this->test->isCached("TestBitCache")); + } - function testRemoveCachedItem() - { - $this->test->removeCached("TestBitCache"); - $this->assertFalse($this->test->isCached("TestBitCache") || - $this->test->getCached("TestBitCache") != NULL); - } + function testRemoveCachedItem() + { + $this->test->removeCached("TestBitCache"); + $this->assertFalse($this->test->isCached("TestBitCache") || + $this->test->getCached("TestBitCache") != NULL, ); + } } ?>
\ No newline at end of file diff --git a/test/TestBitDatabase.php b/test/TestBitDatabase.php Binary files differindex f98b281..6886f4d 100644 --- a/test/TestBitDatabase.php +++ b/test/TestBitDatabase.php diff --git a/test/TestBitPreferences.php b/test/TestBitPreferences.php index d610d0e..a60bba4 100644 --- a/test/TestBitPreferences.php +++ b/test/TestBitPreferences.php @@ -3,15 +3,15 @@ require_once(KERNEL_PKG_CLASS_PATH.'BitPreferences.php'); class TestBitPreferences extends UnitTestCase { - var $test; - - function TestBitPreferences() - { + var $test; + + function TestBitPreferences() + { // no general initialization - } - - function setUp () - { + } + + function setUp () + { global $gBitDb, $gCache; $tmpDB = $gBitDb; $tmpCache = $gCache; @@ -25,53 +25,52 @@ class TestBitPreferences extends UnitTestCase { // 'Error during initialisation'); // This check is probably not needed - it only adds to the passes // and if it is not true it does not save anything anyway. - } - + } - function tearDown () - { + function tearDown () + { $this->test = NULL; - } + } + + function testGetNonexistentItem() + { + $this->assertNull($this->test->getPreference("test")); + } + + function testSetNonexistentItem() + { + $this->test->setPreference("test", "123"); + $this->assertEqual($this->test->getPreference("test"), "123", ""); + } - function testGetNonexistentItem() - { - $this->assertNull($this->test->getPreference("test")); - } - - function testSetNonexistentItem() - { - $this->test->setPreference("test", "123"); - $this->assertEqual($this->test->getPreference("test"), "123", ""); - } - - function testSetDefaultItem() - { + function testSetDefaultItem() + { $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "123"); - } + $this->test->setDefaultPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "123"); + } - function testSetAsDefaultItem() - { + function testSetAsDefaultItem() + { $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "456"); - } + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "456"); + } - function testReadDefaultItem() - { + function testReadDefaultItem() + { $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", NULL); - $this->assertEqual($this->test->getPreference("test"), "456"); - } + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", NULL); + $this->assertEqual($this->test->getPreference("test"), "456"); + } - function testResetItem() - { + function testResetItem() + { $this->test->setPreference("test", "123"); - $this->test->setPreference("test", NULL); - $this->assertNull($this->test->getPreference("test")); - } + $this->test->setPreference("test", NULL); + $this->assertNull($this->test->getPreference("test")); + } } ?> diff --git a/test/TestBitPreferencesCache.php b/test/TestBitPreferencesCache.php index 2dc7998..dd67c2b 100644 --- a/test/TestBitPreferencesCache.php +++ b/test/TestBitPreferencesCache.php @@ -5,11 +5,10 @@ require_once(KERNEL_PKG_PATH.'test/TestBitPreferences.php'); class TestBitPreferencesCache extends TestBitPreferences { + var $name = "TestBitPreferencesCache"; - var $name = "TestBitPreferencesCache"; - - function setUp () - { + function setUp () + { global $gBitDb, $gCache; $tmpDB = $gBitDb; $tmpCache = $gCache; @@ -19,52 +18,51 @@ class TestBitPreferencesCache extends TestBitPreferences { $this->test->mDebug = false; $gBitDb = $tmpDB; $gCache = $tmpCache; - } + } - function tearDown () - { + function tearDown () + { $this->test = NULL; - } - + } # [tests] - function TestBitPreferencesCache() - { - // no general initalization - - } - - function testGetNonexistentItem() - { - $this->assertNull($this->test->getPreference("test")); - } - - function testSetNonexistentItem() - { - $this->test->setPreference("test", "123"); - $this->assertEqual($this->test->getPreference("test"), "123"); - } - - function testSetDefaultItem() - { + function TestBitPreferencesCache() + { + // no general initalization + + } + + function testGetNonexistentItem() + { + $this->assertNull($this->test->getPreference("test")); + } + + function testSetNonexistentItem() + { + $this->test->setPreference("test", "123"); + $this->assertEqual($this->test->getPreference("test"), "123"); + } + + function testSetDefaultItem() + { $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "123"); - } - - function testSetAsDefaultItem() - { - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "456"); - } + $this->test->setDefaultPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "123"); + } + + function testSetAsDefaultItem() + { + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "456"); + } - function testResetItem() - { - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", NULL); - $this->assertEqual($this->test->getPreference("test"), "456"); - } + function testResetItem() + { + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", NULL); + $this->assertEqual($this->test->getPreference("test"), "456"); + } } ?> diff --git a/test/TestBitPreferencesCacheDatabase.php b/test/TestBitPreferencesCacheDatabase.php index 879e908..d6bc95f 100644 --- a/test/TestBitPreferencesCacheDatabase.php +++ b/test/TestBitPreferencesCacheDatabase.php @@ -3,90 +3,88 @@ require_once(KERNEL_PKG_CLASS_PATH.'BitPreferences.php'); #require_once(KERNEL_PKG_PATH.'test/TestBitPreferences.php'); class TestBitPreferencesCacheDatabase extends UnitTestCase { - //class TestBitPreferencesCacheDatabase extends TestBitPreferences { + //class TestBitPreferencesCacheDatabase extends TestBitPreferences { - var $name = "TestBitPreferencesCacheDatabase"; - var $test; - - function TestBitPreferencesCacheDatabase() - { - } - - function setUp () - { + var $name = "TestBitPreferencesCacheDatabase"; + var $test; + + function TestBitPreferencesCacheDatabase() + { + } + + function setUp () + { global $gBitDb, $gBitCache; $gBitCache = new BitCache(); if (!is_object($gBitDb) || !is_object($gBitCache)) { - $this = NULL; - return; + $this = NULL; + return; } $name = "`".$this->name."`"; if (!$gBitDb->tableExists($name)) { - $tables = array( - $name => " + $tables = [ + $name => " `name` C(50) PRIMARY, `pref_value` C(255) - "); - $gBitDb->createTables($tables); + ", ]; + $gBitDb->createTables($tables); } $this->test = new BitPreferences($this->name); - + // This test can not be performed in the constructor in simpleTest $this->assertTrue($this->test != NULL, 'Error during initialisation'); - } - + } - function tearDown () - { + function tearDown () + { global $gBitDb; $name = "`".$this->name."`"; - $tables = array ($name); + $tables = [$name]; $gBitDb->dropTables($tables); $this->test = NULL; - } - + } - // Tests duplicated from TestBitPreferences - // Could not inherit them like in TestBitPreferencesCache for some reason. - function testGetNonexistentItem() - { + // Tests duplicated from TestBitPreferences + // Could not inherit them like in TestBitPreferencesCache for some reason. + function testGetNonexistentItem() + { $this->assertNull($this->test->getPreference("test")); - } - - function testSetNonexistentItem() - { - $this->test->setPreference("test", "123"); - $this->assertEqual($this->test->getPreference("test"), "123", ""); - } + } + + function testSetNonexistentItem() + { + $this->test->setPreference("test", "123"); + $this->assertEqual($this->test->getPreference("test"), "123", ""); + } + + function testSetDefaultItem() + { + $this->test->setPreference("test", "123"); + $this->test->setDefaultPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "123"); + } - function testSetDefaultItem() - { - $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "123"); - } + function testSetAsDefaultItem() + { + $this->test->setPreference("test", "123"); + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "456"); + } - function testSetAsDefaultItem() - { - $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "456"); - } + function testReadDefaultItem() + { + $this->test->setPreference("test", "123"); + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", NULL); + $this->assertEqual($this->test->getPreference("test"), "456"); + } - function testReadDefaultItem() - { - $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", NULL); - $this->assertEqual($this->test->getPreference("test"), "456"); - } - - function testResetItem() - { - $this->test->setPreference("test", "123"); - $this->test->setPreference("test", NULL); - $this->assertNull($this->test->getPreference("test")); - } + function testResetItem() + { + $this->test->setPreference("test", "123"); + $this->test->setPreference("test", NULL); + $this->assertNull($this->test->getPreference("test")); + } } ?> diff --git a/test/TestBitPreferencesDatabase.php b/test/TestBitPreferencesDatabase.php index d92e748..d69db0d 100644 --- a/test/TestBitPreferencesDatabase.php +++ b/test/TestBitPreferencesDatabase.php @@ -2,92 +2,88 @@ require_once(KERNEL_PKG_CLASS_PATH.'BitPreferences.php'); # require_once(KERNEL_PKG_PATH . 'test/TestBitPreferences.php'); - class TestBitPreferencesDatabase extends UnitTestCase { - // class TestBitPreferencesDatabase extends TestBitPreferences { - - var $name = "TestBitPreferencesDatabase"; - var $test; + // class TestBitPreferencesDatabase extends TestBitPreferences { - function TestBitPreferencesDatabase() - { + var $name = "TestBitPreferencesDatabase"; + var $test; + + function TestBitPreferencesDatabase() + { // No general initialization - } - - function setUp () - { + } + + function setUp () + { global $gBitDb; if (!is_object($gBitDb)) { - $this = NULL; - return; + $this = NULL; + return; } $name = "`" . $this->name . "`"; if (!$gBitDb->tableExists($name)) { - $tables = array($name => " + $tables = [$name => " `name` C(50) PRIMARY, `pref_value` C(255) - "); + "]; } global $gCache; $tmpCache = $gCache; $gCache = NULL; $this->test = new BitPreferences($this->name); $gCache = $tmpCache; - } - - - function tearDown () - { + } + + function tearDown () + { global $gBitDb; $name = "`".$this->name."`"; - $tables = array ($name); + $tables = [$name]; $gBitDb->dropTables($tables); $this->test = NULL; - } + } + // Tests duplicated from TestBitPreferences + // Could not inherit them like in TestBitPreferencesCache for some reason. + function testGetNonexistentItem() + { + $this->assertNull($this->test->getPreference("test")); + } + function testSetNonexistentItem() + { + $this->test->setPreference("test", "123"); + $this->assertEqual($this->test->getPreference("test"), "123", ""); + } - // Tests duplicated from TestBitPreferences - // Could not inherit them like in TestBitPreferencesCache for some reason. - function testGetNonexistentItem() - { - $this->assertNull($this->test->getPreference("test")); - } - - function testSetNonexistentItem() - { - $this->test->setPreference("test", "123"); - $this->assertEqual($this->test->getPreference("test"), "123", ""); - } - - function testSetDefaultItem() - { - $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "123"); - } + function testSetDefaultItem() + { + $this->test->setPreference("test", "123"); + $this->test->setDefaultPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "123"); + } - function testSetAsDefaultItem() - { - $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", "456"); - $this->assertEqual($this->test->getPreference("test"), "456"); - } + function testSetAsDefaultItem() + { + $this->test->setPreference("test", "123"); + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", "456"); + $this->assertEqual($this->test->getPreference("test"), "456"); + } - function testReadDefaultItem() - { - $this->test->setPreference("test", "123"); - $this->test->setDefaultPreference("test", "456"); - $this->test->setPreference("test", NULL); - $this->assertEqual($this->test->getPreference("test"), "456"); - } - - function testResetItem() - { - $this->test->setPreference("test", "123"); - $this->test->setPreference("test", NULL); - $this->assertNull($this->test->getPreference("test")); - } + function testReadDefaultItem() + { + $this->test->setPreference("test", "123"); + $this->test->setDefaultPreference("test", "456"); + $this->test->setPreference("test", NULL); + $this->assertEqual($this->test->getPreference("test"), "456"); + } + + function testResetItem() + { + $this->test->setPreference("test", "123"); + $this->test->setPreference("test", NULL); + $this->assertNull($this->test->getPreference("test")); + } } ?> diff --git a/test/TestBitSmartyFilter.php b/test/TestBitSmartyFilter.php index e2402a0..6ac0555 100644 --- a/test/TestBitSmartyFilter.php +++ b/test/TestBitSmartyFilter.php @@ -6,129 +6,126 @@ class InputOutputTester { } - class TestBitSmartyFilter extends UnitTestCase { var $filterTestDir; var $smartyDir; - function TestBitSmartyFilter () { - // directory that contains test directories - $this->filterTestDir = KERNEL_PKG_PATH . '/test/smarty_filter_tests'; - $this->smartyDir = KERNEL_PKG_PATH . 'smarty_bit'; + // directory that contains test directories + $this->filterTestDir = KERNEL_PKG_PATH . '/test/smarty_filter_tests'; + $this->smartyDir = KERNEL_PKG_PATH . 'smarty_bit'; } function testPrePostFilters () { - global $gBitLanguage; - $gBitLanguage->mLanguage = 'sv'; - - $this->assertTrue (is_dir("$this->filterTestDir"), // Quite fatal - "$this->filterTestDir is not a directory"); - - // echo "$this->filterTestDir<br />"; - - $filterTestDirHandle = opendir($this->filterTestDir); - while (false !== ($filterTestCase = readdir($filterTestDirHandle))) { - $filterTestCaseDir = $this->filterTestDir . '/' . $filterTestCase; - $this->assertTrue(is_dir ($filterTestCaseDir), - "$filterTestCaseDir is not a directory"); - - // echo "$filterTestCaseDir<br />"; - if (preg_match('/(.+)filter\.(.+)/', $filterTestCase, $matches)) { + global $gBitLanguage; + $gBitLanguage->mLanguage = 'sv'; + + $this->assertTrue (is_dir("$this->filterTestDir"), // Quite fatal + "$this->filterTestDir is not a directory", ); + + // echo "$this->filterTestDir<br />"; + + $filterTestDirHandle = opendir($this->filterTestDir); + while (false !== ($filterTestCase = readdir($filterTestDirHandle))) { + $filterTestCaseDir = $this->filterTestDir . '/' . $filterTestCase; + $this->assertTrue(is_dir ($filterTestCaseDir), + "$filterTestCaseDir is not a directory", ); + + // echo "$filterTestCaseDir<br />"; + if (preg_match('/(.+)filter\.(.+)/', $filterTestCase, $matches)) { // echo "$matches[0]<br />"; - + $filterType = $matches[1]; $filterBase = $matches[2]; - - $smartyFile = + + $smartyFile = $this->smartyDir . '/' . $filterType .'filter.' . $filterBase . '.php'; $filterName = 'smarty_' . $filterType . 'filter_' .$filterBase; - + // echo "$smartyFile<br />"; // echo "$filterName<br />"; - + $this->assertTrue(file_exists ($smartyFile), - "Smarty filter $smartyFile is missing"); + "Smarty filter $smartyFile is missing", ); include_once($smartyFile); - + // echo "$filterTestCaseDir<br />"; $filterTestCaseDirHandle = opendir("$filterTestCaseDir"); while (false != ($inputFile = readdir($filterTestCaseDirHandle))) { if (preg_match('/^(.+)\.input$/', $inputFile, $matches)) { - $baseName = $matches[1]; - $outputFile = $filterTestCaseDir . '/' . $baseName . '.output'; - $errorFile = $filterTestCaseDir . '/' . $baseName . '.error'; - $inputFile = $filterTestCaseDir . '/' . $inputFile; - - - // echo "$inputFile<br />"; - // echo "$outputFile<br />"; - // echo "$errorFile<br />"; - - $this->assertTrue(file_exists ($inputFile), - (file_exists ($inputFile) ? - "" : - "Input file <strong>$inputFile</strong> " . - "is missing")); - - // remove error file if there is no error - - if (file_exists($errorFile)) { - @unlink ($errorFile); - } - - $input = file_get_contents($inputFile); - // $filterOutput = call_user_func ($filterName, $input, &$smarty); - $filterOutput = call_user_func_array ($filterName, - array($input, &$gBitSmarty)); - - if (!file_exists($outputFile)) { - // Output file does not exist - Create error file - // echo "OUTPUT does not Exists<br />"; - $this->assertTrue(file_exists ($outputFile), + $baseName = $matches[1]; + $outputFile = $filterTestCaseDir . '/' . $baseName . '.output'; + $errorFile = $filterTestCaseDir . '/' . $baseName . '.error'; + $inputFile = $filterTestCaseDir . '/' . $inputFile; + + // echo "$inputFile<br />"; + // echo "$outputFile<br />"; + // echo "$errorFile<br />"; + + $this->assertTrue(file_exists ($inputFile), + (file_exists ($inputFile) ? + "" : + "Input file <strong>$inputFile</strong> " . + "is missing"), ); + + // remove error file if there is no error + + if (file_exists($errorFile)) { + @unlink ($errorFile); + } + + $input = file_get_contents($inputFile); + // $filterOutput = call_user_func ($filterName, $input, &$smarty); + $filterOutput = call_user_func_array ($filterName, + [$input, &$gBitSmarty], ); + + if (!file_exists($outputFile)) { + // Output file does not exist - Create error file + // echo "OUTPUT does not Exists<br />"; + $this->assertTrue(file_exists ($outputFile), (file_exists ($outputFile) ? "" : - "Output file <strong>$outputFile</strong> " . + "Output file <strong>$outputFile</strong> " . "is missing, " . - "<strong>$errorFile</strong> created.")); + "<strong>$errorFile</strong> created."), ); + + // Error handling missing when writing to file, + // final code should be encapsulated in a function. + $outHandle = fopen ($errorFile, 'wb'); + fwrite ($outHandle, $filterOutput, strlen ($filterOutput)); + fclose($outHandle); + // echo "END OUTPUT does not Exists<br />"; + // break; + } - // Error handling missing when writing to file, - // final code should be encapsulated in a function. - $outHandle = fopen ($errorFile, 'wb'); - fwrite ($outHandle, $filterOutput, strlen ($filterOutput)); - fclose($outHandle); - // echo "END OUTPUT does not Exists<br />"; - // break; - } - - else { - // echo "OUTPUT Exists<br />"; - $output = file_get_contents($outputFile); - $compareResult = strcmp ($output, $filterOutput); - // print "$output <br />\n"; - // print "$filterOutput <br />\n"; - // print "$compareResult <br \>\n"; + else { + // echo "OUTPUT Exists<br />"; + $output = file_get_contents($outputFile); + $compareResult = strcmp ($output, $filterOutput); + // print "$output <br />\n"; + // print "$filterOutput <br />\n"; + // print "$compareResult <br \>\n"; - $this->assertTrue (0 == $compareResult, + $this->assertTrue (0 == $compareResult, (0 == $compareResult ? "" : "<strong>$inputFile</strong> did not match " . "output, incorrect data stored in " . - "<strong>$errorFile</strong>")); - if (0 != $compareResult) { + "<strong>$errorFile</strong>"), ); + if (0 != $compareResult) { $outHandle = fopen ($errorFile, 'wb'); fwrite ($outHandle, $filterOutput, strlen ($filterOutput)); fclose($outHandle); - } - // echo "END OUTPUT Exists<br />"; - } + } + // echo "END OUTPUT Exists<br />"; + } + } + } } } - } - } } } diff --git a/test/smarty_filter_tests/prefilter.tr/simple.input b/test/smarty_filter_tests/prefilter.tr/simple.input index 48d07bc..48d07bc 100644..100755 --- a/test/smarty_filter_tests/prefilter.tr/simple.input +++ b/test/smarty_filter_tests/prefilter.tr/simple.input diff --git a/test/smarty_filter_tests/prefilter.tr/simple.output b/test/smarty_filter_tests/prefilter.tr/simple.output index 348ef47..348ef47 100644..100755 --- a/test/smarty_filter_tests/prefilter.tr/simple.output +++ b/test/smarty_filter_tests/prefilter.tr/simple.output diff --git a/view_cache.php b/view_cache.php index 3ef91ec..98e61cd 100755 --- a/view_cache.php +++ b/view_cache.php @@ -14,7 +14,6 @@ */ require_once '../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; -use Bitweaver\Wiki\BitPage; /* if($gBitSystem->getConfig('wiki_list_pages') != 'y') { @@ -29,7 +28,7 @@ if (isset($_REQUEST['url'])) { if (!$id) { $gBitSmarty->assign('msg', KernelTools::tra("No cache information available")); - $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' )); + $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ]); die; } @@ -39,7 +38,7 @@ if (isset($_REQUEST['url'])) { if (!isset($_REQUEST["cache_id"])) { $gBitSmarty->assign('msg', KernelTools::tra("No page indicated")); - $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' )); + $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ]); die; } @@ -54,4 +53,4 @@ if (substr($info["url"], -4, 4) == ".txt") { $gBitSmarty->assign('ggcacheurl', $ggcacheurl); $gBitSmarty->assign('info', $info); -$gBitSystem->display( 'bitpackage:kernel/view_cache.tpl', null, array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:kernel/view_cache.tpl', null, [ 'display_mode' => 'display' ]); |
