473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Writing to files that are not public

Hi,
I'm running a script that reads and writes to a file.
The problem is that in order to read and write to this file I need to
set the public permission to read and write.

As understand the reason is that the script is running with apache
id,however the file (which I uploaded using an FTP) has a different
group and user id.

First of all am I right? is this reason, is there a way to solve this
problem (I do not have a ssh connection to my server, so I can't
change the id).

Thanks,
Efi

Mar 8 '07 #1
6 1083
"Efi Merdler" <fo****@gmail.comwrote in message
news:11*********************@n33g2000cwc.googlegro ups.com...
Hi,
I'm running a script that reads and writes to a file.
The problem is that in order to read and write to this file I need to
set the public permission to read and write.

As understand the reason is that the script is running with apache
id,however the file (which I uploaded using an FTP) has a different
group and user id.

First of all am I right? is this reason, is there a way to solve this
problem (I do not have a ssh connection to my server, so I can't
change the id).
Use FTP to turn on all permissions for the file, or create the file in php.

It seems to me that you should consider whether a database may be a cleaner
solution than a file. In addition to the permissions issue you've already
discovered, there is locking. Have you considered what happens when two
sessions need to access the file at the same time? These sorts of issues
are already dealt with if you use a database.

BTW - you may want to post this to alt.php for more answers, as this is not
really a php language issue.
--
Mike Russell
www.curvemeister.com/forum/
Mar 8 '07 #2

Mike Russell wrote:
It seems to me that you should consider whether a database may be a cleaner
solution than a file. In addition to the permissions issue you've already
discovered, there is locking. Have you considered what happens when two
sessions need to access the file at the same time? These sorts of issues
are already dealt with if you use a database.
--
Mike Russell
www.curvemeister.com/forum/
Thanks, I considered it, I'm using flock, the reason I'm not using a
db because all I needed was a really simple access procedure, however
I do agree that next time I'll use a db, now I just do not have the
time to change my script.

Thanks again,
Efi

Mar 8 '07 #3
"Efi Merdler" <fo****@gmail.comwrote in message
news:11*********************@c51g2000cwc.googlegro ups.com...
>
Mike Russell wrote:
>It seems to me that you should consider whether a database may be a
cleaner
solution than a file. In addition to the permissions issue you've
already
discovered, there is locking. Have you considered what happens when two
sessions need to access the file at the same time? These sorts of issues
are already dealt with if you use a database.
>--
Mike Russell
www.curvemeister.com/forum/

Thanks, I considered it, I'm using flock, the reason I'm not using a
db because all I needed was a really simple access procedure, however
I do agree that next time I'll use a db, now I just do not have the
time to change my script.
Write a php script that creates the file, and primes it with whatever data
is needed.

Or install PHP Shell Terminal - in an access protected folder! - and create
the file from there:
http://sourceforge.net/projects/phpterm/
--
Mike Russell
www.curvemeister.com/forum/
Mar 8 '07 #4

Mike Russell wrote:
"Efi Merdler" <fo****@gmail.comwrote in message
news:11*********************@c51g2000cwc.googlegro ups.com...

Mike Russell wrote:
It seems to me that you should consider whether a database may be a
cleaner
solution than a file. In addition to the permissions issue you've
already
discovered, there is locking. Have you considered what happens when two
sessions need to access the file at the same time? These sorts of issues
are already dealt with if you use a database.
--
Mike Russell
www.curvemeister.com/forum/
Thanks, I considered it, I'm using flock, the reason I'm not using a
db because all I needed was a really simple access procedure, however
I do agree that next time I'll use a db, now I just do not have the
time to change my script.

Write a php script that creates the file, and primes it with whatever data
is needed.

Or install PHP Shell Terminal - in an access protected folder! - and create
the file from there:
http://sourceforge.net/projects/phpterm/
--
Mike Russell
www.curvemeister.com/forum/
Thanks, unfortunately php is running in safe mode.
I guess I'll use a script to create this file.

Efi

Mar 8 '07 #5
Mike Russell כתב:
>
Write a php script that creates the file, and primes it with whatever data
is needed.
--
Mike Russell
www.curvemeister.com/forum/
Hi
Unfortunately when trying to change mode I receive the following
error :
Warning: chmod() has been disabled for security reasons

The security is just too tight I can't do anything :-)

What do you think ?

I want my file to be accessible for read and write from php and not to
the outside world.

Efi

Mar 9 '07 #6
"Efi Merdler" <fo****@gmail.comwrote in message
news:11*********************@8g2000cwh.googlegroup s.com...
Mike Russell ???:
>
Write a php script that creates the file, and primes it with whatever data
is needed.
--
Mike Russell
www.curvemeister.com/forum/
Hi
Unfortunately when trying to change mode I receive the following
error :
Warning: chmod() has been disabled for security reasons
Your php is in safe mode. You apparently cannot change the mode of a file
created by another account, in this case your FTP account.
The security is just too tight I can't do anything :-)
What do you think ?
It is very likely still possible to create files in a particular folder and
read and write to them, however
I want my file to be accessible for read and write from php and not to
the outside world.
Delete the file you created using ftp, then create the file in php and then
see if you have permission to read and write it. No chmod should be needed,
since the file will already belong to the host's php account.

If that doesn't work. it's time to use a database. If there's no database,
IMHO you are out of luck, and will have to ask the administrators of your
php host for suggestions, and change your hosting arrangement if they cannot
give you a good answer. Perhaps someone else will chime in with some ideas.
--
Mike Russell
www.curvemeister.com/forum/
Mar 10 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Markus | last post by:
Hi, Well, I'm still a newbie to C++, so excuse my maybe (probably???) stupid question...btw, I use gcc 2.95.2. Here are my (test) funtions: mainfunc.cpp: #include <iostream> #include...
6
by: guy | last post by:
Does .NET have a class or set of functions that facilitate the creating and writing of html files? I have been creating files in streams and constructing html strings and writing them out but it...
16
by: iwdu15 | last post by:
how can i open a file i saved and place the info into different text boxes?
24
by: ypjofficial | last post by:
Hello all, I have written a class with many private data members.and i am putting it in a separate dll file. Now when i link that file while writing my main program module,natuarally i have to...
0
by: bohuge | last post by:
Hey! At the time being I'm working on a backup solution for a Qtek9090 pocketpc, which should be able to find and backup outlook data to a server, local files, messages and contact from the sim...
2
by: Robert Reijntjes | last post by:
Hi, I need to read/write data from/to binary files that have an already defined. This means I can't define classes with the attribute. The files also have arrays with variable length. This...
6
by: bonk | last post by:
I am trying to create a stream that writes text to a file and: - automatically creates a new file once the current file exceeds a certain size - makes it possible to be used by multiple threads...
0
by: mcc99 | last post by:
Amazing, I surfed around to find a simple utility that could list files recursively from a given top folder down through it, writing out the path and filename in simple \path\file_name form, without...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.