function execute(ActionMapping $map, ActionForm $form, Request $req)
 {
     global $papyrine;
     $papyrine->entries =& $papyrine->getEntries();
     // Instantiate the HTML_QuickForm object
     require_once 'HTML/QuickForm.php';
     require_once 'HTML/QuickForm/group.php';
     $form = new HTML_QuickForm('create_entry');
     $form->addElement('text', 'title', 'Title:');
     $form->addElement('text', 'date', 'Date:');
     $form->addElement('text', 'status', 'Status:');
     // Get the default handler
     $form->addElement('text', 'body', 'Body:');
     $form->addElement('submit', null, 'Create');
     // Define filters and validation rules
     $form->applyFilter('name', 'trim');
     $form->addRule('name', 'Please enter your name', 'required', null, 'client');
     //get classes registered for entry
     //call method
     $plugin = new PapyrinePlugin(BASE . 'plugins/categories/');
     $object = $plugin->getInstance();
     $object->recieveNewEntryForm($form);
     $plugin = new PapyrinePlugin(BASE . 'plugins/comments/');
     $object = $plugin->getInstance();
     $object->recieveNewEntryForm($form);
     // Output the form
     $papyrine->form = $form->toHTML();
     header("Content-Type: application/xhtml+xml;charset=UTF-8");
     $papyrine->display('admin/header.html');
     $papyrine->display($map->getParameter());
     $papyrine->display('admin/footer.html');
 }
예제 #2
0
파일: Kontakt.php 프로젝트: vih/vih.dk
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new HTML_QuickForm('underviser', 'POST', $this->url());
     $form->addElement('text', 'navn', 'Navn');
     $form->addElement('text', 'email', 'E-mail');
     $form->addElement('textarea', 'besked', 'Besked', array('rows' => 12, 'cols' => 30));
     $form->addElement('submit', null, 'Send');
     $form->addRule('navn', 'Du skal indtaste et navn', 'required');
     $form->addRule('email', 'Du skal indtaste en email', 'required');
     $form->addRule('email', 'Du skal indtaste en gyldig email', 'email');
     $form->addRule('besked', 'Du skal indtaste en gyldig besked', 'required');
     $form->applyFilter('__ALL__', 'trim');
     $form->applyFilter('__ALL__', 'strip_tags');
     $form->applyFilter('__ALL__', 'addslashes');
     return $this->form = $form;
 }
예제 #3
0
 private function _validate()
 {
     if ($this->action == TIP_FORM_ACTION_DELETE || $this->action == TIP_FORM_ACTION_CUSTOM) {
         // Special case: GET driven form
         $this->_form->freeze();
         return TIP::getGet('process', 'int') == 1;
     }
     // Add element and form rules
     isset($this->validator) && $this->_form->addFormRule($this->validator);
     foreach (array_keys($this->fields) as $id) {
         if ($this->_form->elementExists($id)) {
             $this->_addGuessedRules($id);
             $this->_addCustomRules($id);
         }
     }
     $stage_id = $this->id . '.stage';
     $last_stage = HTTP_Session2::get($stage_id);
     if (!$this->_form->isSubmitted() || isset($last_stage) && $last_stage < $this->_stage) {
         HTTP_Session2::set($stage_id, $this->_stage);
         $valid = false;
     } elseif (is_null($last_stage)) {
         // No last stage defined
         TIP::notifyError('double');
         $valid = null;
     } else {
         // Validation
         $this->_form->applyFilter('__ALL__', array('TIP', 'extendedTrim'));
         $valid = $this->_form->validate();
     }
     // Perform uploads (if needed)
     if (is_callable(array('HTML_QuickForm_attachment', 'doUploads'))) {
         HTML_QuickForm_attachment::doUploads($this->_form);
     }
     return $valid;
 }
예제 #4
0
#
## Further informations
#
$form->addElement('hidden', 'report_id');
$form->addElement('hidden', 'id');
$redirect =& $form->addElement('hidden', 'o');
$redirect->setValue($o);
$tab = array();
$tab[] =& HTML_QuickForm::createElement('radio', 'action', null, _("List"), '1');
$tab[] =& HTML_QuickForm::createElement('radio', 'action', null, _("Form"), '0');
$form->addGroup($tab, 'action', _("Post Validation"), '&nbsp;');
$form->setDefaults(array('action' => '1'));
#
## Form Rules
#
$form->applyFilter('__ALL__', 'myTrim');
$form->applyFilter('name', 'myReplace');
$form->addRule('name', _("Compulsory Name"), 'required');
$form->addRule('report_description', _("Compulsory decription"), 'required');
$form->addRule('period', _("Compulsory Period"), 'required');
$form->addRule('subject', _("Compulsory Subject"), 'required');
$form->addRule('report_title', _("Compulsory Title"), 'required');
//$form->addRule('report_hgs', _("Compulsory Hostgroup"), 'required');
$form->addRule('report_cgs', _("Compulsory Contactgroup"), 'required');
$form->addRule('retention', _("Compulsory"), 'required');
$form->setRequiredNote("<font style='color: red;'>*</font>&nbsp;" . _("Required fields"));
#
##End of form definition
#
# Smarty template Init
$tpl = new Smarty();
예제 #5
0
 foreach ($payment_options as $value) {
     $value = str_replace('pay_', '', $value);
     $form->addElement('radio', 'payment_method', ucwords(str_replace('_', ' ', $value)) . ':', null, $value);
 }
 $form->addElement('header', null, 'Additional requirements:');
 $form->addElement('textarea', 'requirements', null, array('class' => 'text_area'));
 $s = $form->createElement('select', 'terms', 'I agree to the Terms of Service:', null, array('class' => 'selectbox'));
 $s_opts = array(2 => 'Select One', 1 => 'Yes', 0 => 'No');
 $s->loadArray($s_opts);
 $form->addElement($s);
 $form->addRule('terms', 'You have to agree to the teams', 'required');
 $form->addRule('terms', 'You have to agree to the teams', 'regex', '/^1$/');
 $form->addRule('payment_method', 'Please select a payment method', 'required');
 if ($form->validate()) {
     // Apply form element filters.
     $form->applyFilter('__ALL__', 'escape_data');
     $form->freeze();
     $values = $form->process(array(&$this, 'formValues'), false);
     $pay_method = str_replace('_', ' ', $values['payment_method']);
     $invoice = $this->ushop->insertOrder($pay_method);
     if ($invoice) {
         // email order to user and merchant.
         // get mail config.
         $this->registry->mail_config = new Config($this->registry, array('path' => $this->registry->ini_dir . '/mail.ini.php'));
         // get mailer type and call class instance.
         $mailer = $this->registry->mail_config->get('type', 'mailer');
         $mail = new Mailer($mailer, $this->registry);
         $mail->setMailBody($this->ushop->displayInvoice($_SESSION['user_id'], $invoice));
         if ($values['requirements']) {
             $mail->addMailBody('<p>' . $values['requirements'] . '</p>');
         }
예제 #6
0
function buildWriteForm($options) {
    global $fyr_values, $fyr_postcode, $fyr_who, $fyr_type;
    global $fyr_representative, $fyr_voting_area, $fyr_date;
    global $fyr_postcode_editable, $fyr_group_msg, $fyr_valid_reps;
    global $rep_text, $cobrand, $cocode;

    $form_action = cobrand_url($cobrand, '/write', $cocode);
    $form = new HTML_QuickForm('writeForm', 'post', $form_action);
    
    if ($fyr_voting_area['name']=='United Kingdom')
        $fyr_voting_area['name'] = 'House of Lords';
 
    $write_header = '';
    if ($options['include_write_header']){
        $write_header = "<strong>Now Write Your Message:</strong> <small>(* means required)</small><br><br>";
    }

    if ($options['include_fao']){
        $write_header = '<strong>For the attention of:</strong>';
    }

    $stuff_on_left = <<<END
            <div class="letter-header">
            ${write_header}
            ${rep_text}
            <span>${fyr_voting_area['name']}</span>
            <span>$fyr_date</span>
            </div>
END;
    // special formatting for letter-like code, TODO: how do this properly with QuickHtml?
    if ($options['table_layout']){
        $form->addElement("html", "<tr><td valign=\"top\">$stuff_on_left</td><td align=\"right\">\n<table>"); // CSSify
    } else {
        $form->addElement("html", "<div class=\"highlight\">$stuff_on_left<ul class=\"data-input\">");
    }  

    $form->addElement('text', 'name', "Your name:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('name', 'Please enter your name', 'required', null, null);
    $form->applyFilter('name', 'trim');

    $form->addElement('text', 'writer_address1', "Address 1:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_address1', 'Please enter your address', 'required', null, null);
    $form->applyFilter('writer_address1', 'trim');

    $form->addElement('text', 'writer_address2', "Address 2:", array('size' => 20, 'maxlength' => 255));
    $form->applyFilter('writer_address2', 'trim');

    $form->addElement('text', 'writer_town', "Town/City:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_town', 'Please enter your town/city', 'required', null, null);
    $form->applyFilter('writer_town', 'trim');

    # Call it state so that Google Toolbar (and presumably others) can auto-fill.
    $form->addElement('text', 'state', 'County:', array('size' => 20, 'maxlength' => 255));
    $form->applyFilter('state', 'trim');

    if ($fyr_postcode_editable) {
        // House of Lords
        $form->addElement('text', 'pc', "UK postcode:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
        $form->addRule('pc', 'Please enter a UK postcode (<a href="/about-lords#ukpostcode" target="_blank">why?</a>)', 'required', null, null);
        $form->addRule('pc', 'Choose a valid UK postcode (<a href="/about-lords#ukpostcode" target="_blank">why?</a>)', new RulePostcode(), null, null);
        $form->applyFilter('pc', 'trim');
    } else {
        // All other representatives (postcode fixed as must be in constituency)
        $form->addElement('static', 'staticpc', 'UK postcode:', htmlentities($fyr_postcode));
    }

    $form->addElement('text', 'writer_email', "Your email:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_email', 'Please enter your email address', 'required', null, null);
    $invalid_email_message = cobrand_invalid_email_message($cobrand);
    if (!$invalid_email_message) {
         $invalid_email_message = 'Choose a valid email address';
    }
    $form->addRule('writer_email', $invalid_email_message, 'email', null, null);
    $form->applyFilter('writer_email', 'trim');

    $form->addElement('text', 'writer_email2', "Confirm email:<sup>*</sup>", array('size' => 20, 'maxlength' => 255));
    $form->addRule('writer_email2', 'Please re-enter your email address', 'required', null, null);
    $form->applyFilter('writer_email2', 'trim');
    $form->addFormRule('compare_email_addrs');

    /* add additional text explaining why we ask for email address twice? */

    #    $form->addElement("html", "</td><td colspan=2><p style=\"margin-top: 0em; margin-bottom: -0.2em\"><em style=\"font-size: 75%\">Optional, to let your {$fyr_voting_area['rep_name']} contact you more easily:</em>"); // CSSify

    $form->addElement('text', 'writer_phone', "Phone:", array('size' => 20, 'maxlength' => 255));
    $form->applyFilter('writer_phone', 'trim');

    // special formatting for letter-like code, TODO: how do this properly with QuickHtml?
    if ($options['table_layout']){
        $form->addElement("html", "</table>\n</td></tr>");
    } else {
        $form->addElement("html", "</ul>");
    }

    $form->addElement('textarea', 'body', null, array('rows' => 15, 'cols' => 62));
    $form->addRule('body', 'Please enter your message', 'required', null, null);
    $form->addRule('body', 'Please enter your message', new RuleAlteredBodyText(), null, null);
    $form->addRule('body', 'Please sign at the bottom with your name, or alter the "Yours sincerely" signature', new RuleSigned(), null, null);
    $form->addRule('body', 'Your message is a bit too long for us to send', 'maxlength', OPTION_MAX_BODY_LENGTH);
    if (!$options['table_layout']){
        $form->addElement("html", "</div>");
    }

    add_all_variables_hidden($form, $fyr_values, $options);
    $preview_text = cobrand_preview_text($cobrand);
    if (!$preview_text) {
        $preview_text = 'Ready? Press the "Preview" button to continue:';
    }
    $preview_button_text = cobrand_preview_button_text($cobrand);
    if (!$preview_button_text) {   
        $preview_button_text = 'preview your Message';
    }
    $buttons[0] =& HTML_QuickForm::createElement('static', 'staticpreview', null,"<p class=\"action\" id=\"preview-submit\">$preview_text"); 
    $buttons[2] =& HTML_QuickForm::createElement('submit', 'submitPreview', $preview_button_text);
    $buttons[3] =& HTML_QuickForm::createElement('static', 'staticpreview', null, "</p>");     
    $form->addGroup($buttons, 'previewStuff', '', '', false);

    return $form;
}
예제 #7
0
파일: Find.php 프로젝트: shupp/toasteradmin
 /**
  * _findForm 
  * 
  * Generate find form
  * 
  * @access private
  * @return void
  */
 private function _findForm()
 {
     $form = new HTML_QuickForm('formFind', 'post', './?module=Main&class=Find&event=findNow');
     $form->addElement('text', 'domain', _('Domain'));
     $form->addElement('submit', 'submit', _('Find Domain'));
     $form->addRule('domain', _('Please a domain name'), 'required', null, 'client');
     $form->applyFilter('__ALL__', 'trim');
     return $form;
 }
예제 #8
0
 public function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $tilmelding = VIH_Model_LangtKursus_Tilmelding::factory($this->context->name());
     $tilmelding->loadBetaling();
     $form = new HTML_QuickForm('onlinebetaling', 'POST', $this->url());
     $form->addElement('header', null, 'Hvilke beløb vil du betale?');
     if ($tilmelding->get('skyldig_tilmeldingsgebyr') > 0) {
         $options[0] = HTML_QuickForm::createElement('checkbox', 0, null, number_format($tilmelding->get('skyldig_tilmeldingsgebyr'), 0, ',', '.') . ' kroner (DKK) - dækker tilmeldingsgebyret');
         $options[0]->updateAttributes(array('value' => $tilmelding->get('skyldig_tilmeldingsgebyr') * 100));
     }
     $i = 1;
     if ($tilmelding->antalRater() > 0) {
         foreach ($tilmelding->getRater() as $rate) {
             $options[$i] = HTML_QuickForm::createElement('checkbox', $i, null, number_format($rate['beloeb'], 0, ',', '.') . ' kroner (DKK) - forfalder ' . $rate['dk_betalingsdato']);
             $options[$i]->updateAttributes(array('value' => $rate['beloeb'] * 100));
             $i++;
         }
     } elseif ($tilmelding->get('skyldig_tilmeldingsgebyr') == 0) {
         $options[0] = HTML_QuickForm::createElement('checkbox', $i, null, 'Du kan betale igen, når vi har oprettet dine rater.');
         $options[0]->updateAttributes(array('disabled' => 'disabled'));
     }
     $form->addGroup($options, 'amount', 'Beløb', '<br />');
     $form->addElement('header', null, 'Betaling');
     $form->addElement('text', 'cardnumber', 'Kortnummer');
     $form->addElement('text', 'cvd', 'Sikkerhedsnummer');
     $form->addElement('text', 'mm', 'Mdr.');
     $form->addElement('text', 'yy', 'År');
     $form->addElement('submit', null, 'Betal');
     $form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'required');
     $form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'numeric');
     $form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'required');
     $form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'numeric');
     $form->addRule('mm', 'Du skal udfylde mdr.', 'required');
     $form->addRule('mm', 'Du skal udfylde mdr.', 'numeric');
     $form->addRule('yy', 'Du skal udfylde år ', 'required');
     $form->addRule('yy', 'Du skal udfylde år', 'numeric');
     $form->applyFilter('__ALL__', 'trim');
     $form->applyFilter('__ALL__', 'addslashes');
     $form->applyFilter('__ALL__', 'strip_tags');
     return $this->form = $form;
 }
예제 #9
0
<?php

session_start();
require "db.php";
echo "<h1>Search</h1>";
$searchform = new HTML_QuickForm('searchform', 'get', 'search.php');
$searchform->addElement('text', 'searchterms', 'Search', array('size' => 20, 'maxlength' => 50));
$searchform->addElement('submit', null, 'Search!');
$searchform->applyFilter('name', 'trim');
$searchform->addRule('searchterms', 'Enter a search term', 'required', null, 'client');
$searchform->display();
echo "<table class='visible' width='100%'cellspacing=0 cellpadding=5>";
echo "<tr><th class='visible'>Login details</th></tr>";
echo "<tr><td>";
if ($_SESSION['SESS_USERNAME']) {
    echo "Logged in as <strong>" . $_SESSION['SESS_USERNAME'] . "</strong> - <a href='userlogout.php'>Logout</a>";
    echo "<p>";
    if ($_SESSION['SESS_USERLEVEL'] > 1) {
        echo "<a href='addstory.php'>Post a new story</a><br />";
    }
    if ($_SESSION['SESS_USERLEVEL'] == 10) {
        echo "<a href='addcat.php'>Add a new Category</a><br />";
    }
    echo "<p>";
} else {
    echo "<a href='userlogin.php'>Login</a>";
}
echo "</td></tr>";
echo "</table>";
echo "<h1>Topics</h1>";
$sql = "SELECT * FROM categories WHERE parent = 1;";
예제 #10
0
function login_display($task)
{
    global $db, $cfg;
    if ($task == NULL) {
        if (auth_logged_in()) {
            $task = 'profile';
        } else {
            $task = 'login';
        }
    }
    switch ($task) {
        case "register":
            $form = new HTML_QuickForm('regForm', 'post', 'index.php?view=login&task=register');
            $form->addElement('header', null, 'Register');
            $form->addElement('text', 'handle', 'Handle:');
            $form->addElement('password', 'password', 'Password:'******'password', 'password2', 'Retype Password:'******'text', 'email', 'Email:');
            $form->addElement('header', null, 'Personal Information');
            $form->addElement('text', 'first_name', 'First Name:');
            $form->addElement('text', 'last_name', 'Last Name:');
            $date = getdate();
            $form->addElement('date', 'birth_date', 'Date of Birth:', array('minYear' => $date['year'] - 100, 'maxYear' => $date['year']));
            $form->addElement('text', 'address', 'Street Address:');
            $form->addElement('text', 'city', 'City:');
            $form->addElement('text', 'state', 'State:');
            $form->addElement('text', 'zip', 'Zip:');
            $form->addElement('select', 'division', 'Division:', $cfg["tcl"]["divisions"]);
            $form->addElement('text', 'phone', 'Phone:');
            $form->addElement('textarea', 'quote', 'Quote:', array('rows' => 3));
            $form->addElement('header', null, 'For Password Recovery');
            $form->addElement('text', 'question', 'Secret Question:');
            $form->addElement('text', 'secret', 'Secret Answer:');
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('handle', 'trim');
            $form->applyFilter('handle', 'strtolower');
            $form->applyFilter('email', 'trim');
            $form->applyFilter('first_name', 'trim');
            $form->applyFilter('last_name', 'trim');
            $form->applyFilter('address', 'trim');
            $form->applyFilter('state', 'trim');
            $form->applyFilter('city', 'trim');
            $form->applyFilter('zip', 'trim');
            $form->applyFilter('phone', 'trim');
            $form->applyFilter('question', 'trim');
            $form->applyFilter('secret', 'trim');
            $form->addRule('handle', 'Handle is required.', 'required', null, 'client');
            $form->addRule('handle', 'Handle can only contain alphabets, numbers. and/or undescores.', 'alphanumericscore', null, 'client');
            $form->addRule('password', 'Password is required.', 'required', null, 'client');
            $form->addRule('password2', 'Retyped password is required.', 'required', null, 'client');
            $form->addRule('email', 'Email is required.', 'required', null, 'client');
            $form->addRule('division', 'Division is required.', 'required', null, 'client');
            $form->addRule('first_name', 'First name is required.', 'required', null, 'client');
            $form->addRule('last_name', 'Last name is required.', 'required', null, 'client');
            $form->addRule('question', 'Secret question is required.', 'required', null, 'client');
            $form->addRule('secret', 'Secret answer is required.', 'required', null, 'client');
            $form->addRule('handle', 'Login handle must be between 4 and 15 characters.', 'rangelength', array(4, 15), 'client');
            $form->addRule('password', 'Password must be between 6 and 15 characters.', 'rangelength', array(4, 15), 'client');
            $form->addRule('email', 'Email is invalid.', 'email', null, 'client');
            $form->addRule(array('password', 'password2'), 'Passwords much match.', 'compare', null, 'client');
            $show_form = true;
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                unset($data['password2']);
                // Verify that email is unique
                $res =& db_query('user_by_email', $data['email']);
                if ($res->numRows() != 0) {
                    $res->fetchInto($user);
                    $res->free();
                    ?>
				<p><b>Email already registered to an existing user!</b><br />
				User <?php 
                    echo '<b>' . $user['handle'] . '</b>';
                    ?>
 owns that email address. Maybe you've already registered and forgotten about it?
				Try <a href="index.php?view=login&amp;task=login">logging in</a> if that is the case.</p>
				<?php 
                } else {
                    // Format the birth date correctly
                    $data['birth_date'] = form2sql_date($data['birth_date']);
                    $user = auth_register($data);
                    if ($user == null) {
                        $show_form = false;
                        ?>
	<p><strong>Thanks for registering!</strong><br /> Please proceed to <a href="index.php?view=login&amp;task=login">login</a> into your new account.</p>
	<?php 
                    } else {
                        ?>
	<p><b>That user-handle has already been taken!</b><br/> It belongs to an user registered with the name <?php 
                        echo $user['first_name'] . ' ' . $user['last_name'];
                        ?>
. Please try again with another handle.</p>
	<?php 
                    }
                }
            }
            if ($show_form) {
                ?>
<p><strong>Please fill in your details below.</strong><br /> 
Please choose your <strong>handle</strong> and <strong>division</strong> carefully. Once chosen, they cannot be changed. Moreover, choosing an inappropriate division will lead to disqualification.
<br> 
<br>Any doubts and problems should find their way to the <? echo '<a href="mailto:'.$cfg["site"]["email"].'">admins</a>'; ?>.
</p>
<?php 
                $form->display();
            }
            break;
        case 'logout':
            auth_logout();
            redirect('index.php');
            break;
        case 'login':
            $form = new HTML_QuickForm('loginForm', 'post', 'index.php?view=login&task=login');
            $form->addElement('header', null, 'Login');
            $form->addElement('text', 'handle', 'Handle:');
            $form->addElement('password', 'password', 'Password:'******'submit', null, 'Submit');
            $form->applyFilter('handle', 'trim');
            $form->applyFilter('handle', 'strtolower');
            if ($form->validate()) {
                if (auth_login($form->getSubmitValue('handle'), $form->getSubmitValue('password'))) {
                    redirect('index.php');
                } else {
                    echo "<p>Invalid handle or password! Please try again.</p>\n";
                }
            } else {
                $signature = '<i>' . $_SERVER['SERVER_SOFTWARE'] . ' Server at ' . $_SERVER['SERVER_NAME'] . ', port ' . $_SERVER['SERVER_PORT'] . '</i>';
                ?>
<p><strong>Welcome!</strong><br />
Please login to proceed, or <a href="index.php?view=login&amp;task=register">register</a>
 with us if you're new here.</p>
<?php 
            }
            $form->display();
            ?>
<p class="system_info">This is <b>OGS 2</b> running on <? echo $signature ?>.<br />
<b>Server System:</b> <?php 
            system("uname -srmp");
            ?>
</p>
<hr />
<div id="javascript_warn"><p><strong>Warning!</strong> Javascript is not enabled on your browser. Many features will not work without it.</p></div>
<script type="text/javascript">
getObj('javascript_warn').style.display = "none";
</script>
<p><strong>Before you login.</strong> This website makes heavy use of modern web technologies such as CSS
and Javascript, to enjoy which, you'll need a modern browser. Below is a list of browsers along with their
earliest versions which are guaranteed to work with this website. For best results, we recommend a resolution higher than 800x600 with True Color (32-bit).</p>
<table class="browsers">
<tr>
    <td><img width="32" height="32" src="images/firefox-icon.png" /></td>
    <td><img width="32" height="32" src="images/opera_icon.gif" /></td>
    <td><img width="32" height="32" src="images/internet-explorer-icon.png" /></td>
    <td><img width="32" height="32" src="images/mozilla-icon.png" /></td>
    <td><img width="32" height="32" src="images/safari-icon.png" /></td>
    <td><img width="32" height="32" src="images/icon-konqueror.jpg" /></td>
    <td><img width="32" height="32" src="images/netscape-icon.png" /></td>
</tr>
<tr>
    <td><a href="http://www.getfirefox.com/">Firefox</a><br />1.0+</td>
    <td><a href="http://www.opera.com/">Opera</a><br />7+</td>
    <td><a href="http://www.microsoft.com/windows/ie/">Internet<br />Explorer</a> 6.0+<a></a></td>
    <td><a href="http://www.mozilla.org/products/mozilla1.x/">Mozilla</a><br />1.3+</td>
    <td><a href="http://www.apple.com/safari/">Safari</a><br />1.2+</td>
    <td><a href="http://www.konqueror.org/">Konqueror</a><br />3+</td>
    <td><a href="http://browser.netscape.com">Netscape</a><br />6+</td>
</tr>
</table>
<p>If you experience any problems while browsing this website using one of the above browsers,
then you're welcome to <a href="mailto:de.arijit@gmail.com">email the webmaster</a>. We hope you'll
enjoy your stay here.</p>
        <?php 
            break;
        case 'forgot':
            ?>
<p><strong>Lost your password?</strong><br />Follow these steps to generate a new password for your account.
You will be mailed the new password once you're done.</p>
<?php 
            $form1 = new HTML_QuickForm('forgotForm1', 'post', 'index.php?view=login&task=forgot');
            $form1->addElement('header', null, 'Password Recovery: Step 1');
            $form1->addElement('text', 'handle', 'Enter your login handle:');
            $form1->addElement('submit', null, 'Next');
            $form1->applyFilter('handle', 'trim');
            $form1->applyFilter('handle', 'strtolower');
            $form1->addRule('handle', 'Your login handle is required.', 'required', null, 'client');
            if ($form1->validate()) {
                redirect('index.php?view=login&task=forgot2&handle=' . $form1->getSubmitValue('handle'));
            } else {
                $form1->display();
                ?>
<p><strong>Please note:</strong> Due to the lack of emailing support on our server (Yes! We require better servers!), you'll have to wait a few
hours before we can mail you your new password manually.</p> 
<?php 
            }
            break;
        case 'forgot2':
            $res =& db_query('user_by_handle', $_GET['handle']);
            if ($res->numRows() == 0) {
                $res->free();
                ?>
<p>The given login handle does not exist!</p>
<?php 
            } else {
                $res->fetchInto($row);
                $res->free();
                if ($row['question'][strlen($row['question']) - 1] != '?') {
                    $row['question'] .= '?';
                }
                $form2 = new HTML_QuickForm('forgotForm2', 'post', 'index.php?view=login&task=forgot2&handle=' . $_GET['handle']);
                $form2->addElement('header', null, 'Password Recovery: Step 2');
                $form2->addElement('static', null, 'Secret Question:', $row['question']);
                $form2->addElement('text', 'secret', 'Secret Answer:');
                $form2->addElement('submit', null, 'Next');
                $form2->applyFilter('secret', 'trim');
                $form2->addRule('secret', 'Answer is required for verification.', 'required', null, 'client');
                if ($form2->validate()) {
                    if ($form2->getSubmitValue('secret') == $row['secret']) {
                        $res =& db_query('clean_forgot', $row['user_id']);
                        $new_pass = Text_Password::create(10);
                        $res =& $db->autoExecute('users', array('password' => crypt($new_pass)), DB_AUTOQUERY_UPDATE, 'user_id=' . $row['user_id']);
                        if (PEAR::isError($res)) {
                            error($res->toString());
                        }
                        $res =& $db->autoExecute('forgot', array('user_id' => $row['user_id'], 'password' => $new_pass), DB_AUTOQUERY_INSERT);
                        if (PEAR::isError($res)) {
                            error($res->toString());
                        }
                        ?>
<p>Due to lack of emailing support on our server (Yes! We require better servers!), your password will
have to be emailed to you manually. You should receive your newly generated password within 12 hours.</p>
<?php 
                    } else {
                        ?>
<p><strong>Incorrect answer!</strong><br /> We need to verify your identity before we can proceed. Please try again.</p> 
<?php 
                        $form2->display();
                    }
                } else {
                    $form2->display();
                }
            }
            break;
        case 'profile':
            ?>
<p>You can view or edit your personal information here. 
Any fields that you leave blank will <i>remain unchanged</i>.</p>
<?php 
            $form = new HTML_QuickForm('profileForm', 'post', 'index.php?view=login&task=profile');
            $res =& db_query('user_by_id', $_SESSION['user_id']);
            $res->fetchInto($row);
            $res->free();
            $form->addElement('header', null, 'Edit Your Profile');
            $form->addElement('static', 'handle', 'Handle:');
            $form->addElement('password', 'password', 'Change Password:'******'password', 'password2', 'Retype Password:'******'text', 'email', 'Email:');
            $form->addElement('header', null, 'Personal Information');
            $form->addElement('text', 'first_name', 'First Name:');
            $form->addElement('text', 'last_name', 'Last Name:');
            $date = getdate();
            $form->addElement('date', 'birth_date', 'Date of Birth:', array('minYear' => $date['year'] - 100, 'maxYear' => $date['year']));
            $form->addElement('text', 'address', 'Street Address:');
            $form->addElement('text', 'city', 'City:');
            $form->addElement('text', 'state', 'State:');
            $form->addElement('text', 'zip', 'Zip:');
            $form->addElement('static', null, 'Division:', $cfg['tcl']['divisions'][$row['division']]);
            $form->addElement('text', 'phone', 'Phone:');
            $form->addElement('textarea', 'quote', 'Quote:');
            $form->addElement('submit', null, 'Save Changes');
            unset($row['password']);
            // Format the birth date
            $row['birth_date'] = sql2form_date($row['birth_date']);
            $form->setDefaults($row);
            $form->applyFilter('email', 'trim');
            $form->applyFilter('first_name', 'trim');
            $form->applyFilter('last_name', 'trim');
            $form->applyFilter('address', 'trim');
            $form->applyFilter('state', 'trim');
            $form->applyFilter('city', 'trim');
            $form->applyFilter('zip', 'trim');
            $form->applyFilter('phone', 'trim');
            $form->addRule('password', 'Password must be between 6 and 15 characters.', 'rangelength', array(4, 15), 'client');
            $form->addRule('email', 'Email is invalid.', 'email', null, 'client');
            $form->addRule(array('password', 'password2'), 'Passwords much match.', 'compare', null, 'client');
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                unset($data['password2']);
                // Format the birth date correctly
                $data['birth_date'] = form2sql_date($data['birth_date']);
                foreach ($data as $key => $value) {
                    if ($value == $row['value'] || strlen($value) == 0) {
                        unset($data[$key]);
                    }
                }
                //print_r($data);
                auth_update($data);
                redirect('index.php?view=login&task=profile&updated=1');
            } else {
                $form->display();
            }
            if ($_GET['updated'] == '1') {
                ?>
                <p><b>Note:</b> Your profile has been updated.</p>
            <?php 
            }
            break;
    }
}
예제 #11
0
 /**
  * createLoginForm 
  * 
  * Create HTML_QuickForm object for the login form
  * 
  * @access protected
  * @return object  HTML_QuickForm object
  */
 protected function createLoginForm()
 {
     $form = new HTML_QuickForm('formLogin', 'post', $_SERVER['REQUEST_URI'] . '&event=loginNow');
     $form->addElement('header', 'MyHeader', _('Login'));
     $form->addElement('text', 'email', _('Email'));
     $form->addElement('password', 'password', _('Password'));
     $form->addElement('submit', 'submit', _('Login'));
     $form->addRule('email', _('Please enter your email address'), 'required', null, 'client');
     $form->addRule('email', _('Please enter a valid email address'), 'email', null, 'client');
     $form->addRule('password', _('Please enter your password'), 'required', null, 'client');
     $form->applyFilter('__ALL__', 'trim');
     return $form;
 }
}
$form = new HTML_QuickForm('catform');
$catsql = "SELECT id, category FROM categories WHERE parent = 1 ORDER BY category;";
//	$catres = mysql_query($catsql);
$catres = $db->query($catsql);
$catarr[0] = "-- No Parent --";
//	while($catrow = mysql_fetch_assoc($catres)) {
foreach ($catres as $catrow) {
    $catarr[$catrow['id']] = $catrow['category'];
}
$s =& $form->createElement('select', 'cat_id', 'Parent Category ');
$s->loadArray($catarr, 'cat');
$form->addElement($s);
$form->addElement('text', 'category', 'Category', array('size' => 20, 'maxlength' => 100));
$form->addElement('submit', null, 'Add Story!');
$form->applyFilter('name', 'trim');
$form->addRule('category', 'Please enter a category', 'required', null, 'client');
if ($form->validate()) {
    $form->freeze();
    $form->process("process_data", false);
    header("Location: " . $config_basedir);
} else {
    require "header.php";
    echo "<h1>Add a category</h1>";
    echo "<p>Select the parent category that the new category is part of. If you want to create a new parent category, use the <tt>-- No Parent --</tt> option.</p>";
    $form->display();
}
function process_data($values)
{
    require "db.php";
    global $db;
$form->addElement('header', null, 'Betaling');
$form->addElement('text', 'cardnumber', 'Kortnummer');
$form->addElement('text', 'cvd', 'Sikkerhedsnummer');
$form->addElement('text', 'mm', 'Mdr.');
$form->addElement('text', 'yy', 'År');
$form->addElement('html', null, 'Vær opmærksom på, at det kan tage helt op til et minut at gennemføre transaktionen hos PBS.');
$form->addElement('submit', null, 'Betal');
$form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'required');
$form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'numeric');
$form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'required');
$form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'numeric');
$form->addRule('mm', 'Du skal udfylde Mdr.', 'required');
$form->addRule('mm', 'Du skal udfylde Mdr.', 'numeric');
$form->addRule('yy', 'Du skal udfylde År ', 'required');
$form->addRule('yy', 'Du skal udfylde År', 'numeric');
$form->applyFilter('trim', '__ALL__');
$form->applyFilter('addslashes', '__ALL__');
$form->applyFilter('strip_tags', '__ALL__');
if ($form->validate()) {
    // først skal vi oprette en betaling - som kan fungere som id hos qp
    // betalingen skal kobles til den aktuelle tilmelding
    // når vi så har haft den omkring pbs skal betalingen opdateres med status for betalingen
    // status sættes til 000, hvis den er godkendt hos pbs.
    $eval = false;
    $betaling = new VIH_Model_Betaling('elevforeningen', $order_id);
    $betaling_amount_quickpay = $betaling_amount * 100;
    $betaling_id = $betaling->save(array('type' => 'quickpay', 'amount' => $betaling_amount));
    if ($betaling_id == 0) {
        trigger_error("Kunne ikke oprette betaling", E_USER_ERROR);
    }
    $onlinebetaling = new VIH_Onlinebetaling('authorize');
예제 #14
0
include "trader-functions.php";
redirect_login_pf();
draw_trader_header('select');
// Load the HTML_QuickForm module
require 'HTML/QuickForm.php';
global $db_hostname, $db_database, $db_user, $db_password;
$username = $_SESSION['username'];
$uid = $_SESSION['uid'];
$portfolio = new portfolio($_SESSION['pfid']);
$pfid = $portfolio->getID();
$pfname = $portfolio->getName();
$pf_working_date = $portfolio->getWorkingDate();
$pf_exch = $portfolio->getExch()->getID();
$sql_input_form = new HTML_QuickForm('sql_input');
$sql_input_form->applyFilter('__ALL__', 'trim');
$sql_input_form->addElement('header', null, "SQL to select stocks for '{$pfname}' working date {$pf_working_date}");
$sql_input_form->addElement('textarea', 'sql_select', 'select:', 'wrap="soft" rows="3" cols="50"');
$sql_input_form->addRule('sql_select', 'Must select columns', 'required');
$sql_input_form->addElement('textarea', 'sql_from', 'from:', 'wrap="soft" rows="1" cols="50"');
$sql_input_form->addRule('sql_from', 'Must select tables', 'required');
$sql_input_form->addElement('textarea', 'sql_where', 'where:', 'wrap="soft" rows="4" cols="50"');
$sql_input_form->addRule('sql_where', 'Must include where clause', 'required');
$sql_input_form->addElement('textarea', 'sql_order', 'order by:', 'wrap="soft" rows="1" cols="50"');
$sql_input_form->addRule('sql_order', 'Must order the output', 'required');
$direction = $sql_input_form->addElement('select', 'sql_order_dir', 'direction:');
$direction->addOption('ascending', 'asc');
$direction->addOption('descending', 'desc');
$limit = $sql_input_form->addElement('select', 'sql_limit', 'limit:');
$limit->addOption('1', '1');
$limit->addOption('10', '10');
예제 #15
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $tilmelding = new VIH_Model_KortKursus_Tilmelding($this->context->name());
     $deltagere = $tilmelding->getDeltagere();
     $form = new HTML_QuickForm(null, 'post', $this->url(), '', null, true);
     $form->addElement('header', null, 'Kontaktperson');
     $form->addElement('text', 'kontaktnavn', 'Navn');
     $form->addElement('text', 'adresse', 'Adresse');
     $form->addElement('text', 'postnr', 'Postnummer');
     $form->addElement('text', 'postby', 'By');
     $form->addElement('text', 'telefonnummer', 'Telefonnummer');
     $form->addElement('text', 'arbejdstelefon', 'Arbejdstelefon', 'Telefonnummer hvor du kan træffes mellem 8 og 16');
     $form->addElement('text', 'mobil', 'Mobil');
     $form->addElement('text', 'email', 'E-mail');
     // Confirmation is sent to this e-mail
     $form->addElement('header', null, 'Vil du tegne afbestillingsforsikring');
     $form->addElement('radio', 'afbestillingsforsikring', 'Afbestillingsforsikring', 'Ja', 'Ja');
     $form->addElement('radio', 'afbestillingsforsikring', '', 'Nej', 'Nej');
     $form->addElement('text', 'rabat', 'Rabat');
     //$form->addRule('kontaktnavn', 'Skriv venligst dit navn', 'required');
     //$form->addRule('adresse', 'Skriv venligst din adresse', 'required');
     //$form->addRule('postnr', 'Skriv venligst din postnummer', 'required');
     //$form->addRule('postby', 'Skriv venligst din postby', 'required');
     //$form->addRule('telefon', 'Skriv venligst din telefonnummer', 'required');
     //$form->addRule('arbejdstelefon', 'Skriv venligst din arbejdstelefon', 'required');
     //$form->addRule('email', 'Den e-mail du har indtastet er ikke gyldig', 'e-mail');
     //$form->addRule('afbestillingsforsikring', 'Du skal vælge, om du vil have en afbestillingsforsikring', 'required');
     $form->setDefaults(array('kontaktnavn' => $tilmelding->get('navn'), 'adresse' => $tilmelding->get('adresse'), 'postnr' => $tilmelding->get('postnr'), 'postby' => $tilmelding->get('postby'), 'telefonnummer' => $tilmelding->get('telefonnummer'), 'arbejdstelefon' => $tilmelding->get('arbejdstelefon'), 'mobil' => $tilmelding->get('mobil'), 'email' => $tilmelding->get('email'), 'afbestillingsforsikring' => $tilmelding->get('afbestillingsforsikring'), 'besked' => $tilmelding->get('besked'), 'rabat' => $tilmelding->get('rabat')));
     $deltager_nummer = 1;
     $i = 0;
     foreach ($deltagere as $deltager) {
         $form->addElement('header', null, 'Deltager ' . $deltager_nummer);
         $form->addElement('hidden', 'deltager_id[' . $i . ']');
         $form->addElement('text', 'navn[' . $i . ']', 'Navn');
         $form->addElement('text', 'cpr[' . $i . ']', 'CPR-nummer', '(ddmmåå-xxxx)', null);
         $form->setDefaults(array('deltager_id[' . $i . ']' => $deltager->get('id'), 'navn[' . $i . ']' => $deltager->get('navn'), 'cpr[' . $i . ']' => $deltager->get('cpr')));
         if (!$tilmelding->kursus->isFamilyCourse()) {
             $indkvartering_headline = 'Indkvartering';
             foreach ($tilmelding->kursus->getIndkvartering() as $key => $indkvartering) {
                 $form->addElement('radio', 'indkvartering_key[' . $i . ']', $indkvartering_headline, $indkvartering['text'], $indkvartering['indkvartering_key'], 'id="værelse_' . $indkvartering['indkvartering_key'] . '"');
                 $indkvartering_headline = '';
             }
             if (empty($indkvartering_headline)) {
                 $form->addElement('text', 'sambo[' . $i . ']', 'Vil gerne dele bad og toilet / værelse med?');
                 $form->setDefaults(array('indkvartering_key[' . $i . ']' => $deltager->get('indkvartering_key'), 'sambo[' . $i . ']' => $deltager->get('sambo')));
                 $form->addRule('værelse[' . $i . ']', 'Du skal vælge en indkvarteringsform', 'required');
             }
         }
         switch ($tilmelding->kursus->get('gruppe_id')) {
             case 1:
                 // golf
                 $form->addElement('text', 'handicap[' . $i . ']', 'Golfhandicap', '(begynder &rarr; skriv 99)');
                 $form->addElement('text', 'klub[' . $i . ']', 'Klub');
                 $form->addElement('text', 'dgu[' . $i . ']', 'DGU-medlem', null, null, 'ja');
                 $form->setDefaults(array('handicap[' . $i . ']' => $deltager->get('handicap'), 'klub[' . $i . ']' => $deltager->get('klub'), 'dgu[' . $i . ']' => $deltager->get('dgu')));
                 break;
             case 3:
                 // bridge
                 $niveau = array('Begynder' => 'Begynder', 'Let øvet' => 'Let øvet', 'Øvet' => 'Øvet', 'Meget øvet' => 'Meget øvet');
                 $form->addElement('select', 'niveau[' . $i . ']', 'Bridgeniveau', $niveau);
                 //$form->addRule('niveau['.$i.']', 'Hvilket bridgeniveau har du?', 'required');
                 $form->setDefaults(array('niveau[' . $i . ']' => $deltager->get('niveau')));
                 break;
             case 4:
                 // golf og bridge
                 $form->addElement('text', 'handicap[' . $i . ']', 'Golfhandicap', '(ingen spillere med handicap større end 50)');
                 $form->addElement('text', 'klub[' . $i . ']', 'Klub');
                 $form->addElement('text', 'dgu[' . $i . ']', 'DGU-medlem', 'Du skal være dgu-medlem for at deltage på kurset', null, 'ja');
                 $niveau = array('Let øvet' => 'Let øvet', 'Øvet' => 'Øvet', 'Meget øvet' => 'Meget øvet');
                 $form->addElement('select', 'niveau[' . $i . ']', 'Bridgeniveau', $niveau);
                 //$form->addRule('handicap['.$i.']', 'Du skal v�lge dit handicap', 'required');
                 //$form->addRule('klub['.$i.']', 'Hvem vil skrive en klub', 'required');
                 //$form->addRule('niveau['.$i.']', 'Hvilket bridgeniveau har du?', 'required');
                 $form->setDefaults(array('handicap[' . $i . ']' => $deltager->get('handicap'), 'klub[' . $i . ']' => $deltager->get('klub'), 'dgu[' . $i . ']' => $deltager->get('dgu'), 'niveau[' . $i . ']' => $deltager->get('niveau')));
                 break;
             default:
                 break;
         }
         // switch
         $deltager_nummer++;
         $i++;
     }
     // foreach
     $form->addElement('header', null, 'Øvrige oplysninger');
     $form->addElement('textarea', 'besked', 'Besked');
     $form->addElement('submit', null, 'Videre >>');
     $form->applyFilter('__ALL__', 'trim');
     return $this->form = $form;
 }
