Example #1
0
function newTopic($name, $poster, $message)
{
    $db = Database::obtain();
    $data['name'] = $name;
    $data['lastpost'] = date('Y-m-d H:i:s');
    $topic = $db->insert('forum_topics', $data);
    newPost($topic, $poster, $message);
    return $topic;
}
Example #2
0
}
$redirect = true;
// Check if the request is to make a post
if (isset($_POST['message']) || isset($_POST['file'])) {
    if (TINYIB_DBMIGRATE) {
        fancyDie('Posting is currently disabled.<br>Please try again in a few moments.');
    }
    list($loggedin, $isadmin) = manageCheckLogIn();
    $rawpost = isRawPost();
    if (!$loggedin) {
        checkCAPTCHA();
        checkBanned();
        checkMessageSize();
        checkFlood();
    }
    $post = newPost(setParent());
    $post['ip'] = $_SERVER['REMOTE_ADDR'];
    list($post['name'], $post['tripcode']) = nameAndTripcode($_POST['name']);
    $post['name'] = cleanString(substr($post['name'], 0, 75));
    $post['email'] = cleanString(str_replace('"', '&quot;', substr($_POST['email'], 0, 75)));
    $post['subject'] = cleanString(substr($_POST['subject'], 0, 75));
    if ($rawpost) {
        $rawposttext = $isadmin ? ' <span style="color: red;">## Admin</span>' : ' <span style="color: purple;">## Mod</span>';
        $post['message'] = $_POST['message'];
        // Treat message as raw HTML
    } else {
        $rawposttext = '';
        $post['message'] = str_replace("\n", '<br>', makeLinksClickable(colorQuote(postLink(cleanString(rtrim($_POST['message']))))));
    }
    $post['password'] = $_POST['password'] != '' ? md5(md5($_POST['password'])) : '';
    $post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time(), $rawposttext);
 function uploadVideo()
 {
     if (isset($_SESSION['user_id'])) {
         $user_id = $_SESSION['user_id'];
     } else {
         $user_id = 0;
     }
     $post_type = '';
     $timestamp = date("Y-m-d H:i:s");
     $fileName = $user_id . "_" . $timestamp . ".mp4";
     $post_content = $fileName;
     $post_type = $_POST['post_type'];
     $now_time = $timestamp;
     echo "inside upload video";
     move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/videos/" . $fileName);
     if (!empty($post_content)) {
         $post_id = newPost($post_content, $user_id, $post_type);
         $this->http_response($post_id, 200);
     }
 }
