示例#1
0
                }
            }
            break;
    }
}
// form configuration
$vars =& Variables::getDefaultVariables();
$renderer =& new Horde_Form_Renderer();
$form =& Horde_Form::singleton('NewNWNModule', $vars);
$valid = $form->validate($vars);
if ($valid) {
    // get the information about the file
    $form->getInfo($vars, $info);
    if (!empty($info['module']['file'])) {
        // as long as it was uploaded and there is information
        if (!is_a(Browser::wasFileUploaded('module'), 'PEAR_Error') && filesize($info['module']['file'])) {
            // check the file for validity
            $extension = substr($info['module']['name'], -3);
            if ($extension == "mod" || $extension == "MOD") {
                $moduleOutputName = escapeshellcmd($moduleDir . $info['module']['name']);
                // do not overwrite files
                if (file_exists($moduleOutputName)) {
                    $notification->push(_("Cannot overwrite existing module!"), 'horde.error');
                } else {
                    // get the file data
                    $fp = fopen($info['module']['file'], 'r');
                    $data = fread($fp, filesize($info['module']['file']));
                    fclose($fp);
                    // write the data to the output dir
                    $fp = @fopen($moduleOutputName, 'wb');
                    @fwrite($fp, $data);