php-general Digest 1 May 2009 13:29:28 -0000 Issue 6097

2009-05-01 Thread php-general-digest-help

php-general Digest 1 May 2009 13:29:28 - Issue 6097

Topics (messages 292168 through 292178):

Re: Two very useful PHP functions
292168 by: Raymond Irving
292172 by: Darren

ImageMagick
292169 by: Michael A. Peters
292170 by: Ashley Sheridan
292171 by: Michael A. Peters
292175 by: Kevin Waterson

Re: object literals
292173 by: Richard Heyes
292174 by: Peter Ford
292177 by: Richard Heyes

Upload file name not file
292176 by: MikeP
292178 by: Simon

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---

Hi Colin and Daniel,

Thanks for the feedback.

I know that this functionality can be added to a framework or a stand alone 
function but I'm assuming that we would not get the same performance:

Case 1
---
$c = isset($a) ? $a : ''; 
// total time = overhead  of isset() + overhead of ?:

Case 2
---
$c = myWrapper($a,$b)  
// total time = overhead of myWrapper() + overhead of isset() + overhead of ?:

Case 3
---
$c = ifset($a,$b)  
// total time = overhead of ifset()



Best regards

__
Raymond Irving

--- On Thu, 4/30/09, Daniel Brown danbr...@php.net wrote:

 From: Daniel Brown danbr...@php.net
 Subject: Re: [PHP] Two very useful PHP functions
 To: Raymond Irving xwis...@yahoo.com
 Cc: php-gene...@lists.php.net
 Date: Thursday, April 30, 2009, 11:37 AM
 On Wed, Apr 29, 2009 at 22:32,
 Raymond Irving xwis...@yahoo.com
 wrote:
 
  What do you think? Can they make it into 5.3?
 
     Not when doing the ternary operator that you
 even displayed
 yourself takes up less code and time than a core function
 would.  It's
 a good idea, but better handled on the frontend of
 things.  You may
 want to consider contributing that to a framework, which is
 where it
 would be more appropriate.
 
 -- 
 /Daniel P. Brown
 daniel.br...@parasane.net
 || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon
 DOW1

---End Message---
---BeginMessage---
This was discussed for PHP6, but eventually decided not to have such a
function. Instead, we now have the following:$var = $_GET['var'] ?: 5;

Taken from http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

'you'd be able to do something like this: $foo = $_GET['foo'] ?: 42; (i.e.
if foo is true, $foo will equal 42).'


2009/5/1 Raymond Irving xwis...@yahoo.com


 Hi Colin and Daniel,

 Thanks for the feedback.

 I know that this functionality can be added to a framework or a stand alone
 function but I'm assuming that we would not get the same performance:

 Case 1
 ---
 $c = isset($a) ? $a : '';
 // total time = overhead  of isset() + overhead of ?:

 Case 2
 ---
 $c = myWrapper($a,$b)
 // total time = overhead of myWrapper() + overhead of isset() + overhead of
 ?:

 Case 3
 ---
 $c = ifset($a,$b)
 // total time = overhead of ifset()



 Best regards

 __
 Raymond Irving

 --- On Thu, 4/30/09, Daniel Brown danbr...@php.net wrote:

  From: Daniel Brown danbr...@php.net
  Subject: Re: [PHP] Two very useful PHP functions
  To: Raymond Irving xwis...@yahoo.com
  Cc: php-gene...@lists.php.net
  Date: Thursday, April 30, 2009, 11:37 AM
  On Wed, Apr 29, 2009 at 22:32,
  Raymond Irving xwis...@yahoo.com
  wrote:
  
   What do you think? Can they make it into 5.3?
 
  Not when doing the ternary operator that you
  even displayed
  yourself takes up less code and time than a core function
  would.  It's
  a good idea, but better handled on the frontend of
  things.  You may
  want to consider contributing that to a framework, which is
  where it
  would be more appropriate.
 
  --
  /Daniel P. Brown
  daniel.br...@parasane.net
  || danbr...@php.net
  http://www.parasane.net/ || http://www.pilotpig.net/
  50% Off All Shared Hosting Plans at PilotPig: Use Coupon
  DOW1
 

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


---End Message---
---BeginMessage---

Here's the scenario -

Website has some demonstrative images.

I create these images with the gimp - starting with a jpeg, adding a few 
text layers and straight lines.


I then save as xcf in case I ever need to edit.

Then I export to jpeg, resize for thumb and export to jpeg again.

Admin interface to my web face needs to allow for upload of image.

What would be sweet is if I could just upload the gimp xcf in these 
cases, and have ImageMagick do the export to jpeg and thumbnail creation.


Advantage of doing it this way - it will allow me to keep the original 
xcf on the server along with the generated images.


Issues -

I'd rather not have any 

php-general Digest 2 May 2009 02:09:48 -0000 Issue 6098

2009-05-01 Thread php-general-digest-help

php-general Digest 2 May 2009 02:09:48 - Issue 6098

Topics (messages 292179 through 292204):

how to enable ttf support in php 5.2.9
292179 by: PJ
292182 by: Michael A. Peters
292183 by: Michael A. Peters

Re: Upload file name not file
292180 by: MikeP
292201 by: Simon

