Ejemplo n.º 1
0
function api_getWrans_search($s) {
	_api_getHansard_search( array(
		's' => $s,
		'pid' => get_http_var('person'),
		'type' => 'wrans',
	) );
}
Ejemplo n.º 2
0
function delete_success()
{
    global $PAGE, $this_page;
    $this_page = 'alertdeletesucceeded';
    $PAGE->page_start();
    $PAGE->stripe_start();
    ?>
	
	<p>Your alert has been unsubscribed.</p>
	
	<p>You will no longer receive this alert though any others you have requested will be unaffected. If you wish to unsubscribe from any more
	alerts you will have to do this individually.  If you wish to set new alerts then please visit OpenAustralia again.</p>

	<p><strong>If you didn't mean to do this, <a href="<?php 
    echo WEBPATH;
    ?>
alert/undelete/?t=<?php 
    echo get_http_var('t');
    ?>
">resubscribe to this alert</a></strong></p>


<?php 
    $PAGE->stripe_end();
    $PAGE->page_end();
}
Ejemplo n.º 3
0
 public function display()
 {
     $data = array();
     $data['recent_election'] = false;
     if ($this->user->loggedin()) {
         $data['user_signed_in'] = true;
     }
     if (get_http_var('add-alert')) {
         $data['email'] = get_http_var('email');
         $data['postcode'] = get_http_var('postcode');
         $result = $this->createAlertForPostCode($data['email'], $data['postcode']);
         $data = array_merge($data, $result);
     } elseif (get_http_var('update')) {
         $result = $this->getNewMP(get_http_var('update'));
         $data = array_merge($data, $result);
     } elseif (get_http_var('update-alert')) {
         $success = $this->replaceAlert(get_http_var('confirmation'));
         $data['confirmation_received'] = $success;
     } elseif (get_http_var('confirmed')) {
         $success = $this->confirmAlert(get_http_var('confirmed'));
         $data['confirmation_received'] = $success;
     } else {
         $data['email'] = $this->user->email() ? $this->user->email() : '';
         $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
         if ($this->isEmailSignedUpForPostCode($data['email'], $data['postcode'])) {
             $data['already_signed_up'] = True;
             $mp = $this->getPersonFromPostcode($data['postcode']);
             $data['mp_name'] = $mp->full_name();
         }
     }
     return $data;
 }
Ejemplo n.º 4
0
 function __construct($pagepath = null)
 {
     $this->P = person_if_signed_on();
     // "pwb_" prefix means passwordbox
     $this->action = get_http_var('pwb_action');
     $this->pw1 = get_http_var('pw1', null);
     $this->pw2 = get_http_var('pw2', null);
     $this->err = null;
     $this->info = null;
     if (is_null($pagepath)) {
         // no specific page - use the _current_ one.
         $foo = crack_url($_SERVER['REQUEST_URI']);
         $this->pagepath = $foo['path'];
     } else {
         // use the one supplied.
         $this->pagepath = $pagepath;
     }
     if (is_null($this->P)) {
         return;
     }
     if ($this->action == 'set_password') {
         if (is_null($this->pw1) || is_null($this->pw2)) {
             $this->err = "Please type your new password twice";
         } elseif (strlen($this->pw1) < 5 || strlen($this->pw2) < 5) {
             $this->err = "Your password must be at least 5 characters long";
         } elseif ($this->pw1 != $this->pw2) {
             $this->err = "Please type the same password twice";
         } else {
             // all looks good. do it.
             $this->P->password($this->pw1);
             db_commit();
             $this->info = 'Password changed';
         }
     }
 }
    public static function dispatch()
    {
        $id = get_http_var('id');
        $action = get_http_var('action');
        $sql = <<<EOT
SELECT m.id,m.journo_id, j.ref, j.prettyname, j.oneliner, m.url, m.submitted, m.reason
    FROM missing_articles m LEFT JOIN journo j ON m.journo_id=j.id
    WHERE m.id=?;
EOT;
        $row = db_getRow($sql, $id);
        $w = new MissingArticleWidget($row);
        // perform whatever action has been requested
        $w->perform($action);
        // is request ajax?
        $ajax = get_http_var('ajax') ? true : false;
        if ($ajax) {
            $w->emit_core();
        } else {
            // not an ajax request, so output a full page
            admPageHeader("Missing Article", "MissingArticleWidget::emit_head_js");
            print "<h2>Missing article</h2>\n";
            $w->emit_full();
            admPageFooter();
        }
    }
Ejemplo n.º 6
0
function api_getMPsInfo_id($ids)
{
    $fields = preg_split('#\\s*,\\s*#', get_http_var('fields'), -1, PREG_SPLIT_NO_EMPTY);
    $ids = preg_split('#\\s*,\\s*#', $ids, -1, PREG_SPLIT_NO_EMPTY);
    $safe_ids = array(0);
    foreach ($ids as $id) {
        if (ctype_digit($id)) {
            $safe_ids[] = $id;
        }
    }
    $ids = join(',', $safe_ids);
    $db = new ParlDB();
    $last_mod = 0;
    $q = $db->query("select person_id, data_key, data_value, lastupdate from personinfo\n\t\twhere person_id in (" . $ids . ")");
    if ($q->rows()) {
        $output = array();
        for ($i = 0; $i < $q->rows(); $i++) {
            $data_key = $q->field($i, 'data_key');
            if (count($fields) && !in_array($data_key, $fields)) {
                continue;
            }
            $pid = $q->field($i, 'person_id');
            $output[$pid][$data_key] = $q->field($i, 'data_value');
            $time = strtotime($q->field($i, 'lastupdate'));
            if ($time > $last_mod) {
                $last_mod = $time;
            }
        }
        $q = $db->query("select memberinfo.*, person_id from memberinfo, member\n\t\t\twhere memberinfo.member_id=member.member_id and person_id in (" . $ids . ")\n\t\t\torder by person_id,member_id");
        if ($q->rows()) {
            $oldmid = 0;
            $count = -1;
            for ($i = 0; $i < $q->rows(); $i++) {
                $data_key = $q->field($i, 'data_key');
                if (count($fields) && !in_array($data_key, $fields)) {
                    continue;
                }
                $mid = $q->field($i, 'member_id');
                $pid = $q->field($i, 'person_id');
                if (!isset($output[$pid]['by_member_id'])) {
                    $output[$pid]['by_member_id'] = array();
                }
                if ($oldmid != $mid) {
                    $count++;
                    $oldmid = $mid;
                    $output[$pid]['by_member_id'][$count]['member_id'] = $mid;
                }
                $output[$pid]['by_member_id'][$count][$data_key] = $q->field($i, 'data_value');
                $time = strtotime($q->field($i, 'lastupdate'));
                if ($time > $last_mod) {
                    $last_mod = $time;
                }
            }
        }
        ksort($output);
        api_output($output, $last_mod);
    } else {
        api_error('Unknown person ID');
    }
}
Ejemplo n.º 7
0
function api_getAlerts_start_date($start_date)
{
    $args = array('start_date' => $start_date, 'end_date' => get_http_var('end_date'));
    $alert = new ALERT();
    $data = $alert->fetch_between($confirmed = 1, $deleted = 0, $args['start_date'], $args['end_date']);
    api_output($data);
}
Ejemplo n.º 8
0
function view()
{
    $url = get_http_var('url', '');
    $action = get_http_var('action');
    $art = null;
    $return_code = null;
    $raw_output = '';
    $summary = 'FAILED';
    $urls_form = new ArticleURLsForm($_GET);
    if ($urls_form->is_valid()) {
        $url = $urls_form->cleaned_data['url'];
        // already got it?
        $art_id = article_find($url);
        if (is_null($art_id)) {
            list($return_code, $raw_output) = scrape_ScrapeURL($url);
            $scraped = scrape_ParseOutput($raw_output);
            if (sizeof($scraped) > 0) {
                $art_id = $scraped[0]['id'];
                $summary = 'ARTICLE SCRAPED';
            } else {
                $summary = 'NOT SCRAPED';
            }
        } else {
            $summary = 'ALREADY IN DATABASE';
        }
        if (!is_null($art_id)) {
            $art = fetch_art($art_id);
        }
    }
    $v = array('urls_form' => $urls_form, 'return_code' => $return_code, 'raw_output' => $raw_output, 'summary' => $summary, 'art' => $art);
    template($v);
}
Ejemplo n.º 9
0
 function get_params()
 {
     $p['prettyname'] = trim(get_http_var('prettyname'));
     $p['ref'] = trim(strtolower(get_http_var('ref')));
     $p['firstname'] = trim(strtolower(get_http_var('firstname')));
     $p['lastname'] = trim(strtolower(get_http_var('lastname')));
     if ($p['prettyname']) {
         $def_ref = strtolower($p['prettyname']);
         $def_ref = preg_replace('/[^a-z]+/', '-', $def_ref);
         $parts = explode(' ', strtolower($p['prettyname']));
         if ($parts) {
             $def_lastname = array_pop($parts);
             $def_firstname = array_shift($parts);
         }
         if (!$p['ref']) {
             $p['ref'] = $def_ref;
         }
         if (!$p['lastname']) {
             $p['lastname'] = $def_lastname;
         }
         if (!$p['firstname']) {
             $p['firstname'] = $def_firstname;
         }
     }
     return $p;
 }
