Project

General

Profile

« Previous | Next » 

Revision 1980

Added by Dietmar over 10 years ago

! /framework/initialize.php::SetInstallPathConstants() setting of DOCUMENT_ROOT now compatible for windows installation
! /framework/functions.php::rebuild_all_accessfiles() Optimize rebuild access file coding

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
10 Oct-2013 Build 1980 Dietmar Woellbrink (Luisehahne)
15
! /framework/initialize.php::SetInstallPathConstants() setting of DOCUMENT_ROOT now compatible for windows installation
16
! /framework/functions.php::rebuild_all_accessfiles() Optimize rebuild access file coding
14 17
10 Oct-2013 Build 1979 Manuela v.d.Decken(DarkViper)
15 18
# /admin/pages/PageTree forgotten changes from rev.1973
16 19
08 Oct-2013 Build 1978 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '1979');
54
if(!defined('REVISION')) define('REVISION', '1980');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/framework/initialize.php
80 80
		}
81 81
		if(!defined('ADMIN_REL')){ define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY); }
82 82
		if(!defined('DOCUMENT_ROOT')) {
83
			
84
			define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(WB_REL, '/').'$/', '', WB_PATH));
83
            define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));			
84
            // creating $_SERVER['DOCUMENT_ROOT'] for Windows IIS Server
85
            $_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
85 86
		}
86 87
		if(!defined('TMP_PATH')){ define('TMP_PATH', WB_PATH.'/temp'); }
87 88
	}
branches/2.8.x/wb/framework/functions.php
1446 1446
	}
