php-general Digest 29 Mar 2011 17:06:12 -0000 Issue 7249
Topics (messages 312112 through 312122):
Re: xinetd vs php socket server
312112 by: Bostjan Skufca
312116 by: Curtis Maurand
312119 by: Nathan Nobbe
Resizing an image
312113 by: Andre Polykanine
312115 by: Donovan Brooke
Path question
312114 by: Jack
312121 by: Paul M Foster
312122 by: Al
Re: Permission Denied - Help Requested
312117 by: Ethan Rosenberg
312118 by: Adam Richardson
312120 by: Ethan Rosenberg
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
"It works pretty well until its under attack by the spammers."
Can you elaborate/explain further?
b.
On 29 March 2011 01:14, Curtis Maurand <cur...@maurand.com> wrote:
>
>
> Nathan Nobbe wrote:
> > On Mon, Mar 28, 2011 at 3:34 PM, Bostjan Skufca <bost...@a2o.si> wrote:
> >
> >> If you need high performance you probably already know that it will be
> >> very
> >> expensive CPU wise if workers are spawned on each request. If you don't,
> >> I
> >> would not bother with daemon and just use xinetd. You can always add
> >> daemon-handling stuff later on.
> >>
> >> Well I do hope you find a good working solution with as little
> >> inconvenience as possible,
> >> b.
> >
> >
> > hmm, wouldn't both the solutions most likely be forking? php daemon would
> > fork since threading isn't supported, and xinetd, probly best to have it
> > fork for the same reason apache is typically configured to fork. right?
>
> Speak for yourself. I've always configured my systems to thread. Since
> IBM rewrote the threading library several years back (NPTL), Theading
> works. I use the threading version of apache and threading is enabled in
> PHP.
>
> It works pretty well until its under attack by the spammers.
>
> --Curtis
--- End Message ---
--- Begin Message ---
I have a machine with several websites one of which is quite busy
this time of year. I have another that had its joomla comments on
and open and the spammers found it. They managed to get 700,000
comments into the system before we caught it, but the traffic and strain
on the MySQL server and the webserver (PHP) while it was going on brought
the server to its knees. I've put some iptables rules in to block
the attacks and things are back to normal.
The server (A vmware
VM w/ 2 CPU and 2 GB of RAM) never crashed, but it certainly was on its
knees. The distribution is Gentoo 10.1.
My only other
problem is PHP hanging on MySQL returning an emtpy set.(mysql_num_rows =
0). That 's a whole other issue and off of this topic.
--C
Bostjan Skufca wrote:
> "It works pretty
well until its under attack by the spammers."
>
>
Can you elaborate/explain further?
>
> b.
>
>
> On 29 March 2011 01:14, Curtis Maurand
<cur...@maurand.com> wrote:
>
>>
>>
>> Nathan Nobbe wrote:
>> > On Mon,
Mar 28, 2011 at 3:34 PM, Bostjan Skufca <bost...@a2o.si>
>> wrote:
>> >
>> >> If you need
high performance you probably already know that it will
>>
be
>> >> very
>> >> expensive CPU wise
if workers are spawned on each request. If you
>> don't,
>> >> I
>> >> would not bother with daemon
and just use xinetd. You can always add
>> >>
daemon-handling stuff later on.
>> >>
>>
>> Well I do hope you find a good working solution with as little
>> >> inconvenience as possible,
>> >>
b.
>> >
>> >
>> > hmm, wouldn't
both the solutions most likely be forking? php daemon
>>
would
>> > fork since threading isn't supported, and xinetd,
probly best to have
>> it
>> > fork for the same
reason apache is typically configured to fork.
>> right?
>>
>> Speak for yourself. I've always configured my
systems to thread. Since
>> IBM rewrote the threading library
several years back (NPTL), Theading
>> works. I use the
threading version of apache and threading is enabled
>> in
>> PHP.
>>
>> It works pretty well until its
under attack by the spammers.
>>
>> --Curtis
>
--- End Message ---
--- Begin Message ---
On Mon, Mar 28, 2011 at 5:14 PM, Curtis Maurand <cur...@maurand.com> wrote:
>
>
> Nathan Nobbe wrote:
> > On Mon, Mar 28, 2011 at 3:34 PM, Bostjan Skufca <bost...@a2o.si> wrote:
> >
> >> If you need high performance you probably already know that it will be
> >> very
> >> expensive CPU wise if workers are spawned on each request. If you don't,
> >> I
> >> would not bother with daemon and just use xinetd. You can always add
> >> daemon-handling stuff later on.
> >>
> >> Well I do hope you find a good working solution with as little
> >> inconvenience as possible,
> >> b.
> >
> >
> > hmm, wouldn't both the solutions most likely be forking? php daemon would
> > fork since threading isn't supported, and xinetd, probly best to have it
> > fork for the same reason apache is typically configured to fork. right?
>
> Speak for yourself. I've always configured my systems to thread. Since
> IBM rewrote the threading library several years back (NPTL), Theading
> works. I use the threading version of apache and threading is enabled in
> PHP.
>
It would be nice to have a list of extensions which were known to not be
thread safe. then one could take more comfort at the prospect of a threaded
environment.
-nathan
--- End Message ---
--- Begin Message ---
Hi everyone,
Image processing is a part of Php language completely unknown to me
:-(.
So there is my task: I need to process an uploaded image. We allow
uploading of gif, jpeg, and png images. If an image is wider than
600px, it should be proportionally resized to the width of 600px.
Yes, I've just read about ImageCopyResampled().
My questions are:
1. what are the restrictions of ImageCopyResampled()? Can I make a jpg
image from a jpg one, and a png image from a png one? And what about
gif's?
2. I don't need to output the image as the script output, I need to
upload it as a file (replacing the uploaded larger file). Could I make
it with fwrite and then copy it to the server? All of the examples give
header("image/jpeg")...
Thanks!
--
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion
--- End Message ---
--- Begin Message ---
Andre Polykanine wrote:
Hi everyone,
Image processing is a part of Php language completely unknown to me
:-(.
So there is my task: I need to process an uploaded image. We allow
uploading of gif, jpeg, and png images. If an image is wider than
600px, it should be proportionally resized to the width of 600px.
Yes, I've just read about ImageCopyResampled().
My questions are:
1. what are the restrictions of ImageCopyResampled()? Can I make a jpg
image from a jpg one, and a png image from a png one? And what about
gif's?
2. I don't need to output the image as the script output, I need to
upload it as a file (replacing the uploaded larger file). Could I make
it with fwrite and then copy it to the server? All of the examples give
header("image/jpeg")...
Thanks!
Hi Andre,
http://www.imagemagick.org/script/index.php
http://us.php.net/manual/en/refs.utilspec.image.php
Donovan
--
D Brooke
--- End Message ---
--- Begin Message ---
Hello All,
Is there a smarter way to do includes by setting up a path or something
where I don't have to include /home/domain.com/includes/include_file.php
Apparently my path is as shown above, but I would prefer to just put in
/includes/include_file.php
Thanks!
Jack
--- End Message ---
--- Begin Message ---
On Mon, Mar 28, 2011 at 09:18:39PM -0400, Jack wrote:
> Hello All,
>
>
>
> Is there a smarter way to do includes by setting up a path or something
> where I don't have to include /home/domain.com/includes/include_file.php
>
> Apparently my path is as shown above, but I would prefer to just put in
> /includes/include_file.php
>
As a first action, in whatever file you first include or call, do the
following:
$site_path = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
define ('SITE_PATH', $site_path);
Next, create a function like:
function include_path($filename)
{
$str = SITE_PATH . 'include' . DIRECTORY_SEPARATOR . $filename;
return $str;
}
Now, when you want to include a file, do
include(include_path('something.php'));
In my projects, I have a variety of directories, like libraries, views,
models, etc. So the function I use has a second parameter:
include(fullpath('model', 'pizza.php'));
include(fullpath('include', 'gesundheit.php'));
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--- End Message ---
--- Begin Message ---
On 3/28/2011 9:18 PM, Jack wrote:
Hello All,
Is there a smarter way to do includes by setting up a path or something
where I don't have to include /home/domain.com/includes/include_file.php
Apparently my path is as shown above, but I would prefer to just put in
/includes/include_file.php
Thanks!
Jack
Here's how I do it. For every application, I have a config file with all my
common assignments, including common paths, e.g.,
define('EDITPAGE_ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/editPageSR/');
define('EDITPAGE_IMAGES_DIR', EDITPAGE_ROOT_DIR . 'images/');
define('EDITPAGE_DATA_DIR', PAGE_ROOT_DIR . '/editPageFiles/');
So, in your case, I'd have
define('INCLUDE_FILE', $_SERVER['DOCUMENT_ROOT'] . "/includes
/include_file.php");
So all I need is to use INCLUDE_FILE
--- End Message ---
--- Begin Message ---
At 01:32 AM 3/28/2011, Hans Ã
hlin wrote:
Do you have SELinux installed?
2011/3/28 Ethan Rosenberg <eth...@earthlink.net>:
> Dear List -
>
> Thanks for all your help in the past. Â Here is another one...
>
> I am getting a Permission Denied" message
when I try to run a PHP script. Â I
> just changed the mode on the directory and the files to 777. Â This problem
> arose when I changed the permissions. Â I thought I was solving a problem,
> because I could not open a file for writing. Â I was not receiving error
> messages, but no file was created.
>
> Help and advice, please.
>
> Ethan Rosenberg
>
>
>
**********************************************
 Hans Ã
hlin
  Tel: +46761488019
  icq: 275232967
  http://www.kronan-net.com/
  irc://irc.freenode.net:6667 - TheCoin
**********************************************
Hans -
Sorry, I did not include my signature, which
includes all the requested information.
Here it is....
Ethan
==========
MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
The problem persists. I cannot write to a file from PHP.
Any more suggestions?
Thanks.
Ethan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
--- End Message ---
--- Begin Message ---
On Mon, Mar 28, 2011 at 11:03 PM, Ethan Rosenberg <eth...@earthlink.net>wrote:
> At 01:32 AM 3/28/2011, Hans Ã…hlin wrote:
>
>> Do you have SELinux installed?
>>
>> 2011/3/28 Ethan Rosenberg <eth...@earthlink.net>:
>> > Dear List -
>> >
>> > Thanks for all your help in the past. Â Here is another one...
>> >
>> > I am getting a Permission Denied" message when I try to run a PHP
>> script. Â I
>> > just changed the mode on the directory and the files to 777. Â This
>> problem
>> > arose when I changed the permissions. Â I thought I was solving a
>> problem,
>> > because I could not open a file for writing. Â I was not receiving error
>> > messages, but no file was created.
>> >
>> > Help and advice, please.
>> >
>> > Ethan Rosenberg
>> >
>> >
>> >
>> **********************************************
>> Â Hans Ã…hlin
>> Â Â Tel: +46761488019
>> Â Â icq: 275232967
>> Â Â http://www.kronan-net.com/
>> Â Â irc://irc.freenode.net:6667 - TheCoin
>> **********************************************
>>
>
> Hans -
>
> Sorry, I did not include my signature, which includes all the requested
> information.
>
> Here it is....
>
> Ethan
> ==========
> MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
>
>
> The problem persists. I cannot write to a file from PHP.
>
> Any more suggestions?
>
> Thanks.
>
> Ethan
>
Hi Ethan,
Are you using suPHP or suExec? I believe the server chokes on 777
permissions in those cases.
Have you checked the permissions in the command line (sorry for the basic
question, but just making sure I know what you've already done?)
Also, can we see some of the code you're using to handle the file
processing?
Thanks,
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
At 11:14 PM 3/28/2011, Adam Richardson wrote:
On Mon, Mar 28, 2011 at 11:03 PM, Ethan
Rosenberg <<mailto:eth...@earthlink.net>eth...@earthlink.net> wrote:
At 01:32 AM 3/28/2011, Hans Ã
hlin wrote:
Do you have SELinux installed?
2011/3/28 Ethan Rosenberg <<mailto:eth...@earthlink.net>eth...@earthlink.net>:
> Dear List -
>
> Thanks for all your help in the past. Â Here is another one...
>
> I am getting a Permission Denied" message
when I try to run a PHP script. Â I
> just changed the mode on the directory and the files to 777. Â This problem
> arose when I changed the permissions. Â I thought I was solving a problem,
> because I could not open a file for writing. Â I was not receiving error
> messages, but no file was created.
>
> Help and advice, please.
>
> Ethan Rosenberg
>
>
>
**********************************************
 Hans Ã
hlin
  Tel: +46761488019
  icq: 275232967
  <http://www.kronan-net.com/>http://www.kronan-net.com/
  irc://<http://irc.freenode.net:6667>irc.freenode.net:6667 - TheCoin
**********************************************
Hans -
Sorry, I did not include my signature, which
includes all the requested information.
Here it is....
Ethan
==========
MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
The problem persists. I cannot write to a file from PHP.
Any more suggestions?
Thanks.
Ethan
Hi Ethan,
Are you using suPHP or suExec? I believe the
server chokes on 777 permissions in those cases.
Have you checked the permissions in the command
line (sorry for the basic question, but just
making sure I know what you've already done?)
Also, can we see some of the code you're using to handle the file processing?
Thanks,
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
<http://nephtaliproject.com>http://nephtaliproject.com
+++++++++
Adam -
Thanks.
1] Pardon my ignorance but I do not understand
this - Are you using suPHP or suExec?
2] I changed the permissions to 755 and the
"Permission Denied" message went away.
3] Have you checked the permissions in the command line? Yes
4] Here are some code snippets:
$fptr1 = fopen("chessboard", "r+"); //this works
$fptr2 = fopen('chessboard', 'w'); //this deletes the file, as it should
for($i = 0; $i <8; $i++)
{
for ($j = 0; $j < 8; $j++)
fprinf($fptr2, "%s ", $results[$i][$j]);
fprinf($fptr2, "\n");
} //this never writes, so I am left with an empty file
// I tried the following two code blocks, and the
output files were never created.
$number = 123;
$file = fopen("test.txt","w");
fprintf($file,"%f",$number);
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);
Ethan
--- End Message ---