[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] 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 ? phpinfo() ? 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] 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] 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] 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] Is PHP unsuitable for HTML5 WebSockets?

2012-08-12 Thread BRIAN M. FITZPATRICK
I've looked all over the net and I have been unable to find a concrete answer 
to this question. I am about to start development on a web application that 
will need to provide real-time updates of data to user's browsers. WebSockets 
are ideal for this task.

I have read in some places on the net that PHP is not suitable for WebSockets 
due to it's nature. That WebSockets are designed for long running 
threads/processes which each maintain multiple event-driven connections, 
whereas PHP was designed around the short-lived single process procedural 
paradigm.

Yet on the other hand I see lots of guides and libraries (such as 
http://socketo.me/) on the net that deal with PHP WebSockets. So I don't know 
what to think at this stage. Is PHP a suitable platform for developing a web 
application that requires WebSockets?


Re: [PHP] File moving hell on Windows

2012-07-31 Thread Brian Dunning
Regular Windows networking.

On Jul 30, 2012, at 2:29 PM, Mike Mackintosh mike.mackint...@angrystatic.com 
wrote:
 
 What protocol are you targeting? FTP, SFTP, SSH, SMB, etc?
 
 -- 
 Mike Mackintosh
 PHP 5.3 ZCE
 


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



[PHP] File moving hell on Windows

2012-07-30 Thread Brian Dunning
I'm dealing with a Windows NT network that includes some digital printing 
presses that also run Windows. PHP 5.3.8 is running on one NT machine. Its job 
is to take CSV files that exist in a directory on one machine, and move them to 
a directory on the digital presses. All the source and destination folders 
require different network credentials to read and write -- and because of red 
tape bureaucracy, that cannot be changed. Any suggestions how I could do this? 
I can't find any file-move examples that include the use of network credentials 
with each read and write. Thanks...  :-(
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Bust out a PDF via the print stylesheet?

2012-05-18 Thread Brian Dunning
Hey all -

The articles on my web site already have a very nice stylesheet that produces a 
print version. Does anyone know if there's a such a thing as a PHP class that 
would let me put up a Download PDF link that would generate a PDF doc on the 
fly, using that same stylesheet? I've used various PHP PDF classes before, but 
I'd rather see if I can shortcut this rather than assembling the doc from 
scratch.

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



Re: [PHP] FPDF ?

2012-05-18 Thread Brian Dunning
I never found a solution to this myself.

On Apr 26, 2012, at 2:13 PM, Jim Giner wrote:

 For those of you with FPDF experience.
 
 I've just begun using it and have figured out how it works I think.  I am 
 still having trouble with the bottom of the page tho.  Seems that if I get 
 too close to the bottom margin and my data line exceeds the amount of 
 available space, my MultiCell elements print some of their contents and then 
 my Footer gets printed and then I go to a new page where some small amount 
 of the remaining data for that line gets printed and then a new page is 
 output and repeat.  This can go on for 3-4 pages before things work out and 
 my report continues until it gets a full page again and then it all happens 
 again.
 
 I know it sounds complicated, but I'm hoping someone else has experienced 
 this kind of learning curve and can give me a clue as to what I'm doing 
 wrong, or at least what's happening.  Even better would be an algorithm for 
 detecting how much space I have left so I can avoid these split lines and 
 perhaps solve my entire problem. 
 


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



[PHP] Running through an enormous SQL file

2012-05-04 Thread Brian Dunning
I have a script that downloads a 267MB SQL file (it creates and loads a MySQL 
database). Any idea how to do this? Obviously I'm not going to get a file that 
size into memory to loop through.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running through an enormous SQL file

2012-05-04 Thread Brian Dunning
How would you launch that from PHP?

On May 4, 2012, at 6:11 PM, tamouse mailing lists wrote:

 Is there any need to use PHP with this at all? If it's already in SQL,
 can't you just feed it to mysql?


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



Re: [PHP] Serving a .dmg via readfile?

2012-04-26 Thread Brian Dunning
Thanks, this suggestion from Dante completely solved the problem.

Replaced:

readfile('/var/www/mypath/My Cool Image.dmg');

With:

$fd = fopen ('/var/www/mypath/My Cool Image.dmg', r);
while(!feof($fd)) {
set_time_limit(30);
echo fread($fd, 4096);
flush();
}
fclose ($fd);

It's now serving all files properly. 


On Apr 25, 2012, at 9:07 PM, D. Dante Lorenso wrote:

 You'll want to use fopen, fread, fwrite, and fclose to loop through bytes in 
 your file as you shuttle chunks to the client instead of slooping it all into 
 memory in one hunk.

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



[PHP] Serving a .dmg via readfile?

2012-04-25 Thread Brian Dunning
Hey all - I'm having no luck serving a .dmg from my online store. I stripped 
down the code to just the following to debug, but no matter what I get a 
zero-byte file served:

  header('Content-Type: application/x-apple-diskimage');   // also tried 
octet-stream
  header('Content-Disposition: attachment; filename=My Cool Image.dmg');
  $size = filesize('/var/www/mypath/My Cool Image.dmg');
  header('Content-Length: '.$size);
  readfile('/var/www/mypath/My Cool Image.dmg');

This same code works for a number of other file types that I serve: bin, zip, 
pdf. Any suggestions? Professor Google is not my friend.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Updating Google Plus

2012-03-29 Thread Brian Dunning
Anyone know a way to update Google Plus via the 33669 SMS number?

Yes, I have seen the popular how-to instructions to get the secret email 
address by using Google Voice and forcing the error message, but I'd prefer a 
legit non-hack way to do it. I'd even be happy to pay for an SMS gateway rather 
than depend on the email address, which they might decide to terminate.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating Google Plus

2012-03-29 Thread Brian Dunning
Sorry, I did not mention the implied using PHP. Since everything I do  eat  
breathe is PHP, it didn't even occur to me to state the obvious.  :-)  :-)


On Mar 29, 2012, at 2:46 PM, Stuart Dallas wrote:

 Err, what has this got to do with PHP?!?

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



Re: [PHP] Updating Google Plus

2012-03-29 Thread Brian Dunning
That's EXACTLY what I was looking for. Thanks! Don't know why my Google-Fu 
failed me...  :-)

On Mar 29, 2012, at 5:26 PM, Don Wieland wrote:

 First Google+ (Google Plus) status update bot in PHP
 http://360percents.com/posts/first-google-google-plus-status-update-bot-in-php/
 Is that what you are looking for or something different?


--
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



[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] Would like to subscribe to this mailing list

2011-07-03 Thread Brian Dworkin

I would like to subscribe to this mailing list please.

Thanks.

Sincerely,

Brian Dworkin
Managing Partner
Bright Telecom
201-892-9553 (mobile #)
br...@brighttelecom.net
http://www.brighttelecom.net


--
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] Time zones are spinning my brain

2011-06-29 Thread Brian Dunning
Help. I'm using PayPal's API to get a report of all the yesterday's 
transactions. I'm in California, and I define yesterday as California's 
yesterday, midnight to midnight.

PayPal wants the STARTDATE and ENDDATE provided in UTC/GMT. I'm building and 
testing my report using this:

$start = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 00:00:00));
$end = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 23:59:59));

