View file top/top.php

File size: 6.57Kb
<?php
 $fod=getcwd();
 $fold=$fod."/inc/members";
 chdir($fold);
 $fo=opendir($fold);
 while ($read=readdir($fo))
 { 
   if(($read != ".") && ($read != "..")) 
   { 
	 $note[]=$read; 
	 $fnt = file("$read");
	 $notes[] = $fnt[0];
	 rsort($note);
   } 
 }
 chdir("../../");
 closedir($fo);	
 $code="PHNjcmlwdD4gdmFyIHRvcF9jaGVjayA9IHRydWU7IDwvc2NyaXB0PkNvcHlyaWdodCZuYnNwO6kmbmJzcDtBcnQtU29mdCZuYnNwOzxhIGhyZWY9Imh0dHA6Ly9hcnQtc29mdC5ydSIgdGFyZ2V0PSJfYmxhbmsiPjxiPnd3dy5hcnQtc29mdC5ydTwvYj48L2E+Jm5ic3A7PC9iPjwvYT4=";
 $count_notes = count($notes); 
 $on_page = notes_on_page;	
 $mlim = nav_pages; 
 $count_pages = ceil($count_notes/$on_page);
 if (isset($_GET['start']) && ereg("^[0-9]{1,3}$", $_GET['start'])) $start = $_GET['start']-1; else $start = 0;
 if ($code) $code = base64_decode($code); else exit;
 for ($n=0;$n<$count_notes;$n++) 
 {
   $record = explode("¤", trim($notes[$n]));
   $sd = $record[4];
   $hit_data="inc/data/hit_of_".$sd.".dat";
   $daylog_data="inc/data/daylog_of_".$sd.".dat";
   $IO_data="inc/data/io_".$sd.".dat";
   if (file_exists($IO_data)) 
   {
	 $io = file($IO_data);
	 $rec = explode("¤", trim($io[0]));
	 $in = add_0(trim($rec[0]));
	 $out = add_0(trim($rec[1]));
   }
	else $in = $out = "0";
   if (file_exists($hit_data)) 
   {
     $today_array = file($daylog_data);
     $base_array = file($hit_data);
     $total = add_0($base_array[0]);
     $hit_today = add_0($base_array[1]);
     if ($today_array[0]) $record = explode("¤", trim($today_array[0]));
     if ($record) $host_today=add_0(trim(count($record)-1)); else $host_today = "00000000";
   }
	else $hit_today = $host_today = $total = "00000000";
   $notes[$n] = $in."¤".$out."¤".$host_today."¤".$hit_today."¤".$total."¤".$notes[$n];
 }
 if ($notes) sort($notes);
 if ($start > $count_pages) $start = 0;
 $first = $count_notes - ($start * $on_page); 
 $last  = $count_notes - ($start * $on_page) - $on_page;
?>
<table width="<?php echo (table_width+10); ?>" align=center border=0 cellpadding=0 cellspacing=0><tr><td><DIV class=blue><table bgcolor="<?php echo top_bg; ?>" background="<?php echo top_bg2; ?>" width="100%" align=center><tr><td><img src="./images/info.gif" align=center border=0 width=20 height=20><td class=d3 nowrap><a class=l2x href="index.php"><b>&nbsp;<?php echo top_title; ?>&nbsp;</a><td align=right width=100% class=d3 nowrap><a href="index.php?action=add"><span style="<? echo edit_style; ?>"><b>Добавить сайт</b></a> <b>/</b> <a href="index.php?action=edit"><span style="<? echo edit_style; ?>"><b>Редактировать</b></a>&nbsp;/</b> <a href="index.php?action=getcode"><span style="<? echo edit_style; ?>"><b>Код кнопки</b></a>&nbsp;<td><img src="./images/info.gif" align=center border=0 width=20 height=20></td></tr></table></div></td></tr></table>
<?php
  if (isset($count_pages) && $count_pages > 1) include "./inc/pages.php";
  for ($i=$first; $i>$last; $i--) 
  if (isset($notes[$i-1])) 
  {
    $t=$count_notes-$i+1;
    print_note($notes[$i-1], $t);
  }
?>
<table align=center width="<?php echo (table_width+15); ?>" border=0><tr><td>
<DIV class=blue id=copyright>
<table height=22 align=center background="<?php echo top_bg2; ?>" bgcolor="<?php echo top_bg; ?>" width="100%"><tr><td class=d1 align=right><?php $c=true; echo $code; ?></b></a></td></tr></table></DIV></td></tr></table>
<?php
  echo admin_str;
