예제 #1
1
 function handle(&$params)
 {
     if (!@$_REQUEST['email']) {
         return PEAR::raiseError("No email address  specified");
     }
     import('HTML/QuickForm.php');
     $form = new HTML_QuickForm('opt_out_form', 'post');
     $form->addElement('hidden', 'email', $_REQUEST['email']);
     $form->addElement('hidden', '-action', 'email_opt_out');
     $form->addElement('submit', 'submit', 'Cancel Subscription');
     if ($form->validate()) {
         $res = mysql_query("replace into dataface__email_blacklist (email) values ('" . addslashes($_REQUEST['email']) . "')", df_db());
         if (!$res) {
             trigger_error(mysql_error(df_db()), E_USER_ERROR);
         }
         header('Location: ' . DATAFACE_SITE_HREF . '?--msg=' . urlencode('You have successfully opted out of our mail list.  You will no longer receive emails from us.'));
         exit;
     }
     ob_start();
     $form->display();
     $html = ob_get_contents();
     ob_end_clean();
     $context = array();
     $context['form'] = $html;
     df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
     df_display($context, 'email/opt_out_form.html');
 }
예제 #2
0
 /**
  * function_description
  *
  * @author	John.meng
  * @since    version - Jan 5, 2006
  * @param	datatype paramname description
  * @return   datatype description
  */
 function drawLogin()
 {
     global $__Lang__, $UrlParameter, $SiteDB, $AddIPObj, $FlushPHPObj, $form, $smarty;
     include_once PEAR_DIR . 'HTML/QuickForm.php';
     $form = new HTML_QuickForm('firstForm');
     $replace_str = "../";
     $html_code = str_replace(ROOT_DIR, $replace_str, THEMES_DIR);
     echo "<link href='" . $html_code . "style.css' rel='stylesheet' type='text/css'>";
     $renderer =& $form->defaultRenderer();
     $renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" class=\"log_table\" align=\"center\">\n{content}\n</table>\n</form>");
     $renderer->setHeaderTemplate("\n\t<tr>\n\t\t<td class=\"log_table_head\" align=\"left\" valign=\"top\" colspan=\"2\" ><b>{header}</b></td>\n\t</tr>");
     $form->addElement('header', null, "<img src=\"" . $html_code . "images/logo.gif\" border=\"0\" >");
     $form->addElement('text', 'user_name', $__Lang__['langMenuUser'] . $__Lang__['langGeneralName'] . ' : ');
     $form->addElement('password', 'user_passwd', $__Lang__['langMenuUser'] . $__Lang__['langGeneralPassword'] . ' : ');
     $form->addRule('user_name', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langMenuUser'] . " " . $__Lang__['langGeneralName'], 'required');
     $form->addRule('user_passwd', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langMenuUser'] . " " . $__Lang__['langGeneralPassword'], 'required');
     $form->addElement('hidden', 'Action', 'LOGON');
     $form->setDefaults(array('user_name' => $_COOKIE['UserName']));
     $form->addElement('submit', null, $__Lang__['langGeneralSubmit']);
     $form->addElement('static', 'login_message');
     if ($form->validate() && $_POST['Action'] == 'LOGON') {
         $user_name = $_POST['user_name'];
         $user_password = md5($_POST['user_passwd']);
         $this->checkAuth($user_name, $user_password);
     }
     $form->display();
     exit;
 }
function makeExportForm($selfurl, $inbox)
{
    global $uid;
    $form = new HTML_QuickForm('export', 'post', "{$selfurl}&op=export&noheaderfooter=true");
    $msg = "<p>You can export this data as a CSV (comma-separated values) file, " . "<br/>which can then be imported into Excel for analysis and graphing." . "</p><br/>";
    $form->addElement('header', '', 'Export');
    $form->addElement('static', '', '', $msg);
    $datatype = $form->addElement('select', 'datatype', "Export What", array(EXPORT_ALLDATA => 'All Data', EXPORT_HISTOGRAM_MSG => 'Histogram by Message', EXPORT_HISTOGRAM_DAY => 'Histogram by Day', EXPORT_HISTOGRAM_MONTH => 'Histogram by Month'));
    $form->addElement('submit', 'submit', 'Export');
    if ($form->validate()) {
        $datatypeval = $datatype->getValue();
        switch ($datatypeval[0]) {
            case EXPORT_ALLDATA:
                exportAllData($inbox);
                break;
            default:
                $uidquery = $uid;
                if (isadmin() && !$uid) {
                    unset($uidquery);
                }
                if ($inbox) {
                    $counts = generateHistogramInbox($datatypeval[0], $uid);
                } else {
                    $counts = generateHistogramOutbox($datatypeval[0], $uid);
                }
                $filename = $inbox ? 'inbox-hist-export.csv' : 'outbox-hist-export.csv';
                exportHistogram($counts, $filename);
                break;
        }
        exit;
    }
    $form->display();
}
예제 #4
0
파일: Modules.php 프로젝트: cretzu89/EPESI
 public function body()
 {
     ob_start();
     //create default module form
     print '<div class="title">Select modules to disable</div>';
     print 'Selected modules will be marked as not installed but uninstall methods will not be called. Any database tables and other modifications made by modules\' install methods will not be reverted.<br><br>';
     print 'To uninstall module please use Modules Administration in Application.';
     print '<hr/><br/>';
     $form = new HTML_QuickForm('modulesform', 'post', $_SERVER['PHP_SELF'] . '?' . http_build_query($_GET), '', null, true);
     $states = array(ModuleManager::MODULE_ENABLED => 'Active', ModuleManager::MODULE_DISABLED => 'Inactive');
     $modules = DB::GetAssoc('SELECT * FROM modules ORDER BY state, name');
     foreach ($modules as $m) {
         $name = $m['name'];
         $state = isset($m['state']) ? $m['state'] : ModuleManager::MODULE_ENABLED;
         if ($state == ModuleManager::MODULE_NOT_FOUND) {
             $state = ModuleManager::MODULE_DISABLED;
         }
         $form->addElement('select', $name, $name, $states);
         $form->setDefaults(array($name => $state));
     }
     $form->addElement('button', 'submit_button', 'Save', array('class' => 'button', 'onclick' => 'if(confirm("Are you sure?")) document.modulesform.submit();'));
     //validation or display
     if ($form->validate()) {
         //uninstall
         $vals = $form->exportValues();
         foreach ($vals as $k => $v) {
             if (isset($modules[$k]['state']) && $modules[$k]['state'] != $v) {
                 ModuleManager::set_module_state($k, $v);
             }
         }
     }
     $form->display();
     return ob_get_clean();
 }
예제 #5
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $this->table =& Dataface_Table::loadTable($query['-table']);
     $translations =& $this->table->getTranslations();
     foreach (array_keys($translations) as $trans) {
         $this->table->getTranslation($trans);
     }
     //print_r($translations);
     if (!isset($translations) || count($translations) < 2) {
         // there are no translations to be made
         trigger_error('Attempt to translate a record in a table "' . $this->table->tablename . '" that contains no translations.', E_USER_ERROR);
     }
     $this->translatableLanguages = array_keys($translations);
     $translatableLanguages =& $this->translatableLanguages;
     $this->languageCodes = new I18Nv2_Language($app->_conf['lang']);
     $languageCodes =& $this->languageCodes;
     $currentLanguage = $languageCodes->getName($app->_conf['lang']);
     if (count($translatableLanguages) < 2) {
         return PEAR::raiseError(df_translate('Not enough languages to translate', 'There aren\'t enough languages available to translate.'), DATAFACE_E_ERROR);
     }
     //$defaultSource = $translatableLanguages[0];
     //$defaultDest = $translatableLanguages[1];
     $options = array();
     foreach ($translatableLanguages as $lang) {
         $options[$lang] = $languageCodes->getName($lang);
     }
     unset($options[$app->_conf['default_language']]);
     $tt = new Dataface_TranslationTool();
     $form = new HTML_QuickForm('StatusForm', 'POST');
     $form->addElement('select', '--language', 'Translation', $options);
     $form->addElement('select', '--status', 'Status', $tt->translation_status_codes);
     //$form->setDefaults( array('-sourceLanguage'=>$defaultSource, '-destinationLanguage'=>$defaultDest));
     $form->addElement('submit', '--set_status', 'Set Status');
     foreach ($query as $key => $value) {
         $form->addElement('hidden', $key);
         $form->setDefaults(array($key => $value));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$this, 'processForm'));
         if (PEAR::isError($res)) {
             return $res;
         } else {
             header('Location: ' . $app->url('-action=list&-sourceLanguage=&-destinationLanguage=&-translate=') . '&--msg=' . urlencode('Translation status successfully set.'));
             exit;
         }
     }
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $records =& $this->getRecords();
     df_display(array('form' => $out, 'translationTool' => &$tt, 'records' => &$records, 'translations' => &$options, 'context' => &$this), 'Dataface_set_translation_status.html');
 }
