Exemplo n.º 1
0
 /**
  * データベースへの登録アクション
  * @return Ambigous <\Illuminate\Routing\Redirector, \Illuminate\Http\RedirectResponse, mixed, \Illuminate\Container\static>
  */
 public function insert()
 {
     $thread = new thread();
     //バリデーションの設定
     $validation = Validator::make(['thread_id' => Input::get('thread_id'), 'thread' => Input::get('thread'), 'content' => Input::get('content'), 'image' => Input::file('image')], ['thread_id' => 'integer', 'thread' => 'string', 'content' => 'required|max:512', 'image' => 'image'], ['required' => '内容は入力必須項目です', 'image' => 'jpg,png,gif以外の画像をアップロードしないでください']);
     //バリデーション失敗時
     if ($validation->fails()) {
         return redirect()->back()->withErrors($validation->errors());
     }
     //ユーザ名
     $user = Input::has('user') ? Input::get('user') : 'noname';
     // アップロード画像を取得
     $image = Input::file('image');
     if (Input::file('image')) {
         // ファイル名を生成し画像をアップロード
         $name = md5(sha1(uniqid(mt_rand(), true))) . '.' . $image->getClientOriginalExtension();
         $upload = $image->move('media', $name);
         $upload = preg_replace('/media\\\\/', 'media/', $upload);
     }
     if (Input::has('thread') && Input::has('content')) {
         //スレッド作成からのリクエスト
         //スレッドのタイトルが被らないかどうかチェック
         $threads = $thread->all(array('thread'));
         $threadName = Input::get('thread');
         foreach ($threads as $val) {
             if ($val['thread'] == $threadName) {
                 return back()->withInput()->withErrors(array('同じスレッド名が存在します'));
             }
         }
         //スレッド情報をデータベースへ登録
         $thread->thread = $threadName;
         $thread->user = $user;
         $thread->save();
         $threads = $thread->where('thread', '=', $threadName)->get();
         $thread_id = $threads[0]['id'];
         $response = NULL;
     } else {
         if (Input::has('thread_id') && Input::has('content')) {
             //スレッド詳細からのリクエスト
             $thread_id = Input::get('thread_id');
             $response = ctype_digit(Input::get('response')) ? Input::get('response') : '';
         } else {
             return back()->withInput()->withErrors(array('スレッド名と内容を入力してください'));
         }
     }
     //投稿の登録
     $result = isset($upload) && $upload ? Comment::insertComment($thread_id, $user, Input::get('content'), $response, $upload) : Comment::insertComment($thread_id, $user, Input::get('content'), $response);
     //スレッド内からのリクエストかどうかをチェック
     return !Input::has('thread') ? redirect('/thread?id=' . $thread_id) : redirect('/');
 }
Exemplo n.º 2
0
 public function index()
 {
     //        $pass=_get('pass');
     //        $name=I ('get.name');
     //        $arr=array("xx"=>$pass,"name"=>$name,"time"=>\lib_time::gmtime());
     //        \Msg::outPut($arr);
     //        $out= json_encode($arr);
     //        exit($out);
     //$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover,{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p><br/>版本 V{$Think.version}</div><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_55e75dfae343f5a1"></thinkad><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
     $ip = "bookfuns.com";
     $port = 80;
     // echo \Streams::moni();
     // require_once 'thread.class.php';
     //  \thread::pf('action_log');
     \thread::rolling_curl(array("http://localhost/app/Home/Echo"));
     //$this->display();
 }
Exemplo n.º 3
0
<?php

require '../includes/config.php';
require '../structure/database.php';
require '../structure/forum.php';
require '../structure/forum.thread.php';
require '../structure/base.php';
require '../structure/user.php';
$database = new database($db_host, $db_name, $db_user, $db_password);
$base = new base($database);
$user = new user($database);
$forum = new forum($database);
$thread_obj = new thread($database);
$user->updateLastActive();
//make sure required data is in the correct format AND they're logged in
if (!$user->isLoggedIn() || !ctype_digit($_REQUEST['forum']) || !ctype_digit($_REQUEST['id']) || !ctype_digit($_REQUEST['type']) || !ctype_digit($_REQUEST['pid']) && $_REQUEST['type'] == 1) {
    $base->redirect('index.php');
}
//set some variables that are used a lot throughout the page
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
$f = $_REQUEST['forum'];
$thread = $_REQUEST['id'];
//instead of typing it a million times, we're going to set our redirect url
$redirect = 'viewthread.php?forum=' . $f . '&id=' . $thread;
//make sure they are posting in a forum where they have permission
if ($user->checkMute($username) || !$thread_obj->canView($thread, $username, $rank) || !$thread_obj->canReply($thread, $rank)) {
    $base->redirect($redirect);
}
//extract content for the set type
$data = $_REQUEST['type'] == 1 ? $database->processQuery("SELECT `content`,`username`,`status` FROM `posts` WHERE `id` = ?", array($_REQUEST['pid']), true) : $database->processQuery("SELECT `username`,`content`,`status`,`title` FROM `threads` WHERE `id` = ?", array($thread), true);
<?php

