Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> aktualnosci, skrypt news
fraksipon
post 10.01.2010, 12:59:18
Post #1





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 18.12.2005

Ostrzeżenie: (0%)
-----


Witam, szuakam prostego skryptu do umieszczaniu aktualności na stronie internetowej.

Chciałbym aktualności na stronie umieścić na małym obszarze, tak, że gdy jedna wiadomość jest za długo to jest ona urywana i możliwa do odczytania po naciśnieciu 'wiecej'

Proszę o pomoc
Go to the top of the page
+Quote Post
kosmowariat
post 10.01.2010, 14:19:12
Post #2





Grupa: Zarejestrowani
Postów: 235
Pomógł: 17
Dołączył: 18.07.2007
Skąd: Białystok

Ostrzeżenie: (0%)
-----


http://www.hotscripts.com/category/php/scr...ews-publishing/

do wyboru, do koloru
Go to the top of the page
+Quote Post
fraksipon
post 10.01.2010, 20:19:31
Post #3





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 18.12.2005

Ostrzeżenie: (0%)
-----


Ok dzięki. Znalazłem coś dla mnie.
Mam jeszcze pytania dwa
1) jak zrobić aby on wyświetlał np: 3 ostatnie wiadomości.
albo
2) Jak zrobić aby pokazywal tylko tyle wiadomości ile zmieści się na wysokości height=250

  1. <?php
  2. /*
  3.  * Author: Rafael Rocha - www.projectrr.net - info@rafaelrocha.net
  4.  * <a href="http://www.projectrr.net/" target="_blank">http://www.projectrr.net/</a> -> scripts
  5.  * Date: 21.12.2009
  6.  * Version: 1.0
  7.  * License: LGPL
  8.  * News system
  9.  *
  10.  */
  11.  
  12. require 'config.php';
  13.  
  14. function VerifyTxtFile(){
  15. if(!is_dir("content")) mkdir("content", "0777", true);
  16. if(!file_exists("content/news.txt")) {
  17. $file = fopen("content/coments.txt", "w");
  18. fwrite($file, "");
  19. fclose($file);
  20. }
  21. return true;
  22. }
  23.  
  24.  
  25. function ReadNews(){
  26. VerifyTxtFile();
  27. $fh = fopen("content/news.txt", 'r');
  28. $theData = fgets($fh);
  29. fclose($fh);
  30. return ExplodeNews($theData);
  31. }
  32.  
  33. function ExplodeNews($NewsArray){
  34. $list = array(array());
  35. if($NewsArray == "") return 0;
  36. $Coments = explode("<X-_-X>", $NewsArray);
  37. for($i=0; $i!=sizeof($Coments)-1; $i++){
  38. $Coment = explode("<XXX_>", $Coments[$i]);
  39. $list[$i]['title'] = $Coment[0];
  40. $list[$i]['date'] = $Coment[1];
  41. $list[$i]['resumo'] = $Coment[2];
  42. }
  43. return $list;
  44. }
  45.  
  46. function FindNew($id_new){
  47. VerifyTxtFile();
  48. $fh = fopen("content/news.txt", 'r');
  49. $theData = fgets($fh);
  50. fclose($fh);
  51. $new = array();
  52. $Coments = explode("<X-_-X>", $theData);
  53.  
  54. if($id_new < sizeof($Coments)-1 and $id_new >= 0){
  55.  
  56. $Coment = explode("<XXX_>", $Coments[$id_new]);
  57. $new['title'] = $Coment[0];
  58. $new['date'] = $Coment[1];
  59. $new['completo'] = $Coment[3];
  60. if($Coment[4] != ""){
  61. $new['image'] = $Coment[4];
  62. $new['align'] = $Coment[5];
  63. }
  64.  
  65. }else{
  66. return 0;
  67.  
  68. }
  69.  
  70. return $new;
  71. }
  72.  
  73. ?>
  74. <link rel="stylesheet" type="text/css" href="images/style.css" />
  75. <?php
  76.  
  77. if(isset($_GET['view'])){
  78. $new_c = FindNew($_GET['id']);
  79. if($new_c != 0){
  80. echo "<table width=\"100%\" border=\"0\">
  81. <tr>
  82. <td height=\"20\"><strong><p class=\"NewsTitle\">".$new_c['title']."</p></strong></td>
  83. </tr>
  84. <tr>
  85. <td height=\"20\" class=\"NewsBody\"><strong>".$new_c['date']."</strong></td>
  86. </tr>
  87. <tr>";
  88.  
  89. if(isset($new_c['image'])){
  90. $size = RedimensionaImagem("images/".$new_c['image']);
  91. echo "<td><img style=\"margin-left: 5px; margin-right: 5px;\" src=\"images/".$new_c['image']."\" align=\"".$new_c['align']."\" width=\"".$size['largura']."\" height=\"".$size['altura']."\" class=\"images\" ><span class=\"NewsBody\">".$new_c['completo']."</span></td>";
  92. }else
  93. echo "<td><span class=\"NewsBody\">".$new_c['completo']."</span></td>";
  94.  
  95. echo "</tr>
  96. </table>
  97. <p>&nbsp;</p>";
  98.  
  99. }else{
  100. echo "ERROR, no new found with id ".$_GET['id'];
  101. }
  102.  
  103.  
  104. }else{
  105. echo "<table width=\"100%\" border=\"0\"><tr> <td valign=\"top\">";
  106.  
  107. $all_news = ReadNews();
  108.  
  109. if($all_news != 0){
  110. for($i = sizeof($all_news)-1; $i >= 0; $i--){
  111. echo "<table width=\"100%\" border=\"0\" align=\"center\">
  112. <tr>
  113. <td height=\"15\" class=\"NewsTitle\"><strong><a href=\"?view&id=".$i."\">".$all_news[$i]['title']."</a></strong></td>
  114. </tr>
  115. <tr>
  116. <td height=\"15\" class=\"NewsBody\"><strong>".$all_news[$i]['date']."</strong></td>
  117. </tr>
  118. <tr>
  119. <td class=\"NewsBody\">".$all_news[$i]['resumo']."</td>
  120. </tr>
  121. </table><p>&nbsp;</p>";
  122. }
  123.  
  124. }else{
  125.  
  126. echo "No news yet";
  127.  
  128. }
  129. echo "</td></tr></table>";
  130. }
  131.  
  132. function RedimensionaImagem($imagem){
  133. if(is_file($imagem)){
  134. $size = getimagesize($imagem);
  135. $height = $size[1];
  136. $width = $size[0];
  137. $tamanho = array();
  138.  
  139. if ($height > __MAXHEIGHT)
  140. {
  141. $height = __MAXHEIGHT;
  142. $percent = ($size[1] / $height);
  143. $width = ($size[0] / $percent);
  144. }
  145. else if ($width > __MAXWIDTH)
  146. {
  147. $width = __MAXWIDTH;
  148. $percent = ($size[0] / $width);
  149. $height = ($size[1] / $percent);
  150. }
  151.  
  152. $tamanho['largura'] = (int) $width;
  153. $tamanho['altura'] = (int) $height;
  154. }
  155. return $tamanho;
  156. }
  157.  
  158. ?>
  159.  
  160.  
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 31.07.2025 - 08:26