Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Dziwny bład
D2voX
post
Post #1





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 22.02.2009

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


Witam

Mam taki problem. Pierwszo dam kody źródłowe

CODE

<?
function show_ipsrv() {
$t_ip = $_SERVER['REMOTE_ADDR'];
$t_ipf = "ipserver/$t_ip.srv";
return $t_ipf;
}
function create_ipsrv() {
$t_ipf = show_ipsrv();
$ipsrv = fopen($t_ipf, 'w');
fwrite($ipsrv, '<?
/* IP-Server */
$isrv_ip = '.$t_ipf.';
// Grafika
$isrv_g_rozx = "1280";
$isrv_g_rozy = "1024";
$isrv_g_vapack = "true";
// Muzyka
$isrv_m_mp3player = "false";
$isrv_m_mp3link = "";
// System
$isrv_lang = "Polish";
$isrv_premium = "0";
$isrv_vwpack = "";
?>');
fclose($ipsrv);

}
?>

INDEX.PHP
<?
include("func_main.php");
check_ipsrv();
?>

To wiadomość która mi wyskakuje
Warning: fopen(ipserver/217.144.216.153.srv) [function.fopen]: failed to open stream: No such file or directory in C:\Program Files\WebServ\httpd\func_main.php on line 24

Warning: fwrite(): supplied argument is not a valid stream resource in C:\Program Files\WebServ\httpd\func_main.php on line 39

Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\WebServ\httpd\func_main.php on line
40
Chciałbym zrobić tak gdy otwiera się strona to tworzy się plik o nazwie ip z tamtymi parametrami

Proszę o pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
daniel1302
post
Post #2





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

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


Nie istnieje plik lub katalog. Pisze jak byk w Warning 1
Go to the top of the page
+Quote Post
D2voX
post
Post #3





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 22.02.2009

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


chodzi mi o tworzenie sie pliku, funkcja w jest to funkcja gdy pliku nie on się tworzy
Go to the top of the page
+Quote Post
nexis
post
Post #4





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


Proponuję następujący kod:
  1. <?php
  2. function makeFile() {
  3.   $path    = sprintf('ipserver/%s.php', $_SERVER['REMOTE_ADDR']);
  4.   $file    = fopen($path, 'w');
  5.   $content = sprintf
  6.      (
  7.         '<?php' . PHP_EOL . '/* IP-Server */' . PHP_EOL . '$isrv_ip = "%s";'
  8.         . PHP_EOL . '// Grafika' . PHP_EOL . '$isrv_g_rozx = "1280";' . PHP_EOL
  9.         . '$isrv_g_rozy = "1024";' . PHP_EOL . '$isrv_g_vapack = "true";'
  10.         . PHP_EOL . '// Muzyka' . PHP_EOL . '$isrv_m_mp3player = "false";'
  11.         . PHP_EOL . '$isrv_m_mp3link = "";' . PHP_EOL . '// System' . PHP_EOL
  12.         . '$isrv_lang = "Polish";' . PHP_EOL . '$isrv_premium = "0";' . PHP_EOL
  13.         . '$isrv_vwpack = "";' . PHP_EOL . '?>',
  14.         $_SERVER['REMOTE_ADDR']
  15.      );
  16.   fwrite($file, $content);
  17.   fclose($file);
  18. }
  19. ?>
  20.  
  21. <?php
  22. makeFile();
  23. ?>
Go to the top of the page
+Quote Post
Mephistofeles
post
Post #5





Grupa: Zarejestrowani
Postów: 1 182
Pomógł: 115
Dołączył: 4.03.2009
Skąd: Myszków

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


Lepiej przez file_put_contents.
Go to the top of the page
+Quote Post
nexis
post
Post #6





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


Cytat(Mephistofeles @ 21.03.2009, 20:06:17 ) *
Lepiej przez file_put_contents.

A co rozumiesz pod lepiej?
Cytat(file_put_contents)
This function is identical to calling fopen(), fwrite() and fclose() successively to write data to a file.


Ten post edytował nexis 22.03.2009, 11:38:13
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 14.09.2025 - 17:32