Jump to content


Photo

Guestbook


  • Faça o login para participar
6 replies to this topic

#1 K-19

K-19

    Normal

  • Usuários
  • 91 posts
  • Sexo:Não informado
  • Localidade:Viseu
  • Interesses:bues deles

Posted 11/08/2004, 19:16

Boa noite para todos!

estava presizando da ajuda de voçes.

Tenho estes codigos:

index.php
<?
include "postar.php";
echo '<body bgcolor="#000000">';

$fp=fopen("noticias.lst","r");
$tmp=fgets($fp,2000);
fclose($fp);

$lista=split(":",$tmp);
$total=count($lista)-1;

for ($cont=$total;$cont>$total-10, $cont>0;$cont--)
{
 if (file_exists($cont.".inc")) {include ($cont.".inc"); echo "<br>";}
}

?>

postar.php
<font size="5" color="#FF0000"><center>Livro de Visitas</center></font><p>
<form name="guest" method="post" action="send.php">
<table width='53%' border='0' align="center" cellpadding='4' cellspacing='1' class="Border">
  <tr>
    <td colspan='2' class="Header" ><strong>Adicionar Comentário</strong></td>
  </tr>
  <tr>
    <td colspan='2'  class="Box" ><div align="center">
      <table width="568" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="108">&nbsp;Nome: <font color="#FF0000">*</font></td>
          <td width="460"><input name="name" type="text" size="40" maxlength="25" />
          15 caracteres no máximo</td>
        </tr>
        <tr>
          <td width="108">&nbsp;E-mail: <font color="#FF0000">*</font></td>
          <td width="460"><input name="email" type="text" size="40" maxlength="40" />
          </td>
        </tr>
        <tr>
         <td widht="86" width="108">&nbsp;Classificaçao:</td>
         <td widht="460" width="460"><SELECT name="classificacao" size="1">
<OPTION SELECTED>Excelente</option>
<OPTION>Muito Boa </option>
<OPTION>Boa</option>
<OPTION>Mais ou Menus</option>
<OPTION>Pobre</option>
<option>Podia estar melhor</option>
<OPTION>Fraca</option>
<OPTION>Muito fraca</option>
</SELECT>
         </td>
        </tr>
        <tr>
          <td valign="top" width="108">&nbsp;<br>
&nbsp;Comentário: <font color="#FF0000">*</font></td>
          <td width="460" valign="top">
              <textarea name="noticia" cols="55" rows="5"></textarea><br />
          </td>
          </tr>
        <tr>
          <td height="24" colspan="2" width="546"><div align="center">
              <input type="submit" name="Submit" value="Enviar" />
              <input type="reset" name="reset" value="Limpar" />
            </div>
          </td>
          </tr>
      </table>
    </div>
    </td>
  </tr>
</table>
</form>

send.php
<?
function verifica_email($email){
if (ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email)){
return true;
}else{
   return false;
}
}

if ($email == "") { echo("O campo <b>E-mail</b> não está preenchido!"); exit; }
if (verifica_email($email)==False){ echo "O <b>Email</b> não foi preenchido correctamente!"; exit; }
if ($name == "") { echo("O campo <b>Nome</b> não está preenchido!"); exit; }
if ($noticia == "") { echo("O campo <b>Comentário</b> não está preenchido!"); exit; }

function badword_filter($text){

$badword_array = file("filtro.txt");
foreach($badword_array as $key=>$val)
{
$text = eregi_replace(trim($val),' **** ',$text);
}
return $text;
}

