php-general Digest 3 Jul 2009 15:58:36 -0000 Issue 6209
Topics (messages 294841 through 294867):
Re: Sessions
294841 by: Daniel Brown
294847 by: Luke
294849 by: Tom Chubb
294850 by: Ashley Sheridan
294851 by: Tom Chubb
294852 by: Stuart
294860 by: Richard Heyes
Re: cannot figure out permissions for fopen/fwrite
294842 by: Mari Masuda
294867 by: Shawn McKenzie
Encoding problems on IIS7 + FastCGI on windows server 2008
294843 by: Jon Lau
memcache and security
294844 by: Michael A. Peters
294845 by: Michael A. Peters
Timezone details
294846 by: Manoj Singh
294848 by: Michael A. Peters
Writing to a file
294853 by: Jason Carson
294854 by: Stuart
294855 by: Sándor Tamás (HostWare Kft.)
294857 by: Michael A. Peters
294859 by: Paul Scott
294861 by: Daniel Brown
294862 by: Daniel Brown
apc breaks pear::mdb2
294856 by: Michael A. Peters
294858 by: Michael A. Peters
294863 by: Daniel Brown
294864 by: Michael A. Peters
php-general mail server on blackhole list
294865 by: The Doctor
294866 by: Daniel Brown
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Thu, Jul 2, 2009 at 23:27, Jason Carson<[email protected]> wrote:
> Hello all,
>
> Do I have to add session_start() at the beginning of every page so that
> the $_SESSION variables work on all pages or do I use session_start() on
> the first page and something else on other pages?
Yes, unless you're using session autoloading. Also, in most
cases, you will only need to call session_start() once (before
referencing $_SESSION), even if $_SESSION is accessed in an included
file.
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our hosting and dedicated server deals at http://twitter.com/pilotpig
--- End Message ---
--- Begin Message ---
2009/7/3 Daniel Brown <[email protected]>
> On Thu, Jul 2, 2009 at 23:27, Jason Carson<[email protected]> wrote:
> > Hello all,
> >
> > Do I have to add session_start() at the beginning of every page so that
> > the $_SESSION variables work on all pages or do I use session_start() on
> > the first page and something else on other pages?
>
> Yes, unless you're using session autoloading. Also, in most
> cases, you will only need to call session_start() once (before
> referencing $_SESSION), even if $_SESSION is accessed in an included
> file.
>
> --
> </Daniel P. Brown>
> [email protected] || [email protected]
> http://www.parasane.net/ || http://www.pilotpig.net/
> Check out our hosting and dedicated server deals at
> http://twitter.com/pilotpig
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Some people have a file called init.php, which would contain
session_start(); as well as other things that need to be done every page
load (connect to the database perhaps?) and they just 'require' that at the
top of every page.
--
Luke Slater
http://dinosaur-os.com/
:O)
--- End Message ---
--- Begin Message ---
2009/7/3 Luke <[email protected]>
> 2009/7/3 Daniel Brown <[email protected]>
>
> > On Thu, Jul 2, 2009 at 23:27, Jason Carson<[email protected]> wrote:
> > > Hello all,
> > >
> > > Do I have to add session_start() at the beginning of every page so that
> > > the $_SESSION variables work on all pages or do I use session_start()
> on
> > > the first page and something else on other pages?
> >
> > Yes, unless you're using session autoloading. Also, in most
> > cases, you will only need to call session_start() once (before
> > referencing $_SESSION), even if $_SESSION is accessed in an included
> > file.
> >
> > --
> > </Daniel P. Brown>
> > [email protected] || [email protected]
> > http://www.parasane.net/ || http://www.pilotpig.net/
> > Check out our hosting and dedicated server deals at
> > http://twitter.com/pilotpig
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Some people have a file called init.php, which would contain
> session_start(); as well as other things that need to be done every page
> load (connect to the database perhaps?) and they just 'require' that at the
> top of every page.
>
> --
> Luke Slater
> http://dinosaur-os.com/
> :O)
>
Never thought of that. Sounds like quite a good idea.
Can anyone tell me if there's any reason for not doing that, even on pages
that do not require session data?
Or perhaps use an htaccess file to server side include a file file to all
files under an admin folder or something and another to destroy the session.
I'm thinking of smaller, low-traffic sites.
I know people are going to say, if they're small sites, why can't you only
start sessions on the relevant pages but it sounds like it could work well
for me.
--- End Message ---
--- Begin Message ---
On Friday 03 July 2009 09:41:40 Tom Chubb wrote:
> 2009/7/3 Luke <[email protected]>
>
> > 2009/7/3 Daniel Brown <[email protected]>
> >
> > > On Thu, Jul 2, 2009 at 23:27, Jason Carson<[email protected]> wrote:
> > > > Hello all,
> > > >
> > > > Do I have to add session_start() at the beginning of every page so
> > > > that the $_SESSION variables work on all pages or do I use
> > > > session_start()
> >
> > on
> >
> > > > the first page and something else on other pages?
> > >
> > > Yes, unless you're using session autoloading. Also, in most
> > > cases, you will only need to call session_start() once (before
> > > referencing $_SESSION), even if $_SESSION is accessed in an included
> > > file.
> > >
> > > --
> > > </Daniel P. Brown>
> > > [email protected] || [email protected]
> > > http://www.parasane.net/ || http://www.pilotpig.net/
> > > Check out our hosting and dedicated server deals at
> > > http://twitter.com/pilotpig
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > Some people have a file called init.php, which would contain
> > session_start(); as well as other things that need to be done every page
> > load (connect to the database perhaps?) and they just 'require' that at
> > the top of every page.
> >
> > --
> > Luke Slater
> > http://dinosaur-os.com/
> >
> > :O)
>
> Never thought of that. Sounds like quite a good idea.
> Can anyone tell me if there's any reason for not doing that, even on pages
> that do not require session data?
> Or perhaps use an htaccess file to server side include a file file to all
> files under an admin folder or something and another to destroy the
> session. I'm thinking of smaller, low-traffic sites.
> I know people are going to say, if they're small sites, why can't you only
> start sessions on the relevant pages but it sounds like it could work well
> for me.
It's easier to maintain if you use one include file like Luke said. You won't
get much overhead from a call to session_start() on a page that doesn't use
sessions.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
2009/7/3 Ashley Sheridan <[email protected]>
> On Friday 03 July 2009 09:41:40 Tom Chubb wrote:
> > 2009/7/3 Luke <[email protected]>
> >
> > > 2009/7/3 Daniel Brown <[email protected]>
> > >
> > > > On Thu, Jul 2, 2009 at 23:27, Jason Carson<[email protected]>
> wrote:
> > > > > Hello all,
> > > > >
> > > > > Do I have to add session_start() at the beginning of every page so
> > > > > that the $_SESSION variables work on all pages or do I use
> > > > > session_start()
> > >
> > > on
> > >
> > > > > the first page and something else on other pages?
> > > >
> > > > Yes, unless you're using session autoloading. Also, in most
> > > > cases, you will only need to call session_start() once (before
> > > > referencing $_SESSION), even if $_SESSION is accessed in an included
> > > > file.
> > > >
> > > > --
> > > > </Daniel P. Brown>
> > > > [email protected] || [email protected]
> > > > http://www.parasane.net/ || http://www.pilotpig.net/
> > > > Check out our hosting and dedicated server deals at
> > > > http://twitter.com/pilotpig
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > > Some people have a file called init.php, which would contain
> > > session_start(); as well as other things that need to be done every
> page
> > > load (connect to the database perhaps?) and they just 'require' that at
> > > the top of every page.
> > >
> > > --
> > > Luke Slater
> > > http://dinosaur-os.com/
> > >
> > > :O)
> >
> > Never thought of that. Sounds like quite a good idea.
> > Can anyone tell me if there's any reason for not doing that, even on
> pages
> > that do not require session data?
> > Or perhaps use an htaccess file to server side include a file file to all
> > files under an admin folder or something and another to destroy the
> > session. I'm thinking of smaller, low-traffic sites.
> > I know people are going to say, if they're small sites, why can't you
> only
> > start sessions on the relevant pages but it sounds like it could work
> well
> > for me.
>
>
> It's easier to maintain if you use one include file like Luke said. You
> won't
> get much overhead from a call to session_start() on a page that doesn't use
> sessions.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
Great,
Cheers Ash,
T
--
Tom Chubb
[email protected] | [email protected]
--- End Message ---
--- Begin Message ---
2009/7/3 Ashley Sheridan <[email protected]>:
> On Friday 03 July 2009 09:41:40 Tom Chubb wrote:
>> 2009/7/3 Luke <[email protected]>
>>
>> > 2009/7/3 Daniel Brown <[email protected]>
>> >
>> > > On Thu, Jul 2, 2009 at 23:27, Jason Carson<[email protected]> wrote:
>> > > > Hello all,
>> > > >
>> > > > Do I have to add session_start() at the beginning of every page so
>> > > > that the $_SESSION variables work on all pages or do I use
>> > > > session_start()
>> >
>> > on
>> >
>> > > > the first page and something else on other pages?
>> > >
>> > > Yes, unless you're using session autoloading. Also, in most
>> > > cases, you will only need to call session_start() once (before
>> > > referencing $_SESSION), even if $_SESSION is accessed in an included
>> > > file.
>> > >
>> > > --
>> > > </Daniel P. Brown>
>> > > [email protected] || [email protected]
>> > > http://www.parasane.net/ || http://www.pilotpig.net/
>> > > Check out our hosting and dedicated server deals at
>> > > http://twitter.com/pilotpig
>> > >
>> > > --
>> > > PHP General Mailing List (http://www.php.net/)
>> > > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> > Some people have a file called init.php, which would contain
>> > session_start(); as well as other things that need to be done every page
>> > load (connect to the database perhaps?) and they just 'require' that at
>> > the top of every page.
>> >
>> > --
>> > Luke Slater
>> > http://dinosaur-os.com/
>> >
>> > :O)
>>
>> Never thought of that. Sounds like quite a good idea.
>> Can anyone tell me if there's any reason for not doing that, even on pages
>> that do not require session data?
>> Or perhaps use an htaccess file to server side include a file file to all
>> files under an admin folder or something and another to destroy the
>> session. I'm thinking of smaller, low-traffic sites.
>> I know people are going to say, if they're small sites, why can't you only
>> start sessions on the relevant pages but it sounds like it could work well
>> for me.
>
>
> It's easier to maintain if you use one include file like Luke said. You won't
> get much overhead from a call to session_start() on a page that doesn't use
> sessions.
It's also worth noting that every call to session_start() will result
in the expiry time of the session being updated. Not calling it for
pages that don't use the session could lead to the session expiring if
the user doesn't hit a page that uses it for a while.
-Stuart
--
http://stut.net/
--- End Message ---
--- Begin Message ---
Hi,
> ..
This is precisely what I do, albeit my file is called config.php, and
not init.php. Not that it makes a jot of difference. This file is used
to setup the environment, so that way everything I commonly need is
available simply by including one file. One thing to note though is
that a database connection is not established by default. I used to
get a lot of comment spam on my blog and because it was needlessly
connecting to the database, it was bringing down the server. So now I
simply use something like this to quickly and easily get a reference
to a database object:
$db = getDatabase();
Wunderbar.
--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net - updated 3rd July)
--- End Message ---
--- Begin Message ---
Yes, currently the tmp folder (or any folders in my Apache htdocs
folder) is not accessible to the web due to the Mac's built-in
firewall set to block all incoming traffic except network time and
something installed by Adobe when I installed CS4 (e.g., Photoshop,
InDesign, etc.). However, I was wondering what the normal technique
is for writing files if the script that does the fopen/fwrite is
located on a production server that IS on the web. It occurred to me
that I could create a 777 folder outside of the web root so that it
would not be accessible on the web even if the script was running on
a production server, but I wasn't sure if that was a good or bad idea.
On Jul 2, 2009, at 17:59, Waynn Lue wrote:
The tmp folder isn't accessible from the web though, right? Someone
would first have to get access to your server for that.
On 7/1/09, Mari Masuda <[email protected]> wrote:
On Jul 1, 2009, at 12:54, Shawn McKenzie wrote:
Mari Masuda wrote:
On Jul 1, 2009, at 12:20, Shawn McKenzie wrote:
Shawn McKenzie wrote:
Mari Masuda wrote:
Hello,
This is probably a dumb newbie question. I am running PHP
5.2.5 and
Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP
and
Apache
from source a while ago (as opposed to using the built-in web
server
that is included w/ Mac OS X). I have written the below PHP
whose
purpose is to read an existing comma separated (CSV) file and
save the
data into a text file that I can later copy and paste from
into my
website content management system. The problem is that on my
Mac, I
cannot seem to figure out what permissions I need to set in
order to
make the input CSV and the initially non-existant output text
file
readable and writable by Apache/PHP. I have Googled and come
across
many pages about different ways to set permissions and different
permissions to set but none of the ways suggested that I tried
seemed to
work for me. As a temporary solution, I uploaded my PHP file
to a
Windows 2003 server running Apache and PHP and it worked
flawlessly
(and
makes me suspicious that there is some huge security hole
with the
Windows box since it was able to execute with no permissions
modifications). Any tips would be greatly appreciated. Thanks!
Mari
--- start my code ---
<?php
$in = fopen("/Applications/apache/htdocs/wp-php/wp.csv",
"r");
$out =
fopen("/Applications/apache/htdocs/wp-php/
tableToCutAndPaste.txt",
"w");
$counter = 0;
fwrite($out, "<table>\n");
while(($data = fgetcsv($in)) !== FALSE) {
$paperNumber = $data[0];
$authors = $data[1];
$title = $data[2];
$filename = $paperNumber . ".pdf";
if(($counter % 2) == 0) {
fwrite($out, "<tr>\n");
} else {
fwrite($out, "<tr style=\"background: #cccccc;\">
\n");
}
fwrite($out, "<td><a
href=\"http://www.example.com/workingpapers/getWorkingPaper.php?
filename=$filename\">$paperNumber</a></td>\n");
fwrite($out, "<td>$authors</td>\n");
fwrite($out, "<td>$title</td>\n");
fwrite($out, "</tr>\n");
$counter++;
}
fwrite($out, "</table>\n");
fclose($in);
fclose($out);
?>
--- end my code ---
What are the permissions on /Applications/apache/htdocs/wp-php/ ?
Apache needs write permissions on that dir in order to create
the file
tableToCutAndPaste.txt.
It's probably not a secure idea to give write permissions to
that dir,
so maybe create a subdir of tmp and change those permissions
(one way):
mkdir /Applications/apache/htdocs/wp-php/tmp
chmod a+w /Applications/apache/htdocs/wp-php/tmp
Also, turn on error reporting so that you can see the exact
problem. It
may not be what you think.
--
Thanks!
-Shawn
http://www.spidean.com
Thanks for the suggestions. I added the following lines to the
very top
of my code:
error_reporting(E_ALL);
mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true);
chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w");
and I also changed the line where it tries to open the file to
write to
to go to the new directory:
$out =
fopen("/Applications/apache/htdocs/wp-php/tmp/
tableToCutAndPaste.txt",
"w");
Below are the errors I got:
--- start errors ---
Warning: mkdir() [function.mkdir]: Permission denied in
/Applications/apache/htdocs/wp-php/generateTable.php on line 5
Warning: chmod() [function.chmod]: No such file or directory in
/Applications/apache/htdocs/wp-php/generateTable.php on line 6
Warning:
fopen(/Applications/apache/htdocs/wp-php/tmp/
tableToCutAndPaste.txt)
[function.fopen]: failed to open stream: No such file or
directory in
/Applications/apache/htdocs/wp-php/generateTable.php on line 9
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 13
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 22
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 27
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 28
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 29
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 30
Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 35
Warning: fclose(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 39
--- end errors ---
The permissions are as follows (sorry I didn't think to include
them in
my original message):
[Wed Jul 01 12:28:29] ~: ls -la /Applications/apache/htdocs/wp-php/
total 64
drwxr-xr-x 5 mari admin 170 Jun 29 16:47 .
drwxr-xr-x 24 mari admin 816 Jun 29 16:47 ..
-rw-r--r-- 1 mari admin 6148 Jun 28 21:11 .DS_Store
-rwxr--r-- 1 mari admin 827 Jul 1 12:26 generateTable.php
-rwxr--r-- 1 mari admin 17532 Jun 28 20:53 wp.csv
[Wed Jul 01 12:29:01] ~:
Thank you,
Mari
That's because the apache user doesn't have permissions to create
the
dir or change the permissions. The commands I gave you need to
be run
from the command line.
--
Thanks!
-Shawn
http://www.spidean.com
Oh, duh, thank you. Doing it on the command line like you said
worked great. I also had to edit my .csv file in TextWrangler to
change the line breaks from \r to \r\n before it would work.
Although the Mac's built-in firewall is set to block incoming traffic
except for network time and something installed by Adobe when I
installed CS4, I was wondering about the security of this technique
if done on a production server. I only run this script by pointing
my browser to http://localhost/wp-php/generateTable.php and I think
with my firewall settings nobody else would be able to execute this
script, but it seems if the tmp folder is set to world writable on a
production server that anybody might be able to somehow upload a
malicious file if they knew the location of tmp. Any thoughts?
Thanks!
Mari
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Mari Masuda wrote:
> Yes, currently the tmp folder (or any folders in my Apache htdocs
> folder) is not accessible to the web due to the Mac's built-in firewall
> set to block all incoming traffic except network time and something
> installed by Adobe when I installed CS4 (e.g., Photoshop, InDesign,
> etc.). However, I was wondering what the normal technique is for
> writing files if the script that does the fopen/fwrite is located on a
> production server that IS on the web. It occurred to me that I could
> create a 777 folder outside of the web root so that it would not be
> accessible on the web even if the script was running on a production
> server, but I wasn't sure if that was a good or bad idea.
>
> On Jul 2, 2009, at 17:59, Waynn Lue wrote:
>
>> The tmp folder isn't accessible from the web though, right? Someone
>> would first have to get access to your server for that.
>>
>> On 7/1/09, Mari Masuda <[email protected]> wrote:
>>>
>>> On Jul 1, 2009, at 12:54, Shawn McKenzie wrote:
>>>
>>>> Mari Masuda wrote:
>>>>> On Jul 1, 2009, at 12:20, Shawn McKenzie wrote:
>>>>>
>>>>>> Shawn McKenzie wrote:
>>>>>>> Mari Masuda wrote:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> This is probably a dumb newbie question. I am running PHP
>>>>>>>> 5.2.5 and
>>>>>>>> Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and
>>>>>>>> Apache
>>>>>>>> from source a while ago (as opposed to using the built-in web
>>>>>>>> server
>>>>>>>> that is included w/ Mac OS X). I have written the below PHP whose
>>>>>>>> purpose is to read an existing comma separated (CSV) file and
>>>>>>>> save the
>>>>>>>> data into a text file that I can later copy and paste from into my
>>>>>>>> website content management system. The problem is that on my
>>>>>>>> Mac, I
>>>>>>>> cannot seem to figure out what permissions I need to set in
>>>>>>>> order to
>>>>>>>> make the input CSV and the initially non-existant output text file
>>>>>>>> readable and writable by Apache/PHP. I have Googled and come
>>>>>>>> across
>>>>>>>> many pages about different ways to set permissions and different
>>>>>>>> permissions to set but none of the ways suggested that I tried
>>>>>>>> seemed to
>>>>>>>> work for me. As a temporary solution, I uploaded my PHP file to a
>>>>>>>> Windows 2003 server running Apache and PHP and it worked
>>>>>>>> flawlessly
>>>>>>>> (and
>>>>>>>> makes me suspicious that there is some huge security hole with the
>>>>>>>> Windows box since it was able to execute with no permissions
>>>>>>>> modifications). Any tips would be greatly appreciated. Thanks!
>>>>>>>>
>>>>>>>> Mari
>>>>>>>>
>>>>>>>> --- start my code ---
>>>>>>>> <?php
>>>>>>>>
>>>>>>>> $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r");
>>>>>>>> $out =
>>>>>>>> fopen("/Applications/apache/htdocs/wp-php/tableToCutAndPaste.txt",
>>>>>>>> "w");
>>>>>>>> $counter = 0;
>>>>>>>>
>>>>>>>>
>>>>>>>> fwrite($out, "<table>\n");
>>>>>>>>
>>>>>>>> while(($data = fgetcsv($in)) !== FALSE) {
>>>>>>>> $paperNumber = $data[0];
>>>>>>>> $authors = $data[1];
>>>>>>>> $title = $data[2];
>>>>>>>> $filename = $paperNumber . ".pdf";
>>>>>>>>
>>>>>>>> if(($counter % 2) == 0) {
>>>>>>>> fwrite($out, "<tr>\n");
>>>>>>>> } else {
>>>>>>>> fwrite($out, "<tr style=\"background: #cccccc;\">\n");
>>>>>>>> }
>>>>>>>>
>>>>>>>> fwrite($out, "<td><a
>>>>>>>> href=\"http://www.example.com/workingpapers/getWorkingPaper.php?
>>>>>>>> filename=$filename\">$paperNumber</a></td>\n");
>>>>>>>>
>>>>>>>>
>>>>>>>> fwrite($out, "<td>$authors</td>\n");
>>>>>>>> fwrite($out, "<td>$title</td>\n");
>>>>>>>> fwrite($out, "</tr>\n");
>>>>>>>>
>>>>>>>> $counter++;
>>>>>>>> }
>>>>>>>>
>>>>>>>> fwrite($out, "</table>\n");
>>>>>>>>
>>>>>>>>
>>>>>>>> fclose($in);
>>>>>>>> fclose($out);
>>>>>>>>
>>>>>>>> ?>
>>>>>>>> --- end my code ---
>>>>>>>
>>>>>>> What are the permissions on /Applications/apache/htdocs/wp-php/ ?
>>>>>>>
>>>>>>> Apache needs write permissions on that dir in order to create
>>>>>>> the file
>>>>>>> tableToCutAndPaste.txt.
>>>>>>>
>>>>>>> It's probably not a secure idea to give write permissions to
>>>>>>> that dir,
>>>>>>> so maybe create a subdir of tmp and change those permissions
>>>>>>> (one way):
>>>>>>>
>>>>>>> mkdir /Applications/apache/htdocs/wp-php/tmp
>>>>>>> chmod a+w /Applications/apache/htdocs/wp-php/tmp
>>>>>>>
>>>>>>
>>>>>> Also, turn on error reporting so that you can see the exact
>>>>>> problem. It
>>>>>> may not be what you think.
>>>>>>
>>>>>> --
>>>>>> Thanks!
>>>>>> -Shawn
>>>>>> http://www.spidean.com
>>>>>
>>>>>
>>>>> Thanks for the suggestions. I added the following lines to the
>>>>> very top
>>>>> of my code:
>>>>>
>>>>> error_reporting(E_ALL);
>>>>>
>>>>> mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true);
>>>>> chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w");
>>>>>
>>>>> and I also changed the line where it tries to open the file to
>>>>> write to
>>>>> to go to the new directory:
>>>>>
>>>>> $out =
>>>>> fopen("/Applications/apache/htdocs/wp-php/tmp/
>>>>> tableToCutAndPaste.txt",
>>>>> "w");
>>>>>
>>>>> Below are the errors I got:
>>>>> --- start errors ---
>>>>> Warning: mkdir() [function.mkdir]: Permission denied in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 5
>>>>>
>>>>> Warning: chmod() [function.chmod]: No such file or directory in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 6
>>>>>
>>>>> Warning:
>>>>> fopen(/Applications/apache/htdocs/wp-php/tmp/tableToCutAndPaste.txt)
>>>>> [function.fopen]: failed to open stream: No such file or directory in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 9
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 13
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 22
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 27
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 28
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 29
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 30
>>>>>
>>>>> Warning: fwrite(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 35
>>>>>
>>>>> Warning: fclose(): supplied argument is not a valid stream
>>>>> resource in
>>>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 39
>>>>> --- end errors ---
>>>>>
>>>>> The permissions are as follows (sorry I didn't think to include
>>>>> them in
>>>>> my original message):
>>>>>
>>>>> [Wed Jul 01 12:28:29] ~: ls -la /Applications/apache/htdocs/wp-php/
>>>>> total 64
>>>>> drwxr-xr-x 5 mari admin 170 Jun 29 16:47 .
>>>>> drwxr-xr-x 24 mari admin 816 Jun 29 16:47 ..
>>>>> -rw-r--r-- 1 mari admin 6148 Jun 28 21:11 .DS_Store
>>>>> -rwxr--r-- 1 mari admin 827 Jul 1 12:26 generateTable.php
>>>>> -rwxr--r-- 1 mari admin 17532 Jun 28 20:53 wp.csv
>>>>> [Wed Jul 01 12:29:01] ~:
>>>>>
>>>>> Thank you,
>>>>> Mari
>>>>
>>>> That's because the apache user doesn't have permissions to create the
>>>> dir or change the permissions. The commands I gave you need to be run
>>>> from the command line.
>>>>
>>>> --
>>>> Thanks!
>>>> -Shawn
>>>> http://www.spidean.com
>>>
>>> Oh, duh, thank you. Doing it on the command line like you said
>>> worked great. I also had to edit my .csv file in TextWrangler to
>>> change the line breaks from \r to \r\n before it would work.
>>> Although the Mac's built-in firewall is set to block incoming traffic
>>> except for network time and something installed by Adobe when I
>>> installed CS4, I was wondering about the security of this technique
>>> if done on a production server. I only run this script by pointing
>>> my browser to http://localhost/wp-php/generateTable.php and I think
>>> with my firewall settings nobody else would be able to execute this
>>> script, but it seems if the tmp folder is set to world writable on a
>>> production server that anybody might be able to somehow upload a
>>> malicious file if they knew the location of tmp. Any thoughts? Thanks!
>>>
>>> Mari
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>
Yes, it would be best to keep writable directories and files outside of
the web root.
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
Hi,
The php scripts works OK on windows 2000 server ( it supports chinese,
english & japanese - UTF-8 encoding) but it shows ??? ( non-english chars )
when copied to IIS7 + Fastcgi on windows 2008.
Is there some settings to change in php.ini ?
Regards,
Jon Lau
--- End Message ---
--- Begin Message ---
I'm looking into caching technologies.
memcache looks straight forward, but seems to lack any security, which
seems to indicate it should not be used with shared hosting where
another user could read or alter the objects.
Is there any way to at least do hostname based authentication with
memcache? I suppose that would be too easy to fake.
Any other object caching systems with better security?
Or am I completely mis-understanding memcache and this isn't an issue?
--- End Message ---
--- Begin Message ---
Michael A. Peters wrote:
I'm looking into caching technologies.
memcache looks straight forward, but seems to lack any security, which
seems to indicate it should not be used with shared hosting where
another user could read or alter the objects.
Is there any way to at least do hostname based authentication with
memcache? I suppose that would be too easy to fake.
Any other object caching systems with better security?
Or am I completely mis-understanding memcache and this isn't an issue?
Looks like APC may actually be more suited to my needs anyway (single
host, small objects), but looks like it has similar issue.
--- End Message ---
--- Begin Message ---
Hi All,
Is there any function in PHP which will provide me the details of any
timezone such as current time, DST, offset etc.
Thanks in advance,
Manoj
--- End Message ---
--- Begin Message ---
Manoj Singh wrote:
Hi All,
Is there any function in PHP which will provide me the details of any
timezone such as current time, DST, offset etc.
Thanks in advance,
Manoj
It's called date
http://php.net/manual/en/function.date.php
The manual page on the function tells you how to get all that plus other
groovy information.
--- End Message ---
--- Begin Message ---
Hello everybody,
How would I go about writing stuff to a file but in between the <?php ?>
tags?
Example, say I have config.php as follows...
<?php
$hostname = "localhost";
$database = "database";
$username = "username";
$password = "password";
?>
How would I go about adding stuff at the end of the file, but before the
?> tag?
--- End Message ---
--- Begin Message ---
2009/7/3 Jason Carson <[email protected]>:
> Hello everybody,
>
> How would I go about writing stuff to a file but in between the <?php ?>
> tags?
>
> Example, say I have config.php as follows...
>
> <?php
>
> $hostname = "localhost";
> $database = "database";
> $username = "username";
> $password = "password";
>
> ?>
>
> How would I go about adding stuff at the end of the file, but before the
> ?> tag?
Remove the ?> tag - it's not required if it's the last thing in the file.
-Stuart
--
http://stut.net/
--- End Message ---
--- Begin Message ---
The classic method is:
1.) read the whole file into an array of strings.
2.) search for the last line
3.) insert a string BEFORE the last line.
4.) write back the whole file to the same name
Classic file handling does allow you to append to the end of a file, or
recreate as a whole.
Usually these types of editing must be done in memory, because file handling
does not allow inserts, deletes.
SanTa
----- Original Message -----
From: "Jason Carson" <[email protected]>
To: <[email protected]>
Sent: Friday, July 03, 2009 12:01 PM
Subject: [PHP] Writing to a file
Hello everybody,
How would I go about writing stuff to a file but in between the <?php ?>
tags?
Example, say I have config.php as follows...
<?php
$hostname = "localhost";
$database = "database";
$username = "username";
$password = "password";
?>
How would I go about adding stuff at the end of the file, but before the
?> tag?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Jason Carson wrote:
Hello everybody,
How would I go about writing stuff to a file but in between the <?php ?>
tags?
Example, say I have config.php as follows...
<?php
$hostname = "localhost";
$database = "database";
$username = "username";
$password = "password";
?>
How would I go about adding stuff at the end of the file, but before the
?> tag?
IMHO that's kind of dangerous.
Better to have an xml file -
<config>
<dbconfig>
<hostname value="localhost" />
<database value="database" />
<username value="username" />
<password value="password" />
</dbconfig>
</config>
and read it into a DOM object via DOMDocument.
Then you can add things to the DOM
by making them children of the config node - and write the whole dom
back to file.
That way your web app does not have write permission to a file that gets
executed, and you can potentially cache the DOMDocument object in memory
so it doesn't have to read from file every page load to get your
settings (not tried that yet myself but I don't see why you couldn't).
--- End Message ---
--- Begin Message ---
Jason Carson wrote:
> How would I go about writing stuff to a file but in between the <?php ?>
> tags?
>
http://www.php.net/file_put_contents
-- Paul
http://www.paulscott.za.net/
http://twitter.com/paulscott56
http://avoir.uwc.ac.za
--- End Message ---
--- Begin Message ---
On Fri, Jul 3, 2009 at 06:01, Jason Carson<[email protected]> wrote:
> Hello everybody,
>
> How would I go about writing stuff to a file but in between the <?php ?>
> tags?
The current industry standard is a combination of text editor and
keyboard, but there are many options.
More specifically, are you trying to write to a PHP file *with*
PHP? And if so, would this be the kind of file you're trying to write
(such as creating an automated installer with auto-config)?
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig
--- End Message ---
--- Begin Message ---
2009/7/3 Sándor Tamás (HostWare Kft.) <[email protected]>:
> The classic method is:
> 1.) read the whole file into an array of strings.
> 2.) search for the last line
> 3.) insert a string BEFORE the last line.
> 4.) write back the whole file to the same name
>
> Classic file handling does allow you to append to the end of a file, or
> recreate as a whole.
> Usually these types of editing must be done in memory, because file handling
> does not allow inserts, deletes.
Please don't top-post in threads. It makes them difficult to read
for folks searching the archives.
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig
--- End Message ---
--- Begin Message ---
php 5.2.10
apc 3.0.19
With apc enabled, pear package mdb2 breaks with following error:
<b>Fatal error</b>: Class 'PEAR' not found in
<b>/usr/share/pear/MDB2/Driver/mysql.php</b> on line <b>876</b><br />
disabling apc and site works just dandy again.
; Enable apc extension module
extension = apc.so
; Options for the apc module
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=64
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.cache_by_default=1
apc.stat=0
Last one I added after seeing this:
http://pecl.php.net/bugs/bug.php?id=15356
but that's not my problem
from the apc.php -
apc.cache_by_default 1
apc.coredump_unmap 0
apc.enable_cli 1
apc.enabled 1
apc.file_update_protection 2
apc.filters
apc.gc_ttl 3600
apc.include_once_override 0
apc.max_file_size 1M
apc.mmap_file_mask /tmp/apc.BJhspx
apc.num_files_hint 1024
apc.report_autofilter 0
apc.rfc1867 0
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.shm_segments 1
apc.shm_size 64
apc.slam_defense 0
apc.stat 0
apc.stat_ctime 0
apc.ttl 7200
apc.user_entries_hint 4096
apc.user_ttl 7200
apc.write_lock 1
Any suggestions about what configuration is borking pear?
--- End Message ---
--- Begin Message ---
Michael A. Peters wrote:
php 5.2.10
apc 3.0.19
With apc enabled, pear package mdb2 breaks with following error:
<b>Fatal error</b>: Class 'PEAR' not found in
<b>/usr/share/pear/MDB2/Driver/mysql.php</b> on line <b>876</b><br />
disabling apc and site works just dandy again.
; Enable apc extension module
extension = apc.so
; Options for the apc module
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=64
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.cache_by_default=1
apc.stat=0
Changing apc.cache_by_default to 0 also fixes it, so it seems it has a
problem with how it caches pear/mdb2 stuff.
--- End Message ---
--- Begin Message ---
On Fri, Jul 3, 2009 at 07:00, Michael A. Peters<[email protected]> wrote:
>>
>> <b>Fatal error</b>: Class 'PEAR' not found in
>> <b>/usr/share/pear/MDB2/Driver/mysql.php</b> on line <b>876</b><br />
Have you installed PEAR's PEAR module? I know it sounds a bit
redundant, but see if that works for you. From the command line:
pear install PEAR
If it tells you that it's already on there, or if it installs but
does not fix your problem, the next step is making sure that the
include path contains the path to your PEAR files. If not, the class
fails because the inclusion fails (and without looking at the source
of the MySQL driver in the MDB2 package, my guess is that it's
__autoload()'d rather than explicitly included, hence no message about
a missing file).
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig
--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Fri, Jul 3, 2009 at 07:00, Michael A. Peters<[email protected]> wrote:
<b>Fatal error</b>: Class 'PEAR' not found in
<b>/usr/share/pear/MDB2/Driver/mysql.php</b> on line <b>876</b><br />
Have you installed PEAR's PEAR module? I know it sounds a bit
redundant, but see if that works for you. From the command line:
pear install PEAR
If it tells you that it's already on there, or if it installs but
does not fix your problem, the next step is making sure that the
include path contains the path to your PEAR files. If not, the class
fails because the inclusion fails (and without looking at the source
of the MySQL driver in the MDB2 package, my guess is that it's
__autoload()'d rather than explicitly included, hence no message about
a missing file).
Yes, pear is installed
[mpet...@athens ~]$ pear info PEAR
About pear.php.net/PEAR-1.8.1
=============================
Release Type PEAR-style PHP-based Package
Name PEAR
Channel pear.php.net
Summary PEAR Base System
Description The PEAR package contains:
etc.
It works beautifully as long as apc.cache_by_default=0
I really only need it to cache DB queries and xml fragments.
Caching includes (I assume what it is trying to do) would be nice but
not if it does so in a broken manner.
--- End Message ---
--- Begin Message ---
13 RCVD_IN_JMF_BL RBL: Sender listed in JMF-BLACK
[216.92.131.4 listed in hostkarma.junkemailfilter.com]
truns up in my spamc test.
Please fix!
--
Member - Liberal International This is [email protected]
Ici [email protected] God, Queen and country! Beware Anti-Christ rising!
Never Satan President Republic!
The fool says in his heart, "There is no God". They are corrupt, and their ways
are vile; there is no one who does good. - Ps 53:1
--- End Message ---
--- Begin Message ---
On Fri, Jul 3, 2009 at 10:52, The Doctor<[email protected]> wrote:
> 13 RCVD_IN_JMF_BL RBL: Sender listed in JMF-BLACK
> [216.92.131.4 listed in hostkarma.junkemailfilter.com]
>
> truns up in my spamc test.
>
> Please fix!
I've processed the removal from their erroneous blacklist, but in
the future, please report things such as this to [email protected], as
the traffic on each individual list usually overshadows such reports.
Thanks, Doc.
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig
--- End Message ---