Ejemplo n.º 10
0
function update_url()
{
    global $db;
    global $scriptpath;
    $out = '';
    $sysretval = 0;
    $personid = get_http_var('editperson');
    $q = $db->query("DELETE FROM personinfo WHERE data_key = 'mp_website' AND personinfo.person_id = :person_id", array(':person_id' => $personid));
    if ($q->success()) {
        $q = $db->query("INSERT INTO personinfo (data_key, person_id, data_value) VALUES ('mp_website', :person_id, :url)", array(':person_id' => $personid, ':url' => get_http_var('url')));
    }
    if ($q->success()) {
        exec($scriptpath . "/db2xml.pl --update_person --personid=" . escapeshellarg($personid) . " --debug", $exec_output);
        $out = '<p id="warning">';
        foreach ($exec_output as $message) {
            $out .= $message . "<br>";
        }
        $out .= '</p>';
        # ../../../scripts/db2xml.pl  --update_person --personid=10001
    }
    if ($sysretval) {
        $out .= '<p id="warning">Update Successful</p>';
    }
    return $out;
}
Ejemplo n.º 11
0
function _api_getHansard_search($array)
{
    $search = isset($array['s']) ? trim($array['s']) : '';
    $pid = trim($array['pid']);
    $type = isset($array['type']) ? $array['type'] : '';
    $search = filter_user_input($search, 'strict');
    if ($pid) {
        $search .= ($search ? ' ' : '') . 'speaker:' . $pid;
    }
    if ($type) {
        $search .= " section:" . $type;
    }
    $o = get_http_var('order');
    if ($o == 'p') {
        $data = search_by_usage($search);
        $out = array();
        foreach ($data['speakers'] as $pid => $s) {
            $out[$pid] = array('house' => $s['house'], 'name' => $s['name'], 'party' => $s['party'], 'count' => $s['count'], 'mindate' => substr($s['pmindate'], 0, 7), 'maxdate' => substr($s['pmaxdate'], 0, 7));
        }
        api_output($out);
        return;
    }
    global $SEARCHENGINE;
    $SEARCHENGINE = new SEARCHENGINE($search);
    #        $query_desc_short = $SEARCHENGINE->query_description_short();
    $pagenum = get_http_var('page');
    $args = array('s' => $search, 'p' => $pagenum, 'num' => get_http_var('num'), 'pop' => 1, 'o' => $o == 'd' || $o == 'r' ? $o : 'd');
    $LIST = new HANSARDLIST();
    $LIST->display('search', $args, 'api');
}
Ejemplo n.º 12
0
function signup_form()
{
    ?>
<form class="free_our_bills_signup" method="post" action="subscribe">
<input type="hidden" name="posted" value="1">
<p><strong>This campaign can only succeed if normal internet users like you lend a hand.</strong>
Please sign up and we'll send you easy tasks (like emailing your MP, or coming up with some ideas). Together we can improve Parliament!
</p>

<p><label for="email">Your email:</label>
<input type="text" name="email" id="email" value="<?php 
    echo get_http_var('email');
    ?>
" size="30">
<br><label for="postcode">Your postcode:</label>
<input type="text" name="postcode" id="postcode" value="<?php 
    echo get_http_var('postcode');
    ?>
" size="10">
&nbsp; <input type="submit" class="submit" value="Join up">
</p>
</form>

<?php 
}
Ejemplo n.º 13
0
function fyr_display_emailform()
{
    $messages = array();
    if (isset($_POST['action']) && $_POST['action'] == 'testmess') {
        $messages = emailform_test_message();
        if ($messages) {
            emailform_display($messages);
            return;
        } else {
            $dest = get_http_var('dest');
            $contact_message = get_http_var('notjunk');
            if ($dest == 'rep') {
                $problem = 'You cannot contact your representative by filling in the WriteToThem contact form. To contact your representative, please visit <a href="/">www.writetothem.com</a> and enter your postcode. We have printed your message below so you can copy and paste it into the WriteToThem message box.';
                wrongcontact_display($problem, $contact_message);
            } elseif ($dest == 'other') {
                $problem = 'You can only contact the team behind WriteToThem using our contact form. Your message is printed below so you can copy and paste it to wherever you want to send it.';
                wrongcontact_display($problem, $contact_message);
            } else {
                if (emailform_send_message()) {
                    $messages['messagesent'] = 'Thanks, your message has been sent to ' . OPTION_WEB_DOMAIN;
                } else {
                    $messages['messagenotsent'] = 'Sorry, there was a problem';
                }
                emailform_display($messages);
            }
        }
    } else {
        emailform_display($messages);
    }
}
Ejemplo n.º 14
0
 protected function getSearchSections()
 {
     $sections = array(array('section' => 'wrans', 'title' => 'Written Answers'));
     if (get_http_var('type') == '') {
         $sections[] = array('section' => 'wms', 'title' => 'Written Ministerial Statements');
     }
     return $sections;
 }
