Home Backend Development PHP Tutorial A program to publish dynamic news in real time using text files_PHP tutorial

A program to publish dynamic news in real time using text files_PHP tutorial

Jul 21, 2016 pm 04:03 PM
dynamic release Can land real time accomplish document text news time use of program automatic

A program for dynamically publishing news in real time, which can automatically arrange the display sequence according to the release time. News files are text files stored in the specified directory. When there is news, the program will automatically display it and arrange it at the beginning of the page.


News


News






include('locationfilename.php');

function createur1($text){
/ /Insert your link into the news text file like this
//${http://mysite.ch}
//Or ${http://mysite.ch|My homepage in}
//Start processing 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);
                                                          $a."">".$linktext."".$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 the directory handle
$hd=dir($newspath);

//Get all files, And store it in the array
while($filename=$hd->read() ){
$s=strtolower($filename);
if (strstr($s,".txt ")){
//Detect 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 "";
}
$hd- >close();

?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316336.htmlTechArticleA program for dynamically publishing news in real time, which can automatically arrange the display order according to the release time. News files are text files stored in the specified directory. When there is news, the program...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

How to make Google Maps the default map in iPhone

How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu Mar 22, 2024 pm 09:21 PM

How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu

Why can't Xiaohongshu publish videos of works? How does it publish its work? Why can't Xiaohongshu publish videos of works? How does it publish its work? Mar 21, 2024 pm 06:36 PM

Why can't Xiaohongshu publish videos of works? How does it publish its work?

Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed? Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed? Mar 21, 2024 pm 07:47 PM

Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed?

Convert VirtualBox fixed disk to dynamic disk and vice versa Convert VirtualBox fixed disk to dynamic disk and vice versa Mar 25, 2024 am 09:36 AM

Convert VirtualBox fixed disk to dynamic disk and vice versa

How to delete Xiaohongshu releases? How to recover after deletion? How to delete Xiaohongshu releases? How to recover after deletion? Mar 21, 2024 pm 05:10 PM

How to delete Xiaohongshu releases? How to recover after deletion?

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code.

When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from? When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from? Mar 21, 2024 pm 08:11 PM

When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from?

See all articles
n";
print " ".date("d.m.Y - H:i:s",$newsfile[$key])."
n";
for($i=0; $ i<$n; $i=$i+1){
$s=chop($fa[$i]);
$s=htmlspecialchars($s);
$s=createur1( $s);
print $s."
n";
}
print "