php-general Digest 2 May 2009 02:09:48 -0000 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
----------------------------------------------------------------------
--- Begin Message ---
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=36&text=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 ---
--- Begin Message ---
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 ---
--- Begin Message ---
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 ---
--- Begin Message ---
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?
--- End Message ---
--- Begin Message ---
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!
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
On Fri, May 1, 2009 at 10:29 AM, Robert Cummings <rob...@interjinn.com>wrote:
>
> 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.
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
On Fri, May 1, 2009 at 10:40 AM, Robert Cummings <rob...@interjinn.com>wrote:
> 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.
--- End Message ---
--- Begin Message ---
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.com>wrote:
>
> > 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
--- End Message ---
--- Begin Message ---
On Fri, May 1, 2009 at 10:55 AM, Robert Cummings <rob...@interjinn.com>wrote:
>
> 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.
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
On 5/1/09 4:54 AM, "Richard Heyes" <rich...@php.net> 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.
thanks. i really wanted to confirm that it's absent from the language. i've
been unsure for years if it's somewhere in the manual and i just can't find
it.
--- End Message ---
--- Begin Message ---
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-gene...@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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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-gene...@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
--- End Message ---
--- Begin Message ---
ooops sorry, two more ;-)
> having exactly the same number of characterss.aspx
_________________________________________________________________
Windows Live™: Keep your life in sync. Check it out!
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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).
--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
>
>
--- End Message ---