示例#1
0
# work out which display mode we are in
$display = $_GET["display"];
if (!$dismodes[$display]) {
    if ($_GET["showall"] == "yes") {
        $display = "allvotes";
    } elseif ($singlemotionpage) {
        $display = "summary";
    } else {
        # two motion page
        $display = "differences";
    }
    # default
}
$dismode = $dismodes[$display];
# the sort field
$sort = db_scrub($_GET["sort"]);
if ($sort == "") {
    $sort = "party";
}
# make list of links to other display modes
$thispage = $divattr["divhref"];
if (!$singlemotionpage) {
    $thispageswap = $divattr2["divhref"];
    if ($divattr2["division_date"] != $divattr["division_date"]) {
        $thispage .= "&date2=" . $divattr2["division_date"];
        $thispageswap .= "&date2=" . $divattr["division_date"];
    }
    $thispage .= "&number2=" . $divattr2["division_number"];
    $thispageswap .= "&number2=" . $divattr["division_number"];
}
$tpdisplay = $display == "summary" ? "" : "&display={$display}";
示例#2
0
require_once "../common.inc";
# $Id: addpolicy.php,v 1.15 2006/10/23 17:16:38 publicwhip Exp $
# The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
# For details see the file LICENSE.html in the top level of the source.
require_once "../database.inc";
require_once "user.inc";
require_once "../db.inc";
require_once "../cache-tools.inc";
require_once "../dream.inc";
$just_logged_in = do_login_screen();
if (user_isloggedin()) {
    $name = db_scrub($_POST["name"]);
    $description = db_scrub($_POST["description"]);
    $submit = db_scrub($_POST["submit"]);
    $ok = false;
    if ($submit && !$just_logged_in) {
        if ($name == "" or $description == "") {
            $feedback = "Please name your policy, and give a definition.";
        } else {
            $db = new DB();
            $ret = $db->query_errcheck("insert into pw_dyn_dreammp (name, user_id, description, private) values\n                ('{$name}', '" . user_getid() . "', '{$description}', 2)");
            if ($ret) {
                $new_dreamid = mysql_insert_id();
                $ok = true;
                $feedback = "Successfully made new policy <a href=\"/policy.php?id={$new_dreamid}\">" . html_scrub($name) . "</a>.  To \n                    select votes for your new policy, <a href=\"../search.php\">search</a> or\n                    <a href=\"../divisions.php\">browse</a> for divisions.  On the page for\n                    each division you can choose how somebody supporting your policy would have voted.";
                if (user_getid()) {
                    $db->query("update pw_dyn_user set active_policy_id = {$new_dreamid} where user_id = " . user_getid());
                }
                audit_log("Added new policy '" . $name . "'");
示例#3
0
#print "<h4 id=\"th4\">The candidate calculator for <i>$constituency</i></h4>\n";
#print "<p></p>\n\n";
if (is_postcode($_GET["mppc"]) or $_GET["mpc"]) {
    $mpval = get_mpid_attr_decode($db, $db2, "");
}
$vterdet = db_scrub($_GET["vterdet"]);
$vpubemknow = db_scrub($_GET["vpubemknow"]);
$vpubemagg = db_scrub($_GET["vpubemagg"]);
$vpubem = "{$vpubemknow}-{$vpubemagg}";
$vrand = db_scrub($_GET["vrand"]);
if ($vrand) {
    $vrand = (int) $vrand;
} else {
    $vrand = rand(10, 10000000);
}
$vdash = mysql_real_escape_string(db_scrub($_GET["dash"]));
# used to tell if /by-election or /byelection was used
$vformfilled = ($vterdet and $vpubemknow and $vpubemagg);
$referrer = $_SERVER["HTTP_REFERER"];
$querystring = $_SERVER["QUERY_STRING"];
$ipnumber = $_SERVER["REMOTE_ADDR"];
if (!$referrer) {
    $referrer = $_SERVER["HTTP_USER_AGENT"];
}
$showhits = ($referrer and preg_match("/.*?house=z/", $referrer));
if ($mpval and $vformfilled) {
    $mpprop = $mpval["mpprop"];
    $party = $mpprop["party"];
    $name = $mpprop["name"];
    $constituency = $mpprop["constituency"];
    $minentered_house = $mpval["minentered_house"];
示例#4
0
<?php

require_once "common.inc";
# $Id: mps.php,v 1.39 2009/05/26 11:10:43 marklon Exp $
# The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
# For details see the file LICENSE.html in the top level of the source.
require_once "db.inc";
$db = new DB();
require_once "tablemake.inc";
require_once "tablepeop.inc";
require_once "parliaments.inc";
$rdefaultdisplay_house = "commons";
$rdefaultdisplay_parliament = 'now';
$rdisplay_parliament = db_scrub($_GET["parliament"]);
if (!$rdisplay_parliament) {
    $rdisplay_parliament = $rdefaultdisplay_parliament;
}
$rdisplay_house = strtolower(trim($_GET["house"]));
if ($rdisplay_house !== '' && false === in_array($rdisplay_house, array('lords', 'commons', 'scotland', 'both', 'all'))) {
    pw_header();
    print '<h1>Invalid house entered</h1>';
    possiblexss('house = ' . $rdisplay_house);
    pw_footer();
    exit;
}
if (!$rdisplay_house) {
    $rdisplay_house = $rdefaultdisplay_house;
}
$sort = strtolower(trim($_GET["sort"]));
示例#5
0
$dismode = $dismodes[$display];
# edit definition needs to check login
if ($dismode["editdefinition"]) {
    pw_header();
    print '<h1>Sorry, edit definitions are currently disabled</h1>';
    pw_footer();
    disabled('policy.php editdefinition');
    die;
    $just_logged_in = do_login_screen();
    if (!user_isloggedin()) {
        login_screen();
        exit;
    }
    $name = db_scrub($_POST["name"]);
    $description = $_POST["description"];
    $submiteditpolicy = db_scrub($_POST["submiteditpolicy"]);
    $form_provisional = $_POST["provisional"];
    $query = "select name, description, user_id, private from pw_dyn_dreammp where dream_id = '{$dreamid}'";
    $row = $db->query_one_row($query);
    if (!$name) {
        $name = $row[0];
    }
    if (!$description) {
        $description = $row[1];
    }
    $user_id = $row[2];
    $private = $row[3];
    $provisional = $private == 2 ? 1 : 0;
    $legacy_dream = $private == 1;
    $ok = false;
    if ($private == 1 && user_getid() != $user_id) {
示例#6
0
# This is free software, and you are welcome to redistribute it under
# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
# For details see the file LICENSE.html in the top level of the source.
require_once "db.inc";
require_once "wiki.inc";
require_once "pretty.inc";
require_once "DifferenceEngine.inc";
$db = new DB();
$type = db_scrub($_GET["type"]);
if (!$type) {
    $type = "motion";
}
if ($type) {
    if ($type == 'motion') {
        if ($_GET["date"]) {
            $params = array(db_scrub($_GET["date"]), db_scrub($_GET["number"]), db_scrub($_GET["house"]));
        } else {
            $params = null;
        }
    } else {
        trigger_error("Unknown wiki type " . htmlspecialchars($type), E_USER_ERROR);
    }
}
if ($params) {
    $db->query("select * from pw_division where division_date = '{$params['0']}' \n            and division_number = '{$params['1']}' and house = '{$params['2']}'");
    $division_details = $db->fetch_row_assoc();
    $prettydate = date("j M Y", strtotime($params[0]));
    $title = "Division Description Changes - " . $division_details['division_name'] . " - {$prettydate} - Division No. {$params['1']}";
} else {
    $title = "All Division Description Edits";
}
print "<h4 id=\"th4c\">by-election: 6 November 2008</h4>\n";
$vdash = mysql_real_escape_string(db_scrub($_GET["dash"]));
# used to tell if /by-election or /byelection was used
$vpostcode = db_scrub($_POST["vpostcode"]);
# a string of letters (each a-e for strong favour to against) in order of the policies
$vvote = mysql_real_escape_string(db_scrub($_POST["vvote"]));
$vkey = mysql_real_escape_string(db_scrub($_POST["vkey"]));
$vcomment = mysql_real_escape_string(db_scrub($_POST["vcomment"]));
$vinitials = mysql_real_escape_string(db_scrub($_POST["vinitials"]));
$vrand = $_POST["vrand"];
if ($vrand) {
    $vrand = (int) $vrand;
} else {
    $vrand = rand(10, 10000000);
}
$person = db_scrub($_POST["vname"]);
# name of person who expressing these opinions
if ($person == "I") {
    $person = "";
}
SetCandidateIssueDistances($db, $candidates, $issues);
print "<script type=\"text/javascript\">\n";
WriteJavascriptElecTable($candidates, $issues);
print "</script>\n";
print "<p style=\"background-color:#ffbbbb; margin:22px\"><b>The by-election was <a href=\"http://news.bbc.co.uk/2/hi/uk_news/politics/7415362.stm\">won</a> by Edward Timpson (Con).  Sign up for email alerts about his speeches (which will include his maiden speech) <a href=\"http://www.theyworkforyou.com/mp/edward_timpson/crewe_and_nantwich\">here</a> on theyworkforyou.com.  Thank you for your attention.</b>\n    Why not try <a href=\"/fortytwodays.php\">the fortytwo days quiz?</a></p>\n";
print "<div class=\"secpol\" id=\"sec-top\">\n";
print "<table class=\"candidatetable\" style=\"float:right\">\n";
print "<caption>List of candidates\n       <a href=\"http://www.glenrothesbyelection.com/\" target=\"_blank\">(from glenrothesbyelection.com)</a></caption>\n";
//print "<tr><th>Candidate</th><th>Party (electoral-commission)</th></tr>\n";
for ($i = 0; $i < count($candidatesA); $i++) {
    $candidate = $candidatesA[$i];
示例#8
0
require_once "../divisionvote.inc";
require_once "../forummagic.inc";
$db = new DB();
$just_logged_in = do_login_screen();
if (user_isloggedin()) {
    $type = db_scrub($_GET["type"]);
    if ($type == 'motion') {
        $params = array(db_scrub($_GET["date"]), db_scrub($_GET["number"]), db_scrub($_GET["house"]));
    } else {
        trigger_error("Unknown wiki type " . htmlspecialchars($type), E_USER_ERROR);
    }
    $newtext = $_POST["newtext"];
    $newtitle = $_POST["newtitle"];
    $newdescription = $_POST["newdescription"];
    $submit = db_scrub($_POST["submit"]);
    $rr = db_scrub($_GET["rr"]);
    $db->query("select * from pw_division where division_date = '{$params['0']}' \n        and division_number = '{$params['1']}' and house = '{$params['2']}'");
    $division_details = $db->fetch_row_assoc();
    $prettydate = date("j M Y", strtotime($params[0]));
    $title = "Edit division description - " . $division_details['division_name'] . " - {$prettydate} - Division No. {$params['1']}";
    $debate_gid = str_replace("uk.org.publicwhip/debate/", "", $division_details['debate_gid']);
    $debate_gid = str_replace("uk.org.publicwhip/lords/", "", $debate_gid);
    if ($type == "motion") {
        $motion_data = get_wiki_current_value($db, "motion", array($params[0], $params[1], $params[2]));
        $prev_name = extract_title_from_wiki_text($motion_data['text_body']);
        $prev_description = extract_motion_text_from_wiki_text($motion_data['text_body']);
        $prev_description_editable = extract_motion_text_from_wiki_text_for_edit($motion_data['text_body']);
    }
    if ($submit && !$just_logged_in) {
        if ($submit == "Save") {
            if ($type == 'motion') {
if ($person == "I") {
    $person = "";
}
// a link was selected and notified by the javascript, mark it down and leave
if ($vrand && $vevent) {
    header("Content-Type: text/html; charset=UTF-8");
    //print "<H1>Hi there</h1>\n";
    //$db->query("drop table if exists pw_dyn_glenrothes_event");
    //$db->query("create table pw_dyn_glenrothes_event (ltime timestamp, vrand int, vevent VARCHAR(30))");
    $vconstituency = db_scrub($_GET["mpc"]);
    $db->query("INSERT INTO pw_dyn_glenrothes_event (ltime, vrand, vevent)\n                VALUES (NOW(), {$vrand}, '{$vevent}')");
    // case of just a img src sent out
    exit(0);
}
$vpostcode = db_scrub($_GET["mppc"]);
$vconstituency = db_scrub($_GET["mpc"]);
if (is_postcode($vpostcode) or $_GET["mpc"]) {
    // this function does its own _GETs.  Maybe it should
    $mpval = get_mpid_attr_decode($db, $db2, "");
}
# front page
if (!$vrand) {
    // generate the random number and note it down into the main user table
    $vrand = rand(10, 10000000);
    //$db->query("drop table if exists pw_dyn_glenrothes_use");
    //$db->query("create table pw_dyn_glenrothes_use (ltime timestamp, vrand int, vpostcode varchar(20), vconstituency varchar(40), referrer varchar(200), ipnumber varchar(25), vdash varchar(7))");
    if (!isrobot()) {
        //$hithere = "<h1>hithere $vrand</h1>";
        $db->query("INSERT INTO pw_dyn_glenrothes_use (ltime, vrand, vpostcode, vconstituency, referrer, ipnumber, vdash)\n                    VALUES (NOW(), {$vrand}, '', '', '{$referrer}', '{$ipnumber}', '{$vdash}')");
    }
} else {
示例#10
0
<?php

require_once "common.inc";
# $Id: mpplot.php,v 1.1 2006/02/17 11:47:07 frabcus Exp $
# Draw thumbsketch histogram of how many MPs are each distance away
# from the Dream MP.
# The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
# For details see the file LICENSE.html in the top level of the source.
require_once "db.inc";
require_once "decodeids.inc";
$db = new DB();
$db2 = new DB();
$voter1attr = get_mpid_attr_decode($db, $db2, "");
$person = db_scrub($voter1attr['mpprop']['person']);
// Calculate number of MPs with distance to Dream MP in each of
// $divisions blocked off ranges (between 0.0 and 1.0).
$query = "select division_date, vote, whip_guess\n            from pw_vote\n            left join pw_division on pw_division.division_id = pw_vote.division_id \n            left join pw_mp on pw_mp.mp_id = pw_vote.mp_id\n            left join pw_cache_whip on pw_cache_whip.division_id = pw_division.division_id and pw_mp.party = pw_cache_whip.party\n            where pw_mp.person = {$person}\n            order by division_date";
$db->query($query);
#$divisions = 10;
#$data = array();
#for ($i = 0; $i < $divisions; $i++) {
#    $data[$i] = 0;
#}
$data = array();
while ($row = $db->fetch_row_assoc()) {
    $vote = str_replace("tell", "", $row['vote']);
    $whip = $row['whip_guess'];
    if ($vote != "aye" && $vote != "no" && $vote != "both") {
        trigger_error("Unknown vote type '{$vote}'", E_USER_ERROR);
示例#11
0
	during that day or debate.  This would be graphed to a different scale.  
	
	We should also be able to graph how much an MP is speaking per day 
	or debate (once we have those chunks parsed out) 
	so that you can see where your MP is speaking the most and 
	be able to go straight to the places where he is making 
	the most activity so that you can see and respond to it.  
*/
?>


<?php 
include "db.inc";
# word to search on.
for ($i = 1; $i < 5; $i++) {
    $word = db_scrub($_GET["word{$i}"]);
    if ($word != "") {
        $words[$i - 1] = $word;
    } else {
        break;
    }
}
$title = "Word frequency anaylsis";
include "header.inc";
print "<br>";
?>

<p>Instructions: Type words you want to look for into the 
boxes (you can leave one or two boxes blank), and press the 
button.  
This will give you a visual display of the frequency they 
示例#12
0
<?php

require_once "common.inc";
require_once "db.inc";
//header("Content-Type: text/html");
header("Content-Type: image/png");
$dreamid = intval($_GET["id"]);
$display = $_GET["display"];
$rdisplay_house = db_scrub($_GET["house"]);
$bsmall = $_GET["size"] != 'large';
$fontfile = "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf";
$fontsize = 10;
# $Id: dreamplot.php,v 1.20 2009/05/19 15:03:43 marklon Exp $
# Draw thumbsketch histogram of how many MPs are each distance away
# from the Dream MP.
# The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd
# This is free software, and you are welcome to redistribute it under
# certain conditions.  However, it comes with ABSOLUTELY NO WARRANTY.
# For details see the file LICENSE.html in the top level of the source.
require_once "parliaments.inc";
require_once "dream.inc";
$db = new DB();
update_dreammp_person_distance($db, $dreamid);
# new method
$bars = 9;
$width = 200;
$height = 100;
if ($bsmall) {
    $width = 90;
    $height = 50;
}
示例#13
0
 $key_to_house = array("WMC" => "commons", "SPC" => "scotland", "SPE" => "scotland");
 $pretty_house = array("commons" => "Commons", "scotland" => "Scotland");
 $odd = FALSE;
 # Make sure that the results are listed in the order "WMC", "SPC", "SPE":
 foreach (array("WMC", "SPC", "SPE") as $k) {
     $constituency = $postcode_matches[$k];
     if (!$constituency) {
         continue;
     }
     $house = $key_to_house[$k];
     if (!$house) {
         print "<p>Error: An unknown key " . htmlentities($k) . " was found.</p>";
         pw_footer();
         exit;
     }
     $scrubbed_constituency = db_scrub($constituency);
     # FIXME: should probably do this with mp_table instead:
     $rows = $pwpdo->fetch_all_rows('SELECT * FROM pw_mp WHERE
                     house = ? AND
                     constituency = ? AND
                     CURDATE() >= entered_house and CURDATE() <= left_house
                     ORDER BY house, last_name', array($house, $scrubbed_constituency));
     foreach ($rows as $row) {
         $mp_url = "mp.php?" . link_to_mp($row);
         $constituency_url = "mp.php?mpc=" . urlencode(str_replace(" ", "_", $row['constituency'])) . "&" . "house=" . urlencode($row['house']);
         print "<tr class=\"" . ($odd ? 'odd' : 'even') . "\">\n";
         # Print out house, full name, constituency
         print '<td class="' . $row['house'] . '">';
         print $pretty_house[$row['house']];
         print '</td>' . "\n";
         print '<td><a href="' . $mp_url . '">' . $row['first_name'] . ' ' . $row['last_name'] . '</a></td>' . "\n";