Location: PHPKode > projects > Pearl Forums > pearlforums2.4/includes/adminSettings.php
<?
////////////////////////////////////////////////////////////////////////////
//  Program:        Pearl Forums
//  First Release:  February 20, 2004
//  Version:        2.4 - April 6, 2005
//  Author:         Binh Thuong Nguyen
//  Copyright:      Pearlinger - http://www.pearlinger.com
//  Script File:    adminSettings.php - Update global preferences and 
//                  settings in Admin.
//  -----------------------------------------------------------------------
//  This program is free software and distributed under the terms of the
//  GNU General Public License by the Free Software Foundation, and is
//  WITHOUT ANY WARRANTY/LIABILITY (see license.txt for more details).
//  Copyright notices on outputs can be removed by contributing a small 
//  donation to help us offset costs of maintaining and further development,
//  distribution of Pearl.  Please visit pearlinger.com for more details.
////////////////////////////////////////////////////////////////////////////

include_once("$GlobalSettings[templatesDirectory]/adminSettings.php");
$Document[contentWidth]="90%";
$action=$VARS['action']==""?"entry":$VARS['action'];

$exe="{$action}Settings";
$exe();	

//  Get entry screen
function entrySettings(){
	global $Document;		
	$Document['contents'] .= getFormHTML(true,$Document);
}//entrySettings

