The Program for dynamically publishing news in real time can automatically arrange the display order according to the release time. A news file is a text file stored in a specified directory. When there is news, the program will automatically display it and arrange it in the first part of the page.
<Html>
<Head>
<Title> News </title>
</Head>
<Body bfcolor = "# ffffff">
<H1> News <Div aligh = "center">
<Table border = "0" cellspacing = "5" cellpadding = "10" width = "90%" bgcolor = "# e0e0e0">
<? Php
Include ('locationfilename. php ');
Function createur1 ($ text ){
// Insert your link in the text file of news
// $ {Http://mysite.ch}
// Or $ {http://mysite.ch | My homepage in}
// Start to process text files
$ S = $ text;
$ A = strstr ($ s, '$ {');
If ($ ){
$ B = strstr ($ ,'}');
If ($ B ){
$ La = strlen ($ a); $ ls = strlen ($ s );
$ S = substr ($ s, 0, $ ls-$ la );
$ A = substr ($ a, 2 );
$ Lb = strlen ($ B); $ la = strlen ($ );
$ 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 = $;
}
$ S = $ s. "<a href =" ". $ a." ">". $ linktext. "</a>". $ B;
}
}
Return ($ s );
}
// Modify the news file storage directory here
// Remember, the news file must be a text file
$ Newspath = "/home/htdocs/test/new /";
// Set the Array
$ Newsfile = array ();
// Set the directory handle
$ Hd = dir ($ newspath );
// Obtain all objects and store them in an array.
While ($ filename = $ hd-> read ()){
$ S = strtolower ($ filename );
If (strstr ($ s, ". txt ")){
// Check the latest modification date
$ Lastchanged = filemtime ($ newspath. $ filename );
$ Newsfile [$ filename] = $ lastchanged;
}
}
// Sort files
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 ("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>