Re: Two very useful PHP functions
292181 by: Andrew Ballard

output buffer with Chrome issue.
292184 by: Dan Joseph
292185 by: Robert Cummings
292186 by: Dan Joseph
292187 by: Robert Cummings
292188 by: Dan Joseph
292191 by: Robert Cummings
292192 by: Dan Joseph

how to write /textarea element in textarea?
292189 by: Grega Leskovsek
292190 by: Andrew Ballard

Re: object literals
292193 by: Tom Worster
292194 by: Andrea Giammarchi
292195 by: Robert Cummings
292196 by: Andrea Giammarchi
292197 by: Andrea Giammarchi
292199 by: Robert Cummings

graphical integrated development environment recommendations?
292198 by: Adam Williams
292200 by: Michael A. Peters
292202 by: Al
292203 by: listmail.websage.ca
292204 by: Andrew Hucks

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Is there a module to be activated or what has to be installed to have
ttf support in php?
My port on FreeBSD does not have an option for ttf support under make
config .
I'm trying to learn  understand the following:
In file1 : img src=button.php?s=36text=PHP+is+Cool /
In file2 (button.php)- originally php3 :
?php
  Header(Content-type: image/gif);
  if(!isset($s)) $s=11;
  $size = imagettfbbox($s,0,times.ttf,$text);
  $dx = abs($size[2]-$size[0]);
  $dy = abs($size[5]-$size[3]);
  $xpad=9;
  $ypad=9;
  $im = imagecreate($dx+$xpad,$dy+$ypad);
  $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
  $black = ImageColorAllocate($im, 0,0,0);
  $white = ImageColorAllocate($im, 255,255,255);
  ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
  ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
  ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black,
times.ttf, $text);
  ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white,
times.ttf, $text);
  ImageGif($im);
  ImageDestroy($im);
?
ONLY the above  nothing else. So far, all I get is a small blue square.
Replacing the $text with the text just gives a rectangle a bit wider.
gd is installed but ttf is not, so I figure that is the culprit.
But how is the text supposed to be assigned to $text from file1?
TIA

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php

---End Message---
---BeginMessage---

PJ wrote:

Is there a module to be activated or what has to be installed to have
ttf support in php?


on unix systems, ttf support should be there with freetype - which 
supports both ttf and postscript type 1 fonts (and probably also 
supports .otf though I haven't tried)


enable freetype and use the php freetype functions.
---End Message---
---BeginMessage---

PJ wrote:

Is there a module to be activated or what has to be installed to have
ttf support in php?


addendum to my earlier reply -

make sure your gd library is built with freetype as well, and make sure 
it is freetype 2.


I'm guessing your gd library already is, but ...
---End Message---
---BeginMessage---
I'm not trying to get the path, just the filename and size, I know how to 
get these, but that would include the file using $_Files, but I dont want to 
upload anything just use the filename and size.(without the path) to insert 
into a DB.
Simon turne...@gmail.com wrote in message 
news:5f14cf5e0905010629s2253cc3bk2a83dbf8b754c...@mail.gmail.com...
 Id like to use the popup file system box(input name=userfile 
 type=file
 /) to choose a file name , but I only want to upload the filename , not 
 the
 file. Can I do that?

 You're not supposed to have any access to the remote visitor's
 computer, and the path to the file being uploaded could contain
 sensitive information (ie. like username of windows user).  There are
 ways to get the information, even to read information on disk without
 the use of a file upload form.  But they are/will be considered like
 security threats and are/will be closed down.

 IMO, whatever way you find to get this information is meant 1) not to
 be portable accross different browsers and 2) to stop working
 eventually.  (Of course unless you ask the user to explicitly type the
 path in a text input)

 What do you need 

[PHP] ImageMagick

2009-05-01 Thread Michael A. Peters

Here's the scenario -

Website has some demonstrative images.

I create these images with the gimp - starting with a jpeg, adding a few 
text layers and straight lines.


I then save as xcf in case I ever need to edit.

Then I export to jpeg, resize for thumb and export to jpeg again.

Admin interface to my web face needs to allow for upload of image.

What would be sweet is if I could just upload the gimp xcf in these 
cases, and have ImageMagick do the export to jpeg and thumbnail creation.


Advantage of doing it this way - it will allow me to keep the original 
xcf on the server along with the generated images.


Issues -

I'd rather not have any code that spawns a shell, so I can only do this 
if the pecl imageMagick module is up to snuff for xcf-jpeg conversion. 
Anyone used it? Looks like I'll have to compile it, before I do that I 
would like to know if it even is up to the task.


Second possible issue - I don't know how well imageMagick can deal with 
an xcf file that uses text layer / fonts. I assume I'll have to install 
the font used on the server (Adobe New Century Schoolbook Type 1 - yes, 
I have license for it), but if so, how would I specify to ImageMagick 
the font path?


Anyone done this sort of thing?

I may just do the export on my home box via gimp and just scp the xcf to 
the server so a copy is stored there as well, but it would be nice to 
just stick the xcf into a file upload field and just have php do the rest.


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



Re: [PHP] ImageMagick