function smile($string) {

    $smiles = array(
    ':///' => '<img src="../img/smiles/1.gif">',
    ':cool:' => '<img src="../img/smiles/2.gif">',
    ':(' => '<img src="../img/smiles/3.gif">',
    ':D' => '<img src="../img/smiles/4.gif">',
    ':)' => '<img src="../img/smiles/5.gif">',
    ':|' => '<img src="../img/smiles/6.gif">',
    ':red:' => '<img src="../img/smiles/7.gif">',
    '!' => '<img src="../img/smiles/10.gif">',
    '?' => '<img src="../img/smiles/9.gif">',
    ':P' => '<img src="../img/smiles/8.gif">',
    ':=' => '<img src="../img/smiles/11.gif">',
    ':love:' => '<img src="../img/smiles/12.gif">',
    ':8' => '<img src="../img/smiles/13.gif">',
    ':di' => '<img src="../img/smiles/14.gif">',
    ':lamp:' => '<img src="../img/smiles/15.gif">',
    ':rambo:' => '<img src="../img/smiles/16.gif">',
    ':fumar:' => '<img src="../img/smiles/17.gif">',
    ':note:' => '<img src="../img/smiles/18.gif">',
    ':zaro:' => '<img src="../img/smiles/19.gif">',
    ':lock:' => '<img src="../img/smiles/20.gif">',
    ':disk:' => '<img src="../img/smiles/21.gif">',
    ':rezar:' => '<img src="../img/smiles/22.gif">',
    ':ye:' => '<img src="../img/smiles/23.gif">',
    ':cred:' => '<img src="../img/smiles/24.gif">',

    );
    foreach ($smiles as $smile => $emoticon)
    {
        $string = str_replace($smile, $emoticon, $string);
    }
    return $string;
}

// actualiza o contador
$fp=fopen("noticias.txt","r+");
$cont=fgets($fp,10)+1;
rewind($fp);
fputs($fp,$cont);
fclose($fp);

// adiciona a lista
$fp=fopen("noticias.lst","a+");
fputs($fp,$cont.":");
fclose($fp);



$dias=array("Domingo","Segunda-feira","Terça-feira", "Quarta-feira","Quinta-feira","Sexta-feira","Sábado");
$meses=array("Janeiro","Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");

$h=date("H");
$m=date("i");
$D=date("j");
$M=date("m")-1;
$Y=date("Y");
$dia=date("w");

$noticia=smile($noticia);
$noticia=badword_filter($noticia);
$noticia=nl2br($noticia);

echo "<style>";
echo ".Header { BACKGROUND-IMAGE: url('bar.gif'); COLOR: #000000; TEXT-DECORATION: bold }";
echo "</style>";

$tudo="<table width=90% align=center border=0 cellspacing='0' cellpadding='0'>\n";
$tudo.="<tr>\n";
$tudo.="    <td bgcolor=#EFBA67 height=20 class=Header><font face=verdana size=2><b>&nbsp;" . $classificacao . "</b></font></td>\n";
$tudo.="</tr>\n";
$tudo.="</table>\n\n";

$tudo.="<table width=90% align=center border=0 cellspacing=0 cellpadding=0>\n";
$tudo.="<tr><font size=1><td bgcolor=#F0F0F0><font face=verdana size=1><i>". $dias[$dia].", ". $D ." de " . $meses[$M]. " de ". $Y ." - ". $h .":".$m." </i><br></font>\n";
$tudo.="<font size=1 face=verdana><i>Por:</i><a href=\"mailto:$email\">$name</a><br><i>Mensagem:</i>$noticia</font>";

$tudo.="<font face=verdana size=2>\n";
$tudo.="</td></tr></table>\n";


$fp=fopen($cont.".inc","w");
fputs($fp, $tudo);
fclose($fp);

echo "<h1 align=center>Adicionado.</h1>";
echo '<center><a href="../index.php">VOLTAR</a></center>';

include($cont.".inc");

?>

Estes codigos estao bem, mas queria fazer a "paginaçao" das mensagens, mas nao sei como é, alguem podia dar uma maozinha?

DESCULPEM VIR COM ESTA COISA DA PAGINAÇAO, sei que este assunto ja esta muito batido, mas ainda nao encontrei nada que me ajuda-se.
Agradeço desde já a resposta.
www.Scripts.kom.pt - My WebPage

#2 Hyoga de Cisne

Hyoga de Cisne

    Ativo

  • Banidos
  • PipPipPipPip
  • 359 posts
  • Sexo:Não informado
  • Interesses:Gosto muito de PHP, adoro Webdesign. Sou muito fã de ROCK! Gosto de ajudar à quem precisa, e merece...<br>Gosto de sempre estar atualizado de aprender mais a cada dia que se passa...

Posted 11/08/2004, 19:56

Faça um buskinha q vc vai achar...
hyoga.de.cisne
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
AnimeSchool.com.br - O Melhor em animes, com muitos episódios, informação e muito mais!

#3 K-19

