[PHP] Re: [PHP-DEV] Re: [PHP] mod_php

2010-09-27 Thread Richard Lynch
On Fri, August 20, 2010 1:15 pm, Stanisław Findeisen wrote:
> On 2010-08-20 17:10, Bostjan Skufca wrote:
> 1. What optimizations does PHP interpreter make? I guess it should be
> able to check file modification time and cease to compile it again and
> again. Is this correct?

PHP does not do that.
There are opcode caches such as APC which do.
And APC is rumored to be rolled into the next release, or perhaps is
available in 5.3 already.

> There is some bytecode form, right?

Yes, PHP compiles to bytecode.

> What else does it do? For instance if there is a big, immutable class
> in
> the application (say it contains a bunch of constant XML documents,
> hardcoded into the source): will the interpreter notice that and
> instantiate this class only once across multiple requests?

No.
PHP is a "shared nothing" architecture, by design.
Scaling is accomplished by simply tossing more boxes in, with no
worries about shared resources being out of sync.

> What if this class generates side effects (like printing "hello world"
> in the constructor) and what if it doesn't?

PHP has nothing so formal about "side effects" or the lack thereof.
That's up to the application developer to worry about.

> 2. I guess PHP application wide cache is quite a different story? For
> the worker processes are separate... Or maybe PHP interpreter itself
> provides any means for that??

Again, it's a Shared Nothing architecture by design.
It's not Java.
It's not even ASP.
It's PHP, and we *like* it that way. KISS

> 3. Does PHP interpreter maintain any state across different requests
> within the context of a single Apache worker process? If so, what does
> this state contain?

PHP does not maintain state, as HTTP is a stateless protocol.

Technically, this is not 100% true, as I'm sure there is *something*
down in the guts of the C code that has some kind of "state" but it's
sure not available in userland PHP code.

> 4. Does PHP interpreter maintain any global state within the context
> of
> a single Apache HTTP server instance? If so, what does this state
> contain?

No.

> 5. What about system wide PHP interpreter state?...

No.

> 6. I heard some nasty rumors that PHP interpreter resource management
> is
> somewhat problematic (memory leaks, or something), and because of that
> those Apache worker processes have to be killed from time to time.
>
> Could you please comment on this?

It is trivial to create long-running scripts that "leak" memory by not
clearing variables.

PHP's garbage collector is simplistic, even rudimentary in nature.

But most PHP scripts are designed to spit out a web page in microseconds.

At the end of the script, everything is released.

So, it *CAN* be problematic if:
A) you're using PHP for long-running scripts and
B) you don't have enough sense to wipe out variables that will keep
tons of RAM in use.

-- 
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE



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



[PHP] ldap_search filter filter?

2010-07-16 Thread Richard Lynch
Any Best Practice suggestions for potentially hostile user input being
sent to ldap_search($ldap, "(username=$_POST[username])");

Something like an ldap_escape?

Please cc me on replies. Thanks.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] mysql_real_escape_string(0xffffffff) yields -1

2010-01-15 Thread Richard Lynch
The subject line says it all:

mysql_real_escape_string(0x) yields -1

What's up with that?

Is there some way to convince mysql_real_escape_string to use BIGINT?

I guess I'll just PCRE for digits and then pass it in and...

But what if somebody passes in some BC Math number?...

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] imagerotate bug?

2009-12-25 Thread Richard Lynch
Can anybody email me off-list to comment on whether the bug
demonstrated here for imagerotate is fixed in current PHP?

http://6112northwolcott.com/dogfight/rotate.htm

All the backgrounds should be white, not black.

I can't easily test on a newer version of PHP at the moment.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] mysql_real_escape_string paranoid enough?

2009-03-20 Thread Richard Lynch
I typically do something like this:

$data_sql = mysql_real_escape_string($data, $connection);
$query = "insert into data(data) values('$data_sql')";
$insert = mysql_query($query, $connection);
if (!$insert){
  trigger_error(mysql_error($connection), E_USER_ERROR);
}

My custom error handler logs the mysql error, and displays a nice
generic "Something went wrong. Please try again or contact us" message
to the user, wrapped in the page layout, and then exits.

I've just noticed that while the function signature says:
string mysql_real_escape_string( ...)

The docs say it could return FALSE in case of error.

I'm not real sure what all could cause a FALSE return.

Obviously, if the database server/process/chipmunk has DIED just
before the call to mysql_real_escape_string, I'll get FALSE back.

If the input string is just too whack for the function to parse, could
I get FALSE, and then I'd be inserting junk into the DB?

Or is it possible that the function returns FALSE for what is
obviously a hack attempt?

I guess I'm asking if anybody adds a line like:

if ($data_sql === false){
  trigger_error(mysql_error($connection), E_USER_ERROR);
}

Or is that not really going to do anything useful/better than what I
already have?

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] stdin, stdout, stderr, 3

2009-03-08 Thread Richard Lynch
I have a program sending/receiving data to/from my CLI script using:

0 stdin
1 stdout
2 stderr
3 ??

0, 1, and 2 are trivial.

How do I access 3?

I tried /dev/fd/3 and failed to open it...

Got no error messages about why it failed to open, it just failed.

Am I missing something?

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] Audio stream piping minimal overhead

2009-03-07 Thread Richard Lynch
I'm interfacing PHP with an Asterisk server, and would like to pipe
audio into PHP, through sox, and back out, in real-time, thus with
*minimal* overhead in PHP.

Any suggestions on what would be the best architecture?

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] Seeking PHP Work in Chicago or Telecommute

2009-02-07 Thread Richard Lynch
I figure if job postings are okay, then so are job requests, right? :-)

I'm looking for PHP work in Chicago or telecommuting.

My resume is here:
http://l-i-e.com/resume.htm

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] Multiple queries in PHP

2009-01-25 Thread Richard Lynch
PHP/MySQL and the various functionality such as @var are all
per-connection expressly so that you CAN do this type of stuff.

I'd be pretty shocked if you had any problems.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] best practice wrt multi-lingual websites, gettext() etc.

2009-01-25 Thread Richard Lynch
I can't help with the bits you are asking about, but I can give this
advice:

Don't rely solely on the Apache/browser content-negotiation, please.

This one time...

I was in Paris.

I was at an Internet Cafe.

I couldn't change browser settings.

Some sites that I knew were available in English showed me only
French, and no way to change it.

Despite my using a computer with a French keyboard, my French language
skills remained somewhere around the "Bonjour. Parlez-vous Englias?"
level.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Richard Lynch
Configure your browser to prompt you for cookies.

That will make sure you are doing the session bit the way you think
you are.

Then add some error_log statements when you set or read the secret word.

You'll soon figure out exactly how/why your session has the OLD secret
word in it.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Richard Lynch
You may or may not find this worth reading:
http://richardlynch.blogspot.com/2007/07/php-in-html.html

Bottom line is that what you are trying to do can't be done in PHP.

You'll have to resort to Javascript and DIV tags with display: none;
switching to display: block;


-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] PEAR ExcelWriter corrupt / Bug Report CAPTCHA borked

2008-11-28 Thread Richard Lynch
The PEAR tarball for ExcelWriter is corrupt for 0.9.1, 0.9.0 and 0.8.0

The PEAR bug-reporting system CAPTHCA won't accept the correct answers.

In desparation, I'm reporting this here, hoping somebody from PEAR
reads this and can do something...

$ tar -xvf Spreadsheet_Excel_Writer-0.9.1.tar
package.xml
Spreadsheet_Excel_Writer-0.9.1/Writer.php
Spreadsheet_Excel_Writer-0.9.1/Writer/BIFFwriter.php
Spreadsheet_Excel_Writer-0.9.1/Writer/Workbook.php
Spreadsheet_Excel_Writer-0.9.1/Writer/Format.php
Spreadsheet_Excel_Writer-0.9.1/Writer/Worksheet.php
Spreadsheet_Excel_Writer-0.9.1/Writer/Parser.php
Spreadsheet_Excel_Writer-0.9.1/Writer/Validator.php
tar: A lone zero block at 576

pear install xyz

will NOT work due to firewall/proxy/policy at work.


-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



RE: [PHP] How to submit form via PHP

2008-09-30 Thread Richard Lynch
Yes, any GET parameters you had will not be added in.

I believe a fragment (#anchor) will be included however.

Read the specs for "base" to see for sure.

It's all spelled out, if you can follow the paper trail and have enough time to 
read it :-)

> -Original Message-
> From: Waynn Lue [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 29, 2008 7:34 PM
> To: Lupus Michaelis; php-general@lists.php.net
> Subject: Re: [PHP] How to submit form via PHP
>
> Hm, it specifies base though. Does that mean the full query string
> won't be guaranteed to be passed along?
>
>
>
> On 9/29/08, Lupus Michaelis <[EMAIL PROTECTED]> wrote:
> > Ashley Sheridan a écrit :
> >
> >From the link you gave, we stick on
> > , so it references
> an
> > IETF RFC  that describes what is
> an
> > URI.
> >
> >The fourth section describes how we have to determine the
> resolution
> > of an URI. The point that are in our scope is the next I quote :
> >
> > «
> > a) If the embedded URL is entirely empty, it inherits the
> >entire base URL (i.e., is set equal to the base URL)
> >and we are done.
> > »
> >
> >If you have any doubt, just enjoy reading the full document ;)
> >
> >But for me, it is quite clear that an empty string is a valid URI
> > *into* a document served by HTTP.
> >
> > --
> > Mickaël Wolff aka Lupus Michaelis
> > http://lupusmic.org
> >
> > --
> > 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


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] How to submit form via PHP

2008-09-29 Thread Richard Lynch
I can't speak to cell phones, but it works on all "normal" browsers I've ever 
seen...

From: Nisse Engström [EMAIL PROTECTED]
Sent: Monday, September 29, 2008 6:11 PM
To: php-general@lists.php.net
Subject: Re: [PHP] How to submit form via PHP

On Mon, 29 Sep 2008 11:33:41 -0500, Richard Lynch wrote:

> Actually, I believe action="" submitting to the same URL is *documented* HTTP 
> spec behavior.
>
> I welcome correction/confirmation if somebody wants to wade through the docs 
> again...

HTML 4.01 says:

action = uri [CT]
This attribute specifies a form processing agent. User agent
behavior for a value other than an HTTP URI is undefined.

The "uri" is a reference to RFC 2396, which says:

4.2. Same-document References

A URI reference that does not contain a URI is a reference to the
current document.  In other words, an empty URI reference within a
document is interpreted as a reference to the start of that document,

[For some reason, the syntax does not allow empty URI
 references. However, RFC 2396 has been obsoleted by
 RFC 3986 which /does/ allow empty URI references.]

[And yes, the HTML spec should probably refer to URI
 *references* rather than URIs...]

On the other hand, I seem to recall that it has been
rumoured that some have claimed that browser support
for empty action attribute is (or was) patchy.
I don't know.


/Nisse

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


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] can't get output of exec ('nice -n 19 ffmpeg -i "file"')

2008-09-29 Thread Richard Lynch
I think nice may play games with fork etc and may be confusing php.

Try putting the nice -n 19 ffmpeg -I bit into a mini shell script of its own, 
and call that.

> -Original Message-
> From: Rene Veerman [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 29, 2008 1:54 PM
> To: php-general@lists.php.net
> Subject: [PHP] can't get output of exec ('nice -n 19 ffmpeg -i "file"')
>
> Hi, i have the following php statements;
>
> I'm wondering why exec()'s $output remains empty..
> Any help is greatly appreciated..
>
>  $cmd = 'nice -n 19 ffmpeg -i "'.$sourcePath.'"';
> exec ($cmd, $output, $result);
>  return array (
> 'cmd' => $cmd,
> 'output' => $output,
> 'result' => $result
> );
>
>
> which when executed returns
>
> ["cmd"]=>string(128) "nice -n 19 ffmpeg -i "/data/web/secret/20080929
> 201651/work/MVI_1993.avi""
> ["output"]=>array(0) {
> }
> ["result"]=>int(1)
> }
>
> if i run the same "cmd" on the commandline, it nicely returns:
>
> FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2004 Fabrice Bellard
>   configuration:  --enable-gpl --enable-pp --enable-pthreads
> --enable-vorbis --enable-libogg --enable-a52 --enable-dts
> --enable-libgsm --enable-mp3lame --enable-faad --enable-dc1394
> --disable-debug --enable-shared --prefix=/usr
>   libavutil version: 0d.49.0.0
>   libavcodec version: 0d.51.11.0
>   libavformat version: 0d.50.5.0
>   built on Sep 29 2008 18:43:44, gcc: 4.1.2 20061115 (prerelease)
> (Debian 4.1.1-21)
> Input #0, avi, from
> '/data/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/uploa
> d/20080929
> 201651/work/MVI_1993.avi':
>   Duration: 00:01:45.6, start: 0.00, bitrate: 1746 kb/s
>   Stream #0.0: Video: mjpeg, yuvj422p, 320x240, 15.00 fps(r)
>   Stream #0.1: Audio: pcm_u8, 11024 Hz, mono, 88 kb/s
> Must supply at least one output file
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] PHP + Cron jobs

2008-09-29 Thread Richard Lynch
If you are running PHP as CGI, replacing the CGI with CLI could be problematic 
down the road...

