Re: [PHP] Sending out mass emails

2008-09-04 Thread mike
In my opinion, this is what MTAs are designed for...

Personally I throw every email I need to send at the MTA (postfix is
the best!) and then let it handle processing the queue. If it goes too
slow or too fast that's when you can alter the configuration

(Side note: I'm pretty sure phpmailer would have some sort of delay
built in, it seems to be quite feature-rich) or you can always build
in your own manual loop, use sleep() or just launch the script and
only run $x number of emails each time...

On Thu, Sep 4, 2008 at 6:47 AM, Angelo Zanetti [EMAIL PROTECTED] wrote:
 Hi all,

 We would like to send out mass emails for some of our clients, these are
 HTML email and text alternative for the email clients that cant read those
 HTML emails.

 We have developed some scripts to send the emails using phpmailer.

 Now we anticipate sending emails in batches but not sure how many at once.

 Also what is the best way about going around being black listed due to spam
 issues.

 I know that the headers need to be set to avoid being detected as spam.

 Any advice is appreciated.

 Thanks
 Angelo




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



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



Re: [PHP] Altering the error_reporting

2008-09-03 Thread mike
couldn't a user-defined error handler work for this?

http://www.php.net/manual/en/function.set-error-handler.php

obviously it would require the script that has the error handler still
be parsable.

but you get the info in the format:

handler ( int $errno , string $errstr [, string $errfile [, int
$errline [, array $errcontext ]]] )

you could print out the first two pieces, and not the last 3...


On Wed, Sep 3, 2008 at 5:10 PM, Jochem Maas [EMAIL PROTECTED] wrote:
 Micah Gersten schreef:

 This seems like a futile activity.  It's a waste of time to have to hunt
 down an error if you can be told where it is.  I suggest spending time
 improving coding standards that error chasing.

 besides, try grepping the archives for the number of posts that post errors
 which include the file and line number that ask what, why and where whatever
 is
 going wrong.

 finding someone on that level who actually reads the complete error message
 and attempts to act on it is a hard task by itself. :-D

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 [EMAIL PROTECTED] wrote:

 I am looking for a way to alter the error_reporting(E_All)
  This displays Parse error: parse error, unexpected '}' in
 /var/www/html/test.php on line 7

 I want to remove the file location and line number from the error
 to only produce
 Parse error: parse error, unexpected '}'

 Why? You may ask.

 I am writting a code tester in php but i do not want to display the in
 portion. This will make you find the error on your own. As a learning tool.

 Understand I have error reporting off in the php.ini file and call the
 errors in the php script with ini_set('display_errors', 1);.

 I am sure this is doable I just cant figure out how to do this without
 altering the php.ini file.





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



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



Re: [PHP] How to set sending e-mail address?

2008-09-03 Thread mike
Return-path is used by mail daemons, not usually shown in client emails

That's what From or Reply-to is for...

Return-path is valuable for capturing bounces and stuff. I always set
it to a bounce@ alias, and then the From: is always the friendly
display address.

I also use popen() to open a connection directly to my sendmail binary
(/usr/sbin/sendmail -t -f -i [EMAIL PROTECTED]) it
seems to act instantly where I've had some oddities with PHP's mail()
in the past.

On Wed, Sep 3, 2008 at 10:53 PM, Anders Norrbring [EMAIL PROTECTED] wrote:
 I'm trying to figure out how to set the sending address when sending e-mail
 from PHP, but it doesn't seem like I'm having much success..

 When I look in the mail queue, I always see '[EMAIL PROTECTED]' as the
 origin (the web server user).

 In my sending routine I set headers like this:
 $hdrs = array(
 'From'= $MAILFROM,
 'Subject' = iconv(strtoupper(CHARSET), ISO-8859-1, $subject),
 'Reply-To' = $MAILFROM,
 'Date' = date(r),
 'Return-Path' = '[EMAIL PROTECTED]'
 );

 Oh, the mail sent doesn't use the Return-Path I set, it's still set as
 [EMAIL PROTECTED]
 What else can I do, and what have I missed?

 Anders

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



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



Re: [PHP] Secure way to handle pw on session.

2008-09-02 Thread mike
As an additional note suhosin can transparently encrypt and decrypt  
your session data for reasons just like the /tmp issue. It happens  
without you needing to configure anything (except to enable or disable  
it) I think it is enabled by default.


On Sep 2, 2008, at 12:35 PM, Dan Joseph [EMAIL PROTECTED] wrote:


On Tue, Sep 2, 2008 at 3:27 PM, k bah [EMAIL PROTECTED] wrote:



Hi,

I noticed session files are kept on /tmp for a while, and even if  
they
were immediately deleted, well, someone could use one of my php  
scripts to

inject code and read them, since they belong to the httpd user.
What's the best way to receive passwords thru a form and store them  
in the
$_SESSION while I process other information to decide whether or  
not that
user is able to proceed and login (check to see if user is also  
allowed to
use that service, not just validate user/pw)? I use https, always,  
no plain

http is used.

Thanks

=


--
Powered by Outblaze

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



I personally would recommend you never store passwords in $_SESSION.

I don't know how your auth code works, but the way I've always done  
it would
be to process everything when you his submit, with the password  
being in
$_POST or $_GET, then after you authenticate the user, drop it and  
don't
store it with sessions.  If you find you need it to be stored for  
other

things, I'd suggest rethinking the design/checking you're doing.

--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


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



Re: [PHP] Re: Google Maps Distance Between UK Postcodes

2008-09-01 Thread mike
This is what I have:

$distance = number_format(ceil(69*rad2deg(acos(sin(deg2rad($ulat)) *
sin(deg2rad($vlat)) + cos(deg2rad($ulat)) * cos(deg2rad($vlat)) *
cos(deg2rad($ulong - $vlong));

where:

$ulat = latitude of user #1
$ulong = longitude of user #1

$vlat = latitude of user #2
$vlong = longitude of user #2

it seems to work properly at least with US data. I assume any
longitude/latitude date will work fine with it. If anyone has links to
other countries' zipcode mappings I'd love to be able to add that to
my site :)

(I basically took a MySQL query and mapped it to the PHP functions)

On 9/1/08, Tom Chubb [EMAIL PROTECTED] wrote:

  snip
   public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
  false)
   {
 $multiplier = 6371;
 if ($blnMiles)
   $multiplier *= 1.609344;
 
 $rv = ESQL
   (ACOS(
 SIN(RADIANS($latA)) * SIN(RADIANS($latB))
 + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
  RADIANS($lngA)))
   * $multiplier)
  ESQL;
 return $rv;
   }

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



Re: [PHP] Javascript mailing list

2008-08-30 Thread mike
look at jquery - it will make working with javascript so much easier
and has it's own community around it too.

On 8/30/08, Richard Heyes [EMAIL PROTECTED] wrote:
 Hi,

 Can anyone recommend a good Javascript related mailing list?

 Thanks.

 --
 Richard Heyes

 HTML5 Graphing:
 http://www.phpguru.org/RGraph

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



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



Re: [PHP] Converting JPG to Windows BMP

2008-08-29 Thread mike
If I recall gd doesn't support bmp. However that was probably long  
before gd2 and I started using imagemagick anyway and have since. You  
should look into it especially if php doesn't have support via gd.


On Aug 29, 2008, at 5:06 PM, Dan Joseph [EMAIL PROTECTED] wrote:

On Fri, Aug 29, 2008 at 8:02 PM, Edward Diener [EMAIL PROTECTED] 
wrote:


I have a JPG file on the server which I want to convert to a  
Windows BMP
file. How can I do this in PHP ? I did not see a GD image function  
for doing

this.

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


Actually, I think I misread you there...  Sorry...  I have no idea  
either!


--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


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



RE: [PHP] Re: concatenating with . or ,

2008-08-28 Thread Ford, Mike
On 27 August 2008 18:45, Jay Blanchard advised:

 tedd-o has been around for a long time and has witnessed the evolution
 of said blow-ups dolls enough to know when he sees quality, form and
 function. 
 
 I think I may be the second oldest regular on the
 listtedd and I had
 that discussion once before. So I am stuck neither in the
 toolbox or the
 crayon box.

H'mm -- I think I might be competing in the golden oldies category,
too, although from comments made on the list I think tedd at least beats
me.  I guess I'm a bit of a rusty scalpel these days (used to be good at
fixing other people's problems / never seen the point(!) of blow-ups) --
so does that put me in an alternative toolbox??! ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Re: concatenating with . or ,

2008-08-28 Thread Ford, Mike
On 27 August 2008 19:04, Jay Blanchard advised:

 [snip]
 My memory may be a bit off but I think tedd is around 4017 (he uses
rocks
 if you can recall) [/snip]
 
 I am certainly no less virile. Let's see if anyone can GREP this
 reference for my age; I was born The Day the Music Died

Oh, so you're a couple of months older than my younger brother...!! ;)
;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730



To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Re: Variable name as a string

2008-08-28 Thread Ford, Mike
On 28 August 2008 04:26, Micah Gersten advised:

 You cannot have anything in the brackets for the name in a checkbox
 group.  The brackets specify that it is an array.  The name
 of the array
 is the key in $_POST that contains the values of the checkbox group
that
 were checked.  You can have as many groups as you like.

So how come I have several million *working* forms that do exactly what
you say I can't? (OK, so I exaggerate, but it's still significantly more
than none! ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Re: Variable name as a string

2008-08-28 Thread Ford, Mike
On 28 August 2008 00:04, tedd advised:

 At 12:07 AM +0200 8/28/08, Maciek Sokolewicz wrote:

 input type=check name=my_checkboxes[1] value=1 / 1br /
 input type=check name=my_checkboxes[2] value=1 / 1br /
 input type=check name=my_checkboxes[3] value=1 / 1br /
 input type=check name=my_checkboxes[4] value=1 / 1br /
 
 $my_checked_checkboxes = $_REQUEST['my_checkboxes']; // whichever
 you wish, $_GET or $_POST, I don't care right now; you choose.
 
 Yeah, I remember that -- but a bit different.
 
 Don't use indexes, but rather just my_checkboxes[]
 
 and on the php side
 
 $my_checked_checkboxes = $_REQUEST['my_checkboxes'];
 
 The array $my_checked_checkboxes equals the $_REQUEST$_/$_POST/$_GET
 array -- all the indexes will match (i.e., $my_checked_checkboxes[3]
is
 the same as $_POST[3]). 
 
 The only problem I have with that method is that the [] becomes
 confusing with dealing with javascript that can also handles the form.
 
 One of the ways to get around this is to:
 
 input type=checkbox name=my_checkboxes[]
 id=my_checkbox_1 value=1 
 
 That way php will use name and javascript will use id.

Why???

  form name=my_form ... 
 input type=checkbox name=my_checkboxes[] ... 
  /form

  script language=Javascript
  checkboxes = document.my_form[my_checkboxes[]];
  /script

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Re: concatenating with . or ,

2008-08-28 Thread Ford, Mike
On 28 August 2008 16:40, tedd advised:

 
 I'm really not that old, I wrote my first line of code in college in
 1965 -- I even remember the problem. It was how long a swimming pool
 would take to drain to a trickle with the drain open and a garden
 hose filling it. Of course, we were given all the data to solve it,
 but it was more an adventure in keypunching than programming.
 
 Considering that I never took a deferment for college, I was drafted
 in 1966. I didn't even know what Vietnam was -- at the time.

Ha! You beat me by about 10 years, then -- in 1966, I was a strange
English kid attending 4th grade at a School in Santa Monica, CA.  (My
dad was in a group of engineers seconded to his company's Los Angeles
parent for a year, and the company paid for families to go too, lucky us
;)  Lots of memories and odd stories -- I think my favourite is one my
dad told for many years afterwards about his first few days in the
drawing office where they worked mainly in pencil, and the shock on the
face of the prim elderly secretary when he raised his head and asked, in
all innocence, if anybody had a rubber!!!  And one complete non-memory
-- as I was in the US for the summer of 1966, I had no idea the England
football team had won the world cup until long after we returned to the
UK in 1967.

And I'm convinced that a year's acclimatization to California climate,
conflicting with native British reflexes, accounts for my body's strange
reaction to exactly 68 degrees Fahrenheit

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730



To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Regex for email validation

2008-08-27 Thread mike
 On 8/27/08, VamVan [EMAIL PROTECTED] wrote:
 Hello Guys,

 Does any have a regex for email validation? I need to allow only period and
 underscore in the local part , we would need a @ and .com or watever for
 domain.

php should have a good check built-in.

see http://www.php.net/manual/en/function.filter-var.php

if(!filter_var($var, FILTER_VALIDATE_EMAIL)) {
  echo invalid email;
}

some people also go the extra mile and verify the MX record is valid,
or lookup the MX record and even validate the user exists by querying
the mail server.

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



Re: [PHP] Regex for email validation

2008-08-27 Thread mike
Honestly, I'd stick to using php's filter extension.

It -should- be the best one out there. If it is not processing
something it should, then it's a bug - submit it so all of us benefit
:)

