protected function renderNotes() { $this->writeJavascript('var current_key = 0; var max_key = 0; var crypt_module = "";' . 'function clickRunButton() {' . ' if (current_key == 0) {' . ' max_key = parseInt(document.keygen_form.key_count.value,0);' . ' if (isNaN(max_key) || max_key == 0) { ' . sprintf(' alert("%s");', Messages::getString('GenerateKeysPage.EnterNumberBiggerZero')) . ' document.keygen_form.key_count.focus();' . ' return;' . ' }' . ' crypt_module = document.keygen_form.crypt_module[document.keygen_form.crypt_module.selectedIndex].value;' . sprintf(' document.keygen_form.run_button.value="%s";', Messages::getString('General.Cancel')) . sprintf(' document.getElementById("key_output").innerHTML = "<form action=\\"' . $this->KEY_PDF_PHP . '\\" method=\\"POST\\" target=\\"_blank\\"><table id=\\"key_output_table\\"><tbody id=\\"key_output_table_body\\"><tr><th class=\\"out\\">%s</th><th class=\\"out\\">%s</th></tr></tbody></table><input type=\\"submit\\" value=\\"%s\\" /><input type=\\"hidden\\" name=\\"ext\\" value=\\".pdf\\" /></form> ";', Messages::getString('General.RKey'), Messages::getString('General.Password'), Messages::getString('GenerateKeysPage.GeneratePdf')) . ' generate();' . ' } else { ' . ' stop();' . ' }' . '}' . 'function generate() {' . ' current_key++;' . ' if (current_key > max_key) { stop(); return; }' . sprintf(' document.keygen_form.run_button.value="%s";', Messages::getString('General.Cancel')) . ' keygen_frame.location.href = "' . $this->GEN_KEY_PHP . '?crypt=" + escape(crypt_module) + "¤t=" + current_key + "&max=" + max_key;' . '}' . 'function store_result(reson_key,password) {' . ' add_table_line(reson_key,password);' . ' window.setTimeout("generate()", 10);' . '}' . 'function stop() {' . ' current_key = 0;' . ' max_key = 0;' . sprintf(' document.keygen_form.run_button.value="%s";', Messages::getString('General.Run')) . '}' . 'function add_table_line(key,pwd) {' . ' table = document.getElementById("key_output_table_body");' . ' newTR = document.createElement("tr");' . ' table.appendChild(newTR);' . ' newTD = document.createElement("td");' . ' newTD.setAttribute("class","out");' . ' newTR.appendChild(newTD);' . ' text = document.createTextNode(key);' . ' newTD.appendChild(text);' . ' inp = document.createElement("input");' . ' inp.setAttribute("type","hidden");' . ' inp.setAttribute("name","key[]");' . ' inp.setAttribute("value",key);' . ' newTD.appendChild(inp);' . ' newTD = document.createElement("td");' . ' newTD.setAttribute("class","out");' . ' newTR.appendChild(newTD);' . ' text = document.createTextNode(pwd);' . ' newTD.appendChild(text);' . ' inp = document.createElement("input");' . ' inp.setAttribute("type","hidden");' . ' inp.setAttribute("name","pwd[]");' . ' inp.setAttribute("value",pwd);' . ' newTD.appendChild(inp);' . '}'); $note = '<form name="keygen_form" onsubmit="clickRunButton(); return false;">' . sprintf('%s: <input type="text" name="key_count" value="1" size="5" />', Messages::getString('GenerateKeysPage.NumberOfKeys')) . sprintf(' <input type="button" name="run_button" value="%s" onclick="clickRunButton();" />', Messages::getString('General.Run')) . '<br />' . sprintf('%s: %s', Messages::getString('GenerateKeysPage.EncryptionModule'), $this->getCryptSelect()) . '</form>' . sprintf('<iframe src="%s" name="keygen_frame" id="keygen_frame" scrolling="no" frameborder="0">%s</iframe><br />', $this->GEN_KEY_PHP, Messages::getString('GenerateKeysPage.NoKeyGeneration')); $this->renderNote($note, Messages::getString('GenerateKeysPage.RKeyGeneration')); $this->renderNote(sprintf('<div id="key_output" style="text-align:center">%s</div>', Messages::getString('General.None')), Messages::getString('GenerateKeysPage.NewRKeys')); }
private function getLoginForm() { try { $db = Database::getInstance(); $frontpage_info = $db->getFrontpageInfo(); } catch (Exception $exception) { // in this case, render exception as error. return $exception; } $result = '<form action="admin.php" name="login_form" method="post"><div id="loginform">'; if (count($frontpage_info) > 1) { $result .= sprintf('<label for="project_id">%s: </label>', Messages::getString('General.Project')); $result .= '<select name="project_id" id="project_id_selector">'; foreach ($frontpage_info as $id => $project) { $result .= sprintf('<option value="%03d" %s>%s </option>', $id, $id == Config::$default_project_id ? 'selected="selected"' : '', $project->name); } $result .= '</select><br/>'; } else { foreach ($frontpage_info as $id => $project) { $result .= sprintf('<input type="hidden" name="project_id" value="%03d" />', $id); } } $result .= sprintf('<label for="password">%s: </label>', Messages::getString('LoginPage.EnterPassword')) . ' <input type="password" name="pwd" value="" /> ' . ' <input type="submit" value="Login" />' . '</div></form> '; return $result; }
function __construct() { parent::__construct(); $this->session = Session::getInstance(); $this->project = $this->session->getProject(); $this->menu = array(Messages::getString('General.Logout') => "logout.php") + $this->menu; }
function renderNotes() { $db = Database::getInstance(); $note = sprintf(Messages::getString('AdminMenuPage.Status'), $db->getMemberIdCount($this->project->getId()), $this->project->getName()); $note .= '<ul>'; foreach ($this->option_list as $file => $caption) { $note .= '<li><a href="' . $file . '">' . $caption . '</a></li>'; } $note .= '</ul><br />'; $this->renderNote($note, Messages::getString('AdminMenuPage.SelectRequest')); }
private function getCreateForm() { $result = '<div id="createproject" class="formlayout"><form method="POST" name="createproject_form" autocomplete="off">'; $result .= sprintf('<label for="name">%s: </label><input type="text" size="30" name="name" value="%s" /><br />', Messages::getString('CreateProjectPage.ProjectName'), htmlspecialchars($_POST['name'])); $result .= sprintf('<label for="pwd">%s: </label><input type="password" size="30" name="pwd" value="" /><br />', Messages::getString('General.Password')); $result .= sprintf('<label for="pwd2">%s: </label><input type="password" size="30" name="pwd2" value="" /><br />', Messages::getString('General.PasswordRepeat')); $result .= '<hr />'; $result .= sprintf('<label for="master_pwd">%s: </label><input type="password" size="30" name="master_pwd" value="" /> ', Messages::getString('CreateProjectPage.CreateProjectPassword')); $result .= sprintf('<input type="submit" value="%s" />', Messages::getString('CreateProjectPage.CreateNewProject')); $result .= '</form> </div>'; return $result; }
protected function __construct() { //Open database connection $this->db_link = mysql_connect(Config::$database['server'], Config::$database['username'], Config::$database['password']); if (!$this->db_link || mysql_errno() != 0) { throw new DatabaseConnectionException(Messages::getString('Database.NoConnection')); } if (!mysql_select_db(Config::$database['database'], $this->db_link)) { throw new DatabaseConnectionException(Messages::getString('Database.NoOpen')); } if (isset(Config::$database['db_prefix'])) { foreach ($this->TABLES as $table_name => $table) { $this->TABLES[$table_name] = Config::$database['db_prefix'] . $table; } } }
private function renderContent() { $result = null; if (!isset($_GET['crypt'])) { return null; } $crypt_module = $_GET['crypt']; if (!isset(Config::$crypt_info[$crypt_module])) { echo sprintf(Messages::getString('GenKeyPage.EncryptionModuleNotFound'), $crypt_module); return null; } $current = intval($_GET['current']); $max = intval($_GET['max']); if ($current > $max) { echo sprintf(Messages::getString('GenKeyPage.IndexError'), $current, $max); return null; } try { //Now generate the key echo sprintf(" " . Messages::getString('GenKeyPage.Generating'), $current, $max); flush(); $db = Database::getInstance(); $project_id = $this->project->getId(); $member_id = $db->getNextMemberId($project_id); $crypt = new CryptProxy($crypt_module, $project_id, $member_id); $pw_gen = new ConfiguredPasswordGenerator(); $password = $pw_gen->generatePassword(); $crypt_data = $crypt->generateCryptData($password); if (!$db->createRkey($project_id, $member_id, $crypt_module, $crypt_data)) { echo Messages::getString('GenKeyPage.ErrorInsertingRKey'); return null; } $rkey = new RKey($project_id, $member_id); $result = array($rkey, $password); echo ' ' . Messages::getString('GenKeyPage.Finished'); flush(); } catch (Exception $e) { echo $e; return null; } return $result; }
/** * Offers the option to upload a CSV file */ private function generateCsvImportForm() { $result = '<form method="POST" name="import_csv_form" enctype="multipart/form-data" class="formlayout">'; $result .= sprintf('<p><label for="csvfile">%s:</label> <input name="csvfile" type="file" /></p>', Messages::getString('EnterDataPage.SelectFile')); $result .= sprintf('<p><label for="separator">%s:</label> <select name="separator">', Messages::getString('EnterDataPage.Separator')); foreach (array(';' => ';', ',' => ',', "\t" => Messages::getString('General.Tab')) as $sep => $sep_name) { $result .= sprintf('<option value="%s">%s</option>', urlencode($sep), $sep_name); } $result .= sprintf('</select><br /><input type="submit" value="%s" id="upload_data" /></p>', Messages::getString('EnterDataPage.Upload')); $result .= '</form> '; return $result; }
<?php /* * Created on 20.03.2007 * * This is the entry to the adminsitration * * Licenced under GPL: http://www.gnu.org/licenses/gpl.txt * */ require_once 'classes/autoload.php'; $msg = null; //check, whether there was some login attempt: try { if (isset($_POST['pwd']) && ($password = $_POST['pwd'])) { $session = Session::createNewSession($password, $_POST['project_id']); if (!$session->isLoggedIn()) { $msg = Messages::getString('General.PasswordWrong'); } } } catch (Exception $exception) { // in this case, render exception as error. $msg = $exception; } $page = AdminPageFactory::factory('AdminMenuPage', $msg); $page->render();
/** * Write local configuration file */ private function writeLocalConf() { $local_conf = $this->BASEDIR . '/' . $this->LOCAL_CONF; $handle = fopen($local_conf, "w"); if (!$handle) { return sprintf(Messages::getString('SetupPage.CouldNotWriteFile'), $local_conf); } foreach ($this->local_conf as $line) { fwrite($handle, $line . "\n"); } if (!fclose($handle)) { return sprintf(Messages::getString('SetupPage.CouldNotWriteFile'), $local_conf); } }
private function getCreateForm() { $result = '<div id="createproject"><form method="POST" name="createproject_form" autocomplete="off">'; $result .= sprintf('<label for="name">%s: </label><input type="text" size="30" name="name" value="%s" /><br />', Messages::getString('CreateProjectPage.ProjectName'), htmlspecialchars($this->postValue('name', null, $this->project->getName()))); $result .= '<hr />'; $result .= sprintf('<label for="pwd">%s: </label><input type="password" size="30" name="oldpwd" value="" /><br />', Messages::getString('ManageProjectPage.OldPwd')); $result .= sprintf('<label for="pwd">%s: </label><input type="password" size="30" name="pwd" value="" /><br />', Messages::getString('ManageProjectPage.NewPassword')); $result .= sprintf('<label for="pwd2">%s: </label><input type="password" size="30" name="pwd2" value="" /><br />', Messages::getString('General.PasswordRepeat')); $result .= '<hr />'; $result .= sprintf('<label for="info">%s </label><textarea cols="50" rows="5" name="info">%s</textarea><br />', Messages::getString('ManageProjectPage.FrontpageInfo'), htmlspecialchars($this->postValue('info', null, $this->project->getInfo()))); $access = $this->postValue('access', null, $this->project->getAccess() ? 'yes' : 'no') == 'yes'; $result .= sprintf('<label>%s: </label><input type="radio" name="access" value="yes" %s > %s</input> <input type="radio" name="access" value="no" %s > %s</input><br />', Messages::getString('ManageProjectPage.Access'), $access ? ' checked="checked"' : '', Messages::getString('ManageProjectPage.AccessOpen'), $access ? '' : ' checked="checked"', Messages::getString('ManageProjectPage.Closed')); $result .= '<hr />'; $result .= sprintf('<label for="introduction">%s </label><textarea cols="50" rows="5" name="introduction">%s</textarea><br />', Messages::getString('ManageProjectPage.Introduction'), htmlspecialchars($this->postValue('introduction', null, $this->project->getIntroduction()))); $result .= sprintf('<label for="hint">%s </label><textarea cols="50" rows="5" name="hint">%s</textarea>', Messages::getString('ManageProjectPage.Hint'), htmlspecialchars($this->postValue('hint', null, $this->project->getHint()))); $result .= sprintf('<input type="button" value="%s" onclick="pdfpreview();" id="pdfpreviewbutton" /><br />', Messages::getString('ManageProjectPage.showPdfPreview')); $result .= '<hr />'; $result .= sprintf('<input type="submit" value="%s" /> <input type="reset" value="%s" />', Messages::getString('ManageProjectPage.ChangeProjectInformation'), Messages::getString('ManageProjectPage.ResetValues')); $result .= sprintf('</form><form name="pdfpreview_form" action="%s" method="POST" target="_blank">' . '<input type="hidden" name="key[]" value="123-456789" />' . '<input type="hidden" name="pwd[]" value="previewOnly" />' . '<input type="hidden" name="introduction" value="" />' . '<input type="hidden" name="hint" value="" />' . '<input type="hidden" name="ext" value=".pdf" /></form>', $this->KEY_PDF_PHP); $result .= '</form> </div>'; return $result; }
protected function renderBackNote($text, $title = '') { $this->renderNote(sprintf('%s' . '<div class="back"><input type="button" value="%s" onclick="history.back();" /></div>', $text, Messages::getString('General.Back')), $title); }
private function getResultRequestForm() { $result = '<div id="requestresults"><form method="POST" name="request_results_form" autocomplete="off">'; if (count($this->frontpage_info) > 1) { $result .= sprintf('<label class="startformlabel" for="project_id">%s: </label>', Messages::getString('General.Project')); $result .= '<select name="project_id" id="project_id_selector" onchange="updateProjectInfo();">'; foreach ($this->frontpage_info as $id => $project) { $result .= sprintf('<option value="%03d" %s>%s </option>', $id, $id == $this->default_project_id ? 'selected="selected"' : '', $project->name); } $result .= '</select><br/>'; } else { foreach ($this->frontpage_info as $id => $project) { $result .= sprintf('<input type="hidden" name="project_id" value="%03d" />', $id); } } $result .= sprintf('<label class="startformlabel" for="mat_no">%s: </label><input type="text" name="mat_no" value="" size="10" class="startinput" /><br />', Messages::getString('General.MatNo')) . sprintf('<label class="startformlabel" for="password">%s: </label><input type="password" name="password" value="" size="10" class="startinput" /> ', Messages::getString('General.Password')) . sprintf('<input type="submit" value="%s" id="requestbutton" />', Messages::getString('StartPage.RequestResults')) . '</form> </div>'; return $result; }
private function getManageForm() { $result = '<div id="manageproject" class="formlayout"><form method="POST" name="createproject_form" autocomplete="off">'; $result .= sprintf('<label for="name">%s: </label><input type="text" size="30" name="name" value="%s" /><br />', Messages::getString('CreateProjectPage.ProjectName'), htmlspecialchars($this->postValue('name', null, $this->project->getName()))); $result .= '<hr />'; $result .= sprintf('<label for="pwd">%s: </label><input type="password" size="30" name="oldpwd" value="" /><br />', Messages::getString('ManageProjectPage.OldPwd')); $result .= sprintf('<label for="pwd">%s: </label><input type="password" size="30" name="pwd" value="" /><br />', Messages::getString('ManageProjectPage.NewPassword')); $result .= sprintf('<label for="pwd2">%s: </label><input type="password" size="30" name="pwd2" value="" /><br />', Messages::getString('General.PasswordRepeat')); $result .= '<hr />'; $result .= sprintf('<label for="info">%s </label><textarea cols="50" rows="5" name="info">%s</textarea><br />', Messages::getString('ManageProjectPage.FrontpageInfo'), htmlspecialchars($this->postValue('info', null, $this->project->getInfo()))); $access = $this->postValue('access', null, $this->project->getAccess() ? 'yes' : 'no') == 'yes'; $result .= '<hr />'; $result .= sprintf('<label>%s: </label><input type="radio" name="access" value="yes" %s > %s</input> <input type="radio" name="access" value="no" %s > %s</input><br />', Messages::getString('ManageProjectPage.Access'), $access ? ' checked="checked"' : '', Messages::getString('ManageProjectPage.AccessOpen'), $access ? '' : ' checked="checked"', Messages::getString('ManageProjectPage.Closed')); $result .= '<hr />'; $result .= sprintf('</p><div id="pdf_config"><h3>%s:</h3><p>', Messages::getString('ManageProjectPage.Handout')); $result .= sprintf('<label for="introduction">%s </label><textarea cols="50" rows="6" name="introduction">%s</textarea><br />', Messages::getString('ManageProjectPage.Introduction'), htmlspecialchars($this->postValue('introduction', null, $this->project->getIntroduction()))); $result .= sprintf('<span class="handout_center">(%s)</span>', Messages::getString('ManageProjectPage.HandoutCenter')); $result .= sprintf('<label for="hint">%s </label><textarea cols="50" rows="6" name="hint">%s</textarea>', Messages::getString('ManageProjectPage.Hint'), htmlspecialchars($this->postValue('hint', null, $this->project->getHint()))); $result .= sprintf('<input type="button" value="%s" onclick="pdfpreview();" id="pdfpreviewbutton" /><br />', Messages::getString('ManageProjectPage.showPdfPreview')); $result .= '</div>'; $result .= '<hr />'; $result .= sprintf('<input type="submit" value="%s" id="submit_data" /><br /> <input type="reset" value="%s" id="reset_data_button" />', Messages::getString('ManageProjectPage.ChangeProjectInformation'), Messages::getString('ManageProjectPage.ResetValues')); $result .= sprintf('</form><form name="pdfpreview_form" action="%s" method="POST" target="_blank">' . '<input type="hidden" name="key[]" value="123-456789" />' . '<input type="hidden" name="pwd[]" value="previewOnly" />' . '<input type="hidden" name="introduction" value="" />' . '<input type="hidden" name="hint" value="" />' . '<input type="hidden" name="ext" value=".pdf" /></form>', $this->KEY_PDF_PHP); $result .= '</form> </p></div><p>'; $result .= sprintf('<h3>%s</h3>', Messages::getString('ManageProjectPage.ResetData')); $result .= '<div id="resetproject" class="formlayout"><form method="POST" name="reset_form" id="reset_form" autocomplete="off">'; $result .= '<input type="hidden" id="reset_data" name="reset_data" value="" />'; $result .= sprintf('<input type="button" value="%s" onclick="resetData(\'%s\',\'purge\');" />', Messages::getString('ManageProjectPage.PurgeData'), Messages::getString('ManageProjectPage.PurgeDataConfirm')); $result .= sprintf(' %s<br />', Messages::getString('ManageProjectPage.PurgeDataDescr')); $result .= sprintf('<input type="button" value="%s" onclick="resetData(\'%s\',\'clean\');" />', Messages::getString('ManageProjectPage.CleanData'), Messages::getString('ManageProjectPage.CleanDataConfirm')); $result .= sprintf(' %s<br />', Messages::getString('ManageProjectPage.CleanDataDescr')); $result .= sprintf('<input type="button" value="%s" onclick="resetData(\'%s\',\'remove\');" />', Messages::getString('ManageProjectPage.RemoveData'), Messages::getString('ManageProjectPage.RemoveDataConfirm')); $result .= sprintf(' %s<br />', Messages::getString('ManageProjectPage.RemoveDataDescr')); $result .= sprintf('<input type="button" value="%s" onclick="resetData(\'%s\',\'delete_project\');" />', Messages::getString('ManageProjectPage.DeleteProject'), Messages::getString('ManageProjectPage.DeleteProjectConfirm')); $result .= sprintf(' %s<br />', Messages::getString('ManageProjectPage.DeleteProjectDescr')); $result .= '</form> </div>'; return $result; }
protected function renderError($pdf, $error) { $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 16); $pdf->SetTextColor(255, 0, 0); $pdf->Write(18, sprintf('%s: %s', html_entity_decode(Messages::getString('General.Error')), $error)); }