示例#1
0
文件: post.php 项目: fugeris/8chan
         $file['file'] = mb_substr($file['file'], mb_strlen($config['dir']['img_root'] . $board['dir'] . $config['dir']['img']));
         if ($file['is_an_image'] && $file['thumb'] != 'spoiler') {
             $file['thumb'] = mb_substr($file['thumb'], mb_strlen($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb']));
         }
     }
 }
 $post = (object) $post;
 $post->files = array_map(function ($a) {
     return (object) $a;
 }, $post->files);
 $error = event('post', $post);
 $post->files = array_map(function ($a) {
     return (array) $a;
 }, $post->files);
 if ($error) {
     undoImage((array) $post);
     error($error);
 }
 $post = (array) $post;
 if ($post['files']) {
     $post['files'] = $post['files'];
 }
 $post['num_files'] = sizeof($post['files']);
 // Commit the post to the database.
 $post['id'] = $id = post($post);
 if (!$tor) {
     insertFloodPost($post);
 }
 // Update statistics for this board.
 updateStatisticsForPost($post);
 // Handle cyclical threads
示例#2
0
function post(array $post)
{
    global $pdo, $board;
    $query = prepare(sprintf("INSERT INTO ``posts_%s`` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :body_nomarkup, :time, :time, :files, :num_files, :filehash, :password, :ip, :sticky, :locked, :cycle, 0, :embed, NULL)", $board['uri']));
    // Basic stuff
    if (!empty($post['subject'])) {
        $query->bindValue(':subject', $post['subject']);
    } else {
        $query->bindValue(':subject', null, PDO::PARAM_NULL);
    }
    if (!empty($post['email'])) {
        $query->bindValue(':email', $post['email']);
    } else {
        $query->bindValue(':email', null, PDO::PARAM_NULL);
    }
    if (!empty($post['trip'])) {
        $query->bindValue(':trip', $post['trip']);
    } else {
        $query->bindValue(':trip', null, PDO::PARAM_NULL);
    }
    $query->bindValue(':name', $post['name']);
    $query->bindValue(':body', $post['body']);
    $query->bindValue(':body_nomarkup', $post['body_nomarkup']);
    $query->bindValue(':time', isset($post['time']) ? $post['time'] : time(), PDO::PARAM_INT);
    $query->bindValue(':password', $post['password']);
    $query->bindValue(':ip', isset($post['ip']) ? $post['ip'] : $_SERVER['REMOTE_ADDR']);
    if ($post['op'] && $post['mod'] && isset($post['sticky']) && $post['sticky']) {
        $query->bindValue(':sticky', true, PDO::PARAM_INT);
    } else {
        $query->bindValue(':sticky', false, PDO::PARAM_INT);
    }
    if ($post['op'] && $post['mod'] && isset($post['locked']) && $post['locked']) {
        $query->bindValue(':locked', true, PDO::PARAM_INT);
    } else {
        $query->bindValue(':locked', false, PDO::PARAM_INT);
    }
    if ($post['op'] && $post['mod'] && isset($post['cycle']) && $post['cycle']) {
        $query->bindValue(':cycle', true, PDO::PARAM_INT);
    } else {
        $query->bindValue(':cycle', false, PDO::PARAM_INT);
    }
    if ($post['mod'] && isset($post['capcode']) && $post['capcode']) {
        $query->bindValue(':capcode', $post['capcode'], PDO::PARAM_INT);
    } else {
        $query->bindValue(':capcode', null, PDO::PARAM_NULL);
    }
    if (!empty($post['embed'])) {
        $query->bindValue(':embed', $post['embed']);
    } else {
        $query->bindValue(':embed', null, PDO::PARAM_NULL);
    }
    if ($post['op']) {
        // No parent thread, image
        $query->bindValue(':thread', null, PDO::PARAM_NULL);
    } else {
        $query->bindValue(':thread', $post['thread'], PDO::PARAM_INT);
    }
    if ($post['has_file']) {
        $query->bindValue(':files', json_encode($post['files']));
        $query->bindValue(':num_files', $post['num_files']);
        $query->bindValue(':filehash', $post['filehash']);
    } else {
        $query->bindValue(':files', null, PDO::PARAM_NULL);
        $query->bindValue(':num_files', 0);
        $query->bindValue(':filehash', null, PDO::PARAM_NULL);
    }
    if (!$query->execute()) {
        undoImage($post);
        error(db_error($query));
    }
    return $pdo->lastInsertId();
}
示例#3
0
文件: post.php 项目: nabm/Tinyboard
         // not an image
         //copy($config['file_thumb'], $post['thumb']);
         $post['thumb'] = 'file';
         $size = @getimagesize($config['file_thumb']);
         $post['thumbwidth'] = $size[0];
         $post['thumbheight'] = $size[1];
     }
     $post['filehash'] = $config['file_hash']($post['file']);
     $post['filesize'] = filesize($post['file']);
 }
 if ($post['has_file'] && $config['image_reject_repost'] && ($p = getPostByHash($post['filehash']))) {
     undoImage($post);
     error(sprintf($config['error']['fileexists'], $post['mod'] ? $config['root'] . $config['file_mod'] . '?/' : $config['root'] . $board['dir'] . $config['dir']['res'] . ($p['thread'] ? $p['thread'] . '.html#' . $p['id'] : $p['id'] . '.html')));
 }
 if (!hasPermission($config['mod']['postunoriginal'], $board['uri']) && $config['robot_enable'] && checkRobot($post['body_nomarkup'])) {
     undoImage($post);
     if ($config['robot_mute']) {
         error(sprintf($config['error']['muted'], mute()));
     } else {
         error($config['error']['unoriginal']);
     }
 }
 // Remove DIR_* before inserting them into the database.
 if ($post['has_file']) {
     $post['file'] = substr_replace($post['file'], '', 0, mb_strlen($board['dir'] . $config['dir']['img']));
     if ($is_an_image && $post['thumb'] != 'spoiler') {
         $post['thumb'] = substr_replace($post['thumb'], '', 0, mb_strlen($board['dir'] . $config['dir']['thumb']));
     }
 }
 $id = post($post, $OP);
 if (isset($post['tracked_cites'])) {