I am tired of trying to find regexps and all that every time, I put my
stock into PHP's core when I can.

On 8/27/08, Lupus Michaelis [EMAIL PROTECTED] wrote:
 mike a écrit :
 
  php should have a good check built-in.
 
  see http://www.php.net/manual/en/function.filter-var.php
 

  Argh ! Howmany times it is in ? I spent so many time to write a regex that
 belongs the RFC822 :-/ Because all the regex in answer here was false. They
 don't allow email like Mickael Doodoo@lupusmic.com nor
 [EMAIL PROTECTED] ; and they are valuable email addresses. Without
 the fact that a top level domain isn't always between two and three
 characters (think about .museum).

 --
 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] Large/unreliable file uploading over HTTP

2008-08-26 Thread mike
Let's face it - HTTP is not very good for file uploads. It's stateless
nature, slow connections, inability to resume (technically), etc, etc.

What I've been thinking about is a way to skip all the normal
annoyances with file uploading - multipart form encodings, file upload
tools with specific needs, PUT vs POST, connection resets, ... the
list goes on and on.

Usenet and BitTorrent and other protocols have the right idea - split
up the workload into smaller sets of data. It's easier to operate on.
Usenet has NZB files. BitTorrent splits everything up into chunks. Not
only would it make working with the data more portable (no need to set
your PHP memory limit or POST limits to insane amounts to support
large files) but it could also support multiple segments of the file
being transferred at once...

Here's somewhat of a process braindump of what I'm thinking. It still
requires a 'smart' applet (Flash, Java, anything that can split a file
up and send data over HTTP/HTTPS) - no special socket needs, no PUT
support needed, don't even need to use multipart POST encoding (as far
as I know) - just send the data in chunks over the wire and have a PHP
script on the other side collect the data and reassemble it.

Does this sound insane? I think this is a pretty good approach - no
PUT needed, no large POST configuration required, anything could
upload to it as long as it sends the information properly (I'm
thinking HTTP POST for the header info, and the data could be sent as
another POST field maybe base64 encoded or something that will stay
safe during transit...)



- take input file, checksum it (md5 / sha1)
- calculate number of chunks to split it up based on $chunk configured
size (for example 128k chunks)
- split the file into chunks of $chunk size and create checksums for
all (could use sfv?)
- send request to the server - with the info - use JSON?
action=begin
filename=$filename
filesize=$filesize
checksum=$checksum
segments=list of segments (unique segment id, checksum, bytes)
- server sends back a server ready and unique $transaction_id
- start sending to the server, send header with transaction key and
unique chunk identifier in it
action=process
transaction=$transaction_id
segment=$unique_segment_id
   data=base64_encode($segment_data)
- when done, server sends back $transaction_id, $segment_id, $status
(okay, fail)
- client compares checksum for identifier, if okay, move to next chunk
- if it does not match, retry uploading to server again
- when all chunks are done, send request with transaction key and
action=finish
transaction=$transaction_id
   - when the server receives this, it assembles the file
from the segments and does a final checksum, and reports the checksum
back to the client (warning: on a large file this could take a bit?)
and sends back $transaction_id, $checksum
- client does one last check against the file's original checksum, if
it matches report success, otherwise report failure (would need to
determine why though - if all segments match this should not be able
to happen...)

I'd appreciate everyone's thoughts. This would also allow for file
upload progress, more or less, as the server and client are constantly
communicating when chunks are done and in progress (but again, that
has to be done with an applet)

I can't think of any method to do it in-browser, but doing it this way
could open the gates for things like Google Gears to possibly work
too...

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



RE: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-26 Thread Ford, Mike
On 25 August 2008 00:54, Govinda advised:


 
 
 if (stripos(strrev($file), gpj.) === 0) {
  echo $file;
 }
 
 note the ===, 3 equals signs here is very important! check the docs
 for why.
 
 == means 'equals', and === means 'is identical to'.
 Seems like they would do the same thing when comparing '0' to 'the
 position in the string where that substr is found'.  Why not?

They would -- but stripos will also return FALSE if there is no match,
and FALSE==0 too!

 or you could go a little more robust with regular expressions
 
 if (preg_match(#^.*\.(jpe?g|gif|png)$#i, $file) {
  echo $file; // any image file is echo'ed
 }
 ahhh reg expressions.  So looking forward to when I can see PHP
 properly/clearly enough to throw them in too!  (meanwhile I better get
 the basics first ;-)

Personally, I might be tempted to do something like this:

   if (($pos = strrchr($file, '.'))!==FALSE):
  switch (strtolower(substr($file, $pos))):
 case '.gif':
 case '.png':
 case '.jpg':
 case '.jpeg':
echo $file;
  endswitch;
   endif;

But then, I might go with the pattern match or the glob() solution, too!
;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-26 Thread Ford, Mike
On 26 August 2008 17:15, James Ausmus advised:

 On Tue, Aug 26, 2008 at 8:57 AM, Ford, Mike
 [EMAIL PROTECTED] wrote:
 On 25 August 2008 00:54, Govinda advised:
 
 snip
 
 Personally, I might be tempted to do something like this:
 
   if (($pos = strrchr($file, '.'))!==FALSE):
  switch (strtolower(substr($file, $pos))):
 case '.gif':
 case '.png':
 case '.jpg':
 case '.jpeg':
echo $file;
  endswitch;
   endif;
 
 snip
 
 Of course, this could be simplified *slightly* by actually taking
 advantage of the loose typing of PHP - change the above if statement
to:
 
 if (($pos = strpos($file, '.')))
 {
 $restOfAboveCodeHere;
 }
 
 This way, if the file is the '.' or '..' files, then you will get a 0
 for the position of the '.', which will evaluate to FALSE. All other
 files will return a non-zero position of the '.' char, which will
 evaluate to TRUE. Also, I would believe (but have no evidence at all
 of) that a forward-looking string position search will be very
 slightly faster than a strrchr search - dunno for certain, and don't
 care enough to code up a couple-line test, but just my gut... ;)

The problem with that is that a file called, say, site.logo.jpg will
fail the subsequent tests, since the substr() on the next line will
return '.logo.jpg'.  (And whilst it is vanishingly improbable, it is
_just_ possible for someone to supply a file called .gif ! ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Large/unreliable file uploading over HTTP

2008-08-26 Thread mike
Thanks - there's a lot of uploaders out there...

I'll look at it more, but I'd really like a solution which allows for
us to use any applet language we want. We'd prefer not to use java too
:) I don't see anything specific right off the bat that says how it
uploads (POST vs PUT) or splitting up of files. I would like to design
something that can work without any changes to server settings - so
anyone can use it...

On 8/26/08, Simcha Younger [EMAIL PROTECTED] wrote:

 Is this what you are looking for -- It's a java applet that has most of the
 features you mentioned. I have used it for very large files with no problem.

 http://www.javazoom.net/applets/jclientupload/jclientupload.html

 (Sorry, its not free software.)

 -Original Message-
 From: mike [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 10:07 AM
 To: PHP General list
 Subject: [PHP] Large/unreliable file uploading over HTTP

 Let's face it - HTTP is not very good for file uploads. It's stateless
 nature, slow connections, inability to resume (technically), etc, etc.

 What I've been thinking about is a way to skip all the normal
 annoyances with file uploading - multipart form encodings, file upload
 tools with specific needs, PUT vs POST, connection resets, ... the
 list goes on and on.

 Usenet and BitTorrent and other protocols have the right idea - split
 up the workload into smaller sets of data. It's easier to operate on.
 Usenet has NZB files. BitTorrent splits everything up into chunks. Not
 only would it make working with the data more portable (no need to set
 your PHP memory limit or POST limits to insane amounts to support
 large files) but it could also support multiple segments of the file
 being transferred at once...

 Here's somewhat of a process braindump of what I'm thinking. It still
 requires a 'smart' applet (Flash, Java, anything that can split a file
 up and send data over HTTP/HTTPS) - no special socket needs, no PUT
 support needed, don't even need to use multipart POST encoding (as far
 as I know) - just send the data in chunks over the wire and have a PHP
 script on the other side collect the data and reassemble it.

 Does this sound insane? I think this is a pretty good approach - no
 PUT needed, no large POST configuration required, anything could
 upload to it as long as it sends the information properly (I'm
 thinking HTTP POST for the header info, and the data could be sent as
 another POST field maybe base64 encoded or something that will stay
 safe during transit...)



 - take input file, checksum it (md5 / sha1)
 - calculate number of chunks to split it up based on $chunk configured
 size (for example 128k chunks)
 - split the file into chunks of $chunk size and create checksums for
 all (could use sfv?)
 - send request to the server - with the info - use JSON?
action=begin
filename=$filename
filesize=$filesize
checksum=$checksum
segments=list of segments (unique segment id, checksum, bytes)
- server sends back a server ready and unique $transaction_id
 - start sending to the server, send header with transaction key and
 unique chunk identifier in it
action=process
transaction=$transaction_id
segment=$unique_segment_id
   data=base64_encode($segment_data)
- when done, server sends back $transaction_id, $segment_id, $status
 (okay, fail)
 - client compares checksum for identifier, if okay, move to next chunk
- if it does not match, retry uploading to server again
 - when all chunks are done, send request with transaction key and
action=finish
transaction=$transaction_id
   - when the server receives this, it assembles the file
 from the segments and does a final checksum, and reports the checksum
 back to the client (warning: on a large file this could take a bit?)
 and sends back $transaction_id, $checksum
 - client does one last check against the file's original checksum, if
 it matches report success, otherwise report failure (would need to
 determine why though - if all segments match this should not be able
 to happen...)

 I'd appreciate everyone's thoughts. This would also allow for file
 upload progress, more or less, as the server and client are constantly
 communicating when chunks are done and in progress (but again, that
 has to be done with an applet)

 I can't think of any method to do it in-browser, but doing it this way
 could open the gates for things like Google Gears to possibly work
 too...

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

 No virus found in this incoming message.
 Checked by AVG - http://www.avg.com
 Version: 8.0.138 / Virus Database: 270.6.7/1632 - Release Date: 25/08/2008
 07:05



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



Re: [PHP] APC vs. eaccelerator?

2008-08-25 Thread mike
On 8/25/08, David Park [EMAIL PROTECTED] wrote:

 Some older posts on the net (from 2006) complained about incompatibilities
 between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
 hoping that these problems have been cleared up by now.

2006 is a century ago in open source time :P

