<?php
// Xinfeng Chen, 2002.10.31

define('SP',"\x07");

$_zbbForumBasePath='';

class CForumBase {

 function _getNormalizedName($a_name){
  $tmp=preg_replace("/[\x01-\\x2F|\x3A-\x40|\x5B-\x60|\x7B-\x7F]/","_",$a_name);
  $tmp=strtr($tmp,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  return $tmp;
 }

 function setFileBase($a_path){
  global $_zbbForumBasePath;
  $_zbbForumBasePath = $a_path;
 }

 function getFilePath($a_objType='',$a_name1='',$a_name2=''){
  global $_zbbForumBasePath;
  switch($a_objType){
	case 'NEWS': $path="$_zbbForumBasePath/bbs/$a_name1/news.dat";break; 
	case 'NOTE': $path="$_zbbForumBasePath/etc/note.dat";break; 
	case 'RANK': $path="$_zbbForumBasePath/sys/rank.dat";break; 
	case 'BLIST':
	 $tmp=($a_name1) ? "$a_name1.lst" : 'blist.dat';
	 $path="$_zbbForumBasePath/bbs/$tmp";break; 
	case 'BOARD': $path="$_zbbForumBasePath/bbs/$a_name1/info.dat";break; 
	case 'PERMISSION': $path="$_zbbForumBasePath/bbs/$a_name1/acl.dat";break;
	case 'TLIST': $path="$_zbbForumBasePath/bbs/$a_name1/tlist.dat";break; 
	case 'TINDEX': $path="$_zbbForumBasePath/bbs/$a_name1/tindex.dat";break; 
	case 'TOPIC': $path="$_zbbForumBasePath/bbs/$a_name1/$a_name2";break; 
	case 'REPLYSET': $path="$_zbbForumBasePath/bbs/$a_name1/$a_name2";break; 
	case 'ACTIVITY': $path="$_zbbForumBasePath/etc/activity.dat";break; 
	case 'LOGGROUP': $path="$_zbbForumBasePath/etc/filegroup.log";break; 
	case 'LOG': $path="$_zbbForumBasePath/etc/LG$a_name1.log";break; 
	case 'USER': 
	 $tmp=CForumBase::_getNormalizedName($a_name1);
	 $path="$_zbbForumBasePath/usr/$tmp.dat";
	 break; 
	case 'MAILBOX':
	 $tmp=CForumBase::_getNormalizedName($a_name1);
	 $path="$_zbbForumBasePath/msg/$tmp.dat";
	 break; 
	case 'BACKUPDIR': $path="$_zbbForumBasePath/backup";break; 
	case 'BASEDIR':
	default:
	 $path=$_zbbForumBasePath;break;
  }
  return $path;
 }

 function getDirPath($a_objType='',$a_name1=''){
  global $_zbbForumBasePath;
  switch($a_objType){
	case 'BOARD': $path="$_zbbForumBasePath/bbs/$a_name1";break; 
	case 'LOG': $path="$_zbbForumBasePath/etc";break; 
	case 'USER': $path="$_zbbForumBasePath/usr";break; 
	case 'MAILBOX': $path="$_zbbForumBasePath/msg";break; 
	case 'BACKUP': $path="$_zbbForumBasePath/backup";break; 
	case 'BASE':
	default:
	 $path=$_zbbForumBasePath;break;
  }
  return $path;
 }
}

?>