예제 #6
0
            tr_warn('queries.php:' . $query . ':' . $e->getMessage());
            return false;
        }
        $query = "insert into queries (qid, uid, name, sql_select, sql_from, sql_where, sql_order, sql_order_dir, sql_limit, chart_period, active) values ({$next_qid}, {$uid}, '{$sql_name}', '{$sql_select}', '{$sql_from}', '{$sql_where}', '{$sql_order}', '{$sql_order_dir}', '{$sql_limit}', '{$chart_period}', TRUE);";
        try {
            $pdo->exec($query);
            $_SESSION['qid'] = $next_qid;
        } catch (PDOException $e) {
            tr_warn("html/queries.php: {$query} " . ':' . $e->getMessage());
        }
        // changed both forms, so reload them
        $select_query_form = new HTML_QuickForm('select_query');
        create_select_query_form();
        $sql_input_form = new HTML_QuickForm('sql_input');
        create_sql_input_form();
    }
}
if (isset($_POST['del_sql'])) {
    $query = "update queries set active = FALSE where qid = {$q_id};";
    $pdo->exec($query);
    $select_query_form = new HTML_QuickForm('select_query');
    create_select_query_form();
}
print '<table border="1" cellpadding="5" cellspacing="0" align="center">';
print '<tr><td>';
$select_query_form->display();
print "</td></tr>\n";
print '<tr><td>';
$sql_input_form->display();
print '</td></tr>';
print '</table>';
예제 #7
0
 /**
  * Displays the form as html.
  */
 function display()
 {
     if (!$this->_built) {
         $this->_build();
     }
     parent::display();
 }
