[PHP] version_compare

2010-09-30 Thread Brian Smither

I found this code...
if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
 $text=filter_var($text, FILTER_SANITIZE_URL);
}

...to be questionable.

Under what conditions would version_compare() return true, yet the filter_var() 
be undefined? Because that's what is happening.

Thank you.




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



Re: [PHP] version_compare

2010-09-30 Thread Brian Smither

>Personally, I would change that to be
>if ( function_exists('filter_var') ) {

So would I:
*But it's not my code.
*I wish to learn and understand the cause of the problem - not walk around it.

>It means condition (PHP_VERSION >= 5.2.0)

I understand that. There was a second, more relevant, part to my question.

I have found the version of PHP used as reported in the HTTP header responses.

filter_var() is undefined in PHP/5.2.4_p20070914-pl2-gentoo




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



[PHP] filter_var (was: Re: [PHP] version_compare)

2010-09-30 Thread Brian Smither

>As Paul pointed out, maybe your version of PHP was built without the
>filter_var function compiled in.

This is what I have learned about PHP with filter_var() as an illustrative 
point:

Many people who provide elaborations on PHP make too many assumptions or are 
blatently and woefully incomplete. Statements such as "PHP 5.2.0 or higher is 
required for this to work" is misleading. The PHP online manual pages for 
respective functions make no distinction that any particular function or 
capability is an optional include for a build - considered an "extension" as 
opposed to, what?, "native code"?

I have also learned that when coding my own scripts, I must not only read the 
manual page for that function, but also any metadata for it and its group, such 
as the Introduction page, Installing/Configuring, etc. And where, when I 
finally find it, if I can reason out that I should be looking for it, it may 
say "The filter extension is enabled by default as of PHP 5.2.0", that I need 
to be reasonably cautious because some idiot may build PHP 5.2.0+ without this 
extension.

Are the array_*() functions also an optional extension?



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



[PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither
I am running into a variable collision. The project I'm developing is NOT 
guaranteed to be operating on PHP5. Any solution I find should (hopefully) be 
able to run on PHP4 (yes, I know PHP4 is deprecated).

I am building a bridge between two third-party applications. Both instantiate 
their respective database class assigning it to $db and I cannot change that.

So, I am interested in solutions to this.

I found a reference to a Packager class and will be looking at it shortly.



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



Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither

>Just to clarify, both packages are instantiating and calling their
>respective classes from the $db var, which is in the global scope.
>Is this correct?

I would say yes to the way you are asking. Take the following two applications. 
The four respective statements are in each their respective script.

Application A:


Application B:


The bridge project is operating in A and include()'ing the script that is B (as 
I have not found an API for B). $db in B is colliding with $db in A.



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



Re: [PHP] Variable (Class instantiation) collision

2010-10-06 Thread Brian Smither
Gentlemen,

Thank you. The "Thing1 Thing2" approach worked. 

>If you have total control over application A which contains the bridge
>code, the easiest is to change it to use a different global variable.




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



[PHP] Very Large File Splatter

2013-02-22 Thread Brian Smither
PHP 5.4.4-TS-VC9 on Windows XP SP3 NTFS non-system drive with 18GB free.

I dare not try to replicate this. As such, I cannot firmly place the blame on 
PHP.

I have peppered a PHP application with a call to a function which appends-only 
to a logfile the parameters passed to it. Each pass of the application creates 
many MB of content.

It is conceivable that I ran out of hard drive space.

When that which what I was working on seemed to be acting very weird, I 
rebooted the computer only to see thousands of lines scroll by from Windows 
repairing the file system.

I discovered logfile contents in many dozens of files. The timestamp and 
filesize of the damaged files were not changed. Only the contents replaced with 
slices of the logfile.

Again, I'm not going to try to 'intentionally' replicate this, so I ask:

Has PHP's interface with the NTFS file sub-system ever been reported to 
splatter a file across the contents of a drive?



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



Re: [PHP] Very Large File Splatter

2013-02-22 Thread Brian Smither
"If you can show the write portion of the code in your iteration,
as well as a sample of the naming convention, it may offer more clues."

$dbgMsg = "a diagnostic string maybe 5K in length";
$dbg_fp = fopen(ROOT_DIR.DS."dbg_log.txt", "a"); // Derives a full path
fwrite($dbg_fp, $dbgMsg);
fclose($dbg_fp);

"Did you shutdown the system cleanly, when you
recognized this behaviour?"

Yes, a clean reboot. Not a reset-switch restart, nor a power-cycle restart.

Sample lines from bootex.log:

Checking file system on L:
The type of the file system is NTFS.

One of your disks needs to be checked for consistency. You
may cancel the disk check, but it is strongly recommended
that you continue.
Windows will now check the disk.
Attribute record of type 0x80 and instance tag 0x3 is cross linked
starting at 0x20b3b for possibly 0x100 clusters.
Attribute record of type 0x80 and instance tag 0x3 is cross linked
starting at 0x20b3b for possibly 0x100 clusters.
Some clusters occupied by attribute of type 0x80 and instance tag 0x3
in file 0x3680 is already in use.
Deleting corrupt attribute record (128, $J)
from file record segment 13952.

Sorting index $O in file 25.
The object id in file 0x4d14 does not appear in the object
id index in file 0x19.
Inserting an index entry into index $O of file 25.
The object id in file 0x4d17 does not appear in the object
id index in file 0x19.
Inserting an index entry into index $O of file 25.
The object id in file 0x4d19 does not appear in the object
id index in file 0x19.

Recovering orphaned file .svn (19642) into directory file 13948.
Recovering orphaned file CATEGO~1.TPL (19720) into directory file 28688.
Recovering orphaned file categories.tpl (19720) into directory file 28688.
Recovering orphaned file CATEGO~1.BAK (19721) into directory file 28688.
Recovering orphaned file categories.tpl.bak (19721) into directory file 28688.

And many, many more of each section.



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



[PHP] Lifetime

2013-02-26 Thread Brian Smither
I'm curious to know what the lifetime of a constant is.

I know that sounds like a stupid question, but the context is this:

I have a file I am writing to up to the very last possible micro-second. As 
such, I know that as PHP is destroying itself after having executed the last 
statement in the program, things begin to disappear. The Class objects destruct 
in no discernable order (they have destructors). Any open file handles close. 
Etc.

My question is: During all this destruction, at what point must I no longer 
expect to have a constant available? That is, when the classes are executing 
their __destruct() functions, et al, I want to manage something with those 
destructors.

So when does the constant actually-factually disappear?



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



[PHP] Guaranteed Way to Get Error Message Wanted

2013-07-05 Thread Brian Smither
I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) 
with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3.

