#27 PHP wrapper --- Large number can cause flash app crash

version-1
open
nobody
None
5
2008-06-11
2008-04-13
Anonymous
No

Each number (e.g. y_max) you pass to flash must be formated in form xxx.xx otherwise the flash crashes. Consider PHP code:

$g = new graph();
$g->set_y_max(40000000);
...
echo $g->render();

This can produce such a configuration file:

...
&y_max=4.0E7&
...

and application crashes. So numbers should be written to the configuration file not just by echo floatval($x), but by sprintf() or number_format().

Workaround:
Don't use object's methods set_xxx (does buggy number reformating), use properties instead. Expample:
$x = 40000000;
$g->y_max = sprintf('%f', $x); // Instead of $g->set_y_max($x);

Cheers
Vali

Discussion

  • John Vandervort

    John Vandervort - 2008-06-11
    • milestone: --> version-1
     
  • Placid Development

    Logged In: YES
    user_id=1129716
    Originator: NO

    Change the format_output() function in 'ofc-library/open-flash-chart.php' and use the below function instead. This will fix the problem.

    /**
    * Format the text to the type of output.
    */
    function format_output($function,$values)
    {
    if($this->output_type == 'js')
    {
    $tmp = 'so.addVariable("'. $function .'","'. $values . '");';
    }
    else
    {
    switch (gettype($values))
    {
    case 'integer':
    $tmp = sprintf("&%s=%d&", $function, $values);
    break;
    case 'double':
    $tmp = sprintf("&%s=%f&", $function, $values);
    break;
    default:
    $tmp = '&'. $function .'='. $values .'&';
    }
    }

    return $tmp;
    }

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks