php-general Digest 26 Nov 2006 19:09:56 -0000 Issue 4481

Topics (messages 245145 through 245154):

Re: Self generating variables/arrays
        245145 by: Larry Garfield
        245147 by: Roman Neuhauser
        245148 by: Stut
        245153 by: Richard Lynch

PHP sendmail proxy (using xinetd)
        245146 by: Kelly Jones

Re: To install a small program from a web browser
        245149 by: tedd

Negative memory_get_usage() Values
        245150 by: Chris
        245152 by: Richard Lynch
        245154 by: Chris

Re: GD, and GD JPEG
        245151 by: Peter Lauri

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

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


----------------------------------------------------------------------
--- Begin Message ---
If eval is the answer, you're asking the wrong question.

You haven't given enough information to really say the best way to do what it 
is you're doing.  However, I suspect that explode() and arrays of arrays 
(i.e., $a[1][2]) will do what you need to do much better than messing around 
with eval.

On Sunday 26 November 2006 00:19, jekillen wrote:
> Hello;
> I am writing some code that will format results of a search for display.
> I need to split an array into several different arrays but I won't know
> before hand how many, so, I am looking for a way to dynamically
> generate arrays for this purpose.
> My present direction is to use the following code:
>
> for($i = 0; $i < $c; $i++)
>      { eval('$a_'.$i.' = array();'); }
>
> Where '$c' is the derived number of arrays need to hold the
> pieces of the bigger array. My confusion, though, is; since
> these are created in the scope of the for loop, I don't know
> if I can use them elsewhere in the code. The Global statement
> sends them outside the scope of the function this code is in,
> or does it? And I'm not even sure I am on the right track.
> Perhaps someone can say yay or nay on the spot, if not
> I can go back and do some experimenting.
> Thanks in advance
> Jeff K

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-11-25 22:19:05 -0800:
> Hello;
> I am writing some code that will format results of a search for display.
> I need to split an array into several different arrays but I won't know
> before hand how many, so, I am looking for a way to dynamically
> generate arrays for this purpose.
> My present direction is to use the following code:
> 
> for($i = 0; $i < $c; $i++)
>     { eval('$a_'.$i.' = array();'); }

what's wrong with:

for($i = 0; $i < $c; $i++)
    { $a[$i] = array(); }

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
jekillen wrote:
I am writing some code that will format results of a search for display.
I need to split an array into several different arrays but I won't know
before hand how many, so, I am looking for a way to dynamically
generate arrays for this purpose.
My present direction is to use the following code:

for($i = 0; $i < $c; $i++)
    { eval('$a_'.$i.' = array();'); }

Where '$c' is the derived number of arrays need to hold the
pieces of the bigger array. My confusion, though, is; since
these are created in the scope of the for loop, I don't know
if I can use them elsewhere in the code. The Global statement
sends them outside the scope of the function this code is in,
or does it? And I'm not even sure I am on the right track.
Perhaps someone can say yay or nay on the spot, if not
I can go back and do some experimenting.

I'm not sure why you think you need to do this. In PHP you do not need to 'declare' variables, you can just use them. So unless you're checking for the existance of these arrays after this loop, the loop is completely pointless. But you haven't included enough information about how you intend to use these arrays to give a definite answer.

As far as scope goes, if you want to create these variables in the global scope, create them as elements of the $GLOBALS array [http://php.net/manual/en/reserved.variables.php#reserved.variables.globals].

-Stut

--- End Message ---
--- Begin Message ---
On Sun, November 26, 2006 12:19 am, jekillen wrote:
> I am writing some code that will format results of a search for
> display.
> I need to split an array into several different arrays but I won't
> know
> before hand how many, so, I am looking for a way to dynamically
> generate arrays for this purpose.
> My present direction is to use the following code:
>
> for($i = 0; $i < $c; $i++)
>      { eval('$a_'.$i.' = array();'); }
>
> Where '$c' is the derived number of arrays need to hold the
> pieces of the bigger array. My confusion, though, is; since
> these are created in the scope of the for loop, I don't know
> if I can use them elsewhere in the code. The Global statement
> sends them outside the scope of the function this code is in,
> or does it? And I'm not even sure I am on the right track.
> Perhaps someone can say yay or nay on the spot, if not
> I can go back and do some experimenting.

PHP has only 2 places where "scope" changes:
#1 global "script" scope
#2 function [name] () { [scope change] }

Obviously, class properties are also bound to the class...

All of this is moot, however, as you are working WAY to hard to
pre-define the arrays.

PHP is quite happy to have you just do:

$a[7][13] = 42;

And it will define the arrays needed to make it work.

Using 'eval' here is DEFINITELY the right answer to the wrong
question. :-)

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

--- End Message ---
--- Begin Message ---
I'm trying to write a sendmail proxy in PHP: people would connect to
my proxy running on port 25 (via xinetd), and the proxy would connect
to sendmail (tweaked to run on port 26).

Currently, the proxy is 100% transparent, but I plan to tweak it to
intercept sendmail's replies and substitute its own. My ultimate goal
is to implement sender-recipient-based greylisting (not IP-based
greylisting, which can be done without a proxy).