1447 1447
}
1448 1448

  
1449
if(!function_exists('rebuild_all_accessfiles')){
1450
	function rebuild_all_accessfiles($bShowDetails=false ) {
1451
        global $database;
1452
    	$aRetval = array();
1453
    	/**
1454
    	 * try to remove access files and build new folder protect files
1455
    	 */
1456
//   	$sTempDir = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '').'/';
1457
        $sTreeToDelete = WbAdaptor::getInstance()->AppPath.WbAdaptor::getInstance()->PagesDir;
1458
    	if(($sTreeToDelete!='') && is_writeable($sTreeToDelete)==true) {
1459
//    	 	if(rm_full_dir (WB_PATH.$sTempDir, true, $aProtectedFiles )==false) {
1460
//    			$aRetval[] = 'Could not delete existing access files';
1461
//    	 	}
1462
			$aDeleteLog = array();	// <<< ge?ndert
1463
            DeleteAccessFilesTree($sTreeToDelete, $aDeleteLog);	// <<< ge?ndert
1464
            if($bShowDetails) {
1465
                $aRetval = array_merge($aRetval, $aDeleteLog);	// <<< ge?ndert
1466
            }
1449
if(!function_exists('rebuild_all_accessfiles'))
1450
{
1451
	function rebuild_all_accessfiles($bShowDetails=false ) 
1452
	{
1453
		$oDb = WbDatabase::getInstance();
1454
		$oReg = WbAdaptor::getInstance();
1455
	// try to remove access files and build new folder protect files
1456
        $sTreeToDelete = $oReg->AppPath.$oReg->PagesDir;
1457
    	if(($sTreeToDelete!='') && is_writeable($sTreeToDelete)==true)
1458
		{
1459
			$aDeleteLog = array();
1460
            DeleteAccessFilesTree($sTreeToDelete, $aDeleteLog);
1461
		// show details if debug is set
1462
            if($bShowDetails) { $aRetval = $aDeleteLog; }
1467 1463
    	}
1468

  
1469
		$aRetval = array_merge($aRetval,createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') ));
1470

  
1471
    	/**
1472
    	 * Reformat/rebuild all existing access files
1473
    	 */
1474
//        $sql = 'SELECT `page_id`,`root_parent`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`';
1475
		$sql  = 'SELECT `page_id`,`root_parent`,`link`, `level` ';
1476
		$sql .= 'FROM `'.TABLE_PREFIX.'pages` ';
1477
		$sql .= 'WHERE `link` != \'\' ORDER BY `link` ';
1478
        if (($oPage = $database->query($sql)))
1464
	// set logging informations
1465
		$aRetval = array_merge((isset($aRetval) ? $aRetval : array()),
1466
		                       createFolderProtectFile(rtrim( $oReg->AppPath.$oReg->PagesDir, '/') ));
1467
	// Reformat/rebuild all existing access files
1468
		$sql  = 'SELECT `page_id`,`root_parent`,`parent`,`link`,`level`,`page_trail` '
1469
		      . 'FROM `'.$oDb->TablePrefix.'pages` '
1470
		      . 'WHERE `link` != \'\' '
1471
		      . 'ORDER BY `link`';
1472
        if (($oPage = $oDb->query($sql)))
1479 1473
        {
1480
            $x = 0;
1481
            while (($page = $oPage->fetchRow(MYSQL_ASSOC)))
1474
            $iFileCounter = 0;
1475
		// iterate over all existing page records
1476
            while (($aPageRecord = $oPage->fetchRow(MYSQL_ASSOC)))
1482 1477
            {
1483
                // Work out level
1484
                $level = level_count($page['page_id']);
1485
                // Work out root parent
1486
                $root_parent = root_parent($page['page_id']);
1487
                // Work out page trail
1488
                $page_trail = get_page_trail($page['page_id']);
1489
                // Update page with new level and link
1490
                $sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
1491
                $sql .= '`root_parent` = '.$root_parent.', ';
1492
                $sql .= '`level` = '.$level.', ';
1493
                $sql .= '`page_trail` = "'.$page_trail.'" ';
1494
                $sql .= 'WHERE `page_id` = '.$page['page_id'];
1495

  
1496
                if(!$database->query($sql)) {}
1497
                $filename = WB_PATH.PAGES_DIRECTORY.$page['link'].PAGE_EXTENSION;
1498
                create_access_file($filename, $page['page_id'], $page['level']);
1499
                $x++;
1478
		// --- begin reorg tree structure ------------------------------------------------
1479
			// rebuild level entries
1480
				$sql = 'SELECT `level`+1 AS `level`, `page_trail` '
1481
				     . 'FROM `'.$oDb->TablePrefix.'pages` '
1482
					 . 'WHERE `page_id`='.$aPageRecord['parent'];
1483
			// search for parent record
1484
				$oParent = $oDb->query($sql);
1485
				if(($aParentRecord = $oParent->fetchRow(MYSQLI_ASSOC)))
1486
				{
1487
				// get values from existing parent record
1488
					$aPageRecord['level'] = intval($aParentRecord['level']);
1489
					$aPageRecord['root_parent'] = intval($aParentRecord['page_trail']);
1490
					$aPageRecord['page_trail'] = (string)$aParentRecord['page_trail'].','.(string)$aPageRecord['page_id'];
1491
				}else
1492
				{
1493
				// set as root record if no parentrecord exists
1494
					$aPageRecord['level'] = 0;
1495
					$aPageRecord['root_parent'] = $aPageRecord['page_id'];
1496
					$aPageRecord['page_trail'] = (string)$aPageRecord['page_id'];
1497
				}
1498
			// update current record with regenerated values
1499
                $sql  = 'UPDATE `'.$oDb->TablePrefix.'pages` '
1500
				      . 'SET `root_parent`='.$aPageRecord['root_parent'].', '
1501
				      .     '`level`='.$aPageRecord['level'].', '
1502
				      .     '`page_trail`=\''.$aPageRecord['page_trail'].'\' '
1503
				      . 'WHERE `page_id`='.$aPageRecord['page_id'];
1504
				$oDb->query($sql);
1505
		// --- end reorg tree structure --------------------------------------------------
1506
                $sFilename = $oReg->AppPath.$oReg->PagesDir.$aPageRecord['link'].$oReg->PageExtension;
1507
				$oAccessFile = new AccessFile($sFilename, $aPageRecord['page_id']);
1508
				$oAccessFile->write();
1509
				unset($oAccessFile);
1510
                $iFileCounter++;
1500 1511
            }
1501
            $aRetval[] = 'Number of new formated access files: '.$x.'';
1512
            $aRetval[] = 'Number of new formated access files: '.$iFileCounter;
1502 1513
        }
1503
    return $aRetval;
1504
	}
1505
}
1514
		return $aRetval;
1515
	} // end of function rebuild_all_accessfiles()
1516
} // endif
1506 1517

  
1507 1518
if(!function_exists('upgrade_modules')){
1508 1519
	function upgrade_modules($aModuleList) {

Also available in: Unified diff