An earlier version of this application works. The current version causes a 500 
Internal Server Error. There is no entry in PHP's (fully active) error log. I 
cannot decipher Abyss's logging, so I cannot determine if a clue was reported 
by Abyss or not.

The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 
(Apache module), Apache 2.2).

What I would like to have is a method of getting PHP to report in some 
undeniable manner, short of total system failure, what it doesn't like about 
whatever killed it.




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



[PHP] Guaranteed Way to Get Error Message Wanted

2013-07-06 Thread Brian Smither
>It looks like you are running the thread-safe version with
>FastCGI, which I understand to be counter to the recommendations.

Thank you for the comment.

I switched to PHP5.4.17-NTS-VC9, but the application still crashes. And still 
no clue as to why.

So, still looking for that magic method to get PHP to report what's happening 
on a 500 Internal Server Error when it's (presumably? not sure...) not the 
server's fault.




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



[PHP] Guaranteed Way to Get Error Message Wanted

2013-07-06 Thread Brian Smither
>Have you got all your extensions updated?

I would think so. Just to state the required disclaimers:
phpinfo.php with  works.
Liberally peppering a tracer routine throughout the application shows it is 
getting executed up until one spot. But there is nothing obviously wrong with 
the code. Nothing!

That's why I need the guaranteed message delivery on why PHP does not like the 
code.




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



[PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Brian Smither
I have a situation where, for some unknown reason, where each class that 
finishes its __contruct{} function, that class gets automatically assigned to a 
variable - other than the variable I specify.

Conceptually:

class Hello { private $_world = 'World'; __construct(){} }

$clsHello = new Hello();

echo 'The variable $hello is '.gettype($hello)."\n".print_r($hello,true);

Output:
The variable $hello is object
Hello Object
(
[_world:Hello:private] => World
)

There is no statement in my application that assigns an instance of the class 
to another variable, the name being a lowercase variant of the class name.

Would there be a PHP function that would do this as a side-effect?

I am more interested in learning what is happening as opposed to rolling back 
to a previous version. (A backup copy functions fine. A file compare does not 
reveal any likely suspects.)

PHP5.4.17-NTS-VC9 (Windows XP-SP3)




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



Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Brian Smither
Second go around:

I have a situation where, for some unknown reason, where each class that 
finishes its __contruct{} function, that class gets automatically assigned to a 
variable - other than the variable I specify.

Conceptually (a little bit better on the conceptualizing):

class Hello {
private $_world = 'World';
function __construct(){}
}

$clsHello = new Hello();

echo 'The variable $hello is '.gettype($hello)."\n".print_r($hello,true);

Output:
The variable $hello is object
Hello Object
(
[_world:Hello:private] => World
)

There is no statement in my application that assigns an instance of the class 
to another variable, the name being a lowercase variant of the class name.

Would there be a PHP function that would do this as a side-effect?

I am more interested in learning what is happening as opposed to rolling back 
to a previous version. (A backup copy functions fine. A file compare does not 
reveal any likely suspects.)

PHP5.4.17-NTS-VC9 (Windows XP-SP3)




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



Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Brian Smither
>I cannot replicate this.

I don't expect anyone to be able to replicate this behavior. The example shows 
an extraordinarily stripped-down sequence of statements that informs what 
should work, but do to some unknown agent, which, therefore, cannot be included 
in the example, produces unexpected output.

This conceptual example is not a 'sample' or 'excerpt' of the actual 
application. There is much, much more code. None of it is an apparent likely 
suspect in causing this behavior.

I am hoping for a, "Oh, yeah! I've seen that happen before. It's caused by..."

Let us focus on the central question:

Would there be a PHP function that would do [what the example describes] as a 
side-effect?




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



Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Brian Smither

> $hello = $clsHello;

If that conceptual statement (or any occurance of the conceptual $hello) were 
in the code, then my (really good) Find feature of my code editor would have 
found it.


> There are only a few variables that get assigned as side effects of
>  functions, but they have very specific names, and none of them are
> $hello (but I'm guessing that's not the actual variable name)

I have two dozen classes in this application. In every case, there will be a 
variable, the name of which is a lowercase variant of the class name, to which 
is assigned an instance of the class, when the class's construct() function 
completes. The example informs you of this.


> Somewhere in your code there is something that is assigning to $hello.
> Find everything that's doing that and look at each instance in detail.

I have. Many times. What I am looking for is a side-effect -- something not 
obvious. (This application does not use an eval() function where some 
obfuscated string manipulation would play this out.)


> I would say for definite that it's some of the surrounding code,

Exactly. No sooner and no later than precisely when the class's construct() 
function ends, and control is given to the next statement after the one that 
instantiated that class.


> probably something similar to this:

Let's explore this statement:

> $GLOBALS[strtolower(get_class($this))] = $this;

May I infer that the declaration of $GLOBALS['hello'] will, at the same time, 
also create $hello (without a statement declaring such)?

This:
http://php.net/manual/en/reserved.variables.globals.php
implies the opposite direction.





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



Re: [PHP] Class Auto-Assigning to Variable

2013-08-07 Thread Brian Smither
>Your example does _not_ show this, it works
>as expected and throws a notice, from which can be inferred there is other
>code doing this

Or relevant code having a side-effect not currently realized.


>Is your class maybe inheriting from another one and that contains the code
>causing this issue?

No.


>>May I infer that the declaration of $GLOBALS['hello'] will, at the same
>>time, also create $hello (without a statement declaring such)?
>
>The $GLOBALS array is what's known as a super global. Elements within the
>array are reflected as global variables and vice-versa.


Let's refine the conceptual example:

class Hello {
private $_world = 'World';
function __construct(){}
}

$GLOBALS['hello'] = new Hello();

echo 'The variable $hello is '.gettype($hello)."\n".print_r($hello,true);

Can we then postulate that the value of $GLOBALS['hello'] will also be revealed 
in $hello, even though $hello was never formally declared?

I know that $GLOBALS['hello'] has a universal scope, and $hello (wherever it 
comes from) needs to be global-ized inside functions.



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



[PHP] Parent Limits?

2011-06-20 Thread Brian Smither

The following works (three parents):
include("../../../includes/ini.inc.php");
require_once("../../../includes/ini.inc.php");

The following works (four parents):
include("../../../../includes/ini.inc.php");

The following does not work (four parents):
require_once("../../../../includes/ini.inc.php");

That is, require_once() with four parents has been reported to have been 
disabled for security purposes. But apparently, not disabled is include() with 
four parents.

The device or setting which is causing the problem is not known to me. It may 
be just the four parents (and include() is getting the data from this file 
elsewhere) or it may be the combination.

It has been reported this is not a limit within open_basedir. So, what is it? 
What module or php.ini setting would have this effect?

Thank you.






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



[PHP] Re: Parent Limits?

2011-06-30 Thread Brian Smither
With all kind respect to Richard Buskirk and Daniel Brown (thank you for 
responding), their replies did not actually answer my question.

My question is: What module or php.ini setting would render inoperative a 
directory traversal of X parents?

My original post follows.

The following works (three parents):
include("../../../includes/ini.inc.php");
require_once("../../../includes/ini.inc.php");

The following works (four parents):
include("../../../../includes/ini.inc.php");

The following does not work (four parents):
require_once("../../../../includes/ini.inc.php");

That is, require_once() with four parents has been reported to have been 
disabled for security purposes. But apparently, not disabled is include() with 
four parents.

The device or setting which is causing the problem is not known to me. It may 
be just the four parents (and include() is getting the data from this file 
elsewhere) or it may be the combination.

It has been reported this is not a limit within open_basedir. So, what is it? 
What module or php.ini setting would have this effect?

Thank you.



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



[PHP] PEAR Mail $obj->send()

2011-07-08 Thread Brian Smither
A client has:
PHP 5.3 on Win7x64 running a local web app that needs to send mail. (This app 
was once hosted on a linux-based hosted space.) Apache 2.2 is installed but 
apparently not being used. I think the IIS service is actually the web server 
that is engaged.

During troubleshooting a wide range of problems, I discovered that the PEAR 
Mail module needed to be installed. So I installed PEAR (the PEAR Installer) 
and the Mail module with all dependencies. The PEAR_ENV was added. The system 
was rebooted.

A test php script instantiates the Mail class and the script proceeds fine 
until the send() method is called. I get a browser with "Waiting for localhost" 
for more than 60 seconds. (I used die(); to trace the script. Instead of 
'auth'=> true, I used 'auth' => "PLAIN" as suggested by a user comment on the 
Mail documentation page.)

I believe all the parameters are correct. The actual web app works - except 
emailing.

I added a firewall rule allowing outbound port 465 just for kicks.

I can double-check for the PHP timeout setting but would PHP timeout in this 
case (waiting for a socket??)?

Any suggestions?





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



[PHP] Re: PEAR Mail $obj->send()

2011-07-08 Thread Brian Smither
>>Instead of 'auth'=> true, I used 'auth' => "PLAIN" as 
>> suggested by a user comment on the Mail documentation page.)

$obj = Mail::factory('smtp',
  array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));

(Variables are set. $host = "smtp.gmail.com", $port = "465")


>Do you have a mail server running on localhost?

No.

>If you do not have a local MTA then you need to change the
>params so it uses a remote mail server.

It does.




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



[PHP] Wrong POSTFIELDS Posted

2012-02-17 Thread Brian Smither
I have a script that accepts four POST variables. Three are used and five more 
are added for a total of eight keys and their urlencode() values all strung 
together in the proper format.

Then cURL is initialized with the field string given to:
curl_setopt($ch, CURLOPT_POST,8);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);

But that's not the string arriving at cURL's target URL! What's arriving at the 
target is exactly the POST array that this script received in the first place.

Here's what I don't understand...
The cURL request is coming from this script on domainA, but the target address 
is also domainA. Does everybody play nice in this situation?

PHP 5.3.5
Apache 2.2

Note: CURLOPT_POST evaluates to true, regardless that I use an integer. All 
other curl* commands are set.



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



[PHP] Re: ASP to PHP

2012-02-17 Thread Brian Smither
I've done a site from Classic ASP (no .net) to non-oop PHP.




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