Ejemplo n.º 1
0
function outputErrors()
{
    if (isset($_POST['title'])) {
        if (empty($_POST['title'])) {
            echo "Please fill out all fields. <br>";
        } else {
            if ($_POST['token'] != $_SESSION['token']) {
                echo "There was an error processing the request. Please try again later.";
            } else {
                if (strlen($_POST['title']) > 70) {
                    echo "Title is too long.  Must be 70 characters or less";
                } else {
                    createThread($_POST['title']);
                }
            }
        }
    }
}
Ejemplo n.º 2
0
<?php 
require_once 'classes.php';
?>

<div class="nav">
<?php 
include 'nav.php';
?>
	</div>
<?php 
echo "</br>gdgedsw";
if (isset($_POST['title'], $_POST['description'])) {
    if (empty($_POST['title']) || empty($_POST['description'])) {
        echo "Please fill out all fields. </br>";
    } else {
        createThread($_POST['title'], $_POST['description']);
    }
}
function printThreads($array)
{
    if (getShowId($_GET['showTitle']) > 0) {
        echo "<table><th>Title</th><th>Description</th><th># of posts</th>";
        if (count($array) > 0) {
            for ($i = 0; $i < count($array); $i++) {
                $threadId = $array[$i]["threadId"];
                ?>
			<tr><td><a href='posts.php?threadId=<?php 
                echo $threadId;
                ?>
'> <?php 
                echo $array[$i]["title"];
Ejemplo n.º 3
0
<body>
	<div class="maindiv">
<?php 
session_start();
require_once "php/database.php";
require_once "php/storedprocedures.php";
require_once "php/error.php";
if (isset($_POST['content'])) {
    /* Search the string to find any HTML tags that we have forbidden; that is, anything other than b, u, i, a, img, br, or iframe. If we do find a tag, we can clean it up and set a link back to edit the post. */
    $db = connectToDatabase();
    if ($db) {
        $postToThread = isset($_POST['threadid']) ? $_POST['threadid'] : null;
        if (isset($_POST['newthreadtitle']) && $postToThread == null) {
            // We're making a new thread as well, then posting to it
            // We have to only make a thread if we have content to post.
            $result = createThread($db, $_SESSION['id'], $_POST['forumid'], $_POST['newthreadtitle'], $_SESSION['token']);
            //$_SESSION['token'] = $result[SP::TOKEN];
            switch ($result[SP::ERROR]) {
                case ERR::OK:
                    $postToThread = $result[THREAD::ID];
                    break;
                case ERR::TOKEN_EXPIRED:
                case ERR::TOKEN_FAIL:
                case ERR::USER_NO_TOKEN:
                    header("Location: logout.php?error=" . $result[SP::ERROR]);
                    break;
            }
        }
        if ($postToThread != null) {
            // We're making a new post
            $result = createPost($db, $_SESSION['id'], $postToThread, $_POST['content'], $_SESSION['token']);
Ejemplo n.º 4
0
function cjView($strlink, $num)
{
    global $maxarticleid, $maxPostid, $maxThreadid, $maxUser, $users, $p_hitsend, $db, $strListUrl, $p_titletype, $starringarr, $titlearr, $p_id, $p_titlestart, $p_titleend, $p_hitsstart, $p_hitsend, $p_authortype, $p_authorstart, $p_authorend, $p_typestart, $p_typeend, $p_classtype, $p_collect_type, $p_timestart, $p_timeend, $p_contentstart, $p_contentend, $p_cpagecodestart, $p_cpagecodeend, $p_cpagetype, $p_cpagestart, $p_cpageend, $p_coding, $p_script, $p_showtype, $sb, $cg, $cache;
    $strlink = definiteUrl($strlink, $strListUrl);
    $strViewCode = getPage($strlink, $p_coding);
    if ($strViewCode == False) {
        echo "<tr><td vAlign=center class=\"tdxingmu\" colspan=\"2\">在获取内容页时出错:" . $strlink . " </td></tr>";
        $sb = $sb + 1;
        return;
    } else {
        if ($p_titletype == 1) {
            $titlecode = $titlearr[$num];
        } else {
            $titlecode = getBody($strViewCode, $p_titlestart, $p_titleend);
        }
        $titlecode = filterScript($titlecode, $p_script);
        $titlecode = replaceFilters($titlecode, $p_id, 1, 0);
        //		$sql="select count(*) from {pre}cj_art where m_title='".$titlecode."'";
        //		$rowcount=$db->getOne($sql);
        //		if (intval($rowcount>0)){
        //			echo "<tr><td vAlign=center class=\"tdxingmu\" colspan=\"2\">遇到重复文章数据跳过采集!</td></tr>";
        //			return;
        //		}
        if (isN($p_hitsstart) || !isnum($p_hitsstart)) {
            $p_hitsstart = 0;
        }
        if (isN($p_hitsend) || !isnum($p_hitsend)) {
            $p_hitsend = 0;
        }
        if ($p_hitsstart == 0 && $p_hitsend == 0) {
            $m_hits = 0;
        } else {
            $m_hits = rand($p_hitsend, $p_hitsstart);
        }
        if ($p_authortype == 1) {
            $starringcode = $starringarr[$num];
        } else {
            $starringcode = getBody($strViewCode, $p_authorstart, $p_authorend);
        }
        $starringcode = replaceStr($starringcode, "false", "未知");
        $starringcode = filterScript($starringcode, $p_script);
        if ($p_classtype == 1) {
            $typecode = filterScript(getBody($strViewCode, $p_typestart, $p_typeend), $p_script);
            $typecode = trim($typecode);
            $m_typeid = changeId($typecode, $p_id, 1);
        } else {
            $typecode = $p_collect_type;
            $typecode = trim($typecode);
            $m_typeid = $p_collect_type;
            $typearr = getValueByArray($cache[1], "t_id", $typecode);
            $typecode = $typearr["t_name"];
        }
        $typecode = filterScript($typecode, $p_script);
        $timecode = getBody($strViewCode, $p_timestart, $p_timeend);
        $timecode = replaceStr($timecode, "false", date('Y-m-d', time()));
        $timecode = filterScript($timecode, $p_script);
        $contentcode = getBody($strViewCode, $p_contentstart, $p_contentend);
        $cpagecode = getBody($strViewCode, $p_cpagecodestart, $p_cpagecodeend);
        $contentcode = replaceStr($contentcode, $cpagecode, "");
        if ($p_cpagetype == 1) {
            $cpagelinkarrcode = getArray($cpagecode, $p_cpagestart, $p_cpageend);
            $cpagelinkarr = explode("{Array}", $cpagelinkarrcode);
            for ($i = 0; $i < count($cpagelinkarr); $i++) {
                $cpagelink = $cpagelinkarr[$i];
                if ($cpagelink != "" && $cpagelink != "#") {
                    $cpagelink = definiteUrl($cpagelink, $strListUrl);
                    $cpagelinkcode = getPage($cpagelink, $p_coding);
                    if ($cpagelinkcode != "false") {
                        $cpagecode = getBody($cpagelinkcode, $p_cpagecodestart, $p_cpagecodeend);
                        $cpagelinkcode = getBody($cpagelinkcode, $p_contentstart, $p_contentend);
                        $cpagelinkcode = replaceStr($cpagelinkcode, $cpagecode, "");
                        $contentcode = $contentcode . $cpagelinkcode;
                    }
                }
            }
        }
        $contentcode = replaceFilters($contentcode, $p_id, 2, 0);
        $contentcode = replaceStr($contentcode, "'", "\"");
        //var_dump($contentcode);
        echo "<tr><td colspan=\"2\" align=\"center\">此列表中第" . ($num + 1) . "条数据采集结果</td></tr><tr><td vAlign=center width=\"20%\">来源地址:</td><td class=\"tdback\">" . $strlink . "</td></tr><td>文章标题:</td><td>" . $titlecode . "</td></tr><td>文章作者:</td><td>" . $starringcode . "</td></tr><td>发布时间:</td><td>" . $timecode . "</td></tr><td>分类:</td><td>" . $typecode . "</td></tr> <td>内容:</td><td>" . strlen($contentcode) . "</td></tr>";
        //		$sql="select m_id,m_title,m_type,m_author,m_content,m_addtime,m_urltest,m_zt,m_pid,m_typeid,m_hits from {pre}cj_art where m_urltest='".$strlink."' order by m_id desc";
        //		$rowart=$db->getRow($sql);
        //	    if ($rowart) {
        //			$cg=$cg+1;
        //			$movieid=$rowart["m_id"];
        //			$sql = "update {pre}cj_art set m_type='".$typecode."',m_urltest='".$strlink."',m_title='".$titlecode."',m_author='".$starringcode."',m_content='".$contentcode."',m_addtime='".date('Y-m-d H:i:s',time())."',m_zt='0',m_pid='".$p_id."',m_typeid='".$m_typeid."' where m_id=".$rowart["m_id"];
        //
        //			$db->query($sql);
        //		}
        //		else{
        //			$cg=$cg+1;
        //			$sql="insert {pre}cj_art (m_title,m_type,m_author,m_content,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_addtime) values('".$titlecode."','".$typecode."','".$starringcode."','".$contentcode."','".$strlink."','0','".$p_id."','".$m_typeid."','".$m_hits."','".date('Y-m-d H:i:s',time())."')";
        //			//writetofile("s.txt", $sql);
        // 			$status = $db->query($sql);
        //			$movieid=$db->insert_id();
        //		}
        //$maxaid,$catid,$name,$contents,$summary,$uid,$username
        //	function actionAddArticals($aid,$catid,$name,$content,$summary,$uid,$username){
        ///$name,$content,$maxThreadid,$bbsformid,$maxPostid,$uid,$username
        //	function createThread($name,$content,$tid,$fid,$pid,$uid,$username){
        $userIndex = rand(0, $maxUser);
        $username = $users[$userIndex]['username'];
        $uid = $users[$userIndex]['uid'];
        if (isset($contentcode) && !is_null($contentcode) && strlen(trim($contentcode)) > 0) {
            if ($p_collect_type === '7') {
                $maxPostid++;
                $maxThreadid++;
                createThread($titlecode, $contentcode, $maxThreadid, $p_hitsend, $maxPostid, $uid, $username);
                writetofile("collectForm" . $p_hitsend . ".succ.txt", $titlecode);
            } else {
                if ($p_collect_type === '8') {
                    try {
                        if (strlen($contentcode) > 400) {
                            $summary = substr($contentcode, 0, 400);
                        } else {
                            $summary = $contentcode;
                        }
                        $summary = filterScript($summary, 8191);
                    } catch (Exception $e) {
                        $summary = '';
                    }
                    $maxarticleid++;
                    actionAddArticals($maxarticleid, $p_hitsend, $titlecode, $contentcode, $summary, $uid, $username);
                    writetofile("collectArt" . $p_hitsend . ".succ.txt", $titlecode);
                }
            }
        } else {
            writetofile("collectArt" . $p_hitsend . ".txt", $strlink);
        }
    }
}