예제 #1
0
function addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments)
{
    global $prefix, $db, $cookie, $user, $module_name;
    $passtest = "yes";
    include "header.php";
    include "modules/{$module_name}/d_config.php";
    $ratinglid = intval($ratinglid);
    completevoteheader();
    if (is_user($user)) {
        $user2 = base64_decode($user);
        $user2 = addslashes($user2);
        $cookie = explode(":", $user2);
        cookiedecode($user);
        $ratinguser = $cookie[1];
    } else {
        if ($ratinguser == "outside") {
            $ratinguser = "******";
        } else {
            $ratinguser = "******";
        }
    }
    $results3 = $db->sql_query("SELECT title FROM " . $prefix . "_downloads_downloads WHERE lid='{$ratinglid}'");
    while (list($title) = $results3->fetch_row()) {
        $ttitle = filter($title, "nohtml");
    }
    $title = filter($title, "nohtml");
    /* Make sure only 1 anonymous from an IP in a single day. */
    $ip = $_SERVER['REMOTE_HOST'];
    if (empty($ip)) {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    /* Check if Rating is Null */
    if ($rating == "--") {
        $error = "nullerror";
        completevote($error);
        $passtest = "no";
    }
    /* Check if Download POSTER is voting (UNLESS Anonymous users allowed to post) */
    if ($ratinguser != $anonymous && $ratinguser != "outside") {
        $result = $db->sql_query("SELECT submitter FROM " . $prefix . "_downloads_downloads WHERE lid='{$ratinglid}'");
        while (list($ratinguserDB) = $result->fetch_row()) {
            if ($ratinguserDB == $ratinguser) {
                $error = "postervote";
                completevote($error);
                $passtest = "no";
            }
        }
    }
    /* Check if REG user is trying to vote twice. */
    if ($ratinguser != $anonymous && $ratinguser != "outside") {
        $result = $db->sql_query("SELECT ratinguser FROM " . $prefix . "_downloads_votedata WHERE ratinglid='{$ratinglid}'");
        while (list($ratinguserDB) = $result->fetch_row()) {
            if ($ratinguserDB == $ratinguser) {
                $error = "regflood";
                completevote($error);
                $passtest = "no";
            }
        }
    }
    /* Check if ANONYMOUS user is trying to vote more than once per day. */
    if ($ratinguser == $anonymous) {
        $yesterdaytimestamp = time() - 86400 * $anonwaitdays;
        $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
        $result = $db->sql_query("SELECT * FROM " . $prefix . "_downloads_votedata WHERE ratinglid='{$ratinglid}' AND ratinguser='******' AND ratinghostname = '{$ip}' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '{$anonwaitdays}'");
        $anonvotecount = $db->sql_numrows($result);
        if ($anonvotecount >= 1) {
            $error = "anonflood";
            completevote($error);
            $passtest = "no";
        }
    }
    /* Check if OUTSIDE user is trying to vote more than once per day. */
    if ($ratinguser == "outside") {
        $yesterdaytimestamp = time() - 86400 * $outsidewaitdays;
        $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
        $result = $db->sql_query("SELECT * FROM " . $prefix . "_downloads_votedata WHERE ratinglid='{$ratinglid}' AND ratinguser='******' AND ratinghostname = '{$ip}' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '{$outsidewaitdays}'");
        $outsidevotecount = $db->sql_numrows($result);
        if ($outsidevotecount >= 1) {
            $error = "outsideflood";
            completevote($error);
            $passtest = "no";
        }
    }
    /* Passed Tests */
    if ($passtest == "yes") {
        $ratingcomments = filter($ratingcomments);
        if (!empty($ratingcomments)) {
            update_points(19);
        }
        update_points(18);
        /* All is well.  Add to Line Item Rate to DB. */
        $ratinglid = intval($ratinglid);
        $rating = intval($rating);
        $ratingcomments = filter($ratingcomments, "", 1);
        if ($rating > 10 || $rating < 1) {
            header("Location: modules.php?name={$module_name}&d_op=ratedownload&lid={$ratinglid}");
            die;
        }
        $db->sql_query("INSERT into " . $prefix . "_downloads_votedata values (NULL,'{$ratinglid}', '{$ratinguser}', '{$rating}', '{$ip}', '{$ratingcomments}', now())");
        /* All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
        /* NOTE: If weight is modified, ALL downloads need to be refreshed with new weight. */
        /*	 Running a SQL statement with your modded calc for ALL downloads will accomplish this. */
        $voteresult = $db->sql_query("SELECT rating, ratinguser, ratingcomments FROM " . $prefix . "_downloads_votedata WHERE ratinglid = '{$ratinglid}'");
        $totalvotesDB = $db->sql_numrows($voteresult);
        include "modules/{$module_name}/voteinclude.php";
        $finalrating = intval($finalrating);
        $totalvotesDB = intval($totalvotesDB);
        $truecomments = intval($truecomments);
        $ratinglid = intval($ratinglid);
        $db->sql_query("UPDATE " . $prefix . "_downloads_downloads SET downloadratingsummary='{$finalrating}',totalvotes='{$totalvotesDB}',totalcomments='{$truecomments}' WHERE lid = '{$ratinglid}'");
        $error = "none";
        completevote($error);
    }
    completevotefooter($ratinglid, $ratinguser);
    include "footer.php";
}
예제 #2
0
파일: index.php 프로젝트: cbsistem/nexos
function addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments)
{
    global $downloadsprefix, $db, $userinfo, $module_name, $MAIN_CFG, $module_name, $outsidewaitdays, $anonymous;
    $passtest = true;
    include "header.php";
    completevoteheader();
    if (is_user()) {
        $ratinguser = $userinfo['user_id'];
    } else {
        if (isset($_POST['ratinguser'])) {
            $ratinguser = "******";
        } else {
            $ratinguser = $anonymous;
        }
    }
    $results3 = $db->sql_query("SELECT title FROM " . $downloadsprefix . "_downloads WHERE lid={$ratinglid}");
    while (list($title) = $db->sql_fetchrow($results3)) {
        $ttitle = $title;
    }
    /* Make sure only 1 anonymous from an IP in a single day. */
    $ip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    //returns ip on function failure
    /* Check if Rating is Null */
    if ($rating == "--") {
        $error = "nullerror";
        completevote($error);
        $passtest = false;
    }
    /* Check if Download POSTER is voting (UNLESS Anonymous users allowed to post) */
    if ($ratinguser != $anonymous && $ratinguser != "outside") {
        $result = $db->sql_query("SELECT submitter FROM " . $downloadsprefix . "_downloads WHERE lid={$ratinglid}");
        while (list($ratinguserDB) = $db->sql_fetchrow($result)) {
            if ($ratinguserDB == $ratinguser) {
                $error = "postervote";
                completevote($error);
                $passtest = false;
            }
        }
    }
    /* Check if REG user is trying to vote twice. */
    if ($ratinguser != $anonymous && $ratinguser != "outside") {
        $result = $db->sql_query("SELECT ratinguser FROM " . $downloadsprefix . "_votedata WHERE ratinglid={$ratinglid}");
        while (list($ratinguserDB) = $db->sql_fetchrow($result)) {
            if ($ratinguserDB == $ratinguser) {
                $error = "regflood";
                completevote($error);
                $passtest = false;
            }
        }
    }
    /* Check if ANONYMOUS user is trying to vote more than once per day. */
    if ($ratinguser == $anonymous) {
        $yesterdaytimestamp = time() - 86400 * $MAIN_CFG[$module_name]['anonwaitdays'];
        $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
        $result = $db->sql_query("SELECT * FROM " . $downloadsprefix . "_votedata WHERE ratinglid={$ratinglid} AND ratinguser='******' AND ratinghostname = '{$ip}' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < " . $MAIN_CFG[$module_name]['anonwaitdays']);
        $anonvotecount = $db->sql_numrows($result);
        if ($anonvotecount >= 1) {
            $error = "anonflood";
            completevote($error);
            $passtest = false;
        }
    }
    /* Check if OUTSIDE user is trying to vote more than once per day. */
    if ($ratinguser == "outside") {
        $yesterdaytimestamp = time() - 86400 * $outsidewaitdays;
        $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
        $result = $db->sql_query("SELECT * FROM " . $downloadsprefix . "_votedata WHERE ratinglid={$ratinglid} AND ratinguser='******' AND ratinghostname = '{$ip}' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < {$outsidewaitdays}");
        $outsidevotecount = $db->sql_numrows($result);
        if ($outsidevotecount >= 1) {
            $error = "outsideflood";
            completevote($error);
            $passtest = false;
        }
    }
    /* Passed Tests */
    if ($passtest) {
        $ratingcomments = Fix_Quotes($ratingcomments);
        /* All is well.  Add to Line Item Rate to DB. */
        $db->sql_query("INSERT into " . $downloadsprefix . "_votedata values (NULL,'{$ratinglid}', '{$ratinguser}', '{$rating}', '{$ip}', '{$ratingcomments}', now())");
        /* All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
        /* NOTE: If weight is modified, ALL downloads need to be refreshed with new weight. */
        /*     Running a SQL statement with your modded calc for ALL downloads will accomplish this. */
        $voteresult = $db->sql_query("SELECT rating, ratinguser, ratingcomments FROM " . $downloadsprefix . "_votedata WHERE ratinglid = {$ratinglid}");
        $totalvotesDB = $db->sql_numrows($voteresult);
        include "modules/{$module_name}/voteinclude.php";
        $db->sql_query("UPDATE " . $downloadsprefix . "_downloads SET downloadratingsummary={$finalrating},totalvotes={$totalvotesDB},totalcomments={$truecomments} WHERE lid = {$ratinglid}");
        $error = "none";
        completevote($error);
    }
    completevotefooter($ratinglid, $ttitle, $ratinguser);
    include "footer.php";
}
예제 #3
0
function addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments)
{
    global $prefix, $db, $cookie, $user, $module_name;
    $passtest = "yes";
    include "header.php";
    include "modules/{$module_name}/l_config.php";
    $ratinglid = intval($ratinglid);
    completevoteheader();
    if (is_user($user)) {
        $user2 = base64_decode($user);
        $user2 = addslashes($user2);
        $cookie = explode(":", $user2);
        cookiedecode($user);
        $ratinguser = $cookie[1];
    } else {
        if ($ratinguser == "outside") {
            $ratinguser = "******";
        } else {
            $ratinguser = "******";
        }
    }
    $result = $db->sql_query("SELECT title FROM " . $prefix . "_links_links WHERE lid='{$ratinglid}'");
    while ($row = $db->sql_fetchrow($result)) {
        $title = stripslashes(check_html($row['title'], "nohtml"));
        $ttitle = $title;
        /* Make sure only 1 anonymous from an IP in a single day. */
        $ip = $_SERVER["REMOTE_HOST"];
        if (empty($ip)) {
            $ip = $_SERVER["REMOTE_ADDR"];
        }
        /* Check if Rating is Null */
        if ($rating == "--") {
            $error = "nullerror";
            completevote($error);
            $passtest = "no";
        }
        /* Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) */
        if ($ratinguser != $anonymous && $ratinguser != "outside") {
            $result2 = $db->sql_query("SELECT submitter from " . $prefix . "_links_links where lid='{$ratinglid}'");
            while ($row2 = $db->sql_fetchrow($result2)) {
                $ratinguserDB = $row2['submitter'];
                if ($ratinguserDB == $ratinguser) {
                    $error = "postervote";
                    completevote($error);
                    $passtest = "no";
                }
            }
        }
        /* Check if REG user is trying to vote twice. */
        if ($ratinguser != $anonymous && $ratinguser != "outside") {
            $result3 = $db->sql_query("SELECT ratinguser from " . $prefix . "_links_votedata where ratinglid='{$ratinglid}'");
            while ($row3 = $db->sql_fetchrow($result3)) {
                $ratinguserDB = $row3['ratinguser'];
                if ($ratinguserDB == $ratinguser) {
                    $error = "regflood";
                    completevote($error);
                    $passtest = "no";
                }
            }
        }
        /* Check if ANONYMOUS user is trying to vote more than once per day. */
        if ($ratinguser == $anonymous) {
            $yesterdaytimestamp = time() - 86400 * $anonwaitdays;
            $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
            $result4 = $db->sql_query("SELECT * FROM " . $prefix . "_links_votedata WHERE ratinglid='{$ratinglid}' AND ratinguser='******' AND ratinghostname = '{$ip}' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '{$anonwaitdays}'");
            $anonvotecount = $db->sql_numrows($result4);
            if ($anonvotecount >= 1) {
                $error = "anonflood";
                completevote($error);
                $passtest = "no";
            }
        }
        /* Check if OUTSIDE user is trying to vote more than once per day. */
        if ($ratinguser == "outside") {
            $yesterdaytimestamp = time() - 86400 * $outsidewaitdays;
            $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
            $result5 = $db->sql_query("SELECT * FROM " . $prefix . "_links_votedata WHERE ratinglid='{$ratinglid}' AND ratinguser='******' AND ratinghostname = '{$ip}' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '{$outsidewaitdays}'");
            $outsidevotecount = $db->sql_numrows($result5);
            if ($outsidevotecount >= 1) {
                $error = "outsideflood";
                completevote($error);
                $passtest = "no";
            }
        }
        /* Passed Tests */
        if ($passtest == "yes") {
            $comment = stripslashes($comment);
            if ($comment != "") {
                update_points(16);
            }
            update_points(15);
            /* All is well.  Add to Line Item Rate to DB. */
            $ratinglid = intval($ratinglid);
            $rating = intval($rating);
            $db->sql_query("INSERT into " . $prefix . "_links_votedata values (NULL,'{$ratinglid}', '{$ratinguser}', '{$rating}', '{$ip}', '{$ratingcomments}', now())");
            /* All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
            /* NOTE: If weight is modified, ALL links need to be refreshed with new weight. */
            /*	 Running a SQL statement with your modded calc for ALL links will accomplish this. */
            $voteresult = $db->sql_query("SELECT rating, ratinguser, ratingcomments FROM " . $prefix . "_links_votedata WHERE ratinglid = '{$ratinglid}'");
            $totalvotesDB = $db->sql_numrows($voteresult);
            include "modules/{$module_name}/voteinclude.php";
            $lid = intval($lid);
            $db->sql_query("UPDATE " . $prefix . "_links_links SET linkratingsummary='{$finalrating}',totalvotes='{$totalvotesDB}',totalcomments='{$truecomments}' WHERE lid = '{$ratinglid}'");
            $error = "none";
            completevote($error);
        }
    }
    completevotefooter($ratinglid, $ttitle, $ratinguser);
    include "footer.php";
}