예제 #8
0
function importAutoreply($selfurl)
{
    $form = new HTML_QuickForm('autoreply_import', 'post', "{$selfurl}&op=import");
    $msg = "<p>This will import your autoreplies.</p><br/>";
    $form->addElement('header', '', 'Autoreply Import');
    $form->addElement('static', '', '', $msg);
    $fileupload =& $form->addElement('file', 'importfile', 'Autoreply file');
    $form->addElement('submit', 'submit', 'Import');
    if ($form->validate()) {
        if ($fileupload->isUploadedFile()) {
            $fileinfo = $fileupload->getValue();
            $importfile = $fileinfo['tmp_name'];
            doAutoreplyImport($importfile);
            unlink($importfile);
        }
        exit;
    }
    $form->display();
}
예제 #9
0
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()) {
    $_SESSION['username'] = $g_username;
    $_SESSION['uid'] = $g_uid;
    unset($_SESSION['pfid']);
    redirect_login_pf();
} else {
    draw_trader_header('login', false);
    print '<table border="1" cellpadding="5" cellspacing="0" align="center"><tr><td>';
    $login_form->display();
    print '</td></tr></table>';
}
예제 #10
0
파일: ImportForm.php 프로젝트: promoso/HVAC
 function display()
 {
     $this->_build();
     if ($this->_step == 2) {
         require_once 'Dataface/RecordGrid.php';
         $records = $this->loadImportTable();
         $grid = new Dataface_RecordGrid($records);
         $grid->id = "import-records-preview";
         df_display(array('preview_data' => $grid->toHTML(), 'num_records' => count($records)), 'ImportForm_step2.html');
     }
     $res = parent::display();
     return $res;
 }
