<?php
function extract_nom($files='') {
  $reslut['rub']='';
  $reslut['keyrub']='';
  $reslut['arg']='';

   if (!empty($files)) $f=$files;
   else $f=$_SERVER['REQUEST_URI'];
   $reslut['original'] = $f;

   if ( defined('CHEMIN_ADMIN') && (eregi(CHEMIN_ADMIN, $f)) ) $data= substr($f,strlen(CHEMIN_ADMIN));
   elseif (eregi(CHEMIN_DU_SITE, $f)) $data= substr($f,strlen(CHEMIN_DU_SITE));
   elseif (eregi(URL_DU_SITE, $f)) $data= substr($f,strlen(URL_DU_SITE));
   else $data=$f;


  if (substr($data,0,9)=='index.php') $data=substr($data,9);
  if(substr($data,0,1)=='?') $data=substr($data,1);

  //! chemin
  $chemin=str_replace('//','/',dirname($data));
  if( !preg_match( "/^.*\/$/", $chemin ) ) $chemin .= '/';


  $b=basename($data);
  //! file
  $reslut['p']= $p=strpos($b,'&');
  $reslut['file']=$nom=($p>0)? substr($b,0,$p) : $b;
  //! arg get3
  $reslut['arg']=($p>0)?substr($b,$p) : '';

  //! ext
  $reslut['ext']=(strpos($reslut['file'],EXT)>0)?substr($reslut['file'],-(strlen(EXT))) : '';
  $reslut['file']=(strpos($reslut['file'],EXT)>0)?substr($reslut['file'],0,-(strlen(EXT)+1)) : $reslut['file'];

  $t=explode('/',$chemin);
  foreach($t as $value){
    if (!in_array($value.'/', array('./',REP_DATA,'/',EXT) ) && !preg_match("/^[a-z]{2}$/", $value)) { $reslut['keyrub']=$value; $reslut['rub'].=$value.'/'; }
    elseif(preg_match("/^[a-z]{2}$/", $value)) $reslut['lang']=$value;
  }

  $reslut['url']=$reslut['rub'].$reslut['file'];

  return $reslut;
}
?>