From: Waynn Lue [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 28, 2008 6:12 AM
To: Richard Lynch
Cc: Per Jessen; php-general@lists.php.net
Subject: Re: [PHP] PHP + Cron jobs

Yup, you're completely right.  I checked the cronjob and got this:

PHP 5.2.6 (cgi) (built: Aug 11 2008 13:39:32)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
   with Advanced PHP Debugger (APD) v0.9, , by George Schlossnagle

Turns out there's /usr/bin/php, which is the cgi version, and 
/usr/local/bin/php, which is the cli version.  So I see three possiblities.  1. 
Change the shebang on the php script itself, 2. change the crontab to reflect 
to path I care about, or 3. replace /usr/bin/php.  I'd prefer the 3rd, but does 
that cause problems for me in my actual web pages?

Thanks,
Waynn

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214


RE: [PHP] How to submit form via PHP

2008-09-29 Thread Richard Lynch
Actually, I believe action="" submitting to the same URL is *documented* HTTP 
spec behavior.

I welcome correction/confirmation if somebody wants to wade through the docs 
again...

> -Original Message-
> From: Dotan Cohen [mailto:[EMAIL PROTECTED]
> Sent: Sunday, September 28, 2008 4:13 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] How to submit form via PHP
>
> 2008/9/28 Ashley Sheridan <[EMAIL PROTECTED]>:
> >> Sorry to drag up an old thread, but I just saw this. Is that true of
> >> all browsers? I'm wondering because I just coded a site to use this
> >> behavior, then I saw that the html specification says the action
> >> attribute is required.
> >>
> > Without the action attribute, the form submits to itself, i.e. a form
> on
> > contact.php submits to contact.php without an action attribute being
> > specified.
> >
>
> If it's undocumented then I would not rely upon it. How much trouble
> did we have in the early 00's because of sites that were coded for the
> undocumented 'features' of specific browsers five years prior?
> Additionally, if you cannot test all the varied platforms (PC,
> cellphones, iPhone, PS3, browsers for the disabled) then you should
> not rely on undocumented behaviour.
>
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
>
> ä-ö-ü-ß-Ä-Ö-Ü

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214


RE: [PHP] error warning while connecting to posgreSQL

2008-09-29 Thread Richard Lynch
> -Original Message-
> i try to understand the error_reporting statement and to avoid all
> warning
> or error messages.
> for example i stop the postgresql service and i try to connect to it.
> when error_reporting is set to E_ALL, i get the following warning :
> *Warning*: pg_connect()
> [function.pg-connect connect>]:
> Unable to connect to PostgreSQL server: could not connect to server:
> Connection refused (0x274D/10061) Is the server running on host
> "localhost" and accepting TCP/IP connections on port 5432? in *
> L:\Webserver\se\log\checklogin.php* on line *48*
> Couldn't Connect:
>
> but if i have the error_reporting set to 0, i only get my die message
> "Couldn't connect".
>
> i would like to know if i let the setting "E_ALL" do i have a way how
> to not
> display the warning message to end users but to display only "Couldn't
> connect" ?
> in fact to have the same behavior as error_reporting set to 0.

In production, you can suppress them with E_NONE.

Or, instead of displaying them to end users, log them and check the logs at 
your leisure.

It is technically possible to just slap an @ in front of the offending 
function, but that's a really bad idea.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] How to submit form via PHP

2008-09-29 Thread Richard Lynch
> -Original Message-
> >No it doesn't... without an action statement...
>
> Sorry to drag up an old thread, but I just saw this. Is that true of
> all browsers? I'm wondering because I just coded a site to use this
> behavior, then I saw that the html specification says the action
> attribute is required.

Required but blank works for me.




Valid, and posts to same page.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Regular Expression Backreference in subpattern.

2008-09-27 Thread Richard Lynch
Not sure what you think the (?P is doing, but it looks very suspicious to me...

I'm no PCRE expert though...

Try this:

'|\\s*charge\\s*\\s*\\s*([0-9]*)\\s*|'

\\s allows for whitespace

If you only want ones that HAVE to have numbers, and no blanks, change * after 
the 0-9] bit into +


From: Shiplu [EMAIL PROTECTED]
Sent: Saturday, September 27, 2008 10:24 AM
To: PHP General
Subject: [PHP] Regular Expression Backreference in subpattern.

The string is "charge100".
I want and array( "charge"=>100).
I am using this regular expression,
'/([^<]+)<\/td>(?P<\1>\d+)<\/td>/'.


But its not working..

I get this error.,
PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
at offset 25 in E:\src\php\WebEngine\- on line 4

any idea?

--
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

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


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-27 Thread Richard Lynch
memory_limit and time_limit are implemented down in the guts of the PHP 
interpreter; They are not magic.

They can't do diddly when PHP is running some other binary...

From: Thodoris [EMAIL PROTECTED]
Sent: Saturday, September 27, 2008 8:24 AM
To: [EMAIL PROTECTED]; php-general@lists.php.net
Subject: Re: [PHP] Questions regarding limits of processes launched by system, 
exec,passthru ...

> Hello all,
>
> Is there a way to limit the memory consumption and / or the CPU
> consumption of processes launched by the php functions system,
> exec, passthru, proc_open and shell_exec?
>
> We use mod_php with an apache (mpm-prefork) on Linux.
>
> The following settings don't have any effect at all:
> PHP:
>   max_execution_time 30
>   memory_limit 8M
> Apache:
>   RLimitCPU 30 30
>   RLimitMEM 8388608 8388608
>
> The limits above do have effect on php-scripts (without system calls)
> and on CGIs (as well on processes launched by CGIs).
>
> Any Ideas?
>
> Kind Regards
> valli
>
>
> PS: I tested it with the following two scripts:
> system_memorytest.php
> =
> 
> 
>   php-systemcall-memory test
> 
> 
>   php-systemcall-memory test
>   ... and here's the system call:
>   
> $cmd = '/usr/bin/perl -e \'
>   $| = 1;
>   print "start of the systemcall\n";
>   $s = "teststr_";
>   while (1) {
>  print "len=".length($s)."\n";
>  sleep(1);
>  $s .= $s;
>   }
>\'';
>print htmlspecialchars($cmd);
> ?>
>   
>ob_flush();
>   flush();
>   system($cmd);
> ?>
> 
> 
>
>
> system_timeouttest.php
> ==
> 
> 
>   php-systemcall-timeout test
> 
> 
>   php-systemcall-timeout test
>   ... and here's the system call:
>   
> $cmd = '/usr/bin/perl -e \'
>   $| = 1;
>   print "start of the systemcall\n";
>   $i = 0;
>   while (1) {
>  if (($i % 1000) == 0) {
> print "i=".$i."\n";
>  }
>  $i += 1;
>   }
>\'';
>print htmlspecialchars($cmd);
> ?>
>   
>ob_flush();
>   flush();
>   system($cmd);
> ?>
> 
> 
>
>
>
>
>

Well as far as I know there are already memory limits to every php
process and you define this in php.ini. I recently made a script that
used to exhaust all the given memory and I needed to increase the limit.

memory_limit = 16M

You can change this to whatever you wish to control.  You can also
change these if you want to control execution time:

max_execution_time = 30 ; Maximum execution time of each script, in
seconds
max_input_time = 60 ; Maximum amount of time each script may spend
parsing request data


I haven't seen a way to control disk access space but I guess there are
two ways to do that. One is quota the space that php writes in or do
this by the programming way (meaning that you may check the space before
you write something).

As for the CPU I think there are OS specific techniques to control
resource usage in general but it depends on what *nix system you use
(FreeBSD, Linux etc).



Thodoris

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


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] PHP + Cron jobs

2008-09-27 Thread Richard Lynch
___
O/H Waynn Lue ??:
Perhaps this would do the job much better.

12 6 * * * php -f /home/foo/temp.php

Probably no different, unless the new-fangled -f implies -q, and he's running 
the new version of PHP, which I doubt.

Also consider an alternative solution. Add this on the first line of the
php script:

#! /usr/bin/php

This will work if that is where his CLI php lives.

If that's his CGI php that the cron is finding, and his shell PHP is something 
else, it won't change a thing.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] PHP + Cron jobs

2008-09-27 Thread Richard Lynch

From: Waynn Lue [EMAIL PROTECTED]
Sent: Saturday, September 27, 2008 6:04 AM
To: Per Jessen
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP + Cron jobs

>
> > This is something that I've noticed for awhile, but last post to this
> > mailing list reminded me that someone probably already knows how to
> > work
> > around this!  I have a cron job that looks something like
> >
> > 12 6 * * * php /home/foo/temp.php
> >
> > But even if temp.php doesn't output anything, I still get emails from
> > the crontab that consist of
> >
> > "Content-type: text/html"
> >
> > I assume this is happening because it's interpreting as a web page or
> > some such.
>
> Somehow your /home/foo/temp.php isn't running with the correct PHP
> interpreter.
>
> > Is there a better way to set the crontab so I don't get that
> > output?
>
> You can always use MAILTO= to direct any output from a cronjob.
>
I actually am using MAILTO, and that's where the problem is.  A cronjob only
mails when there actually is output, which I'm fine with.  In fact, when I
run php temp.php from the command line, I don't get any output.  But when
it's part of the cronjob, there's that content-type output, which triggers
mail to me.

You mentioned a correct php interpreter above.  Should I instead be running
php through some other way or with a specific flag?

cron does NOT NOT NOT run with the same user/shell as "you" from command line.

You have TWO different versions of PHP running on your system.

You are running one of them (the newer one).
cron is running the older one, almost for sure.

Do this from command line:
which php

Now do this:
* * * * * which php

Be ready to comment that cron job out as soon as you get the email (and several 
more)
It runs every minute. :-)

But you'll find that cron ain't running the same "which php" as you are.

TIP:
cron jobs should ALWAYS have the FULL path to all files, binaries, inputs, and 
everything else if you expect it to do what you think it is doing.

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] PHP + Cron jobs

2008-09-27 Thread Richard Lynch
You are using the old school PHP CGI as if it were PHP CLI.

Upgrade and use PHP CLI.

Or just add -q to the args:
12 6 * * * php -q /home/foo/temp.php

php -h
will show you the version and nature (CLI/CGI) of PHP you are running, as well 
as the args and what they do, in rather terse format.

From: Waynn Lue [EMAIL PROTECTED]
Sent: Saturday, September 27, 2008 4:21 AM
To: PHP General list
Subject: [PHP] PHP + Cron jobs

This is something that I've noticed for awhile, but last post to this
mailing list reminded me that someone probably already knows how to work
around this!  I have a cron job that looks something like

12 6 * * * php /home/foo/temp.php

But even if temp.php doesn't output anything, I still get emails from the
crontab that consist of

"Content-type: text/html"

I assume this is happening because it's interpreting as a web page or some
such.  Is there a better way to set the crontab so I don't get that output?

Thanks,
Waynn

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Prevent execution bad commands

2008-09-27 Thread Richard Lynch

I am developing a web page where i have to display the files list based on
some search criteria and of certain duration. My web server is on linux
operating system. The command i am using for this peropse is:

find /home/test -mtime -$duration | sort | xargs grep -l "$search_criteria"

Is any malicious user can use the search criteria to perform some bad
commands in the operating system.

YES!

Consider this:

$search_criteria = "foo | rm -rf /";

Or, rather, this:
http://example.com/?duration=5&search_criteria=foo+|+rm+-rf+/

If it is then please suggest how to prevent it.

Please help me out.

#1: Don't do that. :-)
#2: $search_criteria = preg_replace('|[^a-z0-9_-]|', '', $search_criteria;
#3: $search_criteria = escapeshellarg($search_criteria);


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] event feeder

2008-09-27 Thread Richard Lynch

i would like to display on my web application, the latest 3 events added to
my web DB.
something like latest 3 event which happen to company.

what is the best way knowing that each event is translated in several
languages and stored into DB ?
should i directly read latest 3 events from DB using PHP ?
should i firstly query DB for each language, store the result into a txt
file (for example) and after using AJAX or PHP read this file ?

what do you use usally ?

If you can figure out the SQL to do it, that is almost always faster.

Even if you have to do 2 queries, hopefully simpler ones, it's still faster.

Relative Expense Operations:
EXPENSIVE
|   Opening DB Connection (possibly not on localhost, possibly over socket 
versus TCP/IP stack moves it down a level)
|   Opening local file
|   PHP loop through many many values
|   Complicated DB "JOIN" with many many rows
|   PHP loop through small number of values
|   One more small simple DB query
CHEAP

Of course, you can make a mess of this with extremes like a very very very 
remote DB, or a 486 DB server with an 8-cpu 64G RAM webserver or something 
"forced" to prove me wrong.

And, of course, "many" could mean different things on different hardware; You 
have to be comparing on the same hardware, or it all goes out the window.

But the above is a general rule of thumb.

Hope that helps.

It sure would have been useful to me in the first few years of my PHP 
programming :-)

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Passing Variables to an iframe

2008-09-26 Thread Richard Lynch
Anybody can see it and change it.

All user input, which always includes GET/POST/COOKIE data is always 
untrustworthy.

