Location: PHPKode > projects > ActualAnalyzer > info.php
<?php

$path=aa_cpath();

$arr=preg_split("/\//",$path);
$max=sizeof($arr);
$arr[$max-1]='';
$path=join('/',$arr);

echo "<br> <b>Path:</b> $path";

$address=aa_cpage();

$arr=preg_split("/\//",$address);
$max=sizeof($arr);
$arr[$max-1]='';
$address=join('/',$arr);

echo "<br> <b>Address:</b> $address";

function aa_cpath() {
  global $_SERVER,$HTTP_SERVER_VARS;

  $page='';
  if(isset($_SERVER['PATH_TRANSLATED'])) $page=$_SERVER['PATH_TRANSLATED'];
  elseif(isset($HTTP_SERVER_VARS['PATH_TRANSLATED'])) $page=$HTTP_SERVER_VARS['PATH_TRANSLATED'];
  elseif(isset($_SERVER['SCRIPT_FILENAME'])) $page=$_SERVER['SCRIPT_FILENAME'];
  elseif(isset($HTTP_SERVER_VARS['SCRIPT_FILENAME'])) $page=$HTTP_SERVER_VARS['SCRIPT_FILENAME'];

  return $page;
}

function aa_cpage() {
  global $_SERVER,$HTTP_SERVER_VARS;

  //address of current page
  $page='http://';
  if(isset($_SERVER['HTTP_HOST'])) $page.=$_SERVER['HTTP_HOST'];
  elseif(isset($HTTP_SERVER_VARS['HTTP_HOST'])) $page.=$HTTP_SERVER_VARS['HTTP_HOST'];
  elseif(isset($_SERVER['SERVER_NAME'])) $page.=$_SERVER['SERVER_NAME'];
  elseif(isset($HTTP_SERVER_VARS['SERVER_NAME'])) $page.=$HTTP_SERVER_VARS['SERVER_NAME'];
  else return '';
  if(isset($_SERVER['REQUEST_URI'])) $page.=$_SERVER['REQUEST_URI'];
  elseif(isset($HTTP_SERVER_VARS['REQUEST_URI'])) $page.=$HTTP_SERVER_VARS['REQUEST_URI'];
  else {
    if(isset($_SERVER['SCRIPT_NAME'])) $page.=$_SERVER['SCRIPT_NAME'];
    elseif(isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) $page.=$HTTP_SERVER_VARS['SCRIPT_NAME'];
    else return '';
    if(isset($_SERVER['QUERY_STRING'])) $page.='?'.$_SERVER['QUERY_STRING'];
    elseif(isset($HTTP_SERVER_VARS['QUERY_STRING'])) $page.='?'.$HTTP_SERVER_VARS['QUERY_STRING'];
  }

  //to correct back slashes            http://actualscripts.com\index\
  $page=str_replace("\\","/",$page);
  //to remove unnecessary points       http://actualscripts.com.
  $page=preg_replace("/\/\./",'/',$page);
  $page=preg_replace("/\.\//",'/',$page);
  $page=preg_replace("/\.*$/",'',$page);
  $page=preg_replace("/(\"|\')*$/",'',$page);
  //to remove unnecessary duplicates of slashes             http://actualscripts.com///
  $page=preg_replace("/([^:])(\/)+/",'$1/',$page);

  return $page;
}

?>
Return current item: ActualAnalyzer