欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用文本文件實(shí)現(xiàn)的動(dòng)態(tài)實(shí)時(shí)發(fā)布新聞的程序

 更新時(shí)間:2006年10月09日 00:00:00   作者:  
動(dòng)態(tài)實(shí)時(shí)發(fā)布新聞的程序,可以根據(jù)發(fā)布時(shí)間,自動(dòng)地排列顯示順序。新聞文件為存儲(chǔ)在指定目錄的文本文件組成,當(dāng)有新聞的時(shí)候,程序會(huì)自動(dòng)地將其顯示出來(lái),并且排列在頁(yè)面的最開(kāi)始部分。
<html>
<head>
<title>News</title>
</head>
<body bfcolor="#ffffff">
<h1>News</h1>
<div aligh="center">
<table border="0" cellspacing="5" cellpadding="10" width="90%" bgcolor="#e0e0e0">

<?php

  include('locationfilename.php');

  function createur1($text){
  //新聞的文本文件中這樣插入你的鏈接
  //${http://mysite.ch}
  //或是${http://mysite.ch|My homepage in}
  //開(kāi)始處理文本文件部分
    $s=$text;
    $a=strstr($s,'${');
    if ($a){
      $b=strstr($a,'}');
      if ($b){
        $la=strlen($a); $ls=strlen($s);
        $s=substr($s,0,$ls-$la);
        $a=substr($a,2);
        $lb=strlen($b); $la=strlen($a);
        $a=substr($a,0,$la-$lb); $b=substr($b,1);
        $ta=strstr($a,"|");
        if($ta){
          $la=strlen($a); $lt=strlen($ta);
          $linktext=substr($a,$la-$lt+1);
          $a=substr($a,0,$la-$lt);
        }
       else{
         $linktext=$a;
       }
      $s=$s."<a href="".$a."">".$linktext."</a>".$b;
      }
    }

  return($s);
  }

  //在這里修改你的新聞文件存放目錄
  //切記,新聞文件必須是文本文件
  $newspath="/home/htdocs/test/new/";

  //設(shè)置數(shù)組
  $newsfile=array();

  //設(shè)置目錄把柄
  $hd=dir($newspath);

  //獲取全部文件,并將其存放在數(shù)組中
  while($filename=$hd->read() ){
    $s=strtolower($filename);
    if (strstr($s,".txt")){
      //檢測(cè)最新修改日期
      $lastchanged=filemtime($newspath.$filename);
      $newsfile[$filename]=$lastchanged;
    }
  }

  //文件排序
  arsort($newsfile);
  //輸出文件
  for(reset($newsfile);  $key=key($newsfile);  next($newsfile)){
    $fa=file($newspath.$key);
    $n=count($fa);
    print "<tr><td>n";
    print "<b>".date("d.m.Y - H:i:s",$newsfile[$key])."</b><br>n";
    for($i=0; $i<$n; $i=$i+1){
      $s=chop($fa[$i]);
      $s=htmlspecialchars($s);
      $s=createur1($s);
      print $s."<br>n";
    }
    print "</td></tr>";
  }
  $hd->close();

?>
</body>
</html> 

相關(guān)文章

最新評(píng)論