$areaId = 'page'; $model = new ae_PageModel(); $model->load($_GET['page']); } else { if (isset($_GET['post']) && ae_Validate::id($_GET['post'])) { $editArea = 'Post'; $areaId = 'post'; $model = new ae_PostModel(); $model->load($_GET['post']); $model->loadCategoryIds(); } else { if (isset($_GET['user']) && ae_Validate::id($_GET['user'])) { $editArea = 'User'; $areaId = 'user'; $model = new ae_UserModel(); $model->load($_GET['user']); } else { header('Location: admin.php?error=unknown_edit_area'); exit; } } } } } } } ?> <h1>Edit: <?php echo $editArea; ?> </h1>
$model = new ae_PostModel(); } else { if (isset($_GET['user']) && ae_Validate::id($_GET['user'])) { $area = 'user'; $model = new ae_UserModel(); } else { header('Location: ../admin.php?error=unknown_area_or_invalid_id'); exit; } } } } } } } $model->load($_GET[$area]); $prevStatus = $model->getStatus(); if ($_GET['status'] == 'delete') { if (!$model->delete()) { header('Location: ../admin.php?area=' . $mainArea . '&' . $area . '&status=' . $prevStatus . '&error=delete'); exit; } header('Location: ../admin.php?area=' . $mainArea . '&' . $area . '&status=' . $prevStatus . '&success=delete'); exit; } else { try { $model->setStatus($_GET['status']); } catch (Exception $e) { header('Location: ../admin.php?area=' . $mainArea . '&' . $area . '&status=' . $prevStatus . '&error=invalid_status'); exit; }
/** * Create the user. * @return {int} ID of the new user. */ function createUser() { if (!isset($_POST['user-name-internal'], $_POST['user-name-external'], $_POST['user-permalink'], $_POST['user-password'])) { header('Location: ../admin.php?error=missing_data_for_user'); exit; } $permalink = trim($_POST['user-permalink']); $status = isset($_POST['user-status-suspended']) ? ae_UserModel::STATUS_SUSPENDED : ae_UserModel::STATUS_ACTIVE; $user = new ae_UserModel(); if (isset($_POST['edit-id'])) { if (!$user->load($_POST['edit-id'])) { return FALSE; } } $user->setNameInternal($_POST['user-name-internal']); $user->setNameExternal($_POST['user-name-external']); if ($permalink != '') { $user->setPermalink($permalink); } if ($_POST['user-password'] !== '') { $user->setPasswordHash(ae_Security::hash($_POST['user-password'])); } $user->setStatus($status); $user->save(); return $user->getId(); }