Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Problem z funkcją eval()
Jarod
post
Post #1





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Mam dwa pliki:

data.class.php
  1. <?php
  2.  
  3. class Data
  4. {
  5. public $sMessage;
  6. private $sSecret;
  7.  
  8. public function __construct($sInput)
  9. {
  10. echo '<br/><br/><b>Odpaliłem konstruktor klasy Data()...</b>';
  11. $this->sMessage = $sInput;
  12. }
  13.  
  14. public function setSecret()
  15. {
  16. $this->sSecret = md5($this->sMessage);
  17. }
  18.  
  19. public function getSecret()
  20. {
  21. return $this->sSecret;
  22. }
  23.  
  24. public function getMessage()
  25. {
  26. return $this->sMessage;
  27. }
  28. }
  29.  
  30. $oData = new Data('Tajny string...');
  31. $oData->setSecret();
  32. echo '<br/>Message: ' . $oData->getMessage();
  33. echo '<br/>Secret: ' . $oData->getSecret()
  34.  
  35. ?>


oraz index.php
  1. <?php
  2.  
  3. // data.class.php
  4. if (file_exists('data.class.php'))
  5. {
  6. if ($rHandle = @fopen('data.class.php', 'r'))
  7. {
  8. if (flock($rHandle, LOCK_SH))
  9. {
  10. $sFile = htmlspecialchars(fread($rHandle, filesize('data.class.php')));
  11. flock($rHandle, LOCK_UN);
  12. }
  13.  
  14. fclose($rHandle);
  15. }
  16. }
  17.  
  18. $sText = $sFile;
  19.  
  20. // base64_encode()
  21. $sText = base64_encode($sText);
  22. $sText = base64_decode($sText);
  23.  
  24.  
  25. eval($sText);
  26.  
  27.  
  28. ?>


Wywołując funkcję eval() dostaję błąd. W którym miejscu popełniam błąd?
Natomiast coś takiego
  1. <?php
  2. eval("echo \"a\";");
  3. ?>
działa bez problemu..


--------------------
”Godzina nauki w życiu nowoczesnego apostoła jest godziną modlitwy.”
(św. Josemaría Escrivá, Droga, 335)
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 21.08.2025 - 21:39