check('class', 'string', 1, 50)) { // see if a default class is specified if (defined('DEFAULT_CLASS')) { $class = DEFAULT_CLASS; } else { // check if its just a type problem if ($parameters->is_error()) { die("Incorrect type for class parameter : " . $parameters->get_last_error_message()); } else { die("Missing class parameter."); } } } else { // everything is fine, put it into a variable $class = $parameters->get('class'); } // debugging code //error_log($parameters->to_string(), 0); /* make sure the class actually exists as a file * note this means strict class to file name mappings * as it should be */ if ((strpos($class, DIR_SEPERATOR) !== FALSE) || !file_exists(".." . DIR_SEPERATOR . "include" . DIR_SEPERATOR . $class . '.class')) { die("Error calling $class."); } /* include the class, note this is where have your include path wrong * or allowing urls to be opened from the web could cause trouble * hence the check above */ require_once("$class.class"); // 1 % chance could be file with no class in it if (!class_exists($class)) { die("Error creating $class."); } // dynamically create the class object $class_object = new $class; require_once("Type.class"); $type = new Type(); /* as long as we have an object, we are ready to hand off reponsibility * to the requested class */ if ($type->check($class_object, 'object')) { // send parameters to its 'main' function // get the output back, one might ask why I don't inst $result = $class_object->main($parameters); // if we have a string back, print out the returned code if ($type->check($result, 'string', 1)) { print ($result); } else { die($type->get_last_error_message()); } } else { die("Faulty class instantion."); } ?>