417066 post verify x cgi


#!/usr/bin/perl
#------------------------------------------------------------------------------
# UltraThreads
# Copyright (c) 2000 Kelvin Wu
#
# 2000.08
#------------------------------------------------------------------------------

use strict;

# Imports
use CGI::Carp qw(fatalsToBrowser);

BEGIN{ ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); }

use DBI;
use UTConfig;
use UTLanguage;
use UTMain;
use UTCGI;

#------------------------------------------------------------------------------

# Get user
connectDb();
my $user = authUser();

# Check if forum is closed
printMessage("$lng{'forumClosedLb'}", "$lng{'forumClosed'}")
if $cfg{'forumClosed'} && !$user->{'admin'};


# Check if user is registered, not banned, not blocked, and authorized.
$user->{'defaultUser'} and regError();
checkBan($user->{'id'});
checkBlock();
checkAuthz($user, "editPost");

# Check if request is coming from this site
checkReferer();

# Get CGI parameters
my $cgi = new UTCGI;
my $postId = int($cgi->param('id'));
my $a = $cgi->param('a');
$postId or paramError($lng{'errPstIdMiss'});

# Get post data
my $query = "SELECT id, userId, boardId, topicId, parentId, attach FROM ut_posts WHERE id = $postId";
my $sth = query($query);
my $post = $sth->fetchrow_hashref();
$sth->finish;
$post or entryError($lng{'errPstNotFnd'});

# Check if user can delete post
$user->{'id'} == $post->{'userId'}
|| $user->{'admin'} || $user->{'superMod'} || boardAdmin($user->{'id'}, $post->{'boardId'})
or userError($lng{'errNotYours'});

# Check for children
$query = "SELECT COUNT(*) FROM ut_posts WHERE parentId = $postId";
$sth = query($query);
my ($children) = $sth->fetchrow_array();
$sth->finish;

# Delete post
my $topicDeleted = 0;

if ($a eq "o")
{
$query = "update ut_posts set verify = 1 where id = $postId";
}
if ($a eq "c")
{$query = "update ut_posts set verify = 0 where id = $postId";}
$dbh->do($query) or dbError();


# Update board/topic stats
$topicDeleted
? recalcStats($post->{'boardId'})
: recalcStats($post->{'boardId'}, $post->{'topicId'});

# Redirect back
my $age = $user->{'defaultUser'} ? $cfg{'postsAge'} : $user->{'postsAge'};
$user->{'dispMode'}
? redirect("topic_show.cgi?id=$post->{'topicId'}&msg=PstDel#$post->{'parentId'}")
: redirect("threaded_show.cgi?tid=$post->{'topicId'}&pid=$post->{'parentId'}");


Wyszukiwarka

Podobne podstrony:
417063 topic verify x cgi
Viral Blog Post Case Study
post Rdz 1
demo cgi 850
listart cgi id=3
post TYTUŁ
demo cgi 648

więcej podobnych podstron