Example #4
0
function convertPostsToSQLStyle($posts, $singlepost = false)
{
    $newposts = array();
    foreach ($posts as $oldpost) {
        $post = newPost();
        $post['id'] = $oldpost[POST_ID];
        $post['parent'] = $oldpost[POST_PARENT];
        $post['timestamp'] = $oldpost[POST_TIMESTAMP];
        $post['bumped'] = $oldpost[POST_BUMPED];
        $post['ip'] = $oldpost[POST_IP];
        $post['name'] = $oldpost[POST_NAME];
        $post['tripcode'] = $oldpost[POST_TRIPCODE];
        $post['email'] = $oldpost[POST_EMAIL];
        $post['nameblock'] = $oldpost[POST_NAMEBLOCK];
        $post['subject'] = $oldpost[POST_SUBJECT];
        $post['message'] = $oldpost[POST_MESSAGE];
        $post['password'] = $oldpost[POST_PASSWORD];
        $post['file'] = $oldpost[POST_FILE];
        $post['file_hex'] = $oldpost[POST_FILE_HEX];
        $post['file_original'] = $oldpost[POST_FILE_ORIGINAL];
        $post['file_size'] = $oldpost[POST_FILE_SIZE];
        $post['file_size_formatted'] = $oldpost[POST_FILE_SIZE_FORMATTED];
        $post['image_width'] = $oldpost[POST_IMAGE_WIDTH];
        $post['image_height'] = $oldpost[POST_IMAGE_HEIGHT];
        $post['thumb'] = $oldpost[POST_THUMB];
        $post['thumb_width'] = $oldpost[POST_THUMB_WIDTH];
        $post['thumb_height'] = $oldpost[POST_THUMB_HEIGHT];
        $post['stickied'] = isset($oldpost[POST_STICKIED]) ? $oldpost[POST_STICKIED] : 0;
        if ($post['parent'] == '') {
            $post['parent'] = TINYIB_NEWTHREAD;
        }
        if ($singlepost) {
            return $post;
        }
        $newposts[] = $post;
    }
    return $newposts;
}
Example #5
0
            include_once 'includes/pages/adminusers.inc';
            break;
        case "banslist":
            include_once 'includes/pages/adminbans.inc';
            break;
        case "forum":
            if ($_GET['action'] == 'newTopic') {
                if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['name']) && isset($_POST['message'])) {
                    $topic = newTopic($_POST['name'], $id, $_POST['message']);
                    redirect('admin.php?page=forum&topic=' . $topic, 0);
                } else {
                    include_once 'includes/pages/adminnewtopic.inc';
                }
            } elseif ($_GET['action'] == 'newPost' && $_GET['topic']) {
                if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['message'])) {
                    newPost($_GET['topic'], $id, $_POST['message']);
                    redirect('admin.php?page=forum&topic=' . $_GET['topic'], 0);
                } else {
                    include_once 'includes/pages/adminnewpost.inc';
                }
            } elseif ($_GET['topic']) {
                $topic = Topic($_GET['topic']);
                include_once 'includes/pages/adminposts.inc';
            } else {
                include_once 'includes/pages/adminforum.inc';
            }
            break;
    }
} else {
    redirect('index.php', 0);
}
Example #6
0
         if (!threadExistsByID($_POST['parent'])) {
             fancyDie("Invalid parent thread ID supplied, unable to create post.");
         }
         $parent = $_POST["parent"];
     }
 }
 $lastpost = lastPostByIP();
 if ($lastpost) {
     if (time() - $lastpost['timestamp'] < 30) {
         fancyDie("Please wait a moment before posting again.  You will be able to make another post in " . (30 - (time() - $lastpost['timestamp'])) . " seconds.");
     }
 }
 if (strlen($_POST["message"]) > 8000) {
     fancyDie("Please shorten your message, or post it in multiple parts. Your message is " . strlen($_POST["message"]) . " characters long, and the maximum allowed is 8000.");
 }
 $post = newPost();
 $post['parent'] = $parent;
 $post['ip'] = $_SERVER['REMOTE_ADDR'];
 $nt = nameAndTripcode($_POST["name"]);
 $post['name'] = $nt[0];
 $post['tripcode'] = $nt[1];
 $post['name'] = cleanString(substr($post['name'], 0, 75));
 $post['email'] = cleanString(str_replace('"', '&quot;', substr($_POST["email"], 0, 75)));
 $post['subject'] = cleanString(substr($_POST["subject"], 0, 75));
 $post['message'] = str_replace("\n", "<br>", colorQuote(cleanString(rtrim($_POST["message"]))));
 if ($_POST['password'] != '') {
     $post['password'] = md5(md5($_POST['password']));
 } else {
     $post['password'] = '';
 }
 $post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time());
