php-general Digest 10 Apr 2005 14:08:57 -0000 Issue 3389

Topics (messages 212749 through 212761):

Re: [PHP-INSTALL] Install Problems on Fedora 3
        212749 by: Mark Sargent
        212759 by: John Nichel
        212761 by: Mark Sargent

Re: Problem with ob_get_contents()
        212750 by: Skrol 29
        212754 by: Prathaban Mookiah

Re: Installation Warning?
        212751 by: Andy Pieters

Re: Session gets corrupted (or lost)
        212752 by: Burhan Khalid

Question about fsockopen
        212753 by: php.warningnews.com
        212757 by: Josip Dzolonga

Re: Viewing a specific item within a php web-page?
        212755 by: Prathaban Mookiah
        212756 by: Josip Dzolonga
        212758 by: Prathaban Mookiah

Limiting Cpu usage
        212760 by: zini10

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 ---
John Nichel wrote:

Mark Sargent wrote:
<snip>

http://www.php.net/manual/en/install.unix.php

it has 2 examples,

4-1 and 4-2. Little confused with what shared and static modules are and
which 1 pertains to me. I was wanting to get php running to allow base
to show results of snort logging in mysql. Snort/Mysql/Base etc are
installed fine, just php is the last hurdle. Again, sorry. Cheers.


When you installed php, did you install it the same time as Apache (--with-apache=../apache-1.3.x) or was Apache already installed (--with-apxs=/path/to/apxs)?

Hi All,

okay, I need to ask this "dumb"(?) question. What is the difference
between httpd, already installed and Apache..? I thought they were the
same. If they are, and I'm using the default version, from install, I
just add those lines to the .conf file, yes..? Again, I do truly
apologize for what may seem mundane questions. Cheers.

Mark Sargent.
--- End Message ---
--- Begin Message --- Mark Sargent wrote:
John Nichel wrote:

Mark Sargent wrote:
<snip>

http://www.php.net/manual/en/install.unix.php

it has 2 examples,

4-1 and 4-2. Little confused with what shared and static modules are and
which 1 pertains to me. I was wanting to get php running to allow base
to show results of snort logging in mysql. Snort/Mysql/Base etc are
installed fine, just php is the last hurdle. Again, sorry. Cheers.



When you installed php, did you install it the same time as Apache (--with-apache=../apache-1.3.x) or was Apache already installed (--with-apxs=/path/to/apxs)?


Hi All,

okay, I need to ask this "dumb"(?) question. What is the difference
between httpd, already installed and Apache..? I thought they were the
same. If they are, and I'm using the default version, from install, I
just add those lines to the .conf file, yes..? Again, I do truly
apologize for what may seem mundane questions. Cheers.

As far as the functionality of PHP, there really is no difference in the installs. A big advantage to installing PHP as a DSO (--with-apxs) vs. a static module (--with-apache) is when it comes time to re-install PHP (because you need to add a third party library to it, a new version is out, etc.). As a static module, you would have to re-configure/compile/install both PHP and Apache, whereas a DSO, you only need to redo PHP.


In both cases, the solution to your problem is probably adding this to your Apache's config file (httpd.conf), and restarting Apache...

AddType application/x-httpd-php .php

--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
John Nichel wrote:

Mark Sargent wrote:

John Nichel wrote:

Mark Sargent wrote:
<snip>

http://www.php.net/manual/en/install.unix.php

it has 2 examples,

4-1 and 4-2. Little confused with what shared and static modules are and
which 1 pertains to me. I was wanting to get php running to allow base
to show results of snort logging in mysql. Snort/Mysql/Base etc are
installed fine, just php is the last hurdle. Again, sorry. Cheers.




When you installed php, did you install it the same time as Apache (--with-apache=../apache-1.3.x) or was Apache already installed (--with-apxs=/path/to/apxs)?

Hi All,

okay, I need to ask this "dumb"(?) question. What is the difference
between httpd, already installed and Apache..? I thought they were the
same. If they are, and I'm using the default version, from install, I
just add those lines to the .conf file, yes..? Again, I do truly
apologize for what may seem mundane questions. Cheers.