> -Original Message-
> From: Waynn Lue [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 26, 2008 6:17 AM
> To: PHP General list
> Subject: [PHP] Passing Variables to an iframe
>
> This may be more a general HTML question, so let me know if I should
> post
> somewhere else.
>
> I was hoping to do some logic in a script, and then pass the results of
> that
> script to an iframe for more processing.  Is it secure to include those
> variables as get parameters to the iframe, though?  In other words, if
> I
> have something like this:
>
> http://example.com/?accesseverything=true";>
>
> where I use PHP to generate the src for the iframe.  Could someone just
> use
> Firebug or something to set that variable?  Is there a better way of
> passing
> it instead?
>
> Thanks,
> Waynn

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Filters and sanitizing a regexp

2008-09-26 Thread Richard Lynch
> -Original Message-
> > hate to say this but why not cater for all eventualities and just use
> > strtotime( $whatever );
>
> Well it just doesn't have enough geek factor...

Plus, strtotime() does non-intuitive things with some inputs...

I'd insist on at least some kind of confirmation page if you use that beast.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Math problems (No not high school math!)

2008-09-25 Thread Richard Lynch
Run another query and let MySQL add it up.

> -Original Message-
> From: Jason Pruim [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 25, 2008 10:05 AM
> To: PHP General List
> Subject: [PHP] Math problems (No not high school math!)
>
> So I'm trying to figure out how to do a little math in php to add up
> the number of hours that people have worked (Still on the timecard for
> anyone following along at home)
>
> I have it inserting time in and timeout as timestamps into a MySQL
> database, from there, I use a while loop to display the total hours
> for the day which works perfectly, now though, they want it to total
> for the week...
>
> I think what I need to do is create an array of my total time for the
> day then add that up in another loop to display the total... That
> seems like overkill to me though... is there a better way to do it?
>
> Here is the relevant part of the code:
>
> while ($row = mysql_fetch_assoc($result)){
> $timein = date("m/d/y h:i:s", $row['timein']);
> $timeout = date("m/d/y h:i:s",
> $row['timeout']);
> $totalday = ($row['timeout'] - $row['timein']);
> $totalday = $totalday/60/60;
> $totalday = round($totalday, 2);
> $totalweek =
> [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$&*^
>
> echo <<
>
> 
> {$row['Name']}
> {$timein}
> {$timeout}
> {$totalday}
>
> 
>
> ADMIN;
> }
> echo "
> 
> ";
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 11287 James St
> Holland, MI 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
>
>


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-25 Thread Richard Lynch
> -Original Message-
> Is there a way to limit the memory consumption and / or the CPU
> consumption of processes launched by the php functions system,
> exec, passthru, proc_open and shell_exec?

I suspect...

PHP pretty much releases control to the shell or whatever, and just waits 
around for it to finish.

You'll have to put limits into the called processes, I think

I could be wrong.



___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214


RE: [PHP] Problem with install lybrary GD

2008-09-24 Thread Richard Lynch
Did you change php.ini to load in the php_gd.so file?

Is this in Apache, and did you restart apache, which only reads php.ini on 
startup?

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 24, 2008 3:35 PM
> To: php-general@lists.php.net
> Subject: [PHP] Problem with install lybrary GD
>
> Hi forum
>
> I try install library GD on Centos 5
>
> I download the gd-2.0.35.tar with the next sentece
>
> ./configure --prefix=/usr/local --with=/usr/local --with-
> jpeg=/usr/local
> make
> make install
>
> Here all ok.
>
> And next install the php-5.2.6
>
> ./configure (... n parameter...) --with-gd=/usr/local/lib
> --with-png-dir=/usr/local/bin --with-jpeg-dir=/usr/local/bin
> make
> make install
>
> And don't get any problem, all ok.
>
> But, execute in code php, the command phpinfo(); and see the next
> result
>
> Configure Command'./configure' ... '--with-freetype-
> dir=/usr'
> '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm'
> '--with-gettext' '--with-jpeg-dir=/usr' '--with-png' '--without-gd'
> ..
>
> And test with code in php var_dump(gd_info()); but nothing.
>
> What is wrong. Why don't work
>
> Thanks,
>
> P.D. The content the directory are:
>
> /usr/local/bin
>
> annotate
> bdftogd
> gd2copypal
> gd2togif
> gd2topng
> gdcmpgif
> gdlib-config
> gdparttopng
> gdtopng
> giftogd2
> pngtogd
> pngtogd2
> wcmgr
> webalizer
> webazolver
> webpng
>
>
> /usr/local/lib
>
> gd.h
> libgd.a
> libgd.la
> libgd.so
> libgd.so.2
> libgd.so.2.0.0
> libpcap.a
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214


RE: [PHP] Don't understand what is this $arr['N']['#']

2008-09-24 Thread Richard Lynch
> -Original Message-
> I am working on the code of a former employee and I don't understand
> what this  $arr['N']['#'] refers to.
>
> I know it is a multidimensional associative array but the # i don't
> what this means.

'#' is just a string value.

It has no special meaning whatsoever.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] calling functions from one or multiple files

2008-09-24 Thread Richard Lynch
> -Original Message-
> Right now I use one file, usually called functions.php, with all
> functions I'm going to use most likely on every page.
> Then, I create each function I'm going to use once in a while as
> separate file.
> Pro: I would include a function when I'm going to use.
> Con: I have to write extra include line to call function. And have
> bunch of files (functions) in function folder.
>
> I was talking to co-workers few days ago and they said I complicate my
> life to much and putting ALL functions in one file is just fine and
> I'll not be able to see difference in "real situations".

You'd have to have a LOT of functions either way to make a difference...

Actually, it's probably more expensive to open up the individual function files 
than to toss ~30 more functions into a single file.

You'll have to profile 'require' on your own hardware to turn ~30 into a real 
number...


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Re: class const versus define

2008-09-24 Thread Richard Lynch
I’m kind of stuck with a pre-existing code-base that cannot be substantially 
changed at this time...

I guess I can just make it a class variable, even if it never “varies” in the 
script, which to me screams “const”
[shrug]

From: Nathan Nobbe [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 24, 2008 11:14 AM
To: Richard Lynch
Cc: [EMAIL PROTECTED]; php-general@lists.php.net
Subject: Re: [PHP] Re: class const versus define

On Wed, Sep 24, 2008 at 7:35 AM, Richard Lynch <[EMAIL PROTECTED]<mailto:[EMAIL 
PROTECTED]>> wrote:
I need the PATH to differ in development, staging, and production due to mixed 
environments.

factory *cough*

Unfortunately, I CANNOT construct a class const "on the fly" from global 
define'd constants and constant strings.

no, but you could select a class on the fly from globally defined constants.
So, in fact, I'd LIKE to use the class const properly for what it is mean for, 
but cannot do that because its value depends upon the environment.

i tend to agree w/ Jocheem here, if the value is something that will vary, 
perhaps it is best implemented as an instance variable rather than a constant.  
a factory method which took $path, or $env (something like that) could easily 
select an appropriate concrete class to instantiate.

-nathan

___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214


RE: [PHP] spreadsheets are opened read only

2008-09-24 Thread Richard Lynch
> Hi guys. I am having a problem with opening xls files from a link
> generated from php script. Let me analyze this:
>
> I have two linux servers with apache (php,mysql etc) that are running
> the same project. There is a part in this project that reads all the
> files from a directory and generates the appropriate links to them.
> These files are usually spreadsheets (xls) and when I open a file using
> the link on the first machine it opens normally but when I open the
> file
> from the second it is opened read only.
>
> I have checked the rights and the ownership and they are the exact same
> from the servers document root to the file itself.
>
> Any ideas why is this happening?

If Excel thinks they are the SAME document, and it's already open, then you can 
only open it read-only.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] How to detect the host (window or Linux)?

2008-09-24 Thread Richard Lynch
> Thanks Thodoris and Anderson. Sorry for not clear about the question.
> I mean to detect the OS in Host system where the browser is located,
> not the SERVER OS.

It's really none of your business what OS I'm running :-v

You may be able to make an educated guess from the HTTP headers in $_SERVER.

var_dump($_SERVER);
and see what you get.

But you can't RELY on them, as some users will intentionally mask/alter that.

If your website depends on the visitor's OS for anything other than trivial 
behaviour, you're in real trouble.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Re: Browser could not get mp3 files from http site

2008-09-24 Thread Richard Lynch
> On Wed, Sep 24, 2008 at 9:56 AM, Richard Lynch <[EMAIL PROTECTED]>
> wrote:
> > As a general rule, check what happens when you do wget -S on the URL
> and see what the browser sees.
>
> Thanks Richard and all responses. That was the best PHP and HTML debug
> I've learned so far. I always find it is difficult to debug html and
> JS when doing PHP program. I can debug C/C++ using gdb well but no
> idea what the tools can be used for browser debug.
>
> Anyway, the problem has been resolved. It turns out it was an
> authorisation issue. My web server requests a log in at beggin,
> although I can see every pages and download other data and image
> files, somehow it cannot download the mp3 file. As soon as I remove
> the login, it works fine.

If you are used to gdb, you will want to check out:
XDebug

If you are on Windows, there is also a web-based kcachegrind-like tool for code 
analysis, though it is in its infancy:
http://code.google.com/p/webgrind/
Written in PHP, natch. :-)

For webgrind, xdebug-helper is invaluable:
https://addons.mozilla.org/en-US/firefox/addon/3960
Alas, it doesn't seem to work for me with latest FF 3.0.1 :-(


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Re: class const versus define

2008-09-24 Thread Richard Lynch
> Richard Lynch schrieb:
> > Is there any reason why the logic behind define() couldn't be pushed
> down to class const?
> >
> > Code like this is kinda fugly:
> >
> > //It's okay here, but not in a class?
> > define('CACHE_DIR_LONG',  CONFIG_ROOT_PATH . '/cache/');
> > class Cache {
> >   const CACHE_DIR = '/dev/shm/cache/';
> >   const CACHE_TTL = 300; //5 minutes
> >   const CACHE_DIR_LONG = CACHE_DIR_LONG;
> >
> > I'd really prefer to write:
> > class Cache {
> >   const CACHE_DIR = '/dev/shm/cache/';
> >   const CACHE_TTL = 300; //5 minutes
> >   const CACHE_DIR_LONG = CONFIG_ROOT_PATH . '/cache/';
> >
> > I'm happy to add it as a feature request, but not if somebody
> reliable says "Don't Bother"...


> Hi Richard,
> the define function is to be used on the global scope of your
> application. This is helpful to assign Configurations Options and other
> data that you do not will move. For the Class Constants you define the
> Constant only fo the Class where you are working.
> Please read the documentation about this on PHP.NET
> http://de.php.net/manual/en/language.oop5.constants.php

I understand the difference quite well, thank you.

I need the PATH to differ in development, staging, and production due to mixed 
environments.

Unfortunately, I CANNOT construct a class const "on the fly" from global 
define'd constants and constant strings.

Yet, the logic that makes it possible to do that for define itself in some kind 
of pre-processor should not be terribly difficult to push down to the class 
level, I would think.

So, in fact, I'd LIKE to use the class const properly for what it is mean for, 
but cannot do that because its value depends upon the environment.

PS
Apologies for the legal disclaimer over which I have no control; not even the 
silly punct-
uation it ended up with in plain-text email.
Sigh.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



[PHP] class const versus define

2008-09-23 Thread Richard Lynch
Is there any reason why the logic behind define() couldn't be pushed down to 
class const?

Code like this is kinda fugly:

//It's okay here, but not in a class?
define('CACHE_DIR_LONG',  CONFIG_ROOT_PATH . '/cache/');
class Cache {
  const CACHE_DIR = '/dev/shm/cache/';
  const CACHE_TTL = 300; //5 minutes
  const CACHE_DIR_LONG = CACHE_DIR_LONG;

I'd really prefer to write:
class Cache {
  const CACHE_DIR = '/dev/shm/cache/';
  const CACHE_TTL = 300; //5 minutes
  const CACHE_DIR_LONG = CONFIG_ROOT_PATH . '/cache/';

I'm happy to add it as a feature request, but not if somebody reliable says 
"Don't Bother"...

--
Richard Lynch



___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Using Static Class Variables to Access Globally

2008-09-23 Thread Richard Lynch
> -Original Message-
> From: Ryan Panning [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 23, 2008 8:03 PM
> To: php-general@lists.php.net
> Subject: [PHP] Using Static Class Variables to Access Globally
>
> The typical way to access a variable or instance from inside a
> function/method is to either declare it a global variable or pass it as
> a argument. Is there any reason why someone shouldn't use static class
> variables to do this? Ex:
>
>  class Foo {
> public static $bar_instance;
> }
>
> class Bar {
> public function do_something() {}
> }
>
> Foo::$bar_instance = new Bar;
>
> function foo_bar() {
> Foo::$bar_instance->do_something();
> }
>
> foo_bar();
> ?>
>
> Crude example but imagine this on a larger scale. I'm thinking there
> may
> be some kind of php optimization that this would hamper or something to
> that effect.

I can't think of any particular reason to not do this.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



RE: [PHP] Re: Browser could not get mp3 files from http site

2008-09-23 Thread Richard Lynch
> > when the file isn't in a streaming server you have buffering to
> contend
> > with; odds are it won't play the file till it's completely downloaded
> > [regardless of autoplay/autostart]
>
> I am not sure if it is a buffering problem or not. I am baffled as I
> can play from opening a file file:///home/webserver/audio.html, but
> could not play it if I play from an URL
> http::/www.myweb.com/audio.php, the audio.php generate the same
> content of the audio.html.
>
> > A few questions:
> > Why don't you just link to the audio.mp3 file and let the users
> browser/pc
> > determine how best to play it [normal]?
>
> I am sure you have many ways to play an mp3 file, that was not what I
> was asking for. My intention is to learn and understand the PHP and
> HTML program, and to resolve problems. It bothers me as I could  not
> unserstand why the URL way does not work as it should.

As a general rule, check what happens when you do wget -S on the URL and see 
what the browser sees.

You may find that the file is being buffered by PHP and is "too slow" for an 
mp3 player.

A simple loop to close all output buffers will fix that issue.

Of course, you could find something else completely different...

Like the wrong "Content-type" that the browsers will ignore in favor of the 
.mp3 URL ending, or any number of things...

For sure, a simple straight-forward HTTP mp3 file spewing out should work just 
fine.


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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



Re: [PHP] PHP Script/Thread ID thingie

2008-08-15 Thread Richard Lynch
On Fri, August 15, 2008 10:52 am, Stut wrote:
> On 15 Aug 2008, at 16:37, [EMAIL PROTECTED] wrote:
>> I'm logging things with error_log, and would like to be able to sort
>> out one script run from another.
>>
>> So I'm looking for some kind of "script id" or "thread id" or "PHP
>> script run execution ID" type of function.
>>
>> getmypid() just returns the same apache child process ID all the
>> time, so that's not what I want.
>>
>> zend_thread_id() looks useful, but I suspect it's not quite what I'm
>> looking for.  But I'd have to re-compile with ZTS and --debug-mode
>> and I don't think the function I'm looking for should require
>> that...
>>
>> Perhaps I've just missed the right function name?
>>
>> Or perhaps this should be a "Feature Request"?
>
> Don't think there is such a thing, but you could generate one by
> combining the pid, timestamp and the script filename, maybe into an
> md5 hash value or similar. Thinking about it, "ip.pid" would be
> enough, i.e. 127.0.0.1.12345.

The IP and pid will not actually change...

It's just me surfing to my own app (or one I inherited) on my own
desktop.

Apache isn't getting nearly exercised enough to need a second child,
so the pid is the same all the time...

Guess I'll have to create one as Eric Butera suggested...

Seems kind of odd that there isn't some kind of
script/thread/M_INIT/R_INIT id hanging around and exposed that
developers could use.
[shrug]

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] Kill Magic Quotes

2008-08-07 Thread Richard Lynch
If you can't change php.ini, and if it's Apache, you maybe can just
turn it off in .htaccess, far faster and easier than a PHP function.

You are calling the removeSlashes, right?

And, really, there is no reason for the restoreSlashes function to
exist.  If you ever think you need it, you're wrong. :-)

On Thu, August 7, 2008 10:00 pm, Dave M G wrote:
> PHP List,
>
> I am developing a web site that is hosted on a web server where I do
> not
> have permission to change the php.ini file.
>
> This server has magic quotes turned on. I'd like them off.
>
> I wrote two functions to detect when magic quotes is on, and to try
> and
> counter act its effects. But it does not seem to be working. It seems
> to
> have no effect, and I get slashes showing up in all sorts of output
> where I don't want them. Not only in data put into the database, but
> also emails sent to from the site contact page and other places.
>
> Here are the functions I created. Where have I gone wrong?
>
>   public static function removeSlashes($string)
>   {
>// Check if "Magic Quotes" is turned on.
>if (get_magic_quotes_gpc())
>{
>  // Remove escape slashes.
>  return stripslashes($string);
>}
>// Return a string that has no escape slashes.
>return $string;
>   }
>
>   public static function restoreSlashes($string)
>   {
>// Check if "Magic Quotes" is turned on.
>if (get_magic_quotes_gpc())
>{
>  // Add escape slashes.
>  return addslashes($string);
>}
>// Return a string that has escape slashes.
>return $string;
> }
>
> Any advice much appreciated.
>
> --
> Dave M G
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] Re: Windows date("Y/m/d H:i:s") performance

2008-07-31 Thread Richard Lynch
PHP 5.2.6 with Xdebug 2.0.3 here...

Aha!

Turning off Xdebug "fixes" it...

Weird.  Or maybe "normal" for Xdebug?

I'll take this up with Derick and co on Xdebug list next, if anybody
wants to follow...

On Wed, July 30, 2008 11:36 am, Andrew Ballard wrote:
> On Wed, Jul 30, 2008 at 12:19 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> I suppose to be complete, I should point out that in Linux a call to
>> date finishes in 1.2271404266357E-5 seconds on average.
>>
>> For those unfamiliar with scientific notation, that would be:
>> 0.12271404266357 seconds, or rougly 1/10,000th of the time Doze
>> takes.
>>
>
> Interesting. Just for comparison, I ran it directly with the binaries
> (disabling the debugger) for PHP 4.4.4 and 5.2.0 on my machine.
>
> 4.4.4 - in the order of 4.5E-6 - 5.0E-6
>
> 5.2.0 - right around 1.0E-4
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] Re: Windows date("Y/m/d H:i:s") performance

2008-07-30 Thread Richard Lynch
I suppose to be complete, I should point out that in Linux a call to
date finishes in 1.2271404266357E-5 seconds on average.

For those unfamiliar with scientific notation, that would be:
0.12271404266357 seconds, or rougly 1/10,000th of the time Doze
takes.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



[PHP] Windows date("Y/m/d H:i:s") performance

2008-07-30 Thread Richard Lynch
I was profiling some code on my local dev box, and in Windows, the
biggest time sink for the home page is...

a call to date("Y/m/d H:i:s")?!
917 ms???

Here is what I get in a cygwin shell:
php -r '$c = 100; $s = microtime(true); for($i = 0; $i < $c; $i++){ $d
= date("Y/m/d H:i:s"); } echo (microtime(true) - $s)/$c, "\n"; '
1.0072922205925

Same results from a DOS prompt, though I have to actually create a
file as -r didn't seem to work...

Feel free to change $c to 10 to get a faster answer...

Can 'date' really take almost a full second to execute in Doze?...

That seems pretty whack...

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] OS need anything for mail() to work?

2008-04-28 Thread Richard Lynch
On Mon, April 28, 2008 3:09 pm, Jason Pruim wrote:
>
> On Apr 28, 2008, at 3:47 PM, Richard Lynch wrote:
>
>> On Fri, April 25, 2008 3:44 pm, Brian Dunning wrote:
>>> Is there any way for PHP to know that this email is not going
>>> through?
>>
>> You could, perhaps, hack your MTA to notify something somewhere that
>> PHP can check...
>>
>> But it's really out of PHP's hands at this point.
>>
>> If you put a letter in a mailbox, and the USPS fails to deliver it,
>> do
>> you really expect to get notified?
>
> If you're in the US (Hence the USPS) and you put first class postage
> on it and include your return address then yes since it's built in if
> the letter is not deliverable as addressed. If it's part of a
> presorted mailing (not first class) then you have to pay additional
> fees for it to be returned and specifically request it by adding
> "Address Service requested" or "Return service requested"
>
> But none of that has a lick of salt to do with PHP just throwing out
> my knowledge since that what I do in my day job :)