예제 #11
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();
        }
    }
}
예제 #12
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;";
예제 #13
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;
    }
}
예제 #14
0
function display_form() {

	// ////////////////////////////////////////
	// Instantiate the HTML_QuickForm object
	$form = new HTML_QuickForm( 'firstForm', 'get' );



      $languages_suggs = array( "eng" => "eng",
			   "deu" => "deu",
			   "fra" => "fra",
			   "ita" => "ita",
			   "nld" => "nld"
			   );

	$collections = array(
		'376317' => 'One laptop per child basic vocabulary',
		'376322' => 'Destinazione Italia' );

	// Set defaults for the form elements
	$form->setDefaults( array(
	    'name' => 'From'
	) );

	// Add some elements to the form
	$form->addElement( 'header', null, '' );
	$form->addElement( 'hidden', 'ow', '1' );
	$form->addElement( 'select', 'mode', 'voc browser mode:', array( 'browser' => 'lookup dictionary', 'trainer' => 'vocabulary training' ) );
	if ( $_REQUEST['mode'] == 'trainer' ) {

		$form->addElement( 'select', 'wdcollection', 'Collection to choose vocabulary from:', $collections );
		$form->addElement( 'select', 'wdlanguages_1', 'target language you want to train:', $languages_suggs );
	} else {
		$form->addElement( 'select', 'wdlanguages_1', 'first output language:', $languages_suggs );
	}
	if ( $_REQUEST['settings'] == 1 ) {
		$form->addElement( 'text', 'wdlanguages_2', 'second output language:', array( 'value' => '', 'size' => 6, 'maxlength' => 6 ) );
		$form->addElement( 'text', 'wdlanguages_3', 'third output language:', array( 'size' => 6, 'maxlength' => 6 ) );
		$form->addElement( 'text', 'wdlanguages_4', 'fourth output language:', array( 'size' => 6, 'maxlength' => 6 ) );
		$link = build_get_uri_2( 'settings', '0', '' );
		echo '<a href="' . $link . '">hide settings and languages</a>';
	} elseif ( $_REQUEST['mode'] == 'trainer' && ( $_REQUEST['trainer_step'] == 0 ) ) {
		$form->addElement( 'text', 'wdlanguages_2', 'first language you can understand:', array( 'size' => 6, 'maxlength' => 6 ) );
		$form->addElement( 'text', 'wdlanguages_3', 'second language you can understand:', array( 'size' => 6, 'maxlength' => 6 ) );
		$form->addElement( 'text', 'wdlanguages_4', 'third language you can understand:', array( 'size' => 6, 'maxlength' => 6 ) );

	} else {
		$form->addElement( 'hidden', 'wdlanguages_2', '', array( 'size' => 6, 'maxlength' => 6 ) );
		$form->addElement( 'hidden', 'wdlanguages_3', '', array( 'size' => 6, 'maxlength' => 6 ) );
		$form->addElement( 'hidden', 'wdlanguages_4', '', array( 'size' => 6, 'maxlength' => 6 ) );
		$link = build_get_uri_2( 'settings', '1', '' );
		echo '<a href="' . $link . '">edit settings and languages</a>';
	}


	if ( $_REQUEST['definedmeaning'] ) {
		$expression_group[] = &HTML_QuickForm::createElement( 'text', 'expression', 'search expression:', array( 'value' => '' , 'size' => 20, 'maxlength' => 256 ) );
		$form->updateElementAttr( 'expression', array( 'value' => '' ) );
		$expression_group[] = &HTML_QuickForm::createElement( 'text', 'wdexplanguage', 'source language of an expression <br />(leave blank to search all languages)', array( 'size' => 20, 'maxlength' => 256 ) );
	} else {
		$expression_group[] = &HTML_QuickForm::createElement( 'text', 'expression', 'search expression:', array( 'size' => 20, 'maxlength' => 256 ) );
		$expression_group[] = &HTML_QuickForm::createElement( 'text', 'wdexplanguage', 'source language of an expression <br />(leave blank to search all languages)', array( 'size' => 4, 'maxlength' => 256 ) );
	}


	$form->addGroup( $expression_group, 'Expression', 'Search Expression:', '&#160; only in this language:', 0 );

	if ( $_REQUEST['settings'] == 1 ) {
		$form->addElement( 'text', 'definedmeaning', 'definedmeaning (word-id):', array( 'value' => '', 'size' => 15 ) );
	}

	$form->addElement( 'submit', null, 'set / update' );

	// Output the form
	$form->display();
	//
	// ////////////////////////////////////////
}
예제 #15
0
$checkbox =& $sql_input_form->addElement('checkbox', 'chart', 'Draw Charts');
if (isset($_SESSION['chart'])) {
    $checkbox->setChecked(true);
} else {
    $checkbox->setChecked(false);
}
$sql_input_form->addElement('submit', 'execute_sql', 'Run Query');
if (isset($_SESSION['sql_select'])) {
    $sql_input_form->setDefaults(array('sql_select' => $_SESSION['sql_select'], 'sql_from' => $_SESSION['sql_from'], 'sql_where' => $_SESSION['sql_where'], 'sql_order' => $_SESSION['sql_order'], 'sql_order_dir' => $_SESSION['sql_order_dir'], 'sql_limit' => $_SESSION['sql_limit'], 'chart_period' => $_SESSION['chart_period']));
} else {
    $sql_input_form->setDefaults(array('sql_limit' => 10, 'sql_order_dir' => 'desc', 'chart_period' => 180));
}
if (isset($_POST['execute_sql'])) {
    if ($sql_input_form->validate()) {
        print '<table border="1" cellpadding="5" cellspacing="0" align="center"><tr><td align="center">';
        $sql_input_form->display();
        print '</td></tr>';
        // run the sql and return the results
        $data = $sql_input_form->exportValues();
        $_SESSION['sql_select'] = $sql_select = $data['sql_select'];
        $_SESSION['sql_from'] = $sql_from = $data['sql_from'];
        $_SESSION['sql_where'] = $sql_where = $data['sql_where'];
        $_SESSION['sql_order'] = $sql_order = $data['sql_order'];
        $_SESSION['sql_order_dir'] = $sql_order_dir = $data['sql_order_dir'];
        $_SESSION['sql_limit'] = $sql_limit = $data['sql_limit'];
        $_SESSION['chart_period'] = $chart_period = $data['chart_period'];
        $query = "select {$sql_select} from {$sql_from} where ({$sql_where}) and (quotes.date = '{$pf_working_date}' and quotes.exch = '{$pf_exch}') order by {$sql_order} {$sql_order_dir} limit {$sql_limit};";
        try {
            $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password);
            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (PDOException $e) {
예제 #16
0
function bulletin_display($task)
{
    global $db;
    switch ($task) {
        case 'announce':
            bulletin_tabulate(0);
            break;
        case 'show':
            $res =& db_query('bulletin_by_id', array($_GET['id']));
            $res->fetchInto($row);
            $res =& db_query('user_by_id', array($row['poster_id']));
            $res->fetchInto($user);
            echo "<h1>{$row['subject']}</h1>";
            //        $table->addRow(array('Subject: <b>'.$row['subject'].'</b>', 'Posted by: <b>'.user_handle($row['handle']).'</b>'.$action));
            if ($row['addbreaks'] == 1) {
                echo '<div class="message">' . preg_replace('/\\n/', '<br />', $row['message']) . '</div>' . '<i>The above message was posted by <b>' . user_handle($user['handle']) . '</b> on ' . $row['posted'] . '.</i>';
            } else {
                echo '<div class="message">' . $row['message'] . '</div>' . '<i>The above message was posted by <b>' . user_handle($user['handle']) . '</b> on ' . $row['posted'] . '.</i>';
            }
            break;
        case 'analysis':
            bulletin_tabulate(1);
            break;
        case 'admin':
            bulletin_tabulate(2);
            break;
        case 'public':
            bulletin_tabulate(3);
            break;
        case 'edit':
            $form = new HTML_QuickForm('shoutForm', 'post', selflink());
            $form->addElement('header', null, 'Post your message here:');
            $form->addElement('text', 'subject', 'Subject: ');
            $elem =& $form->addElement('checkbox', 'addbreaks', null);
            $elem->setChecked(false);
            $elem->setText('Allow HTML formatting tags. Makes line-break tags necessary.');
            $elem =& $form->addElement('textarea', 'message', 'Shout Message: ');
            $elem->setRows(20);
            $elem->setCols(60);
            $form->addElement('submit', null, 'Post');
            $form->addRule('subject', 'Subject must be maximum 100 characters.', 'maxlength', 100, 'client');
            $res =& db_query('bulletin_by_id', array($_GET['id']));
            $res->fetchInto($row);
            if ($row['addbreaks'] == 1) {
                unset($row['addbreaks']);
            } else {
                $row['addbreaks'] = 1;
            }
            $form->setDefaults($row);
            $res->free();
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                if (!isset($data['addbreaks'])) {
                    $data['addbreaks'] = 1;
                    $data['message'] = htmlentities($data['message']);
                } else {
                    $data['addbreaks'] = 0;
                }
                $res =& $db->autoExecute('bulletin', $data, DB_AUTOQUERY_UPDATE, 'post_id=' . $_GET['id']);
                if (PEAR::isError($res)) {
                    error($res->toString());
                }
                redirect('index.php?view=bulletin&task=' . $_GET['prev']);
            } else {
                $form->display();
            }
            break;
        case 'delete':
            db_query('delete_bulletin_by_id', array($_GET['id']));
            redirect('index.php?view=bulletin&task=' . $_GET['prev']);
            break;
    }
}
function spc_like_form()
{
    global $spcIn, $post, $wpdb, $spc, $errors, $recaptcha_opt, $spc_captcha_activated, $spc_mcsp;
    //spc_dg($spcin->get('gil'));
    // Instantiate the HTML_QuickForm object
    $form = new HTML_QuickForm('likeForm', 'POST', $post->guid . "#like");
    $spc_mcsp->GenerateValues();
    $form->setDefaults(array('mcsp_result' => $spc_mcsp->info['result']));
    // Add some elements to the form
    $form->addElement('header', 'notification', '');
    $form->addElement('hidden', 'post_id', $post->ID);
    $form->addElement('hidden', 'comment_id');
    $form->addElement('hidden', 'spcform', 'likeform');
    $form->addElement('text', 'ln', 'Name:', array('size' => 50, 'maxlength' => 255));
    $form->addElement('text', 'le', 'Email:', array('size' => 50, 'maxlength' => 255));
    $form->addElement('header', 'captcha_notification', '');
    $form->addElement('text', 'human_result', $spc_mcsp->info['operand1'] . ' + ' . $spc_mcsp->info['operand2'] . ' = ', array('size' => 2, 'maxlength' => 2));
    $form->addElement('hidden', 'mcsp_result');
    $form->addElement('submit', null, 'VOTE');
    // Define filters and validation rules
    $form->addRule('ln', 'Please enter Your Name', 'required');
    $form->addRule('le', 'Please enter Your Email', 'required');
    $form->addRule('comment_id', 'Sorry Failed, Refresh your browser', 'required');
    $form->registerRule('mcsp_check', 'callback', 'validateMCSP');
    $form->addRule('human_result', 'Wrong Sum', 'mcsp_check', TRUE);
    if ($form->getSubmitValue('spcform') == 'likeform') {
        // Try to validate a form
        if ($form->validate()) {
            $values = $form->exportValues();
            /**/
            $post_id = $values['post_id'];
            $comment_id = $values['comment_id'];
            $participant_vote = $wpdb->get_var("SELECT participant_vote FROM " . $wpdb->spc_participant . " WHERE participant_commentID = " . $comment_id);
            unset($values['post_id'], $values['comment_id'], $values['MAX_FILE_SIZE'], $values['mcsp_result'], $values['human_result']);
            $temp = array();
            $temp = unserialize($participant_vote);
            $temp[] = $values;
            $update_values = array('participant_vote' => serialize($temp));
            if ($wpdb->update($wpdb->spc_participant, $update_values, array('participant_commentID' => $comment_id))) {
                $form->setDefaults(array('notification' => '<div style="width:100%; background-color:white;">Vote Submitted</div>'));
            }
            /**/
        }
        //END form validation
    }
    // Output the form
    $form->display();
}
예제 #18
0
 function handle($params)
 {
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $this->table =& Dataface_Table::loadTable($query['-table']);
     $translations =& $this->table->getTranslations();
     foreach (array_keys($translations) as $trans) {
         $this->table->getTranslation($trans);
     }
     //print_r($translations);
     if (!isset($translations) || count($translations) < 2) {
         // there are no translations to be made
         trigger_error('Attempt to translate a record in a table "' . $this->table->tablename . '" that contains no translations.', E_USER_ERROR);
     }
     $this->translatableLanguages = array_keys($translations);
     $translatableLanguages =& $this->translatableLanguages;
     $this->languageCodes = new I18Nv2_Language($app->_conf['lang']);
     $languageCodes =& $this->languageCodes;
     $currentLanguage = $languageCodes->getName($app->_conf['lang']);
     if (count($translatableLanguages) < 2) {
         return PEAR::raiseError(df_translate('Not enough languages to translate', 'There aren\'t enough languages available to translate.'), DATAFACE_E_ERROR);
     }
     $defaultSource = $translatableLanguages[0];
     $defaultDest = $translatableLanguages[1];
     $options = array();
     foreach ($translatableLanguages as $lang) {
         $options[$lang] = $languageCodes->getName($lang);
     }
     $form = new HTML_QuickForm('TranslationForm', 'POST');
     $form->addElement('select', '-sourceLanguage', 'Source Language', $options);
     $form->addElement('select', '-destinationLanguage', 'Destination Language', $options);
     $form->setDefaults(array('-sourceLanguage' => $defaultSource, '-destinationLanguage' => $defaultDest));
     $form->addElement('submit', '-translate', 'Translate');
     $mask =& Dataface_LinkTool::getMask();
     // The mask of parameters that are passed to new urls
     // We need to modify this mask so that the appropriate parameters are passed.
     foreach ($query as $key => $value) {
         $form->addElement('hidden', $key);
         $form->setDefaults(array($key => $value));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$this, 'processForm'));
         if (PEAR::isError($res)) {
             if ($query['--format'] == 'rest') {
                 header('Content-type: text/plain');
                 echo 'FAILED' . "\n" . $res->getMessage();
                 exit;
             }
             return $res;
         } else {
             //print_r($form->exportValues());
             //echo "Done";exit;
             if ($query['--format'] == 'rest') {
                 header('Content-type: text/plain');
                 echo 'SUCCEEDED' . "\nRecords Successfully Translated";
                 exit;
             }
             header('Location: ' . $app->url('-action=list&-sourceLanguage=&-destinationLanguage=&-translate=') . '&--msg=Records successfully translated');
             exit;
         }
     }
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     df_display(array('body' => $out), 'Dataface_Main_Template.html');
 }