require '../../includes/config.php';
require '../../structure/database.php';
require '../../structure/forum.php';
require '../../structure/forum.thread.php';
require '../../structure/base.php';
require '../../structure/user.php';
$database = new database($db_host, $db_name, $db_user, $db_password);
$thread = new thread($database);
$base = new base($database);
$user = new user($database);
$user->updateLastActive();
//useful variables
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
$id = $_GET['id'];
//take action then log it
if ($thread->checkExistence($id) && $thread->canView($id, $username, $rank) && $rank > 2) {
    $thread_info = $database->processQuery("SELECT `autohiding` FROM `threads` WHERE `id` = ?", array($id), true);
    $database->processQuery("UPDATE `threads` SET `autohiding` = ? WHERE `id` = ?", array($thread_info[0]['autohiding'] == 1 ? 0 : 1, $id), false);
    $base->appendToFile('../logs.txt', array($username . ' toggled the auto-hide of the thread ' . $id));
} else {
    $base->redirect('../viewthread.php?forum=' . $_GET['forum'] . '&id=' . $id . '&goto=start');
}
$redirect = 'http://' . $domain . '/forums/viewthread.php?forum=' . $_GET['forum'] . '&id=' . $id . '&goto=start';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:IE>

<!-- LeeStrong Runescape Website Source --!>
Exemplo n.º 5
0
 protected static function create($cat, $specifics, $user)
 {
     // Call DB Connector
     $callDB = new PGSdb();
     $callDB->connDB();
     $newThreadName = $specifics['title'];
     $newThreadPost = $specifics['content'];
     $newThreadCategory = $cat;
     $newThreadTime = time();
     $newThreadAuthor = $user['Username'];
     //Prepare
     $newThreadPrep = $callDB->db->prepare("INSERT INTO forum_threads(category, title, author, lastposter, timecreated, timelastpost) VALUES(:categoryN, :titleN, :authorN, :lastposterN, :timecreatedN, :timelastpostN)");
     //Execute
     $newThreadPrep->execute(array('categoryN' => $newThreadCategory, 'titleN' => $newThreadName, 'authorN' => $newThreadAuthor, 'lastposterN' => $newThreadAuthor, 'timecreatedN' => $newThreadTime, 'timelastpostN' => $newThreadTime));
     //Get the thread id
     $getNewThreadID = thread::get_by_title($newThreadName, $newThreadTime);
     $newThreadID = $getNewThreadID['id'];
     //Queue in the thread message into posts
     //Prepare
     $newPostPrep = $callDB->db->prepare("INSERT INTO forum_posts(category, thread, postorderid, author, post, timeposted) VALUES(:categoryN, :threadN, :postorderidN, :authorN, :postN, :timepostedN)");
     //Execute
     $postOrderID = '1';
     $newPostPrep->execute(array('categoryN' => $newThreadCategory, 'threadN' => $newThreadID, 'postorderidN' => $postOrderID, 'authorN' => $newThreadAuthor, 'postN' => $newThreadPost, 'timepostedN' => $newThreadTime));
     // //Incriment users post and thread count
     // $this->updateUserPostCount($newThreadAuthor);
     return array('createCategory' => $cat, 'threadCreated' => $getNewThreadID, 'postCreated' => $newPostPrep->rowCount());
 }
Exemplo n.º 6
0
<?php