예제 #16
0
 function getForm()
 {
     $date_options = array('minYear' => date('Y') - 10, 'maxYear' => date('Y') + 5);
     if ($this->form) {
         return $this->form;
     }
     $tilmelding = $this->getTilmelding();
     foreach (VIH_Model_LangtKursus::getList('alle') as $kursus) {
         $kurser[$kursus->get('id')] = $kursus->getKursusNavn();
     }
     $form = new HTML_QuickForm('tilmelding', 'POST', $this->url());
     $form->addElement('hidden', 'id');
     $form->addElement('header', null, 'Kursus');
     $form->addElement('select', 'kursus_id', 'Kursus', $kurser);
     $form->addElement('header', null, 'Navn og adresse');
     $form->addElement('text', 'vaerelse', 'Værelse');
     $form->addElement('text', 'navn', 'Navn');
     $form->addElement('text', 'adresse', 'Adresse');
     $form->addElement('text', 'postnr', 'Postnummer');
     $form->addElement('text', 'postby', 'Postby');
     $form->addElement('text', 'cpr', 'Cpr-nummer');
     $form->addElement('text', 'telefonnummer', 'Telefonnummer');
     $form->addElement('text', 'kommune', 'Bopælskommune');
     $form->addElement('text', 'nationalitet', 'Nationalitet');
     $form->addElement('text', 'email', 'E-mail');
     foreach ($tilmelding->sex as $key => $value) {
         $radio[] =& HTML_QuickForm::createElement('radio', null, null, $value, $key);
     }
     $form->addGroup($radio, 'sex', 'Køn');
     $form->addElement('header', null, 'Nærmeste pårørende - hvem skal vi rette henvendelse til ved sygdom');
     $form->addElement('text', 'kontakt_navn', 'Navn');
     $form->addElement('text', 'kontakt_adresse', 'Adresse');
     $form->addElement('text', 'kontakt_postnr', 'Postnummer');
     $form->addElement('text', 'kontakt_postby', 'Postby');
     $form->addElement('text', 'kontakt_telefon', 'Telefon');
     $form->addElement('text', 'kontakt_arbejdstelefon', 'Arbejdstelefon');
     $form->addElement('text', 'kontakt_email', 'E-mail');
     $form->addElement('header', null, 'Hvordan er din uddannelsesmæssige baggrund?');
     foreach ($tilmelding->uddannelse as $key => $value) {
         $udd[] =& HTML_QuickForm::createElement('radio', null, null, $value, $key);
     }
     $form->addGroup($udd, 'uddannelse', 'Uddannelse');
     $form->addElement('header', null, 'Hvordan betaler du?');
     foreach ($tilmelding->betaling as $key => $value) {
         $bet[] =& HTML_QuickForm::createElement('radio', null, null, $value, $key);
     }
     $form->addGroup($bet, 'betaling', 'Betaling');
     $form->addElement('header', null, 'Besked til Vejle Idrætshøjskole');
     $form->addElement('textarea', 'besked', 'Er der andet vi bør vide?');
     $form->addElement('textarea', 'tekst_diplom', 'Tekst til diplomet');
     $form->addElement('header', null, 'Termin');
     $form->addElement('text', 'ugeantal', 'Ugeantal');
     $form->addElement('date', 'dato_start', 'Startdato', $date_options);
     $form->addElement('date', 'dato_slut', 'Slutdato', $date_options);
     $form->addElement('header', null, 'Priser');
     $form->addElement('text', 'pris_tilmeldingsgebyr', 'Tilmeldingsgebyr');
     $form->addElement('text', 'pris_uge', 'Ugepris');
     $form->addElement('text', 'pris_materiale', 'Materialer');
     $form->addElement('text', 'pris_rejsedepositum', 'Rejsedepositum');
     $form->addElement('header', null, 'Støtte');
     $form->addElement('text', 'elevstotte', 'Elevstøtte');
     $form->addElement('text', 'ugeantal_elevstotte', 'Elevstøtte antal uger');
     $form->addElement('text', 'kompetencestotte', 'Kompetencestøtte');
     $form->addElement('text', 'statsstotte', 'Indvandrerstøtte');
     $form->addElement('text', 'kommunestotte', 'Kommunestøtte');
     $form->addElement('text', 'aktiveret_tillaeg', 'Aktiveret tillæg');
     $form->addElement('header', null, 'Afbrudt ophold');
     $form->addElement('text', 'pris_afbrudt_ophold', 'Ekstra pris');
     $form->addElement('submit', null, 'Gem');
     $form->applyFilter('__ALL__', 'trim');
     $form->applyFilter('__ALL__', 'strip_tags');
     $form->addRule('id', 'Tilmeldingen skal have et id', 'numeric');
     $form->addRule('kursus_id', 'Du skal vælge et kursus', 'required');
     $form->addRule('kursus_id', 'Du skal vælge et kursus', 'numeric');
     $form->addRule('navn', 'Du skal skrive et navn', 'required');
     $form->addRule('adresse', 'Du skal skrive en adresse', 'required');
     $form->addRule('postnr', 'Postnummer', 'required');
     $form->addRule('postby', 'Postby', 'required');
     $form->addRule('telefonnummer', 'Telefonnummer', 'required');
     $form->addRule('email', 'Du har ikke skrevet en gyldig e-mail', 'email');
     $form->addRule('kommune', 'Du har ikke skrevet en kommune', 'required');
     $form->addRule('nationalitet', 'Du har ikke skrevet en nationalitet', 'required');
     $form->addRule('cpr', 'Du skal skrive et cpr-nummer', 'required');
     $form->addRule('kontakt_navn', 'Du har ikke skrevet et gyldigt kontaktnavn', 'required');
     $form->addRule('kontakt_adresse', 'Du har ikke skrevet et gyldig kontaktadresse', 'required');
     $form->addRule('kontakt_postnr', 'Du har ikke skrevet en kontaktpostnummer', 'required');
     $form->addRule('kontakt_postby', 'Du har ikke skrevet en kontaktpostby', 'required');
     $form->addRule('kontakt_telefon', 'Du har ikke skrevet et nummer under telefon', 'required');
     $form->addRule('kontakt_arbejdstelefon', 'Du har ikke skrevet et nummer under arbejdstelefon', 'required');
     $form->addRule('kontakt_email', 'Du har ikke skrevet en gyldig kontakte-mail', 'email');
     $form->addGroupRule('uddannelse', 'Du skal vælge din uddannelsesmæssige baggrund', 'required', null);
     $form->addGroupRule('betaling', 'Du skal vælge, hvordan du betaler', 'required', null);
     return $this->form = $form;
 }
예제 #17
0
</head>
<body>
<?php 
set_include_path(get_include_path() . ";c:\\php\\pear");
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('frmTest', 'post');
$form->addElement('text', 'Pseudo', 'Votre pseudo : ');
$form->addElement('text', 'Nom', 'Votre nom : ');
$form->addElement('text', 'Email', 'Votre adresse email : ');
$options = array('language' => 'fr', 'format' => 'dMY', 'minYear' => 2001, 'maxYear' => 2005);
$form->addElement('date', 'date', 'votre date de naissance : ', $options);
$form->addRule('Pseudo', 'Vous devez saisir un pseudo', 'required', '', 'client');
$form->addRule('Nom', 'Vous devez saisir un nom', 'required', '', 'client');
$form->addRule('Email', 'Vous devez saisir une adresse Email', 'required', '', 'client');
$form->addRule('Pseudo', 'Votre pseudo doit avoir entre 6 caractères et 10 caractères', 'rangelength', array(6, 10), 'client');
$form->addRule('Email', 'Vous devez saisir une adresse email valide', 'email', '', 'client');
$form->applyFilter('Nom', 'trim');
$form->applyFilter('Pseudo', 'trim');
$form->setRequiredNote('<span style="color: #ff0000">*</span> = champs obligatoires');
$form->setJsWarnings('Erreur de saisie', 'Veuillez corriger');
$form->addElement('reset', 'bouton_clear', 'Effacer');
$form->addElement('submit', 'bouton_effacer', 'Envoyer');
if ($form->validate()) {
    echo "Toutes les règles sont respectées<br>";
} else {
    $form->display();
}
?>
</body>
</html>
<?php

require_once 'include_elevforeningen.php';
require_once 'HTML/QuickForm.php';
//require_once 'Template/Template.php';
require_once 'IntrafacePublic/Contact/XMLRPC/Client.php';
session_start();
$credentials = array('private_key' => INTRAFACE_PRIVATE_KEY, 'session_id' => md5(session_id()));
$form = new HTML_QuickForm('login', 'get');
$form->addElement('text', 'handle', 'Kode');
$form->addElement('submit', null, 'Login');
$form->addRule('handle', 'Du skal indtaste en kode', 'required');
$form->applyFilter('__ALL__', 'trim');
$form->applyFilter('__ALL__', 'strip_tags');
$form->applyFilter('__ALL__', 'addslashes');
$form->setDefaults(array('handle' => @$_GET['handle']));
if ($form->validate()) {
    $auth = new IntrafacePublic_Contact_XMLRPC_Client($credentials);
    $contact_array = $auth->authenticateContact($form->exportValue('handle'));
    $_SESSION['contact_id'] = $contact_array['id'];
    if ($auth->isLoggedIn()) {
        header('Location: index.php');
        exit;
    }
}
$tpl = new Template(PATH_TEMPLATE_KUNDELOGIN);
$tpl->set('title', 'Login');
$tpl->set('content_main', '
    <h1>Login</h1>
    <p>Du kan logge ind ved at indtaste din kode.</p>
    ' . $form->toHTML());
예제 #19
0
 */
$attrsText = array("size" => "5");
/*
 * Form begin
 */
$form = new HTML_QuickForm('Form', 'post', "?p=" . $p);
$form->addElement('header', 'title', _("Refresh Options"));
# Database information
$form->addElement('text', 'refresh_monitoring', _("Refresh Interval for monitoring"), $attrsText);
$form->addElement('text', 'refresh_filters', _("Refresh Interval for filters"), $attrsText);
$redirect =& $form->addElement('hidden', 'o');
$redirect->setValue($o);
/*
 * Form Rules
 */
$form->applyFilter('_ALL_', 'trim');
$form->addRule('refresh_monitoring', _("Required Field"), 'required');
$form->addRule('refresh_filters', _("Required Field"), 'required');
if (isset($cfg_syslog)) {
    $form->setDefaults($cfg_syslog);
} else {
    $form->setDefaults(array("refresh_monitoring " => '10', "refresh_filters" => '240'));
}
#End of form definition
if ($form->validate()) {
    if ($form->getSubmitValue("submitC")) {
        updateRefreshOption();
    }
}
/*
 * Smarty template Init
예제 #20
0
 /**
  * _addForm 
  * 
  * Create Add IP Map form
  * 
  * @access private
  * @return void
  */
 private function _addForm()
 {
     $form = new HTML_QuickForm('addIPMapForm', 'post', './?module=Main&class=IPMaps&event=addNow');
     $form->addElement('text', 'ip', _('IP Address'));
     $form->addElement('text', 'domain', _('Domain'));
     $form->addElement('submit', 'submit', _('Add'));
     $form->addRule('ip', _('Please specify an IP'), 'required', null, 'client');
     $form->addRule('domain', _('Please specify a Domain'), 'required', null, 'client');
     $form->applyFilter('__ALL__', 'trim');
     return $form;
 }
예제 #21
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $tilmelding = VIH_Model_KortKursus_Tilmelding::factory($this->context->name());
     $tilmelding->loadBetaling();
     $forsikringstekst = '';
     if ($tilmelding->get('pris_forsikring') > 0) {
         $forsikringstekst = ' og afbestillingsforsikring';
     }
     $form = new HTML_QuickForm('onlinebetaling', 'POST', $this->url());
     if ($tilmelding->get('skyldig_depositum') > 0 and $tilmelding->get('dato_forfalden') > date('Y-m-d')) {
         $form->addElement('header', null, 'Hvilket beløb vil du betale?');
         $options[] =& HTML_QuickForm::createElement('radio', null, null, $tilmelding->get('pris_total') . ' kroner (DKK) - dækker hele kursusprisen', $tilmelding->get('pris_total') * 100);
         $options[] =& HTML_QuickForm::createElement('radio', null, null, $tilmelding->get('pris_forudbetaling') . ' kroner (DKK) - dækker depositum' . $forsikringstekst, $tilmelding->get('pris_forudbetaling') * 100);
         $form->addGroup($options, 'amount', 'Beløb', '<br />');
         $form->addGroupRule('amount', 'Du skal vælge et beløb', 'required', null);
     } else {
         $form->addElement('header', null, 'Du skal betale nedenstående beløb');
         $form->addElement('radio', 'amount', 'Beløb', $tilmelding->get('skyldig') . ' kroner (DKK) - dækker resten af beløbet', $tilmelding->get('skyldig') * 100);
         $form->addRule('amount', 'Du skal vælge et beløb', 'required');
         $form->addRule('amount', 'Du skal vælge et beløb', 'numeric');
         $form->setDefaults(array('amount' => $tilmelding->get('skyldig') * 100));
     }
     $form->addElement('header', null, 'Betaling');
     $form->addElement('text', 'cardnumber', 'Kortnummer');
     $form->addElement('text', 'cvd', 'Sikkerhedsnummer');
     $form->addElement('text', 'mm', 'Mdr.');
     $form->addElement('text', 'yy', 'år');
     $form->addElement('html', null, 'Vær opmærksom på, at det kan tage helt op til et minut at gennemføre transaktionen hos PBS.');
     $form->addElement('submit', null, 'Betal');
     $form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'required');
     $form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'numeric');
     $form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'required');
     $form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'numeric');
     $form->addRule('mm', 'Du skal udfylde Mdr.', 'required');
     $form->addRule('mm', 'Du skal udfylde Mdr.', 'numeric');
     $form->addRule('yy', 'Du skal udfylde år ', 'required');
     $form->addRule('yy', 'Du skal udfylde år', 'numeric');
     $form->applyFilter('__ALL__', 'trim');
     $form->applyFilter('__ALL__', 'addslashes');
     $form->applyFilter('__ALL__', 'strip_tags');
     return $this->form = $form;
 }
$form->addElement('header', 'pdfreports_report_config', _("Reports Configuration"));
$form->addElement('text', 'pdfreports_smtp_server_address', _("SMTP server address"), $attrsText);
$form->addElement('text', 'pdfreports_email_sender', _("Email Sender"), $attrsText);
$form->addElement('text', 'pdfreports_report_author', _("Report Author"), $attrsText);
$form->addElement('select', 'pdfreports_report_header_logo', _("Header Logo"), $logoImg, array("id" => "pdfreports_report_header_logo"));
$form->addElement('text', 'pdfreports_path_gen', _("Path to report files"), $attrsText);
#
## Form Rules
#
function slash($elem = NULL)
{
    if ($elem) {
        return rtrim($elem, "/") . "/";
    }
}
$form->applyFilter('__ALL__', 'myTrim');
$form->applyFilter('pdfreports_path_gen', 'slash');
$form->registerRule('is_writable_file_if_exist', 'callback', 'is_writable_file_if_exist');
$form->registerRule('is_writable_path', 'callback', 'is_writable_path');
$form->addRule('pdfreports_smtp_server_address', _("Required Field"), 'required');
$form->addRule('pdfreports_email_sender', _("Required Field"), 'required');
$form->addRule('pdfreports_report_author', _("Required Field"), 'required');
$form->addRule('pdfreports_path_gen', _("Required Field"), 'required');
$form->addRule('pdfreports_path_gen', _("Can't write in directory"), 'is_writable_path');
#
##End of form definition
#
$form->addElement('hidden', 'gopt_id');
$redirect =& $form->addElement('hidden', 'o');
$redirect->setValue($o);
# Smarty template Init
예제 #23
0
function admin_display($task)
{
    global $db, $cfg;
    if ($task == NULL) {
        $task = 'contests';
    }
    switch ($task) {
        case 'users':
            $table = new HTML_Table();
            $res =& db_query('users_list');
            $res->fetchInto($row);
            // add users table headers
            $headers = array_keys($row);
            array_push($headers, 'groups');
            array_push($headers, 'actions');
            $table->addRow($headers, null, 'TH');
            // add user records
            while ($row) {
                $res2 =& db_query('groups_by_user_id', $row['user_id']);
                // get list of gourps for this user
                $groups = '';
                $res2->fetchInto($row2);
                while ($row2) {
                    $groups .= $row2['name'];
                    if ($res2->fetchInto($row2)) {
                        $groups .= ', ';
                    }
                }
                $res2->free();
                array_push($row, $groups);
                // actions
                array_push($row, "<a href=\"index.php?view=admin&amp;task=edit_user&amp;id={$row['user_id']}\">edit</a>" . ", <a href=\"index.php?view=admin&amp;task=del_user&amp;id={$row['user_id']}\">delete</a>");
                $table->addRow(array_values($row));
                $res->fetchInto($row);
            }
            $res->free();
            $table->altRowAttributes(1, null, array("class" => "altrow"));
            echo '<div class="overflow">' . $table->toHtml() . '</div>';
            break;
        case 'del_user':
            db_query('del_user_by_id', $_GET['id']);
            db_query('del_user_perms_by_id', $_GET['id']);
            redirect('index.php?view=admin&task=users');
            break;
        case 'edit_user':
            // user id to edit given as arg
            $res =& db_query('groups_by_user_id', $_GET['id']);
            // get list of all groups for this user
            $user_groups = array();
            while ($res->fetchInto($row)) {
                array_push($user_groups, $row['group_id']);
            }
            $res->free();
            // get hanndle of user
            $res =& db_query('user_by_id', $_GET['id']);
            $res->fetchInto($row);
            $handle = $row['handle'];
            $res->free();
            $form = new HTML_QuickForm('userForm', 'post', 'index.php?view=admin&task=edit_user&id=' . $_GET['id']);
            $form->addElement('header', null, 'Groups for user ' . $handle . ' (id: ' . $_GET['id'] . ')');
            // get list of all available groups
            $res =& db_query('groups_list');
            // add checkbox for each group
            $groups = array();
            while ($res->fetchInto($row)) {
                $elem =& $form->addElement('checkbox', $row['group_id'], $row['name']);
                if (in_array($row['group_id'], $user_groups)) {
                    $elem->setChecked(true);
                }
                $groups[$row['group_id']] = $row['name'];
            }
            $res->free();
            $form->addElement('submit', 'submit', 'Apply Changes');
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                foreach ($groups as $gid => $name) {
                    $elem =& $form->getElement($gid);
                    if ($data[$gid] == 1) {
                        auth_set_perm($_GET['id'], $gid);
                        $elem->setChecked(true);
                    } else {
                        auth_clear_perm($_GET['id'], $gid);
                        $elem->setChecked(false);
                    }
                }
            }
            $form->display();
            break;
        case 'groups':
            $table = new HTML_Table();
            $res =& db_query('groups_list');
            $res->fetchInto($row);
            // add groups table header
            $headers = array_keys($row);
            array_push($headers, 'views');
            array_push($headers, 'actions');
            $table->addRow($headers, null, 'TH');
            // add group records
            while ($row) {
                $res2 =& db_query('views_by_group_id', $row['group_id']);
                // get list of views allowed for this group
                $views = '';
                $res2->fetchInto($row2);
                while ($row2) {
                    $views .= $row2['view'];
                    if ($res2->fetchInto($row2)) {
                        $views .= ', ';
                    }
                }
                $res2->free();
                array_push($row, $views);
                array_push($row, "<a href=\"index.php?view=admin&amp;task=edit_group&amp;id={$row['group_id']}\">edit</a>" . ", <a href=\"index.php?view=admin&amp;task=del_group&amp;id={$row['group_id']}\">delete</a>");
                $table->addRow(array_values($row));
                $res->fetchInto($row);
            }
            $res->free();
            // decor
            $table->altRowAttributes(1, null, array("class" => "altrow"));
            echo '<div class="overflow">' . $table->toHtml() . '</div>';
            echo "<hr />";
            // form for adding a group
            $form = new HTML_QuickForm('addGroupForm', 'post', 'index.php?view=admin&task=groups');
            $form->addElement('header', null, 'Add a group');
            $form->addElement('text', 'name', 'Name: ');
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('name', 'trim');
            $form->addRule('name', 'Group name is required.', 'required', null, 'client');
            if ($form->validate()) {
                $res =& $db->autoExecute('groups', $form->getSubmitValues(), DB_AUTOQUERY_INSERT);
                if (PEAR::isError($res)) {
                    error($db->toString());
                }
                redirect('index.php?view=admin&task=groups');
            }
            $form->display();
            break;
        case 'del_group':
            db_query('del_group_by_id', $_GET['id']);
            redirect('index.php?view=admin&task=groups');
            break;
        case 'edit_group':
            // get list of views allowed for this group
            $group_views = array();
            $res =& db_query('views_by_group_id', $_GET['id']);
            while ($res->fetchInto($row)) {
                array_push($group_views, $row['view']);
            }
            $res->free();
            // get name of group
            $res =& db_query('group_by_id', $_GET['id']);
            $res->fetchInto($row);
            $name = $row['name'];
            $res->free();
            $form = new HTML_QuickForm('groupForm', 'post', 'index.php?view=admin&task=edit_group&id=' . $_GET['id']);
            $form->addElement('header', null, 'Views for group ' . $name . ' (id: ' . $_GET['id'] . ')');
            // get list of all available views
            $view_paths = glob($cfg['dir']['views'] . '/*.php');
            $views = array();
            // create the checkboxes, add each view to $views for later checking
            foreach ($view_paths as $path) {
                $tmp = explode('.', basename($path));
                $elem =& $form->addElement('checkbox', $tmp[0], $tmp[0]);
                if (in_array($tmp[0], $group_views)) {
                    $elem->setChecked(true);
                }
                array_push($views, $tmp[0]);
            }
            $form->addElement('submit', 'submit', 'Apply Changes');
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                foreach ($views as $view) {
                    $elem =& $form->getElement($view);
                    if ($data[$view] == 1) {
                        auth_set_view($_GET['id'], $view);
                        $elem->setChecked(true);
                    } else {
                        auth_clear_view($_GET['id'], $view);
                        $elem->setChecked(false);
                    }
                }
            }
            $form->display();
            break;
        case 'views':
            $table = new HTML_Table();
            $table->addRow(array('name', 'path'), null, 'TH');
            // display list of views
            $view_paths = glob($cfg['dir']['views'] . '/*.php');
            foreach ($view_paths as $path) {
                $tmp = explode('.', basename($path));
                $table->addRow(array($tmp[0], $path));
            }
            $table->altRowAttributes(1, null, array("class" => "altrow"));
            echo '<div class="overflow">' . $table->toHtml() . '</div>';
            ?>
<p>To add a view, just drop a .php view-module file inside the views directory.
You can remove a view by deleting or renaming the corresponding file
inside the views directory.
</p> 
		<?php 
            break;
        case 'contests':
            $table = new HTML_Table();
            $res =& db_query('contests_list');
            $res->fetchInto($row);
            if ($row) {
                // add contests table headers
                $headers = array_keys($row);
                array_push($headers, 'actions');
                $table->addRow($headers, null, 'TH');
                // add contests table records
                while ($row) {
                    // Get the handle of the manager for displaying
                    $manager_name = '[none]';
                    $res2 =& $db->query($cfg['sql']['user_by_id'], $row['manager']);
                    if (!PEAR::isError($res2)) {
                        $res2->fetchInto($row2);
                        $manager_name = $row2['handle'];
                        $res2->free();
                    }
                    $row['manager'] = $manager_name;
                    // add edit,delete actions
                    $row['actions'] = "<a href=\"index.php?view=admin&amp;task=edit_contest&amp;id={$row['contest_id']}\">edit</a>, " . "<a href=\"index.php?view=admin&amp;task=del_contest&amp;id={$row['contest_id']}\">delete</a>";
                    $table->addRow(array_values($row));
                    $res->fetchInto($row);
                }
                $res->free();
                // decoration
                $table->altRowAttributes(1, null, array("class" => "altrow"));
                echo '<div class="overflow">' . $table->toHtml() . '</div>';
            } else {
                ?>
<p>No contests added yet.</p>			
			<?php 
            }
            echo "<hr />";
            // get list of all available managers
            $res =& db_query('users_by_group_name', 'Managers');
            while ($res->fetchInto($row)) {
                $managers[$row['user_id']] = $row['handle'];
            }
            // form for adding a contest
            $form = new HTML_QuickForm('contestAddForm', 'post', selflink());
            $form->addElement('header', null, 'Add a contest');
            $form->addElement('text', 'name', 'Name:');
            $form->addElement('text', 'description', 'Description:');
            $elem =& $form->addElement('text', 'team_size', 'Size of team:');
            $form->addElement('select', 'division', 'Division:', $cfg['tcl']['divisions']);
            $elem->setValue('1');
            $date = getdate();
            $form->addElement('date', 'show_time', 'Activation time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'begin_time', 'Begin time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'end_time', 'End time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('select', 'manager', 'Contest manager:', $managers);
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('name', 'trim');
            $form->applyFilter('description', 'trim');
            $form->applyFilter('team_size', 'trim');
            $form->addRule('name', 'Contest name is required.', 'required', null, 'client');
            $form->addRule('manager', 'Contest manager is required.', 'required', null, 'client');
            $form->addRule('team_size', 'Team size is required.', 'required', null, 'client');
            // validate or display form
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $data['show_time'] = form2sql_datetime($data['show_time']);
                $data['begin_time'] = form2sql_datetime($data['begin_time']);
                $data['end_time'] = form2sql_datetime($data['end_time']);
                $db->autoExecute('contests', $data, DB_AUTOQUERY_INSERT);
                if (PEAR::isError($res)) {
                    error($db->toString());
                }
                redirect('index.php?view=admin&task=contests');
            } else {
                $form->display();
            }
            break;
        case 'del_contest':
            $res =& db_query('del_contest_by_id', $_GET['id']);
            redirect('index.php?view=admin&task=contests');
            break;
        case 'edit_contest':
            // contest to edit given as arg
            $res =& db_query('contest_by_id', $_GET['id']);
            $res->fetchInto($row);
            $res->free();
            // get list of all available managers
            $res =& db_query('users_by_group_name', 'Managers');
            while ($res->fetchInto($row2)) {
                $managers[$row2['user_id']] = $row2['handle'];
            }
            // form for editing the contest
            $form = new HTML_QuickForm('contestEditForm', 'post', selflink());
            $form->addElement('header', null, "Edit contest {$row['name']} (id: {$row['contest_id']})");
            $form->addElement('text', 'name', 'Name:');
            $form->addElement('text', 'description', 'Description:');
            $elem =& $form->addElement('text', 'team_size', 'Size of team:');
            $elem->setValue('1');
            $form->addElement('select', 'division', 'Division:', $cfg['tcl']['divisions']);
            $date = getdate();
            $form->addElement('date', 'show_time', 'Activation time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'begin_time', 'Begin time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'end_time', 'End time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('select', 'manager', 'Contest manager:', $managers);
            $form->addElement('text', 'rules', 'Rules URL:');
            $form->addElement('submit', null, 'Submit');
            // convert date format and dtore default values
            $row['show_time'] = sql2form_datetime($row['show_time']);
            $row['begin_time'] = sql2form_datetime($row['begin_time']);
            $row['end_time'] = sql2form_datetime($row['end_time']);
            $form->setDefaults($row);
            $form->applyFilter('name', 'trim');
            $form->applyFilter('description', 'trim');
            $form->applyFilter('team_size', 'trim');
            $form->addRule('name', 'Contest name is required.', 'required', null, 'client');
            $form->addRule('manager', 'Contest manager is required.', 'required', null, 'client');
            $form->addRule('team_size', 'Team size is required.', 'required', null, 'client');
            // validate or display form
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $data['show_time'] = form2sql_datetime($data['show_time']);
                $data['begin_time'] = form2sql_datetime($data['begin_time']);
                $data['end_time'] = form2sql_datetime($data['end_time']);
                $db->autoExecute('contests', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id']);
                if (PEAR::isError($res)) {
                    error($db->toString());
                }
                redirect('index.php?view=admin&task=contests');
            } else {
                $form->display();
            }
            break;
        case 'shell':
            $form = new HTML_QuickForm('shellForm', 'post', selflink());
            $field =& $form->addElement('text', 'command', 'Command:');
            $field->setSize(100);
            $ifield =& $form->addElement('textarea', 'input', 'Standard Input:');
            $ifield->setRows(10);
            $ifield->SetCols(80);
            $form->addElement('submit', null, 'Submit');
            $form->display();
            if ($form->validate()) {
                // Write std input file
                $iname = tempnam("/tmp", "in");
                $ifile = fopen($iname, 'w');
                fwrite($ifile, $form->getSubmitValue('input'));
                fclose($ifile);
                $cmd = $form->getSubmitValue('command');
                echo "<pre class=\"shell_output\">";
                echo "<b>\$ " . html_escape($cmd) . "</b>\n";
                exec("{$cmd} 2>&1 < {$iname}", $out, $ret);
                foreach ($out as $line) {
                    echo html_escape($line) . "\n";
                }
                echo "</pre>\n";
                echo "<p>Command returned: {$ret}</p>\n";
            }
            break;
        case 'uploader':
            // Get list of directories to which files can be uploaded
            $dirs = subdir_list('.');
            array_unshift($dirs, './');
            $form = new HTML_QuickForm('uploaderForm', 'post', selflink());
            $form->addElement('header', null, 'Upload a File:');
            $file =& $form->addElement('file', 'file', 'File:');
            $form->addElement('select', 'dir', 'Destination:', $dirs);
            $form->addElement('submit', 'upload', 'Upload');
            $form->addRule('file', 'Please select file to upload.', 'required', null, 'client');
            $form->setMaxFileSize(10485760);
            // try 10 MB max file size
            if ($form->validate()) {
                if ($file->isUploadedFile()) {
                    $dir = $dirs[$form->getSubmitValue('dir')];
                    if ($file->moveUploadedFile($dir)) {
                        echo "<p>File uploaded successfully to {$dir}.</p>";
                    } else {
                        echo "<p>Failed to save uploaded file to {$dir} (insufficient permissions?).</p>";
                    }
                } else {
                    echo "<p>File upload did not finish successfully</p>";
                }
            }
            $form->display();
            echo "<p><b>Note:</b> Any previous file with the same name will be replaced.</p>";
            echo "<hr />";
            $form = new HTML_QuickForm('mkdirForm', 'post', selflink());
            $form->addElement('header', null, 'Create a Directory:');
            $form->addElement('text', 'name', 'Name:');
            $form->addElement('select', 'dir', 'Destination:', $dirs);
            $form->addElement('submit', 'mkdir', 'Mkdir');
            $form->addRule('name', 'Please enter directory name.', 'required', null, 'client');
            if ($form->validate()) {
                $path = $dirs[$form->getSubmitValue('dir')] . '/' . $form->getSubmitValue('name');
                if (file_exists($path)) {
                    echo "<p><b>Warning:</b> File or directory {$path} already exists.</p>";
                } else {
                    if (mkdir($path)) {
                        echo "<p>Directory {$path} created.</p>";
                    } else {
                        echo "<p>Failed to create directory {$path}. Make sure parent directory permissions allow it.</p>";
                    }
                }
            }
            $form->display();
            break;
        case 'phpinfo':
            phpinfo();
            break;
    }
}
예제 #24
0
    unset($pdh);
    return $flag;
}
if (isset($_SESSION['username'])) {
    // save the username to use as the defualt and then wipe the cookie clean
    $default_username = $_SESSION['username'];
    session_unset();
    # save the default username to the session so it's there even after a reload
    $_SESSION['loginname'] = $default_username;
}
if (isset($_SESSION['loginname'])) {
    $default_username = $_SESSION['loginname'];
}
# create the form and validation rules
$login_form = new HTML_QuickForm('login');
$login_form->applyFilter('__ALL__', 'trim');
$login_form->addElement('header', null, 'Login to the <a href="http://code.google.com/p/trader-dss/">Trader DSS</a>. Authorised users only');
$login_form->addElement('text', 'username', 'Username:'******'size' => 30, 'maxlength' => 100));
$login_form->addRule('username', 'Please enter your username', 'required');
$login_form->addElement('password', 'passwd', 'Password:'******'size' => 10, 'maxlength' => 100));
$login_form->addRule(array('username', 'passwd'), 'Account details incorrect', 'callback', 'check_account');
$login_form->addRule('passwd', 'Must enter a password', 'required');
$login_form->addElement('submit', 'login', 'Login');
if (isset($default_username)) {
    $login_form->setDefaults(array('username' => $default_username));
}
$g_username = '';
# global to hold the username
$g_uid = '';
# global to hold the uid
if ($login_form->validate()) {
예제 #25
0
function manage_display($task)
{
    global $cfg, $db, $cache;
    if ($task == '') {
        $task = 'status';
    }
    // Verify that the user has management perms for the selected contest
    $res =& db_query('contest_by_id', $_GET['id']);
    $res->fetchInto($row);
    $res->free();
    if ($_SESSION['user_id'] != $row['manager'] && !auth_user_in_group('Administrators')) {
        error("Access denied. You are not the contest-manager for this contest.");
    }
    switch ($task) {
        case 'status':
            $table = new HTML_Table();
            // Re-use $row from above
            if ($row['show_future'] == 1) {
                $status = 'Hidden (not activated yet)';
            } else {
                if ($row['begin_future'] == 1) {
                    $status = 'Not started';
                } else {
                    if ($row['end_future'] == 1) {
                        $status = 'Running';
                    } else {
                        $status = 'Ended';
                    }
                }
            }
            $table->addRow(array('Contest status: ', $status), null, 'TH');
            $table->addRow(array('Name: ', $row['name']));
            $table->addRow(array('Description: ', $row['description']));
            $table->addRow(array('Activation time: ', $row['show_time']));
            $table->addRow(array('Begin time: ', $row['begin_time']));
            $table->addRow(array('End time: ', $row['end_time']));
            if ($row['team_size'] != 1) {
                $table->addRow(array('Max size of team: ', $row['team_size']));
                $prefix = 'Teams';
            } else {
                $table->addRow(array('Individual event: ', 'Yes'));
                $prefix = 'Participants';
            }
            // No. of registered teams
            $res =& db_query('count_teams_by_contest_id', $_GET['id']);
            $res->fetchInto($row);
            $res->free();
            $table->addRow(array($prefix . ' registered: ', $row['count']));
            // No. of teams logged in
            $res =& db_query('count_last_teams_by_contest_id', $_GET['id']);
            $res->fetchInto($row);
            $res->free();
            $table->addRow(array($prefix . ' seen in last 30 minutes: ', $row['count']));
            $table->altRowAttributes(1, null, array("class" => "altrow"));
            echo '<div class="overflow">' . $table->toHtml() . '</div>';
            break;
        case 'problems':
            // display problem info as table
            $table = new HTML_Table();
            $res =& db_query('problems_by_contest_id', $_GET['id']);
            if (!$res->fetchInto($row)) {
                ?>
<p>No problems added yet.</p>			
			<?php 
            } else {
                // extra attributes
                $row['content'] = null;
                $row['actions'] = null;
                $table->addRow(array_keys($row), null, 'TH');
                while ($row) {
                    $row['content'] = "<a href=\"index.php?view=manage&amp;task=show_problem&amp;id={$_GET['id']}&amp;prob_id={$row['prob_id']}\">show</a>";
                    $row['actions'] = "<a href=\"index.php?view=manage&amp;task=edit_problem&amp;id={$_GET['id']}&amp;prob_id={$row['prob_id']}\">edit</a>, " . "<a href=\"index.php?view=manage&amp;task=del_problem&amp;id={$_GET['id']}&amp;prob_id={$row['prob_id']}\">delete</a>";
                    $table->addRow(array_values($row));
                    $res->fetchInto($row);
                }
                $res->free();
                // display tables
                $table->altRowAttributes(1, null, array("class" => "altrow"));
                echo '<div class="overflow">' . $table->toHtml() . '</div>';
            }
            echo "<hr />";
            // form for adding a problem
            $form = new HTML_QuickForm('problemAddForm', 'post', selflink());
            $form->addElement('header', null, 'Add a problem');
            $form->addElement('text', 'prob_id', 'Name (one word ID): ');
            $form->addElement('text', 'summary', 'Summary: ');
            $form->addElement('text', 'weight', 'Points weightage: ');
            $form->addElement('text', 'time_limit', 'Time limit: ');
            $form->addElement('text', 'mem_limit', 'Memory limit: ');
            $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): ');
            $elem->setRows(10);
            $elem->setCols(80);
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('prob_id', 'trim');
            $form->applyFilter('summary', 'trim');
            $form->applyFilter('weight', 'trim');
            $form->applyFilter('time_limit', 'trim');
            $form->applyFilter('mem_limit', 'trim');
            $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client');
            $form->addRule('summary', 'Problem summary is required', 'required', null, 'client');
            $form->addRule('weight', 'Points weightage is required', 'required', null, 'client');
            $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client');
            $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client');
            $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client');
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $errs = problem_check($data['content']);
                if ($errs == null) {
                    $data['contest_id'] = $_GET['id'];
                    $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_INSERT);
                    if (PEAR::isError($res)) {
                        error($res->toString());
                    }
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm');
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob');
                    redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
                } else {
                    ?>
<p><b>Error:</b> The problem could not be added due to the following errors encountered while
parsing the problem XML file. Please fix them and try submitting again.</p>
				<?php 
                    echo "<ol class=\"errors\">\n";
                    foreach ($errs as $line) {
                        echo "<li>{$line}</li>\n";
                    }
                    echo "</ol>\n<hr />\n";
                }
            }
            $form->display();
            break;
        case 'del_problem':
            db_query('del_problem_by_id', array($_GET['prob_id'], $_GET['id']));
            redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
            break;
        case 'edit_problem':
            $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id']));
            $res->fetchInto($row);
            $res->free();
            // Get XML content too
            $res =& db_query('problem_content_by_id', array($_GET['prob_id'], $_GET['id']));
            $res->fetchInto($row2);
            $res->free();
            $row['content'] =& $row2['content'];
            // form for editing a problem
            $form = new HTML_QuickForm('problemAddForm', 'post', selflink());
            $form->addElement('header', null, 'Edit a problem');
            $form->addElement('text', 'prob_id', 'Name (one word ID): ');
            $form->addElement('text', 'summary', 'Summary: ');
            $form->addElement('text', 'weight', 'Points weightage: ');
            $form->addElement('text', 'time_limit', 'Time limit: ');
            $form->addElement('text', 'mem_limit', 'Memory limit: ');
            $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): ');
            $elem->setRows(10);
            $elem->setCols(80);
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('prob_id', 'trim');
            $form->applyFilter('summary', 'trim');
            $form->applyFilter('weight', 'trim');
            $form->applyFilter('time_limit', 'trim');
            $form->applyFilter('mem_limit', 'trim');
            $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client');
            $form->addRule('summary', 'Problem summary is required', 'required', null, 'client');
            $form->addRule('weight', 'Points weightage is required', 'required', null, 'client');
            $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client');
            $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client');
            $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client');
            $form->setDefaults($row);
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $errs = problem_check($data['content']);
                if ($errs == null) {
                    //$data['contest_id'] = $_GET['id'];
                    $data['version'] = $row['version'] + 1;
                    // increment version
                    $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id'] . " AND prob_id='" . $data['prob_id'] . "'");
                    if (PEAR::isError($res)) {
                        error($res->toString());
                    }
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm');
                    $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob');
                    redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
                } else {
                    ?>
<p><b>Error:</b> The changes could not be saved due to the following errors encountered while
parsing the problem XML file. Please fix them and try submitting again.</p>
				<?php 
                    echo "<ol class=\"errors\">\n";
                    foreach ($errs as $line) {
                        echo "<li>{$line}</li>\n";
                    }
                    echo "</ol>\n<hr />\n";
                }
            }
            $form->display();
            break;
        case 'show_problem':
            $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id']));
            $res->fetchInto($problem);
            $res->free();
            problem_display($problem);
            break;
        case 'settings':
            // Re-using $row from above
            // form for editing the contest
            $form = new HTML_QuickForm('contestEditForm', 'post', selflink());
            $form->addElement('header', null, "Edit contest {$row['name']} (id: {$row['contest_id']})");
            $form->addElement('text', 'name', 'Name: ');
            $form->addElement('text', 'description', 'Description: ');
            $elem =& $form->addElement('text', 'team_size', 'Size of team: ');
            $elem->setValue('1');
            $date = getdate();
            $form->addElement('date', 'show_time', 'Activation time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'begin_time', 'Begin time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('date', 'end_time', 'End time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5));
            $form->addElement('text', 'rules', 'Rules URL: ');
            $form->addElement('submit', null, 'Submit');
            // convert date format and store default values
            $row['show_time'] = sql2form_datetime($row['show_time']);
            $row['begin_time'] = sql2form_datetime($row['begin_time']);
            $row['end_time'] = sql2form_datetime($row['end_time']);
            $form->setDefaults($row);
            $form->applyFilter('name', 'trim');
            $form->applyFilter('description', 'trim');
            $form->applyFilter('team_size', 'trim');
            $form->addRule('name', 'Contest name is required.', 'required', null, 'client');
            $form->addRule('team_size', 'Team size is required.', 'required', null, 'client');
            // validate or display form
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                $data['show_time'] = form2sql_datetime($data['show_time']);
                $data['begin_time'] = form2sql_datetime($data['begin_time']);
                $data['end_time'] = form2sql_datetime($data['end_time']);
                $db->autoExecute('contests', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id']);
                if (PEAR::isError($res)) {
                    error($db->toString());
                }
                redirect('index.php?view=manage&id=' . $_GET['id']);
            } else {
                $form->display();
            }
            break;
        case 'submissions':
            // Re-use $row from above
            if ($row['end_future'] != '1') {
                // Contest has ended, show system test button
                if ($row['tested'] != 1) {
                    ?>
    <p>Contest has ended. 
    <a class="button" href="index.php?view=manage&amp;&amp;task=test&amp;updateratings=false&amp;id=<?php 
                    echo $_GET['id'];
                    ?>
">Test and grade all submissions.</a>
    <a class="button" href="index.php?view=manage&amp;task=test&amp;updateratings=true&amp;id=<?php 
                    echo $_GET['id'];
                    ?>
">Update Ratings</a>

    </p>
                <?php 
                } else {
                    ?>
    <p>Contest has ended and system tests are over.
    <a class="button" href="index.php?view=manage&amp;task=test&amp;id=<?php 
                    echo $_GET['id'];
                    ?>
">Re-run system tests.</a>
    </p>
                <?php 
                }
            }
            // Show table of all solutions in the contest
            $table = new HTML_Table();
            $res =& db_query('solutions_by_contest_id', $_GET['id']);
            if (!$res->fetchInto($row)) {
                // If no solutions in yet
                ?>
<p>Sorry, no solutions have been submitted yet.</p>
			<?php 
            } else {
                $table->addRow(array_keys($row), null, 'TH');
                if ($row['score'] == '') {
                    $row['score'] = 'n/a';
                }
                if ($row['passed'] == '') {
                    $row['passed'] = 'n/a';
                }
                $table->addRow(array_values($row));
                while ($res->fetchInto($row)) {
                    if ($row['score'] == '') {
                        $row['score'] = 'n/a';
                    }
                    if ($row['passed'] == '') {
                        $row['passed'] = 'n/a';
                    }
                    $table->addRow(array_values($row));
                }
                $table->altRowAttributes(1, null, array("class" => "altrow"));
                echo '<div class="overflow">' . $table->toHtml() . '</div>';
            }
            break;
        case 'test':
            require_once 'tester.php';
            ob_end_clean();
            html_reset();
            html_header(null, $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '.css', $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '-ie.css', null, "submit_frame");
            $contest_id = $_GET['id'];
            $update_ratings = $_GET['updateratings'];
            session_write_close();
            test_contest($update_ratings, $contest_id);
            echo ' <a class="white" href="index.php?view=statistics&amp;task=contest&amp;id=' . $_GET['id'] . '">See the results.</a>';
            html_footer();
            exit;
    }
}
$form->addElement('hidden', 'story_id');
$form->addElement('text', 'subject', 'Subject', array('size' => 50, 'maxlength' => 255));
$form->addElement('textarea', 'body', 'Password', array('size' => 50, 'maxlength' => 1000));
$form->addElement('submit', null, 'Update Story!');
// Set defaults for the form elements
$storysql = "SELECT * FROM story WHERE id = " . $storyid . ";";
//$storyres = mysql_query($storysql);
//$storyrow = mysql_fetch_assoc($storyres);
$storyres = $db->query($storysql);
$storyrow = $storyres->fetchAll(PDO::FETCH_ASSOC);
$form->setDefaults(array('story_id' => $storyid));
$form->setDefaults(array('cat_id' => $storyrow[0]['cat_id']));
$form->setDefaults(array('subject' => $storyrow[0]['subject']));
$form->setDefaults(array('body' => $storyrow[0]['body']));
// Define filters and validation rules
$form->applyFilter('subject', 'trim');
$form->addRule('subject', 'Please enter your username', 'required', null, 'client');
$form->applyFilter('body', 'trim');
$form->addRule('body', 'Please enter your username', 'required', null, 'client');
// if form validates, freeze the data and process it
if ($form->validate()) {
    $form->freeze();
    $form->process("process_data", false);
} else {
    $form->display();
}
// process form data ($values = name/value pairs
function process_data($values)
{
    global $db;
    $sql = "UPDATE story SET cat_id = " . $values['cat_id'] . ", poster_id = " . $_SESSION['POSTERID'] . ", subject = '" . $values['subject'] . "'" . ", body = '" . $values['body'] . "' WHERE id = " . $values['story_id'] . ";";
예제 #27
0
 /**
  * _addForm 
  * 
  * Create add form
  * 
  * @access private
  * @return void
  */
 private function _addForm()
 {
     $form = new HTML_QuickForm('addAliasDomainForm', 'post', './?module=Main&class=AliasDomain&event=addNow');
     $form->addElement('text', 'domain', _('Real Domain'));
     $form->addElement('text', 'alias', _('Alias Domain'));
     $form->addElement('submit', 'submit', _('Add'));
     $form->addRule('domain', _('Please specify a Real Domain'), 'required', null, 'client');
     $form->addRule('alias', _('Please specify an Alias Domain'), 'required', null, 'client');
     $form->applyFilter('__ALL__', 'trim');
     return $form;
 }
예제 #28
0
파일: write.php 프로젝트: vijo/writetothem
function buildWriteForm($options)
{
    global $fyr_values, $stash;
    global $fyr_voting_area;
    global $cobrand, $cocode;
    $form_action = cobrand_url($cobrand, '/write', $cocode);
    $form = new HTML_QuickForm('writeForm', 'post', $form_action);
    if ($fyr_voting_area['name'] == 'United Kingdom') {
        $fyr_voting_area['name'] = 'House of Lords';
    }
    $write_header = '';
    $form->addElement('textarea', 'body', null, array('class' => 'message'));
    $form->addRule('body', 'Please enter your message', 'required', null, null);
    $form->addRule('body', 'Please enter your message', new RuleAlteredBodyText(), null, null);
    $form->addRule('body', 'Please sign at the bottom with your name, or alter the "Yours sincerely" signature', new RuleSigned(), null, null);
    $form->addRule('body', 'Your message is a bit too long for us to send', 'maxlength', OPTION_MAX_BODY_LENGTH);
    $form->addElement('html', '<div class="row">');
    $form->addElement('html', '<fieldset class="large-6 columns">');
    $form->addElement('html', '<legend>About You</legend>');
    $form->addElement('text', 'name', "Your name", array('required' => 'required', 'maxlength' => 255));
    $form->addRule('name', 'Please enter your name', 'required', null, null);
    $form->applyFilter('name', 'trim');
    $form->addElement('text', 'writer_email', "Your email", array('required' => 'required', 'maxlength' => 255));
    $form->addRule('writer_email', 'Please enter your email address', 'required', null, null);
    $invalid_email_message = cobrand_invalid_email_message($cobrand);
    if (!$invalid_email_message) {
        $invalid_email_message = 'Choose a valid email address';
    }
    $form->addRule('writer_email', $invalid_email_message, 'email', null, null);
    $form->applyFilter('writer_email', 'trim');
    $form->addElement('text', 'writer_email2', "Confirm email", array('required' => 'required', 'maxlength' => 255));
    $form->addRule('writer_email2', 'Please re-enter your email address', 'required', null, null);
    $form->applyFilter('writer_email2', 'trim');
    $form->addFormRule('compare_email_addrs');
    $form->updateElementAttr(array('writer_email', 'writer_email2'), array('type' => 'email'));
    $form->addElement('text', 'writer_phone', 'Phone <span class="optional-text">optional</span>', array('maxlength' => 255));
    $form->applyFilter('writer_phone', 'trim');
    $form->addElement("html", "</fieldset>");
    $form->addElement("html", '<fieldset class="large-6 columns">');
    $form->addElement("html", '<legend>Your Address</legend>');
    $form->addElement('text', 'writer_address1', "Address Line 1", array('required' => 'required', 'maxlength' => 255));
    $form->addRule('writer_address1', 'Please enter your address', 'required', null, null);
    $form->applyFilter('writer_address1', 'trim');
    $form->addElement('text', 'writer_address2', 'Address Line 2 <span class="optional-text">optional</span>', array('maxlength' => 255));
    $form->applyFilter('writer_address2', 'trim');
    $form->addElement('text', 'writer_town', "Town/City", array('required' => 'required', 'maxlength' => 255));
    $form->addRule('writer_town', 'Please enter your town/city', 'required', null, null);
    $form->applyFilter('writer_town', 'trim');
    $form->addElement('html', '<div class="row">');
    $form->addElement('html', '<div class="small-8 columns">');
    # Call it state so that Google Toolbar (and presumably others) can auto-fill.
    $form->addElement('text', 'state', 'County <span class="optional-text">optional</span>', array('maxlength' => 255));
    $form->applyFilter('state', 'trim');
    $form->addElement('html', '</div>');
    $form->addElement('html', '<div class="small-4 columns">');
    if (is_postcode_editable($fyr_voting_area['type'])) {
        // House of Lords
        $form->addElement('text', 'pc', "UK postcode", array('required' => 'required', 'maxlength' => 8));
        $form->addRule('pc', 'Please enter a UK postcode (<a href="/about-lords#ukpostcode" target="_blank">why?</a>)', 'required', null, null);
        $form->addRule('pc', 'Please enter a valid UK postcode (<a href="/about-lords#ukpostcode" target="_blank">why?</a>)', new RulePostcode(), null, null);
        $form->applyFilter('pc', 'trim');
    } else {
        // All other representatives (postcode fixed as must be in constituency)
        $form->addElement('text', 'staticpc', "UK postcode", array('disabled' => 'disabled', 'value' => htmlentities($fyr_values['pc'])));
    }
    $form->addElement('html', '</div>');
    $form->addElement('html', '</div>');
    $form->addElement("html", "</fieldset>");
    $form->addElement('html', '</div>');
    # close div.row
    $form->addElement("html", '<fieldset class="last"><legend>Ready?</legend>');
    add_all_variables_hidden($form, $fyr_values, $options);
    $preview_text = cobrand_preview_text($cobrand);
    if (!$preview_text) {
        $preview_text = "When you’re ready to send your message click the button below. You’ll get a chance to read through it again to check for problems before we send it.";
    }
    $preview_button_text = cobrand_preview_button_text($cobrand);
    if (!$preview_button_text) {
        $preview_button_text = 'Preview and send';
    }
    $form->addElement('html', "<p class=\"action\" id=\"preview-submit\">{$preview_text}</p>");
    $form->addElement('submit', 'submitPreview', $preview_button_text, array('class' => 'button radius success'));
    $form->addElement("html", "</fieldset>");
    return $form;
}
예제 #29
0
 /**
  * limitsForm 
  * 
  * Create limits form
  * 
  * @access protected
  * @return HTML_QuickForm object
  */
 protected function limitsForm()
 {
     $defaults = $this->user->getLimits($this->domain);
     // To MB
     if ($defaults['default_quota'] > 0) {
         $defaults['default_quota'] = $defaults['default_quota'] / 1024 / 1024;
     }
     $url = './?module=Main&class=Limits&event=modifyLimitsNow&domain=';
     $url .= $this->domain;
     $form = new HTML_QuickForm('limitsForm', 'post', $url);
     $form->setDefaults($defaults);
     $form->addElement('text', 'max_aliases', _('Maximum Aliases (-1 for unlimited)'), array('size' => 4));
     $form->addElement('text', 'max_forwards', _('Maximum Forwards (-1 for unlimited)'), array('size' => 4));
     $form->addElement('text', 'max_autoresponders', _('Maximum Mail Robots (-1 for unlimited)'), array('size' => 4));
     $form->addElement('text', 'max_mailinglists', _('Maximum EZMLM-IDX Mailing Lists (-1 for unlimited)'), array('size' => 4));
     $form->addElement('text', 'default_quota', _('Default Quota in MB (0 for unlimited)'), array('size' => 4));
     $form->addElement('text', 'default_maxmsgcount', _('Default Message Count Limit (0 for unlimited)'), array('size' => 4));
     $form->addElement('checkbox', 'disable_pop', _('Disable POP'));
     $form->addElement('checkbox', 'disable_imap', _('Disable IMAP'));
     $form->addElement('checkbox', 'disable_dialup', _('Disable Dial-Up'));
     $form->addElement('checkbox', 'disable_password_changing', _('Disable Password Changing'));
     $form->addElement('checkbox', 'disable_webmail', _('Disable Webmail (SqWebmail)'));
     $form->addElement('checkbox', 'disable_external_relay', _('Disable Relaying'));
     $form->addElement('checkbox', 'disable_smtp', _('Disable SMTP-AUTH'));
     $form->addElement('submit', 'submit', _('Modify'));
     $form->registerRule('minusOne', 'regex', '/^(-1|[0-9]+)$/');
     $form->registerRule('zero', 'regex', '/^(0|[1-9][0-9]+)$/');
     $form->addRule('max_aliases', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client');
     $form->addRule('max_forwards', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client');
     $form->addRule('max_autoresponders', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client');
     $form->addRule('max_mailinglists', _('Error: only integers of -1 and greater allowed here'), 'minusOne', null, 'client');
     $form->addRule('default_quota', _('Error: only integers of 0 and greater allowed here'), 'zero', null, 'client');
     $form->addRule('default_maxmsgcount', _('Error: only integers of 0 and greater allowed here'), 'zero', null, 'client');
     $form->applyFilter('__ALL__', 'trim');
     return $form;
 }
예제 #30
0
function submit_field($contest_id, $team_id, &$problem, $practiceMode = false)
{
    global $cfg;
    if ($practiceMode == true) {
        // Check for running contests in practice mode
        $res =& db_query('count_running_contests');
        $res->fetchInto($count);
        if ($count['count'] > 0) {
            ?>
            <p class="system_info"><b>Sorry, solution form is disabled in practice mode.</b><br />
            This is to preserve server resources for the running contest. Practice submissions will be re-enabled when that contest is over.</p>
            <?php 
            return;
        }
    }
    html_include_js($cfg['dir']['scripts'] . '/editor.js');
    $langs = language_list();
    $languages = array();
    foreach ($langs as $lang) {
        require_once $cfg['dir']['languages'] . '/' . $lang . '.php';
        $func = 'lang_' . $lang . '_description';
        $languages[$lang] = $func();
    }
    $lang = $langs[0];
    $source = '';
    $res =& db_query('draft_by_user', array($_SESSION['user_id']));
    if ($res->fetchInto($draft)) {
        if ($draft['contest_id'] == $contest_id && $draft['prob_id'] == $problem['prob_id']) {
            $lang = $draft['language'];
            $source = $draft['source'];
        }
    }
    // Code editing form
    $form = new HTML_QuickForm('submitForm', 'post', selflink() . '#results');
    $e =& $form->addElement('select', 'language', 'Language: ', $languages);
    if (!isset($_POST['language'])) {
        $e->setValue($lang);
    }
    $e =& $form->addElement('textarea', 'source', 'Code: ', array('rows' => 12, 'class' => 'editor'));
    if (!isset($_POST['source'])) {
        $e->setValue($source);
    }
    $form->addElement('html', "\n" . '<tr><td align="right" valign="top"><div id="custom_input1" style="display:none"><b>Custom<br/>Input: </b></div></td>
    		<td><div id="custom_input2" style="display:none"><textarea rows="4" class="editor" name="custom">' . $_POST['custom'] . '</textarea></div></td></tr>' . "\n");
    $form->addElement('html', "\n" . '<tr><td align="right" valign="top"></td><td valign="top" align="left"><input name="test" value="Compile and Test" type="submit"/>
    		<input onclick="handleTestButton()" id="custom_button" name="customb" value="Test with custom input" type="button" />' . "\n");
    if ($practiceMode == false) {
        $form->addElement('html', ' <input name="submitit" value="Submit" type="submit" /></td></tr>');
    } else {
        $form->addElement('html', '</td></tr>');
    }
    $form->applyFilter('source', 'trim');
    //$form->addRule('source', 'Source code area is blank! Refusing to accept.', 'required', null, 'client');
    // Display some text & the form
    ?>
<div class="mimic_para">
<a id="shortcuts_link" onclick="toggleShowShortcuts()" href="#solution">[+] Useful Editor Shortcuts:</a>
<div id="shortcuts"></div>
</div>
<?php 
    html_javascript_check();
    html_rounded_box_open();
    $form->display();
    echo '<div id="edit_status"></div>';
    html_rounded_box_close();
    if ($form->validate()) {
        echo "<a name=\"results\"></a>";
        ?>
<p class="lower"><b>Tester:</b><br /> Please be patient while your code is being compiled and tested.
Results will be displayed in the frame below.</p>
<?php 
        $solution =& $form->getSubmitValues();
        $mode = "";
        if ($practiceMode) {
            $mode = "practice";
        } else {
            if (isset($solution['submitit'])) {
                $mode = "submit";
            }
        }
        if ($id = submit_record($contest_id, $problem['prob_id'], $solution, $mode)) {
            html_rounded_box_open();
            ?>
<iframe width="90%" height="300" scrolling="yes" src="<?php 
            echo "progress.php?id={$id}";
            ?>
">
<!-- Following gets displayed if IFRAME is not supported -->
<b>Your browser is not supported!</b><br />
Please upgrade your browser, as it lacks basic support for inline-frames,
which is necessary for this feature. Recommended browsers are 
<a href="http://www.getfirefox.com">Mozilla/Firefox</a>,
Internet Explorer 5.0+ and Opera 7.0+.
</iframe>
            <?php 
            html_rounded_box_close();
        }
    }
}