Php 脉冲CMS-最近的帖子-显示(100)个字符
有一个客户来找我,他们正在使用Pulse CMS,他们想在主页上显示最近的帖子,很简单。。。但我看不出如何显示一点帖子。我的php知识有限 由此: 职称 01/02/03 见识Php 脉冲CMS-最近的帖子-显示(100)个字符,php,content-management-system,pulse,Php,Content Management System,Pulse,有一个客户来找我,他们正在使用Pulse CMS,他们想在主页上显示最近的帖子,很简单。。。但我看不出如何显示一点帖子。我的php知识有限 由此: 职称 01/02/03 见识 为此: 职称 01/02/03 新的黎明,新的一天,最近的帖子内容 见识 代码如下: <?php error_reporting(0); include_once("config.php"); include_once("path.php"); include_once("helpers/blog_lib.p
为此: 职称 01/02/03 新的黎明,新的一天,最近的帖子内容 见识
代码如下:
<?php
error_reporting(0);
include_once("config.php");
include_once("path.php");
include_once("helpers/blog_lib.php");
include_once("helpers/functions.php");
if($pulse_lang == 0){
include_once("lang.php");}
else
if($pulse_lang == 1){
include_once("lang_de.php");}
$blog_file = new read_File("blog");$amount = $blog_file->countLines();
$lines = $blog_file->getLines();$amount_view = 1 ;
echo "<div class=\"span3 latest-post-1\">\n\n";
for ($n=$amount-1 ; $n>=($amount - $amount_view) ; $n-- ) {
$blog = explode("|", $lines[$n]);
if (isset($blog[0]) & $blog[0] != '') {
$date = explode( ' ' , $blog[2]);
$date = $date[2] . ' ' . $date[1] . ' ' . $date[3];
include("clean_url.php");
if($rewrite) {
if ($blog_comments) {
echo "<p><a href=\"/blog-". $blog[0] ."-".cleanUrlname($blog[3])."\">" .$blog[3]. "</a> (" .$blog[1]. ")<br>";
} else {
echo "<p><a href=\"/blog-". $blog[0] ."-".cleanUrlname($blog[3])."\">" .$blog[3]. "</a><br>";
}
} else {
if ($blog_comments) {
echo "<p><a href=\"". $blog_url ."?d=". $blog[0] ."\">" .$blog[3]."</a> (" .$blog[1]. ")<br>";
} else {
echo "<p><a href=\"". $blog_url ."?d=". $blog[0] ."\">" .$blog[3]."</a><br>";
}
}
if($date_format) {
echo date("d.m.Y", strtotime($date))."</p>\n\n";
} else {
echo date("m-d-Y", strtotime($date))."</p>\n\n";
}
}
}
echo "<p class=\"all-posts\"><a href=\"". $blog_url ."\">$lang_blog_see_all</a></p>";
echo "\n\n</div>";
?>
日志文件行:
4|0|Fri, 11 Oct 2013 12:57:09 +0200|hey this works|<p> Lorem ipsum dolor sit</p>|0
5|0|Fri, 11 Oct 2013 13:04:17 +0200|Subject|<p> This is a sample blog post for Pulse CMS Pro.</p>|0
4 | 0 | Fri,2013年10月11日12:57:09+0200 |嘿,这很有效|Lorem ipsum dolor sit
5 | 0 | Fri,2013年10月11日13:04:17+0200 |主题|这是Pulse CMS Pro的一篇博客文章示例。|0
您可能想发布读取文件()的代码,因为这似乎是获取post数据的代码。很抱歉,编辑了原始帖子。对于读取文件类仍然没有定义。很抱歉,我以为读取文件(“博客”);php文件。就像我说的我的php是垃圾,我想要发布的东西,在你的代码中的某个地方,有一个文件包含class read\u file{
——这是读取文件的类的定义。
<?php
class read_File{
function __construct($name){
$this->name = $name;
if($this->name == "blog"){$this->name = ROOTPATH . "/data/blog/blogfile.txt";}
else if($this->name == "comment"){$this->name = ROOTPATH . "/data/blog/comments.txt";}
else { echo $lang_blog_error_reading;}
}
function getData(){
$open = fopen($this->name , "r");
$data = @fread($open, filesize($this->name));
fclose($open);
return $data;
}
function getLines(){
$lines = explode("\n", $this->getData());
return $lines;
}
function countLines(){
$amount_of_lines = count($this->getLines());
return $amount_of_lines-1;
}
}//end class
class add_Content{
function __construct($name,$data){
$this->name = $name;
$this->data = $data;
if($this->name == "blog"){$this->name = ROOTPATH . "/data/blog/blogfile.txt";}
else if($this->name == "comment"){$this->name = ROOTPATH . "/data/blog/comments.txt";}
else { echo $lang_blog_error_reading;}
}
function appendData(){
$open = fopen($this->name, "a");
fwrite($open, $this->data);
fclose($open);
}
function writeData(){
$open = fopen($this->name, "w");
fwrite($open, $this->data);
fclose($open);
}
}//end class
//sanatize input
function super_clean($text){
$text = trim(stripslashes(strip_tags(htmlspecialchars($text, ENT_QUOTES, 'UTF-8'))));
return $text;
}
?>
array(6) { [0]=> string(1) "5" [1]=> string(1) "0" [2]=> string(31) "Fri, 11 Oct 2013 13:04:17 +0200" [3]=> string(7) "Subject" [4]=> string(54) "
This is a sample blog post for Pulse CMS Pro.
" [5]=> string(1) "0" }
4|0|Fri, 11 Oct 2013 12:57:09 +0200|hey this works|<p> Lorem ipsum dolor sit</p>|0
5|0|Fri, 11 Oct 2013 13:04:17 +0200|Subject|<p> This is a sample blog post for Pulse CMS Pro.</p>|0