Apparently, you live in an area where USPS doesn't lose/mis-deliver
mail routinely... :-v

-- 
Can you do me a favor?
Sign up for http://Facebook.com
Add http://apps.facebook.com/whereivebeen/
Review it, and let 'em know Rich sent you.
http://www.facebook.com/apps/application.php?id=2603626322
(Scroll down to the middle of the middle column)
Give it a 5-star rating please :-)
(If you can't go 5-star, email me to tell me why)


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



Re: [PHP] SMS Cellular Text Messaging

2008-04-28 Thread Richard Lynch
On Mon, April 28, 2008 2:39 pm, Al wrote:
> I didn't word my question well. I know about the following, etc. And,
> I know they charge their
> customers.
>
>> Cingular: [EMAIL PROTECTED]
>> Sprint: [EMAIL PROTECTED]
>> Verizon: [EMAIL PROTECTED]
>> Nextel: [EMAIL PROTECTED]

If you send more than a few through any of those, you'll start having
your messages not get through.

> I want to send a pure SMS via these gateways without the regular email
> headers, etc.

Those are just there for the convenience of normal users who send a
text or two without having an SMS phone.

If you want any kind of volume, you pay a gateway.

Or you could invest a few billion and build your own. :-)

-- 
Can you do me a favor?
Sign up for http://Facebook.com
Add http://apps.facebook.com/whereivebeen/
Review it, and let 'em know Rich sent you.
http://www.facebook.com/apps/application.php?id=2603626322
(Scroll down to the middle of the middle column)
Give it a 5-star rating please :-)
(If you can't go 5-star, email me to tell me why)


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



Re: [PHP] Making an array from delimited data

2008-04-28 Thread Richard Lynch
On Mon, April 28, 2008 2:44 pm, Joe Harman wrote:
> I have some data that I pull from a database that is in the following
> format:
>
> -
> Gauge Style: Auto Meter Pro-Comp
> Tachometer Usage: Standard
> Gauge Series: Analog
> Gauge Range: 0-11,000 rpm
> Gauge Diameter (in): 5 in.
> Gauge Diameter (mm): 127.00mm
> Sweep: Full sweep
> -
>
> I want the array to end up like this

preg_match_all('/^([^:]:(.*)$/msiU', $db_data, $data);
var_dump($data);

-- 
Can you do me a favor?
Sign up for http://Facebook.com
Add http://apps.facebook.com/whereivebeen/
Review it, and let 'em know Rich sent you.
http://www.facebook.com/apps/application.php?id=2603626322
(Scroll down to the middle of the middle column)
Give it a 5-star rating please :-)
(If you can't go 5-star, email me to tell me why)


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



Re: [PHP] OS need anything for mail() to work?

2008-04-28 Thread Richard Lynch
On Fri, April 25, 2008 3:44 pm, Brian Dunning wrote:
> Is there any way for PHP to know that this email is not going through?

You could, perhaps, hack your MTA to notify something somewhere that
PHP can check...

But it's really out of PHP's hands at this point.

If you put a letter in a mailbox, and the USPS fails to deliver it, do
you really expect to get notified?

-- 
Can you do me a favor?
Sign up for http://Facebook.com
Add http://apps.facebook.com/whereivebeen/
Review it, and let 'em know Rich sent you.
http://www.facebook.com/apps/application.php?id=2603626322
(Scroll down to the middle of the middle column)
Give it a 5-star rating please :-)
(If you can't go 5-star, email me to tell me why)


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



Re: [PHP] SOAP and nested input

2008-04-28 Thread Richard Lynch
On Mon, April 28, 2008 4:52 am, Emil Edeholt wrote:
> If I need to pass nested input to a SOAP function; For example a
> function that requires these parameters:
>
> bar
> 
> foobar
> 
>
> Should I simply nest two arrays to the php soap function, i.e:
> $client->foo(array("foo" => "bar", "foonest" => array("barnest" =>
> "foobar"));

Should work, I think...

> The exception I get is: Catchable fatal error: Object of class
> stdClass
> could not be converted to string.

This means you tried to echo/print or embed into a string some kind of
php built-in Object, or some on-the-fly object you created.

-- 
Can you do me a favor?
Sign up for http://Facebook.com
Add http://apps.facebook.com/whereivebeen/
Review it, and let 'em know Rich sent you.
http://www.facebook.com/apps/application.php?id=2603626322
(Scroll down to the middle of the middle column)
Give it a 5-star rating please :-)
(If you can't go 5-star, email me to tell me why)


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



[PHP] PHP_OUTPUT_HANDLER_START et al

2008-04-16 Thread Richard Lynch
Can anybody tell me what is the purpose of PHP_OUTPUT_HANDLER_START
(et al) so I can add a Note to the manual?

They aren't really explained anywhere I can find, and the source...

Well, it seems to be just |= PHP_OUTPUT_HANDLER_START when the first
handler starts and then I kinda get lost as to what's going on...

-- 
Can you do me a favor?
Sign up for http://Facebook.com
Add http://apps.facebook.com/whereivebeen/
Review it, and let 'em know Rich sent you.
http://www.facebook.com/apps/application.php?id=2603626322
(Scroll down to the middle of the middle column)
Give it a 5-star rating please :-)
(If you can't go 5-star, email me to tell me why)


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



Re: [PHP] April Fools Easter Egg

2008-04-01 Thread Richard Lynch


On Tue, April 1, 2008 9:39 am, tedd wrote:
> At 4:33 PM +0200 4/1/08, Paul Scott wrote:
>>On Tue, 2008-04-01 at 10:28 -0400, tedd wrote:
>>>  You got me.
>>>
>>
>>Wobbly PHP logo on mine (PHP-5.2.5 debian)
>>
>>--Paul
>
>
> Ahhh, now I see it.
>
> The one I was checking was 4 something.

And apparently, I can't tell a dog from a bunny... :-)

Where's a 5th grader when you need one?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] April Fools Easter Egg

2008-04-01 Thread Richard Lynch


On Tue, April 1, 2008 9:38 am, Christoph Boget wrote:
>>  > You got me.
>>  Wobbly PHP logo on mine (PHP-5.2.5 debian)
>
> That's all I see for PHP-5.2.1.  Should there be something more?

Probably not, but check the source. :-)

I like the bunny of version 4 better, personally...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] extract escaped quoted strings

2008-04-01 Thread Richard Lynch
Extract them from what?

Without more context, we can't really help...

So far a GREEDY pcre with quote on each end fits all the inputs.

And *WHY* do you have so many backslashes?

Whatever is causing that (MagicQuotes, cough, cough) is your REAL
problem.  Fix the problem, not the symptom.

On Sat, March 29, 2008 6:16 pm, Adam Jacob Muller wrote:
> Hi,
> Have a potentially interesting question here, wondering if anyone has
> done this one before and could shed some light for me.
> I have a bit of PHP code that needs to extract some quoted strings,
> so, very simply:
> "hello"
> perfectly fine and works great
> but, it should also be able to extract
> "hel\"lo"
> bit more complex now
>
> Ideally, it would also handle
> "hel\\"lo"
> properly
>
> it should also handle
> "hel\\\"lo"
>
>
> Any ideason how to do this? attempts to write a PCRE to do this are
> so-
> far unsuccessful, i'm sure I could badger some PHP code into doing it
> perhaps, but i'd love some elegant PCRE solution that thus-far evades
> me :(
>
>
> Any ideas are appreciated.
>
> -Adam
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] new lines in textareas?

2008-04-01 Thread Richard Lynch
On Sun, March 30, 2008 7:20 am, jeffry s wrote:

