public function addPostAction() { if (!isset($_POST['title'])) { require APPLICATION_PATH . '/views/admin/Add.html.php'; } else { $result = addPost($_POST['title'], $_POST['text']); if ($result != 1) { $error = 'Crap'; include APPLICATION_PATH . '/views/Error.html.php'; exit; } else { header('Location: ../'); die; } } }
$title = $_POST['post-title']; if (!$title) { $errors[] = 'The post must have a title'; } $body = $_POST['post-body']; if (!$body) { $errors[] = 'The post must have a body'; } if (!$errors) { $pdo = getPDO(); // Decide if we are editing or adding if ($postId) { editPost($pdo, $title, $body, $postId); } else { $userId = getAuthUserId($pdo); $postId = addPost($pdo, $title, $body, $userId); if ($postId === false) { $errors[] = 'Post operation failed'; } } } if (!$errors) { redirectAndExit('edit-post.php?post_id=' . $postId); } } ?> <!DOCTYPE html> <html> <head> <title> A blog application | New post </title>
addComment($bdd, $id_post, $auteur, $message); } } // Empty pour n'envoyer des posts à la bdd que si $errors est vide ! if (!empty($_POST['submitpost'])) { $titre = $_POST['titre']; $contenu = $_POST['contenu']; $errors = []; if (empty($contenu)) { $errors = "Message requis !"; } if (empty($titre)) { $errors = "Titre requis !"; } if (empty($errors)) { addPost($bdd, $titre, $contenu); } } // Empty pour n'envoyer des réponses à la bdd que si $errors est vide ! if (!empty($_POST['submit'])) { $id_comments = $_POST['id_comments']; $interloc = $_POST['interloc']; $reponse = $_POST['reponse']; $reponse = $_POST['reponse']; $errors = []; if (empty($reponse)) { $errors = "Interlocuteur requis !"; } if (empty($interloc)) { $errors = "Réponse requise !"; }
$xmlRoot->appendChild(setUpRecord($dbconn, $ldapConfig, $xmlDoc, $_REQUEST['username'])); break; case "getPosts": $xmlRoot->appendChild(getPosts($dbConn, $xmlDoc, $_REQUEST['page'], $_REQUEST['sub'], $_REQUEST['user'], $_REQUEST['comments'])); break; case "email": phpMailer($xmlDoc, $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['subject'], $_REQUEST['msg']); break; case "doesUserExist": $xmlRoot->appendChild(doesUserExist($dbconn, $xmlDoc, $_REQUEST['id'], $_REQUEST['user_type'])); break; case "addGoogleUser": $xmlRoot->appendChild(addGoogleUser($dbconn, $xmlDoc, $_REQUEST['id'], $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['url'])); break; case "addPost": $xmlRoot->appendChild(addPost($dbconn, $xmlDoc, $_REQUEST['id'], $_REQUEST['title'], $_REQUEST['text'], $_REQUEST['url'], $_REQUEST['sub'])); break; case "userInfo": $xmlRoot->appendChild(userInfo($dbconn, $xmlDoc, $_REQUEST['id'])); break; case "editUsername": $xmlRoot->appendChild(editUsername($dbconn, $xmlDoc, $_REQUEST['id'], $_REQUEST['username'])); break; case "castVote": $xmlRoot->appendChild(castVote($dbconn, $xmlDoc, $_REQUEST['user_id'], $_REQUEST['post_id'], $_REQUEST['vote'])); break; case "tallyVotes": $xmlRoot->appendChild(tallyVotes($dbconn, $xmlDoc, $_REQUEST['post_id'])); break; case "checkForUserVote": $xmlRoot->appendChild(checkForUserVote($dbconn, $xmlDoc, $_REQUEST['post_id'], $_REQUEST['user_id']));
$feeds = $stmt->fetchAll(); foreach ($feeds as $repository) { $repositories[] = $repository['repository']; } $repositories = array_unique($repositories); $result = []; foreach ($repositories as $repository) { $result[$repository] = json_decode($github->request('repos/' . $repository . '/releases'), true); } foreach ($feeds as $feed) { $timestamp = new \DateTime(); foreach ($result[$feed['repository']] as $release) { if (postExists($dbConnection, $feed['feed_id'], $release['id'])) { continue; } $postId = addPost($dbConnection, $feed['id'], $release); logAddition($dbConnection, $feed['feed_id'], $postId, $timestamp); } } function postExists(\PDO $dbConnection, $feedId, $releaseId) { $query = 'SELECT count(posts.id)'; $query .= ' FROM posts'; $query .= ' JOIN feeds_repositories ON feeds_repositories.id = posts.feed_repository_id'; $query .= ' WHERE feeds_repositories.feed_id = :feedID'; $query .= ' AND release_id = :releaseID'; $stmt = $dbConnection->prepare($query); $stmt->execute(['feedID' => $feedId, 'releaseID' => $releaseId]); return (bool) $stmt->fetchColumn(0); } function addPost(\PDO $dbConnection, $feedRepositoryId, array $release)
<?php include 'includes/connectBDD.php'; include 'includes/reqPost.php'; addPost($bdd); ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/styleAddPost.css" /> <script type="text/javascript" src="js/addPost.js"></script> <title>My_Weblog</title> </head> <body> <div id="main"> <?php include 'includes/nav.php'; ?> <header class="title"> <h1>~ Nouvel article ~</h1> </header> <form method="POST" action="addPost.php" name="addPost" class="marg" onsubmit="return verifPost()"> <label for="title">Titre :</label> <input type="text" id="title" name="title"/> <label for="content">Contenu :</label>
addComment(); } if ($request == "comment-edit") { editComment(); } if ($request == "comment-delete") { deleteComment(); } if ($request == "comment-thumb-up") { thumbUp(); } if ($request == "comment-thumb-down") { thumbDown(); } if ($request == "post-add") { addPost(); } if ($request == "post-edit") { editPost(); } if ($request == "post-delete") { deletePost(); } function escapeText($text) { $result = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" . $text; $dom = new DOMDocument(); $dom->loadHTML($result); $script = $dom->getElementsByTagName('script'); $remove = []; foreach ($script as $item) {
global $dbPosts; global $Language; // Page status, published or draft. if (isset($args['publish'])) { $args['status'] = "published"; } else { $args['status'] = "draft"; } // Add the page. if ($dbPosts->add($args)) { // Reindex tags, this function is in 70.posts.php reIndexTagsPosts(); Alert::set($Language->g('Post added successfully')); Redirect::page('admin', 'manage-posts'); } else { Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to create the post.'); } return false; } // ============================================================================ // Main before POST // ============================================================================ // ============================================================================ // POST Method // ============================================================================ if ($_SERVER['REQUEST_METHOD'] == 'POST') { addPost($_POST); } // ============================================================================ // Main after POST // ============================================================================
return '<script type="text/javascript" src="http://static.indafoto.hu/js/slideshow.js"></script> <script type="text/javascript"> INDAFOTO.slideshow.run({ "feedUrl":"' . $url . '", "width":"300", "height":"90", "orientation":"horizontal", "size":"xs", "bgcolor":"#000000", "textcolor":"#FFFFFF", "number":"3", "target":"blank", "staticUrl":"http://static.indafoto.hu" }); </script> '; } /** parsedText - adds embedcodes at the end of the post */ function parsedText($text) { foreach (parsePost($_POST["szoveg"]) as $item) { $text .= "<br/>" . $item; } return $text; } if (isset($_POST["szoveg"])) { addPost($_POST["author"], parsedText($_POST["szoveg"])); } $xml = simplexml_load_file("hello.xml"); foreach ($xml as $item) { ?> <div style="width:50%;margin:1em;padding:2px;background-color:#ccc;"> <div style="background-color:#ccc"> <?php echo $item->author . " - " . date("Y / m / j"); ?> </div> <div style="background-color:white;padding:0.5em;"> <?php echo $item->text; ?>
$arvamus = ""; $arvamus_error = ""; // keegi vajutas nuppu numbrimärgi lisamiseks if (isset($_POST["add_post"])) { //echo $_SESSION["logged_in_user_id"]; // valideerite väljad if (empty($_POST["arvamus"])) { $arvamus_error = "*See väli on kohustuslik*"; } else { $arvamus = cleanInput($_POST["arvamus"]); } // mõlemad on kohustuslikud if ($arvamus_error == "") { //salvestan ab // message funktsioonist $msg = addPost($arvamus); if ($msg != "") { //õnnestus, teeme inputi väljad tühjaks $arvamus = ""; echo $msg; } } } function cleanInput($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?>
if (isset($_GET["logout"])) { //aadressireal on olemas muutuja logout //kustutame kõik session muutujad ja peatame sessiooni session_destroy(); header("Location: login.php"); } $tweet = ""; $tweet_error = ""; if (isset($_POST["add_tweet"])) { if (empty($_POST["tweet"])) { $tweet_error = " See väli on kohustuslik."; } else { $tweet = cleanInput($_POST["tweet"]); } if ($tweet_error == "") { $msg = addPost($tweet); if ($msg != "") { $tweet = ""; echo "{$msg}"; } } } function cleanInput($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <p> Tere, <?php
public function addNewPost() { $response['signed'] = false; $response['valid'] = false; $response['succeeded'] = false; $response['post'] = array(); $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $post = ['caption' => $caption = $request->caption, 'image_path' => "", 'is_private' => $request->is_private]; $v = new Validator(); $v->required('caption')->lengthBetween(1, 1000); // $v->optional('image_path')->lengthBetween($min, $max)->alpha(); $result = $v->validate($post); $response['valid'] = $result->isValid(); if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0) { $response['signed'] = true; if ($response['valid']) { $response['post'] = addPost($_SESSION['user_id'], $post); $response['succeeded'] = true; } else { print_r($result->getFailures()); } } echo json_encode($response); }
$postQuery['userkey'] = "Введите свой пользовательский секретный ключ"; // Раскомментируйте следующую строку, если вы хотите получить более детальную информацию в результатах проверки текста на уникальность //$postQuery['jsonvisible'] = "detail"; $postQuery = http_build_query($postQuery, '', '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://api.text.ru/post'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postQuery); $json = curl_exec($ch); $errno = curl_errno($ch); if (!$errno) { $resCheck = json_decode($json); if (isset($resCheck->text_unique)) { $text_unique = $resCheck->text_unique; $result_json = $resCheck->result_json; } else { $error_code = $resCheck->error_code; $error_desc = $resCheck->error_desc; } } else { $errmsg = curl_error($ch); } curl_close($ch); } ///////////////// $res = addPost(); var_dump($res); ?> </body> </html>