2009-05-01 Thread Ashley Sheridan
On Thu, 2009-04-30 at 23:35 -0700, Michael A. Peters wrote:
 Here's the scenario -
 
 Website has some demonstrative images.
 
 I create these images with the gimp - starting with a jpeg, adding a few 
 text layers and straight lines.
 
 I then save as xcf in case I ever need to edit.
 
 Then I export to jpeg, resize for thumb and export to jpeg again.
 
 Admin interface to my web face needs to allow for upload of image.
 
 What would be sweet is if I could just upload the gimp xcf in these 
 cases, and have ImageMagick do the export to jpeg and thumbnail creation.
 
 Advantage of doing it this way - it will allow me to keep the original 
 xcf on the server along with the generated images.
 
 Issues -
 
 I'd rather not have any code that spawns a shell, so I can only do this 
 if the pecl imageMagick module is up to snuff for xcf-jpeg conversion. 
 Anyone used it? Looks like I'll have to compile it, before I do that I 
 would like to know if it even is up to the task.
 
 Second possible issue - I don't know how well imageMagick can deal with 
 an xcf file that uses text layer / fonts. I assume I'll have to install 
 the font used on the server (Adobe New Century Schoolbook Type 1 - yes, 
 I have license for it), but if so, how would I specify to ImageMagick 
 the font path?
 
 Anyone done this sort of thing?
 
 I may just do the export on my home box via gimp and just scp the xcf to 
 the server so a copy is stored there as well, but it would be nice to 
 just stick the xcf into a file upload field and just have php do the rest.
 
Do the text layers have to go beneath something on the original xcf, or
have special effects applied to them? If not, you can add t existing
images with GD, by using a source image, adding text layers, etc, and
then exporting it as a new graphic.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] ImageMagick

2009-05-01 Thread Michael A. Peters

Ashley Sheridan wrote:




Do the text layers have to go beneath something on the original xcf, or
have special effects applied to them? If not, you can add t existing
images with GD, by using a source image, adding text layers, etc, and
then exporting it as a new graphic.


Yeah - I know I can do text with gd, I already do for some things.
The issue is that the placement of the text and the lines is custom per 
image, so it would require php coding each instance.


Some examples -

http://i142.photobucket.com/albums/r103/FunkyRes/8md.jpg
http://i142.photobucket.com/albums/r103/FunkyRes/telegans_shields02.jpg

Can be done with gd but it's a lot easier to add the text layers with a 
gui image editor - unless gimp has a php-gd export function that could 
write the code for me (that would be cool)


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



Re: [PHP] Two very useful PHP functions

2009-05-01 Thread Darren
This was discussed for PHP6, but eventually decided not to have such a
function. Instead, we now have the following:$var = $_GET['var'] ?: 5;

Taken from http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

'you'd be able to do something like this: $foo = $_GET['foo'] ?: 42; (i.e.
if foo is true, $foo will equal 42).'


2009/5/1 Raymond Irving xwis...@yahoo.com


 Hi Colin and Daniel,

 Thanks for the feedback.

 I know that this functionality can be added to a framework or a stand alone
 function but I'm assuming that we would not get the same performance:

 Case 1
 ---
 $c = isset($a) ? $a : '';
 // total time = overhead  of isset() + overhead of ?:

 Case 2
 ---
 $c = myWrapper($a,$b)
 // total time = overhead of myWrapper() + overhead of isset() + overhead of
 ?:

 Case 3
 ---
 $c = ifset($a,$b)
 // total time = overhead of ifset()



 Best regards

 __
 Raymond Irving

 --- On Thu, 4/30/09, Daniel Brown danbr...@php.net wrote:

  From: Daniel Brown danbr...@php.net
  Subject: Re: [PHP] Two very useful PHP functions
  To: Raymond Irving xwis...@yahoo.com
  Cc: php-general@lists.php.net
  Date: Thursday, April 30, 2009, 11:37 AM
  On Wed, Apr 29, 2009 at 22:32,
  Raymond Irving xwis...@yahoo.com
  wrote:
  
   What do you think? Can they make it into 5.3?
 
  Not when doing the ternary operator that you
  even displayed
  yourself takes up less code and time than a core function
  would.  It's
  a good idea, but better handled on the frontend of
  things.  You may
  want to consider contributing that to a framework, which is
  where it
  would be more appropriate.
 
  --
  /Daniel P. Brown
  daniel.br...@parasane.net
  || danbr...@php.net
  http://www.parasane.net/ || http://www.pilotpig.net/
  50% Off All Shared Hosting Plans at PilotPig: Use Coupon
  DOW1
 

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




Re: [PHP] object literals

2009-05-01 Thread Richard Heyes
Hi,

    $x = (object) array('a'=1, 'b'=3, ...);

 which works but isn't very lovely. it's neater in, for example, javascript.

Well, you could wrap it up in a function to make it a bit lovelier. Eg:

$foo = createObject(array('key' = 'value'));

It's not great, but PHP doesn't have a object literal syntax AFAIK.

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)

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



Re: [PHP] object literals

2009-05-01 Thread Peter Ford
Richard Heyes wrote:
 Hi,
 
$x = (object) array('a'=1, 'b'=3, ...);

 which works but isn't very lovely. it's neater in, for example, javascript.
 
 Well, you could wrap it up in a function to make it a bit lovelier. Eg:
 
 $foo = createObject(array('key' = 'value'));
 
 It's not great, but PHP doesn't have a object literal syntax AFAIK.
 
You could use JSON,

$foo = json_decode('{a:1,b:3}');

but I guess that's not much better than Richard's suggestion.

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] ImageMagick

2009-05-01 Thread Kevin Waterson
This one time, at band camp, Michael A. Peters wrote:
 Here's the scenario -
 
 Website has some demonstrative images.
 
 I create these images with the gimp - starting with a jpeg, adding a few 
 text layers and straight lines.
 
 I then save as xcf in case I ever need to edit.
 
 Then I export to jpeg, resize for thumb and export to jpeg again.


http://phpro.org/tutorials/Imagick.html

Kevin
http://phpro.org



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



[PHP] Upload file name not file

2009-05-01 Thread MikeP
Hello,
Id like to use the popup file system box(input name=userfile type=file 
/) to choose a file name , but I only want to upload the filename , not the 
file. Can I do that?
Thanks
Mike 



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



Re: [PHP] object literals

2009-05-01 Thread Richard Heyes
Hi,

 You could use JSON,

 $foo = json_decode('{a:1,b:3}');

 but I guess that's not much better than Richard's suggestion.

Didn't think of that (well... it's new). That's actually much better I
think, since you get the added boon of ease of portability to JS (if
that's even a factor).

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)

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



Re: [PHP] Upload file name not file

2009-05-01 Thread Simon
 Id like to use the popup file system box(input name=userfile type=file
 /) to choose a file name , but I only want to upload the filename , not the
 file. Can I do that?

You're not supposed to have any access to the remote visitor's
computer, and the path to the file being uploaded could contain
sensitive information (ie. like username of windows user).  There are
ways to get the information, even to read information on disk without
the use of a file upload form.  But they are/will be considered like
security threats and are/will be closed down.

IMO, whatever way you find to get this information is meant 1) not to
be portable accross different browsers and 2) to stop working
eventually.  (Of course unless you ask the user to explicitly type the
path in a text input)

What do you need this for?

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



[PHP] how to enable ttf support in php 5.2.9

2009-05-01 Thread PJ
Is there a module to be activated or what has to be installed to have
ttf support in php?
My port on FreeBSD does not have an option for ttf support under make
config .
I'm trying to learn  understand the following:
In file1 : img src=button.php?s=36text=PHP+is+Cool /
In file2 (button.php)- originally php3 :
?php
  Header(Content-type: image/gif);
  if(!isset($s)) $s=11;
  $size = imagettfbbox($s,0,times.ttf,$text);
  $dx = abs($size[2]-$size[0]);
  $dy = abs($size[5]-$size[3]);
  $xpad=9;
  $ypad=9;
  $im = imagecreate($dx+$xpad,$dy+$ypad);
  $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
  $black = ImageColorAllocate($im, 0,0,0);
  $white = ImageColorAllocate($im, 255,255,255);
  ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
  ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
  ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black,
times.ttf, $text);
  ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white,
times.ttf, $text);
  ImageGif($im);
  ImageDestroy($im);
?
ONLY the above  nothing else. So far, all I get is a small blue square.
Replacing the $text with the text just gives a rectangle a bit wider.
gd is installed but ttf is not, so I figure that is the culprit.
But how is the text supposed to be assigned to $text from file1?
TIA

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] Upload file name not file

2009-05-01 Thread MikeP
I'm not trying to get the path, just the filename and size, I know how to 
get these, but that would include the file using $_Files, but I dont want to 
upload anything just use the filename and size.(without the path) to insert 
into a DB.
Simon turne...@gmail.com wrote in message 
news:5f14cf5e0905010629s2253cc3bk2a83dbf8b754c...@mail.gmail.com...
 Id like to use the popup file system box(input name=userfile 
 type=file
 /) to choose a file name , but I only want to upload the filename , not 
 the
 file. Can I do that?

 You're not supposed to have any access to the remote visitor's
 computer, and the path to the file being uploaded could contain
 sensitive information (ie. like username of windows user).  There are
 ways to get the information, even to read information on disk without
 the use of a file upload form.  But they are/will be considered like
 security threats and are/will be closed down.

 IMO, whatever way you find to get this information is meant 1) not to
 be portable accross different browsers and 2) to stop working
 eventually.  (Of course unless you ask the user to explicitly type the
 path in a text input)

 What do you need this for? 



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



Re: [PHP] Two very useful PHP functions

2009-05-01 Thread Andrew Ballard
On Fri, May 1, 2009 at 4:05 AM, Darren dar...@sirdaz.com wrote:
 This was discussed for PHP6, but eventually decided not to have such a
 function. Instead, we now have the following:    $var = $_GET['var'] ?: 5;

 Taken from http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

 'you'd be able to do something like this: $foo = $_GET['foo'] ?: 42; (i.e.
 if foo is true, $foo will equal 42).'



I don't like that syntax at all. You would have to scrutinize code
even more to determine whether a statement like this was intentional
or a botched ternary operator. I'm not sure there is a need for a
function like ifset/ifsetor, but I'd MUCH rather have a clear function
name that could easily be found in the manual than mangling the
ternary operator.

