print "1";
error_reporting (E_ALL);
//to prevent any notice about unexistente variables....
$note = "";
$warning ="";
$author_menu="";
$auth_text_full="";
// directory listing function
function listing($dir){
if(is_dir($dir)){
if($open_dir=opendir($dir)){
$listing=array();
while(($read_dir=readdir($open_dir))!=false){
if($read_dir!="." and $read_dir!=".." and $read_dir!="vekper1900.css" and $read_dir!="vekper.css" and $read_dir!="error_log" and $read_dir!="index.php"){
if (!is_dir($read_dir)){ $listing[]=$read_dir;}
}
}
closedir($open_dir);
return $listing;
foreach ($listing as $listing) {
echo $listing->type;
echo "
";
}
}else{
exit("Нет доступа к каталогу!");
print "1";
}
}else{
exit("Отсутствует каталог!");
print "1";
}
}
// END directory listing function
//analyse author info
function analyse_author_info($author_info){
$id = $_GET['file']."->".$_SERVER['PHP_SELF'];
if(preg_match('|
(.*)
|Uis', $author_info, $name)){$trans['title']=strip_tags($name[0]);}
else{$err[]="$id/title";}
if(preg_match('|(.*)
|Uis', $author_info, $transname)){$trans['full_name']=strip_tags($transname[0]);}
else{$err[]="$id/transname";}
if(preg_match('|(.*)
|Uis', $author_info, $lifespan)){$trans['lifespan']=strip_tags($lifespan[0]);}
else{$err[]="$id/lifespan";}
if(preg_match('|(.*)
|Uis', $author_info, $introduction)){$trans['about']=strip_tags($introduction[0]);}
else{$err[]="$id/links";}
if(preg_match('|(.*)
|Uis', $author_info, $links)){$trans['links']=strip_tags($links[0]);}
else{$err[]="$id/links";}
if(preg_match('|(.*)
|Uis', $author_info, $warning)){$trans['warning']=strip_tags($warning[0]);}
else{$err[]="$id/links";}
if(preg_match('|(.*)
|Uis', $author_info, $note)){$trans['note']=strip_tags($note[0]);}
else{$err[]="$id/links";}
//print_r ($trans);
$trans['errors']= $err;
//if (mb_strlen($trans['full_name'],"UTF-8")===strlen(iconv("UTF-8","cp1251",$trans['full_name']))){$trans=iconv("utf-8", "windows-1251", "$trans");}
return $trans;
}
if(is_file($_GET['file'])&&is_file($_GET['file'])){
$file = $_GET['file'];
$filepath="$file";
$domain=$_SERVER['SERVER_NAME'];
$fsize = $size['original_file']=filesize($filepath);
$link="$file";
print ("Обратывается файл: $file ($fsize bytes)");
$html = fopen($filepath, "a+");
if (!$html) {
echo("Ошибка при открытии файла!");
}
else {
$raw_data = fread($html, $fsize);
fclose($html);
$size['pure_text']=strlen(strip_tags($raw_data));
//print "
имеем ".$size['pure_text']."Kb. чистого текста
";
$data = explode("",$raw_data);
$trans = analyse_author_info($data[0]);
unset($data[0]);
foreach($data as $key => $value){
if ($autor_name = preg_match('|(.*)
|Uis',$value, $out[$key] )){}
else{$err[]="$link/author_name";}
$author[$key]['aut_full_name']=strip_tags($out[$key][0]);
if ($autor_life = preg_match('|(.*)
|Uis',$value, $out[$key] )){}else{$err[]="$link/author_name";}
$author[$key]['auth_lifespan']=strip_tags($out[$key][0]);
$search = array ("'.*?'si",
"'.*?
'si");
$replace = array ("",
"");
$text = preg_replace($search, $replace, $value, 1);
$author[$key]['auth_text']=$text;
}
$trans_name=$trans['full_name'];
$link_to_menu ="link_to_index ";
$trans_lifespan = $trans['lifespan'];
$about = $trans['about'];
if (isset($trans['warning'])){$warning = $trans['warning'];}
if (isset($trans['note'])){$note = $trans['note'];}
$autor_menu = "autors_menu";
foreach($author as $key => $value){
extract ($value);
$author_menu .= "";
$auth_text_full .= "
$auth_lifespan
$auth_text
";
}
print "
$trans_name
$trans_name
$trans_lifespan
$about
$warning
$note
$author_menu
$auth_text_full
--- GO TO: HOME - TOP ---";
}
}
if (!isset($file)){
$listing = listing(".");
foreach($listing as $Key => $Value){
//-------------------------------------------------------------------------------start listing of whole data;
if(is_file($Value)&&is_file($Value)){
$file = $Value;
$filepath="$file";
$domain=$_SERVER['SERVER_NAME'];
$fsize = $size['original_file']=filesize($filepath);
$link="$file";
//print ("Обратывается файл: $file ($fsize bytes)");
$html = fopen($filepath, "a+");
if (!$html) {
echo("Ошибка при открытии файла!");
}
else {
$raw_data = fread($html, $fsize);
fclose($html);
$size['pure_text']=strlen(strip_tags($raw_data));
//print "
имеем ".$size['pure_text']."Kb. чистого текста
";
$data = explode("",$raw_data);
$trans = analyse_author_info($data[0]);
unset($data[0]);
foreach($data as $key => $value){
if ($autor_name = preg_match('|(.*)
|Uis',$value, $out[$key] )){}
else{$err[]="$link/author_name";}
$author[$key]['aut_full_name']=strip_tags($out[$key][0]);
if ($autor_life = preg_match('|(.*)
|Uis',$value, $out[$key] )){}else{$err[]="$link/author_name";}
$author[$key]['auth_lifespan']=strip_tags($out[$key][0]);
$search = array ("'.*?'si",
"'.*?
'si");
$replace = array ("",
"");
$text = preg_replace($search, $replace, $value, 1);
$author[$key]['auth_text']=$text;
}
$trans_name=$trans['full_name'];
$link_to_menu ="link_to_index ";
$trans_lifespan = $trans['lifespan'];
$about = $trans['about'];
if (isset($trans['warning'])){$warning = $trans['warning'];}
if (isset($trans['note'])){$note = $trans['note'];}
$autor_menu = "autors_menu";
foreach($author as $key => $value){
extract ($value);
if (mb_strlen($aut_full_name,"UTF-8")===strlen(iconv("UTF-8","cp1251",$aut_full_name))){$aut_full_name=iconv("utf-8", "windows-1251", "$aut_full_name");}
$author_menu .= "$aut_full_name
";
$auth_text_full .= "
$auth_lifespan
$auth_text
";
}
if (mb_strlen($trans_name,"UTF-8")===strlen(iconv("UTF-8","cp1251",$trans_name)))
$output[] = ''.$trans_name.'
';
}
}
}
}
foreach($output as $key => $value){
$last = substr(strrchr($value," "), 1 );"
";
$output_sorted[$last]=$value;
}
ksort($output_sorted);
print '
Век Перевода
';
foreach($output_sorted as $key => $value){
//$value = mb_convert_encoding($value, "utf-8", "windows-1251");
print "$value";
}
?>