php-general Digest 11 Jun 2005 12:19:16 -0000 Issue 3506

Topics (messages 216834 through 216845):

Re: Passing a function & arguments to a function
        216834 by: Jochem Maas

Re: Problems escaping apostrophe, please help
        216835 by: Tom Rogers
        216836 by: Tom Rogers
        216837 by: Leila Lappin

Re: VBScript to PHP
        216838 by: Richard Lynch

Re: reverse MD5 ???
        216839 by: Richard Lynch

Re: failed to open stream error
        216840 by: Richard Lynch

Re: Oracle Interface
        216841 by: Richard Lynch

Re: PHP exec function.
        216842 by: Richard Lynch

Re: [? BUG ?] weird thing; downloading from a php script stops at exactly 
2.000.000 bytes
        216843 by: Richard Lynch
        216844 by: Catalin Trifu

Returned mail: Data format error
        216845 by: Mail Administrator

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 ---
David Johnson wrote:
I am trying to pass a function as an argument to another function, and
then run the first function from within the second function.

Example:

    function function0($arg0, $arg1, $arg2) {

        function2();

    }

> function3();
        do_function($arg5);
        function4();

    }


    function1(5, 100, function0($arg0, $arg1, $arg2));

<?

function func0($arg0, $arg1, $arg2) { /* do stuff */ }

function func1($arg1, $callback, $callbackArgs = /*order!*/array())
{
        func3();
        func4();
        
        if (is_callable($callback)) {
                $retval = call_user_func_array($callback, $callbackArgs);
        }
}

func1(5, 'func0', array($arg0, $arg1, $arg2));

?>

the 'func0' in :

func1(5, 'func0', array($arg0, $arg1, $arg2));

could be something like:

array('ClassName', 'MethodName')
array($YourObject, 'MethodName')



In the above example, I am running function1(), which includes
function0 as an argument.

I am trying to pass "function0($arg0, $arg1, $arg2)" as an argument to
function1, which will then execute the passed function, including its
passed arguments.

I have had mild success by splitting "function0($arg0, $arg1, $arg2)"
into 2 parts of "function0" and "$arg0, $arg1, $arg2", and then
passing both parts as an argument, such as $arg5 & $arg6, and then
doing this:

    function function1($arg3, $arg4, $arg5) {

            $args_array = explode(", ",$arg6);
            $arg5($args_array[0],$args_array[1],$args_array[2]);

        }

However, this causes all of my arguments in the array to be evaluated
as strings and not resources, which they may be.

Also, I don't really like this method, and would prefer a much
"cleaner" way of doing things.


--- End Message ---
--- Begin Message ---
Hi,

Friday, June 10, 2005, 12:05:48 AM, you wrote:
LL> Hello all,

LL> I hope this hasn’t been answered a zillion times already, I've tried
LL> everything I know and nothing has worked. The following is the PHP statement
LL> and the HTML rendering.  The apostrophe is displayed as is and breaks the
LL> browser.  May be I am wrong but I was under the impression that escaping
LL> special characters with one of the these, htmlspecialchars, htmlentities,
LL> and addslashes would replace them with encoded (hex?) value so they wont
LL> break the browser. But it hasn’t worked that way.  I am using
LL> charset=iso-8859-1.  This is my PHP:

LL> === This is the PHP ===
LL> <li>
LL>     <a href="#"
LL> onclick='document.form1.how.value="<?=htmlentities($row['how'])?>";
LL> document.form1.factor.value="<?=addslashes($row['factor'])?>";document.form1
..submit();'>><?= addslashes($row['factor'])?>
LL>       </a>
LL> </li>