i was using turck mmcache which turned into eaccelerator for a while.
i also tried xcache. however, i switched to APC over a year ago now.
it's maintained by core php developers, so i figure it's the best as
it would receive little perks due to new features/fixes being put in
to the core php code and the developers implementing them working on
APC.

i have never done any benchmarks or anything, but i'm pretty sure
they're all relatively close speed-wise. stability-wise i've never had
an issue with APC..

the file upload stuff would be cool except i need something that
supports multiple webservers, not shared memory on a specific host.

besides, i think i've heard PHP6 will have a built in byte-code cache
already, and i am sure it will use APC/portions of APC (why not, it's
already there)

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



RE: [PHP] SESSION problem

2008-08-19 Thread Ford, Mike
Been on holiday, so coming to this party a bit late, but
 
On Sat 16/08/2008 15:06 Stut wrote:
 On 16 Aug 2008, at 14:46, tedd wrote:
  At 2:11 PM +0100 8/16/08, Stut wrote:
  Ahh, I see the problem. You've never been able to use numbers as 
  keys at the root level of the $_SESSION array. It's not a bug, it's 
  just the way it is. I've just checked the documentation and can't 
  find an obvious reference to this limitation which is kinda annoying.
 
Well at http://www.php.net/manual/en/session.examples.php there's a big fat 
Note at the top of the page which includes the following: The keys in the 
$_SESSION associative array are subject to the same limitations as regular 
variable names in PHP, i.e. they cannot start with a number and must start with 
a letter or underscore..
 
[ -- SNIP -- ]

  Let me play the age-card -- in every language I've programmed in for 
  the last 43 years an array can have numeric indexes -- except php's 
  SESSION.
 
 I wish I understood the reason why it's like this but I've never 
 looked into the session extension in that level of detail, but I doubt 
 such a limitation would exist if there was not a very good reason for 
 it. 

One word suffices here: register_globals! Or, if that doesn't suffice: if 
register_globals is turned on, all the $_SESSION entries are automatically 
registered as global variables -- so any numeric indexes will obviously be 
invalid and will disappear. For consistency's sake, PHP enforces the 
restriction even with register_globals off.
 
Cheers!
 
Mike
 
-- 
Mike Ford,  Electronic Information Developer, 
Libraries  Learning Innovation, 
C507, Civic Quarter Campus, Leeds Metropolitan University,
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: [EMAIL PROTECTED]Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


Re: [PHP] FCKEditor, TinyMCE, ... I need a light weight WYSIWYG HTML Editor

2008-08-17 Thread mike
On 8/17/08, AmirBehzad Eslami [EMAIL PROTECTED] wrote:
 Dear list,

 I'm looking for a light weight WYSIWYG HTML Editor to allow
 users to send private messages to each other in a forum application.

 FCKEditor is too complex and very huge for my purposes. I want a
 simple editor. What do you recommend?

WordPress has tweaked tinymce a lot to maintain p spacing and code
snippets and embedded objects. We've tried both at my job with various
configurations, both have had issues - but we've had the most success
and our users have been happy with WordPress's configuration (which
uses a couple custom javascript things + specific tinymce
configuration)

I've been trying to examine the differences so I can create a reusable
standalone component we can use in all our various apps... but WP has
hooked in a lot of custom code and it's been a bit annoying trying to
split it out into a single reusable javascript file and stuff. Almost
done though. I went overboard and tried to make it more generic by
renaming and cleaning up the functions to not need any WordPress
callbacks and stuff and wound up messing it up, so I have to go back
again and probably re-create it from scratch.. Doh :)

Honestly in a forum setting you can just give them a bbcode howto/link
on the side and let them put in their own bbcode (which can be a
strict subset of HTML) - or even just allow HTML tags and limit what
they can do. Loading up a javascript-based thing even if it's pretty
lightweight is still annoying and I could see that being overkill for
a forum.

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



Re: [PHP] Removing an element from the middle of an mdlti-dimentsional array

2008-08-14 Thread mike

Can't you unset() it? Sorry for top posting I'm on an iPhone

On Aug 14, 2008, at 7:30 PM, Don [EMAIL PROTECTED] wrote:


Hi,

Let's say I have the following array:

$myArray = array(array('1','2','3'), array('4','5','6'),  
array('7','8','9'),

array('10','11','12'));

How do I remove say the second element?

I have tried: $myArray = array_splice($myArray, 1, 1);

But this seems to remove the second element as well as all the  
following

elements and I am left with:

$myArray = array(array('1','2','3'));

when I really want:

$myArray = array(array('1','2','3'), array('7','8','9'),
array('10','11','12'));


Thanks,
Don



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



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



Re: [PHP] Removing an element from the middle of an mdlti-dimentsional array

2008-08-14 Thread mike

Not on the specific sub element. I.e unset($array[2][0])

On Aug 14, 2008, at 8:08 PM, Don [EMAIL PROTECTED] wrote:


Won't unset() destroy the entire array?

mike [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

Can't you unset() it? Sorry for top posting I'm on an iPhone

On Aug 14, 2008, at 7:30 PM, Don [EMAIL PROTECTED] wrote:


Hi,

Let's say I have the following array:

$myArray = array(array('1','2','3'), array('4','5','6'),
array('7','8','9'),
array('10','11','12'));

How do I remove say the second element?

I have tried: $myArray = array_splice($myArray, 1, 1);

But this seems to remove the second element as well as all the   
following

elements and I am left with:

$myArray = array(array('1','2','3'));

when I really want:

$myArray = array(array('1','2','3'), array('7','8','9'),
array('10','11','12'));


Thanks,
Don




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



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



[PHP] Anyone using Lighttpd + webdav and a PHP handler?

2008-08-13 Thread mike
i.e. using PUT and using a .php script as the handler for it?

I can successfully PUT a file to /path/to/file-that-doesnt-exist.txt

However, when I try to do a PUT to an existing .php script it gives me
access denied, most likely due to the fact that a file exists. I don't
want it to actually try overwriting the file, and is-readonly =
enable or disable doesn't seem to change this behavior...

Just wondering if anyone out there has done this.

I did it no problem in nginx using a .php handler and set DAV to
readonly - no issues whatsoever...

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



RE: [PHP] newsletter code

2008-08-11 Thread Mike Roberts
Ladies and Gentlemen,
Please pardon the interruption, but I tried the prescribed method of
'opting out' of these messages, but they still arrive. 
I am a recruiter, and I joined to understand a little something about
some of the jobs that I was working on around 10 months ago. Unless
somebody wants job related advice ( which I doubt), I would hazard a
guess that I have nothing to contribute to your conversations.  Can
anybody help me get 'de-listed'? Any help would be appreciated. Thanks
and best of luck to everybody here.  





 Michael Roberts
 Senior Recruitment Strategist
 Corporate Staffing Services
 150 Monument Road, Suite 510
 Bala Cynwyd, PA 19004
 P 610-771-1084
 F 610-771-0390
 E [EMAIL PROTECTED]

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Richard Heyes
Sent: Monday, August 11, 2008 10:40 AM
To: Per Jessen
Cc: php-general@lists.php.net
Subject: Re: [PHP] newsletter code

 I wouldn't bet on it Richard - filtering out an email sent by an
honest
 user from an honest and properly configured mailserver is very, very
 difficult.

Using a dedicated service is still going to be a better bet than
rolling your own. Probably cheaper too.

-- 
Richard Heyes
http://www.phpguru.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



Re: RE: [PHP] Re: PUT vs. POST (was: php File upload)

2008-08-11 Thread mike
On 8/11/08, tedd [EMAIL PROTECTED] wrote:

 Per Jessen:

 I am sure you are smarter than this -- you're probably not understanding
 what I am saying.

No, Per is correct.

PHP itself cannot access anything on the client. It is a server-parsed
language. The client never executes PHP, period.

Javascript, other applets, etc. can *inform* or push information to
PHP about the client or files on the client, but PHP itself has no
idea what is going on other than $_SERVER, $_COOKIE vars and whatnot
identifying the browser. That's all it gets without something else
helping it, and that is still not -PHP- itself.

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



Re: RE: [PHP] Re: PUT vs. POST (was: php File upload)

2008-08-11 Thread mike
On 8/11/08, tedd [EMAIL PROTECTED] wrote:

 Now, do you agree with that?! Isn't that the SAME as what you said above?!

 Now, why not read the rest of what I wrote?

 Sometimes it's hard to get an idea across because some people refuse to
 read, but love to comment about the obvious.

Or this conversation has become a hassle to pay attention to and I'm
not going to waste time since gmail has compressed all the common text
on each conversation trying to flip through it.

Originally this was a decent idea for discussion since this interests
me, but the thread has been hijacked into a semantics discussion now.
So I decided I've seen enough of this back and forth and posted
something.

I therefore request we stop this discussion or put it into another
thread about PHP vs. clientside crap, and let POST vs. PUT resume
discussion if that's even still alive.

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



Re: [PHP] Re: PUT vs. POST (was: php File upload)

2008-08-09 Thread mike



On Aug 9, 2008, at 7:50 AM, Richard Heyes [EMAIL PROTECTED]  
wrote:


Given that PHP doesn't run on the client, there is no way for  
anything

written in PHP to access anything on the client.


Wouldn't it be fun though if it could? :-)

--
Richard Heyes
http://www.phpguru.org

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



Years ago someone made an activex component to run php on the client.  
Apparently it went nowhere. 


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



Re: [PHP] php File upload

2008-08-08 Thread mike
On 8/8/08, Luke [EMAIL PROTECTED] wrote:
 Is a 1.9 gb file upload even sustainable on even a fairly small scale web
 application? Maybe you could implement FTP if you trust the people that want
 to upload the file.

This is why I am pushing for people to use PUT.

Still over HTTP, uploaders can be coded to be 'smart' and resume,
re-transmit on failure, etc.

It does however require applet (java, flash, etc) or thick client
support on the client, and a server that understands the DAV request.
I have it working in nginx right now. Need to test large files and
watch PHP's memory consumption, since I am spoonfeeding the file to
PHP.

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



Re: [PHP] Kill Magic Quotes

2008-08-08 Thread mike
On 8/8/08, Stephen [EMAIL PROTECTED] wrote:

 I found this solution after a web search. I can't attribute the author, but
 would like to if I could.

I have something like that myself, but even on the URL they linked it
has a php.net approved snippet of code that works:

http://www.php.net/manual/en/security.magicquotes.disabling.php

?php
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);

return $value;
}

$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
?

but i'd say skip REQUEST. just unset($_REQUEST); don't get in the
habit of using it. blech.

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



Re: [PHP] php File upload

2008-08-08 Thread mike
On 8/8/08, Andrew Ballard [EMAIL PROTECTED] wrote:

 I've not had to upload such large files over HTTP, so forgive my
 ignorance, but on the request end isn't the only difference between
 PUT and POST the verb used in the request (and the intent of the
 operation)? What can you do with PUT that cannot also be handled the
 same in POST? I don't see any implementations doing it, but from what
 I can tell the spec allows you to use Content-Range in the request
 headers that your client sends to PUT/POST the same way the server
 sends them in the response headers when serving a GET request.

POST sends mime-encoded
PUT is raw (AFAIK)

It's basically file exchange friendly. People usually say HTTP isn't
for files, FTP is but that's a whole other can of worms especially
when you're accepting uploads from -anyone- you have to implement a
wacky two-step process, ensure people know how to use FTP, blahblah.

Using PUT you can do pure file uploads, have smart clients that tell
the server where to resume, it's not mime encoded (so not extra
bytes), it can be processed as a web request via PHP, it can be done
over SSL for security ...

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



Re: [PHP] php File upload

2008-08-08 Thread mike
On 8/8/08, Per Jessen [EMAIL PROTECTED] wrote:

 Same as POST then :-)  (except for the resume bit).

 I still don't see much of a difference.  It doesn't matter much to me,
 I'd just like to understand what the real difference is.  Maybe I need
 to go and read RFC2616.