As far as the functionality of PHP, there really is no difference in the installs. A big advantage to installing PHP as a DSO (--with-apxs) vs. a static module (--with-apache) is when it comes time to re-install PHP (because you need to add a third party library to it, a new version is out, etc.). As a static module, you would have to re-configure/compile/install both PHP and Apache, whereas a DSO, you only need to redo PHP.

In both cases, the solution to your problem is probably adding this to your Apache's config file (httpd.conf), and restarting Apache...

AddType application/x-httpd-php .php

Hi All,

thanx, John. I added that via vi and restarted with,
/etc/rc.d/init.d/httpd restart
but, still get the core php code showing in the browser when going to localhost/index.php. Should I just remove both httpd/php and reinstall both from source with support..? Cheers.


P.S. This is not a production machine. I'm just learning all of it and then when confident, will set up a real system. Cheers, again.

Mark Sargent
--- End Message ---
--- Begin Message ---
Hi,

I've tested your code on PHP 4.3.3 and I have the same behavior has yours.

"Hello" is output at the end of the PhpInfo data, followed by a PHP notice :
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete. in ...
And there is an empty "logfile" file created in the Apache directory insteaf of the script's directory.


If you change in your script:
***********
register_shutdown_function("hello");
echo ("HELLO <br>");
die();
***********
by
***********
// register_shutdown_function("hello");
echo ("HELLO <br>");
hello()
die();
***********
then it runs as expected and the "logfile" file is created in the script's directory.


It seems that when calling the shutdown function, all the buffered output is immedialty sent to the client and the buffer mode is closed.
You maybe have PHP bug here, or the manual is wrong about the possibility to retrieve the contents.
But we can notice that this also happens at the end of a script when there is no shutdown function.


-------------------
Skrol29
www.tinybutstrong.com
-------------------

"Prathaban Mookiah" <[EMAIL PROTECTED]> a Ãcrit dans le message de news: [EMAIL PROTECTED]
Hello,

I've posted a miniature version of my code here to explain my problem.

<CODE>

<?
phpinfo();

ob_start();

register_shutdown_function("hello");

echo ("HELLO");

die();

function hello()
{

$logfile = "logfile";

$error_string = ob_get_contents();

if(!$handle = fopen($logfile, "a"))
{
       echo("Could not open logfile for writing!");
       ob_end_flush();
       exit;
}

if(fwrite($handle, $error_string) === FALSE)
{
       echo("Could not write to logfile!");
       ob_end_flush();
       exit;
}

fclose($handle);

ob_end_clean();

}

?>

</CODE>

This simply does not work the way it should. i.e ob_get_contents doen't return
any string and the buffer just gets flushed by itself at termination.


Though the PHP manual says it is not possible to retrieve the contents of any
output buffers using ob_get_contents() with PHP < 4.0.6. But I am using PHP 5.
x.x


Thanks in advance for any help.

Prathap

--- End Message ---
--- Begin Message ---
Thanks Skrol for your reply.

But the problem is, the shutdown function will have to be executed from a lot 
of points whenever something goes wrong and I guess calling hello() everywhere 
manually is not elegant.

Maybe it should be reported to PHP bugs.

Prathap

---------- Original Message -----------
From: "Skrol 29" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Sun, 10 Apr 2005 07:27:38 +0200
Subject: [PHP] Re: Problem with ob_get_contents()

