示例#1
0
            $time_already_spent = $usr_entry[1];
            $new_time_spent = $time_already_spent + $time_spent;
            $result = pg_prepare($con, "update_user", 'UPDATE users SET time_spent=$2 WHERE id=$1');
            $result = pg_execute($con, "update_user", array($usr_id, $new_time_spent));
            pg_free_result($result);
        }
        $result = pg_prepare($con, "check_url", 'SELECT * FROM votes where url = $1');
        $result = pg_execute($con, "check_url", array($url));
        $url_entry = pg_fetch_array($result);
        pg_free_result($result);
        if (!$url_entry) {
            //create url entry, add vote time
            $result = pg_prepare($con, "register_url", 'INSERT INTO votes VALUES ($1, $2)');
            $result = pg_execute($con, "register_url", array($url, $time_spent));
            pg_free_result($result);
        } else {
            //update vote time
            $vote_count = $url_entry[1];
            $new_count = $vote_count + $time_spent;
            $result = pg_prepare($con, "update_votes", 'UPDATE votes SET votes=$2 WHERE url=$1');
            $result = pg_execute($con, "update_votes", array($url, $new_count));
            pg_free_result($result);
        }
        $id = $usr_entry[0];
        $spent = $usr_entry[1];
        $reg = $usr_entry[2];
        echo json_encode(array("usr" => $id, "spent" => $time_spent, "reg" => $reg, "url" => $url));
    }
}
cast_vote($_POST['url'], $_POST['usr_id'], $_POST['time_spent'], $_POST['time_reg']);
示例#2
0
<?php

include 'core/init.inc.php';
$positions = get_positions($_POST['bid']);
$pos_count = count($positions);
if ($_SESSION['studID'] !== null) {
    for ($rank = 0; $rank < $pos_count; $rank++) {
        cast_vote($_POST['posRank' . $rank]);
    }
}
add_voter($_SESSION['studID'], $_POST['bid']);
$_SESSION['studID'] = null;
header('refresh: 8; url=index.php');
?>
<!DOCTYPE html>
<html>
  <head>
    <title>Voting Site - Confirm Cast</title>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
    <link href="misc/css/index.css" rel="stylesheet" media="screen" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="bootsrap/assets/css/bootstrap-responsive.css" rel="stylesheet" />
  </head>
  <body>
    
    <div class="container-fluid" id="base">
        <br />
        <div class="row-fluid">
            <div class="span8 offset2" id="banner"></div>
        </div>
        <br />
示例#3
0
        $log->LogInfo("[FAILURE] Fail to authenticate " . $webid . " => " . $auth->authnDiagnostic);
    }
}
// Get the number of messages
if (isset($_SESSION['webid']) && $_SESSION['webid']) {
    $messages = get_msg_count($_SESSION['webid']);
    $wall_msg = get_msg_count($_SESSION['webid'], True, True);
}
// Bad place to add logic for adding/removing friends.
// add a specific person as friend
if (isset($_SESSION['myprofile']) && $_SESSION['myprofile']->is_local($webid) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'addfriend') {
    // add friend and display confirmation
    $confirmation = $_SESSION['myprofile']->add_friend($_REQUEST['add_webid']);
    $_SESSION['myprofile'] = new MyProfile($_SESSION['webid'], BASE_URI, SPARQL_ENDPOINT);
    $_SESSION['myprofile']->load(true);
}
// remove a specific person from friends
if (isset($_SESSION['myprofile']) && $_SESSION['myprofile']->is_local($webid) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'delfriend') {
    // remove friend and display confirmation
    $confirmation = $_SESSION['myprofile']->del_friend($_REQUEST['del_webid']);
    $_SESSION['myprofile'] = new MyProfile($_SESSION['webid'], BASE_URI, SPARQL_ENDPOINT);
    $_SESSION['myprofile']->load(true);
}
// cast a YES vote for a given message and user
if (isset($_REQUEST['vote']) && $_REQUEST['vote'] == 'yes' && isset($_SESSION['myprofile']) && isset($_REQUEST['message_id'])) {
    echo cast_vote($_SESSION['webid'], $_REQUEST['message_id'], 1);
}
// cast a NO vote for a given message and user
if (isset($_REQUEST['vote']) && $_REQUEST['vote'] == 'no' && isset($_SESSION['myprofile']) && isset($_REQUEST['message_id'])) {
    echo cast_vote($_SESSION['webid'], $_REQUEST['message_id'], 0);
}