PHP eval error when assigning value to variable -


My CMS (modules are not meant for convenience) which allows people to view pages, comments, forum posts, blog posts, etc ...):

  if (isset $ _GET ["m"])) {// Is the module present and active, and is this a function called the view? If (isset ($ modules_exists [$ _ GET ["m"]]) & amp; amp; amp; method_exists ($ _GET ["m"], "see")) / / yop {// load view (Should be an array) eval ("$ modules_view =". $ _ Get ["m"]. :: :: view (); "); if (! Is_array ($ module_view)) // is not an array :( {error :: e500module ($ _gET ["m"], $ _SERVER ["REQUEST_URI"]);}} else // If not, display error {Now I get these errors when parsing the page:  
  notice: undefined variable: c: \ wamp \ www \ system \ start.php in module_view parse error on line 34 : Parse error C: \ wamp \ www \ system \ start.php (34): eval () line '1 code on notice: undefined variable: in module_view C: \ wamp \ www \ system \ start.php on line 35   ");  

instead of:

  eval (" $ Module_view = ". $ _ GET [" m "]. :: :: view ); ");  

I have not found any errors, but only the array is printed.

You should never make eval of any kind here is the right way to do this:

  $ class = $ _GET [" Me "]; $ Modules_view = $ square :: view ();  

But here too, you should have an array and check that $ square is an authorized module before executing any code, because it does not trust user input and user input Can be done:

  $ class = $ _GET ["me"]; If (! In_array ($ square, $ authorized_modules)) {header ("HTTP / 1.1 404 not found"); // Always 404 is good to send in these cases, so search engine URL will not die ("Content not found"); } $ Module_view = $ class :: view ();  

Just you know, your error is because you have to save your variable eval:

  eval ("\ $ module_view =". $ _GET [ "M"] ":: visible ();".); It is evaluated before  

or after eval () is given in the form of a string.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -