0
I have the XAMPP
installed on a machine with Windows 8 Enterprise
.
Developing in PHP
happens that when loading the page a temporary file is created in the folder C:\Temp
having as content a given IP address.
$tmpfname = tempnam("C:\Temp","CCT_");
$handle = fopen($tmpfname, "w");
fwrite($handle, $circuito['loopback0']);
fclose($handle);
Renaming this temporary file to a default name.
$conn= rename($tmpfname, "C:\Temp\conecta.txt");
It is accessed later where this IP is read and used to make a connection by Telnet
.
In my machine all this works fully, but when accessing the page of other machines, the file comes to be created with the default name, but without content (blank).
What could be causing this problem?
This problem has the face of invalid permissions, because the files created through the function
tempnam
are permitted0600
, where only the creator can read and write to the file. Once the file is being created but there is nothing of it, the machine should not be understand the network user as "owner" of the file.– Rodrigo Rigotti
there is some way to change the permission or other way to make this file be written by users who run?
– Felipe Oliveira
Try to change the function
tempnam
by functionssys_get_temp_dir
andfile_put_contents
, because in that case the files will be created with the permissions for other users to write to them. Or simply try to change the permissions withchmod
before writing.– Rodrigo Rigotti
Unsuccessful also through file_put_contents, and by chmod($tmpfname, 0755) before grace also did not work.
– Felipe Oliveira
This variable
$circuito['loopback0']
doesn’t work just for a local connection? What are you actually trying to record in the file?– Rodrigo Rigotti
in this file an ip address is saved, for example: 10.76.0.50. This ip is the value of $circuit['loopback0']. On my machine everything happens right, the problem is when access by other machines (they are all within the same network/ domain)
– Felipe Oliveira
What is the content of
$circuito
when you access the file remotely?– Rodrigo Rigotti
$circuit['loopback0'] is a field of my BD. after creating the file connects.txt, it is read by another remote access program, Teraterm.
– Felipe Oliveira