added generate.php in order to organize code, generate.php is a genreral function class