function add_action() { add_post(); $posts = get_all_posts(); $html = render_template("view/templates/admin.php", array('posts' => $posts)); return new Response($html); }
function newpost() { $title = $_POST['post_title']; $text = $_POST['post_text']; $category = $_POST['post_category']; $author = $_SESSION['user_id']; add_post($title, $text, $category, $author); }
public function add_action() { $postModel = new PostModel(); add_post(); $posts = $postModel->get_all_rows(); $html = $this->render_template("view/templates/admin.php", array('posts' => $posts)); return new Response($html); }
function add_action() { add_post(); $posts = get_all_posts(); $html = render_template('View/Templates/admin.php', array('posts' => $posts)); return $html; //require "View/Templates/show.php"; // require "View/Templates/list.php"; }
function admin_action() { if (isset($_POST['submit'])) { add_post(); } $posts = get_all_posts(); $html = render_template('view/templates/admin.php', array('posts' => $posts)); return $html; //require "view/templates/admin.php"; }
$message = preparse_bbcode($message, $errors); } if ($message == '') { $errors[] = $lang_post['No message']; } $hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0; $subscribe = isset($_POST['subscribe']) ? 1 : 0; $now = time(); ($hook = get_hook('po_end_validation')) ? eval($hook) : null; // Did everything go according to plan? if (empty($errors) && !isset($_POST['preview'])) { // If it's a reply if ($tid) { $post_info = array('is_guest' => $forum_user['is_guest'], 'poster' => $username, 'poster_id' => $forum_user['id'], 'poster_email' => $forum_user['is_guest'] && $email != '' ? $email : null, 'subject' => $cur_posting['subject'], 'message' => $message, 'hide_smilies' => $hide_smilies, 'posted' => $now, 'subscr_action' => $forum_config['o_subscriptions'] == '1' && $subscribe && !$is_subscribed ? 1 : ($forum_config['o_subscriptions'] == '1' && !$subscribe && $is_subscribed ? 2 : 0), 'topic_id' => $tid, 'forum_id' => $cur_posting['id'], 'update_user' => true, 'update_unread' => true); ($hook = get_hook('po_pre_add_post')) ? eval($hook) : null; add_post($post_info, $new_pid); } else { if ($fid) { $post_info = array('is_guest' => $forum_user['is_guest'], 'poster' => $username, 'poster_id' => $forum_user['id'], 'poster_email' => $forum_user['is_guest'] && $email != '' ? $email : null, 'subject' => $subject, 'message' => $message, 'hide_smilies' => $hide_smilies, 'posted' => $now, 'subscribe' => $forum_config['o_subscriptions'] == '1' && (isset($_POST['subscribe']) && $_POST['subscribe'] == '1'), 'forum_id' => $fid, 'update_user' => true, 'update_unread' => true); ($hook = get_hook('po_pre_add_topic')) ? eval($hook) : null; add_topic($post_info, $new_tid, $new_pid); } } ($hook = get_hook('po_pre_redirect')) ? eval($hook) : null; redirect(forum_link($forum_url['post'], $new_pid), $lang_post['Post redirect']); } } // Are we quoting someone? if ($tid && isset($_GET['qid'])) { $qid = intval($_GET['qid']); if ($qid < 1) {
post('/add/post', function () { $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $title = from($_REQUEST, 'title'); $fi = from($_REQUEST, 'fi'); $vid = from($_REQUEST, 'vid'); $tag = from($_REQUEST, 'tag'); $url = from($_REQUEST, 'url'); $content = from($_REQUEST, 'content'); $description = from($_REQUEST, 'description'); $user = $_SESSION[config("site.url")]['user']; if ($proper && !empty($title) && !empty($tag) && !empty($content)) { if (!empty($url)) { add_post($title, $tag, $url, $content, $user, $description, $fi, $vid); } else { $url = $title; add_post($title, $tag, $url, $content, $user, $description, $fi, $vid); } } else { $message['error'] = ''; if (empty($title)) { $message['error'] .= '<li>Title field is required.</li>'; } if (empty($tag)) { $message['error'] .= '<li>Tag field is required.</li>'; } if (empty($content)) { $message['error'] .= '<li>Content field is required.</li>'; } if (!$proper) { $message['error'] .= '<li>CSRF Token not correct.</li>'; }
$errors[] = '*You need a description!'; } if (empty($act)) { $errors[] = '*You need an act name!'; } if (empty($characters)) { $errors[] = '*You need to name the actors!'; } if (!category_exists('id', $_POST['category'])) { $errors[] = '*That category does not exists'; } if (empty($videoname)) { $errors[] = '*You need to name the video!'; } if (empty($errors)) { add_post($title, $act, $characters, $contents, $videoname, $_POST['category']); $id = mysql_insert_id(); header("Location:index.php?id={$id}"); die; } } session_start(); if (!isset($_SESSION["sess_user"])) { header("location: ../login.php"); } else { ?> <!DOCTYPE html> <html> <head> <title>DMS - Add Content</title> <link rel="stylesheet" type="text/css" href="resources/cms.css">
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); require_once "includes.php"; if (!isset($_GET["course"]) || $_GET["course"] == "") { header("Location: /" . SITE_ROOT); } $course = get_course_info($_GET["course"]); if (!is_course_registered($course["id"], $account)) { header("Location: /" . SITE_ROOT); } $title = $course["department"] . $course["number"]; require_once "header_home.php"; if ($account === false) { header("Location: /" . SITE_ROOT); } if (isset($_POST["content"]) && $_POST["content"] != "") { add_post($account, $course["id"], $_POST["content"]); } if (isset($_GET["attend"]) && $_GET["attend"] != "") { if (is_attending($account, $_GET["attend"])) { leave_post($account, $_GET["attend"]); } else { attend_post($account, $_GET["attend"]); } header("Location: /" . SITE_ROOT . "/posts?course=" . $_GET["course"]); } if (isset($_GET["finish"]) && $_GET["finish"] != "") { finish_post($_GET["finish"]); header("Location: /" . SITE_ROOT . "/posts?course=" . $_GET["course"]); } $account_info = get_account_info($account); ?>
<?php session_start(); include_once "server.php"; include_once "functions.php"; $userid = $_SESSION["user_id"]; $body = substr($_POST["body"], 0, 140); //$userid = 1; //$body = "hello"; add_post($userid, $body); $_SESSION['message'] = "Your post has been added!"; header("Location:index.php");
return $var; } //Отправка сообщения. function add_post($name, $msg) { $name = clearData($name); $msg = clearData($msg); if (empty($name)) { $name = 'Гость'; } if (!empty($msg)) { $query = "INSERT INTO msg (username, post)\n\t\t\t\tVALUES ('{$name}','{$msg}')"; if (mysql_query($query)) { $res = 0; } else { $res = 1; } } return $res; } $send = add_post($name, $msg); if ($send != 0) { echo 'Произошла ошибка, попробуйте ещё раз'; } else { $last_id = mysql_insert_id(); $query = "SELECT username, post, LEFT(date, 16) AS date FROM msg WHERE id = {$last_id}"; $res = mysql_query($query); $arr_res = mysql_fetch_assoc($res); echo json_encode($arr_res); } mysql_close();
post('/add/post', function () { $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $title = from($_REQUEST, 'title'); $tag = from($_REQUEST, 'tag'); $url = from($_REQUEST, 'url'); $content = from($_REQUEST, 'content'); $description = from($_REQUEST, 'description'); $user = $_SESSION[config("site.url")]['user']; $draft = from($_REQUEST, 'draft'); $category = from($_REQUEST, 'category'); if ($proper && !empty($title) && !empty($tag) && !empty($content)) { if (!empty($url)) { add_post($title, $tag, $url, $content, $user, $description, $draft, $category); } else { $url = $title; add_post($title, $tag, $url, $content, $user, $description, $draft, $category); } } else { $message['error'] = ''; if (empty($title)) { $message['error'] .= '<li>Title field is required.</li>'; } if (empty($tag)) { $message['error'] .= '<li>Tag field is required.</li>'; } if (empty($content)) { $message['error'] .= '<li>Content field is required.</li>'; } if (!$proper) { $message['error'] .= '<li>CSRF Token not correct.</li>'; }
get_user_by_email($_REQUEST['email']); break; case 'get_user_by_id': get_user_by_id($_REQUEST['id_user']); break; case 'change_password': change_password($_REQUEST['username'], $_REQUEST['password']); break; case 'get_markers': get_markers(); break; case 'get_markers_by_category': get_markers_by_category($_REQUEST['id_categoria']); break; case 'add_post': add_post($_REQUEST['id_user'], $_REQUEST['post_title'], $_REQUEST['post_content']); break; case 'get_post': get_post($_REQUEST['id_post']); break; case 'get_comments': get_comments($_REQUEST['id_post']); break; case 'comment_post': comment_post($_REQUEST['id_post'], $_REQUEST['username'], $_REQUEST['id_user'], $_REQUEST['comment']); break; case 'qualify': qualify($_REQUEST['id_usuario'], $_REQUEST['qualification']); break; case 'get_average': get_average();
<?php include_once 'resources/midd.php'; if (isset($_POST['image'])) { $errors = array(); $image = trim($_POST['image']); if (empty($errors)) { add_post($image); } } session_start(); if (!isset($_SESSION["sess_user"])) { header("location: ../login.php"); } else { ?> <!DOCTYPE html> <html> <head> <title>DMS - Add Content</title> <link rel="stylesheet" type="text/css" href="resources/cms.css"> </head> <body> <div id="fullwidth"> <div class="wrapper"> <div id="dmslogo"><img src="images/dmslogo.PNG" /></div> <div id="navmove"> </div> <div class="logout">Hello <?php echo $_SESSION['sess_user']; ?>
function engine_doit(){ global $CONF; $whats = explode(',', $_GET['what']); $result = null; if (isset($_GET['SYSTEM_redirect'])){ unset($_GET['SYSTEM_redirect']); switch($_GET['what']){ case 'topic': include('basichtml/viewtopic.php'); break; case 'datetopics': include('basichtml/topic_list.php'); break; case 'confirm_user': include('controller/confirm_user.php'); break; case 'user_stopmail': include('controller/user_stopmail.php'); break; case 'add_email': include('controller/add_email.php'); break; case 'remove_email': include('controller/remove_email.php'); break; case 'restore_password': include('controller/restore_password.php'); break; case 'followchannel_acceptreject': include('controller/followchannel_acceptreject.php'); break; case 'autoopenchannel': include('controller/autoopenchannel.php'); break; case 'autoopentopic': include('controller/autoopentopic.php'); break; /* case 'ETUEngine': include('tool/ETUEngine.php'); $etu=new ETUEngine(); $etu->start(1); break; */ } return; } foreach ($whats as $what) { switch($what) { case 'fromname': require_once("controller/fromname.php"); $result['fromname'] = fromname($_GET['id_fromname']); break; case 'setuserfrom': require_once("class/User.php"); $tuser = new RegUser(); $tuser->setNickname($_GET['nick_setuserfrom']); $valid = $tuser->validatePassword($_GET['pass_setuserfrom']); if ($valid) { $tuser->load(); $tuser->setCameFrom($_GET['fromid_setuserfrom']); $tuser->save(); } break; case 'message': require_once('template/TMessage.php'); require_once('class/Message.php'); $message = new Message(); if (isset($_GET['id_message']) && !empty($_GET['id_message'])) $message->setId($_GET['id_message']); else { $result['message']=array(); break; } $tmessage = new TMessage(); $tmessage->setMessage($message); $result['message']=$tmessage->getJsonTags(); break; case 'mymessages': require_once('template/TListMessage.php'); $tlist = new TListMessage(); $tlist->setListType("cloneMy"); $tlist->setOnlySubsumed(true); if (isset($_GET['sorting_mymessages'])) $tlist->setSorting($_GET['sorting_mymessages']); if (isset($_GET['lastid_mymessages'])) $tlist->setLastId($_GET['lastid_mymessages']); $result['mymessages']=$tlist->getJsonTags(); break; case 'regchannel': require_once("template/TChannel.php"); require_once("class/Channel.php"); $t = new TChannel(); $o=new Channel(); $prettyUrl=''; if (isset($_GET['id_regchannel'])) { $o->setId($_GET['id_regchannel']); } elseif (isset($_GET['name_regchannel'])) { if (substr($_GET['name_regchannel'],-1,1)=='-'){ $result['regchannel']=array("ok"=>false,"error"=>"invalid name","exist"=>true,'prettyUrl'=>''); break; } else { $o->setName($_GET['name_regchannel']); $prettyUrl=Channel::prettyUrlAvailable($_GET['name_regchannel']); } } elseif (isset($_GET['urlname_regchannel'])) { if ($_GET['urlname_regchannel'] != Channel::prettyUrl($_GET['urlname_regchannel'])){ $result['regchannel']=array("ok"=>false,"error"=>"invalid url","exist"=>true, 'prettyUrl'=>''); break; } $o->setUrlname($_GET['urlname_regchannel']); $prettyUrl=$_GET['urlname_regchannel']; } else { $result['regchannel']=array("ok"=>false,"error"=>"no param", "exist"=>true, 'prettyUrl'=>''); break; } $t->setChannel($o); $r=$t->getJsonTags(); if ($r['id']==null || $r['name']==null || $r['lang']==null) $result['regchannel']=array("ok"=>true,"error"=>"","exist"=>false,'prettyUrl'=>$prettyUrl); else $result['regchannel']=array("ok"=>true,"error"=>"","exist"=>true,'prettyUrl'=>$r['urlname']); break; case 'channels': require_once('template/TListChannel.php'); $tlist = new TListChannel(); $tlist->setListType("cloneAll"); $tlist->setOnlySubsumed(true); if (isset($_GET['sorting_channels'])) $tlist->setSorting($_GET['sorting_channels']); $result['channels']=$tlist->getJsonTags(); break; case 'followedchannels': require_once('template/TListChannel.php'); $tlist = new TListChannel(); if ($_SESSION['user']->isAnon()) $tlist->setListType("cloneAll"); else $tlist->setListType("cloneFollowed"); $tlist->setOnlySubsumed(true); if (isset($_GET['sorting_followedchannels'])) $tlist->setSorting($_GET['sorting_followedchannels']); $result['followedchannels']=$tlist->getJsonTags(); break; case 'mychannels': require_once('template/TListChannel.php'); $tlist = new TListChannel(); $tlist->setListType("cloneMy"); $tlist->setOnlySubsumed(false); if (isset($_GET['sorting_mychannels'])) $tlist->setSorting($_GET['sorting_mychannels']); $result['mychannels']=$tlist->getJsonTags(); break; case 'mostvisitedchannels': require_once('template/TListChannel.php'); $tlist = new TListChannel(); $tlist->setListType("cloneMostVisited"); $tlist->setOnlySubsumed(false); if (isset($_GET['qtd_mostvisitedchannels'])) $tlist->setQtd($_GET['qtd_mostvisitedchannels']); if (isset($_GET['signed_mostvisitedchannels'])) $tlist->setSigned($_GET['signed_mostvisitedchannels']); $result['mostvisitedchannels']=$tlist->getJsonTags(); break; case 'recommendedchannels': require_once('template/TListChannel.php'); $tlist = new TListChannel(); $tlist->setListType("cloneRecommended"); $tlist->setOnlySubsumed(false); if (isset($_GET['qtd_recommendedchannels'])) $tlist->setQtd($_GET['qtd_recommendedchannels']); $result['recommendedchannels']=$tlist->getJsonTags(); break; case 'channel': require_once('template/TChannel.php'); require_once('class/Channel.php'); $channel = new Channel(); if (isset($_GET['id_channel']) && !empty($_GET['id_channel'])) $channel->setId($_GET['id_channel']); elseif (isset($_GET['name_channel']) && !empty($_GET['name_channel'])) $channel->setName($_GET['name_channel']); else { $result['channel']=array(); break; } $tchannel = new TChannel(); $tchannel->setChannel($channel); $result['channel']=(array('channel'=>$tchannel->getJsonTags(), "topics"=>array() )); break; case 'followedchanneltopics': require_once('template/TListTopic.php'); $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneChannelFollowed"); $tlisttopic->setOnlySubsumed(true); if (isset($_GET['orderid_followedchanneltopics'])) $tlisttopic->setOrderId($_GET['orderid_followedchanneltopics']); if (isset($_GET['lastorderid_followedchanneltopics'])) $tlisttopic->setLastOrderId($_GET['lastorderid_followedchanneltopics']); if (isset($_GET['sorting_followedchanneltopics'])) $tlisttopic->setSorting($_GET['sorting_followedchanneltopics']); if (isset($_GET['qtd_followedchanneltopics'])) $tlisttopic->setQtd($_GET['qtd_followedchanneltopics']); $result['followedchanneltopics']=$tlisttopic->getJsonTags(); break; case 'recenttopics': require_once('getter/recenttopics.php'); $result['recenttopics']=recenttopics(); break; case 'datetopics': require_once('template/TListTopic.php'); if (!isset($_GET['year_datetopics'])) { $result['datetopics']=array(); break; } $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneByDate"); $tlisttopic->setOnlySubsumed(true); $tlisttopic->setYear($_GET['year_datetopics']); if (isset($_GET['month_datetopics'])) $tlisttopic->setMonth($_GET['month_datetopics']); if (isset($_GET['day_datetopics'])) $tlisttopic->setDay($_GET['day_datetopics']); $result['datetopics']=$tlisttopic->getJsonTags(); break; case 'searchtopics': require_once('template/TListTopic.php'); require_once('tool/SearchTopic.php'); if (isset($_GET['words_searchtopics'])){ $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneSearch"); $tlisttopic->setOnlySubsumed(true); $tlisttopic->setSearch(SearchTopic::getQuery($_GET['words_searchtopics'])); if (isset($_GET['orderid_searchtopics'])) $tlisttopic->setOrderId($_GET['orderid_searchtopics']); $result['searchtopics']=$tlisttopic->getJsonTags(); } else $result['searchtopics']=array("ok"=>false,"error"=>"no words"); break; case 'searchmain': require_once('template/TListChannel.php'); require_once('tool/SearchEngine.php'); if (isset($_GET['words_searchmain'])){ $tlisttopic = new TListChannel(); $tlisttopic->setListType("cloneSearch"); $tlisttopic->setOnlySubsumed(true); $tlisttopic->setSearch(SearchEngine::getQueryChannels(unescape_ampersand($_GET['words_searchmain']))); //if (isset($_GET['orderid_searchtopics'])) $tlisttopic->setOrderId($_GET['orderid_searchtopics']); $result['searchmain']['channels']=$tlisttopic->getJsonTags(); } else $result['searchmain']=array("ok"=>false,"error"=>"no words"); break; case 'usertopics': require_once('template/TListTopic.php'); require_once('class/User.php'); if (isset($_GET['nickname_usertopics'])){ $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneByUser"); $tlisttopic->setOnlySubsumed(true); if (isset($_GET['sorting_usertopics'])) $tlisttopic->setSorting($_GET['sorting_usertopics']); $u=new RegUser(); $u->setNickname($_GET['nickname_usertopics']); $u->load(); $tlisttopic->setUser($u); if (isset($_GET['orderid_usertopics'])) $tlisttopic->setOrderId($_GET['orderid_usertopics']); if (isset($_GET['idchannel_usertopics'])) $tlisttopic->setIdChannel($_GET['idchannel_usertopics']); $result['usertopics']=$tlisttopic->getJsonTags(); } else $result['usertopics']=array(); break; case 'userposttopics': require_once('template/TListTopic.php'); require_once('class/User.php'); if (isset($_GET['nickname_userposttopics'])){ $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneByUserPost"); $tlisttopic->setOnlySubsumed(true); if (isset($_GET['sorting_userposttopics'])) $tlisttopic->setSorting($_GET['sorting_userposttopics']); $u=new RegUser(); $u->setNickname($_GET['nickname_userposttopics']); $u->load(); $tlisttopic->setUser($u); if (isset($_GET['orderid_userposttopics'])) $tlisttopic->setOrderId($_GET['orderid_userposttopics']); if (isset($_GET['idchannel_userposttopics'])) $tlisttopic->setIdChannel($_GET['idchannel_userposttopics']); $result['userposttopics']=$tlisttopic->getJsonTags(); } else $result['userposttopics']=array(); break; case 'uft': require_once('getter/uft.php'); $result['uft']=uft(); break; case 'followedtopics': require_once('conf/session.php'); require_once('template/TListTopic.php'); $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneFollowed"); $tlisttopic->setOnlySubsumed(true); if (isset($_GET['orderid_followedtopics'])) $tlisttopic->setOrderId($_GET['orderid_followedtopics']); if (isset($_GET['idchannel_followedtopics'])) $tlisttopic->setIdChannel($_GET['idchannel_followedtopics']); $result['followedtopics']=$tlisttopic->getJsonTags() ; break; case 'topic': if (!isset($_GET['id_topic']) || empty($_GET['id_topic'])) { $result['topic']=array(); break; } require_once('template/TTopic.php'); require_once('template/TListPost.php'); require_once('class/Topic.php'); require_once('class/Channel.php'); $topic = new Topic(); $topic->setId($_GET['id_topic']); if (!$topic->getChannel()->canIRead()){ $result['topic']=array("error"=>'you cant see this topic'); break; } $ttopic = new TTopic(); $ttopic->setTopic($topic); $tlistpost = new TListPost(); $tlistpost->setTopic($topic); $tlistpostbest = new TListPost(); $tlistpostbest->setTopic($topic); $tlistpostbest->setQtd($CONF['post_best_qt']); $tlistpostbest->setSorting("likes desc,date desc"); $result['topic']=(array('topic'=>$ttopic->getJsonTags(), "posts"=>$tlistpost->getJsonTags(), "bestposts"=>$tlistpostbest->getJsonTags()) ); break; case 'refresh_topic_previews': if (!isset($_GET['ids_refresh_topic_previews']) || empty($_GET['ids_refresh_topic_previews'])) { $result['refresh_topic_previews']=array(); break;} if (!isset($_GET['versions_refresh_topic_previews']) || empty($_GET['versions_refresh_topic_previews'])) { $result['refresh_topic_previews']=array(); break;} require_once("template/TListTopic.php"); $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneUpdated"); $tlisttopic->setOnlySubsumed(true); $tlisttopic->setIds(explode(",",$_GET['ids_refresh_topic_previews'])); $tlisttopic->setCounters(explode(",",$_GET['versions_refresh_topic_previews'])); $result['refresh_topic_previews']=$tlisttopic->getJsonTags(); break; case 'refresh_topics': if (!isset($_GET['ids_refresh_topics']) || empty($_GET['ids_refresh_topics'])) { $result['refresh_topics']=array(); break;} if (!isset($_GET['versions_refresh_topics']) || empty($_GET['versions_refresh_topics'])){ $result['refresh_topics']=array(); break;} require_once("template/TListTopic.php"); $tlisttopic = new TListTopic(); $tlisttopic->setListType("cloneUpdated"); $tlisttopic->setWithPosts(true); if (isset($_GET['idchannel_refresh_topics'])) $tlisttopic->setIdChannel($_GET['idchannel_refresh_topics']); $tlisttopic->setIds(explode(",",$_GET['ids_refresh_topics'])); $tlisttopic->setCounters(explode(",",$_GET['versions_refresh_topics'])); $result['refresh_topics']=$tlisttopic->getJsonTags(); break; case 'new_topic_previews': require_once("getter/new_topic_previews.php"); $result['new_topic_previews']=new_topic_previews(); break; case 'reguser': require_once("template/TUser.php"); require_once("class/User.php"); $tuser = new TUser(); $u=new RegUser(); if (isset($_GET['id_reguser'])) $u->setId($_GET['id_reguser']); elseif (isset($_GET['email_reguser'])) $u->setEmail($_GET['email_reguser']); elseif (isset($_GET['nickname_reguser'])) { if (substr($_GET['nickname_reguser'],-1,1)=='-'){ $result['reguser']=array("ok"=>true,"error"=>"","exist"=>true); break; } else { $u->setNickname($_GET['nickname_reguser']); } } else { $result['reguser']=array("ok"=>false,"error"=>"no param"); break; } $tuser->setUser($u); $r=$tuser->getJsonTags(); if ($r['id']==null || $r['nickname']==null || $r['lang']==null) $result['reguser']=array("ok"=>true,"error"=>"","exist"=>false); else $result['reguser']=array("ok"=>true,"error"=>"","exist"=>true); break; case 'userscamefrom': require_once('template/TListUser.php'); $tlist = new TListUser(); $tlist->setListType("cloneLastCameFrom"); if (isset($_GET['camefrom_userscamefrom'])) $tlist->setCameFrom($_GET['camefrom_userscamefrom']); if (isset($_GET['qtd_userscamefrom'])) $tlist->setQtd($_GET['qtd_userscamefrom']); $result['userscamefrom']=$tlist->getJsonTags(); break; case 'user': require_once("template/TUser.php"); require_once("class/User.php"); global $user; $tuser = new TUser(); if (!isset($_GET['id_user']) || !isset($_GET['anon_user'])){ $tuser->setUser($user); $tuser->setWithEmail(true); } else{ if ($_GET['anon_user']){ $u = new AnonUser(); $u->setId($_GET['id_user']); } else { $u = new RegUser(); $u->setId($_GET['id_user']); } $tuser->setUser($u); } $result['user']=$tuser->getJsonTags(); break; case 'add_topic': require_once('controller/add_topic.php'); $result['add_topic']=add_topic(); break; case 'add_message': require_once('controller/add_message.php'); $result['add_message']=add_message(); break; case 'read_message': require_once('controller/read_message.php'); $result['read_message']=read_message(); break; case 'add_channel': require_once('controller/add_channel.php'); $result['add_channel']=add_channel(); break; case 'add_post': require_once('controller/add_post.php'); $result['add_post']=add_post(); break; case 'update_channel': require_once('controller/update_channel.php'); $result['update_channel']=update_channel(); break; case 'update_topic': require_once('controller/update_topic.php'); $result['update_topic']=update_topic(); break; case 'update_post': require_once('controller/update_post.php'); $result['update_post']=update_post(); break; case 'followtopic': require_once('controller/followtopic.php'); $result['followtopic']=followtopic(); break; case 'unfollowtopic': require_once('controller/unfollowtopic.php'); $result['unfollowtopic']=unfollowtopic(); break; case 'followchannel': require_once('controller/followchannel.php'); $result['followchannel']=followchannel($_GET['channelid_followchannel']); break; case 'followchannels': require_once('controller/followchannel.php'); $chids=explode(",",$_GET['channelids_followchannels']); for ($i=0;$i<count($chids);$i++) $result['followchannels'][$i]=followchannel($chids[$i]); break; case 'unfollowchannel': require_once('controller/unfollowchannel.php'); $result['unfollowchannel']=unfollowchannel(); break; case 'create_account': require_once('controller/create_account.php'); $result['create_account']=create_account(); break; case 'update_user_avatar': require_once('controller/update_user_avatar.php'); $result['update_user_avatar'] = update_user_avatar($_GET['file'],$_GET['x1'],$_GET['y1'],$_GET['x2'],$_GET['y2']); break; case 'upload_temp_avatar': require_once('controller/upload_temp_avatar.php'); $result['upload_temp_avatar'] = upload_temp_avatar(); break; case 'update_channel_logo': require_once('controller/update_channel_logo.php'); $result['update_channel_logo'] = update_channel_logo($_GET['file'],$_GET['x1'],$_GET['y1'],$_GET['x2'],$_GET['y2']); break; case 'upload_temp_logo': require_once('controller/upload_temp_logo.php'); $result['upload_temp_logo'] = upload_temp_logo(); break; case 'update_user': require_once('controller/update_user.php'); $result['update_user'] = update_user(); break; case 'change_user_lang': require_once('controller/change_user_lang.php'); $result['change_user_lang']=change_user_lang(); break; case 'like_dislike_this': require_once("controller/like_dislike_this.php"); $result['like_dislike_this'] = like_dislike_this(); break; case 'signin': $result['signin'] = signin($_POST['nickname_signin'], $_POST['password_signin'], false, $_POST['staysignedin_signin']); break; case 'signout': require_once("controller/signout.php"); $result['signout'] = signout(); break; case 'request_restore_password': require_once('controller/request_restore_password.php'); $result['request_restore_password']=request_restore_password(); break; case 'visittopic': require_once('class/Topic.php'); if (!isset($_GET['topicid_visittopic'])) $result['visittopic']=array("ok"=>false,"error"=>"error no id"); else { $topic = new Topic(); $topic->setId($_GET['topicid_visittopic']); if ($topic->visit()) $result['visittopic']=array("ok"=>true,"error"=>""); else $result['visittopic']=array("ok"=>false,"error"=>"error db"); } break; case 'deletetopic': require_once('controller/deletetopic.php'); $result['deletetopic']=deletetopic(); break; case 'lang': require_once('conf/location.php'); global $LANG; $result['lang']=$LANG['JSON']; break; default: break; } } return $result; }
<?php // Recieving command if (!isset($_REQUEST['cmd'])) { echo '{"result": 0, "message": "Unknown command"}'; return; } $cmd = $_REQUEST['cmd']; // Switch statement to handle different type of commands switch ($cmd) { // case 1 add a post case 1: add_post($_REQUEST['user'], $_REQUEST['content'], $_REQUEST['category']); break; // case 2 get post from a particular user // case 2 get post from a particular user case 2: get_user_post($_REQUEST['user']); break; // Get all post // Get all post case 3: get_all_post(); break; // Get a given amount of recent post // Get a given amount of recent post case 4: $num = 10; get_recent_post($num); break; // Get all post from a given category
<?php // neprihláseným vstup zakázaný if (!is_logged_in()) { add_message("Musíte sa prihlásiť."); redirect("/prihlasenie"); } if (is_post()) { $post_id = add_post(); // ak sa nám podarilo pridať článok if ($post_id) { // skusíme pridať aj obrázok addImage($post_id); // a presmerujeme redirect("clanok/" . $post_id); } } $tags = get_tags(); include_header(array("title" => "Pridanie článku")); ?> <h1 class="text-center">Nový článok</h1> <form method="post" enctype="multipart/form-data"> <label for="title"><strong>Názov článku:</strong></label> <input type="text" name="title" id="title" value="<?php echo isset($_POST["title"]) ? $_POST["title"] : ""; ?> ">
/** * @expectedException WPDieException */ public function testAfterDeletePostDie() { add_post(1, new WP_Post()); $searchClient = m::mock('AliyunOpenSearchClient'); $this->admin->setOpenSearchClient($searchClient); $searchClient->shouldReceive('deletePosts')->once()->andThrow('AliyunOpenSearchException'); $this->admin->afterDeletePost(1); }
function update_database($pdo) { /* Make sure there is a posts table. */ $pdo->exec("CREATE TABLE IF NOT EXISTS posts (\n id TEXT,\n title TEXT,\n date DATETIME\n )"); /* Make sure there is a tags table. */ $pdo->exec("CREATE TABLE IF NOT EXISTS tags (\n post_id INTEGER,\n tag TEXT\n )"); if ($handle = opendir(POST_DIR)) { /* Read all the files in the post directory. */ while (false !== ($entry = readdir($handle))) { /* Disregard any non-markdown files. */ if (substr($entry, -strlen(POST_EXTENSION)) === "markdown") { $path = realpath(POST_DIR . "/" . $entry); /* The ID of the post will be the filename */ $id = basename($path, "." . POST_EXTENSION); /* See if there are any posts by this post's ID */ $existence_statement = $pdo->prepare("SELECT id\n FROM posts\n WHERE id = :id"); /* Bind the ID parameter and execute the query. */ $existence_statement->bindParam(":id", $id); $existence_statement->execute(); /* If there are no entries with this ID, commit it to the database using its <meta> tags * for all information including post date and tags. */ if (count($existence_statement->fetchAll()) == 0) { add_post($pdo, $id, file_get_contents($path)); } } } } }
case "load_frien_posts": echo json_encode(view_friend_posts()); break; case "view_all_friends_posts": echo json_encode(view_all_friends_posts()); break; case "add_post": $add_post = $_POST['addPost']; $add_post = addslashes($add_post); $add_post = strip_tags($add_post); $add_post_length = strlen($add_post); if ($add_post_length < 1 || $add_post_length > 1000) { echo FALSE; break; } echo add_post($add_post); break; case "update_post": $update_post = $_POST['updatePost']; $update_post = addslashes($update_post); $update_post = strip_tags($update_post); $update_post_length = strlen($update_post); if ($update_post_length < 1 || $update_post_length > 1000) { echo FALSE; break; } $postUid = $_POST['postUid']; $postUid = addslashes($postUid); $postUid = strip_tags($postUid); $postUid_length = strlen($postUid); if ($postUid_length < 10) {
function add_action() { add_post(); }
} if (strlen($_POST['content']) > 3000) { $errors[] = "The content of your post must be less than 3,000 characters."; } $postTitle = $_POST['title']; $postContent = $_POST['content']; $postTags = $_POST['tags']; if ($postTags == "Tags: tagone tagtwo etc.") { $postTags = ""; } // Make sure the user has sufficient permissions to post if (!$user_canpost) { $errors[] = "You do not have sufficient permissions to add new posts."; } if (!inError()) { if (add_post($user_id, $postTitle, $postContent, $postTags)) { $postid = get_post_id($user_id, $postTitle, $postContent); echo "Your post was successfully added! \n"; echo "<a href=\"viewpost.php?postid={$postid}\">Go to post.</a>\n"; } else { $errors[] = "There was an unknown error adding your post"; echo "ERROR: add_post(" . $user_id . ", " . $_POST['title'] . ", " . $_POST['content'] . ", " . $_POST['tags'] . ")"; } } if (inError()) { echo "<p>There were some problems with your form. Please go back and try again.</p><br /><br />"; // Display error messages // TODO: change to error handler function write_errors($errors); // lives in lib/errormanagement.php }
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; } else { if (move_uploaded_file($_FILES["post_image"]["tmp_name"], $target_file)) { echo "The file " . basename($_FILES["post_image"]["name"]) . " has been uploaded."; //create safe values for input into the database $display_block = add_post($_FILES["post_image"]["name"]); } else { echo "Sorry, there was an error uploading your file."; } } } else { $display_block = add_post('no_img.png'); } //close connection to MySQL mysqli_close($link); function add_post($file_name) { global $link; if ($_SESSION['username'] == 'Woof Warrior') { $owner = 'Woof Warrior'; } else { $owner = $_SESSION['userID']; } $clean_post_title = mysqli_real_escape_string($link, $_POST['post_title']); $clean_post_text = mysqli_real_escape_string($link, $_POST['post_text']); $clean_image_name = mysqli_real_escape_string($link, $file_name); //create and issue the first query
$contents = trim($_POST['contents']); if (empty($title)) { $errors[] = "You need to supply a title."; } else { if (strlen($title) > 255) { $errors[] = "The title cannot be longer than 255 characters."; } } if (empty($contents)) { $errors[] = "You need to supply some text."; } if (!category_exits('id', $_POST['category'])) { $errors[] = "The category does not exit."; } if (empty($errors)) { add_post($title, $contents, $_POST['category']); $id = mysql_insert_id(); Header("Location: index.php?id={$id}"); die; } } ?> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="bootstrap.min.css"> <style> label{display : block; } </style>
<script src="js/jquery.js"></script> <script src="../js/bootstrap-datepicker.js"></script> <script type="text/javascript"> $(window).load(function(){ $('#automodal').modal('show'); }); $('#add').on('shown.bs.modal', function () { $('#add').focus() }) </script> </head> <body> <?php echo add_post(); ?> <div id="wrapper"> <!-- Navigation --> <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <a class="navbar-brand" href="index.php" id="nav-pandan">KATAR 06</a> </div> <!-- Top Menu Items --> <ul class="nav navbar-right top-nav"> <li class="dropdown"> <a href="" class="dropdown-toggle" data-toggle="dropdown"><?php echo chat_pesan_counter();
require_once "../includes/global_ui.php"; require_once "../connexion.php"; if (!isset($_GET["a"])) { $a = "home"; } else { $a = $_GET["a"]; } switch ($a) { case "home": home(); break; case "add": add(); break; case "add_post": add_post(); break; case "edit": edit(); break; case "edit_post": edit_post(); break; case "suppr_post": suppr_post(); break; default: echo "Erreur de redirection"; } function home() {
<?php session_start(); include_once "header.php"; function add_post($userid, $message) { global $conn; $sql = "insert into posts (user_id, message, stamp) values ({$userid}, '" . mysqli_real_escape_string($conn, $message) . "',now())"; $result = mysqli_query($conn, $sql); } // Get the userid $userid = $_SESSION['userid']; // TODO truncate length to 160 $message = $_POST['message']; add_post($userid, $message); $_SESSION['message'] = "Your post successfully added."; // Go back to the index page header("Location:02_welcome.php"); ?>
<?php /** * Template created by Gregory Chris */ load_model('admin/tutorials'); if (array_key_exists('submit', $_POST) && $_POST['submit'] == 'Save') { if (array_key_exists('post_id', $_POST) && is_numeric($_POST['post_id']) && $_POST['post_id'] > 0) { update_post($_POST['post_id'], $_POST); } } if (array_key_exists('submit', $_POST) && $_POST['submit'] == 'Delete') { if (array_key_exists('post_id', $_POST) && is_numeric($_POST['post_id']) && $_POST['post_id'] > 0) { delete_post($_POST['post_id']); } } if (array_key_exists('submit', $_POST) && $_POST['submit'] == 'Add') { add_post($_POST); } header('Location: ' . _HTTP_ROOT . '/admin/tutorials/'); die;
<?php include "header.php"; //if the form has submitted if (isset($_POST["submit"])) { //check for errors $error = check_addpost_form_error(); if ($error == "") { // do something add_post($con); } else { show_addpost_form($error); } } else { show_addpost_form(); } include "footer.php";