Example #7
0
function disp_body()
{
    if (!isset($_GET['p'])) {
        disp_cats();
    } elseif (isset($_GET['id'])) {
        if ($_GET['p'] == 'f') {
            if (isset($_POST['topicname']) && isset($_POST['message']) && connected()) {
                if (newTopic($_POST['topicname'], $_GET['id'], $_SESSION['id'], $_POST['message'])) {
                    disp_error(ERR_404);
                } elseif (disp_forum($_GET['id'])) {
                    disp_error(ERR_404);
                }
            } elseif (disp_forum($_GET['id'])) {
                disp_error(ERR_404);
            }
        } else {
            if ($_GET['p'] == 't') {
                if (isset($_POST['message']) && connected()) {
                    if (newPost($_POST['message'], $_GET['id'], $_SESSION['id'])) {
                        disp_error(ERR_404);
                    } elseif (disp_topic($_GET['id'])) {
                        disp_error(ERR_404);
                    }
                } elseif (disp_topic($_GET['id'])) {
                    disp_error(ERR_404);
                }
            } else {
                if ($_GET['p'] == 'm') {
                    if (disp_member($_GET['id'])) {
                        disp_error(ERR_404);
                    }
                } elseif ($_GET['p'] == 'newt' || $_GET['p'] == 'newp') {
                    if (connected()) {
                        ?>
				<div id="forum"><h2><?php 
                        if ($_GET['p'] == 'newt') {
                            ?>
Créer un nouveau topic :<?php 
                        } else {
                            ?>
Poster un nouveau message : <?php 
                        }
                        ?>
</h2>
				<form method="post" action="index.php?p=<?php 
                        if ($_GET['p'] == 'newt') {
                            echo 'f';
                        } else {
                            echo 't';
                        }
                        ?>
&id=<?php 
                        echo $_GET['id'];
                        ?>
">
					<p>
						<?php 
                        if ($_GET['p'] == 'newt') {
                            ?>
<label for="topicname">Nom du topic :</label><input id="topicname" type="text" name="topicname" maxlength="64"/><br/><?php 
                        }
                        ?>
						<label for="message">Message :</label><textarea id="message" name="message"></textarea><br/>
						<input type="submit" value="Valider"/>
					</p>
				</form>
				</div>
			<?php 
                    } else {
                        disp_error(ERR_GDC_DC);
                    }
                } else {
                    disp_error(ERR_404);
                }
            }
        }
    } elseif ($_GET['p'] == 'inscr') {
        disp_inscriptionForm();
    } elseif ($_GET['p'] == 'dc') {
        ?>
<p>Vous êtes maintenant déconnecté.</p><?php 
    } elseif ($_GET['p'] == 'co_ok') {
        ?>
<p>Vous êtes maintenant connecté.</p><?php 
    } elseif ($_GET['p'] == 'inscr_ok') {
        ?>
<p>Vous êtes maintenant incrit sur ce forum.</p><?php 
    } elseif ($_GET['p'] == 'gdc') {
        if (connected()) {
            if (isset($_POST['gdc_mdp']) && isset($_POST['gdc_cmdp'])) {
                if ($_POST['gdc_mdp'] == $_POST['gdc_cmdp']) {
                    if (changeMDP($_SESSION['id'], $_POST['gdc_mdp'])) {
                        disp_error(ERR_INSCR_MDP);
                    } else {
                        echo '<div id="green"><p>' . GDC_MDP_CHANGED . '</p></div>';
                    }
                } else {
                    disp_error(ERR_INSCR_CONF);
                }
            } elseif (isset($_POST['gdc_email'])) {
                if (changeEmail($_SESSION['id'], $_POST['gdc_email'])) {
                    disp_error(ERR_INSCR_EMAIL);
                } else {
                    echo '<div id="green"><p>' . GDC_EMAIL_CHANGED . '</p></div>';
                }
            } else {
                disp_gdc();
            }
        } else {
            disp_error(ERR_GDC_DC);
        }
    } else {
        disp_error(ERR_404);
    }
}
Example #8
0
function newTopic($name, $forum_id, $author_id, $text)
{
    $db = db_connect();
    $req = $db->prepare('SELECT `f.name` FROM forums WHERE `f.id` = ?');
    $req->execute(array($forum_id));
    if (!$req->fetch()) {
        $req->closeCursor();
        return 1;
    }
    $req->closeCursor();
    $req = $db->prepare('INSERT INTO topics VALUES(\'\', ?, 0, ?, ?, 0)');
    $req->execute(array($name, $author_id, $forum_id));
    newPost($text, $db->lastInsertId(), $author_id);
    return 0;
}
Example #9
0
 public function reward()
 {
     global $vbulletin, $vbphrase;
     // <editor-fold defaultstate="collapsed" desc="analysis information">
     if ($this->type == 2) {
         $this->chapternumber = "";
     }
     $this->fansubmember = str_replace('false', '', $this->fansubmember);
     $this->fansubmember = str_replace(',,', '', $this->fansubmember);
     if ($this->postid == 0) {
         $this->postid = $this->manga->postid;
     }
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="create new update post, and new read online thread">
     // <editor-fold defaultstate="collapsed" desc=" create new update post ">
     //normal case: there is update post for the chapter, or there is not but no 18+ content.
     //reward and add chapter to the database only, no need to make any new post. Only set the post to yrmspost.
     if ($this->postid != $this->manga->postid) {
         $vbulletin->db->query_write("UPDATE `" . TABLE_PREFIX . "post` " . "SET `yrmspost`=1 " . "WHERE `postid` = '{$this->postid}'");
         if ($this->rate == 1 && !empty($this->numberofhost)) {
             $downloadpost = $this->buildpost('download');
             editPost($downloadpost);
         }
     } else {
         if ($this->postid == $this->manga->postid && $this->rate == 1) {
             $downloadpost = $this->buildpost('download');
             $this->postid = newPost($downloadpost, $this->poster);
             $vbulletin->db->query_write("UPDATE `" . TABLE_PREFIX . "post` " . "SET `yrmspost`=1 " . "WHERE `postid` = '{$this->postid}'");
         }
     }
     //abnormal case 2: no download link, only readonline link.
     //Skip this step
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc=" create new read online thread ">
     //normal case: readonline post is a separate topic
     //do nothing but set the post to yrms post, and reformat it if the chapter is 18+ content
     if (!empty($this->onlinelink)) {
         $vbulletin->db->query_write("UPDATE `" . TABLE_PREFIX . "post` " . "SET `yrmspost`=1 " . "WHERE `postid` = '{$this->readonlinepostid}'");
         if ($this->rate == 1) {
             $readonlinepost = $this->buildpost('online');
             editPost($readonlinepost);
         }
     }
     //abnormal case: readonline post is the same as update post, or manga post
     //turn it into normal case and treat as normal case
     if (!empty($this->onlinelink) && ($this->readonlinepostid == $this->postid || $this->readonlinepostid == $this->manga->postid || $this->readonlinepostid == 0)) {
         $readonlinepost = $this->buildpost('online');
         $idpack = newThread($readonlinepost, $this->readonlineposter);
         $this->readonlinepostid = $idpack['postid'];
         $vbulletin->db->query_write("UPDATE `" . TABLE_PREFIX . "post` " . "SET `yrmspost`=1 " . "WHERE `postid` = '{$this->readonlinepostid}'");
     }
     // </editor-fold>
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="add chapter to the database ">
     $vbulletin->db->query_write("INSERT INTO `" . TABLE_PREFIX . "yrms_vietsubmanga_chapter`" . "(`mangaid`," . "`postid`, " . "`readonlinepostid`, " . "`active`, " . "`status`, " . "`type`, " . "`chapternumber`, " . "`chaptertitle`, " . "`rate`, " . "`numberofhost`, " . "`downloadlink`, " . "`onlinelink`, " . "`fansubmember`, " . "`fansubnote`) " . "VALUES ('{$this->manga->mangaid}'," . "'{$this->postid}'," . "'{$this->readonlinepostid}'," . "'1'," . "'{$this->status}'," . "'{$this->type}'," . "'{$this->chapternumber}'," . "'{$this->chaptertitle}'," . "'{$this->rate}'," . "'{$this->numberofhost}'," . "'" . serialize($this->downloadlink) . "'," . "'{$this->onlinelink}'," . "'" . serialize($this->fansubmember) . "'," . "'{$this->fansubnote}')");
     $this->chapterid = $vbulletin->db->insert_id();
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="update manga">
     $this->manga->fansubmember = update_array_to_array($this->fansubmember, $this->manga->fansubmember);
     $this->manga->fansubmember = reindex_array($this->manga->fansubmember, array("translator", "proofreader", "editor", "qualitychecker", "uploader"));
     if ($this->type == 1 || $this->type == 2) {
         $this->manga->finishedchapter++;
     }
     if (!empty($this->onlinelink)) {
         $this->manga->readonlinestatus = 1;
     }
     $chapterhostname = array();
     if (!empty($this->numberofhost)) {
         foreach ($this->downloadlink as $hostname => $hostlink) {
             $chapterhostname[] = $hostname;
         }
         $this->manga->hostname = update_array_to_array($chapterhostname, $this->manga->hostname);
         $this->manga->numberofhost = count($this->manga->hostname);
     }
     $this->manga->update();
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc=" reward ">
     //For download post
     $award_download = new Award();
     $award_download->postid = $this->postid;
     if (strpos(strtolower($this->manga->fansubsite), 'yurivn')) {
         $award_download->awardcontent = $this->build_awardcontent_fansubmember();
     }
     if (!empty($this->numberofhost)) {
         if (array_key_exists($this->poster, $award_download->awardcontent)) {
             $award_download->awardcontent[$this->poster] += $vbulletin->options['yrms_vietsubmanga_yun_uploader'];
         } else {
             $award_download->awardcontent += array($this->poster => $vbulletin->options['yrms_vietsubmanga_yun_uploader']);
         }
         if ($this->numberofhost >= 2) {
             if (array_key_exists($this->poster, $award_download->awardcontent)) {
                 $award_download->awardcontent[$this->poster] += $vbulletin->options['yrms_vietsubmanga_yun_mirror'];
             } else {
                 $award_download->awardcontent += array($this->poster => $vbulletin->options['yrms_vietsubmanga_yun_mirror']);
             }
         }
     }
     $award_download->resourcetype = 'vietsubmanga';
     $award_download->resourceid = $this->chapterid;
     $award_download->resourceheadid = $this->manga->mangaid;
     $award_download->add();
     //For readonline post
     if (!empty($this->readonlinepostid)) {
         $award_online = new Award();
         $award_online->postid = $this->readonlinepostid;
         $award_online->awardcontent = array($this->readonlineposter => $vbulletin->options['yrms_vietsubmanga_yun_online']);
         $award_online->resourcetype = 'vietsubmanga';
         $award_online->resourceid = $this->chapterid;
         $award_online->resourceheadid = $this->manga->mangaid;
         $award_online->add();
     }
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc=" return the success message ">
     if (isset($award_online)) {
         $awardcontent = $award_download->awardcontent + $award_online->awardcontent;
     } else {
         $awardcontent = $award_download->awardcontent;
     }
     $awardinfo = array();
     foreach ($awardcontent as $userid => $amount) {
         $userinfo = fetch_userinfo($userid);
         $username = $userinfo["username"];
         $awardinfo[] = "{$username}: {$amount} {$vbulletin->options['yrms_main_moneyname']}";
     }
     $awardinfo = implode("\n", $awardinfo);
     $return_message = construct_phrase($vbphrase['yrms_msg_success_rewardchapter'], $vbulletin->userinfo['username'], $vbphrase["yrms_chaptertype{$this->type}"] . " " . $this->chapternumber, $this->manga->mangatitle, nl2br($awardinfo));
     return $return_message;
     // </editor-fold>
 }