Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function list_ini_load($source='',$sep="\r\n",$type='file') {
- global $list_debug;
- $dat=list_from_source($source,$sep,$type);
- $local['pair']['pattern']='/\r\n"([^"]+?)"="([^"]+?)"\r\n/';
- $local['pair']['lead']='pair';
- $local['pair']['label']='$1';
- $local['pair']['value']='$2';
- $local['lead']['pattern']='/\r\n([\-\~\!\@\#\$\%\^\&\*\+\=\_\?\.\:])([^\-\"\ \~\!\@\#\$\%\^\&\*\+\=\?\.\:]+?) "([^"]+?)"\r\n/';
- $local['lead']['lead']='$1';
- $local['lead']['label']='$2';
- $local['lead']['value']='$3';
- $local['if']['pattern']='/\r\n([\-\~\!\@\#\$\%\^\&\*\+\=\_\?\.\:])if\(([^\-\"\ \~\!\@\#\$\%\^\&\*\+\=\?\.\:]+?)="([^"]+?)"\)\r\n/';
- $local['if']['lead']='$1';
- $local['if']['label']='$2';
- $local['if']['value']='$3';
- $ret=null;
- for($ln=0;$ln<$dat['ct'];$ln++) {
- list_log_debug($debug,null,'line[<font color="red">'.$ln.'</font>]=[<font color="red">'.$dat[$ln].'</font>]');
- unset($temp);
- foreach($local as $tier => $cast)
- foreach($cast as $key => $value)
- if($key !== 'pattern'){
- $temp[$tier][$key]=preg_replace($cast['pattern'],$value,"\r\n".$dat[$ln]."\r\n");
- if($temp[$tier][$key]==="\r\n".$dat[$ln]."\r\n")
- unset($temp[$tier][$key]);
- else
- list_log_debug($debug,null,htmlentities($tier).'[<font color="red">'.htmlentities($key).'</font>]="<font color="red">'.htmlentities($temp[$tier][$key]).'</font>" from "<font color="red">'.htmlentities($value).'</font>","<font color="red">'.htmlentities($dat[$ln]).'</font>"');
- }
- $method='comment';
- if(isset($temp['pair']['lead']))
- if($temp['pair']['lead'] === 'pair')
- $method='pair';
- if(isset($temp['if']['lead']))
- if(strlen($temp['if']['lead']) > 0)
- $method='if';
- if(isset($temp['lead']['lead']))
- if(strlen($temp['lead']['lead']) > 0)
- $method='lead';
- list_log_debug($debug,null,'method: <font color="red">'.htmlentities($method).'</font>');
- switch($method){
- case 'comment':
- list_log_debug($debug,null,'comment: <font color="red">'.htmlentities($dat[$ln]).'</font>');
- break;
- case 'pair':
- list_log_debug($debug,null,'pair[<font color="red">'.$temp[$method]['label'].'</font>]=[<font color="red">'.$temp[$method]['value'].'</font>]');
- $ret[$temp[$method]['label']]=$temp[$method]['value'];
- break;
- case 'lead':
- switch($temp[$method]['lead']){
- case '#':
- switch($temp[$method]['label']){
- case 'include':
- list_log_debug($debug,null,'include[<font color="red">'.htmlentities($method).'</font>]=[<font color="red">'.$temp[$method]['value'].'</font>]');
- $tempdat=list_from_source($temp[$method]['value'],$sep,'file');
- for($ln2=$ln+1;$ln2<$dat['ct'];$ln2++)
- $dat[$ln2+$tempdat['ct']]=$dat[$ln2];
- for($ln2=0;$ln2<$tempdat['ct'];$ln2++)
- $dat[$ln+$ln2+1]=$tempdat[$ln2];
- $dat['ct']+=$tempdat['ct'];
- ksort($dat);
- break;
- }
- break;
- case '@':
- switch($temp[$method]['label']){
- case 'include':
- list_log_debug($debug,null,'include[<font color="red">'.htmlentities($method).'</font>]=[<font color="red">'.$ret[$temp[$method]['value']].'</font>]');
- $tempdat=list_from_source($ret[$temp[$method]['value']],$sep,'file');
- for($ln2=$ln+1;$ln2<$dat['ct'];$ln2++)
- $dat[$ln2+$tempdat['ct']]=$dat[$ln2];
- for($ln2=0;$ln2<$tempdat['ct'];$ln2++)
- $dat[$ln+$ln2+1]=$tempdat[$ln2];
- $dat['ct']+=$tempdat['ct'];
- ksort($dat);
- break;
- }
- break;
- case '$':
- list_log_debug($debug,null,'eval: global $<font color="red">'.htmlentities($temp[$method]['label']).'</font>; <-- file:"<font color="red">'.$temp[$method]['value'].'</font>"');
- eval('global $'.$temp[$method]['label'].';');
- $tempdat=list_ini_load($temp[$method]['value'],$sep,$type);
- foreach($tempdat as $key => $value){
- eval('$'.$temp[$method]['label'].'[\''.$key.'\']=\''.addslashes($value).'\';');
- list_log_debug($debug,null,'load: $<font color="red">'.htmlentities($temp[$method]['label']).'</font>[\'<font color="red">'.htmlentities($key).'</font>\']=\'<font color="red">'.addslashes($value).'</font>\';');
- }
- break;
- case '~':
- $ret[$temp[$method]['label']]=$ret[$temp[$method]['value']].$ret[$temp[$method]['label']];
- break;
- case '.':
- $ret[$temp[$method]['label']].=$temp[$method]['value'];
- break;
- case '?':
- if(isset($_GET[$temp[$method]['value']]))
- $ret[$temp[$method]['label']]=$_GET[$temp[$method]['value']];
- else
- if(!isset($ret[$temp[$method]['label']]))
- $ret[$temp[$method]['label']]='';
- break;
- case '=':
- $ret[$temp[$method]['label']]=$ret[$temp[$method]['value']];
- break;
- }
- break;
- case 'if':
- switch($temp[$method]['lead']){
- case '#':
- if(!isset($ret[$temp[$method]['label']]))
- $ln++;
- elseif($ret[$temp[$method]['label']]!==$temp[$method]['value'])
- $ln++;
- break;
- case '@':
- if(!isset($ret[$temp[$method]['label']]))
- $ln++;
- if(!isset($ret[$temp[$method]['value']]))
- $ln++;
- elseif($ret[$temp[$method]['label']]!==$ret[$temp[$method]['value']])
- $ln++;
- break;
- }
- break;
- }
- }
- ksort($dat);
- return $ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement