php-general Digest 3 Nov 2010 11:02:34 -0000 Issue 7019

Topics (messages 309256 through 309266):

Re: Mail delivery failed: returning message to sender
        309256 by: Tamara Temple

Re: updating sub-request parameters
        309257 by: admin.buskirkgraphics.com

PHP for Android
        309258 by: Daevid Vincent
        309259 by: Daniel P. Brown
        309260 by: Daniel P. Brown

Re: include html
        309261 by: Nathan Nobbe

include() and duplicate function definition
        309262 by: David Nelson
        309263 by: Thijs Lensselink
        309264 by: David Nelson
        309265 by: Peter Lind
        309266 by: David Nelson

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:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---

On Nov 1, 2010, at 7:43 AM, Daniel P. Brown wrote:

On Sun, Oct 31, 2010 at 21:06, Tamara Temple <[email protected]> wrote:
Is this something I need to worry about?? Is my mail sending some malware??

   No, you're safe in this case.

<[email protected]>
  (reason: 550 This message contains malware
(winnow.malware.wa.webinjection.1450.UNOFFICIAL))

   Sascha's server's scanner (say that three times fast) is having a
fit over this:

this. (See your code at http://pastie.org/1262989).

   A version of ClamAV released during the spring of this year
erroneously catches all URLs from pastie.org as malware.


Ah, that does explain it, thanks.


--- End Message ---
--- Begin Message ---
So let me get this straight.
Your script.php has all the passed variable positions of $_GET?
Once it has passed you want to change the value?

You can change the value of a $_GET very easy.


If(isset($_GET['param1']))
{
$_GET['param1'] == "no Chew";
}

By changing the global value or using filters on the global values of $_GET.



I have created a similar script only to mess with the $_GET variables.

If(isset($_GET['param1']))
{
        $_GET['param1'] = mysql_real_escape_string($_GET['param1']);

        // you can create $_GET variables like so.
        $_GET['moo_cow'] = mysql_real_escape_string($_GET['param1']);
        
        
}

I hope I have answered your question.



Richard L. Buskirk


-----Original Message-----
From: Daniela Floroiu [mailto:[email protected]] 
Sent: Monday, November 01, 2010 10:21 AM
To: [email protected]
Subject: [PHP] updating sub-request parameters

hi,

I need to make an apache sub-request like:

    virtual('.../script.php?param1=val1&param2=val2...');

where the parameters are different from the parameters of the original
request.
I tried to set param1 and param2 in $_GET, $_REQUEST,
$_SERVER['QUERY_STRING'] but without success: what script.php receives are
nothing less and nothing more than the original parameters with the original
values.

any ideea how one could touch the parameters being passed to a sub-request?

cheers,
--df


--- End Message ---
--- Begin Message ---
http://www.slideshare.net/ivmos/phpforandroid-en

--- End Message ---
--- Begin Message ---
On Tue, Nov 2, 2010 at 19:10, Daevid Vincent <[email protected]> wrote:
> http://www.slideshare.net/ivmos/phpforandroid-en

    Yeah, I gave it a shot when it came out.  Didn't work well at all
for me, but I have a feeling that's more to do with the version of
Android that Verizon pushed out.  Our DROIDs became little better than
$300/mo. paperweights.

    Still, the official site is here: http://phpforandroid.net/

    I had hoped to compile my own and distribute it as a precompiled
binary for all DROID (and perhaps other) handsets, but why reinvent
the wheel?  From what I've heard, it works for most who try it.

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--- End Message ---
--- Begin Message ---
On Tue, Nov 2, 2010 at 19:21, Daniel P. Brown <[email protected]> wrote:
>
>    Yeah, I gave it a shot when it came out.  Didn't work well at all
> for me, but I have a feeling that's more to do with the version of
> Android that Verizon pushed out.  Our DROIDs became little better than
> $300/mo. paperweights.

    Incidentally, I just tried it again now and it works as expected.
Could be that another application I had installed was interfering at
the time and has since been removed or killed.  Who knows?

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--- End Message ---
--- Begin Message ---
On Tue, Nov 2, 2010 at 12:50 AM, Karl DeSaulniers <[email protected]>wrote:

>
> On Nov 2, 2010, at 12:37 AM, Nathan Nobbe wrote:
>
>  On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers <[email protected]>
>> wrote:
>> I need to basically grab the source of the page as text. Then I can do a
>> replace() on the <link> tag. Then insert the text into an Iframe. In theory,
>> this I thought would be handled better server side. Is this possible?
>>
>> yes, there are a few options, fopen wrappers, curl or raw sockets all come
>> to mind.  fopen wrappers sound like they may be easiest for you.
>>
>
> Any examples or urls to make a fopen wrapper? Or is there a simple function
> for getting the source text from a URL?
>

yeah,

$page = file_get_contents($url);

if you have the appropriate wrapper installed (http) in this case the html
will appear in $page.  you will also need to have enabled the
allow_url_fopen ini setting.


> I think the problem I'm having is that the domain I'm requesting from is
>> not the same domain as mine so their may be some security issue.
>>
>> right, this is why you would setup a server side proxy, to avoid client
>> side cross domain security restrictions, however you'll have to change all
>> the instances of the remote domain to your domain, and ensure that your
>> server actually is able to fulfill requests for those resources.
>>
>
> Server side proxy.. I have  heard of this, but do not know exactly what a
> proxy does to know if it would be a solution.
> I also have not seen one in action nor made one (that I know of), any
> beginner tuts you can lend?


yeah, all a proxy does is act on behalf of something.  so for example i ask
for a web page directly, the web page returns to me unaltered.  i ask a
proxy for a web page, it may return an older version of the page which has
been cached to boost performance, or perhaps, as in your case, a derivative
of the original page.


> I also thought about injecting a link tag into the iframe at the same time
>> I load the HTML.
>>
>> when you say link tag are you talking about <a> tags?  you lost me on this
>> last line here.
>>
>
> IE:  [code]
> Get the text from their source, something like:
>
> $htmlTextresult = <html>
> <head>
> <link href="css/fromtheirsite.css" rel="stylesheet" type="text/css"
> media="all" />
> </head>
>

o, right i understand now.  yeah, that sounds workable if the domain is the
same as where the page is being served from.


> Or is there a way to strip the text that is in the <head> , <body> and
> <script>  tags?
> I could then insert those into a blank html file?


once you have the html page in memory on your server, you can manipulate the
contents any way you wish before embedding those contents into an iframe.
 essentially the way it will work is you put a url in the iframe which
points to your site.  that page looks up the real page on the other site
then modifies it as need be before returning the page to the browser.


> Browsers load the last style sheet on top of others.
>>
>> this is true, but i doubt you'll be able to have it load a css file from
>> your domain atop a css file from a remote domain.
>>
>
> Well contrary, I think, only because all css tuts I found warned about
> using the "!important" in your css as it would override an external css.
> Imported css has the least priority out of all and their css is imported,
> maybe if I wrote the css as a <style> inline within the text I received from
> the source?
>

yeah, that could work.


> I know that would work as far as my css beating out theirs. And the idea is
> to get the source and replace the text that points to their css (the  <link>
> tag) with mine before its parsed.


i think if you just make sure your server can serve any relative pages from
the remote site and you replace occurrences of the remote domain w/ your
domain you will be fine.


> Hey thanks for your help Nathan. I was starting to think I needed to scrap.
> You have sparked the curiosity again.
>

again dude, no worries, but as i said even though its do-able it will take
some work to get 100%.  also, if the remote site changes it could break your
alterations quite easily unless you have assurances from the remote site
authors about how things will be changing over time, a contract so to speak.

-nathan

--- End Message ---
--- Begin Message ---
Hi, :-)

I'm making a child theme for WordPress. I need to rewrite one function
defined in "../sometheme/functions/actions.php" and put that rewritten
function in "wp-content/themes/sometheme-child/functions/actions.php".

But I want to preserve "../sometheme/functions/actions.php" unchanged
in any way. (Future theme updates would just overwrite any changes I
made.)

So, in my new "actions.php", I put an include followed by the
replacement function definition, named identically to the one I want
to replace:

<?php

include '../sometheme/functions/actions.php';

function foo($arg_1, $arg_2, /* ..., */ $arg_n)
{
    echo "All my new code.\n";
}

?>

Because this duplicate foo() function definition comes after the foo()
defined in the included file, does it replace the included foo()?

Or how can I achieve what I want?

Big thanks in advance for any suggestions. :-)

David

--- End Message ---
--- Begin Message --- On Wed, 3 Nov 2010 17:59:06 +0800, David Nelson <[email protected]> wrote:
Hi, :-)

I'm making a child theme for WordPress. I need to rewrite one function defined in "../sometheme/functions/actions.php" and put that rewritten function in "wp-content/themes/sometheme-child/functions/actions.php".

But I want to preserve "../sometheme/functions/actions.php" unchanged
in any way. (Future theme updates would just overwrite any changes I
made.)

So, in my new "actions.php", I put an include followed by the
replacement function definition, named identically to the one I want
to replace:

<?php

include '../sometheme/functions/actions.php';

function foo($arg_1, $arg_2, /* ..., */ $arg_n)
{
    echo "All my new code.\n";
}

?>

Because this duplicate foo() function definition comes after the foo()
defined in the included file, does it replace the included foo()?

Or how can I achieve what I want?

Big thanks in advance for any suggestions. :-)

David

As far as I know it is not possible to overwrite functions in PHP (unless you use runkit, apd). Inside classes this is possible. But that's not the case here. Why do the functions have to be equally named?

Try to create a new function and call the original function from there if needed...

foo2() {
foo()
}


--- End Message ---
--- Begin Message ---
Hi Thijs, :-)

On Wed, Nov 3, 2010 at 18:18, Thijs Lensselink <[email protected]> wrote:
> As far as I know it is not possible to overwrite functions in PHP (unless
> you use runkit, apd). Inside classes this is possible. But that's not the
> case here. Why do the functions have to be equally named?

If the functions aren't named the same, my replacement function will
never get called by the code that uses the WordPress theme code...

> Try to create a new function and call the original function from there if
> needed...

Sadly, it wouldn't work for the above reason...

But thanks for your answer. :-)

David Nelson

--- End Message ---
--- Begin Message ---
You can check with function_exists to see if a function is already defined.
If not, create it.

Regards
Peter
On Nov 3, 2010 11:40 AM, "David Nelson" <[email protected]> wrote:
> Hi Thijs, :-)
>
> On Wed, Nov 3, 2010 at 18:18, Thijs Lensselink <[email protected]> wrote:
>> As far as I know it is not possible to overwrite functions in PHP (unless
>> you use runkit, apd). Inside classes this is possible. But that's not the
>> case here. Why do the functions have to be equally named?
>
> If the functions aren't named the same, my replacement function will
> never get called by the code that uses the WordPress theme code...
>
>> Try to create a new function and call the original function from there if
>> needed...
>
> Sadly, it wouldn't work for the above reason...
>
> But thanks for your answer. :-)
>
> David Nelson
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Hi Peter, :-)

On Wed, Nov 3, 2010 at 18:44, Peter Lind <[email protected]> wrote:
> You can check with function_exists to see if a function is already defined.
> If not, create it.

The function is definitely already defined, I just need to replace it
without touching the file in which it's defined...

David Nelson

--- End Message ---

Reply via email to