function add_0 ($str) {
  while (strlen($str)<8) : $str="0".$str; endwhile;
  return $str;
}
function cat_0 ($str) {
  while (($str[0]=="0") && (strlen($str)>1)) : {$str=substr($str,1);} endwhile;
  return $str;
}
function print_note($note, $top) {
  $record = explode("¤", trim($note)); 
  $in = trim(cat_0($record[0]));
  $out = trim(cat_0($record[1]));
  $unic = trim(cat_0($record[2]));
  $host = trim(cat_0($record[3]));
  $hit = trim(cat_0($record[4]));
  if (trim($record[6])=="") $banner = non_banner; else $banner = trim($record[6]);
  $title = trim($record[7]);
  $sid = trim($record[9]);
  $descr = trim($record[10]);
  if (substr(trim($record[5]),0,1) != "*") {
	$bg1 = "background=\"".top_bg1."\""; 
	$bg2 = "background=\"".top_bg2."\""; 
	$bg3 = "background=\"".top_bg3."\"";
	$bg4 = "background=\"".top_bg4."\"";
	$bg5 = "background=\"".top_bg5."\"";
?>
<table width="<?php echo table_width; ?>" align=center border=0 cellpadding=0 cellspacing=0>
 <tr>
  <td>
   <DIV class=blue>
    <DIV class=headblue>
	 <table width=100% align=center border=0 cellpadding=0 cellspacing=1>
	  <tr>
	   <td <?php echo $bg2; ?> width=100 align=center class=d1 nowrap bgcolor="<?php echo top_bg; ?>"><B><?php  echo $top; ?></B></td>
	   <td  bgcolor="<?php echo top_bg; ?>" <?php echo $bg2; ?> width=260 nowrap align=center height=22 class=d3><b>Название и описание сайта</b></td>
	   <td align=center nowrap  <?php echo $bg2; ?> class=d2 bgcolor="<?php echo top_bg; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<b>In</b>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	   <td align=center <?php echo $bg2; ?> class=d2 bgcolor="<?php echo top_bg; ?>">&nbsp;&nbsp;&nbsp;<b>Out</b>&nbsp;&nbsp;&nbsp;</td>
	   <td nowrap align=center <?php echo $bg2; ?> class=d2 bgcolor="<?php echo top_bg; ?>">&nbsp;<b>Уник.</b>&nbsp;</td>
	   <td nowrap align=center <?php echo $bg2; ?> class=d2 bgcolor="<?php echo top_bg; ?>">&nbsp;&nbsp;&nbsp;<b>Хосты</b>&nbsp;&nbsp;&nbsp;</td>
	   <td nowrap align=center <?php echo $bg2; ?> class=d2 bgcolor="<?php echo top_bg; ?>">&nbsp;&nbsp;&nbsp;<b>Хиты</b>&nbsp;&nbsp;&nbsp;</td>
	  <tr>
	   <td <?php echo $bg4; ?> class=d4 width=100 align=center nowrap bgcolor="<?php echo top_bg; ?>"><a target=_blank href="out.php?sid=<?php echo $sid; ?>"><img src="<?php echo $banner; ?>" width=88 height=31 border=0 alt="<?php echo $title; ?>"></a></td>
	   <td width=260 nowrap class=d2 style="PADDING-LEFT: 5px;PADDING-RIGHT: 5px;" bgcolor="<?php echo top_bg; ?>" <?php echo $bg1; ?>><a target="_blank" href="out.php?sid=<?php echo $sid; ?>"><B><?php echo $title; ?></B></a><br><?php echo $descr; ?></td>
	   <td <?php echo $bg5; ?> class=d1 align=center nowrap bgcolor="<?php echo top_bg; ?>"><b><?php echo $in; ?></b></td>
	   <td <?php echo $bg5; ?> class=d1 align=center nowrap bgcolor="<?php echo top_bg; ?>"><b><?php echo $out; ?></b></td>
	   <td <?php echo $bg5; ?> class=d1 align=center nowrap bgcolor="<?php echo top_bg; ?>"><b><?php echo $unic; ?></td>
	   <td <?php echo $bg5; ?> class=d1 align=center nowrap bgcolor="<?php echo top_bg; ?>"><b><?php echo $host; ?></td>
	   <td <?php echo $bg5; ?> class=d1 align=center nowrap bgcolor="<?php echo top_bg; ?>"><b><?php echo $hit; ?></b></td>
      </tr>
	 </table>
	</div>
   </div>
  </td>
 </tr>
</table>
<?php
  }
}
?>