which produces:

2011-06-28T07:00:00.00Z
2011-06-29T06:59:59.00Z

I think this is right, since it's 7 hours off California time, but I just need 
someone to double check my spinning head. Will this give me the PayPal 
transactions that arrived during California's yesterday, or do I need to change 
something?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Time zones are spinning my brain

2011-06-29 Thread Brian Dunning
Thanks everyone. It seems to be working correctly. You gave me some extra peace 
of mind. I did set the date_default_timezone_set('America/Los_Angeles') but it 
looks like that was in the defaults anyway.  :-)
--
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



Re: [PHP] Convert a PDF to a PNG?

2011-06-16 Thread Brian Dunning
I have heard back from Rackspace and ImageMagick is not going to happen for the 
time being, but they say Ghostscript is installed. Is it possible to do this 
completely with GS without ImageMagick? The PDFs are text only.


On Jun 15, 2011, at 2:28 AM, Richard Quadling wrote:

 I use PDF2PNG as this provides the cleanest output mechanism I've
 found. But I didn't try GS which, theoretically, should be perfect.

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



[PHP] Best way to create an image with flowing text?

2011-06-16 Thread Brian Dunning
Hey all -

I need to create PNG images with transparent backgrounds that contain text. The 
text will come from four fields in a database, and needs to be centered, and 
text wrapped. The fields are going to be of varying lengths, so each block of 
text (which will be shown in a different font size) will flow onto an unknown 
number of lines, and I want to start the next line right below, wherever it is.

Unfortunately I have come up against some restrictions. 
- I will not be able to use ImageMagick.
- I have Ghostscript, but only version 7.07.
- The server is Red Hat 4.x with PHP 5.2 and installing new software is 
unlikely.

Can anyone suggest a tool to make this easiest? 
:-(

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



[PHP] Convert a PDF to a PNG?

2011-06-14 Thread Brian Dunning
My server has GD but NOT ImageMagick. Can I convert a PDF doc to a PNG? I have 
the PDFs stored as a files and I need to save an identical PNG alongside each.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Convert a PDF to a PNG?

2011-06-14 Thread Brian Dunning
The server does not have that software installed either.  :-(

On Jun 14, 2011, at 1:53 PM, Richard Quadling wrote:

 I do that using an external tool pdf2png. For me, I use Cygwin.
 


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



Re: [PHP] Convert a PDF to a PNG?

2011-06-14 Thread Brian Dunning
The PDFs are text only (white text on transparent background). I made them 
using the FPDF, which was tedious to set up but works great. I've since learned 
that I need PNG images, not PDFs. I know that I could rebuild them using GD, 
but it's a lot of strings of text wrapping and formatting and that would be the 
long, long way around.

I've put in a request to see about getting ImageMagick/Ghostscript installed... 
see how that goes.


On Jun 14, 2011, at 2:36 PM, Richard Quadling wrote:

 Can you see what pdf tools ARE installed?
 
 Are the PDFs text based or just images in a PDF file (mine are both),
 but for just images, you _COULD_ extract the image data manually.


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



Re: [PHP] Going crazy with include require not working

2011-06-07 Thread Brian Dunning
Thanks, this helped me solve it. FPDI extends a class in FPDF, so I simply had 
to reverse the order in which I call them and all is hunky dory.

On Jun 6, 2011, at 5:54 PM, Michael Shadle wrote:

 
 ini_set('display_errors', 1);
 


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



[PHP] Going crazy with include require not working

2011-06-06 Thread Brian Dunning
Here's my code:

error_reporting(E_ALL);
require_once('/var/www/mysite/includes/fpdi.php');
require_once('/var/www/mysite/includes/fpdf.php');

I have used fpdf many times and never had a problem with it. I've double 
checked my pathnames until I'm blue in the face. But for some reason, the 
script just STOPS at these lines. I've tried include, include_once, require, 
require_once and no error gets reported, it just stops. Help?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] webserviceX.net?

2011-04-23 Thread Brian Dunning
I'm looking for some geographic data, like ZIP codes, area codes, but it has to 
be current and correct. Has anyone ever used the free web services at 
webserviceX.net? Do you know anything about the data? How current/correct is 
it? Seems to be an awful lot they're giving away for free.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Can I modify a MySQL object?

2011-03-23 Thread Brian Dunning
Let's say I do a query:

$result = mysql_query(select * from tablename);

Is there some way I can manually update the contents of certain columns/records 
in $result? I don't want to actually update MySQL, just the results that I'm 
holding in memory for this script. Can I do it without converting it to a 
regular array?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can I modify a MySQL object?

2011-03-23 Thread Brian Dunning
I should have said modify the contents of a MySQL resource.

On Mar 23, 2011, at 5:06 PM, Brian Dunning wrote:

 Let's say I do a query:
 
 $result = mysql_query(select * from tablename);
 
 Is there some way I can manually update the contents of certain 
 columns/records in $result? I don't want to actually update MySQL, just the 
 results that I'm holding in memory for this script. Can I do it without 
 converting it to a regular array?
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Help! Made a boo-boo encrypting credit cards

2011-03-03 Thread Brian Dunning
My merchant provider levies monthly fines based on how many of their security 
restrictions you fail to follow. I follow as many as are reasonably practical, 
but I think it's virtually impossible to follow them all, such as absurdly 
expensive (and probably unnecessary) hardware. IMHO, some of the restrictions 
are based less on reality and more on their security consulting firm's ability 
to frighten them. Their consulting firm's disclosed commissions on the fines 
creates an inherent conflict of interest. 

Goofily, my provider's fine structure does not differentiate between 
transactions that are merely processed on my server with no storage, and 
transactions originating from a card number stored on my server. 

So I have to constantly weigh the monthly fines vs. the cost of the upgrades 
vs. the amount of money that my various services bring in. There is no perfect 
solution.

Nevertheless, I'm very open to any suggestions people have for transactions 
requiring that I keep the card number (in this case, recurring monthly charges 
where the customers choose not to use PayPal etc. and where too many customers 
would flake or get frustrated if forced to re-enter their card info every month 
for an annoyingly small transaction).

Sorry this is getting a little off-topic for PHP.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help! Made a boo-boo encrypting credit cards

2011-03-03 Thread Brian Dunning
That's a great suggestion. I will try this and report back. It's also been 
suggested to me that I should have base64_encoded the encryptions before 
storing them in MySQL, so I'll try this option at the same time.

On Mar 1, 2011, at 2:04 PM, Ashley Sheridan wrote:

 Onto the problem of the data you already have. Do you have a test-case that 
 causes the problem? Try running a bunch of fictitious numbers against your 
 code and store the results in your DB. For a decent test, you'll want to test 
 it against a lot of numbers, store each one in plain format in the DB (use 
 the same character encoding as you already have to see if that's part of the 
 issue) alongside the encrypted version, then retrieve the encrypted value and 
 test it against the original. It may take only a few dozen numbers to show 
 the problem, it may take a thousand, but just let it run until it finds a 
 problem.



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



Re: [PHP] Help! Made a boo-boo encrypting credit cards

2011-03-01 Thread Brian Dunning
I just wanted to ping this, as it's becoming a serious problem. I hope someone 
can help.


On Feb 11, 2011, at 2:42 PM, Brian Dunning wrote:

 Hey all -
 
 I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt 
 fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). 
 Maybe there is a character that appears in about 10% of my encryptions that's 
 not being encoded properly???
 
 // Encryption is set up at the top of the script:
 $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', '');
 $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM);
 $ks = mcrypt_enc_get_key_size($crypto);
 $key = substr(md5('my_funky_term'), 0, $ks);
 
 // When the card number is collected by the form, it's encrypted:
 $cc_number = addslashes($_POST['cc_number']);
 mcrypt_generic_init($crypto, $key, $iv);
 $cc_encrypt = mcrypt_generic($crypto, $cc_number);
 mcrypt_generic_deinit($crypto);
 
 // This is written to the database:
 $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', 
 other_fields='$other_stuff' where id='$account_id' limit 1;
 $result = mysql_query($query) or die(mysql_error());
 
 Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, 
 MyISAM, MySQL 5.0.91
 
 In another script, when I retrieve, I first set it up at the top of the 
 script exactly like step #1 above, then retrieve it like this:
 
 mcrypt_generic_init($crypto, $key, $row['encrypt_iv']);
 $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt']));
 mcrypt_generic_deinit($crypto);
 
 Most of them are good, a few of them are bad. Can anyone see anything I'm 
 doing wrong or a case I'm not covering? Thanks much.
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] chat facebook

