Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FuncGenerator is dangerous #149

Open
rubinlinux opened this issue Sep 11, 2024 · 0 comments
Open

FuncGenerator is dangerous #149

rubinlinux opened this issue Sep 11, 2024 · 0 comments

Comments

@rubinlinux
Copy link

Please have a look at the "E()" method of FuncGenerator class.

class FuncGenerator

The code there is immediately alarming and irresponsible. It should be removed from the project. What were they thinking!?

class FuncGenerator {
    private $iFunc='',$iXFunc='',$iMin,$iMax,$iStepSize;

    function __construct($aFunc,$aXFunc='') {
        $this->iFunc = $aFunc;
        $this->iXFunc = $aXFunc;
    }

    function E($aXMin,$aXMax,$aSteps=50) {
        $this->iMin = $aXMin;
        $this->iMax = $aXMax;
        $this->iStepSize = ($aXMax-$aXMin)/$aSteps;

        if( $this->iXFunc != '' )
        $t = 'for($i='.$aXMin.'; $i<='.$aXMax.'; $i += '.$this->iStepSize.') {$ya[]='.$this->iFunc.';$xa[]='.$this->iXFunc.';}';
        elseif( $this->iFunc != '' )
        $t = 'for($x='.$aXMin.'; $x<='.$aXMax.'; $x += '.$this->iStepSize.') {$ya[]='.$this->iFunc.';$xa[]=$x;} $x='.$aXMax.';$ya[]='.$this->iFunc.';$xa[]=$x;';
        else
        JpGraphError::RaiseL(24001);//('FuncGenerator : No function specified. ');

        @eval($t);

        // If there is an error in the function specifcation this is the only
        // way we can discover that.
        if( empty($xa) || empty($ya) )
        JpGraphError::RaiseL(24002);//('FuncGenerator : Syntax error in function specification ');

        return array($xa,$ya);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant