OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 25 Aug 2005 19:18:55 -0000 Issue 3645

php-general-digest-helplists.php.net
Date: Thu Aug 25 2005 - 14:18:55 CDT


php-general Digest 25 Aug 2005 19:18:55 -0000 Issue 3645

Topics (messages 221320 through 221374):

Re: PHP GD and Unicode
        221320 by: Burhan Khalid

Re: Be careful! Look at what this spammer did.
        221321 by: Dotan Cohen

Re: syntax for two comparison operators
        221322 by: Richard Lynch
        221362 by: Jordan Miller

Re: XML manipulation using PHP
        221323 by: Burhan Khalid

Re: LDAP problem
        221324 by: Richard Lynch

Re: explain to what's going with this piece of code.
        221325 by: Burhan Khalid
        221350 by: wayne

Re: Easier way to clean GET Variables ?
        221326 by: Burhan Khalid
        221328 by: Jasper Bryant-Greene
        221339 by: Burhan Khalid
        221340 by: Jasper Bryant-Greene
        221342 by: Richard Lynch
        221352 by: Robert Cummings
        221373 by: Graham Anderson

Re: trying to get phpmail to send an attachment
        221327 by: Richard Lynch
        221330 by: Jasper Bryant-Greene

Re: Error #1136
        221329 by: Richard Lynch
        221344 by: Jochem Maas

Re: from database to links
        221331 by: Richard Lynch

Re: droping upload files
        221332 by: Richard Lynch

Re: php solution to html problem
        221333 by: Richard Lynch
        221335 by: Jasper Bryant-Greene
        221336 by: Alja¾ Bizjak Zupanc
        221338 by: Jasper Bryant-Greene

Re: Printing \n and \r to the screen
        221334 by: Richard Lynch
        221364 by: Dotan Cohen
        221366 by: Rory Browne

Re: PHP vs. ColdFusion
        221337 by: Richard Lynch

Re: Problem with SimpleXML
        221341 by: Richard Lynch

Re: anyone get corrupted response with php-fcgi when zlib.output_compression=On?
        221343 by: Xuefer

spam report
        221345 by: Xuefer
        221351 by: Edin Kadribasic

Re: Getting queries from files FYI
        221346 by: Robin Vickery

phppatterns.com
        221347 by: Chris Boget
        221349 by: Jay Blanchard

creating of html-archive
        221348 by: Michelle Konzack
        221363 by: Richard Lynch
        221365 by: Rory Browne

Themes, pictures directory
        221353 by: Martin Zvarík
        221354 by: John Ellingsworth
        221355 by: Raz

PHP open source newsletter software
        221356 by: Angelo Zanetti
        221358 by: Mark Rees

Re: parsing useragent string without get_browser
        221357 by: I. Gray

Re: [really O T] Re: [PHP] Catching all errors and redirecting O T
        221359 by: Jochem Maas
        221360 by: Sabine

Re: [new version] Re: [a proactive example of learning by hacking] Re: [PHP] Getting queries from files FYI
        221361 by: Robin Vickery

PHP Polling script?
        221367 by: Jay Paulson
        221368 by: Jay Blanchard
        221369 by: Jay Paulson

Recall: [PHP] PHP without php.ini
        221370 by: Bagus Nugroho

Problem with handling quotes after server upgrade
        221371 by: Vinayakam Murugan
        221372 by: Jay Blanchard

Re: make it remember
        221374 by: George B

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Louie Miranda wrote:
> But when i try it on a image, that has been created with GD. It does
> nothing.
>
> I just want to confirm, it what im doing with the fonts possible thru
> GD/Jpeg?
>
> Please help, if this aint possible. I think imight purchase the PDFLib
> instead to test the unicode support.

What version of GD are you using?

attached mail follows:


On 25 Aug 2005 10:53:37 +0530, Raj Shekhar <rajlistrajshekhar.net> wrote:
> Dotan Cohen <dotancohengmail.com> writes:
>
> > I don't really like CAPTCHA's. I'm filtering the content now, which is
> > in my opinion better anyway. In my university one of the computer
> > science projects (for an assignment!) is to break CAPTCHA's. Jpg-> bmp
> > and once it's a bmp the white noise and lines can be removed (think
> > photoshop filters), then OCR software extracts the words. It even
> > works on squiggly text with the right fonts installed in the OCR. Not
> > 100%, but it is easier for the computer to decipher than a handicapped
> > person, or a text browser. And I don't want to lock those out.
>
> you might find http://www.videolan.org/pwntcha/ helpful
>
> Raj Shekhar (still trying to get over his email backload)
> blog : http://rajshekhar.net/blog home : http://rajshekhar.net
> Disclaimer : http://rajshekhar.net/disclaimer

Thanks. Great site. Lots of other goodies too.

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/184/eurythmics.php
Eurythmics Song Lyrics

attached mail follows:


On Wed, August 24, 2005 6:10 pm, Jordan Miller wrote:
> Is there a technical reason why PHP does not allow comparison
> operator expressions like the following:
>
> if (2 < $x <= 4) {}

2 < $x <= 4 is a valid expression already.

2 < $x is evaluated first, and returns true/false

true/false is compared with 4 using <= and will always return TRUE,
since true/false will get typecast to 0/1 in order for the comparison
to be made.

At least, I THINK that's what will happen... Not sure on the
type-casting of something that I'd never code in the first place.

At any rate, it's already valid under current syntax, so you'd have a
HUGE backwards incompatibility issue to change it.

> From what I can tell, this expression can currently only be written
> as:
>
> if ( $x > 2 && $x <= 4) {}

I personally would use:

((2 < $x) && ($x <= 4))

Yes, the extra parens are kinda bogus -- But they visually separate
the two tests.

Putting the 2, $x, and 4 in order is similar to the 2 < x <= 4
Algebraic notation.

It wouldn't bug me to see 2 < $x && $x <= 4, mind you.

In code I've read/written, it's seldom been a real problem.

In fact, if the author is CONSISTENT in their ordering, and SYSTEMATIC
in their tests/conditions/expressions, it doesn't even really matter
to me if they use 2 < $x && $x <= 4 or $x > 2 && $x <= 4, so long as
it's the same way in all their code.

> Would adding this syntax to PHP be incredibly difficult or lead to
> performance slowdowns?

Probably not incredibly difficult, per se, and performance would not
suffer in any measurable way...

You'd just break a few zillion existing scripts that, whether the
authors know it or not, rely on the current behaviour.

I suspect it would also unearth a large number of previously
un-noticed bugs :-)

> I think I remember reading that PHP always evaluates expressions from
> right to left,

If you did read that, it was a REALLY BAD thing to have been written
by anybody anywhere. :-)

[Maybe that goof that decided PHP wasn't ready for Enterprise use we
were discussing a couple days ago. He was great at writing FACTUALLY
INCORRECT statements to shore up his pathetic arguments. :-)]

PHP has a very precise order of operations with Operater Precedence:

http://php.net/manual/en/language.operators.php#language.operators.precedence

In fact, some of those are VERY common pitfalls for newbies.

&& || versus AND OR often trips up beginning scripters.

Not only does PHP not always evaluate from left-to-right due to
precedence, even within the precedence ordering, some operators are
right-to-left associative:

$x = 2;
$y = 5;
$x = $y = 3;

Here we have a "tie" in order of operations between two assignment
operators.

Since = is RIGHT associative, the tie-breaker is to read from RIGHT to
LEFT and do the operations in this order:
$y = 3;
$x = $y;

So both $x and $y are 3.

[WRONG]
If = were LEFT associative, which it's NOT, you'd end up with $x being
5 and $y would still be 3:
$x = $y;
$y = 3;
[/WRONG]

'Course, $x = $y = 3; is probably Bad Practice anyway...

Though I guess I've seen:
$x = $y = $z = 0;
at the top of enough functions to understand and accept that it's a
convenient way to initalize all three variables to 0...

I don't LIKE it, but I can live with it.

> so I guess there may be a considerable codebase change
> required. Maybe there could be a default function workaround for this
> or some other way to automagically process these more concise
> expressions without too much of a slowdown?? Just curious.

You could maybe check with PHP-Internals to see if they believe that
nobody's relying on the current behaviour with < > <= >=, and then
there's no problem adding it, but I wouldn't get yer hopes up.

PS Is (2 < $x >= 0) a syntax error, or would you allow that silly
expression? :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Good to know about expression evaluation. Writing the expression(s)
like that (left-to-right and right-to-left) solves my dilemma... thanks!

Jordan

On Aug 25, 2005, at 2:44 AM, Richard Lynch wrote:

> I personally would use:
>
> ((2 < $x) && ($x <= 4))
>

attached mail follows:


Anas Mughal wrote:
> Could someone please share with me sample code for:
>
> - Adding an XML node to an existing XML document.

http://www.php.net/manual/en/function.domnode-append-child.php
http://www.php.net/manual/en/function.dom-domnode-appendchild.php

> - Modifying the value for a given XML node in an existing XML document.

http://www.php.net/manual/en/function.dom-domcharacterdata-replacedata.php

Please, RTFM

attached mail follows:


On Wed, August 24, 2005 12:47 pm, Björn Bartels wrote:

>        $binddn Â
> 'uid='.$username.',ou=users,ou=OxObjects,dc=dbusiness,dc=de';

Either you're missing an = sign here, or my eyesight is getting worse
than I thought... :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


wayne wrote:
> When I run a script from a package I download, it always
> bombs out on this section. I think that its getting
> the wrong parameters when it tries to make the Connection.
> I use PostgreSQL as my DB.Moodle is the name of the database and
> the user is moodleuser. I do not have a password on this DB.

Please ask on a Moodle support list, or on their official site. This is
not a moodle mailing list, but a list for general php programming issues.

attached mail follows:


On Thu, 2005-08-25 at 10:55 +0300, Burhan Khalid wrote:
> wayne wrote:
> > When I run a script from a package I download, it always
> > bombs out on this section. I think that its getting
> > the wrong parameters when it tries to make the Connection.
> > I use PostgreSQL as my DB.Moodle is the name of the database and
> > the user is moodleuser. I do not have a password on this DB.
>
> Please ask on a Moodle support list, or on their official site. This is
> not a moodle mailing list, but a list for general php programming issues.

>
I have ask on the moodle list.I thought my question was a general
question.I'm trying to understand the code.
Thanks for your time.

attached mail follows:


Jasper Bryant-Greene wrote:
> Robert Cummings wrote:
>
>> On Wed, 2005-08-24 at 23:12, Jasper Bryant-Greene wrote:
>>
>>> Graham Anderson wrote:
>>>
>>>> Is there a way to loop thru all of these GET requests by:
>>>> putting the GET variables into an array
>>>> processing the variable strings with trim/striptags/etc in a loop
>>>> exploding the variables back out into separate variables
>>>
>>>
>>> I just do this:
>>>
>>> function process_user_input($value) {
>>> return mysql_real_escape_string(strip_tags(trim($value)));
>>> // Or whatever processing you need
>>> }
>>>
>>> $_SAFE_GET = array_map('process_user_input', $_GET);
>>> $_SAFE_POST = array_map('process_user_input', $_POST);
>>>
>>> That way you never need to take them out of an array in the first
>>> place. Then you can do things like:
>>>
>>> mysql_query("INSERT INTO table (col) VALUES ('{$_SAFE_POST['val']}')");
>>
>>
>> Still need to check isset() status unless you've disabled E_NOTICE which
>> I don't advise since it's sloppy ;)
>
>
> Yeah, I usually would in a real script. Just slipped my mind when
> writing that example.

I would also in a real script, not use $_MyVar.

attached mail follows:


Burhan Khalid wrote:
> Jasper Bryant-Greene wrote:
>
>> Robert Cummings wrote:
>>> [snip]
>>> Still need to check isset() status unless you've disabled E_NOTICE which
>>> I don't advise since it's sloppy ;)
>>
>>
>>
>> Yeah, I usually would in a real script. Just slipped my mind when
>> writing that example.
>
>
> I would also in a real script, not use $_MyVar.

Would you care to elaborate with some reasons for this? I find it very
useful as a naming convention for any sort of "external variable" or
user input, so when reading my code I can immediately tell what came
from where.

Prepending the variable name with an underscore happens to be what PHP
does ($_SERVER, $_GET, $_POST, $_COOKIES, so on...) so it is simpler
just to carry on that convention.

Jasper

attached mail follows:


Jasper Bryant-Greene wrote:
> Burhan Khalid wrote:
>
>> Jasper Bryant-Greene wrote:
>>
>>> Robert Cummings wrote:
>>>
>>>> [snip]
>>>> Still need to check isset() status unless you've disabled E_NOTICE
>>>> which
>>>> I don't advise since it's sloppy ;)
>>>
>>>
>>>
>>>
>>> Yeah, I usually would in a real script. Just slipped my mind when
>>> writing that example.
>>
>>
>>
>> I would also in a real script, not use $_MyVar.
>
>
> Would you care to elaborate with some reasons for this? I find it very
> useful as a naming convention for any sort of "external variable" or
> user input, so when reading my code I can immediately tell what came
> from where.
>
> Prepending the variable name with an underscore happens to be what PHP
> does ($_SERVER, $_GET, $_POST, $_COOKIES, so on...) so it is simpler
> just to carry on that convention.

This is exactly the reason why you shouldn't do it. You don't know when
PHP might come out with a new 'superglobal' that conflicts with your
$_Myfunc.

In addition, when PHP prepends $_ to a variable name, it means
something. Specifically, it means that the variable is a 'superglobal'.
The only exception to this that I know of is $GLOBALS.

For the reasons above, I avoid creating user variables with $_ --
although there is no rule regarding variable names (other than the
syntax rules).

Sometimes, just because you can do something, doesn't mean you should.

Regards,
Burhan

attached mail follows:


Burhan Khalid wrote:
> Jasper Bryant-Greene wrote:
>>
>> Prepending the variable name with an underscore happens to be what PHP
>> does ($_SERVER, $_GET, $_POST, $_COOKIES, so on...) so it is simpler
>> just to carry on that convention.
>
>
> This is exactly the reason why you shouldn't do it. You don't know when
> PHP might come out with a new 'superglobal' that conflicts with your
> $_Myfunc.
>
> In addition, when PHP prepends $_ to a variable name, it means
> something. Specifically, it means that the variable is a 'superglobal'.
> The only exception to this that I know of is $GLOBALS.
>
> For the reasons above, I avoid creating user variables with $_ --
> although there is no rule regarding variable names (other than the
> syntax rules).
>
> Sometimes, just because you can do something, doesn't mean you should.

I understand what you're saying, and I had thought of that previously.
However, the only reason I can think of that PHP would create a
$_SAFE_POST superglobal is if it were to be doing exactly what I am
already doing with it, in which case it wouldn't matter.

What's more, if they did implement a $_SAFE_POST superglobal for
whatever reason, my scripts would continue to work anyway, because they
don't rely on the special functionality that could be introduced for
that variable. Example:

$_SAFE_POST = array_map('sanitise_func', $_POST);

would simply overwrite any existing $_SAFE_POST superglobal anyway.

Most of the time if I'm creating my own global variables I actually use
two underscores anyway, like $__db or $__user. I just use one underscore
when I sanitise user input because it looks cleaner.

Jasper

attached mail follows:


On Thu, August 25, 2005 2:56 am, Burhan Khalid wrote:
> I would also in a real script, not use $_MyVar.

$_XYZ use the $_ because they are superglobals.

If your $_MyVar isn't a superglobal with http://php.net/runkit, it
probably shouldn't be $_

That said, I do the same thing, for the variables I make that I WISH
were superglobals. :-)

Given that the list of superglobals is incredibly short, and that I
know damn well the $_PATH variable I made up is NOT a superglobal,
I've never had a problem doing this.

But if I worked somewhere and the boss say "Don't do that" I'd just
fix it and not argue, that's for sure.

By all rights, $GLOBALS should be $_GLOBALS, but it existed way too
early in PHP history and re-naming it would be a real pain.

PS I *think* this explanation of $_ is in the manual, but maybe it's
from some book/interview/paper from Rasmus or something... Sorry,
can't remember where.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Thu, 2005-08-25 at 03:14, Richard Lynch wrote:
> On Wed, August 24, 2005 10:06 pm, Graham Anderson wrote:
> > Is there a way to loop thru all of these GET requests by:
> > putting the GET variables into an array
> > processing the variable strings with trim/striptags/etc in a loop
> > exploding the variables back out into separate variables
>
> In addition to what everybody has posted...
>
> I really would recommend that on any given page you have something like:
>
> $_EXPECTED = array('userID', 'playlistName', 'language');
> $_EXPECTED = array_flip($_EXPECTED);

This isn't necessary if you don't import variables, but rather retrieve
them one by one as in the example I showed. Since there you essentially
denote valid input vars by virtue of retrieval rather than automating
the import.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


thanks guys :)

that was exactly what I needed
good karma to you

g

On Aug 25, 2005, at 6:19 AM, Robert Cummings wrote:

> On Thu, 2005-08-25 at 03:14, Richard Lynch wrote:
>> On Wed, August 24, 2005 10:06 pm, Graham Anderson wrote:
>>> Is there a way to loop thru all of these GET requests by:
>>> putting the GET variables into an array
>>> processing the variable strings with trim/striptags/etc in a loop
>>> exploding the variables back out into separate variables
>>
>> In addition to what everybody has posted...
>>
>> I really would recommend that on any given page you have something
>> like:
>>
>> $_EXPECTED = array('userID', 'playlistName', 'language');
>> $_EXPECTED = array_flip($_EXPECTED);
>
>
> This isn't necessary if you don't import variables, but rather retrieve
> them one by one as in the example I showed. Since there you essentially
> denote valid input vars by virtue of retrieval rather than automating
> the import.
>
> Cheers,
> Rob.
> --
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting |
> | a powerful, scalable system for accessing system services |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for |
> | creating re-usable components quickly and easily. |
> `------------------------------------------------------------'
>

attached mail follows:


On Wed, August 24, 2005 12:39 pm, Ross wrote:
> Fatal error: Function name must be a string in
> c:\Inetpub\wwwroot\ssn\php_mail.php on line 11

var_dump($_FILES['userfile']);

$_FILES['userfile'] is going to be an array.

It will have elements like 'name', 'tmp_name', 'error', 'size' etc.

> $mail->AddAttachment($_FILES('userfile'));

> <input name="userfile"]" type="file" id="userfile">

What's with the extra ]" in there?...

That might be what is messing you up...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Ross wrote:
> $mail->AddAttachment($_FILES('userfile'));

Ignoring the fact that $_FILES['userfile'] is an array and probably
isn't what you want to pass to the AddAttachment method (although I know
nothing about phpmail specifics), shouldn't that be:

$mail->AddAttachment($_FILES['userfile']);

(square brackets, as $_FILES is an array, not a function)

Jasper

attached mail follows:


On Wed, August 24, 2005 11:42 am, George B wrote:
> Column count doesn't match value count at row 1
>
> What does that mean? I have an id auto_increment and it breaks
> everytime
> because of that error. This has never happend before...

If you REALLY don't want to specify all the column names (as suggested
by others) you *CAN* use NULL for the auto_increment field value, and
MySQL will do the right thing.

create table example (
  example_id int(11) unsigned auto_increment unique not null primary key,
  example text
);

INSERT INTO example VALUES (NULL, 'This is an example.');

It's probably better to get in the habit of specifying columns,
though, because eventually you'll have tables where only SOME columns
are known at the time of the initial INSERT, and others will be
UPDATEd later, or not at all, depending on the application.

So you *CAN* do this, but I'm recommending that you don't.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Jay Blanchard wrote:
> [snip]
> Column count doesn't match value count at row 1
>
> What does that mean? I have an id auto_increment and it breaks everytime
>
> because of that error. This has never happend before...
> [/snip]
>
> This is a MySQL problem and should be asked on a MySQL list, but having
> said that...

actually thats not true - John Nichel declared this list a list for anything
remotely related to IBM and the history of IT in general (although we won't
be fielding questions on how to build CPUs from raw sand apparently)

;-)

btw Jay - did you figure anything out for your sql query 'grepper'?

>
> You have specified a wrong number of columns in your INSERT query
>
> INSERT INTO table (1,2,3)
> VALUES ('1', '2')
>
> Will return this error.
>

attached mail follows:


On Wed, August 24, 2005 11:40 am, George B wrote:
> Richard Lynch wrote:
>> On Tue, August 23, 2005 3:52 pm, George B wrote:
>>
>>>You know on forums when you make a topic right away it makes like a
>>>new
>>>link to your topic. How do you do that in PHP?
>>
>>
>> <?php
>> //Untested code:
>> if (isset($_POST['new_topic'])){
>> $new_topic = $_POST['new_topic'];
>> $new_topic = mysql_escape_string($new_topic);
>> $query = "insert into topics (topic) values ('$new_topic')";
>> $insert = mysql_query($query) or die (mysql_error());
>> $topic_id = mysql_insert_id();
>> echo "<a
>> href=\"topics.php?topic_id=$topic_id\">$_POST[new_topic]</a>";
>> }
>> ?>
>>
>> http://php.net/mysql_insert_id
>> is probably the piece of the puzzle you were missing.
>>
> How did you get this in your link?
>
> topics.php?topic_id=$topic_id
>
> I cant figure.

This assumes you have a script named "topics.php" and that script uses
GET parameter "topic_id" to determine which Topic to display in your
Forum.

It was only a WILD GUESS as to how your forum topics would be
displayed, really... Well, not totally a wild guess, since that's
pretty much how they all work, though they will use different names
for stuff:

forum.php?id=$topic_id
view.php?thread_id=$topic_id
show.php?subject_id=$topic_id
.
.
.

Perhaps you need to set this aside for a while, and work on showing a
list of topics, and the display page for something chosen from that
list.

After you've written that, the link to put in there gets a LOT easier
to figure out.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, August 24, 2005 9:50 am, cajbecu wrote:
> Hello. I need some help. I set my php to run script.php before any php
> script. I want to drop uploaded files, so I did
>
> <?php
> if ($_SERVER["SERVER_NAME"]=="some.host.on.my.server") {
> if ((isset($_SERVER['REQUEST_METHOD'])) &&
> ($_SERVER['REQUEST_METHOD']=="POST")) {
> unset($_FILES);
> unset($HTTP_POST_FILES);
> }
> } else {
> }
> ?>
>
> it`s working for that host, but my question is.. if a user can upload
> his
> file on the server, despite the fact i unset all the global variables
> where
> the files are stored.

The files will be in your "tmp" directory (specified in php.ini).

If you change that to be some directory that does not exist, or
/dev/null on a Linux box, then the files won't ever actually live on
your server at all, I don't think...

Well, they will "live" in RAM while Apache accepts the POST, passes it
on to PHP, and then PHP stores it in the directory you chose in
php.ini (the default is to use the OS System default temp directory)

Hope that helps.

NOTE:
Having an invalid temp directory for file upload MAY trigger an error
message in PHP. You may not like that, and may want to test for it,
or use /dev/null for the directory... Oooh, that may not work
either...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, August 24, 2005 9:09 am, Ross wrote:
> I have a table which I put php data from a database.
>
> If i have a name 'thisisaveryverylongfirstname' the table stetches to
> fit
> the name. Is there any way I can force it to wrap to a fixed width of
> 100px??
>
> If I put a space in <BR> the text wraps. How can I do this at
> character 30
> of the string?
>
> Or any other suggestions...

PHP's wordwrap function may have an optional argument to FORCE it to
never be wider than X characters, but I don't think so...

You could write your own wordwrap function in about an hour, max.

Or take one of the umpteen wordwrap functions from before PHP had a
built-in wordwrap function.

If you are using CSS, and if you know the font and font-size it will
display in, I guess you could even fire up GD or PDF or something and
use the string length functions there with the same font and font-size
and figure out exactly where you should break up the string...

I'd cheat a little conservative if you REALLY need it to be no more
than 100px exactly, because I'm guessing differences in rendering will
make the text wider/narrower than GD thinks when the browser renders
it.

Actually, if you go to THAT much effort, and if it's really crucial,
maybe you should display the text as image. Ugh. Still, if it HAS to
be 100px or less, you could do that, and be CERTAIN of the width.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Richard Lynch wrote:
> PHP's wordwrap function may have an optional argument to FORCE it to
> never be wider than X characters, but I don't think so...

http://www.php.net/wordwrap

string wordwrap (string str [, int width [, string break [, bool cut]]])

"If the cut is set to 1, the string is always wrapped at the specified
width. So if you have a word that is larger than the given width, it is
broken apart. (See second example)."

Example:

$string = wordwrap($string, 30, '<br>', true);

Jasper

attached mail follows:


I recommend using Smarty for wrapping:

{$foo|wordwrap:30:"<br/>":true}

--
Regards,
Aljaz mailto:aljazvizija.si

attached mail follows:


Aljaž Bizjak Zupanc wrote:
> I recommend using Smarty for wrapping:
>
> {$foo|wordwrap:30:"<br/>":true}

That does the exact same thing as:

print(wordwrap($foo, 30, '<br />', true));

Which is much more convenient if you're not already using Smarty.

Jasper

attached mail follows:


On Wed, August 24, 2005 8:33 am, Dotan Cohen wrote:
> I seem to be having trouble with \n and \r in variables. I write my
> code on a linux box, and the server is linux. So I should always have
> \n\r, no? Is there a way the I could print $variable; and have it show
> me the /n and /r 's ? I tried with a srt_replace() on /n and on /r,
> but they do not get replaced. I also tried escaping the backslash,
> then double escaping that as was suggested somewhere in the
> php.net/manual, then triple escaping!

Windows uses \r\n
Linux uses \n
Mac uses \r

Depending on what tools you use to read/write/create the files, and
where the data comes from, it's possible that you have any of those
formats.

This is especially true of FORM data from a TEXTAREA.

I frequently do this:

$text = $_POST['text'];
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text);
//Now I *know* it's in Linux newline format.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On 8/25/05, Richard Lynch <ceol-i-e.com> wrote:
>
> Windows uses \r\n
> Linux uses \n
> Mac uses \r
>
> Depending on what tools you use to read/write/create the files, and
> where the data comes from, it's possible that you have any of those
> formats.
>
> This is especially true of FORM data from a TEXTAREA.
>
> I frequently do this:
>
> $text = $_POST['text'];
> $text = str_replace("\r\n", "\n", $text);
> $text = str_replace("\r", "\n", $text);
> //Now I *know* it's in Linux newline format.
>
> Like Music?
> http://l-i-e.com/artists.htm

Thanks, Richard. Jochem pointed that out earlier. I really should have
googled this first, but I was certain that what I _knew_ was right.
That happens sometimes. Now get that Uranus branch up!

Dotan
http://lyricslist.com/lyrics/artist_albums/395/papa_roach.php
Papa Roach Song Lyrics

attached mail follows:


If you're reading this text from a file, and then splitting it into
seperate lines, then I personally think you should leave this to the
built-in file() function.

On 8/24/05, Dotan Cohen <dotancohengmail.com> wrote:
> I seem to be having trouble with \n and \r in variables. I write my
> code on a linux box, and the server is linux. So I should always have
> \n\r, no? Is there a way the I could print $variable; and have it show
> me the /n and /r 's ? I tried with a srt_replace() on /n and on /r,
> but they do not get replaced. I also tried escaping the backslash,
> then double escaping that as was suggested somewhere in the
> php.net/manual, then triple escaping!
>
> Thanks ahead of time for any insight.
>
> Dotan Cohen
> http://lyricslist.com/lyrics/artist_albums/183/etheridge_melissa.php
> Etheridge,Melissa Song Lyrics
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


On Wed, August 24, 2005 7:32 am, Rick Emery wrote:
> Quoting Richard Lynch <ceol-i-e.com>:
>
>> Just for a test case, write a 10-line ASP script that does something
>> similar, if much simpler, and pound on it on the same box with the
>> Padcom clients.
>
> I did that when the problem first appeared. Great minds think alike
> :-)
>
>> I'm betting you'll have the SAME ISSUE, and that the problem has
>> NOTHING to do with PHP whatsoever.
>
> And you'd win that bet. I thought that would be the proof I'd need to
> show that it wasn't PHP, but management has some notion that PHP might
> have somehow tainted IIS.

Install it on a different box, which has IIS/ASP, and *NO* PHP was
ever installed.

It can be any old box out of the closet, that you wipe and install
Windows, IIS, ASP and NOTHING else.

Same bug?

Then it CANNOT be a PHP bug, can it?

Even PHB from Dilbert should understand that one...

Though, honestly, it sounds like they just aren't going to listen to
facts -- not even the ones about how much this is costing them.

I may not be making ends meet, but I sure am happy not to have to put
up with this kind of crap any more :-v

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, August 24, 2005 3:20 am, Uroš Gruber wrote:
> I have XML and I would like to set some values. I almost done the
> whole
> thing but have some problems when looping through some tags
>
> <foo>
> <bar id="1" name="bar1" />
> <bar id="2" name="bar2" />
> ...
> </foo>
>
> I would like to set value for tag "bar" in some loop and then export
> this back to XML. Is this even possible or it's better to use
> SimpleXML
> only for read and create new XML from it.
>
> XML is about 20 rows of data and I'm using PHP 5.0.4 with all XML
> included.

Maybe PHP 5 + SimpleXML really is that simple, but...

For 20 lines of text, you could probably write a function with explode
and implode and have it done in an hour...

<?php
  $bars = explode("<bar", $text);
  while (list(, $bar) = each($bars)){
    preg_match('/.*id="(.*)" name="(.*)".*/', $bar, $parts);
    $id = $parts[1];
    $name = $parts[2];
    //Do whatever you want with id and name and:
    echo "<bar id=\"$id\" name=\"$name\" />\n";
  }
?>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


never mind. i send it as bug report. and confirmed

attached mail follows:


From: <AdminBE2battery.co.za>

Subject of the message: [PHP] Re: anyone get corrupted response with
php-fcgi when zlib.output_compression=On?
Recipient of the message: "PHP LIST" <php-generallists.php.net>
===========
is anyone moderate this mailinglist? and get him out of the list?

attached mail follows:


This list are not moderated, but Derick has taken care of this
particular problem :)

Edin

Xuefer wrote:
> From: <AdminBE2battery.co.za>
>
> Subject of the message: [PHP] Re: anyone get corrupted response with
> php-fcgi when zlib.output_compression=On?
> Recipient of the message: "PHP LIST" <php-generallists.php.net>
> ===========
> is anyone moderate this mailinglist? and get him out of the list?
>

attached mail follows:


On 8/23/05, Jay Blanchard <jay.blanchardniicommunications.com> wrote:
> You may (or may not) remember me posting to the list a couple of weeks
> ago asking about using REGEX to get queries out of PHP files for a
> migration project. I had to let it go for several days, but started
> working on it again yesterday, here is the code (no REGEX was used in
> the making of this code);

Just a thought - and I know it's a little late, sorry.

Have you considered writing a wrapper for mysql_query() that logs its
parameters?

You could:

1. do a search and replace on your code replacing 'mysql_query' with
'mysql_query_wrapper'.

2. put a function definition for mysql_query_wrapper() in an auto_prepend file.

function mysql_query_wrapper()
{
  $args = func_get_args();
  $backtrace = debug_backtrace();
  $details = $backtrace[0];
  log(sprintf("%s (line %d): %s\n", $details['file'],
$details['line'], $details['args'][0]));
  return call_user_func_array('mysql_query', $args);
}

3. Let your users hammer it for a week or so. Your log should then
contain all the queries used by the app on a day-to-day basis and
where they were called from.

5. Do a grep for all lines containing 'mysql_query_wrapper' and diff
it with your log file. That should give you the locations of the
(hopefully few) remaining queries.

cut -d ':' -f 1,2 logfile.txt | sort --unique > recorded_queries.txt

fgrep -n 'mysql_query_wrapper' /path/*.php | cut -d ':' -f 1,2 | sort
--unique > all_queries.txt

comm -3 recorded_queries.txt all_queries.txt

attached mail follows:


Has the above site gone down? Does anyone know? I've not been able to
access it for quite a while...
 
thnx,
Chris

attached mail follows:


[snip]
Has the above site gone down? Does anyone know? I've not been able to
access it for quite a while...
[/snip]

I'm thinking that it must be down.

attached mail follows:


Hello,

Curently I do it with wget and by hand using a bash script,
but like to integrate it into my php4 webinterface.

What I need is:

    1) INPUT-Form where I can type the URL of
        a html/php (or something like this) page.

when submited,

    2) the php script download the page and create an md5sum
    3) look in a database where it check the whole URL wheter
        it is already there and if
        YES check the md5sum
            3.1) if equal drop the URL and stop here
            3.2) if different calculate original md5sum
                    and insert it into database
        NO calculate original md5sum and insert it into database

up to here it is working fine.

    4) now get all FULL URIs from the page requisites

*PAFF*

How can this be done ?

Please note, that the files should be renamed to md5-hashes and
reinseted into the original page. Then safed all files into ONE
directory with names as md5-hashes.

Note: I am talking about (curently) 127.000.000 files.
        It is curently in a Raid-5 with 7 x 147 GByte but because
        a major upgrade of Hardware to 15 x 300 GByte the number
        of files will increase

        Curently I do not know, whether I should use ONE Raid with
        15 HDDs, TWO with 7 HDDs, three with 5 HDDs or 5 with 3 HDDs.

        Maybe I will run into a performance problems with the Inodes
        which I already have... (I think)

Greetings
Michelle

--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
Michelle Konzack Apt. 917 ICQ #328449886
                   50, rue de Soultz MSM LinuxMichi
0033/3/88452356 67100 Strasbourg/France IRC #Debian (irc.icq.com)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFDDarZC0FPBMSS+BIRAu26AJ4sN/jj54OwhoPGLk7i5guVJfD5TwCfZ6QZ
MNKSwGP01kg/ClWHd8wh07g=
=5OaP
-----END PGP SIGNATURE-----

attached mail follows:


On Thu, August 25, 2005 6:26 am, Michelle Konzack wrote:
> Curently I do it with wget and by hand using a bash script,
> but like to integrate it into my php4 webinterface.

<?php exec("wget $URL", $output, $error);?>
http://php.net/exec

You really don't want to re-write all of wget.

And I doubt that anything in PHP to do what wget does will out-perform
exec + wget

You can also exec() your bash shell script, or combine the wget and
your script into one script to execute.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


At the risk of making a complete and utter ass of myself, I'm going to
disagree with Richard.

I'm going to justify this, by the fact that file_get_content function
is written in C, and performs function required, that is currently
performed by wget.

On 8/25/05, Michelle Konzack <linux4michellefreenet.de> wrote:
> Hello,
>
> Curently I do it with wget and by hand using a bash script,
> but like to integrate it into my php4 webinterface.
>
> What I need is:
>
> 1) INPUT-Form where I can type the URL of
> a html/php (or something like this) page.

I assume you know the html to create a web form, and how to use the
$_GET and $_POST variables. If not, go learn php, and then read the
rest of my reply.

>
> when submited,
>
> 2) the php script download the page and create an md5sum
Assuming that allow-url-fopen is enabled you can

$content = file_get_contents($url);
$md5hash = md5($content);

> 3) look in a database where it check the whole URL wheter
> it is already there and if
> YES check the md5sum

What DB are you using?

> 3.1) if equal drop the URL and stop here
> 3.2) if different calculate original md5sum
> and insert it into database
> NO calculate original md5sum and insert it into database
>
> up to here it is working fine.
>
> 4) now get all FULL URIs from the page requisites
>
> *PAFF*
>
> How can this be done ?
>
> Please note, that the files should be renamed to md5-hashes and
> reinseted into the original page. Then safed all files into ONE
> directory with names as md5-hashes.
>
> Note: I am talking about (curently) 127.000.000 files.
> It is curently in a Raid-5 with 7 x 147 GByte but because
> a major upgrade of Hardware to 15 x 300 GByte the number
> of files will increase
>
> Curently I do not know, whether I should use ONE Raid with
> 15 HDDs, TWO with 7 HDDs, three with 5 HDDs or 5 with 3 HDDs.
>
> Maybe I will run into a performance problems with the Inodes
> which I already have... (I think)
>
> Greetings
> Michelle
>
> --
> Linux-User #280138 with the Linux Counter, http://counter.li.org/
> Michelle Konzack Apt. 917 ICQ #328449886
> 50, rue de Soultz MSM LinuxMichi
> 0033/3/88452356 67100 Strasbourg/France IRC #Debian (irc.icq.com)
>
>
>

attached mail follows:


Hi,
    I have a website, which uses themes.

The web tree looks like this:

    * webroot
          o *themes*
                + default
                      # images
                + red design
                      # images
          o *index.php*

Let's say I choose "red design" theme. All the pictures the theme is
using will have URL like "www.site.com/themes/default/images/bla.jpg".

Is there a way how I can change it? So noone can see I have themes in
that directory?

I was thinking about: ShowImage.php?blah.jpg, but that is too slow... :-/

Any help appreciated.

Martin

attached mail follows:


Martin

You can use this, modified to fit your specific needs:

<?
// THE NAME OF YOUR IMAGEFILE
$imagefile = "bla.jpg";

//PATH WHERE THE IMAGES ARE STORED ON OUR WEB SERVER
$path = "/home/user/website.come/themes/default/images/" . $imagefile;

//TELL THE BROWSER WE ARE SENDING AN IMAGE
header("Content-type: image/jpeg");

//OPEN THE IMAGEFILE
$jpeg = fopen($path,"r");

//READ THE IMAGEFILE
$image = fread($jpeg,filesize($path));

//SEND IT DOWN THE PIPE
echo $image;
?>

Call this image.php

Call it in a webpage using this:

img src=image.php

Of course, you will need to figure out how to specify which image you
want loaded as $imagefile - be it a database, random selection, etc.

--
Thanks,

John Ellingsworth
Project Leader
Virtual Curriculum
Academic Programs
(215) 573-4451

Virtual Curriculum
http://www.cu2000.med.upenn.edu
AIM: vc2000support

To contact the Virtual Curriculum team:
cu2000mail.med.upenn.edu

Martin Zvarík wrote:
> Hi,
> I have a website, which uses themes.
>
> The web tree looks like this:
>
> * webroot
> o *themes*
> + default
> # images
> + red design
> # images
> o *index.php*
>
>
> Let's say I choose "red design" theme. All the pictures the theme is
> using will have URL like "www.site.com/themes/default/images/bla.jpg".
>
> Is there a way how I can change it? So noone can see I have themes in
> that directory?
>
> I was thinking about: ShowImage.php?blah.jpg, but that is too slow... :-/
>
>
> Any help appreciated.
>
> Martin
>
>

attached mail follows:


Martin

Using Apache? Check out
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html - all about
rewriting URLs...good luck!

HTH

Raz

attached mail follows:


Hi guys.

Does anyone know of any open source software written in PHP to create
HTML news letters (head, side and bottom graphics). as well as being
able to send the newsletters.

thanks in advance.

--

Angelo Zanetti
Z Logic
www.zlogic.co.za
[c] +27 72 441 3355
[t] +27 21 469 1052

attached mail follows:


"Angelo Zanetti" <angelozlogic.co.za> wrote in message
news:430DDBA4.10007zlogic.co.za...
> Hi guys.
>
> Does anyone know of any open source software written in PHP to create
> HTML news letters (head, side and bottom graphics). as well as being
> able to send the newsletters.

PHPlist from www.tincan.co.uk

>
> thanks in advance.
>
> --
>
> Angelo Zanetti
> Z Logic
> www.zlogic.co.za
> [c] +27 72 441 3355
> [t] +27 21 469 1052

attached mail follows:


The problem is I haven't seen any examples of this in php.

The best I have come up with is the following. I know the code is pants,
but it works. I am sure people out there can think of a better way of
doing it-

                $ua = $logInfo[useragent];
                if ( ereg("Firefox/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}",
$ua, $array)) {$browser = $array[0];}
                if ( ereg("MSIE [0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}",
$ua, $array)) {$browser = $array[0];}
                if (
ereg("Bloglines/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}", $ua,
$array)) {$browser = $array[0];}
                if (
ereg("Amfibibot/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}", $ua,
$array)) {$browser = $array[0];}
                if ( ereg("msnbot/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}",
$ua, $array)) {$browser = $array[0];}
                if (
ereg("Googlebot/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}", $ua,
$array)) {$browser = $array[0];}
                if ( ereg("Safari/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}",
$ua, $array)) {$browser = $array[0];}
                if (
ereg("Konqueror/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}", $ua,
$array)) {$browser = $array[0];}
                if ( ereg("Netscape/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}",
$ua, $array)) {$browser = $array[0];}
                if (
ereg("Thunderbird/[0-9]{1,2}[\.]{0,1}[0-9]{0,4}[\.]{0,1}[0-9]{0,4}",
$ua, $array)) {$browser = $array[0];}
                if (strpos($ua, "Web RSS Reader")!== FALSE) {$browser = "Web RSS
Reader";}
                if (strpos($ua, "BDFetch")!== FALSE) {$browser = "BDFetch";}
                if (strpos($ua, "www.almaden.ibm.com/cs/crawler")!== FALSE) {$browser
= "Web Fountain";}
                if (strpos($ua, "sohu-search")!== FALSE) {$browser = "Sohu Search";}
                if (strpos($ua, "Yahoo! Slurp")!== FALSE) {$browser = "Yahoo! Slurp";}
                if (strpos($ua, "Windows NT 5.1")) {$platform = "Windows XP";}
                elseif (strpos($ua, "Windows NT 5.0")) {$platform = "Windows 2000";}
                elseif (strpos($ua, "Windows 98") OR strpos($ua, "Win98")) {$platform
= "Windows 98";}
                elseif (strpos($ua, "Windows 95") OR strpos($ua, "Win95")) {$platform
= "Windows 95";}
                elseif (strpos($ua, "Win16") OR strpos($ua, "Windows 3.1")) {$platform
= "Windows 3.1";}
                elseif (strpos($ua, "Mac OS X")) {$platform = "Mac OSX";}
                elseif (strpos($ua, "Linux")) {$platform = "Linux";}

attached mail follows:


Sabine wrote:
> But pity for female germans asking stupid questions and mingling english
> with german? ;-)

of course :-)

<humour not-aimed-at="idiots, sheep">
you might as well know that soon John Nichel will take over the world
and outlaw political correctness. this means we can soon start to take a
proper sexist stance on this list - hey as long as you wear high heels you're
okay ;-)
</humour>

>
> Jochem Maas schrieb:
>
>>
>> the guy is german - most germans speak/write better english people do.
>> just like they build better cars. ;-) so no pity for [male] germans. :-P
>>
>> _only joking_
>>
>

attached mail follows:


Jochem Maas schrieb:

> Sabine wrote:
>
>> But pity for female germans asking stupid questions and mingling
>> english with german? ;-)
>
>
>
> of course :-)
>
> <humour not-aimed-at="idiots, sheep">
> you might as well know that soon John Nichel will take over the world
> and outlaw political correctness. this means we can soon start to take a
> proper sexist stance on this list - hey as long as you wear high heels
> you're
> okay ;-)
> </humour>

Oh, I'm really fond of high heels - as long as males with long and
pretty legs in nylons wear them ;-)

>
>>
>> Jochem Maas schrieb:
>>
>>>
>>> the guy is german - most germans speak/write better english people do.
>>> just like they build better cars. ;-) so no pity for [male] germans.
>>> :-P
>>>
>>> _only joking_
>>>
>>
>
>
>

attached mail follows:


This is another rather hackish attempt at using the tokeniser.

It turns this:

<?php
$emu = "my_column {$banana}";
$wallaby = 'my_table';
$kookaburra = 'SELECT * FROM';
$kookaburra .= $wallaby;
$koala = 'ASC';
$taipan = ' ORDER BY' . $emu;
$dropBear = 'group by something';

mysql_query("$kookaburra WHERE (up = 'down') $taipan $koala " .
strtoupper($dropBear));
?>

into this:

SELECT * FROM my_table WHERE (up = 'down') ORDER BY my_column $banana
ASC strtoupper( group by something)

Which isn't perfect by a long shot, but I'm away home now so it'll have to do.

I'd be interested to know what it makes of your queries.

 -robin

<?php

//looks at all $dir/*.php files.
$dir = '/path/to/php/files';

foreach (getPhpFileList($dir) as $file) {
  print "===== $file =====\n";
  $token = tokeniseFile($file);

  // first find all calls to mysql_query()
  $mysqlCalls = getMysqlQueryCalls($token);
  foreach($mysqlCalls as $range) {
    $sql = resolveExpression($token, $range[0], $range[0], $range[1]);
    echo trim(preg_replace('/\s+/', ' ', $sql)), "\n"; // tidy it a little
  }
}

function getMysqlQueryCalls($token) {
  $callList = array();
  for ($i=0; isset($token[$i]); $i++) {
    if (!is_array($token[$i])) continue; // not interested in atomic tokens
    if (strtolower($token[$i][1]) !== 'mysql_query') continue;
    $args = getMysqlQueryArguments($i, $token);
    if ($args !== false) $call[] = $args;
  }
  return $call;
}

function nameTokens($token, $start = 0, $end = null)
{
  if (is_null($end)) $end = sizeof($token);
  $range = array_slice($token, $start, $end - $start);
  foreach ($range as $key => $tok) {
    if (is_array($tok)) $range[$key][0] = token_name($range[$key][0]);
  }
  return $range;
}

function resolveToken($token, $cursor, $i) {
  if(is_array($token[$i])) {
    switch ($token[$i][0]) {
    case T_DOLLAR_OPEN_CURLY_BRACES:
    case T_CURLY_OPEN:
      break;
    case T_STRING:
    case T_WHITESPACE:
    case T_ENCAPSED_AND_WHITESPACE:
      return $token[$i][1];
    case T_CONSTANT_ENCAPSED_STRING:
      return eval( "return {$token[$i][1]};");
    case T_VARIABLE:
    case T_STRING_VARNAME:
      $def = findLastDefinition($token, $cursor, $i);
      if ($def === false) {
        // can't find anything else to replace $var with
        // presume it's defined elsewhere or we're not clever
        // enough to find it.
        return preg_replace('/^\$*/', '$', $token[$i][1]);
      }
      if ($def[3] == '.=') return
        resolveToken($token, $def[0], $i)
        . resolveExpression($token, $def[0], $def[1], $def[2]);
      
      return resolveExpression($token, $def[0], $def[1], $def[2]);
    default:
      return '('.token_name($token[$i][0]) . ':' . $token[$i][1] . ')';
    }
  } else {
    switch ($token[$i]) {
    case '(':
    case ')':
      return $token[$i];
    default:
      return '';
    }
  }
}

function ResolveExpression($token, $cursor, $start, $end) {
  $output = '';
  // just try and resolve all the tokens in the expression, concat
them and throw them back.
  for ( $i=$start; $i<$end; $i++) {
    $output .= resolveToken($token, $cursor, $i);
  }
  return $output;
}

function findLastDefinition($token, $i, $id) {
  // make sure all variables are in the form $name as ${name} ones are
  // just 'name' by the time they end up here.
  $name = preg_replace('/^\$*/', '$', $token[$id][1]);

  // rewind until we hit an assignment or run out of tokens
  while (isset($token[--$i])) {
    // if we catch an assignment and our $name is to the left then
capture the right.
    if (($token[$i] == '=' || (is_array($token[$i]) && $token[$i][0]
== T_CONCAT_EQUAL)) && getLHS($token, $i) == $name) {
      $RHS = getRHS($token, $i);
      $RHS[] = is_array($token[$i]) ? $token[$i][1] : $token[$i];
      return $RHS;
    }
  }
  // we've run out of tokens, so seems like we can't find where this
variable was defined.
  return false;
}

function getLHS($token, $i)
{
  // rewind until we hit an variable name or run out of tokens
  while (isset($token[--$i])) {
    if (is_array($token[$i]) && $token[$i][0] == T_VARIABLE) return
$token[$i][1];
  }
  // run out of tokens, we can't get a left hand side.
  return false;
}