Andrew

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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-01 Thread Michael A. Peters

PJ wrote:

Is there a module to be activated or what has to be installed to have
ttf support in php?


on unix systems, ttf support should be there with freetype - which 
supports both ttf and postscript type 1 fonts (and probably also 
supports .otf though I haven't tried)


enable freetype and use the php freetype functions.

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



Re: [PHP] how to enable ttf support in php 5.2.9

2009-05-01 Thread Michael A. Peters

PJ wrote:

Is there a module to be activated or what has to be installed to have
ttf support in php?


addendum to my earlier reply -

make sure your gd library is built with freetype as well, and make sure 
it is freetype 2.


I'm guessing your gd library already is, but ...

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



[PHP] output buffer with Chrome issue.

2009-05-01 Thread Dan Joseph
Hi Everyone,

I'm trying to get Chrome to output html information as it comes thru.  We
have an iframe running a php script, and when the php script receives
information, it outputs it.  FF, IE, and Safari all work just fine, displays
the info as it comes in.  However, Chrome is not.  It will only display the
information after the php script stops executing.

I am outputting this after every echo:

echo str_pad( , 4096 ) . \n;

flush();
ob_flush();

ob_implicit_flush();

Has anyone else had this issue?  Anyone know how to fix it?

-- 
-Dan Joseph

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


Re: [PHP] output buffer with Chrome issue.

2009-05-01 Thread Robert Cummings
On Fri, 2009-05-01 at 10:24 -0400, Dan Joseph wrote:
 Hi Everyone,
 
 I'm trying to get Chrome to output html information as it comes thru.  We
 have an iframe running a php script, and when the php script receives
 information, it outputs it.  FF, IE, and Safari all work just fine, displays
 the info as it comes in.  However, Chrome is not.  It will only display the
 information after the php script stops executing.
 
 I am outputting this after every echo:
 
 echo str_pad( , 4096 ) . \n;
 
 flush();
 ob_flush();
 
 ob_implicit_flush();
 
 Has anyone else had this issue?  Anyone know how to fix it?

Have you tried a bigger pad? Try... oh I dunno... 40096. if that works
then you can chop back until you find the threshold. Seems to be though
that it might be better done as AJAX.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] output buffer with Chrome issue.

2009-05-01 Thread Dan Joseph
On Fri, May 1, 2009 at 10:29 AM, Robert Cummings rob...@interjinn.comwrote:


 Have you tried a bigger pad? Try... oh I dunno... 40096. if that works
 then you can chop back until you find the threshold. Seems to be though
 that it might be better done as AJAX.


Hi,

I tried that, didn't work at all even up to 144096 on the pad, but no dice.
Ajax unfortunately isn't an option in this particular case.

-- 
-Dan Joseph

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


Re: [PHP] output buffer with Chrome issue.

2009-05-01 Thread Robert Cummings
On Fri, 2009-05-01 at 10:34 -0400, Dan Joseph wrote:

 Ajax unfortunately isn't an option in this particular case.

Why? Maybe you're thinking about it wrong.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] output buffer with Chrome issue.

2009-05-01 Thread Dan Joseph
On Fri, May 1, 2009 at 10:40 AM, Robert Cummings rob...@interjinn.comwrote:

 On Fri, 2009-05-01 at 10:34 -0400, Dan Joseph wrote:
 
  Ajax unfortunately isn't an option in this particular case.

 Why? Maybe you're thinking about it wrong.


Maybe, I'm open to suggestions:

Here's the basic way the application works.   main index renders, javascript
runs to create an iframe, and set the src='phpfile.php' that runs in a
continuous loop.  it connects to the server, and then listens for output.

Disconnecting from the server isn't an option at all, or else the
application will not function properly.  It needs to have the constant
stream to the server.

Is there a better solution for this?

-- 
-Dan Joseph

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


[PHP] how to write /textarea element in textarea?

2009-05-01 Thread Grega Leskovsek
I am writing CMS, that will be able to edit files.
For editing I put file inside textarea, but when I open file that has
textarea element inside it I lose (read: don't show data in the
textarea element.) the data after the inside /textarea element.
Any suggestions how can I fix this?

Thanks in advance,

-- 
When the sun rises I receive and when it sets I forgive -
http://users.skavt.net/~gleskovs/
All the Love, Grega Leskov'sek

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



Re: [PHP] how to write /textarea element in textarea?

2009-05-01 Thread Andrew Ballard
On Fri, May 1, 2009 at 10:44 AM, Grega Leskovsek mavri...@gmail.com wrote:
 I am writing CMS, that will be able to edit files.
 For editing I put file inside textarea, but when I open file that has
 textarea element inside it I lose (read: don't show data in the
 textarea element.) the data after the inside /textarea element.
 Any suggestions how can I fix this?

 Thanks in advance,


You need to use htmlspecialchars on whatever you place inside the textarea:

textarea name=content?php echo htmlspecialchars($content); ?/textarea


Andrew

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



Re: [PHP] output buffer with Chrome issue.