My problem: the proxy works fine when I test it, but seems to cutoff
some clients. I send the clients a "message accepted for delivery"
message and close the connection, but the client thinks it's been
cutoff and tries to deliver the mail again a little later (ironically,
this is the behavior I'll want when I start greylisting, but not
now!). This happens w/ legitimate ISP SMTP clients, not just spammers.

I suspect I'm doing something wrong with buffering or flushing. I made
both STDIN and the socket connection (to port 26, where sendmail's
running for real) nonblocking, since it's hardish to tell which one's
going to "speak" next.

Is there any generic proxy code I could use? An existing PHP sendmail
proxy would be even better.

Note: I realize that using a proxy means that *all* sendmail
connections appear to come from localhost, which is dangerous. Once in
production, my proxy will handle this situation by using xinetd's
REMOTE_HOST environment variable.

--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.

--- End Message ---
--- Begin Message ---
At 11:24 AM -0800 11/25/06, Navid wrote:
Thanks guys. I found out (or he actually revealed to me) what he wants his members to download without their knowledge. I refused to work on his project. I knew it sounded fishy.


Navid:

Way to go -- not everything is worth the money.

Besides, I'm not sure that it's possible anyway. I know that we (via php/js) can download to the user's computer text in the form of a cookie in the background and thus the operation is somewhat hidden from the user. But we can't do anything with the cookie other than detect/read it the next time the user passes by -- and that's only if the user accepts cookies.

I guess one could work out a scheme where you could have a link that appears to be something else but when clicked it downloads a file, virus have been known spread that way. But most/some browsers show you when a download has been started and you have to do something to unpack it -- or at least that's my understanding.

In any event, if someone placed something on my machine without my knowledge, I would be pissed -- that's not a good thing.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hey gang,

I'm getting a negative return value from memory_get_usage() using the following script. My I've got --enable-memory-limit enabled and my memory_limit is set to 100MB (which should more than enough memory).

I suspect that there is a bug in utf8_encode() but I'd like others to test it (on different platforms) before I submit it as a bug.

<?php

for ($i=0; $i < 20000; $i++) {
    echo utf8_encode('This is a test');
}

echo memory_get_usage();

?>


Chris
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
What version of PHP and what OS?

I *think* that there is some jiggery-pokery going on in
memory_get_usage() in PHP 5 and managed memory where it would make
perfect sense to get negative numbers occasionally...

You may also want to log the memory_get_usage inside the loop, and
then graph the memory usage as it goes up/down to get a better idea of
what's going on.

On Sun, November 26, 2006 8:35 am, Chris wrote:
> Hey gang,
>
> I'm getting a negative return value from memory_get_usage() using the
> following script. My I've got --enable-memory-limit enabled  and my
> memory_limit is set to 100MB (which should more than enough memory).
>
> I suspect that there is a bug in utf8_encode() but I'd like others to
> test it (on different platforms) before I submit it as a bug.
>
> <?php
>
> for ($i=0; $i < 20000; $i++) {
>      echo utf8_encode('This is a test');
> }
>
> echo memory_get_usage();
>
> ?>
>
>
> Chris
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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

--- End Message ---
--- Begin Message ---
Whoops,

I'm using PHP 5.2.0 on Mac OS X 10.4.8.

I'll do as you suggest (and learn more about PHP memory usage) to try to see what's going on.

Chris
[EMAIL PROTECTED]



On Nov 26, 2006, at 12:34 PM, Richard Lynch wrote:

What version of PHP and what OS?

I *think* that there is some jiggery-pokery going on in
memory_get_usage() in PHP 5 and managed memory where it would make
perfect sense to get negative numbers occasionally...

You may also want to log the memory_get_usage inside the loop, and
then graph the memory usage as it goes up/down to get a better idea of
what's going on.

On Sun, November 26, 2006 8:35 am, Chris wrote:
Hey gang,

I'm getting a negative return value from memory_get_usage() using the
following script. My I've got --enable-memory-limit enabled  and my
memory_limit is set to 100MB (which should more than enough memory).

I suspect that there is a bug in utf8_encode() but I'd like others to
test it (on different platforms) before I submit it as a bug.

<?php

for ($i=0; $i < 20000; $i++) {
     echo utf8_encode('This is a test');
}

echo memory_get_usage();

?>


Chris
[EMAIL PROTECTED]

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




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



--- End Message ---
--- Begin Message ---
I don't know what environment you are on, because I have been absent from
this list a long while. If you are on a Linux distribution you might be able
to do this via the command line:

yum install php-gd.i386

service httpd restart

That might install GD and then restart the web server.

/Peter



-----Original Message-----
From: sublimenal [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 26, 2006 6:31 AM
To: php-general@lists.php.net
Subject: Re: [PHP] GD, and GD JPEG


Hey you need to ./configure it into your php installation via the command
line

Jeff-153 wrote:
> 
> 
>   Hi there.
> I installed a script but it requires GD and GD JPEG
> 
> I downloaded GD, and GD JPEG
> 
> But how the heck do I install it?
> 
> Thanks guys
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/GD%2C-and-GD-JPEG-tf2705080.html#a7543299
Sent from the PHP - General mailing list archive at Nabble.com.

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

--- End Message ---

Reply via email to