function getRHS($token, $i)
{
  // save the cursor at the assignment operator, so if $name is referred to on
  // the RHS, and we have to look for it again, we don't look at this bit.
  $cursor = $i;

  // fast forward until we get to a ';' or run out of tokens.
  while (isset($token[++$i]) && $token[$i] != ';') {
    if (!isset($start)) $start = $i;
  }
  // if we've run out of tokens or the RHS is empty then give up.
  if (!isset($start) || !isset($token[$i])) return false;
  return array($cursor, $start, $i);
}

// just stick all the tokens together to see what's going on.
function renderTokens($token, $start, $end)
{
  $output = '';
  for ( $i=$start; $i<$end; $i++) {
    $output .= is_array($token[$i]) ? $token[$i][1] : $token[$i];
  }
  return $output;
}

function getMysqlQueryArguments($i, $token) {
  /* only allowed whitespace before brackets */
  while (isset($token[++$i])) {
    if ($token[$i] === '(') break;
    if (!is_array($token[$i])) return false;
    if ($token[$i][0] !== T_WHITESPACE) return false;
  }

  // if we're here, we've found the '('
  // now find the matching ')'
  $start = $i;
  $braceCount = 1;
  while (isset($token[++$i]) && $braceCount) {
    if ($token[$i] === '(') $braceCount++;
    if ($token[$i] === ')') $braceCount--;
    
  }
  // if we're left with any unmatched braces, something's wrong.
  if ($braceCount != 0) return false;
  // otherwise return the start and end positions of the parameters.
  return array($start+1,$i-1);
}

function getPhpFileList($dir)
{
  if (!is_dir($dir)) $dir = '.';
  return glob($dir . '/*.php');
}

function tokeniseFile($file)
{
  return token_get_all(file_get_contents($file));
}

function findMysqlQueries($tokens)
{
  return array_filter($tokens, 'isMysqlQuery');
}

function isMysqlQuery($token) {
  if (!is_array($token)) return 0;
  return ($token[0] == T_FUNCTION) || (strtolower($token[1]) == 'mysql_query');
}
?>

attached mail follows:


Does anyone know of a good polling script that is, obviously, written
in PHP?

Thanks!

attached mail follows:


[snip]
Does anyone know of a good polling script that is, obviously, written
in PHP?
[/snip]

What are you polling?

attached mail follows:


> [snip]
> Does anyone know of a good polling script that is, obviously, written
> in PHP?
> [/snip]
>
> What are you polling?

It's for a contest so that people can come in and read about the people
who are entered and then vote on which one they think should win. I
would like to at lease be able to restrict the polling by IP (using
mysql) and maybe cookies as well.

There seems to be a ton of polling packages out there in php but I'm
hoping someone on the list will have experience with one and can
recommend it instead of myself having to sift through a ton of them. :)

thanks!

attached mail follows:


Bagus Nugroho would like to recall the message, "[PHP] PHP without php.ini".

DISCLAIMER: The information in this email is confidential and proprietary. If you are not the intended recipient, please do not read, copy, use, or disclose the contents of this communication. Please permanently delete this e-mail and all copies that you may have. This information may be subject to privilege or may otherwise be protected by legal rules.

attached mail follows:


Hi

We have a content management system running for a client of ours. It was
earlier on Debian and Apache 1.3 . Now they have moved to Redhat Ent and
Apache 2. The PHP and MySQL versions are the standard packages available
with Redhat Ent and the same version as before. However we can see that it
now rejects any query which has a quote in it. Earlier it used to work fine..
So I am wondering whether there is any setting in PHP which controls it.

Not sure if I am making sense. Any pointers would be greatly appreciated.

--
Warm Regards
~~~~~~~~~~~~~~~
Vinayak
http://theregoesanotherday.blogspot.com/

attached mail follows:


[snip]
We have a content management system running for a client of ours. It was

earlier on Debian and Apache 1.3 . Now they have moved to Redhat Ent and

Apache 2. The PHP and MySQL versions are the standard packages available

with Redhat Ent and the same version as before. However we can see that
it
now rejects any query which has a quote in it. Earlier it used to work
fine..
So I am wondering whether there is any setting in PHP which controls it.

Not sure if I am making sense. Any pointers would be greatly
appreciated.
[/snip]

http://www.php.net/magic_quotes

Check the php.ini for the settings on magic_quotes

attached mail follows:


Robert Cummings wrote:
> On Thu, 2005-08-25 at 00:19, George B wrote:
>
>>Robert Cummings wrote:
>>
>>>On Thu, 2005-08-25 at 00:10, George B wrote:
>>>
>>>
>>>>Ok, I am doing a sort of a project right now... It is like a php chat
>>>>room that records every message into a database. Now, on the first post
>>>>I want it to like set the name, so on first post it would say Name: and
>>>>you set your name, then on every other message you post it just says
>>>>Posted by and remembers your name from the last entry. Is this anyhow
>>>>possible?
>>>
>>>
>>>Check session... if no name, display name prompt, otherwise don't
>>>display name prompt.
>>>
>>>Cheers,
>>>Rob.
>>
>>which would I choose.
>>http://us2.php.net/manual-lookup.php?pattern=sessions
>
>
>
> In brief:
>
> if( isset( $_POST['userName'] ) && !empty( trim( $_POST['userName'] ) )
> )
> {
> //
> // Save userName to session.
> //
> $_SESSION['userName'] = trim( $_POST['userName'] );
> }
>
> if( isset( $_POST['message'] ) && !empty( trim( $_POST['message'] ) )
> &&
> isset( $_SESSION['userName'] ) )
> {
> //
> // Handle submission of message.
> //
> }
>
> if( !isset( $_SESSION['userName'] ) )
> {
> //
> // Display user name prompt.
> //
> }
>
>
If I do that then i get this error

Fatal error: Can't use function return value in write context in
myfilename line 2

What does that mean. And one more thing, on the code where it says
if( !isset( $_SESSION['userName'] ) )
Does that mean that in this code

<form name="form1" method="" action="">
the method is session?