Ejemplo n.º 1
0
function getRandomImage($db_handle, $db_found)
{
    require 'getTotalVotes.php';
    if ($db_found) {
        $SQL_stmt = "SELECT * FROM files ORDER BY RAND() LIMIT 2";
        $query_result = mysqli_query($db_handle, $SQL_stmt);
        if ($query_result) {
            $num_rows = mysqli_num_rows($query_result);
            if ($num_rows > 0) {
                //echoing some html
                echo "<table>";
                while ($row = mysqli_fetch_assoc($query_result)) {
                    //sets the image id to the file id, which is unique
                    echo "<img src='data:image/jpeg;base64," . base64_encode($row['fdata']) . "' height='350' id=" . $row['fid'] . " class='the_image'/> <br>\n\t\t\t\t\t      <div id='" . $row['fid'] . "_text' class='the_image_text'>" . getTotalVotes($db_handle, $row['fid']) . "</div>";
                }
                echo "</table>";
            } else {
                $func_message = "No files found";
            }
        } else {
            echo "Error querying database";
        }
        mysqli_close($db_handle);
    } else {
        echo "Error connecting to database";
    }
}
Ejemplo n.º 2
0
            $query_result = mysqli_multi_query($db_handle, $SQL_stmt);
            if ($query_result) {
                $message = getTotalVotes($db_handle, $image_id);
            } else {
                $message = "Voting error";
            }
        } else {
            $fusers_voted = $fusers_voted . $modified_username;
            $images_voted = $images_voted . $modified_image_id;
            //multi query was going out of sync here
            $SQL_stmt = "UPDATE files SET fusers_voted = '{$fusers_voted}', fvote_total = fvote_total + 1 WHERE fid = '{$image_id}'";
            $query_result = mysqli_query($db_handle, $SQL_stmt);
            $SQL_stmt = "UPDATE users SET images_voted = '{$images_voted}' WHERE uid = '{$uid}';";
            $query_result = mysqli_query($db_handle, $SQL_stmt);
            if ($query_result) {
                $message = getTotalVotes($db_handle, $image_id);
            } else {
                $message = "Voting error";
            }
        }
        mysqli_close($db_handle);
    }
}
function checkVoted($voted, $user)
{
    $voted = explode(',', $voted);
    if (in_array($user, $voted)) {
        return true;
    } else {
        return false;
    }
Ejemplo n.º 3
0
 *  substitute goods or services; loss of use, data, or profits; or business    *
 *  interruption) however caused and on any theory of liability, whether in     *
 *  contract, strict liability, or tort (including negligence or otherwise)     *
 *  arising in any way out of the use of this software, even if advised of the  *
 *  possibility of such damage.                                                 *
 *                                                                              *
 ********************************************************************************/
include_once $_SERVER['DOCUMENT_ROOT'] . '/config.php';
include_once $HUB_FLM->getCodeDirPath("ui/headerstats.php");
global $CFG, $LNG;
$sort = optional_param("sort", "vote", PARAM_ALPHANUM);
$oldsort = optional_param("lastsort", "", PARAM_ALPHANUM);
$direction = optional_param("lastdir", "DESC", PARAM_ALPHANUM);
$totalsItems = getTotalItemVotes();
$totalsConns = getTotalConnectionVotes();
$totals = getTotalVotes();
$topVotedNodes = getTotalTopVotes(10);
$topVotedForNodes = getTopNodeForVotes(10);
$topVotedAgainstNodes = getTopNodeAgainstVotes(10);
$topVoters = getTopVoters(10);
$topVotersFor = getTopForVoters(10);
$topVotersAgainst = getTopAgainstVoters(10);
$allNodeVotes = getAllVoting($direction, $sort, $oldsort);
?>

<h3 style="margin-top:0px;"><?php 
echo $LNG->STATS_GLOBAL_VOTES_MENU_TITLE;
?>
</h3>

<table width="160" style="float:left;margin-right:50px;">