require '../includes/config.php';
require '../structure/base.php';
require '../structure/forum.php';
require '../structure/forum.index.php';
require '../structure/forum.thread.php';
require '../structure/forum.post.php';
require '../structure/database.php';
require '../structure/user.php';
$database = new database($db_host, $db_name, $db_user, $db_password);
$base = new base($database);
$user = new user($database);
$forum = new forum($database);
$forum_index = new forum_index($database);
$thread = new thread($database);
$post = new post($database);
$user->updateLastActive();
//get config
$config = $base->loadConfig();
//set some variables that are used a lot throughout the page
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
$f = $_GET['forum'];
$i = $_GET['id'];
//preform basic checks
if (!ctype_digit($f) || !ctype_digit($i) || !$thread->checkExistence($i) || !$thread->canView($i, $username, $rank)) {
    $base->redirect('index.php');
}
//if the GOTO field is set, let's skip to the selected post
if (ctype_digit($_GET['goto'])) {
Exemplo n.º 7
0
<?php

require '../includes/config.php';
require '../structure/database.php';
require '../structure/base.php';
require '../structure/forum.php';
require '../structure/forum.thread.php';
require '../structure/user.php';
$base = new base();
$database = new database($db_host, $db_name, $db_user, $db_password);
$user = new user($database);
$forum = new forum($database);
$thread_obj = new thread($database);
$user->updateLastActive();
//get the user's rank and username, and set the forum variable (less typing)
$username = $user->getUsername($_COOKIE['user'], 0);
$rank = $user->getRank($username);
$f = $_GET['forum'];
//let's also make sure they have the right permissions to view the forum
if ($forum->canView($f, $rank) == false) {
    $base->redirect('index.php');
}
//check if a moderator is taking action against threads
if (isset($_POST['action']) && isset($_POST['selection']) && $rank > 2) {
    //get all the threads we're going to update
    foreach ($_POST['selection'] as $object) {
        $threads .= $object . '-';
    }
    //now send them off to action.php to update all the threads selected
    $base->redirect('action.php?forum=' . $f . '&action=' . $_POST['action'] . '&threads=' . $threads);
}
Exemplo n.º 8
0
<?php

/**
@title:PHP多线程类(Thread)
@version:1.0
@author:axgle <*****@*****.**>
*/
$th = new thread(10);
//10个线程
$th->exec('demo');
//执行自定义的函数
function demo()
{
    fopen('data/' . microtime(), 'w');
}
class thread
{
    var $count;
    function thread($count = 1)
    {
        $this->count = $count;
    }
    function _submit()
    {
        for ($i = 1; $i <= $this->count; $i++) {
            $this->_thread();
        }
        return true;
    }
    function _thread()
    {
Exemplo n.º 9
0
 public function createNewThread($title, $text, $toptopic = -1)
 {
     $this->connect->exec("INSERT INTO `" . $this->dbPrefix . "forum_threads` (`forumid`, `userid`, `title`, `text`, `timestamp`, `toptopic`) VALUES (NULL, '" . $this->user->getId() . "', '" . $title . "', '" . $text . "', CURRENT_TIMESTAMP, '" . $toptopic . "');");
     $this->nrOfThreads += 1;
     $thread = new thread();
     $thread->setId($this->connect->lastInsertId());
     $thread->setText($text);
     $thread->setTimestamp("");
     $thread->setTitle($title);
     $thread->setUserId($this->user->getId());
     $thread->setTopTopic($toptopic);
     $thread->setUsername($this->user->getUsername(), $this->connect);
     array_push($this->threads, $thread);
     return $this->connect->lastInsertId();
 }
Exemplo n.º 10
0
<?php

require '../../includes/config.php';
require '../../structure/database.php';
require '../../structure/forum.php';
require '../../structure/forum.thread.php';
require '../../structure/base.php';
require '../../structure/user.php';
$database = new database($db_host, $db_name, $db_user, $db_password);
$thread = new thread($database);
$base = new base($database);
$user = new user($database);
$user->updateLastActive();
//useful variables
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
$id = $_GET['id'];
//take action then log it
if ($thread->checkExistence($id) && $thread->canView($id, $username, $rank) && $rank > 2) {
    if ($_GET['type'] == 2) {
        $thread->coverThread($id, $rank);
        $base->appendToFile('../logs.txt', array($username . ' hid the thread ' . $id));
    } else {
        $thread->hideThread($id, $rank);
        $base->appendToFile('../logs.txt', array($username . ' hid the thread ' . $id));
    }
} else {
    $base->redirect('../viewthread.php?forum=' . $_GET['forum'] . '&id=' . $id . '&goto=start');
}
$redirect = 'http://' . $domain . '/forums/viewthread.php?forum=' . $_GET['forum'] . '&id=' . $id . '&goto=start';
?>
Exemplo n.º 11
0
<?php

require '../../includes/config.php';
require '../../structure/database.php';
require '../../structure/forum.php';
require '../../structure/forum.thread.php';
require '../../structure/base.php';
require '../../structure/user.php';
$database = new database($db_host, $db_name, $db_user, $db_password);
$thread = new thread($database);
$base = new base($database);
$user = new user($database);
$user->updateLastActive();
$username = $user->getUsername($_COOKIE['user'], 2);
//get the user's last bump
$data = $database->processQuery("SELECT `lastbump` FROM `users` WHERE `username` = ?", array($username), true);
if (time() - $data[0]['lastbump'] > 3600 && $thread->canReply($_GET['id'], $user->getRank($username))) {
    $thread->bumpThread($_GET['id'], $username);
} else {
    $base->redirect('../viewthread.php?forum=' . $_GET['forum'] . '&id=' . $_GET['id'] . '&goto=start');
}
$redirect = 'http://' . $path . 'forums/viewthread.php?forum=' . $_GET['forum'] . '&id=' . $_GET['id'] . '&goto=start';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:IE>

<!-- LeeStrong Runescape Website Source --!>
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><!-- /Added by HTTrack -->
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
Exemplo n.º 12
0
<?php

require '../includes/config.php';
require '../structure/base.php';
require '../structure/database.php';
require '../structure/user.php';
require '../structure/forum.php';
require '../structure/forum.index.php';
require '../structure/forum.thread.php';
$base = new base();
$database = new database($db_host, $db_name, $db_user, $db_password);
$user = new user($database);
$forum_index = new forum_index($database);
$forum_thread = new thread($database);
$user->updateLastActive();
//get the user's rank
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
if ($rank > 2) {
    //get selected threads and our action
    $threads = explode('-', $_GET['threads']);
    $action = $_GET['action'];
    //ACTION LIST
    //1 = HIDE
    //2 = LOCK
    //3 = MOVE
    //4 = AUTO-HIDE
    //5 = STICKY
    //6 = DELETE
    if ($action == 3) {
        if (!isset($_GET['moveto'])) {
Exemplo n.º 13
0
<?php

require_once 'classes/post.class.php';
require_once 'classes/thread.class.php';
require_once 'classes/user.class.php';
if (isset($_GET['id'])) {
    $thread = new thread($_GET['id']);
    $threadData = $thread->getData();
    $author = new user($threadData['userid']);
} else {
    header('Location: ?page=forums');
}
if (isset($_POST['submit'])) {
    $post = new post();
    $post->insert($_POST['text'], $_SESSION['userid'], $_GET['id']);
}
$posts = array();
try {
    $getPosts = $con->prepare('select id, text, userid, date from posts where threadid = :threadid');
    $getPosts->bindValue('threadid', $_GET['id'], PDO::PARAM_INT);
    $getPosts->execute();
} catch (PDOException $e) {
    die($config['errors']['database'] . $e->getMessage());
}
while ($post = $getPosts->fetch()) {
    $author = new user($post['userid']);
    $post['username'] = $author->getData()['name'];
    $posts[] = $post;
}
echo $twig->render('thread.html', array('thread' => $threadData, 'author' => $author->getData(), 'loggedin' => isset($_SESSION['userid']), 'posts' => $posts));
Exemplo n.º 14
0
<?php

if (!isset($_SESSION['userid'])) {
    header('Location: ?page=login');
}
require_once 'classes/thread.class.php';
try {
    $getCategories = $con->query('select id, name from categories');
} catch (PDOException $e) {
    die($config['errors']['database'] . $e->getMessage());
}
$categories = array();
while ($c = $getCategories->fetch()) {
    $categories[] = $c;
}
if (isset($_POST['submit'])) {
    $thread = new thread();
    $id = $thread->insert($_POST['title'], $_POST['text'], $_SESSION['userid'], $_POST['categoryid']);
    header('Location: ?page=thread&id=' . $id);
}
echo $twig->render('createthread.html', array('categories' => $categories));
Exemplo n.º 15
0
 private function update_thread($data)
 {
     if ($this->user['SiteRank'] >= 4) {
         if (isset($data['cat']) && isset($data['thread'])) {
             $thread = thread::get($data['thread']);
             if ($thread != null && $data['title'] != '' && $data['title'] != ' ' && $this->user['SiteRank'] >= 4) {
                 $result = thread::update($data);
                 //Build event details to log
                 // $logEventID = '132';
                 // $logDetails = 'Forum post id:'.$post_id.' in thread id:'.$thread.' for category id:'.$category.' deleted!';
                 // $logEventAuthor = $this->user['Username'];
                 //Write to admin log.
                 // $this->eventLog($logEventID, $logDetails, $logEventAuthor);
                 json::resp(array('success' => true));
             } else {
                 self::errorJSON('Error updating thread!');
             }
         }
     }
 }
Exemplo n.º 16
0
 /**
  * 检查是否有线程退出了
  * @param thread $work
  */
 public static function check($work)
 {
     self::$threadIsTerminated = false;
     if ($work->isTerminated()) {
         self::$threadIsTerminated = true;
         return true;
     }
     return false;
 }