> Hi,
> 
> I've tested your code on PHP 4.3.3 and I have the same behavior has yours.
> 
> "Hello" is output at the end of the PhpInfo data, followed by a PHP 
> notice :   Notice: ob_end_clean(): failed to delete buffer. No 
> buffer to delete. in ... And there is an empty "logfile" file 
> created in the Apache directory insteaf of the script's directory.
> 
> If you change in your script:
> ***********
>   register_shutdown_function("hello");
>   echo ("HELLO <br>");
>   die();
> ***********
> by
> ***********
>   // register_shutdown_function("hello");
>   echo ("HELLO <br>");
>   hello()
>   die();
> ***********
> then it runs as expected and the "logfile" file is created in the 
> script's directory.
> 
> It seems that when calling the shutdown function, all the buffered 
> output is immedialty sent to the client and the buffer mode is 
> closed. You maybe have PHP bug here, or the manual is wrong about 
> the possibility to retrieve the contents. But we can notice that 
> this also happens at the end of a script when there is no shutdown function.
> 
> -------------------
> Skrol29
> www.tinybutstrong.com
> -------------------
> 
> "Prathaban Mookiah" <[EMAIL PROTECTED]> a Ãcrit dans le message 
> de news: [EMAIL PROTECTED]
> > Hello,
> >
> > I've posted a miniature version of my code here to explain my problem.
> >
> > <CODE>
> >
> > <?
> > phpinfo();
> >
> > ob_start();
> >
> > register_shutdown_function("hello");
> >
> > echo ("HELLO");
> >
> > die();
> >
> > function hello()
> > {
> >
> > $logfile = "logfile";
> >
> > $error_string = ob_get_contents();
> >
> > if(!$handle = fopen($logfile, "a"))
> > {
> >        echo("Could not open logfile for writing!");
> >        ob_end_flush();
> >        exit;
> > }
> >
> > if(fwrite($handle, $error_string) === FALSE)
> > {
> >        echo("Could not write to logfile!");
> >        ob_end_flush();
> >        exit;
> > }
> >
> > fclose($handle);
> >
> > ob_end_clean();
> >
> > }
> >
> > ?>
> >
> > </CODE>
> >
> > This simply does not work the way it should. i.e ob_get_contents doen't 
> > return
> > any string and the buffer just gets flushed by itself at termination.
> >
> > Though the PHP manual says it is not possible to retrieve the contents of 
> > any
> > output buffers using ob_get_contents() with PHP < 4.0.6. But I am using 
> > PHP 5.
> > x.x
> >
> > Thanks in advance for any help.
> >
> > Prathap
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
------- End of Original Message -------

--- End Message ---
--- Begin Message ---
On Friday 08 April 2005 20:27, [EMAIL PROTECTED] wrote:
>
> Anyone have any ideas on why it is suggesting NOT to use php and Apache
> 2.0.x in a production environment? I'm planning on developing several large
> apps for my company and expect 300-400 people to be hitting it throughout
> the business day.
>
Off course I know of tons and tons of sites out there that have Linux + 
Apache2 + MySql + Php > 4

And the're running just fine, day after day after day.

It is a calculated risk we made and haven't regreted it since.  

Andy

-- 
Registered Linux User Number 379093
-- ---BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT/O/CM d- s:+ a- C++++ UL++++ P+ L+++ E--- W+++ N++ o+ K w--- O+++ M- V
PS+ PE++ Y+ PGP+++ t+ 5-- X R !tv b DI+++ D++ G e-- h+ r--- y+
-- ---END GEEK CODE BLOCK------

Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

--- End Message ---
--- Begin Message --- Marcelo Volmaro wrote:
Hi,
IÂve made a simple site with a loguin, that in my machine works perfectly, but not on the server.
The problem seems to be on the session handling. I donÂt loose the SID, but the session gets corrupted.
If I do a print_r($_SESSION), after the loguin i get the correct vars, but after i click on a link, while the session ID is
still the same (i pass it both in the URL and using cookies) the print_r returns something like the following:
__PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => user [ID] => 30 [nick] => ....

Your class is not in scope on the second page. For your objects to have relevance in the session, make sure the class definition is included in each file that references the object in the session.

--- End Message ---
--- Begin Message ---
Dear list,

I have several IP in one interface (eth0) in my server and I want make
connection to another server (check email, etc) using different ip for
every mail server. I was read the document, and there is no way how to
make this happen. Any idea?


Thank you

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:

Dear list,

I have several IP in one interface (eth0) in my server and I want make
connection to another server (check email, etc) using different ip for
every mail server. I was read the document, and there is no way how to
make this happen. Any idea?


Thank you