> my client ask me about this problem 2 weeks ago. he want the text to
> automatically
> go to new line after user type until the end of the line. The only
> possible
> solutions so
> far is using wrap='hard' or wrap='soft'
> eg: 
> but wrap only work on IE & Netscape browser. Not working in firefox.
> i guess i want to use javascript to do the text formatting. trigger
> the
> javascript event
> every time the user using the onchange event (i never try)..
> i is quite complicated & i dont have much time working on it.
> so i decided to tell him, it cannot be done :)

If wrap="soft" isn't working in Firefox, then your fancy-dancy CSS is
messing things up somehow, or you've managed to do something else
really weird...

Firefox wraps just fine for me, in all the textarea inputs I've ever
used.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] new lines in textareas?

2008-04-01 Thread Richard Lynch
On Sat, March 29, 2008 11:26 pm, Mary Anderson wrote:
> I have a php script which produces text which is to be displayed
> in
> a textarea.  I have the wrap for the text area set to 'hard'.  I need

Do NOT set the wrap to "hard"

It will only cause you grief in the long run.

It's going to insert newlines where they shouldn't be, and then your
data is corrupt.

> to
> have newlines inserted in the text.
>  "\n" and "" don't work.  They just get quoted literally in
> the
> text.  I suspect I need to use htmlspecialchars , but don't know what
> special character to feed it.

If they are being quoted literally, then something is not right...

\n in particular should flow through just fine.

 would be quoted literally if you ran it through htmlspecialchar
or htmlentities.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] auto generated PDF

2008-04-01 Thread Richard Lynch
On Sun, March 30, 2008 4:27 am, Alain Roger wrote:
> i want to implement on my web portal electronic invoicing system.
> basically data will be stored into PostgreSQL DB.
>
> I would like to know if someone already have experiences with such
> feature
> or where could i find some tutorials or help about this topic.

Google for "PHP PostgreSQL shopping cart" and find a few hundred
off-the-shelf packages you could use instead of re-inventing the
wheel.

Some have HORRIBLE security histories, so do your research.

> Concretly, user will buy some products/services online and i would
> like to
> send him a PDF invoice via email.
>
> is there a PDF module under PEAR or directly under PHP ?

In addition to the other options given so far:
http://php.net/pdf
is an option, and it's not that tough to build up the PDF the way you
want.

Some more sample code:
http://uncommonground.com/events.phps

I find that thinking in "inches" and using *72 a lot works well for me.

E.g., $page_top = 10.0 * 72; //10 inches

PDFs are always 72 dpi.

Flame wars about the meaninglessness of dpi can please be sent to your
own /dev/null.  Thanks.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] PHP 5 file_get_contents() problems

2008-04-01 Thread Richard Lynch


On Sun, March 30, 2008 5:03 pm, php wrote:
> Thanks Greg...I am aware of the allow_url_fopen/allow_url_include
> relationship.
>
> Your suggestion to look into curl was implemented and there still
> seems to
> be something else afoot.
>
> I created a simple set of curl functions which just printed a remote
> url to
> the browser window. This tested well on an alternate test site which
> has PHP
> 5 running.
>
> However back on the hosting client I'm having problems with, curl
> throws the
> following error message:
> CURLE_COULDNT_RESOLVE_HOST (6)
>
> Couldn't resolve host. The given remote host was not resolved.
>
> A second test script, uses the popular PayPal Instant Payment
> Notification
> scheme which opens up a socket connection with the paypal server. Even
> this
> method of remote communition was defeated.
>
> So I'm lead to believe there is some other PHP configuration (or
> server
> configuration) which is stopping PHP from connecting with remove
> services.

Can you SSH into the box and "ping" other domain names?

If that box has messed up DNS, there is NO WAY php can fix it...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] LDAP in php

2008-04-01 Thread Richard Lynch
On Sun, March 30, 2008 8:15 pm, [EMAIL PROTECTED] wrote:
> As LDAP can have SQL back-end (I saw an example with PostgreSQL) - is
> it
> a very wild idea to implement (a simple) LDAP server in php?
>
> We have all the address data already in PostgreSQL and a php
> application
> managing all of it.
>
> I am thinking of simple uses, such as providing LDAP address books to
> Thunderbird/Squirrelmail users.
>
> For instance, is it too wild to think of Apache/php listening on the
> LDAP port (or so), get the request, parse it, get the data from
> PostgreSQL and send it back to the LDAP client?

You probably wouldn't run it through Apache, but you probably COULD
run an LDAP server of sorts using http://php.net/sockets

Main problem is one of performance.

The reason most people choose LDAP in the first place is to get
blazing fast performance, because they NEED it.

PHP is probably not going to give you blazing fast performance
compared to an off-the-shelf LDAP server in C.

You may be able to leverage from the code in http://php.net/ldap to
move most of the heavy lifting into an extension, or perhaps you could
expand that extension to do so, and then you just have a simple PHP
wrapper to handle the sockets part.

That would help some, and possibly even come "close" to C performance,
since the socket open/close/traffic/bandwidth is probably the limiting
factor there, rather than a single PHP byte-code interpreted function
call...

This is all just my expectations.  Feel free to surprise me with
actual test results. :-)

ymmv

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] restricting filesystem access

2008-04-01 Thread Richard Lynch
On Mon, March 31, 2008 3:21 am, Hamar Gábor wrote:
> I am a new php user and I have a question, for which I couldn't find
> any
> answer.
>
> I'd like to restrict php code to access the filesystem. I'd like to
> have
> only one directory where the php code can write, create or read files,
> and an other directory hierarchy where the php codes present. I need
> this to avoid php code to rewrite other php code in case of bug and/or
> an attack.
>
> I already tried the open_basedir directive, but it couldn't work
> because
> in this case the executed php have to be in the accessable directory
> hierarchy.

PHP runs as the Apache user.

chown/chmod the source files to not be writable by that user.

Problem solved.

No real PHP "trick" here.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Reporting mail as spam

2008-04-01 Thread Richard Lynch
On Mon, March 31, 2008 11:01 am, Sándor Tamás (HostWare Kft.) wrote:
> I wrote a little registration routine, which will send a confirmation
> letter to the user with a random number in the message body (my site
> is on a host, so I can't write in the subject, and ask the user to
> reply), which can be clicked then, and my site will finish the
> registration. My big problem is, that this host inserts an X header to
> the mail which identifies my PHP script as the X-PHP. As I recognize,
> this header adds a huge number to the spam score. Is there any
> possibility, to reduce the other scores? By the way, what counts most
> in a spam?

I doubt that the X-PHP mailer header is going to "hurt" your score
that much...

If it's not actually spam, it will probably get through...

Using PLAIN TEXT email will reduce your spam score FAR more than
losing the X-PHP header.

You could also probably put your emails into some kind of database
somewhere that can be accessed by some OTHER program to send emails
out, and search for something that gives you more control over the
email composition.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date Issue

2008-04-01 Thread Richard Lynch
If you want the DAY before, you can use the -1 for the day, and get
what you want.

mktime() will "wrap" the month as needed.

But, yeah, if you try to hit a MONTH before by putting in a month
before AND the day, it will "slingshot" back and forth to get what you
don't want.

If you want the MONTH before, I *suspect* you can use date('m') for
the argument, and do NOT provide a day, and it may do what you want.

But for sure, if you use ONE (1) for the day, and then -1 for the
month it will do what you want, since every month has a ONE (1) day.

Anything 1 from 28 will work fine, actually, but using 1 is probably
clearest:

$today = mktime();
$tomorrow = mktime(1, 0, 0, date('m'), date('d') + 1);
$next_month = mktime(1, 0, 0, date('m') + 1, 1);
$last_month = mktime(1, 0, 0, date('m') - 1, 1);

I've been using these for a web calendar since nineteen-ninety-mumble,
and they've worked fine, through leap years.

You can view the source to the PDF version here:
http://uncommonground.com/events.phps

The HTML version has the exact same stuff at the top.
http://uncommonground.com/events.htm

Feel free to page through as many months/years past/present and future
to see that it works.

Since it's a 32-bit machine, it does conk out in March 2038.

I'm fairly confident our web-server will be a 64-bit machine before we
book any (real) events for 2038...

You can ignore my test events in January 2038 :-)

On Mon, March 31, 2008 3:24 pm, [EMAIL PROTECTED] wrote:
> Thank you again Dan. Thought never crossed my mind the day being the
> 31st. That fixed it.
>
> Richard L. Buskirk
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Mon, Mar 31, 2008 at 4:15 PM,  <[EMAIL PROTECTED]> wrote:
>> I tried that a big no go.
>>  Seems if I do a +1 i get 2 months from now and a -1 gives me the
>> current
> month.
>>
>>
>>
>>  $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
>>  $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"),
>> date("Y")));
>>  $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>>
>>
>>  $month echo's MARCH should be Feb
>>  $zomonth echo's MARCH should be March
>>  $nmonth echo's MAY this should be April
>
> That's because you're using today's date('d');, which is 31.
>
> February doesn't have 31 days, nor does April, so mktime() forces
> them to the following month to correct the error.
>
> --
> 
> Forensic Services, Senior Unix Engineer
> 1+ (570-) 362-0283
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date Issue

2008-04-01 Thread Richard Lynch
I generally use 1 hour after midnight with mktime() to avoid the edge
cases of daylight savings etc...

mktime(1, 0, 0, date('m') - 1, date('d'), date('Y'));

You also have to consider that you *COULD* call this right on the cusp
of midnight, and the call to date('d') could happen one day, and the
call to mktime( ) the next "day" as the clock ticked over...

At 1 am, the day doesn't change over...

Larry's probably right that you should use DateTime, but it's too
new-fangled for an old fart like me to have got around to messing with
it yet...

On Mon, March 31, 2008 3:15 pm, [EMAIL PROTECTED] wrote:
> I tried that a big no go.
> Seems if I do a +1 i get 2 months from now and a -1 gives me the
> current month.
>
>
> $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
> $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"),
> date("Y")));
> $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
> $month echo's MARCH should be Feb
> $zomonth echo's MARCH should be March
> $nmonth echo's MAY this should be April
>
> You will notice i used all options apostrophes double quotes and no
> quotes exactly the same output.
>
>
>
>
>
>
>
> You need apostrophes (or quotes) around your args to date() in the
> parameters...
>
> date('m')
>
> As it stands now, PHP assumes you mean the constant m
> (http://php.net/define) and that's not defined, so they are all 0.
>
> So you are passing in 0 to ALL the args.
>
> You also should use E_ALL for your error_reporting so you would SEE
> the error messages telling you about this.
>
> On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
>> Not understanding why this is happening.
>>
>> $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
>> $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>>
>> echoing out the exact same month
>> March
>> March
>>
>> Checked server timezone/date/time all is good. Am I half asleep at
>> the
>> wheel on this one and just not seeing my mistake here?
>>
>>
>> Richard L. Buskirk
>>
>> Hardware Failure: $4,000.
>> Network Outage: $15,000.
>> Always blaming the programmers for everything: Priceless.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date Issue

2008-03-31 Thread Richard Lynch
You need apostrophes (or quotes) around your args to date() in the
parameters...

date('m')

As it stands now, PHP assumes you mean the constant m
(http://php.net/define) and that's not defined, so they are all 0.

So you are passing in 0 to ALL the args.

You also should use E_ALL for your error_reporting so you would SEE
the error messages telling you about this.

On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
> Not understanding why this is happening.
>
> $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
> $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>
> echoing out the exact same month
> March
> March
>
> Checked server timezone/date/time all is good. Am I half asleep at the
> wheel on this one and just not seeing my mistake here?
>
>
> Richard L. Buskirk
>
> Hardware Failure: $4,000.
> Network Outage: $15,000.
> Always blaming the programmers for everything: Priceless.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] date CDT CST UTC

2008-03-26 Thread Richard Lynch
On Wed, March 26, 2008 12:50 pm, Dee Ayy wrote:
> Today, we are in Central Daylight Time "CDT" in Dallas, Texas, USA --
> yes?
>
> "date" on:
> mail server: Wed Mar 26 11:45:00 CDT 2008 (CORRECT)
> web server: Wed Mar 26 11:45:00 CST 2008
> Note CDT versus CST.
>
> "date -u"
> mail server: Wed Mar 26 16:45:00 UTC 2008 (CORRECT at 11:45 AM local
> time [Central Daylight Time (CDT) is UTC minus 5 hours])
> web server: Wed Mar 26 17:45:00 UTC 2008
>
> From a test CLI script and from the web page test script on the web
> server,
> echo date("Y-m-d H:i:s");
> returns "2008-03-26 11:45:00".
>
> An application PHP script ran on the web server, uses date("Y-m-d
> H:i:s") to generate a timestamp to put in the body of an email sent
> with PHP mail().
> I think the mail() command on the web server forwards to the actual
> mail server (but I am not sure -- how do I verify this?).
>
> An example email (only after we switched to daylight savings time on
> 3/10 and I'm sure our admin had to manually update the clock) shows
> the email header as Mon, 10 Mar 2008 14:35:44 -0500
> and in the email client without looking at raw source as Date: March
> 10, 2008 2:35:44 PM CDT, but the body of the email (which used PHP
> date("Y-m-d H:i:s")) shows 2008-03-10 13:35:44.
> Note 13 instead of 14.
>
> I've asked the admin to make sure the web server reports CDT (I'm
> still waiting), but it seems strange that date("Y-m-d H:i:s") from the
> test scripts already shows the correct info before this change.
>
> Any thoughts?

Because too many sysadmins were NOT updating their time zone database
with package/software updates as they should, the PHP Dev Team got
tired of bug reports et al about messed up dates, and they now include
a CURRENT copy of the timezone database built-in to PHP.

This, of course, violates the principle of having the source in one
place...

But it saves them a lot of headaches.

So PHP "knows" about the recent date-change of when daylight savings
kicks in, but since your sysadmin didn't update the time zone db on
the "web server" the OS does *not* know the correct time.

Daylight Savings Time must die!

Really, there cannot be any real "savings" here... The time wasted by
humanity to reset clocks and fix all the buglets from this stupid
clock-changing game MUST outweight any debatable "benefits"

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Quick email address check

2008-03-26 Thread Richard Lynch
On Wed, March 26, 2008 12:28 pm, Al wrote:
> Is there a better way than simply sending a test email to see if it
> bounces?

Yes.

Force the user to click on a link to prove that they actually CHECK
that email address.

Just because it doesn't bounce doesn't mean it's a valid email address.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date math

2008-03-26 Thread Richard Lynch
On Sun, March 23, 2008 11:17 pm, Ron Piggott wrote:
> I have this math equation this list helped me generate a few weeks
> ago.
> The purpose is to calculate how many days have passed between 2 dates.
>
> Right now my output ($difference) is 93.958333 days.
>
> I am finding this a little weird.  Does anyone see anything wrong with
> the way this is calculated:
>
> $date1 = strtotime($date1); (March 21st 2008)
> $date2 = strtotime($date2); (December 18th 2007)
>
> echo $date1 => 1206072000
> echo $date2 => 1197954000
>
> #86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days
> worth of seconds)
>
> $factor = 86400;
>
> $difference = (($date1 - $date2) / $factor);

float division introduces rounding errors, by the nature of a floating
point representation in a finite number of bits.

Use http://php.net/round and http://php.net/int

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] optimilize web page loading