Ejemplo n.º 15
0
 protected function display_front()
 {
     if (get_http_var('more')) {
         return parent::display_front();
     } else {
         return $this->display_front_ni();
     }
 }
Ejemplo n.º 16
0
 function setup()
 {
     $leaflet_id = get_http_var('q');
     if (!isset($leaflet_id)) {
         throw_404();
     } else {
         $this->leaflet_id = $leaflet_id;
     }
 }
Ejemplo n.º 17
0
function admin_page_display($site_name, $pages, $default = null)
{
    $maintitle = "{$site_name} admin";
    if (get_http_var("page")) {
        // find page
        $id = get_http_var("page");
        foreach ($pages as $page) {
            if (isset($page) && $page->id == $id) {
                break;
            }
        }
        // display
        ob_start();
        if (isset($page->contenttype)) {
            header($page->contenttype);
        } else {
            header("Content-Type: text/html; charset=utf-8");
            $title = $page->navname . " - {$maintitle}";
            admin_html_header($title);
            print "<h1>{$title}</h1>";
        }
        $self_link = "?page={$id}";
        $page->self_link = $self_link;
        $page->display($self_link);
        # TODO remove this as parameter, use class member
        if (!isset($page->contenttype)) {
            admin_html_footer();
        }
    } else {
        header("Content-Type: text/html; charset=utf-8");
        admin_html_header($maintitle);
        print '<h3>' . $site_name . '</h3>';
        if (!is_null($default)) {
            $default->display();
        }
        // generate navigation bar
        $navlinks = "<ul>";
        foreach ($pages as $page) {
            if (isset($page)) {
                if (isset($page->url)) {
                    $navlinks .= "<li><a href=\"" . $page->url . "\">" . $page->navname . "</a>";
                } else {
                    $navlinks .= "<li><a href=\"?page=" . $page->id . "\">" . $page->navname . "</a>";
                }
            } else {
                $navlinks .= '</ul> <ul>';
            }
        }
        $navlinks .= '</ul>';
        print $navlinks;
        ?>
<p><a href="http://www.mysociety.org/"><img class="mslogo" src="https://secure.mysociety.org/mysociety_sm.gif" border="0" alt="mySociety"></a></p>
<?php 
        admin_html_footer();
    }
}
Ejemplo n.º 18
0
 public function display()
 {
     global $PAGE;
     if ($spid = get_http_var('spid')) {
         $this->spwrans_redirect($spid);
         $PAGE->page_end();
     } else {
         return parent::display();
     }
 }
Ejemplo n.º 19
0
 function setup()
 {
     $leaflet_id = get_http_var('q');
     if (!isset($leaflet_id)) {
         throw_404();
     } else {
         $this->viewstate['leaflet_id'] = $leaflet_id;
     }
     $this->viewstate['message_sent'] = false;
 }
