Example #1
0
/**
 *
 */
function show_upload_filetypes()
{
    $ns = e107::getRender();
    $e_userclass = e107::getUserClass();
    if (!getperms("0")) {
        exit;
    }
    //TODO still needed?
    $definition_source = DOWLAN_71;
    $source_file = '';
    $edit_upload_list = varset($_POST['upload_do_edit'], false);
    if (isset($_POST['generate_filetypes_xml'])) {
        // Write back edited data to filetypes_.xml
        $file_text = "<e107Filetypes>\n";
        foreach ($_POST['file_class_select'] as $k => $c) {
            if (!isset($_POST['file_line_delete_' . $c]) && vartrue($_POST['file_type_list'][$k])) {
                $file_text .= "   <class name='{$c}' type='{$_POST['file_type_list'][$k]}' maxupload='" . vartrue($_POST['file_maxupload'][$k], ini_get('upload_max_filesize')) . "'/>\n";
            }
        }
        $file_text .= "</e107Filetypes>";
        if (($handle = fopen(e_UPLOAD_TEMP_DIR . e_SAVE_FILETYPES, 'wt')) == FALSE || fwrite($handle, $file_text) == FALSE || fclose($handle) == FALSE) {
            $text = DOWLAN_88 . e_UPLOAD_TEMP_DIR . e_SAVE_FILETYPES;
        } else {
            $text = DOWLAN_86 . e_UPLOAD_TEMP_DIR . e_SAVE_FILETYPES . '<br/>' . DOWLAN_87 . e_ADMIN . e_READ_FILETYPES . '<br/>';
        }
        $ns->tablerender(DOWLAN_49, $text);
    }
    $current_perms = array();
    if ($edit_upload_list && is_readable(e_UPLOAD_TEMP_DIR . e_SAVE_FILETYPES) || !$edit_upload_list && is_readable(e_ADMIN . e_READ_FILETYPES)) {
        require_once e_HANDLER . 'xml_class.php';
        $xml = new xmlClass();
        $xml->setOptArrayTags('class');
        $source_file = $edit_upload_list ? e_UPLOAD_TEMP_DIR . e_SAVE_FILETYPES : e_ADMIN . e_READ_FILETYPES;
        $temp_vars = $xml->loadXMLfile($source_file, true, false);
        if ($temp_vars === FALSE) {
            echo "Error parsing XML file!";
        } else {
            foreach ($temp_vars['class'] as $v1) {
                $v = $v1['@attributes'];
                $current_perms[$v['name']] = array('type' => $v['type'], 'maxupload' => $v['maxupload']);
            }
        }
    } elseif (is_readable(e_ADMIN . 'filetypes.php')) {
        $source_file = 'filetypes.php';
        $current_perms[e_UC_MEMBER] = array('type' => implode(',', array_keys(get_allowed_filetypes('filetypes.php', ''))), 'maxupload' => '2M');
        if (is_readable(e_ADMIN . 'admin_filetypes.php')) {
            $current_perms[e_UC_ADMIN] = array('type' => implode(',', array_keys(get_allowed_filetypes('admin_filetypes.php', ''))), 'maxupload' => '2M');
            $source_file .= ' + admin_filetypes.php';
        }
    } else {
        // Set a default
        $current_perms[e_UC_MEMBER] = array('type' => 'zip,tar,gz,jpg,png', 'maxupload' => '2M');
    }
    $frm = new e_form(true);
    //enable inner tabindex counter
    $columnInfo = array("ftypes_userclass" => array("title" => DOWLAN_73, "type" => "", "width" => "auto", "thclass" => "", "forced" => true), "ftypes_extension" => array("title" => DOWLAN_74, "type" => "", "width" => "auto", "thclass" => ""), "ftypes_max_size" => array("title" => DOWLAN_75, "type" => "", "width" => "auto", "thclass" => ""), "ftypes_confirm_del" => array("title" => DOWLAN_76, "type" => "", "width" => "auto", "thclass" => "last"));
    $filterColumns = array("ftypes_userclass", "ftypes_extension", "ftypes_max_size", "ftypes_confirm_del");
    $text = "\n         <form method='post' action='" . e_SELF . "?filetypes'>\n            <fieldset id='core-download-upload1'>\n               <div>\n                  <div>\n                     <input type='hidden' name='upload_do_edit' value='1'/><p>" . str_replace(array('--SOURCE--', '--DEST--'), array(e_UPLOAD_TEMP_DIR . e_SAVE_FILETYPES, e_ADMIN . e_READ_FILETYPES), DOWLAN_85) . "</p><p>" . DOWLAN_72 . $source_file . "\n                  </p></div>\n                  <table class='table adminform'>" . $frm->colGroup($columnInfo) . $frm->thead($columnInfo, $filterColumns) . "\n                     <tbody>\n      ";
    foreach ($current_perms as $uclass => $uinfo) {
        $text .= "\n            <tr>\n               <td>\n                  <select name='file_class_select[]' class='tbox'>\n                     " . $e_userclass->vetted_tree('file_class_select', array($e_userclass, 'select'), $uclass, 'member,main,classes,admin, no-excludes') . "\n                  </select>\n               </td>\n               <td><input type='text' name='file_type_list[]' value='{$uinfo['type']}' class='tbox' size='40'/></td>\n               <td><input type='text' name='file_maxupload[]' value='{$uinfo['maxupload']}' class='tbox' size='10'/></td>\n               <td><input type='checkbox' value='1' name='file_line_delete_{$uclass}'/></td>\n            </tr>\n         ";
    }
    // Now put up a box to add a new setting
    $text .= "\n                        <tr>\n                           <td colspan='" . count($columnInfo) . "'>" . DOWLAN_90 . "</td>\n                        </tr>\n                        <tr>\n                           <td><select name='file_class_select[]' class='tbox'>\n                           " . $e_userclass->vetted_tree('file_class_select', array($e_userclass, 'select'), '', 'member,main,classes,admin,blank, no-excludes') . "\n                           </select></td>\n                           <td><input type='text' name='file_type_list[]' value='' class='tbox' size='40'/></td>\n                           <td colspan='2'><input type='text' name='file_maxupload[]' value='" . ini_get('upload_max_filesize') . "' class='tbox' size='10'/></td>\n                        </tr>\n                     </tbody>\n                  </table>\n               </div>\n            </fieldset>\n            <div class='buttons-bar center'>\n               <input class='btn btn-default button' type='submit' name='generate_filetypes_xml' value='" . DOWLAN_77 . "'/>\n               </div>\n        \t\t</form>\n      ";
    $ns->tablerender(DOWLAN_23, $text);
}
Example #2
0
function poll_list()
{
    $sql = e107::getDb();
    $ns = e107::getRender();
    $tp = e107::getParser();
    $frm = new e_form(true);
    global $user_pref;
    if (isset($_POST['etrigger_ecolumns'])) {
        $user_pref['admin_poll_columns'] = $_POST['e-columns'];
        save_prefs('user');
    }
    $fieldpref = varset($user_pref['admin_poll_columns']) ? $user_pref['admin_poll_columns'] : array("poll_id", "poll_title", "poll_options", "poll_vote_userclass");
    //TODO Add more column options.
    $fields = array('poll_id' => array('title' => ID, 'width' => '5%', 'forced' => TRUE), 'poll_title' => array('title' => POLLAN_3, 'width' => 'auto'), 'poll_options' => array('title' => POLLAN_4, 'type' => 'text', 'width' => 'auto', 'thclass' => 'center'), 'poll_vote_userclass' => array('title' => LAN_USERCLASS, 'type' => 'text', 'width' => 'auto'), 'options' => array('title' => LAN_OPTIONS, 'forced' => TRUE, 'width' => '10%', 'thclass' => 'center last'));
    $text = "<div style='text-align:center'><div>\n\t\t<form action='" . e_SELF . "' method='post' id='del_poll'>";
    if ($poll_total = $sql->db_Select("polls", "*", "poll_type=1")) {
        $text .= "<table class='table adminlist'>";
        $text .= $frm->colGroup($fields, $fieldpref) . $frm->thead($fields, $fieldpref);
        $text .= "<tbody>";
        while ($row = $sql->db_Fetch()) {
            extract($row);
            $text .= "<tr>\n\t\t\t\t<td>{$poll_id}</td>";
            $text .= in_array("poll_title", $fieldpref) ? "<td class='left'>" . $tp->toHTML($poll_title, TRUE, "no_hook, emotes_off, defs") . "</td>" : "";
            $text .= in_array("poll_options", $fieldpref) ? "<td class='left'>" . str_replace(chr(1), "<br />", $poll_options) . "</td>" : "";
            $text .= in_array("poll_comment", $fieldpref) ? "<td>" . ($poll_comment ? LAN_YES : LAN_NO) . "</td>" : "";
            $text .= in_array("poll_vote_userclass", $fieldpref) ? "<td>" . r_userclass_name($poll_vote_userclass) . "</td>" : "";
            $text .= "\n\t\t\t\t<td class='center'>\n\t\t\t\t\t<input type='image' name='edit[{$poll_id}]' value='edit' src='" . ADMIN_EDIT_ICON_PATH . "' alt='" . LAN_EDIT . "' title='" . LAN_EDIT . "' style='border:0px' />\n\t\t\t\t\t<input type='image' name='delete[{$poll_id}]' value='del' onclick=\"return jsconfirm('" . $tp->toJS(LAN_CONFIRMDEL . " [" . $poll_id . "]") . "') \" src='" . ADMIN_DELETE_ICON_PATH . "' alt='" . LAN_DELETE . "' title='" . LAN_DELETE . "' style='border:0px' />\n\t\t\t\t</td>\n\t\t\t\t</tr>";
        }
        $text .= "</tbody></table>";
    } else {
        $text .= "<div style='text-align:center'>" . POLLAN_7 . "</div>";
    }
    $text .= "</form></div></div>";
    $emessage = eMessage::getInstance();
    $ns->tablerender(POLLAN_MENU_CAPTION . " :: " . POLLAN_1, $emessage->render() . $text);
}