Beispiel #1
0
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Jarifa.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once "inc/poll.inc";
require_once "inc/identica.inc";
$poll = new poll();
// First, create the hash of the password for attaching BOINC projects
$passwd_hash = md5($poll->conf->projects->password . "\n");
if ($_GET['auth'] == $passwd_hash) {
    $two_projects = array();
    // Attach to clients only the two most voted projects (in case of a draft with several projects, choose one random)
    $projects = $poll->get_projects($order = "votes");
    // Save stats in stats_poll table
    $poll->save_stats();
    // Rank of votes, zero position has the highest number of votes and last position the lowest one.
    $votes = $poll->get_votes();
    if (count($votes) > 1) {
        for ($i = 0; $i < 2; $i++) {
            $clause = "votes=" . $votes[$i]->votes;
            $candidate_projects = $poll->get_projects("name", $clause);
            // If there are more than one project with the same number of votes, we choose one of them randomly
            shuffle($candidate_projects);
            $two_projects[] = $candidate_projects[0];
        }
    } else {
        $clause = "votes=" . $votes[0]->votes;
        $candidate_projects = $poll->get_projects("name", $clause);
        // If there are more than one project with the same number of votes, we choose one of them randomly
        shuffle($candidate_projects);