Advertisement
garfield

[PHP]Recebendo dados e tratando-os (SAMP)

Jul 24th, 2014
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. // nick:isuyanw,score:200
  5. // isuyanw,200
  6.  
  7. if(isset($_GET['test']))
  8. {
  9.  
  10.     $_Get = $_GET['test'];
  11.  
  12.     $Extrair = explode(",", $_Get);
  13.  
  14.     $Arquivo = "contas/".$Extrair[0].".ini";
  15.  
  16.  
  17.     file_Set($Arquivo, "Score", $Extrair[1]);
  18. }
  19.  
  20.  
  21.  
  22. function file_Set($filename, $tag, $val){
  23.  
  24.  
  25.  
  26.     $Internal_F =  0;
  27.  
  28.  
  29.     if(file_exists($filename)) $Internal_F = 5;
  30.  
  31.     if(!file_exists($filename)) $Internal_F = 15;
  32.  
  33.  
  34.     $Contend    = "";
  35.  
  36.     if($Internal_F == 5)
  37.     {
  38.  
  39.         $Arquivo    = fopen($filename, "r");
  40.  
  41.         $Conteudo   = fread($Arquivo, filesize($filename));
  42.  
  43.         $linha      = explode("\n", $Conteudo);
  44.  
  45.  
  46.         for($i = 0; $i != sizeof($linha); $i ++)
  47.         {
  48.             if(!(strpos($linha[$i], $tag) !== false)){
  49.  
  50.                 if(!is_null($linha[$i])) $Contend .= $linha[$i]."\n";
  51.  
  52.  
  53.             }
  54.         }
  55.  
  56.         fclose($Arquivo);
  57.  
  58.         unlink($filename);
  59.  
  60.         $Internal_F = 15;
  61.     }
  62.  
  63.  
  64.  
  65.     if($Internal_F == 15){
  66.  
  67.         $Contend .= $tag."=".$val;
  68.  
  69.         $Arquivo    = fopen($filename, "w");
  70.         fwrite($Arquivo, $Contend);
  71.         fclose($Arquivo);
  72.  
  73.     }
  74.  
  75.     return true;
  76. }
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement