php-general Digest 5 Oct 2005 21:16:40 -0000 Issue 3721

Topics (messages 223638 through 223664):

query regerding copying files using php
        223638 by: Suresh Pandian
        223643 by: Jochem Maas

Re: Session object destruction failed
        223639 by: Dan Rossi
        223640 by: Dan Rossi
        223644 by: Dan Rossi

Re: php.ini & magic quotes
        223641 by: Jochem Maas

Re: possibly buffer problem, including a bit of code this time
        223642 by: Jochem Maas

Global unavailable?
        223645 by: Marcus Bointon
        223647 by: Jochem Maas
        223649 by: Marcus Bointon
        223650 by: Jochem Maas

is_subclass_of() weird behaviour with APC
        223646 by: ogrange.gmail.com
        223648 by: Jochem Maas
        223662 by: ogrange.gmail.com

Re: Handling competing edits in a wiki engine?
        223651 by: Skippy
        223658 by: Niels Ganser
        223659 by: Jochem Maas

caching parsed XML files as DOM objects in memory
        223652 by: Petr Smith

Php is not writing errors in logfile
        223653 by: Jacob Friis Saxberg
        223654 by: Skippy
        223655 by: Jacob Friis Saxberg
        223656 by: Jacob Friis Saxberg
        223657 by: Jacob Friis Saxberg

sessions
        223660 by: blackwater dev
        223661 by: Jochem Maas

Possible bug in array_diff() php v4.4.0 or at least some odd behavior
        223663 by: Edward Vermillion

Scripts not working outside of Zend Studio
        223664 by: Steve Harp

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
hello friends,
 
i have a query in writng  the content of one file to another.
i attempted it.
it only writes the html codings.it could not write the php scripts inside the 
file.
 
i use the following code to accomplish my problem...
 
##############################################################
 
if (!defined('T_ML_COMMENT')) {
   define('T_ML_COMMENT', T_COMMENT);
} else {
   define('T_DOC_COMMENT', T_ML_COMMENT);
}
$source = file_get_contents('-.php');
$tokens = token_get_all($source);
foreach ($tokens as $token) {
   if (is_string($token)) {
       // simple 1-character token
       $ourFileName = "/home/itempla1/public_html/links/".$pwd.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
      echo $token;
       fwrite($ourFileHandle, $token);
fclose($ourFileHandle);
   } else {
       // token array
       list($id, $text) = $token;
       switch ($id) {
           case T_COMMENT:
           case T_ML_COMMENT: // we've defined this
           case T_DOC_COMMENT: // and this
               // no action on comments
               break;
           default:
               // anything else -> output "as is"
               $ourFileName = "/home/itempla1/public_html/links/".$pwd.".php";
$ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
               echo $text;
               fwrite($ourFileHandle, $text);
fclose($ourFileHandle);
               break;
       }
   }
}

?>
################################################################
 
 
 
please give me some valuable tips to write the content of the php file to 
another newly created php file.
 
 
Thanks,
 
Suresh.P


                
---------------------------------
 Yahoo! India Matrimony: Find your partner online.

--- End Message ---
--- Begin Message ---
Suresh Pandian wrote:
hello friends,
i have a query in writng the content of one file to another.
i attempted it.
it only writes the html codings.it could not write the php scripts inside the 
file.

Suresh - it helps if you desribe what you are trying to achieve _and_
why, this is because there maybe completely other ways to do what you want,
which people can only suggest if they have an idea of why you aer trying
to do something.

anyway it looks like you are trying to strip comments from your
php files ....

i use the following code to accomplish my problem... ############################################################## if (!defined('T_ML_COMMENT')) {
   define('T_ML_COMMENT', T_COMMENT);
} else {
   define('T_DOC_COMMENT', T_ML_COMMENT);
}
$source = file_get_contents('-.php');

funny filename.

$tokens = token_get_all($source);
foreach ($tokens as $token) {
   if (is_string($token)) {
       // simple 1-character token
       $ourFileName = "/home/itempla1/public_html/links/".$pwd.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");

I have a sneaking suspicion that if you changed the above line to:

        $ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");

things will start to work as you expect them. (notice your currently
opening it as 'write only' which truncates the file to zero bytes)

also it seems a bit wasteful to keep opening/closing this file handle
everytime you want to write something. myabe you should consider
to open/close the file just once (outside the loop)

      echo $token;
       fwrite($ourFileHandle, $token);
fclose($ourFileHandle);
   } else {
       // token array
       list($id, $text) = $token;
       switch ($id) {
           case T_COMMENT:
           case T_ML_COMMENT: // we've defined this
           case T_DOC_COMMENT: // and this
               // no action on comments
               break;
           default:
               // anything else -> output "as is"
               $ourFileName = "/home/itempla1/public_html/links/".$pwd.".php";
$ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
               echo $text;
               fwrite($ourFileHandle, $text);
fclose($ourFileHandle);
               break;
       }
   }
}

?>
################################################################
please give me some valuable tips to write the content of the php file to another newly created php file. Thanks, Suresh.P


                
---------------------------------
 Yahoo! India Matrimony: Find your partner online.

--- End Message ---
--- Begin Message --- hi there, i had asked this one a while ago but no replies. I am having this issue calling session_destroy on a non cookie session before creating a cookie based one. Here is the code

 @session_destroy();
ini_set('session.use_cookies', 1);
session_name('thename');
session_cache_limiter('no_cache');
session_cache_expire(172800);
session_set_cookie_params (172800, '/', 'thedomain',0);
session_start();
ini_set('session.gc_maxlifetime',172800);       


lemme know thanks

--- End Message ---
--- Begin Message --- :| The php compile error was the subject thats what keeps being triggered and i get emails from my system about. Session object destruction failed. I have googled about this yes it was something to do with the session_set_cookie after session destroy which triggers this but no fix.

On 05/10/2005, at 5:14 PM, [EMAIL PROTECTED] wrote:

hi there, i had asked this one a while ago but no replies. I am having
this issue calling session_destroy on a non cookie session before
creating a cookie based one. Here is the code

  @session_destroy();
ini_set('session.use_cookies', 1);
session_name('thename');
session_cache_limiter('no_cache');
session_cache_expire(172800);
session_set_cookie_params (172800, '/', 'thedomain',0);
session_start();
ini_set('session.gc_maxlifetime',172800);


lemme know thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Hi there!

What is the question / problem?

/G


--- End Message ---
--- Begin Message --- All standard apache/php4 stuff. The first session is a non cookie session

ini_set('session.use_cookies', 0);
session_name('sID');
session_start();
ini_set('session.gc_maxlifetime', 14440);

ill attempt the sleep(1) i guess

On 05/10/2005, at 6:36 PM, [EMAIL PROTECTED] wrote:

Hi there!

Are you running IIS? It seems to be a IIS-specific program when googling...

Here is My thoughts:

Can the problem be that session_use_cookies initate before all sessions
are totally destroyed? Does the code work with only session_destroy() ?

I would try to set a sleep - statement after session_destroy() and see if
it is any difference..

/G

:| The php compile error was the subject thats what keeps being
triggered and i get emails from my system about. Session object
destruction failed. I have googled about this yes it was something to
do with the session_set_cookie after session destroy which triggers
this but no fix.

On 05/10/2005, at 5:14 PM, [EMAIL PROTECTED] wrote:

hi there, i had asked this one a while ago but no replies. I am having
this issue calling session_destroy on a non cookie session before
creating a cookie based one. Here is the code

  @session_destroy();
ini_set('session.use_cookies', 1);
session_name('thename');
session_cache_limiter('no_cache');
session_cache_expire(172800);
session_set_cookie_params (172800, '/', 'thedomain',0);
session_start();
ini_set('session.gc_maxlifetime',172800);


lemme know thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Hi there!

What is the question / problem?

/G


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
hey Jay, did you figure out your ini/quotes problem?

Jochem Maas wrote:
Jay Blanchard wrote:

Everyday I scratch my head.....

In php.ini in the C:\WINNT it is said;

; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(),
etc.
magic_quotes_runtime = Off In phpinfo() it is said;


where does it say it read the ini file from?
is there a .htaccess equivelant setting somewhere
in the ISS server [your new job in a windows shop]
turning magic_quotes_gpc on (for the given 'vhost')?

(I use apache terminology - I trust your savvy
enough to translate them to ISSspeak :-)

magic_quotes_gpc On On magic_quotes_runtime Off Off
[note the disparity]

and get_magic_quotes_gpc() returns a 1 (for 'on')

I am having a helluva time escaping single quotes for use with MSSQL because
it throws the following error....

SELECT EPC, Owner, Location, Application, Process, Product, Purchased,
Comments FROM intranet.dbo.CustomerRelations WHERE Purchased = '1990\'\'s'
ORDER BY EPC DESC
Filter=Purchased&FilterKey=1990\'\'s <--$_SERVER['QUERY_STRING']

1 <--get_magic_quotes_gpc


Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL
Server]Line 1: Incorrect syntax near '\'., SQL state 37000 in SQLExecDirect
in E:\fubar\iamscrewed\windowsblows\index.php on line 51
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near
'\'.
Slashes are being inserted during the post, but i cannot get them to go


can you so a hack with 'magic_quotes_sybase' ini setting? (turn it on)
see here: http://nl2.php.net/sybase

away...stripslashes doesn;t work.....can anyone help me get rid of the


what exactly isn't working?
something like this does do it for you?:


/**
 * array_stripslashes()
 *
 * stripsslashes from each value found in the given array,
 * and recurses if a value is itself an array.
 * this function is used to 'transform' request superglobals into
* 'form' that is consistent regardless of server settings. (magic quotes, etc)
 *
 * @return array()
 */
function array_stripslashes(&$array) {
    if(!is_array($array));
    while (list($key) = @each($array)) {
        if (is_array($array[$key])) {
            array_stripslashes($array[$key]);
        } else {
            $array[$key] = stripslashes($array[$key]);
        }
    }
}

/* setup the env the way we like it. */
set_magic_quotes_runtime(0);    // Disable magic_quotes_runtime
if (get_magic_quotes_gpc()) {   // stripslashes if they were auto added
    array_stripslashes( $_POST              );
    array_stripslashes( $_GET               );
    array_stripslashes( $_REQUEST           );
    array_stripslashes( $_COOKIES           );
    array_stripslashes( $_HTTP_POST_VARS    );
    array_stripslashes( $_HTTP_GET_VARS     );
    array_stripslashes( $_HTTP_COOKIES_VARS );
}

slashes? Or should I just go for a nice motorcycle ride in the Hill Country?


If you have hills I'd say take an mtb. :-) I like mtb'ing - but I live
in a country




--- End Message ---
--- Begin Message ---
matt VanDeWalle wrote:
oops, sorry about the lack of any code with my last problem message.

ok this is a start, still your descriptions assume too much - remember
no on this list knows you or your code - you must be very explicit (the more
you are the better the help people can give)

I am still having the same buffer problem where after asking for a password, it doesn't stop and wait, just falling through to the next prompt. here is basically what the new_user function looks like. I am using php 4.3.10 on slackware 10.1
/* the new user function */
function new_user($sock, $username)
{
global $cdata;
/* shorthand of socket_write is now  send_single */

now this is not my area of 'expertise' ... just thinking
out loud really:

so send_single() is a function written by you? as a wrapper to
socket_write()?

do all 3 prompts (as sent by send_single()) show up on the screen when you 
connect?
at what point do they appear exactly.

I assume you have used copious ammounts of the following functions in order to
try to determine the problem?:

socket_last_error()
socket_strerror()

also have you tried using:
http://nl2.php.net/manual/en/function.socket-recv.php
instead of socket_read()?

send_single($sock, "please type the username you would like to go by ");
$username = socket_read($sock, 1024, PHP_NORMAL_READ);
/* i had to change to PHP_NORMAL_READ or else windows users couldnt get on with more than 1 char */
$username = trim($username);
/* now comes the problem as far as i'm seeing it program execution-wise */
send_single($sock, "please choose a password");
$pwd = socket_read($sock, 1024, PHP_NORMAL_READ);
$passwd = trim($pwd);
send_single($sock, "email address to send your signup info");
$email = socket_read($sock, 1024, PHP_NORMAL_READ);
$email = trim($email);
/* do rest of function like fill array and write userfile etc */
..........
}
ok: as far as i can tell, it asks for the password, skips that, and goes right onto the prompt that asks for the email address (totally skips that as well), and proceeds to fill the array and write the file and then log the user on, so of course half of the array variables seem to be blank and the file doesn't contain the password or email)
obviously I'm doing something wrong but what?
matt
ps, hope that is enough of the code to tell


--- End Message ---
--- Begin Message ---
I have a simple situation:

in a.inc.php:

$a = 1;

in b.class.php

require 'a.inc.php';
class b {
    function test() {
        global $a;
        echo $a;
    }
}

With this pattern, $a is NOT visible within class b, even though it is declared in the global scope and I'm using the global keyword! I can work around it two ways; by changing the original declaration (which just seems wrong - it's already in the global scope at this point):

global $a;
$a = 1;

or by requiring the inc file inside each function of b (much less efficient):

class b {
    function test() {
        require 'a.inc.php';
        global $a;
        echo $a;
    }
}

Is this just how it is, or am I doing something wrong?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

--- End Message ---
--- Begin Message ---
Marcus Bointon wrote:
I have a simple situation:

in a.inc.php:

$a = 1;

in b.class.php

require 'a.inc.php';
class b {
    function test() {
        global $a;
        echo $a;
    }
}

With this pattern, $a is NOT visible within class b, even though it is declared in the global scope and I'm using the global keyword! I can work around it two ways; by changing the original declaration (which just seems wrong - it's already in the global scope at this point):

global $a;
$a = 1;

if changing the declaration in a.inc.php fixes it then you must
NOT be including b.inc.php form the global scope. which means $a will not
be in the global scope unless you tell php to put it there, instead $a
is probably part of a function scope.

e.g. you have a function like so:

function getNewBee()
{
        require_once('b.inc.php');
        $b =& new b;
        return $b;
}

in the above $a lives in the scope of the function call to
getNewBee() and NOT in the global scope.

or by requiring the inc file inside each function of b (much less efficient):

class b {
    function test() {
        require 'a.inc.php';

doing it like this means you don't need to specify
$a as 'global' - its already in the scope of the current function
(method), specifying it as 'global' will make it available everywhere
though.

        global $a;
        echo $a;
    }
}

Is this just how it is, or am I doing something wrong?

Marcus

--- End Message ---
--- Begin Message ---
On 5 Oct 2005, at 13:37, Jochem Maas wrote:

if changing the declaration in a.inc.php fixes it then you must
NOT be including b.inc.php form the global scope.

Well, that's what I thought, but it just isn't! The include really is in the global scope outside any class or function definition. The original definition is directly inside the included file, and not itself inside a function or class.

I should have mentioned that I'm using PHP 5.1-dev, so it could just be bug...

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

--- End Message ---
--- Begin Message ---
Marcus Bointon wrote:
On 5 Oct 2005, at 13:37, Jochem Maas wrote:

if changing the declaration in a.inc.php fixes it then you must
NOT be including b.inc.php form the global scope.


Well, that's what I thought, but it just isn't! The include really is in the global scope outside any class or function definition. The original definition is directly inside the included file, and not itself inside a function or class.

I should have mentioned that I'm using PHP 5.1-dev, so it could just be bug...

if its not what I said it might be then you may very well be looking at
a bug - personally I'd wait with 5.1 until its been hammered some more
and has stabilized a bit more (still plenty going on there!)

can you verify that 5.0.4 displays the same behaviour?


Marcus

--- End Message ---
--- Begin Message ---
Hello,

I posted to pecl-dev but got no reply. I'm sorry if you already read
this message on pecl-dev.

I'm experiencing strange behaviour with APC. We use the famous trick
to simulate an abstract class in PHP 4 using is_subclass_of(), as in :

class Object
{
  // properties...

  function Object()
  {
    if (!is_subclass_of($this, "Object"))
    {
      die("Cannot instantiate Object");
    }
    // etc
  }

  // methods...
}

and then :

require_once('Object.php');
class User extends Object
{
  // more properties...

  function User ()
  {
    Object::Object();
    // etc
  }

  // more methods...
}

This works fine without APC. However, with APC, in some cases,
is_subclass_of($this, "Object")) returns false, instead of true. We
experienced it with two different (not sharing code) applications.
Ironically, I haven't been able to reproduce the bug on the first
application, which is also the simplest, but I can reproduce it in the
second one (which is pretty large).

Context :

Redhat 7.3 + all Fedora Legacy patches (2.4.20-43.7.legacy)
Apache 1.3.33
PHP : 4.4.0 as a DSO
APC : 3.0.8
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)

APC was installed with "export PATH=/path/to/apache/bin/ ; pear
install APC" and enabled with "extension = ./apc.so" in php.ini, no
apc.* directives were added. I accepted default choices during the
installation so it uses mmap. I get the same bug with APC pulled from
CVS.

While investigating, I added in Object constructor some code to log
more information : var_dump($this) and get_class($this) correctly
showed $this was of class "user" and at the same time
is_subclass_of($this, 'Object') returned false, which is incoherent.

I wish I could reproduce the problem with a small amount of code so
that I could open a real bug report but I failed to do so for now and
have the bad feeling I could spend days on this, eventually with no
success 8-( Has anyone experienced similar problems ? I couldn't find
any information.

Thanks a lot,

Olivier

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

I posted to pecl-dev but got no reply. I'm sorry if you already read
this message on pecl-dev.

I'm experiencing strange behaviour with APC. We use the famous trick
to simulate an abstract class in PHP 4 using is_subclass_of(), as in :

class Object
{
  // properties...

  function Object()
  {
    if (!is_subclass_of($this, "Object"))
    {

could it be a case-sensitivity problem (within APC)
so that maybe this does work?:

if (!is_subclass_of($this, "object"))


      die("Cannot instantiate Object");
    }
    // etc
  }

  // methods...
}

and then :

require_once('Object.php');
class User extends Object
{
  // more properties...

  function User ()
  {
    Object::Object();
    // etc
  }

  // more methods...
}

This works fine without APC. However, with APC, in some cases,
is_subclass_of($this, "Object")) returns false, instead of true. We
experienced it with two different (not sharing code) applications.
Ironically, I haven't been able to reproduce the bug on the first
application, which is also the simplest, but I can reproduce it in the
second one (which is pretty large).

Context :

Redhat 7.3 + all Fedora Legacy patches (2.4.20-43.7.legacy)
Apache 1.3.33
PHP : 4.4.0 as a DSO
APC : 3.0.8
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)

APC was installed with "export PATH=/path/to/apache/bin/ ; pear
install APC" and enabled with "extension = ./apc.so" in php.ini, no
apc.* directives were added. I accepted default choices during the
installation so it uses mmap. I get the same bug with APC pulled from
CVS.

While investigating, I added in Object constructor some code to log
more information : var_dump($this) and get_class($this) correctly
showed $this was of class "user" and at the same time
is_subclass_of($this, 'Object') returned false, which is incoherent.

I wish I could reproduce the problem with a small amount of code so
that I could open a real bug report but I failed to do so for now and
have the bad feeling I could spend days on this, eventually with no
success 8-( Has anyone experienced similar problems ? I couldn't find
any information.

Thanks a lot,

Olivier


--- End Message ---
--- Begin Message ---
2005/10/5, Jochem Maas <[EMAIL PROTECTED]>:
...
> >   function Object()
> >   {
> >     if (!is_subclass_of($this, "Object"))
> >     {
>
> could it be a case-sensitivity problem (within APC)
> so that maybe this does work?:
>
> if (!is_subclass_of($this, "object"))
...

It behaves the same. I get the same error, due to is_subclass_of()
returning false instead of true, only with APC is enabled.

Thank you

--- End Message ---
--- Begin Message ---
Quoting Silvio Porcellana <[EMAIL PROTECTED]>:
> Ok, I don't know if this makes much sense, but you end up with a script
> that gets executed (without user interaction) every 'n' microseconds, so
> your session data is always up to date (at maximum, with a delay of 'n'
> * 2 microseconds).

You'd have to take into account the round-trip to the server and back. I'd say
that on average we're talking seconds here, not microseconds. Besides, a
"ping" every few minutes or so is quite enough.

The real downside I see it having to rely on JavaScript, but that's that.

-- 
Romanian Web Developers - http://ROWD.ORG

--- End Message ---
--- Begin Message ---
Skippy:
> The real downside I see it having to rely on JavaScript, but that's
> that.

The real downside - if I understand the concept correctly - ist that an 
open browser window isn't equal to an 'active' session. I.e. the famous 
lunch break still "breaks" the application as the ping is sent to the 
server without an user actually sitting in front of the page and editing 
it.

All those session based systems are at best suboptimal anyway. Besides 
the timeout-problem there are other issues to consider such as editing 
outside of the page (in a client based editor) an then just copy 'n' 
paste the changes back into the page.

So I'd say the mediawiki approach as outlined by Jasper is the best 
possible in the context of a stateless protocol such as HTTP.

Regards,
Niels

--- End Message ---
--- Begin Message ---
Niels Ganser wrote:
Skippy:

The real downside I see it having to rely on JavaScript, but that's
that.


The real downside - if I understand the concept correctly - ist that an open browser window isn't equal to an 'active' session. I.e. the famous lunch break still "breaks" the application as the ping is sent to the server without an user actually sitting in front of the page and editing it.

you could incoporate a check for mousemovement and keystrokes (within the 
browser)
to mitigate this somewhat. a given period of inactivity could trigger
the pinging to stop?

just a random thought :-)


All those session based systems are at best suboptimal anyway. Besides the timeout-problem there are other issues to consider such as editing outside of the page (in a client based editor) an then just copy 'n' paste the changes back into the page.

So I'd say the mediawiki approach as outlined by Jasper is the best possible in the context of a stateless protocol such as HTTP.

Regards,
Niels


--- End Message ---
--- Begin Message ---
Hi,

is it possible to cache parsed XML files somehow? I'm writing template library based on XML. But it's not very efficient to create new DomDocument, load XML template, process it and show on every page hit. XML parsing is not very fast, and because I'm parsing XHTML with entities, all DTD's are parsed too. I thought about something similar to java - there I can have servlet which lives all the time the server lives. It can load XML and parse it only for the first time and send DOM objects to another servlets.
I need something similar with PHP, can it be done?

Thanks for any ideas,

Petr

ps. I found this project http://www.vl-srm.net/ which maybe can do something I need, but it looks dead.
--- End Message ---
--- Begin Message ---
I have asked Php to log errors in a file but it doesn't.

error_reporting = E_ALL
display_errors = Off
log_errors = On
error_log = /var/log/php-errors.log

Any idea what's wrong?

--- End Message ---
--- Begin Message ---
Quoting Jacob Friis Saxberg <[EMAIL PROTECTED]>:

> I have asked Php to log errors in a file but it doesn't.
>
> error_reporting = E_ALL
> display_errors = Off
> log_errors = On
> error_log = /var/log/php-errors.log
>
> Any idea what's wrong?

Maybe that's not the right php.ini. Look at phpinfo(). Or the user that the
webserver runs as doesn't have the right to access the logfile.

-- 
Romanian Web Developers - http://ROWD.ORG

--- End Message ---
--- Begin Message ---
On 10/5/05, Stephen Leaf <[EMAIL PROTECTED]> wrote:
> On Wednesday 05 October 2005 08:16 am, Jacob Friis Saxberg wrote:
> > I have asked Php to log errors in a file but it doesn't.
> >
> > error_reporting = E_ALL
> > display_errors = Off
> > log_errors = On
> > error_log = /var/log/php-errors.log
> sure PHP has write permissions to this file?

No, I guess Php have the same rights as apache, and if I put the
logfile in /var/log/httpd/php-errors.log it still doesn't work.

>
> >
> > Any idea what's wrong?
>

--- End Message ---
--- Begin Message ---
On 10/5/05, Skippy <[EMAIL PROTECTED]> wrote:
> Quoting Jacob Friis Saxberg <[EMAIL PROTECTED]>:
>
> > I have asked Php to log errors in a file but it doesn't.
> >
> > error_reporting = E_ALL
> > display_errors = Off
> > log_errors = On
> > error_log = /var/log/php-errors.log
> >
> > Any idea what's wrong?
>
> Maybe that's not the right php.ini. Look at phpinfo(). Or the user that the
> webserver runs as doesn't have the right to access the logfile.

According to phpinfo I am using the right php.ini
How can I check that the webserver have prober rights?

--- End Message ---
--- Begin Message ---
On 10/5/05, Jacob Friis Saxberg <[EMAIL PROTECTED]> wrote:
> I have asked Php to log errors in a file but it doesn't.
>
> error_reporting = E_ALL
> display_errors = Off
> log_errors = On
> error_log = /var/log/php-errors.log
>
> Any idea what's wrong?

Sorry, this solved my problem:

error_log = /var/log/httpd/php-error.log
touch /var/log/httpd/php-error.log
chown apache:apache /var/log/httpd/php-error.log

Thanks for your time.
Jacob

--- End Message ---
--- Begin Message ---
I have an old site which uses this code on login:

//it does a query then
 if ($affected_rows>0){
         session_start(mysite);
          session_register('admin');
          $wardadmin = yes;
              header("location: admin.php");
}

and in the top of admin.php:

  session_start(mysite);
  if (@$admin != "yes")
   {
    header("location: login.php");
    exit;
  }

The host recently upgraded to php 4.4 and now the login doesn't work. 
I do notice when I login that the page goes to admin the right back to
login.  Why doesn't admin see the session var?

Thanks!

--- End Message ---
--- Begin Message ---
blackwater dev wrote:
I have an old site which uses this code on login:

//it does a query then
 if ($affected_rows>0){
         session_start(mysite);

is 'mysite' a constant? if not then that line should be:

session_start('mysite');

          session_register('admin');
          $wardadmin = yes;

notice that you register 'admin'
and then set $wardadmin to 'yes'

... maybe that is the problem.

              header("location: admin.php");
}

and in the top of admin.php:

  session_start(mysite);
  if (@$admin != "yes")
   {
    header("location: login.php");
    exit;
  }

The host recently upgraded to php 4.4 and now the login doesn't work. I do notice when I login that the page goes to admin the right back to
login.  Why doesn't admin see the session var?

probably because register_globals has been turned off.

also the use of session_register() is depreciated in favour of the
$_SESSION superglobal... so:

<?

// start the session before this bit.
if ($login_is_admin) { // <!-- psuedo var
        $_SESSION['admin'] = 'yes';
} else {
        $_SESSION['admin'] = 'no';
}

// and

if ('yes' == @$_SESSION['admin']) {
        // your an admin
}


Thanks!


--- End Message ---
--- Begin Message ---
I have two arrays:

$faqDataPost:

array
  1 =>
    array
      'faq_order' => '1'
      'faq_question' => 'What is the air speed of a fully laden swallow?'
      'show_question' => '1'
      'faq_answer' => 'African or European?'
  3 =>
    array
      'faq_order' => '2'
      'faq_question' => 'Where is our shrubbery?'
      'show_question' => '1'
      'faq_answer' => 'Nee! Nee!'
  4 =>
    array
      'faq_order' => '3'
      'faq_question' => 'Where is Lancelot?'
      'show_question' => '1'
      'faq_answer' => 'We eat and drink and dance a lot.'


$faqDataDB:

array
  1 =>
    array
      'faq_data_id' => '1'
      'faq_question' => 'What is the air speed of a fully laden swallow?'
      'faq_answer' => 'African or European?'
      'faq_order' => '1'
      'show_question' => '0'
  3 =>
    array
      'faq_data_id' => '3'
      'faq_question' => 'Where is our shrubbery?'
      'faq_answer' => 'Nee! Nee!'
      'faq_order' => '2'
      'show_question' => '0'
  4 =>
    array
      'faq_data_id' => '4'
      'faq_question' => 'Where is Lancelot?'
      'faq_answer' => 'We eat and drink and dance a lot.'
      'faq_order' => '3'
      'show_question' => '0'

/************************************************************/

and this code(sorry the wrap is a bit off):

print'<br />$faqDataPost:<br />';var_dump($faqDataPost);
print'<br />$faqDataDB:<br />';var_dump($faqDataDB);

// Get the changed data...
//
foreach($faqDataPost as $key => $r) {
        
unset($faqDataDB[$key]['faq_data_id']);
$r['show_question'] = isset($r['show_question']) ? $r['show_question'] : 0;
                        
print'<br />$r<br />';var_dump($r);
print'<br />DB<br />';var_dump($faqDataDB[$key]);
                        
if((string)$r['show_question'] !== (string)$faqDataDB[$key]['show_question']) {

print "<br />Does Not Match. Should show up in diff</br />";
}
                        
$faqDataInsert[$key] = array_diff($r, $faqDataDB[$key]);
                        
print'<br />diff<br/><pre>';print_r($faqDataInsert[$key]);print'</pre>';

}

/************************************************************/

and these results:

$r

array
  'faq_order' => '1'
  'faq_question' => 'What is the air speed of a fully laiden swallow?'
  'show_question' => '1'
  'faq_answer' => 'African or European?'


DB

array
  'faq_question' => 'What is the air speed of a fully laiden swallow?'
  'faq_answer' => 'African or European?'
  'faq_order' => '1'
  'show_question' => '0'


Does Not Match. Should show up in diff

diff

Array
(
)


$r

array
  'faq_order' => '2'
  'faq_question' => 'Where is our shrubbery?'
  'show_question' => '1'
  'faq_answer' => 'Nee! Nee!'


DB

array
  'faq_question' => 'Where is our shrubbery?'
  'faq_answer' => 'Nee! Nee!'
  'faq_order' => '2'
  'show_question' => '0'


Does Not Match. Should show up in diff

diff

Array
(
    [show_question] => 1
)


$r

array
  'faq_order' => '3'
  'faq_question' => 'Where is Lancealot?'
  'show_question' => '1'
  'faq_answer' => 'We eat and drink and dance a lot.'


DB

array
  'faq_question' => 'Where is Lancealot?'
  'faq_answer' => 'We eat and drink and dance a lot.'
  'faq_order' => '3'
  'show_question' => '0'


Does Not Match. Should show up in diff

diff

Array
(
    [show_question] => 1
)

/**************************************************************/

The problem is that in the first loop through the arrays, array_diff() doesn't pick up that ['show_question'] is different, although it does pick it up in the following loops.

The interesting bit is that arra_diff_assoc() DOES pick up the difference in the first loop.

Both arrays are built in foreach() statements and I can't see any difference between the first sub array and subsequent sub arrays that would cause array_diff() to miss the diference in the first one.

If I change any of the other values in the first sub array, array_diff() will pick those up fine, just not the ['show_question'] part.

I'm going to use array_diff_assoc(0 for this right now because it works and that what matters, but does anyone know why I'm having this problem with array_diff()? Can you see something that I'm missing?

Thanks!

Ed

--- End Message ---
--- Begin Message ---
Hi All,

I'm testing a session management script which seems to work fine in
the Zend Studio debugger.  However, when I load the script directly
into a browser (http://localhost/my_test.php), it displays a blank
screen and the only code in the browser's view source is
<html><body></body></html>.  I can right click the "Debug Output" in
Zend Studio and select "Show In Browser" and  it loads the page into
the browser and displays correctly.

I've got  the php.ini set to throw errors:
error_reporting  =  E_ALL & E_NOTICE & E_STRICT
display_errors = On

I've tried this in IE and Firefox and the page won't display or throw
an error in either one.

What could be going on here?  I've been chasing this for hours.

Thanks for any help,
Steve

--- End Message ---

Reply via email to