LL> ====== This is the rendering =======
LL> ====== (note the heart's apostrophe breaks IE and firefox) ===
LL> <li>
LL>      <a href="#" onclick='document.form1.how.value="Pulmonary edema is a
LL> condition in which fluid accumulates in the lungs, usually because the
LL> heart's left ventricle does not pump adequately. In cases of severe
LL> pulmonary edema, the symptoms will worsen and include A drop in blood
LL> pressure resulting in a thready pulse.";
LL> document.form1.factor.value="Pulmonary
LL> edema";document.form1.submit();'>Pulmonary edema
LL>     </a>
LL> </li>

What I do to overcome this is in PHP do:

$content = rawurlencode($content);

and in the html javascript:

unescape("$content");

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
Hi,

TR> What I do to overcome this is in PHP do:

TR> $content = rawurlencode($content);

TR> and in the html javascript:

TR> unescape("$content");


I didn't do that very well, your code would look something like:

<li>
  <a href="#" 
    onclick='document.form1.how.value=unescape("<?php 
rawurlencode($row['how'])?>");
    document.form1.factor.value=unescape("<?php 
rawurlencode($row['factor']))?>");
    document.form1.submit();'><?php htmlentities($row['factor'])?>
  </a>
</li>




-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
Hi,

I solved the problem by using htmlspecialchars and passing it ENT_QUOTES.
But I'll try your way as a more general way too.  Thanks


-----Original Message-----
From: Tom Rogers [mailto:[EMAIL PROTECTED]
Sent: Friday, June 10, 2005 8:36 PM
To: php-general@lists.php.net
Cc: Leila Lappin
Subject: Re[2]: [PHP] Problems escaping apostrophe, please help


Hi,

TR> What I do to overcome this is in PHP do:

TR> $content = rawurlencode($content);

TR> and in the html javascript:

TR> unescape("$content");


I didn't do that very well, your code would look something like:

<li>
  <a href="#"
    onclick='document.form1.how.value=unescape("<?php
rawurlencode($row['how'])?>");
    document.form1.factor.value=unescape("<?php
rawurlencode($row['factor']))?>");
    document.form1.submit();'><?php htmlentities($row['factor'])?>
  </a>
</li>




--
regards,
Tom

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

--- End Message ---
--- Begin Message ---
On Fri, June 10, 2005 3:26 pm, Rory Browne said:
> asp2php - I'm not sure how effective it is though.

If you wrote it using all those goofy Microsoft tools that auto-generate
about 5 X as much code as necessary, it's quite good at converting those.

If you hand-wrote your ASP because you're a Real Programmer trapped in
hell, then it's not gonna do very good, at least in my limited experience,
way back in time.

Won't take long to try it though, and see.

Don't expect it to work 100% right off the bat, though, no matter what the
code is like.

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

--- End Message ---
--- Begin Message ---
On Fri, June 10, 2005 3:01 pm, Jason Barnett said:
> That is incredibly interesting stuff, many thanks for that link!  So the
> position seems to be that it may not be feasible to reverse MD5, but it
> is now feasible to create forged documents / binaries / whatever that
> result in exactly the same MD5 hash as the original.

No.

> I actually tried it out for myself... and indeed the two different
> documents produced the exact same MD5 sum.

That's a one in a billion chance...

So, if your binary file HAPPENS to match that meaningless string, you
could use that OTHER meaningless string instead...

I'll bet neither of the two strings has any real-world "meaning"

They just happen to be the two strings that are "easy" to find that have
the same MD5.

This has absolutely NO meaning in real-world uses of MD5.

You'd have heard a LOT more screaming and wailing and gnashing of teeth if
this mattered. :-)

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

--- End Message ---
--- Begin Message ---
On Fri, June 10, 2005 2:19 pm, Richard Kurth said:
> Hello Duncan,
>
> Friday, June 10, 2005, 12:01:33 AM, you wrote:
>
> DH> On Friday 10 June 2005 06:31, Richard Kurth typed:
>>>  Way do I get
>>>  Warning:
>>> fopen(https://esos.state.nv.us/SOSServices/AnonymousAccess/CorpSearch/CorpD
>>>etails.aspx?CorpID=478765): failed to open stream: Invalid argument
>>>  When I run this. I can access the page from the browser but not from
>>>  inside of a script
>
> DH> Is your installation of PHP configured to allow URLs in fopen calls?
>
> Yes it is set to on in php.ini file. I can make it grab files from
> other web sites just not with this one. What else can I look at to try
> and make it work

fopen and friends, last time I checked, did not have all the SSL
key-exchange stuff built-in.

Use cURL or use a URL without the 's' on the http part.

http://php.net/curl

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

--- End Message ---
--- Begin Message ---
On Fri, June 10, 2005 8:48 am, Shane Presley said:
> Where can I find some info on integrating Oracle and PHP?

http://php.net/oracle

pretty much covers it.

> I had some PHP front ends to a MySQL database, worked great.  Our DBAs
> want to change the back end from MySQL to Oracle 10g.  How hard would
> it be to convert my PHP scripts, and where would I go to read up on
> Oracle <--> PHP?

It's mostly a global search and replace to change out your mysql_query()
to, err, oracle_exec() or whatever it is...

Unless you used MySQL-specific SQL syntax and features.

Your biggest hurdle will probably be getting a database connection :-)