Take a look here : http://sourceforge.net/projects/snoopy/ , I'm not much sure but I think that it has that feature.

--
Josip Dzolonga
http://josip.dotgeek.org

jdzolonga[at]gmail.com
--- End Message ---
--- Begin Message ---
I think you have totally got it wrong. You pass on the value to a php script 
in the form on http://   /script.php?variable=value.

So to accomplish your need you may have to do something like call http://   
/script.php?articleid=post_040905.

Your program should be modified to maybe something like:

<?

$post_041005 = "article for April 10th 2005";
$post_040905 = "text for April 9th 2005";

switch ($_HTTP_GET_VARS['articleid'])
{
   case "post_041005": print($post_041005);
                       break;
   case "post_040905": print($post_040905);
                       break;
   default: echo "No articleid specified"
}

If you still want to call it in the form domain.com/articles.php?post_040905, 
then you may do something like this:

$post_041005 = "article for April 10th 2005";
if isset($_HTTP_GET_VARS['post_041005'])
    print($post_041005);

$post_040905 = "text for April 9th 2005";
if isset($_HTTP_GET_VARS['post_040905'])
    print($post_post_040905);

?>

There are more efficient ways to do it, but this should get the job done.

Prathap

---------- Original Message -----------
From: "Carlos Palomino" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sat, 9 Apr 2005 21:23:06 -0400
Subject: [PHP] Viewing a specific item within a php web-page?

> I have a document entitled: articles.php
> Within this document, I want to store various written articles which 
> are headed by a string value - example:
> 
> $post_040905 = "text for April 9th 2005";
> print($post_040905);
> $post_041005 = "article for April 10th 2005";
> print($post_041005);
> 
> How can I view a specific string's text via the browser?  I thought 
> I could use domain.com/articles.php?post_040905  and only the 
> content written for that post would be shown.  However, all of the 
> posts are shown. I just began reading about PHP from limited 
> tutorials so I am at a loss as to how I can accomplish this.  I 
> would appreciate all assistance in this matter.
> 
> Best Regards,
> 
> Carlos
------- End of Original Message -------

--- End Message ---
--- Begin Message ---
Carlos Palomino wrote:

I have a document entitled: articles.php
Within this document, I want to store various written articles which are headed by a string value - example:


$post_040905 = "text for April 9th 2005";
print($post_040905);
$post_041005 = "article for April 10th 2005";
print($post_041005);

That's a _really_ bad idea. It is better to store all of them in a database (MySQL is a simple one and works perfectly with PHP) ordered by an id. So the script can take a numerical argument ID which will hold the ID of the text which shall be shown. The argument can be passed as a GET variable (script.php?variable=value&second=second_value) and you can get it with $_GET['variable_name']. Take a better look here http://www.php.net/manual/en/reserved.variables.php#reserved.variables.get . However don't forget to filter than input argument first, to prevent SQL Injections :

$id = $_GET['id'];
if($id == strval(intval($id))) { /* Okay, do the query */ }
else die('Looser !');

Hope this helps,

--
Josip Dzolonga
http://josip.dotgeek.org

jdzolonga[at]gmail.com
--- End Message ---
--- Begin Message ---
I guess I had some 'spelling mistakes' in my suggested code.

Try the one below. It should be $HTTP_GET_VARS not $_HTTP_GET_VARS.

<?

 $post_041005 = "article for April 10th 2005";
 $post_040905 = "text for April 9th 2005";

 switch ($HTTP_GET_VARS['articleid'])
 {
    case "post_041005": print($post_041005);
                        break;
    case "post_040905": print($post_040905);
                        break;
    default: echo "No article was specified.";
 }

?>

And you can name the script in any way you want to. It need not be script.php. 
Say if you put this code into a script call getarticle.php, you should call it 
as youdomain/getarticle.php?articleid=post_xxxxx where xxxx is the appropriate 
article number.

As someone else suggested, putting them into a database is the best way to do 
it. But since I guess you are a beginner you might as well keep it very simple 
like this for the time being. But ultimately you should consider databases.

Cheers,

Prathap

