00001 <?php
00021 $__ZIGFSTAB = false;
00022
00023 if(!function_exists('fstab')){
00024 function fstab($prjName = null, $data = null){
00025 global $__ZIGFSTAB;
00026 if(!$__ZIGFSTAB){
00027 $fstab = file(ZIGSETTINGS.DRS.'fstab.php');
00028 unset($fstab[0]);
00029 foreach($fstab as $i => $elem){
00030 $fstab[$i] = preg_split('~\s+~', trim($elem));
00031 if(count($fstab[$i]) > 3){
00032 perror('Failed to parse the `'.ZIGSETTINGS.DRS.'/fstab.php` Properly near line '.$i.' Unexected '.count($fstab[$i]).' params on a single line expecting Just 3');
00033 return false;
00034 }
00035 if(@$fstab[$i][2] != '0' && @$fstab[$i][2] != '1'){
00036 perror('Failed to parse the fstab file Properly near line '.$i.'unexpected value '.@$fstab[$i][2].' expecting either 0 or 1');
00037 return false;
00038 }else{
00039 if($fstab[$i][2] == '1')$fstab[$i][2] = true;
00040 else $fstab[$i][2] = false;
00041 }
00042 }
00043 $__ZIGFSTAB = $fstab;
00044 }else{
00045 $fstab = $__ZIGFSTAB;
00046 }
00047 if(is_null($prjName))return $fstab;
00048 foreach($fstab as $lex){
00049 if($lex[0] == $prjName){
00050 $ret = $lex;
00051 break;
00052 }
00053 }
00054 if(!isset($ret)){
00055 perror("Project `$prjName` doesn't exists");
00056 return;
00057 }
00058 switch($data){
00059 case null:
00060 return $ret;
00061 break;
00062 case 'name':
00063 return $ret[0];
00064 break;
00065 case 'dir':
00066 return $ret[1];
00067 break;
00068 case 'index':
00069 return $ret[2];
00070 break;
00071 }
00072 }
00073 }
00074
00075 function fstab_getPrimaryProject(){
00076 foreach(fstab() as $project){
00077 if($project[2]){
00078 return $project[0];
00079 }
00080 }
00081 }
00082 function fstab_getProjectDirByName($name){
00083 foreach(fstab() as $project){
00084 if($project[0] == $name)return $project[1];
00085 }
00086 }
00087 ?>