2008-03-26 Thread Richard Lynch
You can use onload and XmlHttpRequest to send back the desktop client
computer date/time and compare that with your start time.

Note that you'll need to test on [a] computer[s] where you know the
date/time is set correctly, which is not true of the general visitor.

On Wed, March 26, 2008 3:25 am, Alain Roger wrote:
> Hi,
>
> i would like to know if there is a way to know how long does a web
> page need
> to be loaded into browser ?
> this is interesting fact for me, as i will optimilize my PHP code in
> order
> to reduce this time to minimum.
>
> i was thinking to use some timestamp but as it will be in PHP, it mean
> that
> it should take time from server and therefore it is not fully
> representative
> from client browser time needed to load page :-(
> purpose :
> mywebpage.php -> 23 s before optimalization
> mywebpage.php -> 12 s after optimalization
>
> do you have any idea ?
>
> --
> Alain
> 
> Windows XP SP2
> PostgreSQL 8.2.4 / MS SQL server 2005
> Apache 2.2.4
> PHP 5.2.4
> C# 2005-2008
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Cookie Trouble: getting the information back out...

2008-03-26 Thread Richard Lynch
On Tue, March 25, 2008 8:11 pm, Mark Weaver wrote:
> I suspect I already know part of the answer to this, but I'm not sure
> which way to go with it. I've got a project I'm working on and one of
> the things it's got to do is set cookies and then read them later.
> When
> the app was first written I was doing everything in PERL and cookies
> are
> fairly straight-forward, however I'm finding cookies in PHP somewhat
> problematic.
>
> Setting the cookie is a snap, however getting the info back out is,
> well... problematic.
>
> this is basically what I'm doing, what I'm seeing in the cookie, and
> what I'm getting back out.
>
> Setting the cookie
> ==
> $values = "blah|blah|blah";
> setcookie("cookiename", $values, time()+$timevalue);

Because IE engineers CANNOT READ a technical document to save their
lives, you MUST supply a "path" if you supply a "time":

setcookie("cookiename", $values, time() + $timevalue, "/");

You also don't tell use what $timevalue is, so that could be something
very wrong... :-)

> Inside the Cookie
> ==
> Content: blah%7Cblah%7Cblah
>
>
> Getting info Out Of Cookie
> ==
> list($first,$second,$third) = explode("|", $values);

Unless you have register_globals set to "ON" (bad!) then $values will
only have meaning in the setcookie script...

> Cookie Test Page
> ==
> if (isset($_COOKIE["cookiename"])){
>   list($first,$second,$third) = explode('|',$_COOKIE["cookiename"]);
>   echo "I found your cookie\n";
>   echo "The following Values were Contained in the cookie:
> Username: $first
> Password: $second
> Type: $third\n";

You should NOT NOT NOT NOT NOT be storing a username *or* password in
a cookie!!!

> }
> else{
>   echo "I wasn't able to find your cookie.\n";
> }
>
> Now, I've constructed a cookie_test.php page to check things out and
> the
> strange behavior I'm seeing is, upon first execution I get the "else"
> block, but if I hit the browser's reload button I get the "if" block.
> At
> first I thought the cookie wasn't being read at all because of weird
> characters, but then upon reloading the page and seeing the "if" block
> being displayed I'm thoroughly confused. It's gotta something simple
> I'm
> missing.

What *is* in your cookies?

var_dump($_COOKIES);

Perhaps putting '|' in there is not a valid character?

You could base64 encode it or ...

> and I swear if someone tells me to RTFM I'm gonna shit and go blind
> cause I haven't got a clue as to "which" part of the FM to read
> concerning this. :)

It would be some chunk of the Netscape Cookie spec.

Google for "Netscape Cookie spec" and read that.  It's only a page.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] session var not changed if file not found error

2008-03-26 Thread Richard Lynch
On Tue, March 25, 2008 8:29 pm, Eric Wood wrote:
> This has baffled me all day on my FC6 php-5.1.6 based server.
>
> On a normal working page, I set a session variable at the top and
> another session variable in the middle of the page/script.  This page
> has no errors nor missing links.  So everything works great.
>
> Now, if I cause at least 1 image in the page to become missing on the
> server (ie, by deleting a .jpg file), then Apache logs the error as
> usual, ie: "File does not exist".  But in addition, my two session
> variables seem to get deleted.  If I put the picture(s) back, then no
> apache errors, and my session vars are set fine.
>
> I've even enabled detailed php error reporting and I get no errors.
>
> Is this normal session behavior?  Please say no.  Any ideas?  I can't
> understand why missing links would cause a session variable's
> annihilation.

It's not normal.

Perhaps you have some kind of 404 error handler that is destroying the
session.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] loosing session in new window (IE only)

2008-03-26 Thread Richard Lynch
On Tue, March 25, 2008 4:07 pm, Lamp Lists wrote:
> - Original Message 
> From: Andrew Ballard <[EMAIL PROTECTED]>
> To: PHP General list 
> Sent: Tuesday, March 25, 2008 3:41:35 PM
> Subject: Re: [PHP] loosing session in new window (IE only)
>
> On Tue, Mar 25, 2008 at 3:49 PM, Lamp Lists <[EMAIL PROTECTED]>
> wrote:
>> hi,
>>  i have a list of people on one page. each row, on the end has link
>> view details.
>>  it's requested to open detail page in new window.
>>  very few people complained they can't open detail page. all of them
>> use IE.
>>  I wasn't able to reproduce the error, though using GoToMeeting I
>> was able to look while customer was doing it.
>>  I put session info on screen to see what's going on and found that
>> new window doesn't have session info from "old" window?!? like, new
>> window - new session.
>>
>>  does anybody knows anything about this?
>>
>>  thanks.
>>
>>  -ll
>
> If they open a new window by clicking on IE (say, on the desktop, the
> QuickLaunch bar, or the Start menu), Windows actually opens a new,
> totally separate process of IE along side the first. The new one will
> share any persistent cookies with the first, since they are written to
> the file system, but sessions do not usually use persistent cookies.
> As long as your users are opening the new window by clicking a link or
> by pressing  Ctrl+N from the first window, the session information
> *should* remain in tact.
>
> Andrew
>
> should - but don't :D
> you're right and  I understand opening new window from "desktop"
> starts new process, but this is happening after visitor hits the link
> "detail view" and that is confusing :(

WILD GUESS ALERT!

Perhaps the MS version of "open popup in new tab/window" is to start a
whole new process?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Hot job opportunity - Sr. Software Developer/Architect

2008-03-07 Thread Richard Lynch
On Thu, February 28, 2008 10:39 am, Nick Gasparro wrote:
> I have an immediate need for a Sr. Developer/Architect; with one of
> Denver's
> Best employers.  They are a Web 2.0 company, rapidly growing and very
> profitable.  They will pay top compensation and provide relocation
> assistance for the right person.

It is customary for geographically-challenged job postings to include
the location in the subject.

Thanks!

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] regular expressions question

2008-03-07 Thread Richard Lynch
The + requires at least one character.

The * is "0 or more" characters.

http://php.net/pcre

On Wed, March 5, 2008 9:13 am, It Maq wrote:
> Hi,
>
> I am using that right now and i have don't know how to include blank
> fields. For example if a user does not fill a field in a form i want
> to accept it. I tried the code you posted, for now it is blocking
> blank fields.
>
> Thank you
>
> - Original Message 
> From: Richard Lynch <[EMAIL PROTECTED]>
> To: Adil Drissi <[EMAIL PROTECTED]>
> Cc: php-general@lists.php.net
> Sent: Tuesday, March 4, 2008 3:09:09 PM
> Subject: Re: [PHP] regular expressions question
>
> On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
>> Is there any way to limit the user to a set of characters for
>> example
>> say i want my user to enter any character between a and z (case
>> insensitive). And if the user enters just one letter not belonging
>> to
>> [a-z], this will not be accepted.
>>
>> I tried  eregi('[a-z]', $fname) but this allows the user to enter
>> abdg4512kdkdk for example.
>
> What you tried only requires ONE a-z character somewhere in the input.
>
> Try this:
>
> preg_match('^[a-z]+$', $fname);
>
> This will:
> ^ "anchor" the string at the beginning
> [a-z]+ a to z, with at least one letter
> $ "anchor" the string at the end
>
> Note, however, that some people have other characters in their first
> name, such as apostrophe, space, and dash.
>
> Oh, and the digit 3, for "bo3b" who was a programmer on the first
> Apple Macintosh.  His parents were hippies, and that really is his
> name...
>
> You may want to obtain a LARGE list of "first names" and run them
> through your validator as a test.
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
>
>
>   
> 
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] validating mysql bound date

2008-03-07 Thread Richard Lynch
Something like this, perhaps:

preg_match('/^((19|20)[0-9]{2})-([0-1]?[0-9])-([0-3]?[0-9])$/',
$input, $date_parts);
var_dump($date_parts);

This doesn't completely rule out bogus dates such as 2008-02-30 however.

I think MySQL would just convert that to MAR 1, 2008 anyway...

But if you want that degree of comparison:

list(,$year, $month, $day) = $date_parts;
$unix = mktime(1, 0, 0, $month, $day, $year);
list($y, $m, $d) = date('Y-m-d', $unix);
if ($year != $y || $month != $m || $day != $d){
  //handle invalid date input here
}

If you do all of that (which is really 5 lines of code) you should be
pretty sure it's a correct/valid date.

On Tue, March 4, 2008 10:12 pm, Larry Brown wrote:
> Thanks,
>
> I ended up doing:
>
> $incomingQuestDatePieces = explode("-", $incomingQuestDate );
>
> if(checkdate($incomingQuestDatePieces[1],$incomingQuestDatePieces[2],
> $incomingQuestDatePieces[0]))
> {
>   return true;
> }
> else
> {
>   return false;
> }
>
>
> I was just wondering since a lot of people have to verify correct
> format
> of the date when working with mysql that there might be some built in
> that is faster etc.
>
> Thanks though...
>
> On Wed, 2008-03-05 at 14:34 +1100, Chris wrote:
>> Larry Brown wrote:
>> > Its been a long week already... -MM-DD.
>> >
>> > On Tue, 2008-03-04 at 20:16 -0500, Larry Brown wrote:
>> >> Does anyone know if there is a builtin function for checking the
>> >> formatting of an incoming date to verify it is /MM/DD.  I
>> know how
>> >> to convert between formats but want a quick way to check an
>> incoming
>> >> variable to ensure it will be handled properly by mysqld.
>>
>> I normally provide dropdown fields for each (except the year which
>> is a
>> text-field) and put it together how I need it. Validate each part
>> separately and you're off and racing.
>>
>> If you accept any date you'll probably have to split it up first but
>> the
>> principles will be the same.
>>
>>
>> $date = '-00-00';
>> // if they didn't use exactly two dashes? invalid
>> if (substr_count($date, '-') !== 2) {
>>die("Invalid date");
>> }
>>
>> list($year, $month, $day) = explode('-', $date);
>> if (strlen($year) != 4) {
>>die("Invalid year");
>> }
>>
>>
>> and so on.
>>
> --
> Larry Brown <[EMAIL PROTECTED]>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Logging session timeout in DB

2008-03-07 Thread Richard Lynch
On Wed, March 5, 2008 2:08 am, Angelo Zanetti wrote:
> I am implementing a system where when a user is logged in and out that
> a
> date time is set in a database for each action for each used. We can
> then
> trace who logged in a and when.
>
> No what I would like to know is how can I record when a user closes
> the
> browser or the session expires? There is no action for these items. So
> what
> would the best way be to keep a record of this? Would the use of a
> cron job
> be appropriate? I read in the archives that the banks use javascript
> but I
> don't want to go that route.
>
> If anyone has any idea how to do this please let me know, thanks in
> advance.

There is no way to know when they quit/closed the browser or even just
walked away and let the session time out.

But you *CAN* easily log the last time they accessed any page, by
adding something like:

$query = "update user_profile set last_access = now()";
$access = mysql_query($query, $connection);
if (!$access){
  //error handling here
}

So you'll know the last time they actually DID anything, which is
probably more interesting than recording when they closed the browser
if they were looking at some other tab anyway.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Re: Variable post as array