2009-05-01 Thread Robert Cummings
On Fri, 2009-05-01 at 10:42 -0400, Dan Joseph wrote:
 On Fri, May 1, 2009 at 10:40 AM, Robert Cummings rob...@interjinn.comwrote:
 
  On Fri, 2009-05-01 at 10:34 -0400, Dan Joseph wrote:
  
   Ajax unfortunately isn't an option in this particular case.
 
  Why? Maybe you're thinking about it wrong.
 
 
 Maybe, I'm open to suggestions:
 
 Here's the basic way the application works.   main index renders, javascript
 runs to create an iframe, and set the src='phpfile.php' that runs in a
 continuous loop.  it connects to the server, and then listens for output.
 
 Disconnecting from the server isn't an option at all, or else the
 application will not function properly.  It needs to have the constant
 stream to the server.
 
 Is there a better solution for this?

I presume your backend script is running something that passes the data
to the browser un-interrupted... maybe a shell script? You can wrap this
in popen() or proc_open() and read the output as you would a file. This
can then be queued for consumption by an AJAX script.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] output buffer with Chrome issue.

2009-05-01 Thread Dan Joseph
On Fri, May 1, 2009 at 10:55 AM, Robert Cummings rob...@interjinn.comwrote:


 I presume your backend script is running something that passes the data
 to the browser un-interrupted... maybe a shell script? You can wrap this
 in popen() or proc_open() and read the output as you would a file. This
 can then be queued for consumption by an AJAX script.


Ah ok, I've never used either of those before.  I am going to give that a
shot and will let you know how it goes.  I should be able to bolt that on
quickly.  Thanks!

-- 
-Dan Joseph

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


RE: [PHP] object literals

2009-05-01 Thread Andrea Giammarchi

var o = {
a : b,
c : d
};

$o = array(
'a' = b,
'c' = d
);

so I guess the problem is a couple of quotes, isn't it?


otherwise define object statically and externally and use json_decode ;-)




 Date: Thu, 30 Apr 2009 16:56:21 -0400
 From: f...@thefsb.org
 To: php-general@lists.php.net
 Subject: [PHP] object literals
 
 is there a neat literal syntax for creating objects on the fly without
 defining a type?
 
 whenever i need to do it i do something like
 
 $x = (object) array('a'=1, 'b'=3, ...);
 
 which works but isn't very lovely. it's neater in, for example, javascript.
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

_
Show them the way! Add maps and directions to your party invites. 
http://www.microsoft.com/windows/windowslive/products/events.aspx

RE: [PHP] object literals

2009-05-01 Thread Robert Cummings
On Fri, 2009-05-01 at 17:36 +0200, Andrea Giammarchi wrote:
 var o = {
 a : b,
 c : d
 };
 
 $o = array(
 'a' = b,
 'c' = d
 );
 
 so I guess the problem is a couple of quotes, isn't it?
 
 
 otherwise define object statically and externally and use json_decode ;-)

You made an array-- not an object.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



RE: [PHP] object literals

2009-05-01 Thread Andrea Giammarchi

you are in PHP, not in JavaScript.

In PHP arrays are like collections or hash tables.
if you strictly need object cause

$o-stuff
is better than
$o['stuff']

having exactly the same number of characters, you can create a function like

function o(array $a){
 $o = new stdClass;
 foreach($a as $key = $value)
 $o-$key = $value;
 return $o;
}


and the syntax will be

$o = o(array(
'a' = b,
'c' = d
));

spot the difference from (object) array(whatever) ?

I do not ... and that's why json_encode resolves associative arrays rather than 
list automatically but still, if you are in PHP, you should think about being 
familiar with associative arrays, also because so far is the only class you 
cannot create/extend.

class string {
// ok
}

class object {
// ok
}

class array {
// no way
}

Regards

 From: rob...@interjinn.com
 To: an_...@hotmail.com
 CC: f...@thefsb.org; php-general@lists.php.net
 Date: Fri, 1 May 2009 11:40:11 -0400
 Subject: RE: [PHP] object literals
 
 On Fri, 2009-05-01 at 17:36 +0200, Andrea Giammarchi wrote:
  var o = {
  a : b,
  c : d
  };
  
  $o = array(
  'a' = b,
  'c' = d
  );
  
  so I guess the problem is a couple of quotes, isn't it?
  
  
  otherwise define object statically and externally and use json_decode ;-)
 
 You made an array-- not an object.
 
 Cheers,
 Rob.
 -- 
 http://www.interjinn.com
 Application and Templating Framework for PHP
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

_
Show them the way! Add maps and directions to your party invites. 
http://www.microsoft.com/windows/windowslive/products/events.aspx

[PHP] graphical integrated development environment recommendations?

2009-05-01 Thread Adam Williams
With the wide range of users on the list, I'm sure there are plenty of 
opinions on what are good graphical IDE's and which ones to avoid.  I'd 
like to get away from using notepad.exe to code with due to its 
limitations.  Something that supports syntax/code highlighting and has 
browser previews would be nice features.  I'm looking at Aptana 
(www.aptana.com) but it seems like it is more complicated to use then it 
should be.  Either Linux or Windows IDE (i run both OSes) 
recommendations would be fine.



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