I'm all for using existing POST but it seems like a lot of
configuration needs to occur, and PHP is expecting a single stream of
data. If the stream is broken, how do you resume it? If you accepted
the data raw you could dump the stream to a file until it ends, and
then fseek($fp, $offset) when you get a resume request...

PUT seems to be expected to be straight old file $x goes here ... I
actually am not allowing the file to be put on the filesystem directly
but fed to a PHP script.

I am totally down for POST since POST is supported by browsers, flash,
everything, and PUT has some limitations (java applets aplenty, flash
can do it i think but you have to do actual raw socket communication
and I haven't found an applet for that yet)

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



Re: [PHP] Re: PUT vs. POST (was: php File upload)

2008-08-08 Thread mike
On 8/8/08, Per Jessen [EMAIL PROTECTED] wrote:

 I am not for or against either, I'm just looking for the right argument
 for PUT support as it seems to be lacking (and I've never found myself
 in a situation where PUT was the solution).

I need to accept files of various sizes - up to 2GB, maybe even more
(if it can be supported) - videos, code samples, zips, pdfs, anything.

They're coming from various geographies - so slow unreliable
connections must be factored in.

HTTP upload even with -large- files on a fast connection can be
spotty, due to how many systems are in place between client - server.
There is no resume either with straight browser upload...

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



Re: [PHP] uploading big files with PHP

2008-08-04 Thread mike
On 8/3/08, Catalin Zamfir Alexandru | KIT Software CAZ
[EMAIL PROTECTED] wrote:

 What are you talking about? I've been able to upload a 4GB file without 
 problem. Uploading doesn't depend on memory limit, and this has been a 
 subject of debate on the PHP.net Manual (uploading files section, check it 
 out).

using the PUT method?

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



Re: [PHP] [PHP Header] Right-Click Download in Firefox showing php filename

2008-08-04 Thread mike
On 8/3/08, Will [EMAIL PROTECTED] wrote:

 @readfile($filename);

You should look into a webserver and instead of using readfile() which
will keep the PHP engine open while it is spoonfeeding the browser,
offload the file to the webserver.

nginx has X-Accel-Redirect (nginx is the best anyway)
Lighttpd has X-Lighttpd-Sendfile (or something)
Apache has mod_sendfile (something like that)

etc.

I don't think it will change the renaming behavior, but it will
offload your PHP engines for normal processing. :)

Basically (you'll have to configure it quick but otherwise) instead of
the readfile($file) you'd be sending another:

header(X-Accel-Redirect: $file); (you have to configure $file's location)

and that's it. the webserver takes over and PHP is released back to do
other things.

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



Re: [PHP] uploading big files with PHP

2008-08-03 Thread mike
On 7/25/08, Angelo Zanetti [EMAIL PROTECTED] wrote:
 Hi all

 We are pitching to develop a website where the admin has to upload big video
 files but I'm not sure how this can be done as the file upload will most
 probably time out.

 How do current websites do it? Is there somehow a way to make use of FTP to
 transfer the files?

 Any links, help, advice will be appreciated.

 Thanks in advance

Use the PUT method
- requires webserver configuration to support it
- requires PHP to open the stream using php://input
- supports resuming (the client needs to give the script something
like ?offset=1234 and the PHP script needs to fseek() to that position
in the file)

Variety of options for uploading this way:
- anything that can leverage curl/libcurl
- browser plugins - lots of java ones, haven't found a flash one yet

Bonuses:
- Can run over ssl/https - since its just HTTP talking, so proxies are okay
- Can resume
- Doesn't require a two-step process for people to upload things (FTP,
SFTP to server, then go somewhere and associate the file, etc)

We'll be using this method we just wish there were nicer frontends,
most of the java ones are ugly as sin.

javauploader.com mentioned does not look like it supports PUT. however
I believe all of these do:

http://www.jfileupload.com/products/jfileupload/
http://www.radinks.com/upload/plus/resume.php
http://upload.thinfile.com/features.php

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



Re: [PHP] uploading big files with PHP

2008-08-03 Thread mike
On 8/3/08, brian [EMAIL PROTECTED] wrote:

 Also, use set_time_limit(0);

and configure the server and php to accept a decent size, and probably
configure the client to put only chunks at a time right?

otherwise php will hit it's memory limit for the script quite easily i
would assume. so there has to be something that allows it to stream
and keep only so much in the buffer at a time.

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



Re: [PHP] Exposing PHP/errors on production vs. dev

2008-08-02 Thread mike
On 8/2/08, Richard Heyes [EMAIL PROTECTED] wrote:
  Personally, and I know I'm not alone here... I keep E_NOTICE enabled

 Then you're both mad. Users really shouldn't see any error regardless,
 so error reporting IMO should be off entirely. A blank screen that you
 can blame on a variety of things is far preferable to users knowing
 that your website is broken. In production I keep error_reporting set
 to 0. There are a variety of things you could also do like log them to
 a file or have them emailed to you so that you get notified when
 errors occur.

That's what we're saying.

He's saying he is LOGGING everything (error_reporting) not
display_errors - where it would output to the user :)

display_errors and maybe display_startup_errors are the key ones afaik
that expose any PHP related errors to the user. that's why I started
this thread to confirm my logic.


[PHP] anyone have HTML snippet example of HTTP method = put?

2008-08-02 Thread mike
I have this:

form method=PUT action=work.php
 File: input type=file /
 input type=submit value=Submit /
/form

Looking in my webserver logs, it changes that to a GET.

Ideas anyone? The receiver is PHP and I am pretty sure I know how to
handle it once it is properly PUT-ted.

(I run nginx for the server and have enabled PUT as a method, supposedly)

Maybe I need to do something different on the web form though?

thanks!

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



Re: [PHP] Re: Exposing PHP/errors on production vs. dev

2008-08-02 Thread mike
On 8/2/08, Al [EMAIL PROTECTED] wrote:
 Here' the snippet I use on all my code files. Default is create and add to
 error log file on the current dir.

The problem is if the script is fubar, it won't read the error_log ini
override...

Open question for all:

Even though I have error_reporting set to on, and display_errors set
to on, sometimes errors occur and it just shows a blank page. Why is
that? I used to always get -some- output, now I get nothing. It's
quite annoying.

I am excited for PHP 5.3's ini settings features - then I can create a
PHP error log per each docroot (manually, for now), or I suppose if I
can remember the syntax in php-fpm I can already do that. Problem is
then I just need to configure things to rotate/reset those logs every
so often. (heads up: feature request, error_log_max_filesize!)

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



Re: [PHP] anyone have HTML snippet example of HTTP method = put?

2008-08-02 Thread mike
On 8/2/08, Benjamin Hawkes-Lewis [EMAIL PROTECTED] wrote:

 I can appreciate why one might imagine otherwise, but XHTML 1.x forms only
 support GET and POST. GET and POST are the only allowed values for the
 method attribute.

Sigh. That makes sense then.

So to test my script I need to use curl or something, I was hoping to
test my browser directly. I thought at least PUT would work. Obviously
not every DAV command or anything else.

 There are proposals to add PUT and DELETE to the supported methods in a
 future version of HTML.

Well, I won't actually be using this in production this way anyway, I
just wanted to do some testing at home using PUT first. Looks like I
will have to use curl or another method that isn't in-browser.

 Hard to be sure, but judging from your markup, you might well be using the
 wrong HTTP method anyway. The action attribute specifies where the URL the
 form submits to. In the case of a PUT method, the server is supposed to
 replace the resource represented by that URL with the entity dispatched in
 the request:

Yeah - that is why I had set my webserver as dav_access readonly. I
was wanting to see it first PUT the file, see if PHP accepted it, or
it just said access denied

I need to PUT a file but use a PHP script as a wrapper, and my
webserver is nginx.

 I note in passing that if you're intending to use that markup in production,
 you should really enclose the text File:  in a label element associated
 with the input element by having a for attribute matching an id
 attribute adding to the input. This will allow user agents to accurately
 associate the label with the file upload control, for example screen readers
 and voice browsers can speak or braille File:  when the focus enters the
 control. For a detailed explanation, see:

Thanks for the tip.

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



[PHP] HTTP PUT for file uploads

2008-08-01 Thread mike
It appears that PHP can support the PUT method using php://stdin and
appropriately configuring the webserver to accept it.

My company needs a file upload solution that will support large file
uploads (2GB limit is optional - if we have to tell them less than 2GB
that's fine) that will keep re-trying the upload until it is done. We
have slow geo users and then just flat out large files to deal with
even from fast connections.

There's a variety of Java-based PUT uploaders.

So far, we haven't found any Flash ones (we'd love to NOT use Java) -
but there is a way to do it apparently, we just can't find anyone
who's done it yet.

I'm assuming that we should keep the connection open as long as there
is some activity and maybe timeout after a minute or two... the
client-side applet should have the logic to continue retrying and
since it is PUT, the PHP script will accept the data and use fseek()
on the file to resume at the offset supplied (the client will have to
give us that info)

See the examples here:
http://www.radinks.com/upload/examples/ - look at the Handlers that
support resume section.

Anyone have any thoughts? I think I need to tweak PHP settings
too possibly as well, for max execution time and such. But also any
uploader ideas would be great.

The reason for using this is FTP/SFTP require logins or some sort of
pick up process or two step process to first upload the file then
have the user associate it (or a cronjob somehow associate and move
it) to it's final destination. HTTP isn't the best for file uploads
but it appears PUT does support resuming, and we just want the
cleanest possible frontend to it. Java stuff is slow, Flash would be
better, but it appears Flash only supports basic POST/GET and you have
to use a third party library (and possibly the latest Flex?) to be
able to support other HTTP methods. If anyone has any products or
knows of any projects, open source solutions would be best but money
is not an object basically so we'd be open to commercial ones as well.
We want the least amount of work for the end-user, so no thick clients
and hopefully the most compact [cross-platform] browser applet as
well. (I am assuming Flash does finally work on Linux)

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



Re: [PHP] HTTP PUT for file uploads

2008-08-01 Thread mike
On 8/1/08, Micah Gersten [EMAIL PROTECTED] wrote:

 Is this a repetitive thing your clients will do many times?  I recently
 created a backup solution using ssh keys and the pecl ssh extension to
 automate backups.  Then a cronjob sorts the files on the server.  It's a
 lot more secure than allowing PUTs.

Yes, we have end users (non-employees) and other employees from all
geographies (slow connections in China, India), USA, europe, etc, etc.
uploading files of any size and any shape. Video files, audio files,
executables, PDFs, anything.

This is a general purpose file upload solution for our content
management system used worldwide. We can't really create a list of
users and such, as it's open to anyone to contribute. We still
moderate/filter/etc. as needed. We're not worried about security, each
file will have its own unique location so they wouldn't clobber each
other, and they'll be isolated and not executed on the server, so
security to me isn't a concern. The webserver is already open to the
world, SSH/SFTP and FTP are not; so that would technically open that
up to the world, and actually open up more attack vectors :)

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



[PHP] Exposing PHP/errors on production vs. dev

2008-08-01 Thread mike
Does this look right?

Obviously you still want to know about production errors, so I'd like
to log them.

Development I want to see -everything- and I want it to display on the
page. The assumption is production won't have any notices as the code
should be clean and our higher priority are fixing errors. But that
one is easily editable if needed :)

Production:

display_errors  = Off
display_startup_errors = Off
error_reporting = E_ALL  ~E_NOTICE
expose_php  = Off
log_errors  = On
error_log   = syslog

Dev:

display_errors  = On
display_startup_errors = On
error_reporting = E_ALL
expose_php  = On
log_errors  = On
error_log   = syslog

Am I missing any?

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



Re: [PHP] Back to Basics - Why Use Single Quotes?