2008-03-07 Thread Richard Lynch
Are you really using temp_name when you want tmp_name?

On Wed, March 5, 2008 4:37 am, Pieter du Toit wrote:
> Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it
> tells
> me that temp_name is also an array, but when i echo
> $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
> vardump i can see that temp name is ["tmp_name"]=> string(14)
> "/tmp/phplR1WSl" and not an array by itself.
>
> Im going crazy here
>
> ""Pieter du Toit"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the
>> variable
>> arrives as an array at the action php file, this is the code, and
>> the
>> variable name is txtPhoto
>>
>> 
>>
>> 
>>
>> 
>>
>> Specials Update
>>
>> 
>>
>> 
>>
>> >
>> echo "> name=\"Edit
>> Special\" action=\"specials_proc.php\">\n";
>>
>> echo "> value=\"$g_client_id\">";
>>
>> echo "> value=\"$special\">";
>>
>> echo "> value=\"$k_subsystem_id\">";
>>
>> echo "> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";
>>
>>
>>
>> if ($special != "")
>>
>> {
>>
>> $new = 0;
>>
>> echo "Edit
>> Special\n";
>>
>> $result = mysql("zululandcoza", "select * from client_specials where
>> client_id = $g_client_id and special = $special");
>>
>> if (list($client_id, $special, $description, $special_type, $price,
>> $discount, $startdate, $enddate) = mysql_fetch_row($result))
>>
>> {
>>
>> }
>>
>> }
>>
>> else
>>
>> {
>>
>> $new = 1;
>>
>> echo "New Special (this
>> page is
>> undergoing maintenance, please try again later)\n";
>>
>> $result = mysql("zululandcoza", "select max(special) from
>> client_specials
>> where client_id = $client_id");
>>
>> if (list($max_special) = mysql_fetch_row($result))
>>
>> {
>>
>> $special = $max_special + 1;
>>
>> }
>>
>> }
>>
>>
>>
>> echo "\n";
>>
>> echo " > class=\"Prompt\">Special Number\n";
>>
>> if ($new)
>>
>> echo " > name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
>> value=\"$special\">\n";
>>
>> else
>>
>> echo " > name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
>> enabled=\"0\">\n";
>>
>> echo "\n";
>>
>> echo "\n";
>>
>> echo " Description\n";
>>
>> echo " > name=\"txtDescription\" maxlength=\"200\" size=\"50\"
>> value=\"$description\">\n";
>>
>> echo "\n";
>>
>> echo "\n";
>>
>> echo " > class=\"Prompt\">Special Type\n";
>>
>> echo " \n";
>>
>> $optPRICE = "";
>>
>> $optDISC = "";
>>
>> $optFROM = "";
>>
>> if ($special_type == "FROM")
>>
>> $optFROM = " SELECTED";
>>
>> elseif ($special_type == "DISC")
>>
>> $optDISC = " SELECTED";
>>
>> else
>>
>> $optPRICE = " SELECTED";
>>
>> echo " \n";
>>
>> echo " Special Price\n";
>>
>> echo " Discount %\n";
>>
>> echo " From\n";
>>
>> echo " \n";
>>
>> echo " \n";
>>
>> echo "\n";
>>
>> echo "\n";
>>
>> echo " Price\n";
>>
>> echo " > name=\"txtPrice\" maxlength=\"20\" size=\"10\"
>> value=\"$price\">\n";
>>
>> echo "\n";
>>
>> if ($k_subsystem_id == 2)
>>
>> {
>>
>> if (! $new)
>>
>> {
>>
>> echo "\n";
>>
>> echo " Current Photo\n";
>>
>> echo " > src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$special\">\n";
>>
>> echo "\n";
>>
>> }
>>
>> echo "\n";
>>
>> echo " New Photo\n";
>>
>> echo " > name=\"txtPhoto\" size=\"50\">\n";
>>
>> echo "\n";
>>
>> }
>>
>> echo "\n";
>>
>> echo " \n";
>>
>> if ($new)
>>
>> {
>>
>> echo " > value=\"Add\"> \n";
>>
>> }
>>
>> else
>>
>> {
>>
>> echo " > value=\"Update\"> \n";
>>
>> echo " > value=\"Delete\"> \n";
>>
>> }
>>
>> echo " > value=\"Cancel\">\n";
>>
>> echo " \n";
>>
>> echo "\n";
>>
>> echo "\n";
>>
>> echo "\n";
>>
>> ?>
>>
>>
>>
>> 
>>
>> 
>>
>>
>>
>>
>>
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Array questions...

2008-03-07 Thread Richard Lynch
On Wed, March 5, 2008 9:35 am, Robert Cummings wrote:

No textbook, but here's some advice...

Think of a variable like a house address for an actual house.

123 Maple Street

An array is just an apartment building:

125 Maple Street, Unit 1
125 Maple Street, Unit 2
125 Maple Street, Unit 3
.
.
.

When you want to talk about the whole array (building) you can use
just the street address.

If you want a specific unit, you have to add the [$unit] part.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] imagerotate

2008-03-07 Thread Richard Lynch
On Wed, March 5, 2008 11:17 am, Zeshan Uddin wrote:

> *
> Code for rotate.php
>
>  // File and rotation
> $filename = 'image.png';
> $degrees = 18;
>
> // Content type
> header('Content-type: image/png');
>
> // Load
> $source = imagecreatefrompng($filename);
>
> // Rotate
> $rotate = imagerotate($source, $degrees, 0);

This line does the actual rotation, and, along with $degrees = 18, is
all you need to add to the other script.

>
> // Output
> imagepng($rotate);
> ?>
>
> 
>
> Code for resize.php
>
>  $src_img = imagecreatefrompng('image.png');
> $srcsize = getimagesize('image.png');
>
> $dest_x = 200;
> $dest_y = (200 / $srcsize[0]) * $srcsize[1];
> $dst_img = imagecreatetruecolor($dest_x, $dest_y);
>
> imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,
> $dest_x, $dest_y, $srcsize[0], $srcsize[1]);

You can add them here, after the image is resized, and you are done.

> header("content-type: image/png");
>
> imagepng($dst_img);
> imagedestroy($src_img);
> imagedestroy($dst_img);
> ?>
>
>
> thanks
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Re: Preserving URL after redirect?

2008-03-07 Thread Richard Lynch
On Thu, March 6, 2008 6:42 am, Jochem Maas wrote:
> big boys use mod_rewrite, go grab a kilt :-)

If mod_rewrite gives you the willies...

You don't really NEED it here...

Just don't create /wi/* directories, and use $_SERVER['PATH_INFO']
instead.

Store all the school data somewhere else, and let the PHP/AJAX spew it
out as needed based on the URL, with only an index.php file running
the whole site.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Preserving URL after redirect?

2008-03-07 Thread Richard Lynch
On Wed, March 5, 2008 11:18 am, Skip Evans wrote:

> "shortname", in this case "madison", and then sets
> a session variables for school ID that allows the
> user to access this school's data.
>
> Then it redirects back to
>
> http://prepcube.com/


Don't redirect to this.

Your session data has "wi/madison" in it, redirect to that:

header("Location:
http://precube.com/$_SESSION[state]/$_SESSION[shortname]";);

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Pear Installation Problem - Ubuntu

2008-03-07 Thread Richard Lynch
SPM decided to move stuff to a different place, namely inside of a
/usr/share/php/PEAR directory, instead of just /usr/share/PEAR.

So change your include path and be done with it.

On Wed, March 5, 2008 11:59 am, Stephen wrote:
> My LAMP is on Ubuntu 7.10
>
> I am trying to use PEAR, for the first time, and get an error about
> the
> include file not being found.
>
> It is not there.
>
> phpinfo() has include_path set to .:/usr/share/php:/usr/share/pear
>
> Here is my error:
>
> Warning: require_once(HTML/QuickForm.php) [function.require-once]:
> failed to open stream: No such file or directory in
> /home/stephen/www/roissy.ca/public_html/quotesForm.php on line 3
>
> Fatal error: require_once() [function.require]: Failed opening
> required
> 'HTML/QuickForm.php' (include_path='.:/usr/share/php:/usr/share/pear')
> in /home/stephen/www/roissy.ca/public_html/quotesForm.php on line 3
>
> Now I have always just used the Synaptic Package Manager, and I just
> did
> a reinstall of PEAR.
>
> But there is no /usr/share/pear directory.
>
> I have a /usr/share/php/PEAR and it has things that look like
> installation files.
>
> I am venturing where I have not before. I have never performed any
> kind
> of CLI install.
>
> Can anyone help me figure out how to get the installation fixed?
>
> Thanks
> Stephen
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Universaly Accepted Naming Conventions..?

2008-03-07 Thread Richard Lynch
On Wed, March 5, 2008 1:06 pm, John Papas wrote
> Are there any in PHP?
>
> It seems like there are those that draw upon the C/unix naming
> conventions and those that follow the Java/OO style.

There are several popular "standards" out there.

The PEAR coding standard and the Zend one tend to get mentioned a lot.

The most important thing is to be consistent yourself, rather than to
follow a specific standard.

Anybody halfway decent can follow what you did if you are consistent.

> Even PHP's native syntax (like function names pre/post v5) are not
> consistent.

They ARE consistent with the underlying libraries, which is more
important, really, because that means you don't have to waste hours
figuring out what PHP did to shoe-horn the other library's functions
into some other system.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] How to measure memory leakage/usage in PHP?

2008-03-07 Thread Richard Lynch
On Wed, March 5, 2008 9:57 pm, Zareef Ahmed wrote:
>I am looking into the concepts behind memory management in PHP.
> Which
> kind of approach will be best to measure memory leakage or usage in a
> PHP
> script?
>
> I can measure my apache process but is there any way by which I can
> know
> which exact part of script is consuming how much memory?

valgrind is an excellent tool for this sort of thing.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Re: Transferring files between computers using php

2008-03-07 Thread Richard Lynch


On Thu, March 6, 2008 11:10 pm, Chris wrote:
>
>> If ssh keys are installed on the remote hosts then scp works
>> transparently and you just stick the scp in a cron job.  Am I
>> missing
>> something?
>
> Yeh - looks like you have to log in to "A" and then it uses
> key-forwarding to let you log in to "B" and "C":
>
> ---
> To login to B and C I should use A because it has a SSH key. I don't
> have any other way of accessing these two computers.
> ---
>
> ie B & C can't talk to each other directly (that's my understanding
> anyway).

Scenario #1:
B&C can't talk for a reason.
Ergo, you SHOULD use A as a go-between

Scenario #2:
B&C could talk if you wanted them to.
Install SSH key-pairs on B&C and then use rsync over SSH

There's still no PHP involved, really...

Maybe there should be, in that the two programs should, perhaps,
expose something as web services via RCP, REST, or SOAP, but not from
what has been explained so far...

@OP:
Please give us the "big picture" of what B&C are doing, and what info
needs to go back and forth.

This could change the answers dramatically.

Or not. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Transferring files between computers using php

2008-03-07 Thread Richard Lynch
On Thu, March 6, 2008 7:58 pm, Rahul wrote:
> I have a small file to be transferred between two computers every few
> seconds.

Use rsync

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



RE: [PHP] CVS Scripts

2008-03-06 Thread Richard Lynch
On Thu, March 6, 2008 10:02 am, Wolf wrote:
>> I am using Zend Studio Server and I haven't upgraded to Zend Studio
>> for
>> Eclipse as yet.  It also has some CVS capability not its not what I
>> am
>> after.
>>
>> Google was my first stop but it didn't turn up anything which
>> appeared to be
>> in a stable enough state.  Hence my email to the list to see if
>> anyone else
>> had come across such a solution.  My application is built from
>> several
>> modules contained with cvs.  Some of these modules are used across
>> projects.
>> I wanted to create my own web-based script to check these out of cvs
>> and to
>> build and configure the application on the fly.
>>
>> I had a look at cruisecontrol but its not really what I am looking
>> for
>> either.
> 
>
> You're probably going to have to code that sucker on your own and
> slide it in as a cron job on your build server to get the
> latest/greatest whenever needed.  I haven't come across anything like
> it before, but I definitely like the concept.

Perhaps something very low-brow simple could work for a short-term
solution, while you code up the fancy internal PHP CVS functions one:



The remaining functions are left as an exercise for the reader. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Question about PHP Licence and it's future!

2008-03-04 Thread Richard Lynch
On Sat, February 23, 2008 10:50 pm, Tamer Higazi wrote:
> I have asked myself a question. After I saw, that SAP will no more
> release future Versions of their open source Database MaxDB under the
> GPL License, I have asked myself either if this could happen with PHP.

No.

For starters, all the core developers are very committed to PHP being
Open Source.

Secondly, Zend has gone "on record" saying that the Zend Engine will
always be Open Source.  I know, cuz I said so when I worked there. :-)

> Who owns PHP? Is it Zend Technologies or the PHP Group itself? "Who"
> is
> the PHP Group and what makes the PHP Group?

Who owns any GPL for FOSS-licensed software?

The community.

> Who guaranties that future Versions of PHP stays open source and are
> being released under the Terms of the General Public Licenses?

The community.

There are MORE than enough users who would fork it in an instant if
anybody was foolish enough to try and close it.

> Can future Versions from one day to the other no more being released
> under the GPL, only under a closed source license? Let us say, PHP
> would
> be distributed for several architectures only in binary forms and the
> PECL modules stay open source.

Not gonna happen.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Weird Zend IDE Issue