---------- Original Message -----------
From: "Carlos Palomino" <[EMAIL PROTECTED]>
To: "Prathaban Mookiah" <[EMAIL PROTECTED]>
Sent: Sun, 10 Apr 2005 06:09:53 -0400
Subject: Re: [PHP] Viewing a specific item within a php web-page?

> Hi,
> 
> I tried the following but can not view the specified article but 
> receive the default message when attempting to view either of the 
> posts.  I used the proper URL as suggested 
> (script.php?read=post_041005).
> 
> $post_041005 = "article for April 10th 2005";
> $post_040905 = "text for April 9th 2005";
> switch ($_HTTP_GET_VARS['read'])
> {
>    case "post_041005": print($post_041005);
>                        break;
>    case "post_040905": print($post_040905);
>                        break;
>    default: echo "No article was specified.";
> }
> 
> Any ideas on why I am receiving only the default message even though 
> I go to the proper article URL?
> 
> Best Wishes,
> 
> Carlos
>   ----- Original Message ----- 
>   From: Prathaban Mookiah
>   To: [email protected]
>   Sent: Sunday, April 10, 2005 4:23 AM
>   Subject: Re: [PHP] Viewing a specific item within a php web-page?
> 
>   I think you have totally got it wrong. You pass on the value to a 
> php script  in the form on http://   /script.php?variable=value.
> 
>   So to accomplish your need you may have to do something like call http://
>   /script.php?articleid=post_040905.
> 
>   Your program should be modified to maybe something like:
> 
>   <?
> 
>   $post_041005 = "article for April 10th 2005";
>   $post_040905 = "text for April 9th 2005";
> 
>   switch ($_HTTP_GET_VARS['articleid'])
>   {
>      case "post_041005": print($post_041005);
>                          break;
>      case "post_040905": print($post_040905);
>                          break;
>      default: echo "No articleid specified"
>   }
> 
>   If you still want to call it in the form 
> domain.com/articles.php?post_040905,  then you may do something like 
> this:
> 
>   $post_041005 = "article for April 10th 2005";
>   if isset($_HTTP_GET_VARS['post_041005'])
>       print($post_041005);
> 
>   $post_040905 = "text for April 9th 2005";
>   if isset($_HTTP_GET_VARS['post_040905'])
>       print($post_post_040905);
> 
>   ?>
> 
>   There are more efficient ways to do it, but this should get the 
> job done.
> 
>   Prathap
> 
>   ---------- Original Message -----------
>   From: "Carlos Palomino" <[EMAIL PROTECTED]>
>   To: <[email protected]>
>   Sent: Sat, 9 Apr 2005 21:23:06 -0400
>   Subject: [PHP] Viewing a specific item within a php web-page?
> 
>   > I have a document entitled: articles.php
>   > Within this document, I want to store various written articles which
>   > are headed by a string value - example:
>   >
>   > $post_040905 = "text for April 9th 2005";
>   > print($post_040905);
>   > $post_041005 = "article for April 10th 2005";
>   > print($post_041005);
>   >
>   > How can I view a specific string's text via the browser?  I thought
>   > I could use domain.com/articles.php?post_040905  and only the
>   > content written for that post would be shown.  However, all of 
> the  > posts are shown. I just began reading about PHP from limited  
> > tutorials so I am at a loss as to how I can accomplish this.  I  > 
> would appreciate all assistance in this matter.  >  > Best Regards,  
> >  > Carlos
>   ------- End of Original Message -------
> 
>   -- 
>   PHP General Mailing List (http://www.php.net/)
>   To unsubscribe, visit: http://www.php.net/unsub.php
------- End of Original Message -------

--- End Message ---
--- Begin Message ---
hello, how can i limit cpu usage for shared hosting enviroment?
i mean , im hosting serveal sites and wish for all php scripts to have (for 
example) no more than 5% of cpu usage so no one can bomb my server.
im currently using php as a module , i know i can do it if ill use php as a 
cgi and limit apache with cpu usage , but wont it decrease dramtically my 
preformance?

thanks. 

--- End Message ---

Reply via email to