RE: [PHP] object literals

2009-05-01 Thread Robert Cummings
On Fri, 2009-05-01 at 17:52 +0200, Andrea Giammarchi wrote:
 you are in PHP, not in JavaScript.
 
 In PHP arrays are like collections or hash tables.
 if you strictly need object cause
 
 $o-stuff
 is better than
 $o['stuff']
 
 having exactly the same number of characters, you can create a
 function like
 
 function o(array $a){
  $o = new stdClass;
  foreach($a as $key = $value)
  $o-$key = $value;
  return $o;
 }
 
 
 and the syntax will be
 
 $o = o(array(
 'a' = b,
 'c' = d
 ));
 
 spot the difference from (object) array(whatever) ?
 
 I do not ... and that's why json_encode resolves associative arrays
 rather than list automatically but still, if you are in PHP, you
 should think about being familiar with associative arrays, also
 because so far is the only class you cannot create/extend.
 
 class string {
 // ok
 }
 
 class object {
 // ok
 }
 
 class array {
 // no way
 }
 
 Regards

First off, you compared the syntax between creating a PHP array and a
JavaScript object when the previous post specifically spoke about
getting a PHP OBJECT. Now you've made a rather lengthy and redundant
post trying to describe to me objects versus arrays in PHP. Lastly
you've suggested writing a function to convert an array to an object
using a foreach loop for the members which is completely unnecessary.
The following will suffice:

?php

function o( array $a )
{
return (object)$a;
}

?

... and the syntax will be:

?php

$o = o(array
(
'a' = b,
'c' = d,
));

?

But why bother when you could have just done:

?php

$o = (object)array
(
'a' = b,
'c' = d,
);

?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] graphical integrated development environment recommendations?

2009-05-01 Thread Michael A. Peters

Adam Williams wrote:
With the wide range of users on the list, I'm sure there are plenty of 
opinions on what are good graphical IDE's and which ones to avoid.  I'd 
like to get away from using notepad.exe to code with due to its 
limitations.  Something that supports syntax/code highlighting and has 
browser previews would be nice features.  I'm looking at Aptana 
(www.aptana.com) but it seems like it is more complicated to use then it 
should be.  Either Linux or Windows IDE (i run both OSes) 
recommendations would be fine.





Not an ide - I use bluefish, which is a gui text editor with syntax 
highlighting. It's an X11/gtk2+ application, packaged for most Linux 
distribution (ie yum install bluefish on Fedora or RHEL)


For previewing, I just run a web server on my development box.

Only hitch with bluefish - the syntax highlighting sometimes gets 
confused and it drops the highlighting. Press F5 and it reloads.


I believe there is a windows port of bluefish but if I was on windows, 
I'd probably just use Homesite (not free).


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



Re: [PHP] Upload file name not file

2009-05-01 Thread Simon
On Fri, May 1, 2009 at 9:34 AM, MikeP mpel...@princeton.edu wrote:
 I'm not trying to get the path, just the filename and size, I know how to
 get these, but that would include the file using $_Files, but I dont want to
 upload anything just use the filename and size.(without the path) to insert
 into a DB.

Those are attributes of the file for which you dont have access
remotely, and the only way to access this information without an
upload will be using the same hacks as those spywarez use.  A
technology like flash has read/write access to the remote user's disk
(to a certain extent), you could use flash to get that information and
make it send it to you, same thing could be done with ActiveX, etc...
PHP, JS and HTTP protocol cannot acheive what you want.  (PHP is
server-side, HTTP is for communication only, JS is client-side but
locked down very much).

However, at a very low level, it might be possible to achieve this in
PHP, you could do the upload as if you wanted the whole file.  But the
first packet received will contain the HTTP Header, and in the header,
you should have all the info you need (filename and size of data).
So, low-level speaking, as soon as you receive the first packet and
have the info, you just need to close the connection (remote end might
display an error msg saying the upload failed, etc).  PHP supports
sockets connections, so you could make a basic 'server' that listens
on another port to perform this.  But i see no way to acheive your
goal without complications.

Good luck!

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



Re: [PHP] graphical integrated development environment recommendations?

2009-05-01 Thread Al



Michael A. Peters wrote:

Adam Williams wrote:
With the wide range of users on the list, I'm sure there are plenty of 
opinions on what are good graphical IDE's and which ones to avoid.  
I'd like to get away from using notepad.exe to code with due to its 
limitations.  Something that supports syntax/code highlighting and has 
browser previews would be nice features.  I'm looking at Aptana 
(www.aptana.com) but it seems like it is more complicated to use then 
it should be.  Either Linux or Windows IDE (i run both OSes) 
recommendations would be fine.





Not an ide - I use bluefish, which is a gui text editor with syntax 
highlighting. It's an X11/gtk2+ application, packaged for most Linux 
distribution (ie yum install bluefish on Fedora or RHEL)


For previewing, I just run a web server on my development box.

Only hitch with bluefish - the syntax highlighting sometimes gets 
confused and it drops the highlighting. Press F5 and it reloads.


I believe there is a windows port of bluefish but if I was on windows, 
I'd probably just use Homesite (not free).


