Jump to content
Fórum Script Brasil
  • 0

Erro Chat


Guest --rogerio --
 Share

Question

Guest --rogerio --

ao abrir essa pagina.

global.php

<?

function ler_arquivo($file_name)
{
    $fd = @fopen($file_name, 'r');
    $file_content = fread($fd, filesize($file_name));
    fclose($fd);
    $var = unserialize($file_content);
    return $var;
}

function gravar_arquivo($file_name, $var)
{
    $content = serialize($var);
    $fd = @fopen($file_name, 'w+');
    fwrite($fd, $content);
    fclose($fd);
    chmod($file_name, 0644);
    return true;
}


class chat{
   var $users;
   var $msgs;
   var $perfil;
   var $tmsgs;
   var $timer;

   function removeuser($nome){
      $str=time()+60;
      $str.="||||";
      $str.=$this->perfil[$nome]." sai da sala|saida";
      $this->addmsgs($str);
      unset($this->users[$nome]);
      unset($this->perfil[$nome]);
      unset($this->tmsgs[$nome]);
   }

   function adduser($nome){
      if(!isset($this->users[$nome])){
         $str=time()+60;
         $str.="||||";
         $str.=$this->perfil[$nome]." entra na sala|entra";
         $this->addmsgs($str);
         $this->users[$nome]=time()+60;
         $this->tmsgs[$nome]=0; 
      }else{
         $this->users[$nome]=time()+60;
      }
   }

   function addmsgs($str){
      array_splice($this->msgs,100,100,$str);
   }

   function atualiza(){
      if(empty($this->timer)){
         $this->timer=time()+120;
      }//fim if
      if($this->timer < time()){
         $this->timer+=60;
         $k=0;
         for($i=0;$i < sizeof($this->msgs);$i++){
            $pieces=explode("|",$this->msgs[$i]);
            if($pieces[0] < time()){
              $k++;
            }
         }
         array_splice($this->msgs,0,$k);
         $keys=array_keys($this->users);
         for($i=0;$i < sizeof($keys);$i++){
            if($this->users[$keys[$i]] < time()){
               $this->removeuser($keys[$i]);
            }
         }
      }//fim if
   }
}

$file_name = 'chat.txt';

$resultado = ler_arquivo($file_name);

if(!isset($resultado["sala"])){
   $resultado["sala"]=new chat;
   $resultado["sala"]->msgs[0]="0||||";
}
?>

ELE MOSTRA O SEGUINTE ERRO

php on line 6

Warning: fclose(): supplied argument is not a valid stream resource in /home/familial/public_html/chat/global.php on line 7

Warning: fwrite(): supplied argument is not a valid stream resource in /home/familial/public_html/chat/global.php on line 16

Warning: fclose(): supplied argument is not a valid stream resource in /home/familial/public_html/chat/global.php on line 17

Warning: chmod() [function.chmod]: Operation not permitted in /home/familial/public_html/chat/global.php on line 18

ajuda

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Tire o "@" desta linha : $fd = @fopen($file_name, 'r'); o sistema pode não estar conseguibdi abrir o arquivo, e como tem o "@" ele ta escondendo o erro, em coseguencia as funçoes seguintes tb esta gerando erro.

Tire o "@" e veja o erro que vai dar.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.1k
    • Total Posts
      647k
×
×
  • Create New...