//  Update settings
function updateSettings(){
	global $GlobalSettings,$Member,$Document,$Language,$AdminLanguage,$VARS;		
	extract($GlobalSettings,EXTR_PREFIX_ALL,"Global");	
	extract($VARS,EXTR_OVERWRITE);		
	$isError=false;
	if($restore){
		$sql="select name,defaultValue from {$Global_DBPrefix}DefaultSettings where type=\"variable\"";
		$fetchedData=mysql_query($sql) or commonLogError($sql,true);
		while($dataSet = mysql_fetch_array($fetchedData)){
			$$dataSet[name]=$dataSet['defaultValue'];	
		}
	}

	if(trim($languagePreference)==""){//language preference is required
		$isError=true;
		$Document[msg] = "<LI>$AdminLanguage[LanguagePreference] $Language[required]";
	}
	else{
		if(!file_exists("$languagePreference")){ // language folder must exist
			$isError=true;
			$Document[msg] .= "<BR /><LI>" . $AdminLanguage['Nonexistlanguagepref'];
		}
	}
	if(!$width){
		$isError=true;
		$Document[msg] .= "<BR /><LI>$AdminLanguage[TemplateWidth] $Language[required].";
	}	
	if(!$sessionDuration){
		$isError=true;
		$Document[msg] .= "<BR /><LI>$AdminLanguage[SessionDuration] $Language[required].";
	}	
	if(!$postingsPerPage){
		$isError=true;
		$Document[msg] .= "<BR /><LI>$AdminLanguage[PostingsPerPage] $Language[required].";
	}	
	if(!$listingsPerPage){
		$isError=true;
		$Document[msg] .= "<BR /><LI>$AdminLanguage[ListingsPerPage] $Language[required].";
	}
	if($isError){
		$Document['contents'] .= getFormHTML(false,$VARS);
	}
	else{
		if($SpamGuardFolder != $oSpamGuardFolder){
			$moveStatus=rename($oSpamGuardFolder,$SpamGuardFolder);
			if(!$moveStatus){			
				$Document[msg] .= "<BR /><LI>$AdminLanguage[spamguardfolderfailed].";		
				$SpamGuardFolder=$oSpamGuardFolder;
			}
		}

		$avatarTypes=trim($avatarTypes);
		$avatarTypes="array(\"" . str_replace(" ","\",\"",$avatarTypes)  . "\")";
		$disallowAttachmentTypes=trim($disallowAttachmentTypes);
		$disallowAttachmentTypes="array(\"" . str_replace(" ","\",\"",$disallowAttachmentTypes)  . "\")";
		$organization=htmlspecialchars(stripslashes($organization));
		$title=htmlspecialchars(stripslashes($title));
		//contents of the settings.php file
		$contents=<<<EOF
<?
////////////////////////////////////////////////////////////////////////////
//  Program:        Pearl Forums
//  First Release:  February 20, 2004
//  Version:        2.4 - April 6, 2005
//  Author:         Binh Thuong Nguyen
//  Copyright:      Pearlinger - http://www.pearlinger.com
//  Script File: 	settings.php - Hold global settings and variables.
//  -----------------------------------------------------------------------
//  This program is free software and distributed under the terms of the
//  GNU General Public License by the Free Software Foundation, and is
//  WITHOUT ANY WARRANTY/LIABILITY (see license.txt for more details).
//  Copyright notices on outputs can be removed by contributing a small 
//  donation to help us offset costs of maintaining and further development,
//  distribution of Pearl.  Please visit pearlinger.com for more details.
////////////////////////////////////////////////////////////////////////////

//  Note: Although generated by adminSettings.php, you can update existing 	
//  variables' values here directly.  However, if you add new variables or make 
//  changes to existing variables' names please do so in the adminSettings.php file.

global \$GlobalSettings,\$Document,\$Member,\$VARS,\$Language,\$AdminLanguage; 

//  Database:begin
\$GlobalSettings['DBServer']                  = "$DBServer";
\$GlobalSettings['DBName']                    = "$DBName";
\$GlobalSettings['DBUser']                    = "$DBUser"; 
\$GlobalSettings['DBPassword']                = "$DBPassword"; 
\$GlobalSettings['DBPrefix']                  = "$DBPrefix";
//  Database:end

//General
\$GlobalSettings['Organization']              = "$Organization";
\$GlobalSettings['WebmasterEmail']            = "$WebmasterEmail";		
\$GlobalSettings['RegistrationSpamGuard']     = "$RegistrationSpamGuard";	
\$GlobalSettings['LoginSpamGuard']            = "$LoginSpamGuard";	
\$GlobalSettings['SpamGuardFolder']           = "$SpamGuardFolder";	
\$GlobalSettings['MaxAddressBook']			  = "$MaxAddressBook";

\$Document['membersOnly']                     = "$membersOnly";  
\$Document['checkBannedIPs']                  = "$checkBannedIPs";  
\$Document['checkSensoredWords']              = "$checkSensoredWords";  
\$Document['languagePreference']              = "$languagePreference";
\$Document['allowGuestPosting']               = "$allowGuestPosting";
\$Document['allowAttachments']                = "$allowAttachments";
\$Document['allowMessageAttachments']         = "$allowMessageAttachments";
\$Document['allowNotify']                     = "$allowNotify";
\$Document['displayMemberProfile']            = "$displayMemberProfile"; 
\$Document['showEditTime']                    = "$showEditTime";
\$Document['showModerators']                  = "$showModerators";
\$Document['showForumInfo']                   = "$showForumInfo";
\$Document['showBoardDescription']            = "$showBoardDescription";
\$Document['showIPs']                         = "$showIPs";
\$Document['graphicButtons']                  = "$graphicButtons";
\$Document['linkColor']                       = "$linkColor"; 
\$Document['textColor']                       = "$textColor";
\$Document['title']                           = "$title"; 
\$Document['width']                           = "$width";
\$Document['allowableTags']                   = "$allowableTags";
\$Document['badAttributes']                   = "$badAttributes";
\$Document['avatarSize']                      = "$avatarSize"; 
\$Document['avatarWidth']                     = "$avatarWidth";
\$Document['avatarHeight']                    = "$avatarHeight";
\$Document['avatarTypes']                     = $avatarTypes;
\$Document['disallowAttachmentTypes']         = $disallowAttachmentTypes;
\$Document['attachmentSize']                  = "$attachmentSize";
\$Document['sessionDuration']                 = "$sessionDuration"; #Default 1 day - 86400
\$Document['postingsPerPage']                 = "$postingsPerPage";
\$Document['listingsPerPage']                 = "$listingsPerPage";
\$Document['maxMemberMessages']               = "$maxMemberMessages";
\$Document['maxMessageAttachment']            = "$maxMessageAttachment"; #Default 1MB - 1024000
\$Document['MaxPagingLinks']				  = "$MaxPagingLinks";

// Variables below this line can not be changed through the Admin's Settings section.
// You might want to leave them the way they are.
\$GlobalSettings['pearlVersion']              = "2.4";
\$GlobalSettings['serverName']                = \$SERVER_NAME;
\$GlobalSettings['boardPath']                 =  str_replace("/" . basename(\$PHP_SELF),"",\$PHP_SELF);// "/forums";			
\$GlobalSettings['includesDirectory']         = "includes"; #Functions & source files
\$GlobalSettings['templatesDirectory']        = "templates"; #HTML layout files
\$GlobalSettings['attachmentPath']            = "attachments";
\$GlobalSettings['avatarsPath']               = "avatars";
\$GlobalSettings['smileysPath']               = "smileys";
\$GlobalSettings['messageAttachmentPath']     = \$GlobalSettings['attachmentPath'] . "/messages";

\$Document['mainScript']                      = \$PHP_SELF;
\$Document['spacer']                          = "&nbsp;&nbsp;";
\$Document['contents']                        = "";
\$Document['navigation']                      = "";
\$Document['onLoad']                          = "";
\$Document['onUnload']                        = "";
\$Document['quickLogin']                      = "";
\$Document['forumNavigation']                 = "";
\$Document['moderators']                      = array();
\$Member                                      = array();
\$Language                                    = array();
\$AdminLanguage                               = array();
\$VARS                                        = array();
?>
EOF;
		$fp = fopen ("settings.php", "w"); 
		fputs ($fp,$contents); 
		fclose ($fp); 
		
		$Document['msg'] .= "$AdminLanguage[Recordupdated]";
		$Document['contents'] .= reloadHTML();
	}
	
}//updateSettings

?>
Return current item: Pearl Forums