check_auth()) { Header("Location: login.php"); exit(); } $loader->load('admin'); $ac = $_REQUEST['ac']; $section = $_REQUEST['section']; $user = new User(); $text = new Text(); $admin = new Admin(); if ($section == 'user') { if ($_POST['id'] != $_SESSION['user_id']) { $info = $lang['user_profile_error']; } else { $admin->process_data('user', 'edit', $_POST); $info = $lang['user_profile_edited']; } $template_file = 'user_success'; $template->assign("INFO", $info); $title = $lang['user_profile_title']; } elseif ($section == 'profile') { $template_file = $admin->show_form('user', 'edit', $_SESSION['user_id']); $title = $lang['user_profile_title']; } elseif ($section == 'fic' && ($ac == 'update_form' || $ac == 'edit')) { $id = $_REQUEST['id']; $title = $lang['suggest_update']; if ($ac == 'edit') { $template_file = 'user_success'; $admin->process_data('fic', 'user_update_submit', $_POST); $template->assign("INFO", $lang['suggest_update_sent']); } else { // 'update_form' $template_file = $admin->show_form('fic', 'edit', $id); } } elseif ($section == 'fic') { $id = $_REQUEST['id']; $title = $lang['suggest_fic_title']; if ($ac == 'add') { $template_file = 'user_success'; unset($_POST['ac']); $admin->process_data('fic', 'user_submit', $_POST); $template->assign("INFO", $lang['suggest_fic_sent']); } else { $template_file = $admin->show_form('fic', 'add'); } } elseif ($section == 'challenge') { $title = $lang['add_challenge_title']; if ($ac == 'add') { $template_file = 'user_success'; if (!$_POST['title']) { $info = $lang['challenge_empty_title']; } elseif (!$_POST['text']) { $info = $lang['challenge_empty_author']; } elseif (!isset($tags[0])) { $info = $lang['challenge_empty_tags']; } else { $admin->process_data('challenge', 'add', $_POST); $info = $lang['challenge_added']; } $template->assign("INFO", $info); } else { $template_file = $admin->show_form('challenge', 'add'); } } elseif ($section == 'challenge_answer') { $title = $lang['challenge_answer_title']; if ($ac == 'add') { $template_file = 'user_success'; $user->submit_challenge_answer($_POST); $template->assign("INFO", $lang['challenge_answer_submitted']); } else { $user->submit_challenge_answer_form($id); $template_file = 'user_form_challenges_answer'; } } else { $template_file = 'user_account'; $title = $_SESSION['name'].stripslashes($lang['user_account_title']); $template->assign("NAME", $_SESSION['name']); } // Process template $template->assign("PAGE_TITLE", $title); $template->assign("HEAD_TITLE", $site->site_title($title, 1)); $template->pparse("layout/$template_file.tmpl"); ?>