Do that first, in a simple example script, comletely outside the scope of
your project.  The hair you save, may be your own.

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

--- End Message ---
--- Begin Message ---
On Fri, June 10, 2005 3:04 am, Bob Snowdon said:
> ....
> $execstring="winposd.exe \"${physical}-${logical}-${parameter}\"";
> $output=exec($execstring);
> ....

exec only returns the FIRST LINE of output -- perhaps winposd (whatever
that is) prints a blank line first?

For that matter, winposd might output to standard error...

Does Windows have that???

If it does, how do you redirect?...

It *MIGHT* be the same as some shells in Linux:

$execstring="winposd.exe \"${physical}-${logical}-${parameter}\" 2&>1";

Or, it might not...

At any rate, USE the extra arguments to exec to get, like, *ALL* the
output, *PLUS* a super special bonus ERROR CODE returned from the
Operating System.

exec($execstring, $output, $error);
if ($error){
  echo "OS Error: $error\n";
  echo implode("\n", $output);
  exit;
}
echo implode("\n", $output);

To bastardize a quote:

If you ignore the errors of the present, you won't even have the
opportunity to repeat them. :-)

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

--- End Message ---
--- Begin Message ---
On Thu, June 9, 2005 4:12 pm, Catalin Trifu said:
>   Tried it and it works indeed, but it's quite annoying to make such
> tricks
> and is not the best solution either; fopen and fread are "expensive".
>    I can't say if it's a bug in PHP or some config option.

You may want to benchmark the difference between readfile and fopen/fread
for a 1.9M file.

If it ain't much, don't worry about it.

One posible work-around:

`cat filename`;

This MIGHT be cheaper than fopen/fread -- Or not, since it has to build a
shell of some kind, I think.

PS File a bug report, if you haven't already.

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

--- End Message ---
--- Begin Message ---
        Hi,

    There is not a big speed difference between the two.
The only thing is that it was frustrating to find out the limitations
on readfile.
    I used it before with large files and it was ok; only to find out now
that on 5.0.4 it doesn't work as it used to.
    As php manual states readfile should be the way to spit a file out
the wire.
    btw:
    $fp = fopen('somefile');
    fpassthru($fp);
    is also stopping at 2.000.000 bytes, which definetely drives me
to think there is a bug somewhere.


Catalin


Richard Lynch wrote:
> On Thu, June 9, 2005 4:12 pm, Catalin Trifu said:
> 
>>  Tried it and it works indeed, but it's quite annoying to make such
>>tricks
>>and is not the best solution either; fopen and fread are "expensive".
>>   I can't say if it's a bug in PHP or some config option.
> 
> 
> You may want to benchmark the difference between readfile and fopen/fread
> for a 1.9M file.
> 
> If it ain't much, don't worry about it.
> 
> One posible work-around:
> 
> `cat filename`;
> 
> This MIGHT be cheaper than fopen/fread -- Or not, since it has to build a
> shell of some kind, I think.
> 
> PS File a bug report, if you haven't already.
> 

--- End Message ---
--- Begin Message ---
ALERT!

This e-mail, in its original form, contained one or more attached files that 
were infected with a virus, worm, or other type of security threat. This e-mail 
was sent from a Road Runner IP address. As part of our continuing initiative to 
stop the spread of malicious viruses, Road Runner scans all outbound e-mail 
attachments. If a virus, worm, or other security threat is found, Road Runner 
cleans or deletes the infected attachments as necessary, but continues to send 
the original message content to the recipient. Further information on this 
initiative can be found at http://help.rr.com/faqs/e_mgsp.html.
Please be advised that Road Runner does not contact the original sender of the 
e-mail as part of the scanning process. Road Runner recommends that if the 
sender is known to you, you contact them directly and advise them of their 
issue. If you do not know the sender, we advise you to forward this message in 
its entirety (including full headers) to the Road Runner Abuse Department, at 
[EMAIL PROTECTED]



file attachment: Text.cmd

This e-mail in its original form contained one or more attached files that were 
infected with the [EMAIL PROTECTED] virus or worm. They have been removed.
For more information on Road Runner's virus filtering initiative, visit our 
Help & Member Services pages at http://help.rr.com, or the virus filtering 
information page directly at http://help.rr.com/faqs/e_mgsp.html. 

--- End Message ---

Reply via email to