public function getForm($action) { $form = new form_renderer($action); $form->append($tabs = new widget_tabs()); foreach ($this->info as $cat => $category) { $inputs = array(); foreach ($category['items'] as $id => $field) { $name = "options[{$cat}][{$id}]"; $value = $this->{$cat}->{$id}; $class = 'data_option_' . $field['type']; if (class_exists($class)) { $provider = new $class($field); $inputs[] = $provider->getField($name, $value); } elseif ($field['type'] == 'text') { $inputs[] = new form_field_text($name, $field['caption'], $value); } elseif ($field['type'] == 'textarea') { $inputs[] = new form_field_textarea($name, $field['caption'], $value); } elseif ($field['type'] == 'checkbox') { $inputs[] = new form_field_checkbox($name, $field['caption'], $value); } } $tabs->add(literal($category['caption']), implode('', $inputs)); } return $form; }
$grid[1]->box($form, 'Profil', '500px'); } elseif (empty($_GET['edit']) || !$modulrights['edit']) { $grid[1]->box($rc->get_create(), 'User erstellen'); } else { $form = $rc->get_edit($_GET['edit']); $edituser = db()->id_get('user_data', $_GET['edit']); $tabs = new tabs(); $uri = MODUL_SELF . '&edit=' . $edituser['id']; if ($modulrights['password']) { $i++; if (!empty($_POST['pass_new']) && $_POST['pass_new'] == $_POST['pass_rep']) { $pass = session_iv::crypt($_POST['pass_new'], $salt = uniqid()); db()->id_update('user_data', array('pass_type' => 0, 'pass_hash' => $pass, 'pass_salt' => $salt), $_GET['edit']); $msg = alert('Passwort geändert.', 'success'); } $passform = new form_renderer($uri . '#tabs-' . $i . '-hash'); $passform->password('pass_new', 'Neues Passwort'); $passform->password('pass_rep', 'Passwort Wiederholung'); $tabs->add('Password', $msg . $passform); } if ($modulrights['rights']) { $i++; if (isset($_POST['type'])) { $type = 4 * $_POST['type']['sysadmin'] + 2 * $_POST['type']['backend'] + $_POST['type']['frontend']; db()->id_update('user_data', array('type' => $type), $_GET['edit']); throw new redirect($uri . '#tabs-' . $i . '-hash'); } $typeform = new form_renderer($uri . '#tabs-' . $i . '-hash'); $typeform->checkbox('type[frontend]', 'Frontend', $edituser['type'] & 1); $typeform->checkbox('type[backend]', 'Backend', $edituser['type'] & 2); $typeform->checkbox('type[sysadmin]', 'Sysadmin', $edituser['type'] & 4);
<?php if (!empty($_POST)) { $_POST['captcha'] = isset($_POST['captcha']); $panelvars = array_intersect_key($_POST, array_flip(array('theme', 'captcha'))); } $form = new form_renderer(EDITOR_SELF); $form->checkbox('captcha', 'Use Captcha', $panelvars['captcha']); $form->select('theme', 'Recaptcha Theme', array('red' => 'red', 'white' => 'white', 'blackglass' => 'blackglass', 'clean' => 'clean'), $panelvars['theme']); $form->text('passlen', 'Passwort Länge', $panelvars['passlen']); $view->box($form, "Registrierungseinstellungen");
<?php if (!empty($_POST)) { $_POST['resize'] = isset($_POST['resize']); $panelvars = array_intersect_key($_POST, array_flip(array('max_width', 'max_height', 'resize'))); } $form = new form_renderer(EDITOR_SELF); $form->checkbox('resize', 'Resize', $panelvars['resize']); $form->text('max_width', 'Maximale Breite', $panelvars['max_width']); $form->text('max_height', 'Maximale Höhe', $panelvars['max_height']); $view->box($form, "Avatareinstellungen");
<?php if (isset($_POST['login_name'])) { if ($session->login($_POST['login_name'], $_POST['login_pass'], $_POST['relogin'], 1)) { throw new redirect($_POST['ref'] && !strpos($_POST['ref'], 'logout') ? $_POST['ref'] : 'index.php'); } else { echo '<div class="error">Userdaten ungültig</div>'; } } $form = new form_renderer(PAGE_SELF, 'Login'); $form->text('login_name', 'Username'); $form->password('login_pass', 'Passwort'); $form->checkbox('relogin', 'Eingeloggt bleiben'); $form->hidden('ref', $_SERVER['HTTP_REFERER']); echo $form;
$file = 'upload/avatar_' . current_user(); $width = $panelvars['max_width'] ?: 100; $height = $panelvars['max_height'] ?: 100; if (!empty($_FILES['avatar'])) { try { $upload = new upload_img($_FILES['avatar']); $upload->restrictType(array('png', 'jpg', 'jpeg', 'gif')); if ($panelvars['resize']) { $upload->resizeScale($width, $height); } else { $upload->restrictImageSize($width, $height); } $upload->savePng($file); // Create Thumbnail $upload->resizeScale(16, 16)->savePng('upload/thumb_' . current_user()); db()->user_data->updateRow(array('avatar' => 1), $user->id); echo '<div class="success">Upload erfolgreich.</div>'; } catch (Exception $e) { echo '<div class="error">' . $e->getMessage() . '</div>'; } } if (file_exists($file . '.png')) { echo '<div class="current_avatar"> <p><img src="' . $file . '.png" alt="Avatar"></p> <p><a href="" class="btn">Avatar löschen</a></p> </div>'; } $form = new form_renderer(PAGE_SELF); $form->upload('avatar', 'Avatar', 'image/*'); echo '<h2>Avatar Hochladen</h2>'; echo $form;
printf($error, 'Passwort und Wiederholung stimmen nicht überein'); } elseif ($usecap && !recaptcha_check_answer($recaptcha_privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"])->is_valid) { printf($error, 'Captcha ist inkorrekt'); } elseif ($db->query("SELECT 1 FROM `user_blocked`\n\t\t\tWHERE '%s' LIKE CONCAT('%%', `pattern`,'%%')\n\t\t\tAND `type` = 'name'", $_POST['register_name'])->num_rows()) { printf($error, 'Der Username ist unzulässig'); } elseif ($db->query("SELECT 1 FROM `user_blocked`\n\t\t\tWHERE '%s' LIKE CONCAT('%%', `pattern`,'%%')\n\t\t\tAND `type` = 'email'", $_POST['register_mail'])->num_rows()) { printf($error, 'Die E-Mail ist unzulässig'); } elseif ($db->id_get('user_data', $_POST['register_mail'], 'email')) { printf($error, 'Die angegebene E-Mail ist bereits vergeben'); } elseif ($db->id_get('user_data', $_POST['register_name'], 'name')) { printf($error, 'Der angegebene Name ist bereits vergeben'); } else { $db->insert('user_data', array('name' => $_POST['register_name'], 'email' => $_POST['register_mail'], 'pass_salt' => $salt = uniqid(), 'pass_hash' => session_iv::crypt($_POST['register_pass'], $salt), 'type' => 1)); // @TODO: Registration Mail throw new redirect(PAGE_SELF . 'completed'); } } if (isset($_GET['completed'])) { echo '<p>Registration erfolgreich und so...</p>'; } else { $captcha = '<div class="control-group"><label class="control-label" for="form_field_3">Captcha</label>' . '<div class="controls">' . recaptcha_get_html($recaptcha_publickey) . '</div></div>'; $form = new form_renderer(PAGE_SELF); $form->text('register_name', 'Username', $_POST['register_name']); $form->password('register_pass', 'Passwort'); $form->password('register_repetition', 'Wiederholung'); $form->text('register_mail', 'E-Mail', $_POST['register_mail']); if ($usecap) { $form->append($captcha); } echo $form; }
public function index() { global $conf; $categoryId = intval($_GET['category']); $self = MODUL_SELF . '&category=' . $categoryId; // upload files if (isset($_FILES['file']) && isset($_POST['category'])) { $file = $_FILES['file']; $category = intval($_POST['category']); if (!$file['name'] && !$file['tmp_name']) { $this->view->error('Es muss eine Datei für den Upload ausgewählt werden!'); } elseif (!$category) { $this->view->error('Es muss eine Kategorie für den Upload ausgewählt werden!'); } else { // May be restricted by modul rights later $types = array('png', 'jpg', 'jpeg', 'gif'); $fileClass = new upload_attachment($file); $fileClass->restrictFileSize(1024 * 1024 * 2)->restrictType($types); $fileClass->attach('media', $category); $fileClass->save(self::UPLOAD_DIR . 'upload_' . uniqid()); $this->view->success('Upload erfolgreich!'); } } // move files if (isset($_GET['move']) && $categoryId) { upload_list::move($_GET['move'], $categoryId); throw new redirect($self); } // delete file hook if (isset($_GET['deleteImg'])) { $img = db()->t('content_upload')->row((int) $_GET['deleteImg'])->assoc(); upload_list::delete($img['id']); $writer = new writer_fs(); $writer->delete($img['path']); $this->view->success('Datei erfolgreich gelöscht!'); } // category data controller $rc = new data_controller('content_upload_category', $self); $rc->add('id', 'ID', 1, 0, 0, 0); $rc->add('name', 'Name'); // edit category form if ($_GET['edit']) { $this->view->content($rc->get_edit($_GET['edit'])); $this->view->format = 'plain'; return; } // delete hook if (isset($_GET['delete'])) { $list = new upload_list('media'); if ($list->get($_GET['delete'])->num_rows()) { $this->view->error('Die Kategorie kann nicht gelöscht werden, da sie noch Dateien enthält!'); $run = false; } else { $run = true; } } else { $run = true; } // run category actions if ($run && $rc->run()) { throw new redirect($self); } // upload form $uploadForm = new form_renderer($self, 'Hochladen'); $uploadForm->select('category', 'Kategorie', array(0 => "Bitte Wählen") + db()->t('content_upload_category')->get(1)->relate(), $categoryId); $uploadForm->upload('file', 'Datei'); $error = false; $data = array(); // filter files by category if ($_GET['category'] > 0) { $list = new upload_list('media'); $data = $list->get($categoryId); if (!$data->num_rows()) { $error = 'Keine Ergebnisse!'; } } else { $error = "Keine Ergebnisse!"; } // render the page $this->view->content(template('iv.media')->render(array('categories' => db()->t('content_upload_category')->all(), 'modul_self' => MODUL_SELF, 'current' => $categoryId, 'images' => $data, 'url' => trim($conf->page->url, '/'), 'error' => $error, 'category' => $categoryId, 'uploadForm' => $uploadForm, 'createForm' => $rc->get_create()))); }
db()->update_migration->delRow($_GET['reset']); throw new redirect(MODUL_SELF); } if (!empty($_GET['install'])) { $view->format = 'plain'; $migrations->install($_GET['install']); } else { $all = globFiles('migration/*'); $applied = db()->select('update_migration')->assocs('id'); $result = $pending = array(); foreach ($all as $id) { $result[] = array('id' => $id, 'status' => isset($applied[$id]) ? 'applied' : 'pending', 'date' => $applied['create_date']); if (empty($applied[$id])) { $pending[] = $id; } } $grid = $view->grid(); $view->js('assets/js/migration.js'); $form = new form_renderer(MODUL_SELF, 'Erstellen'); $form->text('create', 'Migrationsname'); $grid[0]->box($form, 'Migration erstellen'); $grid[0]->box(template('iv.migrations.install')->render(array('pending' => $pending)), 'Migrationen anwenden'); $list = new list_array(MODUL_SELF); $list->text('Datei', 'id'); $list->text('Status', 'status'); $list->date('Datum', 'date'); $list->add($actions = new list_column_actions('Aktionen')); $actions->add(MODUL_SELF, 'apply', 'Mark Applied', 'assets/small/check.png'); $actions->add(MODUL_SELF, 'reset', 'Reset', 'assets/small/undo.png'); $grid[1]->box($list->get($result), 'Migrationen', '600px'); }
/** * This method is evil and should only avoid copy & paste */ public function changePassword($action) { $result = array(); if (!empty($_POST['change_pass'])) { if ($_POST['change_pass'] != $_POST['change_repeat']) { $result['error'] = 'Passwort und Wiederholung stimmen nicht überein.'; } else { $pass = self::crypt($_POST['change_pass'], $salt = uniqid()); db()->user_data->updateRow(array('pass_format' => 0, 'pass_hash' => $pass, 'pass_salt' => $salt), current_user()); $result['success'] = 'Passwort erfolgreich geändert.'; } } $result['form'] = $form = new form_renderer($action); $form->password('change_pass', 'Neues Passwort'); $form->password('change_repeat', 'Wiederholung'); return $result; }
protected function create_form($type, $action, $edit, $back = NULL) { $form = new form_renderer($action, 'Speichern'); if ($back) { $form->linkbutton('Zurück', $back); } foreach ($this->columns as $c) { if ($c[$type]) { switch ($c['type']) { case 'password': $form->password($c['name'], $c['caption'], $edit[$c['name']]); break; case 'radio': $form->radio($c['name'], $c['caption'], $c['values'], $edit[$c['name']]); break; case 'hidden': $form->hidden($c['name'], $edit[$c['name']]); break; case 'textarea': $form->textarea($c['name'], $c['caption'], $edit[$c['name']]); break; case 'select': $form->select($c['name'], $c['caption'], $c['values'], $edit[$c['name']]); break; case 'checkbox': $form->checkbox($c['name'], $c['caption'], $edit[$c['name']]); break; case 'date': $form->field(new form_field_date($c['name'], $c['caption'], $edit[$c['name']])); break; default: $form->text($c['name'], $c['caption'], $edit[$c['name']]); } } } return $form; }