A simple PHP back-end script that can get the latest news from (a certain network.

Source: Internet
Author: User

<?
// Sunboys data
// Bi balo aruhan domdadu o los in wuber mongglo in huen egun I wuzhe
// Zhu tuhe re hu humen tai ban nai zha bolu ya!

$ Link_prefix = "& nbsp; o ";
$ Link_postfix = "<BR> n ";
$ Cache_file = "tmp/heise. cache ";
$ Cache_time = 3600;


$ Items = 0;
$ Time = split ("", microtime ());

Srand (double) microtime () * 1000000 );
$ Cache_time_rnd= 300-rand (0,600 );

If ((! (File_exists ($ cache_file) | (filectime ($ cache_file) + $ cache_time-$ time [1]) + $ cache_time_rnd <0) | (! (Filesize ($ cache_file )))){
$ Fp1 = fopen ("http://www.ourjia.net/index.shtml", "r ");
$ String = fread ($ fp1, 20000 );

Ereg ("<! -- MITTE (NEWS) --> (. *) <! -- MITTE (NEWS-UEBERBLICK) --> ",
$ String, $ matches );
$ Match = str_replace ("HREF ="/newsticker/"," href = "http://www.ourjia.net/", $ matches [1]);

$ Exp = "# newsticker/data/(. *)/"> (. * </FONT> </B>) # I ";
Preg_match_all ($ exp, $ matches [1], $ matchin );

For ($ I = 0; $ I <count ($ matchin [1]); $ I ++)
{
$ Body. = "$ link_prefix <a href =" http://www.ourjia.net/data ". $ matchin [1] [$ I]. "/"> ". $ matchin [2] [$ I]. "</a> <br> n ";
}
$ Body = eregi_replace ("</A> </FONT> </B>", "", $ body );
Fclose ($ fp1 );

$ Fpwrite = fopen ($ cache_file, w );
Fputs ($ fpwrite, "$ body ");
Fclose ($ fpwrite );
}
Include ($ cache_file );
?>

Note: 1: Here www.ourjia.net should be a website with a news update system, for example:
Http://www.heise.de/newsticker.

[This article is copyrighted by the author and osuo. If you need to reprint it, please indicate the author and its source]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.