toolbox-v100

Gesponsorde koppelingen

PHP script bestanden

  1. toolbox-v100

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/* ******************************************************************
 * Main: API
 * ****************************************************************** */

// get a new instance

$page = new THF_Admin_Tool_ToolBox(); // See at the bottom.

// Read all the data from the tools

$page->readAllIniFiles();

// Echo the heading of the webpage.
echo $page->htmlHeading();

// Dit we select a valid tool or nothing at all?
$tool = $page->readUri();

// Switch for the content depending on the $tool variable
if( NULL === $tool )
{

    // startpage
    echo $page->htmlToolTable();
}

elseif( FALSE === $tool )
{

    // Impossible or bad people?
    echo '<br /><h3 style="color:red">Invalid tool request.</h3><br />';
    echo $page->htmlToolTable();
}

else
{
    // Show the form connected to the tool.
    $page->invokeTool($tool);
}


echo $page->htmlFooter();



/* ******************************************************************
 *
 * Class for easy handling this tool page.
 *
 * ****************************************************************** */


class THF_Admin_Tool_ToolBox
{
    // Holds all the info about every tool
    private $_about;

    public function __construct()
    {

        $this->_about = array();
    }


    public function readAllIniFiles()
    {

        $this->_about = array();
        $dir = new DirectoryIterator('./');
        foreach( $dir as $subdir )
        {

            if( $subdir->isDir() AND ! $subdir->isDot() )
            {

                $inipath = $subdir->getPathname() . DIRECTORY_SEPARATOR . 'about.ini';
                $content = parse_ini_file($inipath);
                $content = array($subdir->getBasename() => $content);
                $this->_about = array_merge($this->_about, $content);
            }
        }
    }


    public function htmlToolTable()
    {

        $html  = '<table border="1" cellpadding="5">';
        $html .= '<tr><th align="left">tool</th><th align="left">description</th></tr>';
        foreach( $this->_about as $tool => $data )
        {

            $html .= '<tr><td align="left"><a href="?tool='.$tool.'">'.$data['name'].'</a><br />'.$data['version'].'</td><td align="left" style="vertical-align:text-top">'.$data['description'].'</td></tr>';
        }

        $html .= '</table>';
        return $html;
    }


    public function invokeTool($tool)
    {

        $path = './'.$tool.'/form.php';
        include $path;
    }


    public function readUri()
    {

        if( ! isset($_REQUEST['tool']) )
                return NULL;

        $tool = $_REQUEST['tool'];
        if( ! array_key_exists($tool, $this->_about) )
                return FALSE;

        return $tool;
    }


    public function htmlHeading()
    {

        $out  = '<h1>Toolbox</h1>';
        $out .= '<a href="?">hoofdmenu toolbox</a>';
        $out .= '<hr /><br />';
        return $out;
    }


    public function htmlFooter()
    {

        $out  = '<br /><hr />';
        $out .= '<a href="?">hoofdmenu toolbox</a>';
        $out .= '&nbsp;&nbsp;&nbsp;&nbsp;<span>'.date('d M Y').'</span>';
        return $out;
    }

}

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.