예제 #19
0
 /**
  * Displays the form.
  */
 function display()
 {
     $this->_build();
     $domainTable = $this->_relationship->getDomainTable();
     if (PEAR::isError($domainTable)) {
         $domainTable = $this->_relationship->_schema['selected_tables'][0];
     }
     $domainTable = Dataface_Table::loadTable($domainTable);
     $io = new Dataface_IO($domainTable->tablename);
     echo "<p>" . df_translate('scripts.Dataface.RemoveRelatedRecordForm.display.MESSAGE_ARE_YOU_SURE', "Are you sure you want to remove the following records from the relationship '" . $this->_relationship->getLabel() . "'?", array('relationship' => $this->_relationship->getLabel())) . "</p>";
     echo "<ul>";
     $records = df_get_selected_records($this->query);
     foreach ($records as $record) {
         echo "<li>" . $record->getTitle() . "</li>\n";
     }
     echo "</ul>";
     parent::display();
 }
예제 #20
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;
    }
}
예제 #21
0
    if ($create_pf_form->validate()) {
        $create_pf_form->process('create_portfolio');
        // we've added a portfolio, load a clean create_pf_form and reload the choose
        $create_pf_form = new HTML_QuickForm('add_portfolio');
        create_add_form();
        $choose_pf_form = new HTML_QuickForm('choose_portfolio');
        create_choose_form();
    }
} elseif (isset($_POST['choose'])) {
    if ($choose_pf_form->validate()) {
        $choose_pf_form->process('choose_portfolio');
        header("Location: /queries.php");
        exit;
    }
} elseif (isset($_POST['delete'])) {
    if ($choose_pf_form->validate()) {
        $data = $choose_pf_form->exportValues();
        $pfid = $data['portfolio'];
        delete_portfolio($pfid);
        // recreate the choose form since the data has changed
        $choose_pf_form = new HTML_QuickForm('choose_portfolio');
        create_choose_form();
    }
}
// display the forms
print '<table border="1" cellpadding="5" cellspacing="0" align="center"><tr><td>';
$create_pf_form->display();
print '</td></tr>';
print '<tr><td>';
$choose_pf_form->display();
print '</td></tr></table>';
예제 #22
0
파일: installer.php 프로젝트: promoso/HVAC
 function db2app()
 {
     require_once 'HTML/QuickForm.php';
     $form = new HTML_QuickForm('db2app');
     $res = mysql_list_dbs(db());
     if (!$res) {
         trigger_error(mysql_error(db()), E_USER_ERROR);
     }
     $options = array('' => 'Please Select Database ...');
     while ($row = mysql_fetch_row($res)) {
         $options[$row[0]] = $row[0];
     }
     $form->addElement('hidden', '-action', 'db2app');
     $form->addElement('select', 'database_name', 'Select Database' . $this->infoLink('archive2app.database_name'), $options, array('onchange' => 'listeners.database_name.onchange(this)'));
     $form->addElement('header', 'db_info', 'Database connection details');
     //$form->addElement('html', 'this is a test');
     $form->addElement('text', 'mysql_user', 'MySQL Username ' . $this->infoLink('archive2app.mysql_user'));
     $form->addElement('password', 'mysql_password', 'MySQL Password');
     //$form->addElement('radio','output_format','Output options','Download as tar.gz archive','download');
     //$form->addElement('radio','output_format','','Install on webserver in apps directory','install');
     $form->addElement('select', 'install_type', 'Installation type ' . $this->infoLink('archive2app.install_type'), array('' => 'Please select ...', 'download_tarball' => 'Download Tarball', 'ftp_install' => 'Install on server (using FTP)'), array('onchange' => "listeners.install_type.onchange(this);"));
     $form->addElement('header', 'ftp_info', 'FTP Connection Info');
     $form->addElement('text', 'ftp_host', 'FTP Host');
     $form->addElement('checkbox', 'ftp_ssl', 'Use SSL');
     $form->setDefaults(array('ftp_host' => DB_HOST));
     $form->addElement('text', 'ftp_path', 'FTP Path', array('size' => 50));
     $form->setDefaults(array('ftp_path' => $_SERVER['DOCUMENT_ROOT']));
     $form->addElement('text', 'ftp_username', 'FTP Username');
     $form->addElement('password', 'ftp_password', 'FTP Password');
     $form->addElement('submit', 'submit', 'Submit');
     $form->addRule('database_name', 'Please select a database', 'required', null, 'client');
     $form->addRule('mysql_user', 'Please enter a mysql username that the application can connect as.', 'required', null, 'client');
     $form->addRule('install_type', 'Please select an installation type and then click submit.', 'required', null, 'client');
     $form->setDefaults(array('mysql_user' => $_SERVER['PHP_AUTH_USER'], 'mysql_password' => $_SERVER['PHP_AUTH_PW']));
     if ($form->validate()) {
         $tarpath = $form->process(array(&$this, 'db2app__process'), true);
         header('Content-type: application/x-gzip');
         header('Content-Disposition: attachment; filename="' . basename($tarpath) . '.tar.gz"');
         echo file_get_contents($tarpath);
         exit;
     }
     require_once 'HTML/QuickForm/Renderer/Array.php';
     $renderer = new HTML_QuickForm_Renderer_Array(true, true, true);
     $form->accept($renderer);
     $context = $renderer->toArray();
     //print_r($context);
     ob_start();
     $form->display();
     $out = ob_get_contents();
     ob_end_clean();
     include 'install' . DIRECTORY_SEPARATOR . 'db2app.inc.php';
 }
