php
/**
Generate an associative array with form action as key
*/
$actions = array(
'event_edit' => array(
'object' => 'Calendar',
'method' => 'processForm',
'header' => 'Location:../../'
),
'user_login' => array(
'object' => 'Admin',
'method' = > 'processLoginForm',
'header' => 'Location:../../'
)
);
/**
Ensure that the anti-cross-site mark in the session is consistent with the submitted mark and the requested action is legal
*/
if ( $_POST['token']==$ _SESSION['token'] &&
isset($actions[$_POST['action']]) ) {
$use_array = $actions[$_POST['action']];
$obj = new $use_array'object' ;
<code>if ( true == $msg=$obj->$use_array['method']() ) { header($use_array['header']); exit;} else { die( $msg );}</code>
} else {
//If the token/action is illegal, redirect to the homepage
header("Location:../../");
exit;
}
function __autoload($class) {
<code>$filename = "../../../sys/class/class.".$class.".inc.php";if ( file_exists($filename) ) { include_once $filename;}</code>
}
The main problem is this: $obj->$use_array'method'
As soon as you get to this step, Function name must be a string in E:qampphtdocsSource Filespublicassetsincprocess.inc.php:40 Stack trace : #0 {main} thrown in E:qampphtdocsSource Filespublicassetsincprocess.inc.php on line 40 error.
If you use $obj to directly call the processForm() or processLoginForm() method in this class, you can.
Ask God for help.
http://blog.sina.com.cn/s/blog_8d7518cb0100zk1t.html