Witajcie,
Mam taki o to skrypt:
<?php
//config//
$includepath = "/domains/mojastronka.pl/public_html/forum/news/"; //path where the news folder resides
$mainurl = "http://www.mojastronka.pl.pl";
$forumurl = "http://www.mojastronka.pl/forum/";
$includeurl = "http://www.mojastronka.pl/forum/news/"; //URL where the news folder resides
$newstemp = "template.html";
// Database Information
$dbserver = 'localhost';
$dbuser = 'abcd_123';
$dbpass = 'haslo';
$dbase = 'abcd_123';
$db = mysql_connect($dbserver, $dbuser, $dbpass) or
die('Could not connect to DB server!');
function replace_bb_code($text) {
$text = eregi_replace("[img]([^[]*)[/img]","<img src=\"1\" border=0>",$text); $text = eregi_replace("+)]([^[]*)","<font color=\"1\">2</font>",$text); $text = eregi_replace("<!--quoteo--><div class='quotetop'>Cytat</div><div class='quotemain'><!--quotec-->([^[]*)<!--QuoteEnd--></div><!--QuoteEEnd-->","<br><br><strong>Quote:</strong><table width='80%' border='0' cellspacing='0' cellpadding='3'><tr><td bgcolor='#EFEFEF'><font color='#000000' size='-2'>1</font></td></tr></table><br>",$text); $text = eregi_replace("<!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1-->([^[]*)<!--c2--></div><!--ec2-->","<br><br><strong>Code:</strong><table width='80%' border='0' cellpadding='3' cellspacing='0' bgcolor='#FFFFFF' style='border:1px solid gray;'><tr><td bgcolor='#FFFFFF'><font color='#009900' size='-2'>1</font></td></tr></table><br>",$text); $text = eregi_replace("+)]([^[]*)","<font size='2'>2</font>",$text); return $text;
}
$forumid = '3'; // You can set your forum ID here to pull the posts from the forum you want
$post_count = $_REQUEST['postcount'];
if (!$post_count) { $post_count = 3; } // You may Change the amount of posts that are returned here by changing the number
$changetemplate = $_REQUEST['template'];
if ($changetemplate == "") { } else { $newstemp = $changetemplate; }
$truncate = $_REQUEST['truncate'];
if (!$truncate) { $truncate = 100000; }
if($_REQUEST['reverse']==1) { ////you may need to change your database prefix from vbforum_ to what yours is
$query = "SELECT * FROM post p, thread t WHERE p.threadid = t.threadid AND t.forumid ='".$forumid."' ORDER BY p.threadid ASC, p.postid;";
} else {
$query = "SELECT * FROM post p, thread t WHERE p.threadid = t.threadid AND t.forumid ='".$forumid."' ORDER BY p.threadid DESC, p.postid;";
}
$post = 0;
while($post < $post_count) {
if($row=="") { break; }
if ($previous_topic == $row->threadid) { // do nothing.
}
else {
$previous_topic = $row->threadid;
$post++;
$posttextquery = "SELECT * FROM post WHERE postid='".$row->postid."';";
$useridquery = "SELECT * FROM user WHERE userid='".$row->userid."';";
$responsesquery = "SELECT * FROM post WHERE threadid='".$row->threadid."';";
$fileopen = fopen($includeurl.$newstemp, "r"); $newsstring = fread($fileopen, filesize($includepath.$newstemp));
$subject = $posttextrow->title;
$newsstring = str_replace("((post_date))", date("F j, Y", $row->dateline), $newsstring); $newsstring = str_replace("((post_time))", date("g:i a", $row->dateline), $newsstring); $newsstring = str_replace("((poster_name))", "<a href='".$forumurl."member.php?u=".$row->userid."' target='_blank'>".$useridrow->username."</a>", $newsstring); $newsstring = str_replace("((post_subject))", $subject, $newsstring); if (strlen($newsstring) > $truncate) { $newsstring = str_replace("((post_text))", substr(nl2br($posttextrow->pagetext),0
,$truncate)."... <a href='".$forumurl."showthread.php?t=".$row->postid."' target='_blank'>READ MORE</a>", $newsstring); } else {
$newsstring = str_replace("((post_text))", nl2br($posttextrow->pagetext), $newsstring); }
$newsstring = str_replace("((comment))", "<a href='".$forumurl."showthread.php?t=".$row->threadid."' target='_blank'>Comments</a>", $newsstring); $newsstring = str_replace("((responses))", $num_responses, $newsstring);
$newsstring = replace_bb_code($newsstring);
$newsstring = replace_bb_code($newsstring);
}
}
?>
Po odpaleniu wywala błędy:
Kod
Warning: filesize() [function.filesize]: stat failed for /domains/mojastronka.pl/public_html/forum/news/template.html in /home/abcd_123/domains/mojastronka.pl/public_html/forum/news/include.php on line 76
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/abcd_123/domains/mojastronka.pl/public_html/forum/news/include.php on line 76
Warning: filesize() [function.filesize]: stat failed for /domains/mojastronka.pl/public_html/forum/news/template.html in /home/abcd_123/domains/mojastronka.pl/public_html/forum/news/include.php on line 76
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/abcd_123/domains/mojastronka.pl/public_html/forum/news/include.php on line 76
Warning: filesize() [function.filesize]: stat failed for /domains/mojastronka.pl/public_html/forum/news/template.html in /home/abcd_123/domains/mojastronka.pl/public_html/forum/news/include.php on line 76
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/abcd_123/domains/mojastronka.pl/public_html/forum/news/include.php on line 76
Linijka nr. 76:
<?php
$newsstring = fread($fileopen, filesize($includepath.$newstemp)); ?>
Jakieś pomysły jak poprawić?
Ten post edytował ZLoM 30.03.2009, 13:07:10