예제 #23
0
    if ($rows_inserted > 0) {
        $res =& $db->query('commit transaction');
    } else {
        $res =& $db->query('rollback transaction');
    }
    if (PEAR::isError($res)) {
        die($res->getDebugInfo());
    }
    $params['filename'] = $_FILES['filename']['name'];
    $params['rows_inserted'] = $rows_inserted;
    $params['rows_totals'] = $rows_totals;
    $params = params_encode($params);
    $continue = 'action=alumno_import_end&params=' . $params;
} else {
    // <UI>
    include_once 'header.php';
    $uploadForm->display();
    echo '<br>';
    echo '<b>Nota:</b> esta operacion carga alumnos en la base de inscripciones, si el nro de legajo de un alumno ya se encuentra cargado, no se carga, y se prosigue con el proximo.';
    echo '<br>';
    echo 'Si no cuenta con un archivo para importar,<BR>haga click aquí para bajar el: ';
    echo '<a href="modelo_alta.xls" type="application/vnd.ms-excel" target="_blank">Modelo de planilla para importar alumnos</a>';
    echo '<br><br>';
    echo '<b>Indicaciones de uso :</b><BR>';
    echo '1.- Llenar la planilla (el campo "nombre" es requerido)';
    echo '<br>';
    echo '2.- Guardar la planilla como tipo: Texto (delimitado por tabulaciones).';
    echo '<br>';
    echo '3.- Seleccionar el archivo en el formulario y subirlo.';
    include_once 'footer.php';
}
예제 #24
0
 function display()
 {
     $this->_build();
     $showform = true;
     $b = new Dataface_QueryBuilder($this->_tablename, $this->_query);
     if (isset($this->_query['-delete-one'])) {
         $q = array('-skip' => $this->_query['-cursor'], '-limit' => 1);
         $sql = $b->select('', $q);
         $res = xf_db_query($sql, $this->_db);
         if (!$res) {
             throw new Exception(df_translate('scripts.Dataface.DeleteForm._build.ERROR_TRYING_TO_FETCH', "Error trying to fetch element to be deleted.: ") . xf_db_error($this->_db), E_USER_ERROR);
         }
         if (xf_db_num_rows($res) == 0) {
             $msg = df_translate('scripts.Dataface.DeleteForm._build.ERROR_NO_RECORD_SELECTED', "No record is currently selected so no record can be deleted.");
             $showform = false;
         } else {
             $row = xf_db_fetch_array($res);
             $rowRec = new Dataface_Record($this->_tablename, $row);
             $displayCol = $rowRec->getTitle();
             $msg = df_translate('scripts.Dataface.DeleteForm.display.ARE_YOU_SURE', "Are you sure you want to delete this record: &quot;{$displayCol}&quot;?", array('displayCol' => $displayCol));
         }
     } else {
         if (isset($this->_query['-delete-found'])) {
             $q = $b->select_num_rows();
             $res = xf_db_query($q, $this->_db);
             if (!$res) {
                 throw new Exception(df_translate('scripts.Dataface.DeleteForm.display.ERROR_ESTIMATING', "Error estimating number of rows that will be deleted: ") . xf_db_error($this->_db), E_USER_ERROR);
             }
             list($num) = xf_db_fetch_row($res);
             if ($num <= 0) {
                 $msg = df_translate('scripts.Dataface.DeleteForm.display.ERROR_NO_RECORDS_FOUND', "There are no records in the current found set so no records can be deleted.");
                 $showform = false;
             } else {
                 $msg = df_translate('scripts.Dataface.DeleteForm.display.ARE_YOU_SURE_MULTIPLE', "Are you sure you want to delete the found records.  {$num} records will be deleted.", array('num' => $num));
             }
         } else {
             $msg = df_translate('scripts.Dataface.DeleteForm.display.ERROR_GET_VARS', "Error: You must specify either '-delete-one' or '-delete-found' in GET vars.");
             $showform = false;
         }
     }
     if ($showform) {
         ob_start();
         parent::display();
         $form = ob_get_contents();
         ob_end_clean();
     } else {
         $form = '';
     }
     $context = array('msg' => $msg, 'form' => $form);
     import('Dataface/SkinTool.php');
     $skinTool =& Dataface_SkinTool::getInstance();
     //$smarty = new Smarty;
     //$smarty->template_dir = $GLOBALS['Dataface_Globals_Templates'];
     //$smarty->compile_dir = $GLOBALS['Dataface_Globals_Templates_c'];
     //$smarty->assign($context);
     //$smarty->display('Dataface_DeleteForm.html');
     $skinTool->display($context, 'Dataface_DeleteForm.html');
 }