Look at phpEdit. It has everything you are looking for and is rock solid. I love the folding and 
regions features.


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



Re: [PHP] graphical integrated development environment recommendations?

2009-05-01 Thread listmail
On Fri, 01 May 2009 12:57:25 -0400
Al n...@ridersite.org wrote:

 
 
 Michael A. Peters wrote:
  Adam Williams wrote:
  With the wide range of users on the list, I'm sure there are
  plenty of opinions on what are good graphical IDE's and which ones
  to avoid. I'd like to get away from using notepad.exe to code with
  due to its limitations.  Something that supports syntax/code
  highlighting and has browser previews would be nice features.  I'm
  looking at Aptana (www.aptana.com) but it seems like it is more
  complicated to use then it should be.  Either Linux or Windows IDE
  (i run both OSes) recommendations would be fine.
 
 
  
  Not an ide - I use bluefish, which is a gui text editor with syntax 
  highlighting. It's an X11/gtk2+ application, packaged for most
  Linux distribution (ie yum install bluefish on Fedora or RHEL)
  
  For previewing, I just run a web server on my development box.
  
  Only hitch with bluefish - the syntax highlighting sometimes gets 
  confused and it drops the highlighting. Press F5 and it reloads.
  
  I believe there is a windows port of bluefish but if I was on
  windows, I'd probably just use Homesite (not free).
 
 Look at phpEdit. It has everything you are looking for and is rock
 solid. I love the folding and regions features.
 

Isn't phpedit windows-only?

shudder

Eclipse + PDT is my recommendation FWIW...

GM

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



Re: [PHP] graphical integrated development environment recommendations?

2009-05-01 Thread Andrew Hucks
http://notepad-plus.sourceforge.net/uk/site.htm

Try out N++. It's very good, supports a whole bunch of languages by
default, has folding, and you can tweak the syntax highlight if you
want. (You don't need to though.)

Takes two minutes to install, and 45 seconds to uninstall it if you
don't like it. It's worth a try.

On Fri, May 1, 2009 at 12:08 PM, Adam Williams
awill...@mdah.state.ms.us wrote:
 With the wide range of users on the list, I'm sure there are plenty of
 opinions on what are good graphical IDE's and which ones to avoid.  I'd like
 to get away from using notepad.exe to code with due to its limitations.
  Something that supports syntax/code highlighting and has browser previews
 would be nice features.  I'm looking at Aptana (www.aptana.com) but it seems
 like it is more complicated to use then it should be.  Either Linux or
 Windows IDE (i run both OSes) recommendations would be fine.


 --
 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] Re: graphical integrated development environment recommendations?

2009-05-01 Thread Shawn McKenzie
Adam Williams wrote:
 With the wide range of users on the list, I'm sure there are plenty of
 opinions on what are good graphical IDE's and which ones to avoid.  I'd
 like to get away from using notepad.exe to code with due to its
 limitations.  Something that supports syntax/code highlighting and has
 browser previews would be nice features.  I'm looking at Aptana
 (www.aptana.com) but it seems like it is more complicated to use then it
 should be.  Either Linux or Windows IDE (i run both OSes)
 recommendations would be fine.
 

I used eclispe, but I'm using netbeans now.  Runs on win and linux.
Just to edit a file here and there I use kate on linux (many text
editors have highlighting/folding on linux) and notepad++ when I have to
be on windows.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] SOAP and Exception Handling

2009-05-01 Thread VamVan
Hello Guys,

I use SOAP calls to make web service requests.I have a class that does
webservice calls to various wsdls. So my question is about try catch blocks.

so my method looks like this:

private function method($cookie){
  //Define Client
  try{
  // Check if WSDL exists
  if(!...@file_get_contents($this-WSDL)) {
throw new SoapFault('Server', 'No WSDL found at ' .
$this-WSDL);
  }
  $client = new SoapClient($this-WSDL, array(
  'exceptions' = 1,
  'encoding' = UTF-8,
  'connection_timeout' = 60
  ));
  }catch(SoapFault $fault){
  // Error if the WSDL is not available or new client cannot be made
  //log errror
  }
  //Define Input Array
$input = array();
$input['cookie'] = $cookie;

//Make the call
  try{
  $result = $client-function($input);// Make the Call
  return $result;
  }catch(SoapFault $fault){
//log error
  }
   }

How is it possible for me to *remove *these 2 try and catch blocks from this
method and just throw exceptions, but do a try and catch in the business
logic.

So basically I might have different functions in  business logic area that
might call the same method and I do error logging there itself instead
directly in the method?

Thanks,
V


[PHP] PHP6 return by reference deprecation

2009-05-01 Thread Paul M Foster
In another thread (which I mercifully declined to highjack), someone
cited:

 Taken from http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

And I read this:

Both '$foo = new StdClass()' and 'function foo' will now raise an
E_STRICT error.

I don't use this much, but where I do, it's vital. Typically, I use it
to ensure a single copy of the $config for an application, as:

function get_config() ...

and/or:

$cfg = get_config();

If this is going away, how do you return things by reference, so as to
ensure a single copy of something (yes, I know the singleton pattern can
be used; I do use it as well; it's more complicated)?

Paul

-- 
Paul M. Foster

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