2008-07-30 Thread mike
On 7/30/08, Stephen [EMAIL PROTECTED] wrote:

 But I wonder, is there any reason to use single quotes?

extremely minor performance gains, afaik.

probably moreso when doing $foo[bar] and $foo['bar']

but i believe it's negligible $foo = 'bar' and $foo = bar

sara golemon did some performance tests with actual opcode results here:
http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

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



Re: [PHP] XML Encoding

2008-07-29 Thread mike
you should want it to be utf-8 anyway.

On 7/29/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:
 Guys,

 I'm building a XML in a PHP Script. Everything works fine until I add
 accented (ISO-8859-1) characters into it.

 As far as I can see, there's no way to change DOMDocument's encoding from
 UTF-8, right?


 Thanks,
 --
 Thiago Henrique Pojda


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



Re: [PHP] Why PHP4?

2008-07-29 Thread mike
I started using superglobals since 4.x; not even thinking about it  
from a security angle per se, but because it just makes sense to know  
the source of where your input data is coming from. I guess  
technically security is a byproduct of that thinking too.




On Jul 29, 2008, at 7:31 PM, VamVan [EMAIL PROTECTED] wrote:

Its because PHP got really famous with version 4.0 and many people  
actually converted their CGI or other websites in to PHP 4 websites  
because it was easy and cheap. But 5.0 brought too many changes like  
serious OOPS and register global concepts for security, which is  
useful but made transition difficult. I feel thats why PHP 4 is  
still supported.


Its not only the language that has changed, but also people had to  
upgrade their skill set and there was some learning curve involved.


Unfortunately everyone fell in the trap of register globals which  
was not dealt until php 4.3.1 as a security concept. Pear and Pecl  
were there but everyone was pretty much writing all the code  
(reinventing the wheel) from scratch. This brings in huge code base  
to change.


I liked PHP because intitially it was a procedural langauge and it  
resembled C. But now with OOPS you can build powerful websites which  
is good.


There are many other  cases but I feel strongly this is what makes  
them still support PHP 4.


Thanks


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



Re: [PHP] Why PHP4?

2008-07-28 Thread mike
On 7/28/08, n3or [EMAIL PROTECTED] wrote:
 Compatibility to older Software of the hosters and sloth of the developers

i think this is a cop-out, any halfass open source package should be
compatible with php5 now.

i've been running php5 since it came out and everything i have tried
never has a single issue due to php versions. and i've tried a lot of
stuff :P

actually, a lot of stuff is finally saying php5 only now ... in
theory lazy hosters may be creating a poor hosting environment the
longer they sit on it.

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



Re: [PHP] getting info from video formats

2008-07-28 Thread mike
On 7/28/08, Rene Veerman [EMAIL PROTECTED] wrote:

 ImageMagick's identify command supposedly reads AVI and MPEG, but i can't
 get it to work on my avi's:

