Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: fread() Length parameter must be greater than 0
Forum PHP.pl > Forum > Przedszkole
ZLoM
Witajcie,
Mam taki o to skrypt:
  1. <?php
  2. //config//
  3. $includepath = "/domains/mojastronka.pl/public_html/forum/news/";   //path where the news folder resides
  4. $mainurl = "http://www.mojastronka.pl.pl";
  5. $forumurl = "http://www.mojastronka.pl/forum/";
  6. $includeurl = "http://www.mojastronka.pl/forum/news/"; //URL where the news folder resides
  7. $newstemp = "template.html";
  8.  
  9. // Database Information
  10. $dbserver = 'localhost';
  11. $dbuser = 'abcd_123';
  12. $dbpass = 'haslo';
  13. $dbase = 'abcd_123';
  14.  
  15. $db = mysql_connect($dbserver, $dbuser, $dbpass) or die('Could not connect to DB server!');
  16. mysql_select_db($dbase) or die("Could not connect to database: ".mysql_error());
  17.  
  18.  
  19. function replace_bb_code($text) {
  20.    $text = preg_replace('/:[0-9a-z:]+]/si', ']', $text);
  21.    $text = preg_replace( "#(.+?)#is", "<b>1</b>", $text );
  22.    $text = preg_replace( "#(.+?)#is", "<i>1</i>", $text );
  23.    $text = preg_replace( "#(.+?)#is", "<u>1</u>", $text );
  24.    $text = preg_replace( "#(.+?)#is", "<s>1</s>", $text );
  25.    $text = eregi_replace("([^[]*)","<a href=\"1\" target=\"_blank\">1</a>",$text);
  26.    $text = eregi_replace("+)]([^[]*)","<a href=\"1\" target=\"_blank\">2</a>",$text);
  27.    $text = eregi_replace("[img]([^[]*)[/img]","<img src=\"1\" border=0>",$text);
  28.    $text = eregi_replace("+)]([^[]*)","<font color=\"1\">2</font>",$text);
  29.    $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);
  30.    $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);
  31.    $text = eregi_replace("+)]([^[]*)","<font size='2'>2</font>",$text);
  32.    return $text;
  33.    }
  34.  
  35. $forumid = '3';  // You can set your forum ID here to pull the posts from the forum you want
  36. $post_count = $_REQUEST['postcount'];
  37.  
  38. if (!$post_count) { $post_count = 3; }  // You may Change the amount of posts that are returned here by changing the number
  39. $changetemplate = $_REQUEST['template'];
  40. if ($changetemplate == "") { } else { $newstemp = $changetemplate; }
  41. $truncate = $_REQUEST['truncate'];
  42. if (!$truncate) { $truncate = 100000; }
  43.  
  44. if($_REQUEST['reverse']==1) {   ////you may need to change your database prefix from vbforum_ to what yours is
  45. $query = "SELECT * FROM post p, thread t WHERE p.threadid = t.threadid AND t.forumid ='".$forumid."' ORDER BY p.threadid ASC, p.postid;";
  46. } else {
  47. $query = "SELECT * FROM post p, thread t WHERE p.threadid = t.threadid AND t.forumid ='".$forumid."' ORDER BY p.threadid DESC, p.postid;";
  48. }
  49.  
  50. $result = mysql_query($query);
  51. $num = mysql_num_rows($result);
  52. $post = 0;
  53.  
  54. while($post < $post_count) {
  55. $row = mysql_fetch_object($result);
  56.    if($row=="") { break; }
  57.    if ($previous_topic == $row->threadid) {  // do nothing.
  58.    }
  59.    else {
  60.    $previous_topic = $row->threadid;
  61.    $post++;
  62.        
  63.    $posttextquery = "SELECT * FROM post WHERE postid='".$row->postid."';";
  64.    $posttextresult = mysql_query($posttextquery);
  65.    $posttextrow = mysql_fetch_object($posttextresult);
  66.    
  67.    $useridquery = "SELECT * FROM user WHERE userid='".$row->userid."';";
  68.    $useridresults = mysql_query($useridquery);
  69.    $useridrow = mysql_fetch_object($useridresults);
  70.    
  71.    $responsesquery = "SELECT * FROM post WHERE threadid='".$row->threadid."';";
  72.    $responsesresults = mysql_query($responsesquery);
  73.    $num_responses = mysql_num_rows($responsesresults)-1;
  74.        
  75.    $fileopen = fopen($includeurl.$newstemp, "r");
  76.    $newsstring = fread($fileopen, filesize($includepath.$newstemp));
  77.    
  78.    $subject = $posttextrow->title;
  79.    
  80.    $newsstring = str_replace("((post_date))", date("F j, Y", $row->dateline), $newsstring);
  81.    $newsstring = str_replace("((post_time))", date("g:i a", $row->dateline), $newsstring);
  82.    $newsstring = str_replace("((poster_name))", "<a href='".$forumurl."member.php?u=".$row->userid."' target='_blank'>".$useridrow->username."</a>", $newsstring);
  83.    $newsstring = str_replace("((post_subject))", $subject, $newsstring);
  84.    if (strlen($newsstring) > $truncate) {
  85.    $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);
  86.    } else {
  87.    $newsstring = str_replace("((post_text))", nl2br($posttextrow->pagetext), $newsstring);
  88.    }
  89.    $newsstring = str_replace("((comment))", "<a href='".$forumurl."showthread.php?t=".$row->threadid."' target='_blank'>Comments</a>", $newsstring);
  90.    $newsstring = str_replace("((responses))", $num_responses, $newsstring);
  91.  
  92.  
  93.    
  94.    $newsstring = replace_bb_code($newsstring);
  95.    $newsstring = replace_bb_code($newsstring);
  96.    
  97.    echo $newsstring;
  98.    }
  99. }
  100. ?>


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:
  1. <?php
  2. $newsstring = fread($fileopen, filesize($includepath.$newstemp));
  3. ?>


Jakieś pomysły jak poprawić?
Maxik
Po co dajesz taką ścieżkę w filesize? Podaj tylko template.html
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.