function postEditAction() { $data = isset($_POST['post']) ? $_POST['post'] : []; $errors = []; $post = []; if (isset($data['id'])) { $id = $data['id']; } else { if (isset($_GET['id'])) { $id = $_GET['id']; } } if (isset($id)) { $post = getPostById((int) $id); if (!$post) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); exit('Post not found'); } } if ($data) { $msg = 'Запись успешно ' . (isset($post['id']) ? 'обновлена' : 'добавлена'); $post = savePost($data, $errors); if (!$errors) { addFlashMessages($msg); header('location: index.php?r=post/edit&id=' . $post['id']); exit; } } /* * Мы попадаем сюда в 4-х случаях: * 1) форма не была отправлена, id не найден => добавить новую запись * 2) форма не была отправлена, id найден => вывести форму для редактирования существующей записи * 3) форма была отправлена, id не найден => добавление новой записи, но введенные данные не корректны * 4) форма была отправлена, id найден => редактирование записи, но введенные данные не корректны */ var_dump($post, $errors); require_once __DIR__ . '/../views/edit.php'; }
<input type="submit" value="Reply" />" <input type="hidden" name="addReplyFlag" value="true"/> <input type="hidden" name="commentId" value="$lastNewId"/> </form> */ if (isset($_POST['addReplyFlag'])) { $sender = $_SESSION['username']; $receiver = $uname; $message = sanitize($_POST['newReply']); $message = preg_replace("/'/", "", $message); if (strlen($message) > 500) { $message = substr($message, 0, 500); } //insert comment into database here... $newPost = new Post(NULL, "REPLY", $sender, $receiver, NULL, $message, $_POST['commentId']); savePost($newPost); } //END ADDING REPLY TO WALL $user = getUser($uname); $userSummary = getUserSummary($uname); if (is_null($userSummary)) { $userSummary = ""; } ?> <?php if (!is_null($user)) { ?> <div class="wrapper">
function blog_admin_controller() { $Blog = new Blog(); getBlogUserPermissions(); global $blogUserPermissions, $SITEURL; if (!isset($_GET['update'])) { $update = blog_version_check(); if ($update[0] == 'current') { $ucolor = '#308000'; } elseif ($update[0] == 'update') { $ucolor = '#FFA500'; } elseif ($update[0] == 'beta') { $ucolor = '#2B5CB3'; } else { $ucolor = '#D94136'; } } else { $ucolor = '#777777'; } if (isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) { editPost($_GET['edit_post']); } elseif (isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) { editPost(); } elseif (isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) { if (isset($_GET['edit_category'])) { $add_category = $Blog->saveCategory($_POST['new_category']); if ($add_category == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/CATEGORY_ADDED') . '</div>'; } else { echo '<div class="error">' . i18n_r(BLOGFILE . '/CATEGORY_ERROR') . '</div>'; } } if (isset($_GET['delete_category'])) { $Blog->deleteCategory($_GET['delete_category']); } #edit_categories $category_file = getXML(BLOGCATEGORYFILE); require_once 'html/category-management.php'; } elseif (isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) { if (isset($_POST['post-rss'])) { $post_data = array(); $post_data['name'] = $_POST['post-rss']; $post_data['category'] = $_POST['post-category']; $add_feed = $Blog->saveRSS($post_data); if ($add_feed == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/FEED_ADDED') . '</div>'; } else { echo '<div class="error">' . i18n_r(BLOGFILE . '/FEED_ERROR') . '</div>'; } } elseif (isset($_GET['delete_rss'])) { $delete_feed = $Blog->deleteRSS($_GET['delete_rss']); if ($delete_feed == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/FEED_DELETED') . '</div>'; } else { echo '<div class="error">' . i18n_r(BLOGFILE . '/FEED_DELETE_ERROR') . '</div>'; } } #edit_rss $rss_file = getXML(BLOGRSSFILE); require_once 'html/feed-management.php'; } elseif (isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) { show_settings_admin(); } elseif (isset($_GET['update']) && $blogUserPermissions['blogsettings'] == true) { show_update_admin(); } elseif (isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) { require_once 'html/help-admin.php'; } elseif (isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) { $CustomFields = new customFields(); if (isset($_POST['save_custom_fields'])) { $saveCustomFields = $CustomFields->saveCustomFields(); if ($saveCustomFields) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/EDIT_OK') . '</div>'; } } show_custom_fields(); } else { if (isset($_GET['save_post'])) { savePost(); } elseif (isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) { $post_id = urldecode($_GET['delete_post']); $delete_post = $Blog->deletePost($post_id); if ($delete_post == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/POST_DELETED') . '</div>'; } else { echo '<div class="error">' . i18n(BLOGFILE . '/FEED_DELETE_ERROR') . '</div>'; } } #show_posts_admin $all_posts = $Blog->listPosts(true, true); // Get a list of all the posts in the blog require_once 'html/posts-admin.php'; // Bring in the HTML to show this section } }
return array('name' => 'archives', 'type' => 'builtin', 'nicename' => 'Archives Admin', 'description' => 'Edit archives', 'authors' => 'Eaden McKee, Tobias Schlottke', 'licence' => 'GPL', 'help' => ''); } $loq->assign('form_type', 'edit'); $loq->get_modifiers(); $actions = array('delete', 'edit', 'postedit', 'filter', 'allowcomments'); if (isset($_POST['action']) && in_array($_POST['action'], $actions)) { $postid = intval($_POST['postid']); switch ($_POST['action']) { case 'delete': deletePost($loq, $postid); break; case 'edit': editPost($loq, $postid); break; case 'postedit': savePost($loq, $postid); break; case 'filter': filterDisplay($loq); break; case 'allowcomments': allowComments($loq, $postid); break; default: //Unknown - handle this error break; } } else { defaultDisplay($loq); } function deletePost(&$loq, $postid = null)
<?php require_once 'twitteroauth/twitteroauth.php'; require_once 'config.php'; require_once 'common.php'; session_start(); error_reporting(0); $user_id = $_SESSION['user_id']; $access_token = $_SESSION['access_token']; $pid = 0; if ('1' == $_POST['status']) { $message = $_POST['message']; $shrinked = $_POST['shrinked']; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); $pid = savePost($user_id, $message); if ($shrinked) { $shortUrl = getPostUrl($pid); $message = "{$shrinked}... {$shortUrl}"; //echo $message; } $connection->post("statuses/update", array("status" => $message)); } ?> <html> <head> <title>Bangla Twitter Status</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="style/grid.css" type="text/css" rel="stylesheet" media="screen"/> <script src="js/jquery-1.5.min.js" type="text/javascript"></script> <script src="js/driver.phonetic.js" type="text/javascript"></script> <script src="js/engine.js" type="text/javascript"></script>
if (isset($data['id'])) { $id = $data['id']; } else { if (isset($_GET['id'])) { $id = $_GET['id']; } } if (isset($id)) { $post = getPostById((int) $id); if (!$post) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not found'); exit('Post not found!'); } } if ($data) { $post = savePost($data, $errors); if (!$errors) { // запись успешно сохранена header('location: edit.php?id=' . $post['id']); exit; } } ?> <!Doctype html> <html> <head> <meta charset="utf-8"> <title>Бложек</title> </head> <body> <form method="post">
/** @var Boolean $loginStatus */ $loginStatus = false; if (isset($_SESSION['login'])) { echo "session: isset|"; $isLogin = $_SESSION['login']; if ($isLogin === true) { // echo "session: true|"; $loginStatus = true; } } ?> <?php if ($loginStatus === true) { echo "session true|"; savePost(); } elseif (isset($_POST['submit'])) { $submitType = $_POST['submit']; if ($submitType == 'login') { $username = $_POST['username']; $password = $_POST['password']; $statement = getEncryptedPassword($username); $encryptedPassword = ""; $databaseInfo = $statement->fetchObject(); if ($databaseInfo) { $encryptedPassword = $databaseInfo->password; } if (strtoupper(md5($password)) == $encryptedPassword) { $_SESSION['login'] = true; //save post // savePost();
/** * Handles conditionals for admin functions * * @return void */ function blog_admin_controller() { $Blog = new Blog(); getBlogUserPermissions(); global $blogUserPermissions; showAdminNav(); if (isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) { editPost($_GET['edit_post']); } elseif (isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) { editPost(); } elseif (isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) { if (isset($_GET['edit_category'])) { $add_category = $Blog->saveCategory($_POST['new_category']); if ($add_category == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/CATEGORY_ADDED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/CATEGORY_ERROR'); echo '</div>'; } } if (isset($_GET['delete_category'])) { $Blog->deleteCategory($_GET['delete_category']); } edit_categories(); } elseif (isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) { if (isset($_POST['post-rss'])) { $post_data = array(); $post_data['name'] = $_POST['post-rss']; $post_data['category'] = $_POST['post-category']; $add_feed = $Blog->saveRSS($post_data); if ($add_feed == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/FEED_ADDED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/FEED_ERROR'); echo '</div>'; } } elseif (isset($_GET['delete_rss'])) { $delete_feed = $Blog->deleteRSS($_GET['delete_rss']); if ($delete_feed == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/FEED_DELETED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/FEED_DELETE_ERROR'); echo '</div>'; } } edit_rss(); } elseif (isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) { show_settings_admin(); } elseif (isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) { show_help_admin(); } elseif (isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) { $CustomFields = new customFields(); if (isset($_POST['save_custom_fields'])) { $saveCustomFields = $CustomFields->saveCustomFields(); if ($saveCustomFields) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/EDIT_OK') . '</div>'; } } show_custom_fields(); } else { if (isset($_GET['save_post'])) { savePost(); } elseif (isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) { $post_id = urldecode($_GET['delete_post']); $delete_post = $Blog->deletePost($post_id); if ($delete_post == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/POST_DELETED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/FEED_DELETE_ERROR'); echo '</div>'; } } show_posts_admin(); } }