2008-03-04 Thread Richard Lynch
On Mon, March 3, 2008 10:49 am, Jochem Maas wrote:
> Richard Lynch schreef:
>> On Sun, March 2, 2008 11:07 pm, Steve Finkelstein wrote:
>>> Hi all,
>>>
>>> I know this isn't a forum for Zend IDE, but since there's probably
>>> a
>>> decent population here using it, I figured I'd ask away.
>>>
>>> I'm using 5.5.1 Professional on Mac OSX 10.5.2.  My issue here is
>>> that
>>> all left brackets, (eg: [ ) are not showing up in the code editor.
>>> I
>>> have a screenshot of it here:  http://catalyst.httpd.org/zend.png
>>>
>>> Has anyone ever experienced anything similar?
>>
>> Looks to me like your monitor needs adjusting, and it's just not
>> showing that column of pixels.
>
> I think it's more a case of grubby font display in Java apps running
> on
> Mac OS X (leopard at least).
>
> when is the last time you saw a Mac (iMac or MacBook) with dodgy
> monitor settings?

I dunno about iMac or MacBook, but I saw a TON of Macs with dodgy
monitor settings all the time back in the day!

Sometimes on the desk of Graphic Artist who then got cranky when their
images were messed up on a well-tuned monitor...

So unless Apple has perfected the auto-tuning of a monitor or
something, I'd be surprised if it *was* correctly-tuned.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] PHP performance

2008-03-04 Thread Richard Lynch
#1
Get the code, install it on a box in the closet, run valgrind --callgrind

This will give you a stack trace of what gets called the MOST in your
application.

Look for "tall" trees in the call graph, and fix those first.

#2
You can use 'ab' (apache benchmark) or similar to test it externally.

#3
You can also script things with Selenium IDE and then use Selenium
remote control to run them repeatedly, for the end-user experience.

Don't let server non-access stop you from doing #1 though...

On Mon, March 3, 2008 11:09 am, Thiago Pojda wrote:
> Guys,
>
> I've been asked to build a performance report for a PHP app. I can't
> profile
> it using automated tools as I don't have full access to the server,
> only to
> the application itself.
>
> It's a PHP4 Object-Oriented app, which uses ADODB as abstraction layer
> with
> a Oracle 8i databse. The system also uses a VB.NET socket server for
> some
> data manipulation.
>
> As for migrating to PHP5 I think it's crucial, but I need facts that
> it
> really runs faster than PHP4. Anyone? :)
>
> Any ideas on what might be the bottleneck?
>
> Thanks guys
>
> Atenciosamente,
>
>
>   www.softpartech.com.br
>
>
> Thiago Henrique Pojda
> Desenvolvimento Web
> +55 41 3033-7676
> [EMAIL PROTECTED]
> Excelência em Softwares Financeiros
>
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Making an interactive RGB color picker

2008-03-04 Thread Richard Lynch
for ($red = 0; $red < 256; $red++){
  for ($green = 0; $green < 256; $green++){
for ($blue = 0; $blue < 256; $blue++){
  $output = << This may not be exactly what you think, but I didn't know how else to
> word
> the title. I basically need to make a script that will go through
> every
> possible color combination and print them to look just like (or
> similar) to
> the windows color picker. I need it in the format X-Y-Z. For example:
>
> 255-255-255
> 255-254-254
> 255-253-253
>
> What I have so far is this:
>
> ***
>  $break = print"";
> $n1 = "255";
> $n2 = "12";
> $n3 = "186";
>
> $output = print"
> \$drawrect(\$get(color_x),\$get(color_y),\$get(color_w),\$get(color_h),brushColor-$n1-$n2-$n3
> penColor-$n1-$n2-$n3)
> \$button2(\$get(color_x),\$get(color_y),0,0,\$get(color_w),\$get(color_h),,,PVAR:SET:colorize_global:brushcolor-$n1-$n2-$n3
> pencolor-$n1-$n2-$n3,TOOLTIP:\"$n1-$n2-$n3\")
> ";
>
> $output
> ?>
> ***
>
> The $drawrect, $button2, and $get are NOT php functions, but to be
> printed
> as actual text (which is why I have escaped them with the backslash).
> Anyways, I thought it would be easiest to separate each R-G-B value
> into its
> own variable ($n1, $n2, and $n3). That way I could just use some code
> (regex?) to cycle through the numbers 0 to 255.
>
> The HARD part (that I can't seem to even think of a way to make it
> possible)
> is to change JUST the G and B values while keeping the R value at 255.
> Then
> when the G and B values both hit 0, the R value is set to 254 and
> repeated
> until it also hits 0 with the other two. I think (?) that will do
> every
> possible color? I also need to print each string with the individual
> color
> output, and I don't know how to do that either.
>
> In short, I would like something that looks just like the windows
> color
> picker, and when each pixel of it is clicked, it will show me the
> R-G-B
> value in the format I would like.
>
> If anyone understands what I am after,and could help, that would be
> awesome!
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Fatal error: Call to a member function web_order_change() on a non-object

2008-03-04 Thread Richard Lynch
register_globals got turned off.

All your $_SESSION variables (in your case, $_SESSION['SESSION']) need
to be reference explicitly now.

Add this at the top:

$SESSION = $_SESSION['SESSION'];
right after session_start();

On Mon, March 3, 2008 5:48 pm, Chris wrote:
> Ben Edwards wrote:
>> Our server has just been upgraded to PHP 5.2.5 and suddenly I am
>> getting the following error:
>>
>> Fatal error:  Call to a member function web_order_change() on a
>> non-object in /var/www/vhosts/cultureshop.org/httpdocs/cart.php on
>> line 32
>>
>> The code is:
>>
>> $SESSION["cart"]->web_order_change( true );
>>
>> The command 'global $SESSION;' is the first line of the script.
>>
>> $SESSION is the session variable created with
>>
>> session_start();
>> session_register("SESSION");
>>
>> if ( !isset($SESSION["cart"]) ) {
>>   $SESSION["cart"] = new Cart;
>> }
>>
>> I am guessing this is a change in OO handling, any idea what is
>> going
>> on and how to fix it?
>
> I don't think it's a change in OO handling, maybe it's a change in the
> error_reporting level for the new version and you hadn't noticed the
> problem before.
>
> The problem is that $SESSION['cart'] isn't an object - you'll have to
> work out why.
>
> It could be that $SESSION['cart'] is getting overridden at some point
> with another type of variable.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Crop part of existing pdf

2008-03-04 Thread Richard Lynch
On Mon, March 3, 2008 8:14 pm, gary liang wrote:
> Is there any command line tool, which is able to crop part of pdf
> file? I ask for command line tool, because it can be used in php code.
> Any hint?

The commercial version of phpLib might do that.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] 2 Questions: Static variables and the nature of the online manual

2008-03-04 Thread Richard Lynch
On Tue, March 4, 2008 10:12 am, Svevo Romano wrote:
> Still, I jusy wonder how Jochem knew that the line is only executed
> the
> first time a function is called while this info is not available on
> the
> online manual. It's maybe all about how close you are to the community
> and
> how many degrees are between yourself and the source?

That's how it works in C.
And Perl.
And Modula-2.
And Ada.
And Pascal.
And even Lisp.
.
.
.

After you've learned a couple computer languages, the rest are mostly
about "differences" and "gotchas" rather than learning something new.

Ok, except the Lisp/Scheme/Prolog stuff, where you have to think
inside-out. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] 2 Questions: Static variables and the nature of the online manual

2008-03-04 Thread Richard Lynch
On Tue, March 4, 2008 6:16 am, Svevo Romano wrote:
> Hello,
>
> I got this e-mail address from the ŒAdd note¹ page within the php.net
> website. I was going to post something that was a question and I
> realised I
> was in the wrong place :)
>
> I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m
> a bit
> new to php.
>
> The first question has to do with the static variables. I understand
> how
> this works from the examples, but there is something that I cannot
> seem to
> find clearly stated anywhere on that page.
>
> The example:
>
>  function Test()
> {
> static $a = 0;
> echo $a;
> $a++;
> }
> ?>
>
> Of course works (I¹ve tested it on my server), but it is still obscure
> to
> me, according to general programming principles, since I¹m still
> assigning
> zero (0) to $a on each call to the Test function. How does this
> exactly work
> when the static word is found? Is there and index that keeps track of
> each
> call to the function ignoring any assignment in subsequent calls to
> the
> function? Why doens¹t this work when you assign an expression result
> to the
> variable?

It's not an assignment, it's an initialization, and, yes, the compiler
does "keep track" and doesn't do that after the first time.

*THIS* would be what you describe:
function Test(){
  static $a;
  $a = 0;
  echo $a;
  $a++;
}

> The second question has to do with the online manual. I¹ve found
> several
> things on that manual specified in comments and not in the actual
> manual
> part of it. What is the nature of the manual? Contributions from
> voluteers?

The manual is contributions from volunteers who have been "blessed" by
the other volunteers (viz) to edit the manual.

The "Notes" is from anybody on the planet with a web browser that can
beat the CAPTCHA.

> Is there any official manual I can buy that documents everything about
> the
> language from the source? Or any official company that maintains the
> language and that possibly offers support as well?

There is nothing you can buy that's more official (nor more complete)
than the on-line manual.

You can buy support from Zend, which is a separate company run by two
guys who happen to be core developers;  You can probably buy support
elsewhere as well.

PS
If you can find a language with a better manual, I'd like to see it...
:-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] maintaining [user] state without a session ...

2008-03-04 Thread Richard Lynch
On Tue, March 4, 2008 10:22 am, Jason Pruim wrote:
>
> On Mar 4, 2008, at 11:11 AM, Daniel Brown wrote:
>
>> On Tue, Mar 4, 2008 at 11:09 AM, Stut <[EMAIL PROTECTED]> wrote:
>>> On 4 Mar 2008, at 15:52, Daniel Brown wrote:
 On Tue, Mar 4, 2008 at 9:10 AM, Stut <[EMAIL PROTECTED]> wrote:
> I'm working on an article
> for my website that describes exactly how I'm doing it and what
> the
> issues are but it's not ready yet. I'll let the list know when
> it's
> done.

   Is it done yet?
>>>
>>> No. I have a day job, that takes priority.
>>
>>You're full of crap.  I have a day job, too, but I still feel
>> like
>> I spend half of my time reading and responding to list posts.  ;-P
>
> Ummm... Mr. Brown... I'm pretty sure you do :P You need to talk to
> Richard and get the code for his AI so you don't  get in trouble for
> not getting your work done :)

Richard is waiting for a lonng PHP script to push/pull a bunch of
cron output emails out of his Inbox and dump them to a DB so he can
figure out what's going on with the system for his boss, but that
script has cause php to segfault once already, and he is also trying
(and failing) to get a Gentoo Live CD to actually finish an install on
an ancient Compaq Proliant, so pretty much posts while waiting for the
other computers/softwares to crash...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] maintaining [user] state without a session ...

2008-03-04 Thread Richard Lynch


On Tue, March 4, 2008 8:22 am, Bojan Tesanovic wrote:
> Hi,
> It depends what do you need to track,
> if you need to track small amount of variables you can do it by cookie
> I often use it eg here is the state for one user
> $state = array{
> 'logedin'=>true,
> 'n'=>'Peter',
> 'id'=>'5',
> //anything else you need
> }
>
> //at end of you script before outputing any content
> //set cookie only for browser session and set path to '/'  so it is
> available through whole site
> setcookie('user_data',serialize($state),null,'/');

Woof.

So anybody with half a clue could look in their cookies and change,
say, 'id' to '1' and masquerade as anybody they want in your system.

And with an 'id' of '1', they might even getting CMS 'admin' access or
something.

Probably not a Good Idea...

You could, perhaps, use a 2-way encryption algorithm and try to keep
your key as securely as possible, and do this much more safely.

> Also you can use some way to detect if the user is not Search engine
> to display message like
> "To properly use this site you need to enable cookies in your browser
> bla bla "
>
> This can be done via JS alert message which will not be triggered by
> SE but only by real user

Use robots.txt to keep out "real" search engines.

Anybody who REALLY wants to can run your JS with Webmonkey, the JS
engine of Firefox, released as a stand-alone command line tool.
(E.g., JS email obfuscation is useless against somebody with
webmonkey.  Try it and see!)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] regular expressions question

2008-03-04 Thread Richard Lynch
On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
> Is there any way to limit the user to a set of characters for example
> say i want my user to enter any character between a and z (case
> insensitive). And if the user enters just one letter not belonging to
> [a-z], this will not be accepted.
>
> I tried  eregi('[a-z]', $fname) but this allows the user to enter
> abdg4512kdkdk for example.

What you tried only requires ONE a-z character somewhere in the input.

Try this:

preg_match('^[a-z]+$', $fname);

This will:
^ "anchor" the string at the beginning
[a-z]+ a to z, with at least one letter
$ "anchor" the string at the end

Note, however, that some people have other characters in their first
name, such as apostrophe, space, and dash.

Oh, and the digit 3, for "bo3b" who was a programmer on the first
Apple Macintosh.  His parents were hippies, and that really is his
name...

You may want to obtain a LARGE list of "first names" and run them
through your validator as a test.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] imap_setflags_full Seen [SOLVED]

2008-03-04 Thread Richard Lynch
On Mon, March 3, 2008 7:04 pm, Richard Lynch wrote:
> I am trying to use this:
>
> imap_setflag_full($imap, $uid, "Seen", FT_UID) or die("Unable to
> mark message as \\Seen");
> to mark a message as "read"

Ah-ha!!!

The docs specify for Flags that the values are:
\\Seen \\Answered...

But the actual source and the RFC use data such as:
\Seen \Answered

This makes all the difference in the world!

I've added a note and submitted a Docs bug report.

And now anybody finding this thread will know what to do too. :-)

It works with "\\Seen" (which is to say, \Seen)

Reminiscient of Magic Quotes, eh?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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