");
$zip_ret=iconv("windows-1251", "UTF-8",$zip_ret);
fclose($handle);
// $row_ft = mysqli_fetch_array(mysqli_query($dbh,"SELECT id,text FROM `ref_full_text` where `id`=".$refid." limit 1"));
// $zip_ret=$row_ft['text'];
}
$durl="Скачать";
preg_match("/materstudiorum.ru-(\d*).zip/",$row["url"],$idmatch);
//echo $idmatch[1];
// @parse_ref($idmatch[1]);
$f_size=round(filesize($ref_dir.$row["url"])/1024);
if($f_size==0) {$durl="none"; }
$dell="";
if($adminf){$dell="Delete";}
$shortd=str_replace("|", "", $row['short_desc']);
$shortd=preg_replace("/(\s+)/", " ", $shortd);
$ref_table="$dell Название: | ".$row['title']." |
\nПросмотров: | ".$row['views']." |
\nРаздел: | ".$cat_set['name']." |
\nСсылка: | $durl($f_size KB) |
\nОписание: | ".$shortd." |
\n";
//$zip_ret= preg_replace("(http://(.+) |http://(.+)\/)", "", $zip_ret);
$cat_cat=" Начало -> ".$cat_set['name']." -> ".$row['title']."";
$m_content= "".$menu_cat." | \n";
$m_content.= "".$cat_cat."
".$ref_table." | ";
$m_content.= "".banner()." | ";
//echo $zip_ret;
if(strlen($zip_ret)>5){
$offset=strpos($zip_ret, ". ", 6000);
$zip_ret=substr($zip_ret, 0, $offset+2);
$zip_ret=preg_replace("/(\s+)/", " ", $zip_ret);
$m_content.= "Часть полного текста документа:".nl2br($zip_ret)." ............ | ";}
//echo $m_content;
$m_content.="".banner2()."
".comments()." | ";
//echo "dfd";
$m_content.= $simpl_ref;
$m_content.= " |
";
// echo $m_content;
@mysqli_query($dbh,"UPDATE referat SET lastvisit=NOW() where id=".$refid);
@mysqli_query($dbh,"UPDATE referat SET views=views+1 where id=".$refid);
//echo $m_content;
}else
{
/// нет такого реферата
$m_content= "".$menu_cat." | \n";
$m_content.= "";
$m_content.= " |
";
}
}
else
{
//$pages = pages($nref,$pg,"category-".$catid."-",$set_ref_p_page);
//первая страничка
if( strlen($ref_table)<5) {
$p_title="MaterStudiorum.ru - домашняя страничка студента.";
$search_form="Поиск(по названиям)";
$main_text="На нашем сайте вы найдете много рефератов, докладов, курсовых, дипломных работ.
У нас вы можете собрать много материалов для вашей работы. Сравнить, что и как написали ваши коллеги.
На основании собранных здесь материалов вы сделаете отличную курсовую или дипломную работу.
Чтобы найти нужную вам курсовую работу или реферат воспользуйтесь посковой формой.
Мы постоянно пополняем нашу базу рефератов, курсовых и дипломных работ.
Вы получили \"отлично\" или \"хорошо\" за курсовую или реферат - присылайте нам! ";
$last_ref=last_referat(10);
$last_visit=last_visited(25);
//$top_views=top_views(5);
$m_content= "".$menu_cat." | \n";
$m_content.= "
".$search_form."
".$main_text;
//$m_content.="
Самые популярные:
".$top_views;
$m_content.="
Сейчас читают:
".$last_visit;
$m_content.="
Последние поступления:
".$last_ref;
$m_content.="
".banner2()." |
";
$m_content.="";
//echo navigation($set_ref_p_page, $pg, $nref);
}
}
//output
include "header.php";
echo "".$m_content;
include "footer.php";
//////////////////////////////////// CALCULATE TIME //////////////////////////////////////////
$end_time = microtime();
$end_array = explode(" ",$end_time);
$end_time = $end_array[1] + $end_array[0];
$time = $end_time - $start_time;
echo '';
//echo $_SERVER['QUERY_STRING'];
flush();
$rrrr=rand(1,7);
if($rrrr==1){
//echo "0";
//include "parserr.php";
//echo "1";
}
function make_full_text($id,$text){
global $ft_dir;
if($id<10000) $nf="00";
elseif($id<20000) $nf="01";
elseif($id<30000) $nf="02";
elseif($id<40000) $nf="03";
elseif($id<50000) $nf="04";
elseif($id<60000) $nf="05";
elseif($id<70000) $nf="06";
elseif($id<80000) $nf="07";
elseif($id<90000) $nf="08";
elseif($id<100000) $nf="09";
elseif($id<110000) $nf="10";
elseif($id<120000) $nf="11";
elseif($id<130000) $nf="12";
elseif($id<140000) $nf="13";
elseif($id<150000) $nf="14";
elseif($id<160000) $nf="15";
elseif($id<170000) $nf="16";
elseif($id<180000) $nf="17";
elseif($id<190000) $nf="18";
elseif($id<200000) $nf="19";
elseif($id<210000) $nf="20";
elseif($id<220000) $nf="21";
elseif($id<230000) $nf="22";
elseif($id<240000) $nf="23";
elseif($id<250000) $nf="24";
$filename=$ft_dir.$nf."/".$id.".txt";
if(!is_file($filename)){
/*
if (!$handle = fopen($filename, 'a')) {
return false;
}
if (fwrite($handle, $text) === FALSE) {
return false;
}
*/
return true;
fclose($handle);
}
}
function get_simle_referat ($searcha) {
global $dbh;
$rets="";
//$keywords = split(' ', $searcha);
for ($i=0; $i0){
$rets.="
Похожие работы:
";
while ($row = mysqli_fetch_array($result)){
$latname = cyr2lat( $row['title']);
$rets.="Название: | ".$row['title']." |
\nПросмотров: | ".$row['views']." |
\nОписание: | ".str_replace("|", "", $row['short_desc'])." |
\n";
}
}
return $rets;
}
function last_referat($num){
global $use_rewrite,$dbh;
$ret="";
$start=rand(1,180000);
$result = mysqli_query($dbh,"SELECT id,title,category,short_desc,views FROM `referat` order by `id` DESC limit $start, $num");
If (mysqli_num_rows($result)>0){
while ($row = mysqli_fetch_array($result)){
$latname = cyr2lat($row['title']);
if($use_rewrite)
$ret.="Название: | ".$row['title']." |
\nПросмотров: | ".$row['views']." |
\nОписание: | ".str_replace("|", "", $row['short_desc'])." |
\n";
else
$ret.="
\n";
}
}
return $ret;
}
function last_visited($num){
global $use_rewrite,$dbh;
$ret="";
$result = mysqli_query($dbh,"SELECT id,title,category,short_desc,views FROM `referat` order by `lastvisit` DESC limit $num");
If (mysqli_num_rows($result)>0){
while ($row = mysqli_fetch_array($result)){
$latname = cyr2lat($row['title']);
if($use_rewrite)
$ret.="Название: | ".$row['title']." |
\nПросмотров: | ".$row['views']." |
\nОписание: | ".str_replace("|", "", $row['short_desc'])." |
\n";
else
$ret.="
\n";
}
}
return $ret;
}
function top_views($num){
global $use_rewrite,$dbh;
$ret="";
$result = mysqli_query($dbh,"SELECT `id`,`title`,`category`,`short_desc`,`views` FROM `referat` ORDER BY `views` DESC limit ".$num);
If (mysqli_num_rows($result)>0){
while ($row = mysqli_fetch_array($result)){
$latname = cyr2lat( $row['title']);
if($use_rewrite)
$ret.="Название: | ".$row['title']." |
\nПросмотров: | ".$row['views']." |
\n | |
\nОписание: | ".str_replace("|", "", $row['short_desc'])." |
\n";
else
$ret.="
\n";
}
}
return $ret;
}
function r_zip($zip_file){ $z_info="";
$zip = new ZipArchive;
if ($zip->open($zip_file) === TRUE) {
$z_files= $zip->numFiles;
for ($i=0; $i<$zip->numFiles;$i++) {
$z_a=$zip->statIndex($i);
$fname= $z_a['name'];
//$fname = mb_convert_encoding($fname, "UTF-8");
$z_info .= ($i+1).": " . $fname . " ";
//$zip->deleteName($fname);
}
}
$zip->close();
return $z_info;
}
function pages($records,$r_start,$URL,$inpage) {
global $use_rewrite;
$str="";
$e_url="";
if($use_rewrite) $e_url=".html";
if ($records<=$inpage) return;
if ($r_start!=0) {
//$str.="<< ";
//$str.="< ";
}
else $str.=" ";
if ($r_start==0) {$sstart=$r_start-0;$send=$r_start+10;}
if ($r_start==1) {$sstart=$r_start-1;$send=$r_start+9;}
if ($r_start==2) {$sstart=$r_start-2;$send=$r_start+8;}
if ($r_start==3) {$sstart=$r_start-3;$send=$r_start+7;}
if ($r_start==4) {$sstart=$r_start-4;$send=$r_start+6;}
if ($r_start>=5) {$sstart=$r_start-5;$send=$r_start+5;}
if ($send*$inpage>$records) $send=$records/$inpage;
if ($sstart<0) $sstart=0;
if ($records%$inpage==0) $add=0; else $add=1;
// show all link on page
$send=intval($records/$inpage)+$add;
for ($i=$sstart;$i<$send;$i++) {
//// all pages ".(intval($records/$inpage)+$add)."
$ir="";
if($i>=$send-1) $ir="";
if ($i==$r_start) $str.=" ".($i+1)." $ir ";
else $str.="".($i+1)." $ir ";
}
if ($r_start+(1-$add)>";
//$str.=" >>";
}
else $str.=" ";
return("".$str."
");
}
function text_words($f_text){ //conspect
//чистим текст
$s = array(",", ".", "/", "'", "\"", ":", ";", "-", "\\n", "_", "!", "»", "«", "(", ")", "%");
$s2 = array("\t", "\n");
$bez_znaka = str_replace($s ," ", $f_text);
$bez_znaka = str_replace($s2 ," ", $bez_znaka);
$bez_znaka = preg_replace("/ (\d+) /is"," ",$bez_znaka);
while(strstr($bez_znaka, " ")) $bez_znaka=str_replace(" ", " ",$bez_znaka);
$arr1 = explode (" ", $bez_znaka);
foreach($arr1 as $ww){if (strlen($ww)>6) {$arr2[]=$ww;}}
//находим уникальные слова
$uw = array_unique($arr2);
array_multisort($uw);
//print_r($uw);
$num = Array();
//находим кол-во наибольших совпадений
foreach ($uw as $w){
$num[] = substr_count(implode(" ",$arr2), $w);
}
arsort ($num);
//print_r($num);
$result = count_chars($bez_znaka, 0);
//asort ($result[2]);
for ($i=0; $i < count($result); $i++) {
if ($result[$i] != 0){
// echo "\"" , iconv("windows-1251", "UTF-8",chr($i)) , "\" встречается в строке $result[$i] раз(а).
\n";
}
}
//print_r($num);
//отбираем слова с большей частотой
$i=0;
foreach ($num as $key => $ww){
$ret_w[]= $uw[$key];
$i++;
if($i>2) break;
}
return $ret_w;
}
function cyr2lat($text) {
//echo $text;
$text=str_replace("-","",$text);
$text=str_replace(" ","",$text);
$text=str_replace(" ","-",$text);
$cyr = array('а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у', 'ф','х','ц','ч','ш','щ','ъ','ы','ь', 'э', 'ю','я','А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У', 'Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ь', 'Э', 'Ю','Я');
$lat = array('a','b','v','g','d','e','yo','zh','z','i','y','k','l','m','n','o','p','r','s','t','u','f' ,'h' ,'ts' ,'ch','sh' ,'sht' ,'a','y', 'y', 'e', 'yu' ,'ya','A','B','V','G','D','E','YO','Zh','Z','I','Y','K','L','M','N','O','P','R','S','T','U','F' ,'H' ,'Ts' ,'Ch','Sh' ,'Sht' ,'A' ,'Y', 'E', 'Yu' ,'Ya');
$textcyr = strtolower(str_replace($cyr, $lat, $text));
$textcyr = preg_replace('/[^a-z-]/', '', $textcyr);
if(strlen($textcyr)>50){
$textcyr = substr($textcyr, 0, 50);
$textcyr = substr($textcyr, 0, strrpos($textcyr, "-"));
//$textlat = str_replace($lat, $cyr, $text);
}
return $textcyr;
}
?>