Ejemplo n.º 20
0
function formFetch()
{
    $p = array();
    $p['action'] = get_http_var('action');
    $p['name'] = get_http_var('name');
    $p['email'] = get_http_var('email');
    $p['message'] = get_http_var('message');
    $p['recaptcha_response_field'] = get_http_var('recaptcha_response_field', null);
    $p['recaptcha_challenge_field'] = get_http_var('recaptcha_challenge_field');
    return $p;
}
Ejemplo n.º 21
0
function update_policy()
{
    global $db;
    $out = '';
    $policyid = get_http_var('editpolicy');
    $q = $db->query("UPDATE policies SET title = :title, description = :description, image = :image,\n        image_attrib = :image_attrib, image_license = :image_license, image_license_url = :image_license_url,\n        image_source = :image_source WHERE policy_id = :policy_id", array(':policy_id' => $policyid, ':title' => get_http_var('title'), ':description' => get_http_var('description'), ':image' => get_http_var('image'), ':image_attrib' => get_http_var('image_attrib'), ':image_license' => get_http_var('image_license'), ':image_license_url' => get_http_var('image_license_url'), ':image_source' => get_http_var('image_source')));
    if ($q->success()) {
        $out = "<h4>update successful</h4>";
    }
    return $out;
}
function api_getConstituencies_latitude($lat)
{
    $lon = get_http_var('longitude') + 0;
    $d = get_http_var('distance') + 0;
    if (!$lat) {
        api_error('You must supply a latitude and longitude');
        return;
    }
    $out = _api_getConstituencies_latitude($lat, $lon, $d);
    api_output($out);
}
Ejemplo n.º 23
0
 function setup()
 {
     //store callback url in viewstate if needed
     $callback = get_http_var('callback');
     if (isset($callback)) {
         if (valid_url($callback)) {
             $callback = urldecode($callback);
             $this->viewstate['callback'] = $callback;
         }
     }
 }
Ejemplo n.º 24
0
function update_banner()
{
    global $banner;
    $banner_text = get_http_var('banner');
    if ($banner->set_text($banner_text)) {
        $out = "<h4>update successful</h4>";
        $out .= "<p>Banner text is now:</p><p>{$banner_text}</p>";
    } else {
        $out = "<h4>Failed to update banner text</h4>";
    }
    return $out;
}
Ejemplo n.º 25
0
 private function set_application()
 {
     $application = session_read('application');
     if (!isset($application)) {
         $application = factory::create('application');
     }
     $this->application = $application;
     $election_id = get_http_var('election_id');
     if ($election_id != 0) {
         session_write('election_id', $election_id);
     }
 }
 function setup()
 {
     //clear session
     session_delete("image_ids");
     //store callback url in viewstate if needed
     $callback = get_http_var('callback');
     if (isset($callback)) {
         if (valid_url($callback)) {
             $callback = urldecode($callback);
             $this->viewstate['callback'] = $callback;
         }
     }
 }
Ejemplo n.º 27
0
function api_getConstituencies_latitude($lat)
{
    api_error('Currently disabled, sorry; please get in touch if you need this function.');
    return;
    $lon = get_http_var('longitude') + 0;
    $d = get_http_var('distance') + 0;
    if (!$lat) {
        api_error('You must supply a latitude and longitude');
        return;
    }
    $out = _api_getConstituencies_latitude($lat, $lon, $d);
    api_output($out);
}
Ejemplo n.º 28
0
function voteerror($text)
{
    global $PAGE;
    $PAGE->page_start();
    $message = array('title' => 'Sorry', 'text' => $text);
    if (get_http_var('ret') != '') {
        $message['linkurl'] = get_http_var('ret');
        $message['linktext'] = 'Back to previous page';
    }
    $PAGE->message($message);
    $PAGE->page_end();
    exit;
}
Ejemplo n.º 29
0
 function setup()
 {
     //store callback url in viewstate if needed
     $callback = get_http_var('callback');
     if (isset($callback)) {
         if (valid_url($callback)) {
             $callback = urldecode($callback);
             $this->viewstate['callback'] = $callback;
         }
     }
     //create a new upload id and add to viewstate
     $this->viewstate['upload_key'] = md5(uniqid(rand(), true));
 }
Ejemplo n.º 30
0
 function setup()
 {
     $leaflet_id = get_http_var('q');
     if (!isset($leaflet_id)) {
         throw_404();
     } else {
         $this->leaflet_id = $leaflet_id;
     }
     $message_id = get_http_var('m');
     if ($message_id == 1) {
         $this->add_message("Thank you, your leaflet has been added");
     }
 }