K-19

    Normal

  • Usuários
  • 91 posts
  • Sexo:Não informado
  • Localidade:Viseu
  • Interesses:bues deles

Posted 11/08/2004, 21:18

meti este codigo, mas esta dando muitos erros!

<?php
include "postar.php";
echo '<body bgcolor="#000000">';

$dir = "./";

$files = array();
if( is_dir( $dir ) ) {
  if( $dh = opendir( $dir ) ) {
    while( ( $file = readdir( $dh ) ) !== false ) {
      if( $file != "." && $file != ".." ) {
        array_push( $files, $file );
      }
    }
    closedir( $dh );
  }
}

$page_size = 3;
$total_pages = ceil( count( $files ) / $page_size );

if( isset( $_GET['p'] ) ) {
  $current_page = $_GET['p'];
  if( $current_page > $total_pages ) {
    $current_page = $total_pages;
  }
} else {
  $current_page = 1;
}

$start = ( $current_page * $page_size ) - $page_size;

print( "Página " . $current_page . " de " . $total_pages . "<br><br>\n\n" );

for( $j=0; $j<$total_pages; $j++ ) {
  $p = $j + 1;
  print( "<a href='?p=" . $p . "'>" . $p . "</a> " );
}

print( "<br><br>" );

for( $i=$start; $i<$start + $page_size; $i++ ) {
  if( is_file( $dir . $files[$i] ) ) {
    include ($i.".inc"); echo "<br>";
  }
}
?>

Alguem me ajude por favor.
www.Scripts.kom.pt - My WebPage

#4 JeDaH

JeDaH

    Rammstein!

  • Usuários
  • 490 posts
  • Sexo:Masculino
  • Localidade:São Paulo - SP - ZN

Posted 11/08/2004, 22:17

poste os erros para que todos possam ajudar ;)
Ein Schrei wird zum Himmel fahren
schneidet sich durch Engelscharen
Vom Wolkendach fällt Federfleisch
auf meine Kindheit mit Gekreisch

Rammstein - Mein Teil

#5 Inter4u

Inter4u

    Turista

  • Usuários
  • 38 posts
  • Sexo:Não informado

Posted 11/08/2004, 23:24

http://www.phpclasse.org

tem classes muito boas de paginação

#6 Felipe Pena

Felipe Pena

    O temor do Senhor é o princípio da sabedoria

  • Ex-Admins
  • 6441 posts
  • Sexo:Masculino

Posted 12/08/2004, 05:18

Se baseia na páginação feita com php+mysql. ;)

Daí tu vai se ligar no que tá errando.
Felipe Pena
[...] ó terra, terra, terra; ouve a palavra do Senhor. — Jeremias 22:29

#7 K-19

K-19

    Normal

  • Usuários
  • 91 posts
  • Sexo:Não informado
  • Localidade:Viseu
  • Interesses:bues deles

Posted 12/08/2004, 06:17

O felipensp passou o codigo para mim.

<?php
include "postar.php";
echo '<body bgcolor="#000000">';

$dir = "./";

$a=0;
if( is_dir( $dir ) ) {
 if( $dh = opendir( $dir ) ) {
   while( ( $file = readdir( $dh ) ) !== false ) {
     if( $file != "." && $file != ".." ) {
      $e = explode(".", $file);
         if($e[1]=="inc"){ $a++; }
     }
   }
   closedir( $dh );
 }
}

$page_size = 2;
$total_pages = ceil( $a / $page_size );

if( isset( $_GET['p'] ) ) {
 $current_page = $_GET['p'];
 } else {
 $current_page = 1;
}

$inicio = $current_page - 1;
$start = ( $inicio * $page_size + 1 );

if($start==0){ $start=1; }

print( "Página " . $current_page . " de " . $total_pages . "<br><br>\n\n" );

for( $j=0; $j<$total_pages; $j++ ) {
 $p = $j + 1;
 print( "<a href='?p=" . $p . "'>" . $p . "</a> " );
}

print( "<br><br>" );

for( $i=$start; $i<$start + $page_size; $i++ ) {
 if( is_file( $dir . $i.".inc") ) {
   include ($i.".inc"); echo "<br>";
 }
}
?>


Mas queria saber o que tenho que mudar para postar os arquivos de ordem inversa.Do maior para o menor
www.Scripts.kom.pt - My WebPage




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq