JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix enc_ functions for image/thumb parts
[wfpl.git] / file_run.php
1 <?php
2
3 #  Copyright (C) 2005 Jason Woofenden
4 #
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.
9 #  
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.
14 #  
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/>.
17
18
19 # This function makes it easier to put everything in functions like you should.
20 #
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
24 # one easy step.
25
26 # EXAMPLE
27 #
28 # list($user, $pass) = file_run('db_password.php');
29 #
30 # the file db_password.php would be like so:
31 #
32 #     function db_password_main() {
33 #           return array('me', 'secret');
34 #     }
35
36 function file_run($filename /* args... */) {
37         $args = array_slice(func_get_args(), 1);
38         require_once($filename);
39         $func = basename($filename, '.php') . '_main';
40
41         if(function_exists($func)) {
42                 return call_user_func_array($func, $args);
43         }
44 }
45
46 ?>