3 # Copyright (C) 2005 Jason Woofenden
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This function makes it easier to put everything in functions like you should.
21 # Instead of putting everything in the global namespace and having it run when
22 # you include the file, put everything in functions. This function makes it so
23 # you can both include (require_once) the file, and call its main function in
28 # list($user, $pass) = file_run('db_password.php');
30 # the file db_password.php would be like so:
32 # function db_password_main() {
33 # return array('me', 'secret');
36 function file_run($filename) {
37 require_once($filename);
38 $func = basename($filename, '.php') . '_main';
40 if(function_exists($func)) {