예제 #25
0
 * @ignore
 */
require_once 'HTML/QuickForm.php';
$template = '<tr>
    <td align="right" valign="top">
        <!-- BEGIN required --><font color="red">*</font><!-- END required -->
        <b>{label}</b>
    </td>
    <td nowrap="nowrap" valign="top" align="left">
        {element}
        <!-- BEGIN error --><br/><font color="red">{error}</font><br/><!-- END error -->
        <!-- BEGIN label_2 --><br/><font size="-1">{label_2}</font><!-- END label_2 -->
    </td>
</tr>';
// Create the form, and add a header to it.
$form = new HTML_QuickForm('labels_example', 'post');
$form->addHeader('QuickForm Labels Example');
// Do the magic! Just pass your label to the element as an array!
$form->addElement('text', 'name', array('Name', 'The name that you would like to enter in this element.'));
$form->addElement('checkbox', 'check', array('Check Me!', 'If you check this box, it will have tick in it.'));
// More boring stuff.
$form->addElement('submit', null, 'Submit');
if ($form->validate()) {
    $form->freeze();
}
// customize the element template
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate($template);
// output the form
$form->display();
예제 #26
0
            break;
        } else {
            $msg = "El registro a sido cargado satisfactoriamente.";
        }
    }
    unset($params_cont);
    $params_cont['msg'] = $msg;
    $params_cont = params_encode($params_cont);
    $continue = 'action=' . $params['table'] . '&params=' . $params_cont;
    return;
}
// <UI>
include_once 'header.php';
if (isset($params['msg'])) {
    echo $params['msg'];
}
echo '<br>';
$params_alumno['sql_list'] = 'select * from alumno';
$params_alumno['sql_where'] = ' where id = ?';
$params_alumno['sql_order'] = '';
$params_alumno['sql_data'] = $_SESSION['alumno_id'];
echo sak_display_list($params_alumno);
echo '<br>';
$form->display();
echo '<br>';
if (isset($materia_id)) {
    echo '<hr width="60%">';
    echo $msg_comis;
    $form_comis->display();
}
include_once 'footer.php';
예제 #27
0
 function display()
 {
     $this->_build();
     parent::display();
 }
예제 #28
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;
    }
}
 function display()
 {
     $this->getValidationScript();
     return parent::display();
 }
예제 #30
0
 public static function mobile_login()
 {
     $t = Variable::get('host_ban_time');
     if ($t > 0) {
         $fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, get_client_ip_address()));
         if ($fails >= 3) {
             print __('You have exceeded the number of allowed login attempts.') . '<br>';
             print '<a href="' . get_epesi_url() . '">' . __('Host banned. Click here to refresh.') . '</a>';
             return;
         }
     }
     $qf = new HTML_QuickForm('login', 'post', 'mobile.php?' . http_build_query($_GET));
     $qf->addElement('text', 'username', __('Login'));
     $qf->addElement('password', 'password', __('Password'));
     $qf->addElement('submit', 'submit_button', __('Login'));
     $qf->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon');
     $qf->addRule(array('username', 'password'), __('Login or password incorrect'), 'check_login');
     $qf->addRule('username', __('Field required'), 'required');
     $qf->addRule('password', __('Field required'), 'required');
     if ($qf->validate()) {
         self::set_logged($qf->exportValue('username'));
         self::new_autologin_id();
         return false;
     }
     $qf->display();
 }