2011-02-19 Thread Brian Waters
2011/2/19 fakessh @ fake...@fakessh.eu:
 anyone have a recipe for it on facebook chat

a recipe for what?

 and I request a second thing
 how to install PHP API

you're going to have to be more specific than that.

- BW

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Brian Waters
On Tue, Feb 15, 2011 at 12:52 PM, tedd tedd.sperl...@gmail.com wrote:
 At 11:37 AM -0600 2/15/11, Nicholas Kell wrote:

 On Feb 15, 2011, at 10:51 AM, tedd wrote:
   At 8:26 PM -0500 2/14/11, Brian Waters wrote:
   (if that's OK). I know that PHP sometimes has a reputation for having
   (some) lousy developers, and I'd like to avoid becoming one of those
  
   We don't agree that PHP has a reputation of having some lousy
 developers -- because that's simply not true.

 Humm I seem to agree with the OP. But, that being said, unlike most
 language fanboys PHP'ers usually fully admit it.


 I guess that we run in different worlds. Most of the PHP programmers I know
 are very good.

I didn't mean to suggest anything. Nor do I necessarily subscribe to
the idea (that PHP has some lousy developers). It's just something
I've heard bouncing around - probably on those noisy internet forums.

- BW

P.S:

On Tue, Feb 15, 2011 at 11:51 AM, tedd tedd.sperl...@gmail.com wrote:
 PS: We seldom point out spelling errors, but it's good to review what you
 post. Remember, what you post will be public for generations to come.

I'm aware that I misspelled viciously in my original post but was
too lazy to rectify the situation.

P.P.S, Apologies for backchanneling tedd there; I'm used to mailing
lists with a default Reply-To: t...@mailinglist.com header.

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Brian Waters
On Tue, Feb 15, 2011 at 3:37 PM, tedd tedd.sperl...@gmail.com wrote:
 So, I took a *weekend* and programmed about 90 percent of application in
 FutureBasic. I then created a shell application and forwarded it to the
 client.

 After receiving the application, the client said Yes, this is exactly what
 I want -- except I want it in C++.

Of course, that's a ridiculous reason to choose one language over
another. But to augment what you're saying, sometimes certain
languages are chosen because of the availability of libraries and
tools, and, more importantly, because of the availability of skilled
programmers. That's especially important if a client has to expand and
modify a solution in the future.

- BW

PS, Once again, tedd, apologies for backchanneling you...

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



[PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Brian Dunning
Hey all -

I've got long articles, the HTML for which comes out of MySQL. Works great. I 
want to split it up so that I can insert ad blocks at various points within it. 
The articles are all pretty long but they're of variable length. I want to chop 
them up into three close-to-equal (doesn't have to be) chunks of paragraphs, 
thus:

pHere's the original article/p
pHere's the original article/p
pHere's the original article/p
pHere's the original article/p
pHere's the original article/p

Would become:

pHere's the original article/p
pHere's the original article/p
?php include('first_ad'); ?
pHere's the original article/p
pHere's the original article/p
?php include('second_ad'); ?
pHere's the original article/p

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



Re: [PHP] Rate my (really) simple template class

2011-02-15 Thread Brian Waters
On Mon, Feb 14, 2011 at 11:49 PM, Paul M Foster pa...@quillandmouse.com wrote:
 Advice: don't use eval() this way. It's slow and dangerous.

Could you elaborate, or provide a link?

 ...read in the file and pass it to you on the stack, which is
 really an abuse of the stack if you can avoid it.

Interesting. I'm used to statically-typed languages. Normally I never
would have passed a large structure like that on the stack. But then
again, in those languages, large structures are usually passed by
reference, by default. In C, the only way to pass a string or array by
value is to wrap it in a struct, and in Java, objects are passed by
reference (if I recall correctly).

Guess that's something to get used to.

- BW

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



Re: [PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Brian Dunning
Yes, thanks, what I'm looking for is how to do that.

On Feb 15, 2011, at 1:38 PM, Simon J Welsh wrote:

 Assuming you're only using p tags, count the number of opening p tags, 
 divide by three. First ad block goes after the round($amount/3)-th /p, 
 second ad block goes after the round($amount/3*2)-th /p.
 ---
 Simon Welsh


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



Re: [PHP] Help! Made a boo-boo encrypting credit cards

2011-02-14 Thread Brian Dunning
On Feb 13, 2011, at 12:44 AM, Richard Quadling wrote:

 You are
 using addslashes($_POST['cc_number']). Considering a credit card
 number is purely numeric, the addslashes would seem to be redundant as
 you don't need to escape numbers.

I do that routinely to all input fields as one additional layer of protection 
against injection attacks.


 And you can run a Luhn10 check
 against the card number to make sure it is valid before storing it.

I do that as well.


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



[PHP] Howdy (new in here)

2011-02-14 Thread Brian Waters
Hi everyone! I'm just starting out with PHP so I'm looking for a good
place to ask some questions, have my code critiqued (read: visciously
ripped apart), and generally BS about PHP and programming in general
(if that's OK). I know that PHP sometimes has a reputation for having
(some) lousy developers, and I'd like to avoid becoming one of those
people. To that end, I've subscribed here because I've always found
mailing lists to have much higher-quality discourse than the average
online foum.

Looking forward to participating!

- BW

P.S, The rules page on the web
(http://us2.php.net/reST/php-src/README.MAILINGLIST_RULES) is
currently broken, but this one works:
http://us2.php.net/reST/php-src/trunk_README.MAILINGLIST_RULES. Just a
heads up to whoever is in charge of that.

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



[PHP] Rate my (really) simple template class

2011-02-14 Thread Brian Waters
So I decided to write a template class in order to get myself going on
learning PHP. Of course I wrote the simplest thing possible:

class Template
{
protected $template;
protected $vars;

public function __construct($template)
{
$this-template = $template;
}

public function __set($name, $value)
{
$this-vars[$name] = $value;
}

public function __get($name)
{
return $this-vars[$name];
}

public function __toString()
{
ob_start();
eval('?' . $this-template);
return ob_get_clean();
}
}

Which you can use, quite simply like this:

$tpl = new Template(file_get_contents('index.tpl.php'));

$tpl-title = 'Here\'s the title';
$tpl-text = 'Blah blah blah...';

echo $tpl;

I have a few questions though.

- First, I'm storing the template as an actual string, instead of just
a path to a template file, which means I'm using eval() instead of
require() in my __toString(). My thinking was that this would avoid
reading the template file twice in the case that __toString() gets
called multiple times. But will PHP handle this automagically if I do
in fact decide to store a path to a file, and call require() instead?

- Secondly, I noticed that in the constructor, it's not necessary to
initialize $vars to an empty array, and I haven't done so. I guess PHP
automatically initializes it the first time I set one of its elements
to a value. Is this okay, or is there a better way in the name of best
practices?

- Finally, I'd like to be able to limit what things can be accessed
from the scope of the template file. As it stands, if you have a
function named blowUpTheComputer() or a gobal variable called
$dontTouchThis, a template author can easily cause trouble. They can
also access any methods and properties of the Template class. How
would you go about restricting this?

Thanks a lot!

- BW

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



[PHP] Help! Made a boo-boo encrypting credit cards

2011-02-11 Thread Brian Dunning
Hey all -

I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt 
fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). 
Maybe there is a character that appears in about 10% of my encryptions that's 
not being encoded properly???

// Encryption is set up at the top of the script:
$crypto = mcrypt_module_open('rijndael-256', '', 'ofb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM);
$ks = mcrypt_enc_get_key_size($crypto);
$key = substr(md5('my_funky_term'), 0, $ks);

// When the card number is collected by the form, it's encrypted:
$cc_number = addslashes($_POST['cc_number']);
mcrypt_generic_init($crypto, $key, $iv);
$cc_encrypt = mcrypt_generic($crypto, $cc_number);
mcrypt_generic_deinit($crypto);

// This is written to the database:
$query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', 
other_fields='$other_stuff' where id='$account_id' limit 1;
$result = mysql_query($query) or die(mysql_error());

Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, 
MyISAM, MySQL 5.0.91

In another script, when I retrieve, I first set it up at the top of the script 
exactly like step #1 above, then retrieve it like this:

mcrypt_generic_init($crypto, $key, $row['encrypt_iv']);
$cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt']));
mcrypt_generic_deinit($crypto);

Most of them are good, a few of them are bad. Can anyone see anything I'm doing 
wrong or a case I'm not covering? Thanks much.


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



[PHP] How to define a data range for graphing?

2010-12-17 Thread Brian Dunning
Hey all -

I'm trying to provide reporting to users of our widget. Some may get 0 to 5 
hits a day; others may get up to 10,000 hits a day. I need to define the range 
of the graph (using one of Google's). If their max day is 7, I'd like the graph 
to go from 0 to 10. If their max day is 5678, I'd probably like it to go from 0 
to 6000. I'm guessing the way to do this is with a ceiling function?

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



[PHP] Help with sending credentials?

2010-10-14 Thread Brian Dunning
Gents -

I'm trying to work with a major vendor's web service, but all my efforts are 
met with a 401 authentication error response. I can log in manually to this URL 
using these credentials through a browser, so I know the credentials are good. 
Unfortunately the support guys at the vendor don't see any problem with my code 
and have not been able to help.

$url = https://servername.com/script;;
$ctx = stream_context_create(array('https' = array(
'timeout' = 10,
'header'  = sprintf(Authorization: Basic %s\r\n, 
base64_encode(myUsername:myPassword))
)));
$result = file_get_contents($url, 0, $ctx); 
$http_response = explode(' ', $http_response_header[0]);
$response_code = $http_response[1]; === This is evaluating to '401'


Thanks.
--
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:
?php
class foo {}
$db = new foo();
$outA = barA();
function barA() { global $db; include(Application B); }
?

Application B:
?php
class bar {}
$db = new bar();
$outB = barB();
function barB() { global $db; }
?

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



[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] SimpleXML/array duality (like particles waves)

2010-09-28 Thread Brian Dunning
I am kind of jacked here. I have a SimpleXML object that's been converted to an 
array. In one of the nodes, for no reason I can see, the array is populated 
differently if there is only one order_item than if there are multiple 
order_items.

If there is just one, my $order_item array looks like this:
Array
(
[order_item_product_code] = 1300
[order_item_description] = 4x8 photo cards (set of 20)
)

But if there are multiple items, I get this:
Array
(
[0] = SimpleXMLElement Object
(
[order_item_product_code] = 1060
[order_item_description] = 4x5.3 trueDigital print(s)
)

[1] = SimpleXMLElement Object
(
[order_item_product_code] = 1300
[order_item_description] = 4x8 photo cards (set of 20)
)
)

See my problem? I can't foreach through those and process the items in the same 
way.

In case it matters, here is that snip of what the original XML looks like, it's 
all good:
?xml version=1.0 encoding=UTF-8?
order xmlns=http://.com/; version=1.0
  order_items
order_item
  order_item_product_code finish=glossy1060/order_item_product_code
  order_item_description4x5.3 trueDigital 
print(s)/order_item_description
/order_item
order_item
  order_item_product_code finish=glossy1300/order_item_product_code
  order_item_description4x8 photo cards (set of 
20)/order_item_description
/order_item
  /order_items
/order

And here is the function I'm using to convert the XML to an array:
function xmlToArray($xml, $isChild = false) {
if($xml instanceof SimpleXMLElement) {
$xmlObject = $xml;
} elseif($isChild) {
return $xml;
} else {
try {
$xmlObject = new SimpleXMLElement($xml);
} catch(Exception $e) {
$string = $e-getMessage();
throw new Exception('Invalid XML found in ' . 
__FUNCTION__ . ' function on line '.__LINE__.'.');
}
}
$children = (array)$xmlObject-children();
if(is_array($children)) {
if(count($children) == 0) {
$children = '';
} else {
foreach($children as $element = $value) {
$children[$element] = xmlToArray($value, true);
}
}
}
return $children;
}

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



Re: [PHP] SimpleXML/array duality (like particles waves)

2010-09-28 Thread Brian Dunning
If you read down to the bottom of the post, the function I used is given.


On Sep 28, 2010, at 3:47 PM, Nathan Nobbe wrote:

 On Tue, Sep 28, 2010 at 4:29 PM, Brian Dunning br...@briandunning.com wrote:
 I am kind of jacked here. I have a SimpleXML object that's been converted to 
 an array.
 
 how was the SimpleXMLElement converted to an array?
 
 -nathan 



[PHP] Can't read $_POST array

2010-08-18 Thread Brian Dunning
I'm trying to write a VERY simple script that does nothing but store all the 
submitted GET and POST vars in a string and echo it out.

$response = print_r($_REQUEST, true);
echo $response;

The problem is it only shows GET vars. I've tried $POST instead of $_REQUEST 
and it always gives an empty array. I've got it on two different servers, and 
we have three guys trying various methods of submitting forms to it, trying to 
eliminate all potential problems, like the possibility that the request might 
not actually have any POST vars. I think we've safely eliminated these 
possibilities.

Can anyone see a reason why the above should not see POST vars? Is there some 
security setting I don't know about?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't read $_POST array

2010-08-18 Thread Brian Dunning
Sorry, my typo, $_POST is one of the options we tried, not $POST. It returns an 
empty array also.



On Aug 18, 2010, at 1:50 PM, Joshua Kehn wrote:

 On Aug 18, 2010, at 4:45 PM, Brian Dunning wrote:
 
 I'm trying to write a VERY simple script that does nothing but store all the 
 submitted GET and POST vars in a string and echo it out.
 
 $response = print_r($_REQUEST, true);
 echo $response;
 
 The problem is it only shows GET vars. I've tried $POST instead of $_REQUEST 
 and it always gives an empty array. I've got it on two different servers, 
 and we have three guys trying various methods of submitting forms to it, 
 trying to eliminate all potential problems, like the possibility that the 
 request might not actually have any POST vars. I think we've safely 
 eliminated these possibilities.
 
 Can anyone see a reason why the above should not see POST vars? Is there 
 some security setting I don't know about?
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 You have to use $_POST for the post data.
 
 Regards,
 
 -Josh
 
 Joshua Kehn | josh.k...@gmail.com
 http://joshuakehn.com
 


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



Re: [PHP] Can't read $_POST array

2010-08-18 Thread Brian Dunning
This was the complete code of the page (this is the POST version not the 
REQUEST version):

?php
$response = print_r($_POST, true);
echo $response;
?

Returns an empty array no matter what POST vars are sent. We fixed it by 
changing it to this, which I've never even heard of, but so far is working 
perfectly:

?php
$response = file_get_contents('php://input');
echo $response;
?

I have no idea what the problem was. Thanks to everyone for your help.


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



[PHP] Battle of Spam

2010-06-07 Thread Brian Dunning
Hey - It looks like a PHP form on my server is insecure and is being used to 
send spam. This is Rackspace's best guess. The problem is there are SO MANY 
forms on all the web sites on this server that it would be a nightmare task to 
try and look at them all to be sure they're properly secured.

Is anyone aware of a way to shortcut this process, maybe find out what 
script(s) are being attacked to send the spam?

:-(


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



Re: [PHP] Battle of Spam

2010-06-07 Thread Brian Dunning
Agreed that's a great overall strategy but what I need now is a way to track 
down the offending script, within the next few days if possible.

On Jun 7, 2010, at 1:35 PM, Jim Lucas wrote:

 Change all the forms to use a single
 processing script and then you won't have such a big problem tracking down the
 information processing error/insecurity that you are having.



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



Re: [PHP] Battle of Spam

2010-06-07 Thread Brian Dunning
I think I must have misstated the problem. Thanks to everyone for the replies, 
but the question is not how to fix it, it's how to find the script being 
attacked. Many different admins manage many different sites on this server, and 
I can't even begin to guess how many mail forms are on there from different 
programmers.

I'm currently downloading the logs as Peter suggested, and will take a look. 
I'm not much of a sysad and I just thought maybe someone might know a way to 
sniff outgoing email or something, I really don't know how to attack this. 
Fixing the scripts is a long term solution, obviously, but I need a short term 
fix other than killing email on the apache account.

Might be more of a Linux question than a PHP question.


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



Re: [PHP] Battle of Spam

2010-06-07 Thread Brian Dunning
I'm currently geotargeting all the IPs in the log, and focusing on the hits 
from Russia (the majority of these apache@ spams seem to be Russian). I've got 
a much shorter list of scripts to look at now. Hopefully I'll find some that 
just use mail() with no scrubbing.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Help, FPDI is changing the size of my PDFs

2010-05-21 Thread Brian Dunning
I'm using FPDI to add some stuff to some existing PDF documents. Works great, 
except that it's slightly changing the size of the PDF document (the physical 
page size, not the file size), which is unacceptable since this is for a 
high-end print file. I've stripped out all the code to the bare bones to try 
and debug this. Here is what I have:

$pdf = new fpdi();
$pdf-AddPage();
$pdf-setSourceFile('D:\\DocShare\\'.$filename);
$tplidx = $pdf-importPage(1);
$pdf-useTemplate($tplidx);
$pdf-Output('newpdf.pdf', 'D');

When I have PHP output the raw original PDF file, it measures 8.34x11.12. If 
I process it with the above code, the output measures 8.27x11.7 with a blank 
white band added along the bottom. Any suggestions? I just need the new file to 
be the same size as the original. Thanks!

Re: [PHP] Help, FPDI is changing the size of my PDFs

2010-05-21 Thread Brian Dunning
Solved it. Here's the solution:

$pdf = new fpdi();
$pdf-setSourceFile('D:\\DocShare\\'.$filename);
$tplidx = $pdf-ImportPage(1);
$s = $pdf-getTemplatesize($tplidx);
$pdf-AddPage($s['h']  $s['w'] ? 'P' : 'L', array($s['w'], $s['h'])); // This 
gets it the right dimensions
$pdf-useTemplate($tplidx, 0, 0, 0, 0, true);
$pdf-Output('newpdf.pdf', 'D');



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



[PHP] 2D barcodes

2010-05-11 Thread Brian Dunning
I have a project where I need to add some 2D barcodes onto some PDF files. I 
plan to use fpdi, since I've used it before and am familiar with it, but I need 
a source to generate the 2D barcodes, preferably as a png or jpg. Anyone have a 
suggestion - either a local classfile or a reliable web service? Free is 
preferred.  :-)


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



Re: [PHP] PHP Encoder like IonCube

2010-05-11 Thread Brian Dunning
Hi Shiplu -

I also have a product with similar requirements. I searched a LOT and was never 
able to find a free solution that I was satisfied with. Even a lot of the 
commercial solutions required some server-side runtime EXE or something be 
installed, and my customers are not tech savvy enough to get that going.

I ultimately settled on PHP Lockit, which is $29. It's a Windows program that 
you run to create an obfuscated version of your script. I'm very satisfied with 
the obfuscation, and it does not require any external runtime files or 
anything. Works like a charm, and I recommend it.

http://phplockit.com/

- Brian

On May 9, 2010, at 1:36 PM, shiplu wrote:

 Is there any php encoder like IonCube ?
 Looking for an opensource solution.
 My main target is to deliver encoded php codes so that it can not be
 re-engineered.




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



Re: [PHP] PHP Encoder like IonCube

2010-05-11 Thread Brian Dunning
Totally agree. But just in case it wasn't clear, you only need a Windows 
computer once to run the obfuscator; once done the code runs on any PHP server.


On May 11, 2010, at 5:06 PM, Ashley Sheridan wrote:

 Does slightly limit you to the Windows platform though, which I always think 
 is a shame when using a language as open as PHP.





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



Re: [PHP] simplexml choking on apparently valid XML - Solved

2010-05-10 Thread Brian Dunning
I was able to resolve this by changing the XML file encoding from UTF-8 to 
ISO-8859-1. Works like a charm now, with the XML-encoded characters.

Thanks to all who offered their help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] simplexml choking on apparently valid XML

2010-05-07 Thread Brian Dunning
This time simplexml-load-string also gave me the same error on the following 
line:

first_nameCharlie amp; Brady/first_name

Can anyone confirm whether simplexml-load-string will or will not accept or 
allow XML-encoded characters? It seems that it should and would be pretty 
surprising if it wouldn't.



On May 6, 2010, at 5:02 PM, Brian Dunning wrote:

 Hey all -
 
 I'm using simplexml-load-string just to validation a string of XML, and 
 libxml-get-errors to return any errors. It's always worked before, but today 
 it's choking on this line in the XML:
 
 client_orderitem_numberBasketball Personalized Notebook - 
 Jeffapos;s/client_orderitem_number
 
 It's returning Premature end of data in tag client_orderitem_number line 90 
 but as far as I can tell, Jeffapos;s is properly XML encoded. I can't debug 
 this. Any suggestions?
 
 I have run the XML through a couple of online validators and it does come 
 back as valid with no errors found.
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] simplexml choking on apparently valid XML

2010-05-06 Thread Brian Dunning
Hey all -

I'm using simplexml-load-string just to validation a string of XML, and 
libxml-get-errors to return any errors. It's always worked before, but today 
it's choking on this line in the XML:

client_orderitem_numberBasketball Personalized Notebook - 
Jeffapos;s/client_orderitem_number

It's returning Premature end of data in tag client_orderitem_number line 90 
but as far as I can tell, Jeffapos;s is properly XML encoded. I can't debug 
this. Any suggestions?

I have run the XML through a couple of online validators and it does come back 
as valid with no errors found.


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



[PHP] Simple code obfuscation

2010-02-08 Thread Brian Dunning
Hey all -

I'm selling a custom PHP solution to FileMaker users. It uses FileMaker's PHP 
API, so everyone who has FileMaker Server is already set up to use it, but very 
few of them have any knowledge of how to set up a server or do anything PHP 
related. But I do want to add some level of code obfuscation to prevent them 
from making simple changes to my code that allow them to exceed the privileges 
they've purchased.

I've looked at custom code encryption services like Ioncube and phpCipher, but 
in my estimation, deploying the needed server-side code for these is going to 
be beyond the capabilities of a large segment of my customers. I would rather 
have a few customers cheat me than offer a product that most customers are 
unable to figure out how to run.

So I was thinking of doing something like base64_encoding the crucial chunk of 
my code (maybe 20 lines worth) and using eval(base64_decode($that_content)) to 
run it. I figure that will scare away most of the customers who might be able 
to edit my code. Can anyone suggest something that goes one better?

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



[PHP] Can't get my PHP-generated RSS to serve properly

2010-02-03 Thread Brian Dunning
Hey all -

Glad some of you found that sample data helpful.   :-)

I use PHP/MySQL to generate RSS feeds of my podcasts. The feed is submitted as 
*.xml and I use .htaccess to redirect it to my PHP document. The start of the 
document sets the right header and outputs the ?  ? to prevent PHP from 
trying to process the leading XML line as code (this is cleaned up a bit for 
readability):

?php
header(content-type: application/rss+xml);
echo '?';
?
xml version=1.0 encoding=UTF-8
?php
echo '?';
?
rss xmlns:itunes=http://www.itunes.com/dtds/podcast-1.0.dtd; 
xmlns:atom=http://www.w3.org/2005/Atom; version=2.0

This has always worked fine on one podcast, but on a new one it's not. You can 
see the results here:
http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Finfactvideo.com%2Fpodcast.php

It's throwing a 500 error, a parsing error, and complaining that feeds should 
not be served with the text/html type, even though I'm serving the right 
header. Other PHP pages on this site work fine, and there are no special Apache 
directives on my site that works that are missing here. Can anyone suggest what 
I might be missing?

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



Re: [PHP] Can't get my PHP-generated RSS to serve properly

2010-02-03 Thread Brian Dunning
Ugh. Stupid me. Thanks Robert. It was a type elsewhere in my code further down 
the page. I was so hung up thinking it was an encoding or MIME or delivery 
problem I didn't think to check my PHP.

Someone slap me upside the head please.


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



Re: [PHP] Good source for sample data?

2010-01-29 Thread Brian Dunning
Thanks for the suggestions but I couldn't find any that suited my needs, so I 
made my own. Feel free to download if you can use them, I made files with up to 
a million unique records.

Name, Company, Address, Phone, Email, etc., all are fake but are real addresses 
with correct area codes, zips, exchange, so will work for mapping, phone or 
address validation, whatever your needs are. Hope someone find it useful.

http://www.briandunning.com/sample-data/

On Jan 28, 2010, at 3:52 PM, Brian Dunning wrote:

 I need a few million sample contact records - name, company, address, email, 
 web, phone, fax. ZIP codes and area codes and street addresses should be 
 correct and properly formatted, but preferably not real people or companies 
 or email addresses. But they'd work if you did address validation or mapping. 
 Anyone have a suggestion?

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



[PHP] Good source for sample data?

2010-01-28 Thread Brian Dunning
Hey all -

I need a few million sample contact records - name, company, address, email, 
web, phone, fax. ZIP codes and area codes and street addresses should be 
correct and properly formatted, but preferably not real people or companies or 
email addresses. But they'd work if you did address validation or mapping. 
Anyone have a suggestion?

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



[PHP] Emergency! Performance downloading big files

2009-12-01 Thread Brian Dunning
This is a holiday-crunch emergency.

I'm dealing with a client from whom we need to download many large PDF docs 
24x7, several thousand per hour, all between a few hundred K and about 50 MB. 
Their security process requires the files to be downloaded via https using a 
big long URL with lots of credential parameters.

Here's how I'm doing it. This is on Windows, a quad Xeon with 16GB RAM:

$ctx = stream_context_create(array('http' = array('timeout' = 1200)));
$contents = file_get_contents($full_url, 0, $ctx);
$fp = fopen('D:\\DocShare\\'.$filename, w);
$bytes_written = fwrite($fp, $contents);
fclose($fp);

It's WAY TOO SLOW. I can paste the URL into a browser and download even the 
largest files quite quickly, but the PHP method bottlenecks and cannot keep up.

Is there a SUBSTANTIALLY faster way to download and save these files? Keep in 
mind the client's requirements cannot be changed. Thanks for any suggestions.



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



Re: [PHP] Emergency! Performance downloading big files

2009-12-01 Thread Brian Dunning
Oops, it's several hundred per hour, several thousand per day. Sorry for the 
accidental superlative.

 I'm dealing with a client from whom we need to download many large PDF docs 
 24x7, several thousand per hour, all between a few hundred K and about 50 MB. 



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



Re: [PHP] Emergency! Performance downloading big files

2009-12-01 Thread Brian Dunning
Can someone explain how this would work? It's a Windows web server running IIS 
and the files are saved to a drive that is outside the web root. PHP is 
grabbing each filename from a MySQL database, along with the URL and 
credentials for it, and ends up with a url something like this:
https://server.com?filename=filename.pdfuser=xxxpass=xxxsomething=xxx


On Dec 1, 2009, at 2:55 PM, Ashley Sheridan wrote:

 Why not put the files behind a secured directory. Apache will handle
 that, so PHP needs not be involved. Once logged in, they can download
 loads without it being asked for again.



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



Re: [PHP] Re: Checkbox in PHP form

2009-11-08 Thread Brian Hazelton

input class=text id=myCheck1 type=checkbox ?php if ( $row[33] ==
'no') { echo checked=checked;  } ? value=PFDs
name=f_sequipment1/bfont size=2PFDsb


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



Re: [PHP] � Frontier Acela High Performan ce Fume Hoods

2009-11-03 Thread Brian Hazelton

My guess is that it is some sort of spam.

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



[PHP] Cookie Quandary

2009-10-27 Thread Brian Dunning
I wrote some cookies for a whole bunch of site admins, but failed to  
set the path, so all the cookies are set to '/admin', which is not  
going to work for everything they need to do. They are also too long,  
set for 6 months.


I need to correct both issues, so I changed it to write cookies to '/'  
for 72 hours. I've checked my Safari, and I see that I have both  
cookies set: A long one for '/admin' and a short one for '/'. I'm  
worried that once the admins' short cookies run out, their browsers  
will pick up the longer lasting value for the '/admin' version of the  
cookie.


I want to kill everyones' '/admin' cookies, but I'm worried that some  
browsers might erase both cookies if I do this. Does anyone know if I  
can safely kill the '/admin' cookie without risking deletion of the  
'/' cookie?



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



Re: [PHP] Cookie Quandary

2009-10-27 Thread Brian Dunning
No, I'm talking about cookies, thus the references to pathnames and  
expirations.


On Oct 27, 2009, at 10:56 AM, Ashley Sheridan wrote:


Cookies are client-side. Do you mean session files?




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



[PHP] getcsv error

2009-10-25 Thread Brian Hazelton
I have a script which uploads csv data into a database. This works well 
and has worked in every instance so far. However what I am noticing is 
that today, even if I escape the data before putting it into mysql it 
will not enter a line if it has a single quote, once I take out the 
single quote it enters it into the database so I know it is the single 
quote, is this an error or are single quotes not allowed in csv...?



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



Re: [PHP] getcsv error

2009-10-25 Thread Brian Hazelton

Brian Hazelton wrote:
I have a script which uploads csv data into a database. This works 
well and has worked in every instance so far. However what I am 
noticing is that today, even if I escape the data before putting it 
into mysql it will not enter a line if it has a single quote, once I 
take out the single quote it enters it into the database so I know it 
is the single quote, is this an error or are single quotes not allowed 
in csv...?



I figured out part of the problem. The problem lies with one of my 
functions for cleaning the data before putting it into the database. I 
have a function, see below, that will clean the data to put into mysql 
and work whether magic quotes is on or off. It is not working because I 
echo the query and the part I need escaped is not being escaped. I try 
mysql_real_escape_string and it is being escaped by that so I think the 
problem is something with my function, if anyone can help that would be 
appreciated.


function clean($str){
   if(get_magic_quotes_gpc()){
   stripslashes($str);
   mysql_real_escape_string($str);
   return $str;
   }
   else{
   mysql_real_escape_string($str);
   return $str;
   }
}



$name = 'O'Leksy';
$cleaned_name = clean($name);

echo of $cleaned name = O'Leksy';
if mysql_real_escape_string is used it echoes O\'Leksy';


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



Re: [PHP] getcsv error

2009-10-25 Thread Brian Hazelton

Brian Hazelton wrote:

Brian Hazelton wrote:
I have a script which uploads csv data into a database. This works 
well and has worked in every instance so far. However what I am 
noticing is that today, even if I escape the data before putting it 
into mysql it will not enter a line if it has a single quote, once I 
take out the single quote it enters it into the database so I know it 
is the single quote, is this an error or are single quotes not 
allowed in csv...?



I figured out part of the problem. The problem lies with one of my 
functions for cleaning the data before putting it into the database. I 
have a function, see below, that will clean the data to put into mysql 
and work whether magic quotes is on or off. It is not working because 
I echo the query and the part I need escaped is not being escaped. I 
try mysql_real_escape_string and it is being escaped by that so I 
think the problem is something with my function, if anyone can help 
that would be appreciated.


function clean($str){
   if(get_magic_quotes_gpc()){
   stripslashes($str);
   mysql_real_escape_string($str);
   return $str;
   }
   else{
   mysql_real_escape_string($str);
   return $str;
   }
}



$name = 'O'Leksy';
$cleaned_name = clean($name);

echo of $cleaned name = O'Leksy';
if mysql_real_escape_string is used it echoes O\'Leksy';


Sorry for all of the posts. I got it figured out, it was just me being 
stupid. Since this data isnt coming from get, post or cookies then 
calling this function will still work but no slashes are getting added 
so when the stripslashes function is called it returns an error and will 
not continue to work because it does not return the string on error.


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



[PHP] Ubuntu and Apache

2009-10-24 Thread Brian Hazelton
I know this is not quite on topic but I do not know where else to turn. 
I needed to reinstall ubuntu and now I cannot change myself to be the 
owner of var www. I had been able to change myself to the owner of it 
and create, delete and modify any files I wanted before I had to 
reinstall. Now it seems the change is not taking effect. What happens  
is I use the sudo chown command and it shows that I am the owner. I have 
a script that creates a file when I go to the page and it creates a file 
and has www-data as the owner, not me. What am I doing wrong?

Thanks,
Brian

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



Re: [PHP] PHP broadcast mailer

2009-10-17 Thread Brian Hazelton
I thought about doing a batch email, is that an accepted practice, also 
how do I find my smtp server limit?


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



[PHP] PHP broadcast mailer

2009-10-16 Thread Brian Hazelton
I am in charge of an email newsletter list and making sure it gets sent 
out in time. My problem is I have never done broadcast emailing and 
right now we have 400 subscribers but want to build a system that can 
scale well regardless of the number of subscribers. Right now I use 
mysql to store the email and use phpmailer in a loop to send an email to 
each of the emails in the db, it is already slow with just 400(takes 
around 10 min (i think that's slow isnt it?). Has anyone built a 
broadcast email script and willing to help me?


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



[PHP] Really quick try/catch question

2009-08-18 Thread Brian Dunning

I have a new SimpleXMLElement() that is occasionally throwing:
'Exception: String could not be parsed as XML'

Will this catch it when it happens, or am I missing something?

function domyfunction() {
// This does some stuff to exit the script gracefully
}

try {
$xmlobject = new SimpleXMLElement($xml);
} catch($e) {
domyfunction($e);
}



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



Re: [PHP] Server change affecting ability to send downloaded files???

2009-08-08 Thread Brian Dunning
A Rackspace guy determined that php.ini was set to use 16MB of memory,  
and he upped it to 32MB, and now everything works. Some of my  
downloads are as large as 41MB so I asked him to up it to 48MB.


Maybe they upgraded the PHP version or something and wiped this  
setting. The 41MB files had always been downloading to customers  
before, without any problem -- is there some way that could have  
worked with php.ini set to 16MB, or does this mean for sure that the  
setting was changed somehow?



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



[PHP] Server change affecting ability to send downloaded files???

2009-08-07 Thread Brian Dunning

Hey all --

A couple of weeks ago my online stores, on a machine I host at  
Rackspace, stopped delivering files that people purchase. I've used  
this for years, and it's always worked perfectly with all filetypes:


header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='. 
$file_row[filename].'');

$size = filesize('../../store/files/'.$file_row['filename']);
header('Content-Length: '.$size);
readfile('../../store/files/'.$file_row['filename']);

But then, all of a sudden, it only works with ZIP files. There were no  
changes to the code or to the files, just one day all of a sudden any  
time someone purchases a DMG, EXE, PDF, etc. they get zero bytes. I've  
asked Rackspace if they upgraded something that might produce this  
change but they say check your code. The code had not been touched  
in years (literally). I've tried a zillion combos of different headers  
but I'm having no luck.


Has anyone ever heard of something (besides my code and my files) that  
could cause this behavior? You'll be my best friend if you can help.  
Thanks.




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



  1   2   3   4   5   6   7   8   9   10   >