Просмотр файла mynews/zoom.php

Размер файла: 4.06Kb
<?php
// -----------------------------------------------------------------------------------------------
// File:           zoom.php
// Topic:          zoom articles
// Author:         urs_at_circle_dot_ch
// -----------------------------------------------------------------------------------------------

  $header = '<html><title>MyNEWS</title><body style="font-family: arial">';
  $footer = '</body></html>';

  define("myDataFile", "./data/mynews.txt");

// --------------------------------------------------------------------------------
// news headlines
// --------------------------------------------------------------------------------

  /**
  * transform txt to html -> "д" to "&auml;"
  * urs_at_circle_dot_ch, 16-1-2001
  *
  */
  function txt2html ($str = "") {
  global $HTML_ENTITIES;

  $trans = get_html_translation_table(HTML_ENTITIES );
  return strtr($str, $trans);
  }

  /**
  * transform html to txt -> "&auml;" to "д"
  * urs_at_circle_dot_ch, 16-1-2001
  *
  */
  function html2txt ($str = "") {
  global $HTML_ENTITIES;

  $trans = array_flip(get_html_translation_table(HTML_ENTITIES ));
  $trans["&amp;"] = "&";
  return strtr($str, $trans);
  }

  function evalQUERY($item){
    global $QUERY_STRING;

    $pairs = explode("&", $QUERY_STRING);

    for($i=0;$i<count($pairs);$i++):
      $query[$i] = explode("=", $pairs[$i]);
      if($query[$i][0] == $item):
        return $query[$i][1];
        break;
      endif;
    endfor;
  }

function listHEADLINES(){

  $content = file(myDataFile);                 // read file

  for($i=0; $i<count($content); $i++):
    $myLINES[$i] = explode("|",$content[$i]);
  endfor;

  ?>
  <table border="0" cellspacing="0" cellpadding="2" width="100%">
  <?php
  $size = count($content);

  for($i=$size-1; $i>($size-6); $i--):          // show only the latest five articles
    if($myLINES[$i][5] == 1):
    ?>
      <tr bgcolor="<?php echo($k++ % 2 == 0 ? '#EEEEEE' : '#FFFFFF'); ?>">
         <td valign="top" align="left" width="20%"><?php echo $myLINES[$i][1]; ?>
         <td valign="top" align="left" width="80%" >
         <a href="<?php echo "zoom.php?id=".$myLINES[$i][0]; ?>" class="main"><?php echo stripslashes(html2txt($myLINES[$i][2])); ?></a>
    <?php
    endif;
  endfor; ?>
  </table>
  <?php
}

function zoomITEM(){

  $content = file(myDataFile);

  for($i=0; $i<count($content); $i++):
    $myLINES[$i] = explode("|",$content[$i]);
    if($myLINES[$i][0] == evalQUERY("id")) break;
  endfor;

  if(evalQUERY("id") != ""):
     ?>
     <table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
         <tr>
         <td width="50%"><p><?php echo $myLINES[$i][1]." - ".stripslashes(html2txt($myLINES[$i][4])); ?><p>
         <tr>
         <td width="50%"><h4><?php echo stripslashes(html2txt($myLINES[$i][2])); ?></h4>
         <tr>
         <td width="50%"><p><?php echo stripslashes(html2txt($myLINES[$i][3])); ?><p>
     </table>

<br>
<br>
<br>
<?php
  endif;
}
?>

<?php echo $header; ?>
<table bgcolor=#cccccc border=0 cellpadding=1 cellspacing=0
            width="500" align="center">
  <tbody>
  <tr>
    <td>
      <table border=0 cellpadding=3 cellspacing=0 width="100%">
        <tbody>
        <tr bgcolor="#ffffff" valign="top">
          <td> <?php zoomITEM(); ?> </td>
        </tr>
        </tbody>
      </table>
    </td>
  </tr>
  </tbody>
</table>
<br>
<br>
<table bgcolor=#CCCCCC border=0 cellpadding=1 cellspacing=0 width="500" align="center">
  <tbody>
  <tr>
    <td>... more</td>
  </tr>
  <tr>
    <td>
      <table border=0 cellpadding=3 cellspacing=0 width="100%">
        <tbody>
        <tr bgcolor="#ffffff" valign="top">
          <td><?php listHEADLINES(); ?></td>
        <tr bgcolor="#ffffff" valign="top">
          <td>&nbsp;
        <tr bgcolor="#ffffff" valign="top" align="center">
          <td>[ <a href="list_all_news.php" class="main">all messages</a> ]
        </tbody>
      </table>
    </td>
  </tr>
  </tbody>
</table>
<br>
<?php echo $footer; ?>