Location: PHPKode > projects > LabWiki > labwiki/index.php
<?php 
require_once( "_global.php" );

// Disable Caching
QWDisableCaching();

// Update the list of recently viewed pages
$recentlyViewedPages[] = $QW['page'];
if ( isset( $QW['cookieRecentPageList'] ) ) {$QW['cookieRecentPageList'] = array_merge( array( $QW['page'] ), $QW['cookieRecentPageList'] );}
else {$QW['cookieRecentPageList'] = array( $QW['page'] );}
$QW['cookieRecentPageList'] = QWUnduplicateArray( $QW['cookieRecentPageList'] );
QWTruncateArrayInPlace( $QW['cookieRecentPageList'], 20 ); // only keep a history of 20 pages
setcookie( "recentpages", serialize( $QW['cookieRecentPageList'] ), time()+60*60*24*30 );


// QWTIndexFormatGlobalNav
$QW_TEMPLATE['getGlobalNavPageNameList'] = "QWTIndexFormatGlobalNav";
function QWTIndexFormatGlobalNav( )
{global $QW_CONFIG;
return QWFormatQwikiText( $QW_CONFIG['globalNav'] );}
// QWTIndexFormatTitle
$QW_TEMPLATE['getTitle'] = "QWTIndexFormatTitle";
function QWTIndexFormatTitle( )
{global $QW;
return "Document: " . QWCleanQwikiPageName( $QW['page'] );}

// QWTIndexFormatBody
$QW_TEMPLATE['injectBody'] = "QWTIndexFormatBody";
function QWTIndexFormatBody( )
{global $QW;
return QWFormatQwikiFile( $QW['pagePath'] );}

// QWTIndexFormatCommandList
$QW_TEMPLATE['commandList'] = "QWTIndexFormatCommandList";
function QWTIndexFormatCommandList( )
{
 global $QW, $QW_CONFIG, $_SERVER;	
 if($QW['userIsAuthenticated'])
   {
   $commandList[]='<a href="logout.php?page='.$QW['page'].$QW['URLSuffix'].'">Admin logout</a>';
   $commandList[] = '<a href="backups.php?page='.$QW['page'].'">Backup maintainance</a>';
   if(!QWLockExists($QW['lockPath']))
     {
     $commandList[] = '<a href="javascript:confirmdelete(\'delete.php?page='.$QW['page'].'\');" title="Delete this page">Delete this page</a>';
     }
   }
   else{$commandList[]='<a href="login.php?page='.$QW['page'].$QW['URLSuffix'].'">Admin login</a>';}
 if($QW['requestFrom']){$fromSuffix="&amp;from=$QW[requestFrom]";}
   else{$fromSuffix="";}
 if(!$QW['pageIsProtected']||$QW['userIsAuthenticated'])
   {
   if(QWLockExists($QW['lockPath'])) 
	 {
	 if(QWHoldsLockfile($QW['globalLockPath'],$QW['lockPath'],$_SERVER['REMOTE_ADDR']))
	   {$commandList[]='<a href="edit.php?page='.$QW['page'].$fromSuffix.$QW['URLSuffix'].'">(Continue editing this page)</a>';}
     else{$commandList[]="(Page is being edited)";}
	 }
   else          
	 {
	 if (empty($QW_CONFIG['ipArray']))
	 {
	 $commandList[] = '<a href="edit.php?page='.$QW['page'].$fromSuffix.$QW['URLSuffix'].'">Edit this page</a>';
	 }
	 else
	 {
       if(empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
         {$IP=$_SERVER["REMOTE_ADDR"];}
       else{$IP=$_SERVER["HTTP_X_FORWARDED_FOR"];} 
       $lh = gethostbyaddr($_SERVER['REMOTE_ADDR']);
       $test=$IP.".".$lh;
       // if clause to show 'edit' link based on IP address checking
       if(in_array($test, $QW_CONFIG['ipArray']) || in_array($IP, $QW_CONFIG['ipArray']))
         {$commandList[] = '<a href="edit.php?page='.$QW['page'].$fromSuffix.$QW['URLSuffix'].'">Edit this page</a>';
         }
       }
     }
   }

if( $QW_CONFIG['emailEnable'] ) {$commandList[] = '<a href="mailinglist.php?page='.$QW['page'].$QW['URLSuffix'].'">'.$QW['page'].' mailing list</a>';}
// to show link to disclaimer page - itself a wiki document
$commandList[]='<a href="index.php?page=Disclaimer">Disclaimer</a>';
return $commandList;
}

// Include the template
include_once( $QW_CONFIG['templateFilename'] );

// Output debugging, if requested
if( $QW_CONFIG['enableDebugging'] && $QW['requestDebug'] ) echo QWFormatDebug( );

// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);
?>
Return current item: LabWiki