i wouldn't rely on it; i'd rely on it for Images :)

 C:\Users\rene\Documents\Downloadsidentify
 Stargate.Atlantis.S05E02.HDTV.XviD-0TV.avi
 identify: Not enough pixel data
 `Stargate.Atlantis.S05E02.HDTV.XviD-0TV.avi'.

you naughty pirater :P

 So if ImageMagick isn't the tool to use for video files, i wonder if there
 is any other tool that i can use to determine the size of video files.

 I'd like to be able to read as many of the major video formats (AVI, XVID,
 DIVX, QT, etc) as possible.

ffmpeg is probably the best bet. i believe it has an option to get
video info and not try to process it.

also look at the mencoder/mplayer suite of tools.

maybe even transcode.

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



Re: FW: [PHP] getting info from video formats

2008-07-28 Thread mike
On 7/28/08, Chris Scott [EMAIL PROTECTED] wrote:
 I agree.

 I use MPlayer to process videos. One script gets the video length like this.

 //use mplayer to pull some info from the video
 $info = exec(\$mplayer\ $videoPath/$videoName -identify -nosound -frames 0 
  $tmpInfoFile);
 //and open the file it stores the data in
 $infoFile = fopen($tmpInfoFile, rb);
 //then parse for the video length
 while(! feof($infoFile) )
 {
$lineBuffer = fgets($infoFile);
if(preg_match(/ID_LENGTH=/, $lineBuffer))
{
$videoLength = (int) preg_replace(/ID_LENGTH=/, , 
 $lineBuffer);
}
 }

you could probably skip piping it to a tempfile - and just use popen()
to open the process...

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



Re: [PHP] uploading big files with PHP

2008-07-25 Thread mike
On 7/25/08, T Lensselink [EMAIL PROTECTED] wrote:

 You are right on this. There are some other great methods for uploading.
 I just meant that in PHP there is not much more options. Of course in
 combination with other technologies you can do some pretty cool stuff.
 You could use some Java applet, Flash, or like you said Ajax in
 combination with PHP.

Exactly.

We need to be able to accept uploads now going upwards of  50MB, and
from slow international connections too. HTTP just isn't good for
that, not to mention all the configuration needing to be done in the
webserver and PHP to sit there and wait...

We'll probably be forced into looking into third party tools, since
HTTP itself, regardless of what server-side language used, is a bit
too unreliable, and we need some thicker/beefier solution which allows
for resuming, retries on timeouts, etc.

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



Re: [PHP] Code beautifier

2008-07-25 Thread mike
On 7/25/08, tedd [EMAIL PROTECTED] wrote:

 I do it all the time. In fact, I enjoy doing it (no I don't want to do it
 for anyone else).

 What I find interesting/entertaining is reducing the amount of code down to
 what's actually necessary and then reorganizing the code to make routines
 more optimum and generic. Most of the stuff I review is reduced
 considerably.

 In short, it's a great way for me to both learn and build my own library.
 When clients don't have me pounding keys for their service, I enjoy
 reviewing, rewriting code and creating demos.

 However, I would never use a Code beautifier because as I go through the
 code, the only code that get beautified is the code that I approve. When I
 see code formatted differently than mine, then I know it's suspect and I
 need to review it.

basically, quote what this guy says - this is me in a nutshell. i can
tell my code from others too, so i know if something's been fubared
that i've written :)

tedd you took the words out of my mouth about the subject.

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Richard Heyes [EMAIL PROTECTED] wrote:
 Anyone know of an unintrusive code beautifier written specifically with in 
 mind?

just be prudent (and anal retentive) when you code :)

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

 That doesn't work when you get code from someone else that wasn't prudent
 enough ;)

I figured that'd be the reply - it's not my code ... sadly, I still
go and reformat other coworker's code anyway, heh. Yeah, I'm -that
bad-

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:

 That's why I looked for a tool like that months ago. Big project from
 someone else, do you feel like reformatting hundreds of files with hundreds
 (thousands?) of lines manually?

 I didn't :)

If it's something I will wind up working on, I just do it naturally,
it's not even a pain in the ass for me anymore. It also lets me look
line by line for ways to improve/optimize, the problem is I do run
into a lot of why the hell did they do this? and yes, sometimes I do
give up or ignore some code :P

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Stut [EMAIL PROTECTED] wrote:

 That's not just bad, it's downright anti-productive. You need to either have
 a standard style across a team or accept that other developers format their
 code differently. If you spend time reformatting other peoples code it's a
 waste of your time. Differently (not that I didn't say badly) formatted code
 does not make it wrong, it's just different and if you can't live with that
 then you need to work on getting your preferred format adopted as the
 standard for the team.

We've shown the team and new people join all the time. They bring
their own styles, use crap editors which leave extra linefeeds,
spaces, etc. all over. It's fine, as I am reviewing their code anyway,
it helps me think clearer, and since I have to support fixing the bugs
later on, I can go back to it and read it quicker as well.

Now if I was just cleaning it up and never seeing it again, yes, it
would be a waste of time. But everything usually falls on my plate
when nobody else can figure it out.

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



Re: [PHP] Code beautifier

2008-07-24 Thread mike
On 7/24/08, Stut [EMAIL PROTECTED] wrote:

 Obviously you can run your team the way you want to, but personally I prefer
 to get all my developers singing from the same hymn sheet such that after a
 couple of weeks they can go to any part of the code and not see a horrific
 mess because they're used to the coding style and be able to conform to that
 style when they make changes.

Heh, I'd love to see you try to tackle the team I'm on. No matter how
many times I show them things, no matter how many simpler methods of
coding we provide (I have a custom library to make life easier) they
still find new ways since PHP is so open to create obtuse and
overengineered solutions for the simplest of things. It's a
never-ending evolutionary process that will probably continue to be
never-ending.

 Any half-decent developer should be able to adopt any style they're told to.

I never said the quality of developers I had to work with :p Most are
decent in their respective fields, but PHP is new to most people here.
It appears that most .NET/Microsoft style coders don't care about
whitespace, tab however they wish, etc, even though VS editors try to
help them, it always comes out with extra white noise.

 Likewise they should be able to use any editor you tell them to, but even if
 you would prefer to be flexible in the name of productivity there are very
 few editors beyond Notepad that can't use a particular EOL and auto-strip
 trailing spaces. As far as extra linefeeds etc that's all coming from the
 developer unless you're using WYSIWYG editors. I've met far too many
 developers who don't care about formatting their code and unless you slap
 their nose for it they won't change.

Eh, I've shown my way many times... it doesn't really help. Besides,
most of the time I have to review this stuff anyway, or go back and
fix bugs in it, so I'm already messing with the code to begin with.

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



Re: [PHP] Getting info from SVN commit with php

2008-07-23 Thread mike
On 7/23/08, Raido [EMAIL PROTECTED] wrote:

 I have an SVN server but I need to add some extra to commit message which
 PHP will get  and use(for example use the parameters from commit message to
 change data on mysql database... (if commit messages first line has
 character *, then run sql query... update tasks set some_row='OK'
 where

There's an SVN PECL module: http://pecl.php.net/package/svn

Also, you can easily run these kind of commands via system() - I've
done that in the past, but now that there's this SVN PECL module I've
been wanting to get aligned that way. Always better in my opinion to
use APIs and not system() calls.

If the svn module doesn't meet your needs you can ask for
enhancements, or just use system() for now.

here's a couple functions I wrote.
$config['svn'] was the path to the svn command (like /usr/bin/svn)

i used the xml output option so i could parse it using simplexml.
also, i pass it a username, password and repository since i support
multiple repositories and each one has a unique username/password set.
it worked like a charm. i am sure you can tailor this code to suit
your needs.

# get the latest revision #
function svn_latest($username, $password, $repository) {
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
info --xml --non-interactive --no-auth-cache --username {$username}
--password{$password} svn://localhost/{$repository}));
return intval($xml-entry-commit['revision']);
}

function svn_history($username, $password, $repository, $count = 20,
$start = 0, $latest = 0) {
# svn's revisions are incremental, so we need to calculate
backwards to find the right offsets
if($latest == 0) {
$latest = svn_latest($username, $password, $repository);
}
$start = $latest - $start;
$end = intval($start - $count) + 1;
if($end  0) { $end = 0; }
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
log --xml --non-interactive --no-auth-cache --username {$username}
--password {$password} -r {$start}:{$end}
svn://localhost/{$repository}));
return $xml;
}

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



Re: [PHP] big files download with php - configuration problem

2008-07-23 Thread mike
On 7/23/08, Giulio Mastrosanti [EMAIL PROTECTED] wrote:
 Hi all,

 I have a set of php scripts that handle the browsing and download of file
 from the server.

 it has worked fine for a long time on a server linux, now I have got to
 migrate those scripts also on a windows server, and something very strange
 is happening:

 the download process hangs when  downloading big ( 50 MB and up ) files from
 the server, and the files are only partially downloaded.
 the log on the server shows a Timer_connectionidle error message.

 I'm quite sure it is a configuration ( php or IIS ) issue, but I have no
 idea about what could be the problem.

 it is not an execution time problem since I have set the max_execution_time
 on the php.in to a very large value.
 it seems that the php script simply stops communicating with the server, and
 after a while the server kills it.

 the original script used a  readfile($filename) function, I have also tryed
 to replace it with fopen($filename, 'rb') and a while cicle with
 fread($filename, $chunksize), but with no success.

I would recommend looking into a webserver that supports offloading
the file download to the webserver via fastcgi:

- nginx (preferred) using X-Accel-Redirect header
- lighttpd using X-Lighttpd-Sendfile header
- apache has a module mod_sendfile or something, but I don't recommend
apache for anything anymore

not sure if other webservers have it or not. But basically it allows
you to use PHP/application level logic to validate if the user has
access, and then tells the webserver okay, now send the file and
releases PHP/application level from having to spoonfeed the file using
things like readfile() and keeping the PHP thread/whatever open

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



Re: [PHP] $_ENV or getenv to get bash environmental variables.. change php.ini?? env vars

2008-07-23 Thread mike
On 7/23/08, mindspin311 [EMAIL PROTECTED] wrote:

 I want to be able to do a getenv('SYMFONY_HOME'); or any env var that I've
 setup in my /etc/bashrc for everyone. But apache obviously doesn't have a
 shell, so it doesn't know about these. only the stuff in $_ENV.

 What I want to know is how can I read env vars like ANT_HOME, JAVA_HOME,
 etc.. in php? I just need to be able to read symfony's root path so I can
 stop hard coding it into a config file in the project everytime I deploy to
 a new machine.

i believe you can add it to /etc/profile and restart apache (possibly
need to reboot, not sure) and those are global environment variables
everyone receives, including non-interactive shells and processes.

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 14 July 2008 20:47, tedd advised:

 Round-off errors normally don't enter into things unless your doing
 multiplication and division operations. At that point, what you get
 back from the operation is an approximation and not the actual
 number.

Bull! Nearly all computer floating point numbers are approximations
because of being held in binary rather than decimal. Any number with a
(decimal) fractional part that doesn't end with the digit 5 is
necessarily an approximation, and that's only half the story. So as soon
as you involve numbers like 0.1 or 0.2, you've already got minor
inaccuracies which will propagate through any kind of arithmetic -- it's
just worse with multiplication or division because these tend to result
in inaccuracy in more significant digits!

Bottom line: a floating point value should *always* be treated with an
appropriate degree of suspicion.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 14 July 2008 21:44, Jay Blanchard advised:

 [snip]
 So does that mean your problem is solved?
 [/snip]
 
 It would appear so. I just need to remember to check for absolute
values
 when working with floats.

Yeah, that's Computer Science 101 stuff.  (Well, it was when I did my
degree 30+ years ago, so it's probably nearer primary school level by
now ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 15 July 2008 14:33, tedd advised:

 At 11:24 AM +0100 7/15/08, Ford, Mike wrote:
 On 14 July 2008 20:47, tedd advised:
 
   Round-off errors normally don't enter into things unless your
doing
   multiplication and division operations. At that point,
 what you get
  back from the operation is an approximation and not the actual
  number.
 
 Bull! Nearly all computer floating point numbers are approximations
 because of being held in binary rather than decimal. Any number with
a
 (decimal) fractional part that doesn't end with the digit 5 is
 necessarily an approximation, and that's only half the story. So as
soon
 as you involve numbers like 0.1 or 0.2, you've already got minor
 inaccuracies which will propagate through any kind of arithmetic --
it's
 just worse with multiplication or division because these tend to
result
 in inaccuracy in more significant digits!
 
 Bottom line: a floating point value should *always* be treated with
an
 appropriate degree of suspicion.
 
 Cheers!
 
 Mike
 
 Mike:
 
 No reason to be rude.
 
 I said:
 
 Round-off errors normally don't enter into things unless your doing
 multiplication and division operations.
 
 And that is not Bull -- it's true. You can add and subtract all the
 floating point numbers (the one's we are talking about here) you want
 without any rounding errors whatsoever.

Sorry, I do apologise if I came over too strongly -- there was no
intention to offend.

However, you really can't dismiss the effects of round-off errors on
addition and subtraction as lightly as that.  It's simply not true that
approximations only occur at the point of doing multiplication and
division -- there *are* approximations involved in addition and
subtraction, and it is necessary to be aware that this is the case -- as
Jay proved, 0.1+0.2 is hardly ever exactly 0.3. In this sort of case, it
may well be that an appropriate degree of suspicion is simply to round
to 2 decimal places at every stage, or compare the absolute difference
to .001, but nonetheless one has to *know* that this is necessary.

Ummm -- sorry, better /rant, now!!!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Math Weirdness

2008-07-15 Thread Ford, Mike
On 15 July 2008 16:07, bruce advised:

 anyone remember the intel debacle in the 1990's.. when they
 ate a couple
 hundred million when they had a math err in one of their coprocessors!

Oh, yes!

And then, back in the day, there was the DEC arithmetic processor which
hung if you happened to divide the most negative possible integer by
zero (instead of returning a divide-by-zero error as it did for any
other dividend!).

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730



To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] scalable web gallery

2008-07-10 Thread mike
On 7/10/08, paragasu [EMAIL PROTECTED] wrote:
 i am planning to create a web photo gallery. i know there is a lot
 available out there,
 but i really want to create my own. the problem is not about creating
 the photo gallery.
 i want it to be scalable.

 the plan is saving the image metadata in the database and keep the
 original files
 in a folder. while it work perfectly, i afraid how many files 1
 directory can keep.
 in 1 year, there going to be more than 1000 photo uploaded or more.
 sure it bring problem
 to maintain thus files.

if this becomes a huge project i'd recommend looking into using mogilefs.

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



Re: [PHP] PHP code will not work

2008-07-09 Thread Mike V

I had this problem and just figured it out.  I was copying and pasting the
code snippet from the tutorials page to my test editor and in the process
picked up an invisible ctrl char.  Doh!!


Joseph Subida wrote:
 
 
 The error I get when I try
 
 ?php
 echo $_SERVER['HTTP_USER_AGENT'];
 ?
 
 is
 
 Parse error: syntax error, unexpected T_VARIABLE in 
 /Library/WebServer/Documents/test.php on line 106
 
 I tried Googling T_VARIABLE and haven't found any useful solutions. 
 Any ideas? Thanks!
 
 -J.C.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-code-will-not-work-tp17811807p18362005.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] Looking for a reasonable explanation as to why $_REQUEST exists

2008-07-07 Thread mike
I have never had a use for this feature. To me it introduces another
register_globals style atttack vector. I see no need why people need
to combine post/get/etc variables into the same superglobal. I
actually run unset($_REQUEST) on it at the top of my library to
discourage its use.

For third party products which use it I tell people to combine it
themselves by using array_merge() - like $_REQUEST =
array_merge($_POST, $_GET) etc...

Anyway can someone here please give me a good reasoning why it should
exist? It isn't as easily abused as register_globals but when people
have a session variable they want to access and use $_REQUEST for it I
could easily override it by using a GET param on the url (depending on
how the order of globals get processed)

Simply put, I see no reason why people would not want to clearly
define where they are getting their input from. If for some reason
there is some need to lazily code something I would still say to do
something like:

if(isset($_GET['foo'])) {
 $foo = $_GET['foo'];
} elseif(isset($_POST['foo'])) {
 $foo = $_POST['foo'];
} else {
 $foo = 'default value';
}

... or just do the array merge.

But please someone maybe can justify this to me... I've been using
superglobals before I really understood how important they were and
then one day I see they introduced $_REQUEST and thought .. okay that
seems stupid. I finally am deciding to see if anyone can give me a
reason as to why this is useful and not just a lazy coding practice
that can lead to security risks.

You don't really know if your data is coming from GET, from POST, a
SESSION variable, etc...

I'd love to see a good discussion going on this. I might have
overlooked something important.

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



Re: [PHP] Looking for a reasonable explanation as to why $_REQUEST exists

2008-07-07 Thread mike
On 7/7/08, Eric Butera [EMAIL PROTECTED] wrote:

 Laziness/convenience.

 I always get my data from the exact source I want.  If someone chooses
 to use REQUEST it shouldn't break their application.  You say it is a
 security risk, but not really.  As long as everything is
 filtered/escaped properly it should be fine because you force the data
 to play by your rules.

I'm not talking about escaping/filtering. I'm talking about variable overriding.

In the past, it was

$_GET['foo']
$foo

register_globals fixed that.

however, if your app is relying on

$_SESSION['username'] or $_COOKIE['username'] or something like that,
depending on the variables order, it can be overridden.

I don't see why if you -know- you need $_COOKIE['username'] someone
would be lazy and use $_REQUEST['username']

It winds up allowing the end user to override information themselves
(again, depending on the variables order) which depending on that and
how poor the code is (which to me if you're relying on $_REQUEST
you've probably got some bugs and exploitable holes in there) creates
a security risk.

and session vars are in $_REQUEST, I tried it to sanity check myself
before posting this :)

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



Re: [PHP] Looking for a reasonable explanation as to why $_REQUEST exists

2008-07-07 Thread mike
On 7/7/08, Daniel Brown [EMAIL PROTECTED] wrote:

 That's the point --- it's intended as a fallback where you *don't*
 know the method that will be used, or if you want to be lackadaisical
 with your code (which, as we all know, is HIGHLY unrecommended).

Then you should code for that, not fallback to a lazy overrideable option.

if(isset($_GET['foo'])) { $foo = $_GET['foo']; } etc ...

or

$foo = array_merge($_GET['foo'], $_POST['foo']) or something like that.

 Because, in this case, it really doesn't matter if $word is
 obtained via GET or POST, so you can allow external users to use your
 service via an HTTP POST form or a plain URL.

Then code for it :P I understand the idea, I don't see the need to
create a dedicated construct in PHP for it. Part of PHP's power to me
was finally getting away from the lazy ASP (VB-based)
Request.Value('foo') or whatever it was and not able to identify if it
was post, get, etc and making the coder define exactly what source of
data he's getting it from.

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



Re: [PHP] Looking for a reasonable explanation as to why $_REQUEST exists

2008-07-07 Thread mike
On 7/7/08, Eric Butera [EMAIL PROTECTED] wrote:

 If your app is
 written correctly it doesn't matter what is thrown at it, it should
 always work.  Even if a variable gets overridden it should still be
 forced to play with the rules of the app and work like a valid request
 does.

That is not an excuse to trust GET and POST for the same variable.

1) Filter your input
2) Sanity check your input/fill in your own default value if one is requied

 I think that having a set of if statements that say something like the
 following is silly.
 if (isset($_POST['id'])) {
 } else if (isset($_GET['id'])) {
 }

Oh it definately is silly. I'm saying that's a workaround if people
-had- to mix their POST/GET data.

I've never had to do it and I've coded a variety of apps, including
plenty of various pagination methods, multi-page forms, etc, etc.

For example:

# 1 - filter it, and typecast it to int
$page = $page = intval(filter_input(INPUT_GET, 'page',
FILTER_SANITIZE_NUMBER_INT));

# 2 - sanity check. a page number cannot be negative and it cannot be
greater than the number of pages (which can be determined by a db
query, or hardcoded somewhere else)
if($page  0 || $page  $maxpages) {
   $page = 1;
}

In the end $page should be trusted as it won't have any foreign data -
it has been intval()'ed and there is a default value put in - $page =
1, and there is a bounds check to ensure it's valid info.

For a better user experience, instead of setting $page = 1, I would
probably use a header(Location: foo.php?page=1); exit(); so the
user's URL in the address bar properly matches up with the page. But
you get the idea.

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



Re: [PHP] Question before I end up writing alot of extra code...

2008-07-07 Thread mike
please oh please also run that through filter_input() before throwing
a $_POST directly into the db query ;p


On 7/7/08, Shawn McKenzie [EMAIL PROTECTED] wrote:
 Jason Pruim wrote:
 
  MAIN PAGE:
  ?PHP
 

 echo $row['Tab'];  //what do you get?

  if($row['Tab'] == done){
 $Tchecked1 = CHECKED;
 $Tchecked2 = NULL;
  }else{
 $Tchecked1 = NULL;
 $Tchecked2 = CHECKED;
  }
 
  echo
  fieldsetTabBR
  input type=radio name=rdoTab value=done $Tchecked1Done BR
  input type=radio name=rdoTab value=on $Tchecked2Not DoneBR
  /fieldset;
  ?
  PROCESSING:
  ?PHP
 

 print_r($_POST);  //what do you get?

 $tab = $_POST['rdoTab'];
 $record = $_POST['txtRecord'];
 $updateQuery = UPDATE `current` SET Tab='$tab'  WHERE
 Record='$record';
mysqli_real_query($link, $updateQuery);
  ?
 

 You're saying now that that record now has field Tab=''?

 -Shawn

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



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



Re: [PHP] Question before I end up writing alot of extra code...

2008-07-07 Thread mike
doh - and mysql_escape_string or equivalent.



On 7/7/08, mike [EMAIL PROTECTED] wrote:
 please oh please also run that through filter_input() before throwing
 a $_POST directly into the db query ;p


 On 7/7/08, Shawn McKenzie [EMAIL PROTECTED] wrote:
  Jason Pruim wrote:
  
   MAIN PAGE:
   ?PHP
  
 
  echo $row['Tab'];  //what do you get?
 
   if($row['Tab'] == done){
  $Tchecked1 = CHECKED;
  $Tchecked2 = NULL;
   }else{
  $Tchecked1 = NULL;
  $Tchecked2 = CHECKED;
   }
  
   echo
   fieldsetTabBR
   input type=radio name=rdoTab value=done $Tchecked1Done BR
   input type=radio name=rdoTab value=on $Tchecked2Not DoneBR
   /fieldset;
   ?
   PROCESSING:
   ?PHP
  
 
  print_r($_POST);  //what do you get?
 
  $tab = $_POST['rdoTab'];
  $record = $_POST['txtRecord'];
  $updateQuery = UPDATE `current` SET Tab='$tab'  WHERE
  Record='$record';
 mysqli_real_query($link, $updateQuery);
   ?
  
 
  You're saying now that that record now has field Tab=''?
 
  -Shawn
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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



Re: [PHP] Looking for a reasonable explanation as to why $_REQUEST exists

2008-07-07 Thread mike
On 7/7/08, Eric Butera [EMAIL PROTECTED] wrote:

 You asked for an explanation.  I was just stating that is how I've
 seen some people write apps.  I've also stated that isn't how I write
 them either.  I use something along these lines:

This is true. I really wanted to ask the internals folks first, to see
how it came up. I mean, if there wasn't the option available, people
would figure out a way to do it (probably one of the two ways I was
showing before)

The problem is, the cat's out of the bag now and a lot of people are
just being lazy (in my mind) especially those who are used to ASP's
Request.Value() which unfortunately is a lot of our developers at
work. They don't have a real good background as to the difference
between POST vs GET and even how the web works it seems.

That's why in the library I've created for us to use, I unset() it
before it's usable. Most third party software works okay too - off the
top of my head we've got Pligg, WordPress, MediaWiki all using hooks
into my library - a couple I did have to do a $_REQUEST =
array_merge($_POST, $_GET) on, unfortunately.

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



Re: [PHP] NOLOH Launches Beta Program to Developers

2008-06-23 Thread mike
I want the damn code to look at! Not a hosted environment...

:)

Sounds like that's not an option right now?

On 6/23/08, Asher Snyder [EMAIL PROTECTED] wrote:
 NOLOH (Not One Line Of HTML), a fully object-oriented development platform
 for PHP launched a Beta Program today for developers.

 More information can be found at http://www.noloh.com.

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



Re: [PHP] NOLOH Launches Beta Program to Developers

2008-06-23 Thread mike
Well it's a framework right? I expected it to be like any other...

It says it will run on any webserver - which means it's expected to be
hosted on your own boxes at some point. It looks like they're running
a hosted beta program first though.

On 6/23/08, Wolf [EMAIL PROTECTED] wrote:

 If they let you look at the code, why would you purchase their hosting space?

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



Re: [PHP] NOLOH Launches Beta Program to Developers

2008-06-23 Thread mike
On 6/23/08, Asher Snyder [EMAIL PROTECTED] wrote:

 Hey Mike,

 Currently we're freely hosting all developer sandboxes. Your sandbox
 contains several examples of NOLOH applications of which you can freely
 access and modify the source.

Ah, then maybe I'll signup. I probably am too busy to write an app on
it though, but I really enjoy looking at how people accomplish certain
things. That's really my intention here. I like to download, view,
tinker, etc.

 We're still figuring out the various source licenses, open-source, personal,
 commercial, etc. If there's anything you need help with we're always
 available in #noloh on freenode, or e-mail to help you during the beta
 program.

That's cool, thanks.

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



RE: [PHP] looping through a database

2008-06-17 Thread Ford, Mike
On 16 June 2008 21:58, Richard Kurth advised:

 I am looping through a database of files that are numbers 1 through 10
 if  number 1 is in the database I what to print out the first table
 below if it is not then print the else section below. Then
 loop through
 the database to see if 2 through 10 are there and do the same thing.
Of
 course what I am doing does not work. Should I move it all to
 an array
 and then loop through it. Or use a foreach loop.
 Could you please give me an idea where to start looking
 
 while($row=mysql_fetch_array($sql_result)){
 
 if ($row[number]==1) {
 tr
 td File 1/td
 tdThis is the file/td
 tdDelete/td
 /tr
 }else{
 tr
 tdFile1/td
 td/td
 tdAdd/td
 /tr
 }
 
 }

Well, first of you need a few ?php ? tags to make this legal:

  if ($row[number]==1) {
  ?
  tr
  td File 1/td
  tdThis is the file/td
  tdDelete/td
  /tr
  ?php
  }else{
  ?
  tr
  tdFile1/td
  td/td
  tdAdd/td
  /tr
  ?php
  }
  
  }

Of course, some people frown on this and prefer other techniques such as
echo-ing the HTML, or assembling it into a variable which gets echoed at
the end -- but whatever floats your boat...!!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Problem with output_buffering directive in cli

2008-06-11 Thread Mike Burba
Thanks for ideas, Nathan.

 dunno if this was a typo on your part, but shouldnt it be,
 ini_get(output_buffering) ?

yes...was getting tired last night.  but it is correct in the code.

 you might not be getting your settings from the ini file you think you are,
 or there could be another one in the way.  just for the hell of it, why not
 give

 php --ini

This is a great idea...and I tried this but I'm using php 5.1.x and
--ini flag is not available until 5.2.something. sigh

 also, this brings up the point of setting local values on the cli.  im not
 sure how to do it.  w/ apache, you can supply a .htaccess file which allows
 you to alter values in the 'local' column of the phpinfo() output.  anyone
 know how to do it on the cli ?

Exactly my thoughts...anyone out there know?

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



Re: [PHP] Problem with output_buffering directive in cli

2008-06-11 Thread Mike Burba
I think I solved this issue by using the -d option on the commandline.

When I use:
php -d output_buffering=On ./filename.php

the local value / active value of output_buffering is correct.

MKB

On Wed, Jun 11, 2008 at 5:54 AM, Mike Burba [EMAIL PROTECTED] wrote:
 Thanks for ideas, Nathan.

 dunno if this was a typo on your part, but shouldnt it be,
 ini_get(output_buffering) ?

 yes...was getting tired last night.  but it is correct in the code.

 you might not be getting your settings from the ini file you think you are,
 or there could be another one in the way.  just for the hell of it, why not
 give

 php --ini

 This is a great idea...and I tried this but I'm using php 5.1.x and
 --ini flag is not available until 5.2.something. sigh

 also, this brings up the point of setting local values on the cli.  im not
 sure how to do it.  w/ apache, you can supply a .htaccess file which allows
 you to alter values in the 'local' column of the phpinfo() output.  anyone
 know how to do it on the cli ?

 Exactly my thoughts...anyone out there know?


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



[PHP] Problem with output_buffering directive in cli

2008-06-10 Thread Mike Burba
I am using Smarty templates to format HTML emails from the command
line (using cli).  My typical command is:
php filename.php

However, and I am struggling with templates that are greater than 10k.
 It looks like the Smarty output is getting truncated at about 10k.
Smarty uses output_buffering, so I need to be set the output_buffering
directive to 1 or On or 100, or something other than Off.
But I have not been able to do that.

I have changed the output_buffering setting in /.../cli/php.ini (as
well as /.../apache2/php.ini  /.../cgi/php.ini for good measure).
And that does seem to have an effect.

Here is what the output from phpinfo() is from the command line:
Directive = Local Value = Master Value
snip...
output_buffering = 0 = 100
output_handler = no value = no value
...snip...

So in other words, when I change the value in my /.../cli/php.ini, the
Master Value changes. However, the Local Value stays at 0.

In my code, I am testing for the value of output_buffering (using
ini_get(output buffering)), and its value is always 0 (same as the
Local Value that is output from the phpinfo().

So my question is...how do I turn on output_buffering correctly from
the command line?  Am I configuring the /.../cli/php.ini file
correctly?  Is something in my code (maybe an included library) maybe
setting that value without me knowing?  Am I looking in the wrong
place / headed in the wrong direction?

Mike

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



RE: [PHP] A problem with fgets()

2008-06-04 Thread Ford, Mike
On 30 May 2008 02:56, Usamah M. Ali advised:

 So you're confirming that fgets() doesn't necessarily read a whole
 line? This user note existed on the manual's page of fgets() since
 2004 and nobody deleted it or commented about:
 
 rstefanowski at wi dot ps dot pl
 12-Aug-2004 09:03
 
 Take note that fgets() reads 'whole lines'. This means that if a file
 pointer is in the middle of the line (eg. after fscanf()), fgets()
 will read the following line, not the remaining part of the currnet
 line. You could expect it would read until the end of the current
 line, but it doesn't. It skips to the next full line.
 
 That was my source of confusion.

Yes, I agree that that note is complete hogwash, and have just deleted
it!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Avoid object twice

2008-06-04 Thread Ford, Mike
On 04 June 2008 16:03, Yui Hiroaki advised:

 NO!
 That is what I do not want!
 setting.php need to run mail() function.
 also setting.php need $googlemapkey.
 
 other.php just need $googlemapkey.
 other .php do not need run mail() function.
 
 If I use include, I will get twice email.

Same answer as Thijs gave, just with the filenames moved around:

 google_info.php
 ?php
$googlemapkey = g8ejeUFEUHEU;// example

function sendMail() {
mail([EMAIL PROTECTED],test.test);
}
 ?


 setting.php
 ?php
include google_info.php;

sendMail();  // sends mail

// other stuff using your google API key
 ?

 other.php
 ?php
   include google_info.php;

// use your google API key any way you want
// ... but no call to sendMail()
 ?

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread mike
On 5/29/08, Weston C [EMAIL PROTECTED] wrote:

 Fortunately, I'll have full control of the hosting environment in the
 context this matters. :)

 dl is  definitely interesting, but I'm worried that runtime invocation
 might mean performance hits. Is there a way to do load/startup time
 inclusion?

you could put it in your php ini file

extension = foo.so

then I believe the impact will be on the first instance for that php
engine. so in fastcgi mode, you'd only have the hit once every
PHP_FCGI_MAX_REQUESTS when the child restarts...

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



[PHP] Trying to install imagick PECL module

2008-05-19 Thread mike
It doesn't appear to -need- this MagickWand stuff, yet configure keeps
failing on it.

Anyone here use it, know for sure? Thanks. It looks and it sees
imagemagick and such, but why it -requires- this API is confusing me.



[EMAIL PROTECTED]:/usr/src/build/imagick-2.2.0b2# ./configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc and cc understand -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php
-I/usr/local/include/php/main -I/usr/local/include/php/TSRM
-I/usr/local/include/php/Zend -I/usr/local/include/php/ext
-I/usr/local/include/php/ext/date/lib
checking for PHP extension directory...
/usr/local/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/local/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.12.0 or later if you want to
regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable the imagick extension... yes, shared
checking whether to enable the imagick GraphicsMagick backend... no
checking ImageMagick MagickWand API configuration program...
configure: error: not found. Please provide a path to
MagickWand-config or Wand-config program.
[EMAIL PROTECTED]:/usr/src/build/imagick-2.2.0b2#

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



RE: [PHP] JavaScript and PHP

2008-05-16 Thread Ford, Mike
On 14 May 2008 21:21, tedd advised:

 At 7:31 PM +0100 5/14/08, Mário Gamito wrote:
 Hi,
 
 I have this HTML/JS page that switches images
 clicking on the radio buttons and call
 template.php with the image ID as parameter:
 http://portulan-online.net/einstein.html
 
 Now, I need to make it a PHP page, because it is
 going to receive a parameter from the URL that
 calls it and pass it as is to template.php
 
 Mário:
 
 The key here to remember is that javascript uses
 ID and php uses NAME for inputs.

That's incorrect.  A form will function perfectly well with only name= 
attributes, and no ids, and it's quite possible for JavaScript to address the 
form elements using only the names (in fact, it's easier than via the ids as 
there's a short syntax for it!).

CSS and the DOM, however, use the ids as primary identifier, so use of either 
of those may demand the presence of ids.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] JavaScript and PHP

2008-05-16 Thread Ford, Mike
On 16 May 2008 16:12, Boyd, Todd M. advised:

 -Original Message-
 
 8 snip!
 
 That's incorrect.  A form will function perfectly well with only
name=
 attributes, and no ids, and it's quite possible for JavaScript to
 address the form elements using only the names (in fact, it's easier
 than via the ids as there's a short syntax for it!).
 
 CSS and the DOM, however, use the ids as primary identifier, so use
of
 either of those may demand the presence of ids.
 
 8 snip!
 
 True, you can access an input named myInput in a form named myForm
by
 simply writing: 
 
   document.myForm.myInput.value = Hello!;
 
 BUT... for CSS, it's also quite easy to reference something by name:
 
   [name=myElement]
   {
   color: blue;
   font-size: 10pt;
   }

Well, true -- hence the qualifiers in *primary* identifier and *may*
demand!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] Question about setting up FTP Upload and using the FTP suite...

2008-05-14 Thread Mike McGonagle
Hello all,
I am just trying to see if I can connect up with my internal FTP server from
our website. The server is accessible from the outside world, as we can log
in using a client, etc. I am not really sure how to troubleshoot this, but
below is the script that I have. I found it on the net (and can't remember
where), and changed it a bit for my needs. It would appear that the call to
'ftp_connect' is where it fails. I tried this with both a URL as well as the
actual IP address, both error at the same place with the same error. Is
there a way to get an actual error message that is a bit more explanatory as
to what is happening?

?php
$ftp_server = FTP.URL;
$ftp_user = USER;
$ftp_pass = PASSWORD;

echo Trying to connect with $ftp_server using $ftp_user, $ftp_pass;

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die(Couldn't connect to
$ftp_server);

if ($conn_id) {
echo Logging in as $ftp_user, $ftp_pass.;
 $login = ftp_login($conn_id, $ftp_user, $ftp_pass);

// try to login
 if ($login) {
echo Connected as [EMAIL PROTECTED];
} else {
echo Couldn't connect as $ftp_user\n;
}

 // close the connection
ftp_close($conn_id);
} else {
echo Could not establish connection;
}
?

Thanks for your help,

Mike

-- 
Peace may sound simple—one beautiful word— but it requires everything we
have, every quality, every strength, every dream, every high ideal.
—Yehudi Menuhin (1916–1999), musician


Re: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM

2008-05-14 Thread mike
I've got that before and I am not using a Hebrew version of PHP :)

On 5/14/08, Daniel Brown [EMAIL PROTECTED] wrote:

You're using a Hebrew version of PHP?

That means something along the lines of two times the two marks in 
 Hebrew.

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



Re: [PHP] tracking Mials Which were bounced.

2008-05-13 Thread mike
Seems like the general way is to create a mailbox (POP3 or IMAP) to
accept the bounces, then check it periodically and mark the emails as
invalid in your local database.

I would set threshholds so you don't mark something failed that only
bounced once - it could have been a mail setup error or something
else; I'd say wait for 3 failures in a 7 day period at least. If you
get 3 bounces by that point, the address is probably safely dead.

You can use PHP's IMAP functions to check the mailbox (even for POP3)
or a million classes or your own functions directly on the socket
(POP3 is a simple protocol) - it also helps if you parse the bounced
email message to process the return address and the mail code; perhaps
build something better than just 3 failures = invalid, but actually
determine if they're full out failures, or if they're just temporary
bounces, etc.

Another method: you could just parse mail logs, if you have access to them.

 Chetan Rane wrote:
  Hi All
 
  I am using a PHP Mailer to send mass mails.
  How can I Identify how mails have bounced.

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



Re: [PHP] tracking Mials Which were bounced.

2008-05-13 Thread mike
On 5/13/08, Chris [EMAIL PROTECTED] wrote:

 I use this method and it works reasonably well. The hard part is the
 last sentence - there are so many ways to say mailbox full - half
 don't include smtp error codes, the rest tell you the same thing in
 thousands of different ways.

exactly. that's why i try to make it spread out - if there's failures
for 7 days, odds are that email account is dead/unused. worst case you
lose one person on your mailing list who doesn't check their email
often enough to be worthwhile :)

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



[PHP] Web page excerpt editor

2008-05-04 Thread Mike Potter
We are looking for a script similar to SnippetMaster
(http://www.snippetmaster.com/). We want to give the non-html-coding
client the ability to make edits to one part of one page on their Web
site on a weekly or near-daily basis. We are looking for something
free and turnkey, so we can move on to the next paying client. As
stated, the client is not html-aware so SnippetMaster itself fails our
criteria, the free version does not offer WYSIWYG previews of changes
while editing (http://www.snippetmaster.com/compare.html).

Does anyone have any experience with something else? Alternately, has
anyone written something they'd be willing to share under GPL?

Ski

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



Re: [PHP] Web page excerpt editor

2008-05-04 Thread Mike Potter
Oops, I replied to Paul only.

On Sun, May 4, 2008 at 11:46 AM, Paul Scott wrote:

  FCKEditor, TinyMCE and a host of others. All JS based, so not really
  relevant on a PHP list though

Whereas, SnippetMaster *is* PHP-based. Sad if it's the only one, I
thought (hoped) there would be more.

Ski

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



Re: [PHP] Web page excerpt editor

2008-05-04 Thread Mike Potter
On Sun, May 4, 2008 at 5:49 PM, Robert Cummings wrote:

   Whereas, SnippetMaster *is* PHP-based. Sad if it's the only one, I
   thought (hoped) there would be more.

  When you can't find what you want, feel free to pick up you keyboard and
  create the solution. Then be sure to share it with everyone else.

Perhaps I shall, in due time. As indicated earlier however, one of the
goals is something free and turnkey, so we can move on to the next
paying client. If time and money were no issue, I wouldn't have
bothered Googling up SnippetMaster in the first place. I'd have
started writing something from scratch as a first step. Alas...

Ski

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



Re: [PHP] the most amazing php code i have ever seen so far

2008-04-25 Thread mike
On 4/25/08, paragasu [EMAIL PROTECTED] wrote:

 too bad, i can't find  any framework out there  using this concept. well, i
 think
 have to figure out how it works and code on my own. can anyone kind enough
 to
 give me a good reference to read about this?

google? :)

http://en.wikipedia.org/wiki/Observer_pattern

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



Re: [PHP] Big companies that use PHP?

2008-04-23 Thread mike
We're using it at Intel on a handful of sites... I think my team is
the only one though :) The apps aren't really big but we are a big
company using it.

On 4/23/08, Thiago Pojda [EMAIL PROTECTED] wrote:
 Hey guys,

 I've been asked this common question: What big companies use PHP in big
 apps?

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



Re: [PHP] the most amazing php code i have ever seen so far

2008-04-23 Thread mike
On 4/23/08, paragasu [EMAIL PROTECTED] wrote:

 But one project using php in a very clean way. The codeis look so simple.
 yet do so much thing.
 Personally, i vote for www.eyeos.org project for the best php code. Anyone
 know better?

Yes: mine.

:)

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



Re: [PHP] Testing HTTPS without certificate

2008-04-23 Thread mike
just use a self-signed cert.

there should be a lot of examples out there for that.

On 4/23/08, Ken Kixmoeller [EMAIL PROTECTED] wrote:
 Hi - - -   - --

 I have a typical setup -- my development machine, a testing server and, of
 course, the production server. My development machine, of course, doesn't
 have a Secure certificate, yet I need to be able to test https pages here,
 before getting to the testing server. (Currently, the testing server doesn't
 have one either, but that will be remedied shortly.)

 I know how to test for the existance of HTTPS, and stuff like that.

 So: Can one test https on a local machine? Resources, anyone? I have Googled
 my fingers off.

 Environment: PHP 5.2.5
 Win 2K
 IIS 5

 - or, if I need to -

 Mac OS-X 10.4
 Apache? (I haven't set up the Mac as a server)

  - or -

 Linux (Ubuntu) with Apache (I am moving this direction and haven't yet
 learned how to run Apache)

 Ken

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



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



Re: [PHP] the most amazing php code i have ever seen so far

2008-04-23 Thread mike
Some day I'll package up some stuff and release it.

Sadly I have nothing worthwhile out in public right now.

On 4/23/08, paragasu [EMAIL PROTECTED] wrote:
  Yes: mine.

 kind enough to let me see your code .. =)


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



Re: [PHP] the most amazing php code i have ever seen so far

2008-04-23 Thread mike
i'm confident, there just isn't much use to the barrage of snippets
and customized stuff.

i am in the middle of some useful, generic code, we're using it where
i work, but it isn't in any sort of distributable fashion at the
moment. it almost mirrors the idea of the zend framework, but in a
procedural fashion.

On 4/23/08, paragasu [EMAIL PROTECTED] wrote:

  Some day I'll pac
  Sadly I have nothing worthwhile out in public right now.

 everything is relative in this small world. honestly, just like you,
 i also tend to think my code is good (of course because i wrote it)..
 personal opinion is different than what the public might say.

 some day, when you confident enough to release you code. i hope
 i will be there to see.. =)


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



Re: [PHP] Cannot modify header information - headers already sent by ...

2008-04-21 Thread mike
this also should not be an issue if you have output buffering turned on.

PHP is great, it will make sure to send the headers *first* then.

but yes, whitespace sucks as well. it makes IE's CSS flake out weird
sometimes. there's multiple reasons to write clean code :)

  On Mon, Apr 21, 2008 at 11:33 AM, Waynn Lue [EMAIL PROTECTED] wrote:
   I fixed this last time by looking for white space both before and
after the opening and closing php tags, as a Google search had
revealed.  But this time, I've spent an hour running down various
files and not seeing what the heck is wrong.  Here's the essential
setup.
  
main.php
?
  
require_once 'shared_style.php';
require_once 'something.php'
  
?

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