The program for dynamic and real-time news release can automatically arrange the display order according to the release time. News files are composed of text files stored in a specified directory. When there is news, the program will automatically display it and arrange it at the beginning of the page.
<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('');
function createur1($text){
//Insert your link in the text file of the news
//${}
//or ${|My homepage in}
//Start the text file part
$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);
}
//Modify your news file storage directory here
//Remember, news files must be text files
$newspath="/home/htdocs/test/new/";
//Set the array
$newsfile=array();
//Set directory handle
$hd=dir($newspath);
//Get all files and store them in an array
while($filename=$hd->read() ){
$s=strtolower($filename);
if (strstr($s,".txt")){
//Detection of the latest modification date
$lastchanged=filemtime($newspath.$filename);
$newsfile[$filename]=$lastchanged;
}
}
//File sorting
arsort($newsfile);
//Output file
for(reset($newsfile); $key=key($newsfile); next($newsfile)){
$fa=file($newspath.$key);
$n=count($fa);
print "<tr><td>n";
print "<b>".date(" - 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>
<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('');
function createur1($text){
//Insert your link in the text file of the news
//${}
//or ${|My homepage in}
//Start the text file part
$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);
}
//Modify your news file storage directory here
//Remember, news files must be text files
$newspath="/home/htdocs/test/new/";
//Set the array
$newsfile=array();
//Set directory handle
$hd=dir($newspath);
//Get all files and store them in an array
while($filename=$hd->read() ){
$s=strtolower($filename);
if (strstr($s,".txt")){
//Detection of the latest modification date
$lastchanged=filemtime($newspath.$filename);
$newsfile[$filename]=$lastchanged;
}
}
//File sorting
arsort($newsfile);
//Output file
for(reset($newsfile); $key=key($newsfile); next($newsfile)){
$fa=file($newspath.$key);
$n=count($fa);
print "<tr><td>n";
print "<b>".date(" - 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>