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 _htmlspecialchars(get_http_var('email')); ?> " size="30"> <br><label for="postcode">Your postcode:</label> <input type="text" name="postcode" id="postcode" value="<?php echo _htmlspecialchars(get_http_var('postcode')); ?> " size="10"> <input type="submit" class="submit" value="Join up"> </p> </form> <?php }
$c = 0; foreach ($all_news as $id => $news_row) { if ($c++ == 10) { break; } list($title, $content, $date) = $news_row; $url = "http://www.theyworkforyou.com" . news_individual_link($date, $title); $excerpt = trim_characters(news_format_body($content), 0, 250); $date = str_replace(" ", "T", $date) . "+00:00"; ?> <item rdf:about="<?php echo $url; ?> "> <title><?php echo _htmlspecialchars($title); ?> </title> <link><?php echo $url; ?> </link> <description><?php echo $excerpt; ?> </description> <dc:subject></dc:subject> <dc:creator>theyworkforyou</dc:creator> <dc:date><?php echo $date; ?>
} $date = "{$hdate} {$htime} +0000"; ?> <item> <title><?php if (isset($row['parent']) && count($row['parent']) > 0) { echo strip_tags($row['parent']['body']); } echo ' (' . format_date($row['hdate'], SHORTDATEFORMAT) . ')'; ?> </title> <link>http://www.theyworkforyou.com<?php echo $row['listurl']; ?> </link> <pubDate><?php echo $date; ?> </pubDate> <description><?php if (isset($row['speaker']) && count($row['speaker'])) { $name = ucfirst($row['speaker']['name']); echo entities_to_numbers($name) . ': '; } echo _htmlspecialchars(str_replace(array('—', '<span class="hi">', '</span>'), array('-', '<b>', '</b>'), $row['extract'])) . "</description>\n</item>\n"; } } ?> </channel> </rss>
if (sizeof($errors)) { print '<p>Please correct the following errors:</p>'; print '<ul><li>' . join('</li> <li>', $errors) . '</li></ul><br>'; ?> <form action="./" method="post"> <p> <label for="recmail">Their email:</label> <input type="text" name="recipient_mail" id="recmail" value="<?php echo _htmlspecialchars($recipient_email); ?> " size="30"> <br><label for="sendmail">Your email:</label> <input type="text" id="sendmail" name="sender_mail" value="<?php echo _htmlspecialchars($sender_email); ?> " size="30"> <br><label for="sendname">Your name:</label> <input type="text" id="sendname" name="sender_name" value="<?php echo _htmlspecialchars($sender_name); ?> " size="30"> <input type="hidden" name="pid" value="<?php echo $pid; ?> "> <br>(<a href="/privacy/">privacy policy</a>) <input type="submit" class="submit" value="Send"></p> </form> <?php } else { $rep_name = $MEMBER->full_name(); if ($MEMBER->house_disp == 1) { $rep_name .= ' MP'; } elseif ($MEMBER->house_disp == 3) {
} } ?> <p class="intro">Constituency boundaries are <strong>changing</strong> for the 2011 Scottish and Northern Irish elections. Enter your postcode here to find out what constituency you were in, and what constituency you are now voting in at the election, along with maps of before and after for Scotland (Northern Irish people will have to make do with this <a href="http://www.boundarycommission.org.uk/pics/big_map_1.jpg">overall summary map</a> from the Boundary Commission). </p> <form method="get"> <p><label for="pc">Enter your Scottish or Northern Irish postcode:</label> <input disabled type="text" id="pc" name="pc" value="<?php echo _htmlspecialchars(get_http_var('pc')); ?> " size="7"> <input disabled type="submit" value="Look up"> </p> </form> <p>This service should work anywhere in Scotland or Nothern Ireland, errors and omissions excepted.</p> <p>This service is also available through our web service <a href="http://mapit.mysociety.org/">MaPit</a>, which can provide programmatic access to the constituency for a particular postcode.</p> <ul class="results"> <li><a href="/scotland/">TheyWorkForYou’s coverage of the Scottish Parliament</a> <li><a href="/ni/">TheyWorkForYou’s coverage of the Northern Ireland Assembly</a> </ul>
" size="15"> to <input type="text" name="to" value="<?php echo _htmlspecialchars($to); ?> " size="15"> <div class="help"> You can give a <strong>start date, an end date, or both</strong>, to restrict results to a particular date range; a missing end date implies the current date, a missing start date implies the oldest date we have in the system. Dates can be entered in any format you wish, <strong>e.g. “3rd March 2007” or “17/10/1989”</strong>. </div> <li> <label for="person">Person:</label> <input type="text" name="person" value="<?php echo _htmlspecialchars($person); ?> " size="25"> <div class="help"> Enter a name here to restrict results to contributions only by that person. </div> <li> <label for="section">Section:</label> <select id="section" name="section"> <option value="">Any <?php optgroups(array('UK Parliament' => array('uk' => 'All UK', 'debates' => 'House of Commons debates', 'whall' => 'Westminster Hall debates', 'lords' => 'House of Lords debates', 'wrans' => 'Written answers', 'wms' => 'Written ministerial statements', 'standing' => 'Bill Committees', 'future' => 'Future Business'), 'Northern Ireland Assembly' => array('ni' => 'Debates'), 'Scottish Parliament' => array('scotland' => 'All Scotland', 'sp' => 'Debates', 'spwrans' => 'Written answers')), $section); ?> </select> <div class="help">
if ($current_mp) { ?> <h3>Your MP alert</h3> <ul class="alerts-manage__list"> <li> You are not subscribed to an alert for your current MP, <?php echo $current_mp->full_name(); ?> . <form action="<?php echo $actionurl; ?> " method="post"> <input type="hidden" name="t" value="<?php echo _htmlspecialchars($token); ?> "> <input type="hidden" name="pid" value="<?php echo $current_mp->person_id(); ?> "> <input type="submit" class="button small" value="Subscribe"> </form> </li> </ul> <?php } ?> <?php
<option value="ni">Debates </optgroup> <optgroup label="Scottish Parliament"> <option value="scotland">All <option value="sp">Debates <option value="spwrans">Written answers </optgroup> </select> </div> <div class="help"> Restrict results to a particular parliament or assembly that we cover (e.g. the Scottish Parliament), or a particular type of data within an institution, such as Commons Written Answers. </div> <div><label for="column">Column</label> <input type="text" id="column" name="column" value="<?php echo _htmlspecialchars(get_http_var('column')); ?> " size="10"> </div> <div class="help"> If you know the actual column number in Hansard you are interested in (perhaps you’re looking up a paper reference), you can restrict results to that. </div> <p align="right"> <input type="submit" value="Search"> </p> </form>
function api_documentation_front($method, $explorer) { global $PAGE, $this_page, $DATA, $methods; $this_page = 'api_doc_front'; $DATA->set_page_metadata($this_page, 'title', "{$method} function"); $PAGE->page_start(); $PAGE->stripe_start(); include_once 'api_' . $method . '.php'; print '<p align="center"><strong>http://www.theyworkforyou.com/api/' . $method . '</strong></p>'; api_call_user_func_or_error('api_' . $method . '_front', array(), 'No documentation yet', 'html'); ?> <h4>Explorer</h4> <p>Try out this function without writing any code!</p> <form method="get" action="?#output"> <p> <?php foreach ($methods[$method]['parameters'] as $parameter) { print $parameter . ': <input type="text" name="' . $parameter . '" value="'; if ($val = get_http_var($parameter)) { print _htmlspecialchars($val); } print '" size="30"><br>'; } ?> Output: <input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output') == 'js' || !get_http_var('output')) { print ' checked'; } ?> > <label for="output_js">JS</label> <input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output') == 'xml') { print ' checked'; } ?> > <label for="output_xml">XML</label> <input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output') == 'php') { print ' checked'; } ?> > <label for="output_php">Serialised PHP</label> <input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output') == 'rabx') { print ' checked'; } ?> > <label for="output_rabx">RABX</label> <input type="submit" value="Go"> </p> </form> <?php if ($explorer) { $qs = array(); foreach ($methods[$method]['parameters'] as $parameter) { if (get_http_var($parameter)) { $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter))); } } print '<h4><a name="output"></a>Output</h4>'; print '<p>URL for this: <strong>http://www.theyworkforyou.com/api/'; print $method . '?' . join('&', $qs) . '&output=' . _htmlspecialchars(get_http_var('output')) . '</strong></p>'; print '<pre>' . _htmlspecialchars($explorer) . '</pre>'; } $sidebar = api_sidebar(); $PAGE->stripe_end(array($sidebar)); $PAGE->page_end(); }
<?php include_once '../../includes/easyparliament/init.php'; include_once INCLUDESPATH . 'easyparliament/video.php'; $offset = 10; $from = get_http_var('from'); $gid = get_http_var('gid'); $start = intval(get_http_var('start')); $file = intval(get_http_var('file')); $pid = intval(get_http_var('pid')); $gid_safe = _htmlspecialchars($gid); if (!$gid) { $this_page = 'video_front'; $PAGE->page_start(); $PAGE->stripe_start(); video_front_page(); $PAGE->stripe_end(); $PAGE->page_end(); exit; } $this_page = 'video_main'; $surrounding_speeches = 3; # if ($from == 'next') $surrounding_speeches = 2; $gid = "uk.org.publicwhip/{$gid}"; # Fetch this GID from the database, and captioner bot time if there is one $db = new ParlDB(); $q = $db->query("select hdate, htime, adate, atime, hpos, video_status, subsection_id, major,\n (select h.gid from hansard as h where h.epobject_id=hansard.subsection_id) as parent_gid,\n (select body from epobject as e where e.epobject_id=hansard.subsection_id) as parent_body\n from hansard\n left join video_timestamps on hansard.gid = video_timestamps.gid and user_id = -1 and video_timestamps.deleted = 0\n where hansard.gid = :gid", array(':gid' => $gid)); if (!$q->rows()) { $PAGE->error_message('That GID does not appear to exist.', true, 404); exit; }
echo '<dt><a href="', $row['listurl'], '">'; if (isset($row['parent']) && count($row['parent']) > 0) { echo '<strong>' . $row['parent']['body'] . '</strong>'; } echo '</a> <small>(' . format_date($row['hdate'], LONGDATEFORMAT) . ')'; if (isset($row['video_status']) && ($row['video_status'] == 5 || $row['video_status'] == 7)) { echo ' <em>has video</em> '; } if (isset($row['collapsed']) && $row['collapsed'] && $row['subsection_id']) { $URL = new URL('search'); $URL->insert(array('s' => $info['s'] . " segment:{$row['subsection_id']}")); echo ' <a href="', $URL->generate(), '">See ', $row['collapsed'], ' other result', $row['collapsed'] > 1 ? 's' : '', ' from this ', $hansardmajors[$row['major']]['singular'], '</a>'; } echo '</small>'; if ($match = get_http_var('match')) { echo ' – <a href="/search/record.php?result=', $row['gid'], '&match=', _htmlspecialchars($match), '">This is the correct match</a>'; } echo '</dt> <dd><p>'; if (isset($row['speaker']) && count($row['speaker'])) { echo "<em>" . ucfirst($row['speaker']['name']) . "</em>"; if ($row['extract']) { echo ": "; } } echo $row['extract'] . "</p></dd>\n"; } echo '</dl> <!-- end searchresults -->'; $PAGE->page_links($info); $PAGE->search_form($info['s']); } // else, no results.
function hidden_vars($omit = array()) { global $DATA; foreach ($args as $key => $val) { if (!in_array($key, $omit)) { print "<input type=\"hidden\" name=\"{$key}\" value=\"" . _htmlspecialchars($val) . "\">\n"; } } }
echo $user_id; ?> "> <input type="text" name="g" value="<?php echo _htmlspecialchars($title); ?> " size="80"> <label for="definition"><p><textarea name="definition" id="definition" rows="10" cols="40"><?php echo _htmlentities($body); ?> </textarea></p> <?php // Wiki woo! // We need to work out how best to work this... $wiki_link = _htmlspecialchars("http://en.wikipedia.org/wiki/" . strtr($title, " ", "_")); ?> <p>Guessing the wikipedia link - give it a go:<br> <a href="<?php echo $wiki_link; ?> " target="_blank"><?php echo $wiki_link; ?> </a></p> <p>Tick here if it worked <input type="checkbox" name="wikiguess"$checked></p> <p><input type="submit" name="previewterm" value="Preview" class="submit"> <input type="submit" name="submitterm" value="Post" class="submit"></p></label> </div> <?php
function update_featured() { $featured = new MySociety\TheyWorkForYou\Model\Featured(); $title = get_http_var('title'); $context = get_http_var('context'); $gid = get_http_var('gid'); $related1 = get_http_var('related_gid1'); $related2 = get_http_var('related_gid2'); $related3 = get_http_var('related_gid3'); $featured->set_title($title); $featured->set_context($context); $featured->set_gid($gid); $featured->set_related(array($related1, $related2, $related3)); $out = "<h4>update successful</h4>"; $out .= "<p>Title set to " . _htmlspecialchars($title) . " and gid to " . _htmlspecialchars($gid) . "</p>"; return $out; }
public function _get_nextprev_items($itemdata) { global $hansardmajors; // Pass it an array of item info, of a section/subsection, and this will return // data for the next/prev items. twfy_debug(get_class($this), "getting next/prev items"); // What we return. $nextprevdata = array(); $prev_item_id = false; $next_item_id = false; if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { // Debate subsection or section - get the next one. if ($hansardmajors[$itemdata['major']]['type'] == 'other' && $hansardmajors[$itemdata['major']]['location'] == 'UK') { $where = 'htype = 11'; } else { $where = "(htype = 10 OR htype = 11)"; } } else { // Anything else in debates - get the next element that isn't // a subsection or section, and is within THIS subsection. $where = "subsection_id = '" . $itemdata['subsection_id'] . "' AND (htype != 10 AND htype != 11)"; } // Find if there are next/previous debate items of our // chosen type today. // For sections/subsections, // this will find headings with no content, but I failed to find // a vaguely simple way to do this. So this is it for now... // Find the epobject_id of the previous item (if any): $q = $this->db->query("SELECT epobject_id\n FROM \thansard\n WHERE \thdate = '" . $itemdata['hdate'] . "'\n AND \thpos < '" . $itemdata['hpos'] . "'\n AND \tmajor = '" . $itemdata['major'] . "'\n AND \t{$where}\n ORDER BY hpos DESC\n LIMIT 1"); if ($q->rows() > 0) { $prev_item_id = $q->field(0, 'epobject_id'); } // Find the epobject_id of the next item (if any): $q = $this->db->query("SELECT epobject_id\n FROM \thansard\n WHERE \thdate = '" . $itemdata['hdate'] . "'\n AND \thpos > '" . $itemdata['hpos'] . "'\n AND \tmajor = '" . $itemdata['major'] . "'\n AND \t{$where}\n ORDER BY hpos ASC\n LIMIT 1"); if ($q->rows() > 0) { $next_item_id = $q->field(0, 'epobject_id'); } // Now we're going to get the data for the next and prev items // that we will use to make the links on the page. // Previous item. if ($prev_item_id) { // We have a previous one to link to. $wherearr = array(); $wherearr['hansard.epobject_id='] = $prev_item_id; // For getting hansard data. $input = array('amount' => array('body' => true, 'speaker' => true), 'where' => $wherearr, 'order' => 'hpos DESC', 'limit' => 1); $prevdata = $this->_get_hansard_data($input); if (count($prevdata) > 0) { if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { // Linking to the prev (sub)section. $thing = $hansardmajors[$this->major]['singular']; $nextprevdata['prev'] = array('body' => "Previous {$thing}", 'url' => $prevdata[0]['listurl'], 'title' => $prevdata[0]['body']); } else { // Linking to the prev speaker. if (isset($prevdata[0]['speaker']) && count($prevdata[0]['speaker']) > 0) { $title = $prevdata[0]['speaker']['name']; } else { $title = ''; } $nextprevdata['prev'] = array('body' => 'Previous speaker', 'url' => $prevdata[0]['commentsurl'], 'title' => $title); } } } // Next item. if ($next_item_id) { // We have a next one to link to. $wherearr = array(); $wherearr['hansard.epobject_id='] = $next_item_id; // For getting hansard data. $input = array('amount' => array('body' => true, 'speaker' => true), 'where' => $wherearr, 'order' => 'hpos ASC', 'limit' => 1); $nextdata = $this->_get_hansard_data($input); if (count($nextdata) > 0) { if ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { // Linking to the next (sub)section. $thing = $hansardmajors[$this->major]['singular']; $nextprevdata['next'] = array('body' => "Next {$thing}", 'url' => $nextdata[0]['listurl'], 'title' => $nextdata[0]['body']); } else { // Linking to the next speaker. if (isset($nextdata[0]['speaker']) && count($nextdata[0]['speaker']) > 0) { $title = $nextdata[0]['speaker']['name']; } else { $title = ''; } $nextprevdata['next'] = array('body' => 'Next speaker', 'url' => $nextdata[0]['commentsurl'], 'title' => $title); } } } if ($this->major == 6) { $URL = new URL('pbc_bill'); $URL->remove(array('bill')); $nextprevdata['up'] = array('body' => _htmlspecialchars($this->bill_title), 'title' => '', 'url' => $URL->generate() . $this->url); } elseif ($itemdata['htype'] == '10' || $itemdata['htype'] == '11') { $URL = new URL($this->listpage); // Create URL for this (sub)section's date. $URL->insert(array('d' => $itemdata['hdate'])); $URL->remove(array('id')); $things = $hansardmajors[$itemdata['major']]['title']; $nextprevdata['up'] = array('body' => "All {$things} on " . format_date($itemdata['hdate'], SHORTDATEFORMAT), 'title' => '', 'url' => $URL->generate()); } else { // We'll be setting $nextprevdata['up'] within $this->get_data_by_gid() // because we need to know the name and url of the parent item, which // we don't have here. Life sucks. } return $nextprevdata; }
function display_search_form($alert, $details = array(), $errors = array()) { global $this_page, $PAGE; $ACTIONURL = new URL($this_page); $ACTIONURL->reset(); $form_start = '<form action="' . $ACTIONURL->generate() . '" method="post"> <input type="hidden" name="t" value="' . _htmlspecialchars(get_http_var('t')) . '"> <input type="hidden" name="email" value="' . _htmlspecialchars(get_http_var('email')) . '">'; if (isset($details['members']) && $details['members']->rows() > 0) { echo '<ul class="hilites">'; $q = $details['members']; for ($n = 0; $n < $q->rows(); $n++) { echo '<li>'; echo $form_start . '<input type="hidden" name="pid" value="' . $q->field($n, 'person_id') . '">'; echo 'Things by '; $name = member_full_name($q->field($n, 'house'), $q->field($n, 'title'), $q->field($n, 'given_name'), $q->field($n, 'family_name'), $q->field($n, 'lordofname')); if ($q->field($n, 'constituency')) { echo $name . ' (' . $q->field($n, 'constituency') . ') '; } else { echo $name; } echo ' <input type="submit" value="Subscribe"></form>'; echo "</li>\n"; } echo '</ul>'; } if (isset($details['constituencies'])) { echo '<ul class="hilites">'; foreach ($details['constituencies'] as $constituency) { $MEMBER = new MEMBER(array('constituency' => $constituency, 'house' => 1)); echo "<li>"; echo $form_start . '<input type="hidden" name="pid" value="' . $MEMBER->person_id() . '">'; if ($details['valid_postcode']) { echo '<input type="hidden" name="pc" value="' . _htmlspecialchars($details['alertsearch']) . '">'; } echo $MEMBER->full_name(); echo ' (' . _htmlspecialchars($constituency) . ')'; echo ' <input type="submit" value="Subscribe"></form>'; echo "</li>"; } echo '</ul>'; } if ($details['alertsearch']) { echo '<ul class="hilites"><li>'; echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($details['alertsearch']) . '">'; echo 'Mentions of ['; $alertsearch = $details['alertsearch']; if (preg_match('#speaker:(\\d+)#', $alertsearch, $m)) { $MEMBER = new MEMBER(array('person_id' => $m[1])); $alertsearch = str_replace("speaker:{$m['1']}", "speaker:" . $MEMBER->full_name(), $alertsearch); } echo _htmlspecialchars($alertsearch) . '] '; echo ' <input type="submit" value="Subscribe"></form>'; # Use original alertsearch variable here, because name replacement might introduce a comma if (strstr($details['alertsearch'], ',') > -1) { echo '<em class="error">You have used a comma in your search term – are you sure this is what you want? You cannot sign up to multiple search terms using a comma – either use OR, or fill in this form multiple times.</em>'; } if (preg_match('#([A-Z]{1,2}\\d+[A-Z]? ?\\d[A-Z]{2})#i', $alertsearch, $m) && strlen($alertsearch) > strlen($m[1]) && validate_postcode($m[1])) { $scottish_text = ''; $mp_display_text = ''; if (postcode_is_scottish($m[1])) { $mp_display_text = 'your MP, '; $scottish_text = ' or MSP'; } echo '<em class="error">You have used a postcode and something else in your search term – are you sure this is what you want? You will only get an alert if all of these are mentioned in the same debate. Did you mean to get alerts for when your MP' . $scottish_text . ' mentions something instead? If so click subscribe below.</em></li>'; try { $MEMBER = new MEMBER(array('postcode' => $m[1])); // move the postcode to the front just to be tidy $tidy_alertsearch = $m[1] . " " . trim(str_replace("{$m['1']}", "", $alertsearch)); $alertsearch_display = str_replace("{$m['1']} ", "", $tidy_alertsearch); $alertsearch = str_replace("{$m['1']}", "speaker:" . $MEMBER->person_id, $tidy_alertsearch); echo "<li>"; echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($alertsearch) . '">'; echo 'Mentions of ['; echo _htmlspecialchars($alertsearch_display) . '] by ' . $mp_display_text . $MEMBER->full_name(); echo ' <input type="submit" value="Subscribe"></form>'; if ($scottish_text) { $constituencies = postcode_to_constituencies($m[1]); if (isset($constituencies['SPC'])) { $MEMBER = new MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4)); // move the postcode to the front just to be tidy $alertsearch = str_replace("{$m['1']}", "speaker:" . $MEMBER->person_id, $tidy_alertsearch); echo "</li><li>"; echo $form_start . '<input type="hidden" name="keyword" value="' . _htmlspecialchars($alertsearch) . '">'; echo 'Mentions of ['; echo _htmlspecialchars($alertsearch_display) . '] by your MSP, ' . $MEMBER->full_name(); echo ' <input type="submit" value="Subscribe"></form>'; } } } catch (MySociety\TheyWorkForYou\MemberException $e) { echo '<p>We had a problem looking up your representative.</p>'; } } echo "</li></ul>"; } if ($details['pid']) { $MEMBER = new MEMBER(array('person_id' => $details['pid'])); echo '<ul class="hilites"><li>'; echo "Signing up for things by " . $MEMBER->full_name(); echo ' (' . _htmlspecialchars($MEMBER->constituency()) . ')'; echo "</li></ul>"; } if ($details['keyword']) { echo '<ul class="hilites"><li>'; echo 'Signing up for results from a search for ['; $alertsearch = $details['keyword']; if (preg_match('#speaker:(\\d+)#', $alertsearch, $m)) { $MEMBER = new MEMBER(array('person_id' => $m[1])); $alertsearch = str_replace("speaker:{$m['1']}", "speaker:" . $MEMBER->full_name(), $alertsearch); } echo _htmlspecialchars($alertsearch) . ']'; echo "</li></ul>"; } if (!$details['pid'] && !$details['keyword']) { ?> <p><label for="alertsearch">To sign up to an email alert, enter either your <strong>postcode</strong>, the <strong>name</strong> of who you're interested in, or the <strong>search term</strong> you wish to receive alerts for.</label> To be alerted on an exact <strong>phrase</strong>, be sure to put it in quotes. Also use quotes around a word to avoid stemming (where ‘horse’ would also match ‘horses’). <?php } echo '<form action="' . $ACTIONURL->generate() . '" method="post"> <input type="hidden" name="t" value="' . _htmlspecialchars(get_http_var('t')) . '"> <input type="hidden" name="submitted" value="1">'; if (!$details['pid'] && !$details['keyword'] || isset($errors['alertsearch'])) { if (isset($errors["alertsearch"])) { $PAGE->error_message($errors["alertsearch"]); } $text = $details['alertsearch']; if (!$text) { $text = $details['keyword']; } ?> <div class="row"> <input type="text" name="alertsearch" id="alertsearch" value="<?php if ($text) { echo _htmlentities($text); } ?> " maxlength="255" size="30" style="font-size:150%"> </div> <?php } if ($details['pid']) { echo '<input type="hidden" name="pid" value="' . _htmlspecialchars($details['pid']) . '">'; } if ($details['keyword']) { echo '<input type="hidden" name="keyword" value="' . _htmlspecialchars($details['keyword']) . '">'; } if (!$details['email_verified']) { if (isset($errors["email"]) && $details['submitted']) { $PAGE->error_message($errors["email"]); } ?> <div class="row"> <label for="email">Your email address:</label> <input type="text" name="email" id="email" value="<?php if (isset($details["email"])) { echo _htmlentities($details["email"]); } ?> " maxlength="255" size="30" class="form"> </div> <?php } ?> <div class="row"> <input type="submit" class="submit" value="<?php echo $details['pid'] || $details['keyword'] ? 'Subscribe' : 'Search'; ?> "> </div> <div class="row"> <?php if (!$details['email_verified']) { ?> <p>If you <a href="/user/?pg=join">join</a> or <a href="/user/login/?ret=%2Falert%2F">sign in</a>, you won't need to confirm your email address for every alert you set.<br><br> <?php } if (!$details['pid'] && !$details['keyword']) { ?> <p>Please note that you should only enter <strong>one term per alert</strong> – if you wish to receive alerts on more than one thing, or for more than one person, simply fill in this form as many times as you need, or use boolean OR.<br><br></p> <p>For example, if you wish to receive alerts whenever the words <i>horse</i> or <i>pony</i> are mentioned in Parliament, please fill in this form once with the word <i>horse</i> and then again with the word <i>pony</i> (or you can put <i>horse OR pony</i> with the OR in capitals as explained on the right). Do not put <i>horse, pony</i> as that will only sign you up for alerts where <strong>both</strong> horse and pony are mentioned.</p> <?php } ?> </div> <?php if (get_http_var('sign')) { echo '<input type="hidden" name="sign" value="' . _htmlspecialchars(get_http_var('sign')) . '">'; } if (get_http_var('site')) { echo '<input type="hidden" name="site" value="' . _htmlspecialchars(get_http_var('site')) . '">'; } echo '</form>'; }
include_once '../../includes/easyparliament/init.php'; $dept = get_http_var('dept'); $PAGE->page_start(); $PAGE->stripe_start(); $db = new ParlDB(); if (!$dept) { } else { $dept = strtolower(str_replace('_', ' ', $dept)); $q = $db->query('select epobject.epobject_id from hansard,epobject where hansard.epobject_id=epobject.epobject_id and major=3 and section_id=0 and hdate>(select max(hdate) from hansard where major=3) - interval 7 day and lower(body) = :dept', array(':dept' => $dept)); $ids = array(); for ($i = 0; $i < $q->rows(); $i++) { $ids[] = $q->field($i, 'epobject_id'); } print '<h2>' . _htmlspecialchars(ucwords($dept)) . '</h2>'; print '<h3>Written Questions from the past week</h3>'; $q = $db->query('select gid,body from hansard,epobject where hansard.epobject_id=epobject.epobject_id and major=3 and subsection_id=0 and section_id in (' . join(',', $ids) . ') order by body'); print '<ul>'; for ($i = 0; $i < $q->rows(); $i++) { print '<li><a href="/wrans/?id=' . fix_gid_from_db($q->field($i, 'gid')) . '">' . $q->field($i, 'body') . '</a>'; print '</li>'; } print '</ul>'; } $PAGE->stripe_end(); $PAGE->page_end();
public function construct_search_string() { // If q has a value (other than the default empty string) use that over s. if (get_http_var('q') != '') { $search_main = trim(get_http_var('q')); } else { $search_main = trim(get_http_var('s')); } $this->searchkeyword = $search_main; $searchstring = $this->parse_advanced_params(); $searchstring .= $this->parse_date_params(); $searchstring .= $this->parse_column_params(); $searchstring .= $this->parse_search_restrictions(); $searchstring .= $this->parse_groupby_params(); $searchstring .= $this->parse_person_params(); $searchstring = $this->tidy_search_string($search_main, $searchstring); twfy_debug('SEARCH', _htmlspecialchars($searchstring)); return $searchstring; }
function toString() { $styles = array(); switch ($this->name) { case 'br': return '<p><br class="block" /></p>'; case 'hr': return '<hr class="short_line" />'; case 'ref': $param = $this->param != '' ? csv_explode(',', $this->param) : array(); return guiedit_convert_ref($param); case 'clear': $styles[] = 'clear:both;'; } if ($this->text) { $this->text = str_replace(' ', ' ', _htmlspecialchars($this->text)); $this->text = preg_replace("/\r/", "<br />", $this->text); } $this->param = _htmlspecialchars($this->param); $inner = "#{$this->name}" . ($this->param ? "({$this->param})" : '') . $this->text; if (MSIE) { $styles[] = 'cursor:default;'; } $style = ''; if ($styles) { $style = ' style="' . join('', $styles) . '"'; } //$inner = '<pre>'. $inner . '</pre>'; global $xpwiki; $attr = $xpwiki->func->exist_plugin_convert($this->name) ? ' class="plugin" contenteditable="true"' : ''; return $this->wrap($inner, 'div', $attr . $style); }
<?php foreach ($topics as $page => $topic) { ?> <?php $URL = new URL($page); ?> <li><a href="http://<?php echo DOMAIN; echo $URL->generate(); ?> "> <img src="/images/<?php echo $page; ?> .jpg"> <?php echo _htmlspecialchars($topic); ?> </a></li> <?php } ?> </ul> </div> </div>
$link_to_us_form = <<<END <!-- TheyWorkForYou box, begin --> <div style="position: relative; width: 17em; color: #000000; background-color: #E8FDCB; font-family: Arial, Geneva, Sans-serif; margin-bottom: 1em; border: 1px solid #4d6c25; padding: 0 10px 2em 10px;"> <h5 style="font-family: Arial, Geneva, Sans-serif; font-size: 1.4em; position: absolute; margin: 0; bottom: 2px; right: 10px;" title="TheyWorkForYou.com"><a style="color: #880101; text-decoration: none; font-weight: normal;" href="http://www.TheyWorkForYou.com"><em style="font-weight: bold; font-style: normal;">TheyWorkFor</em><strong style="color: #cc0000; font-weight: bolder;">You</strong>.com</a></h5> <form style="margin: 0; padding: 5px 0 0 0;" title="Find out about your MP" action="http://www.theyworkforyou.com/mp/" method="get"> <label style="display: block; font-size: small; font-weight: bold; margin: 0 0 2px 0;" for="pc">Find out more about your <abbr class="display: inline; speak: spell-out;" title="Member of Parliament">MP</abbr></label> <input id="pc" name="pc" style="width: 12em; border: solid 1px #4D6C25;" title="Enter your UK postcode here" tabindex="1" type="text" size="8" maxlength="20" value="Your Postcode"> <input id="Submit1" name="Submit1" style="border: solid 0px #4d6c25; background-color: #4D6C25; color: #ffffff; font-weight: bold; text-transform: uppercase;" title="Submit search" tabindex="2" type="submit" value="Go"> </form> <form style="margin: 0; padding: 5px 0 0 0;" title="Search everything said in Parliament since 2001" action="http://www.theyworkforyou.com/search/" method="get"> <label style="display: block; font-size: small; font-weight: bold; margin: 0 0 2px 0;" for="search_input">Search Parliament</label> <input id="search_input" name="q" style="width: 12em; border: solid 1px #4D6C25;" title="Type what you're looking for" type="text" tabindex="3" size="15" maxlength="100" value="Your Search"> <input id="Submit2" name="Submit2" style="border: solid 0px #4d6c25; background-color: #4D6C25; color: #ffffff; font-weight: bold; text-transform: uppercase;" title="Submit search" tabindex="4" type="submit" value="Go"> <br> </form> </div> <!-- TheyWorkForYou box, end --> END; print $link_to_us_form; ?> <p>Cut and paste the code below into your webpage:</p> <textarea class="sourcecode" style="width: 100%; height: 20em;"> <?php print _htmlspecialchars($link_to_us_form); ?> </textarea> <p>Please retain the link to <a href="http://www.theyworkforyou.com">theyworkforyou.com</a> (Google points mean prizes). Any questions, just drop us a line at: <a href="http://www.theyworkforyou.com/contact/">http://www.theyworkforyou.com/contact/</a> </p>
?> </li> </ul> <?php $PAGE->block_end(); /////////////////////////////////////////////////////////////// // Recent users. ?> <h4>Recently registered users</h4> <?php $q = $db->query("SELECT firstname,\n lastname,\n email,\n user_id,\n confirmed,\n registrationtime\n FROM\tusers\n ORDER BY registrationtime DESC\n LIMIT 50\n "); $rows = array(); $USERURL = new URL('userview'); for ($row = 0; $row < $q->rows(); $row++) { $user_id = $q->field($row, 'user_id'); $USERURL->insert(array('u' => $user_id)); if ($q->field($row, 'confirmed') == 1) { $confirmed = 'Yes'; $name = '<a href="' . $USERURL->generate() . '">' . _htmlspecialchars($q->field($row, 'firstname')) . ' ' . _htmlspecialchars($q->field($row, 'lastname')) . '</a>'; } else { $confirmed = 'No'; $name = _htmlspecialchars($q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname')); } $rows[] = array($name, '<a href="mailto:' . $q->field($row, 'email') . '">' . $q->field($row, 'email') . '</a>', $confirmed, $q->field($row, 'registrationtime')); } $tabledata = array('header' => array('Name', 'Email', 'Confirmed?', 'Registration time'), 'rows' => $rows); $PAGE->display_table($tabledata); $menu = $PAGE->admin_menu(); $PAGE->stripe_end(array(array('type' => 'html', 'content' => $menu))); $PAGE->page_end();
function api_output_xml($v, $k = null) { global $api_xml_arr; $verbose = get_http_var('verbose') ? "\n" : ''; if (is_array($v)) { if (count($v) && array_keys($v) === range(0, count($v) - 1)) { $elt = 'match'; $api_xml_arr++; $out = "<{$elt}>"; $out .= join("</{$elt}>{$verbose}<{$elt}>", array_map('api_output_xml', $v)); $out .= "</{$elt}>{$verbose}"; return $out; } $out = ''; foreach ($v as $k => $vv) { $out .= is_numeric($k) || strpos($k, ' ') ? '<match><id>' . _htmlspecialchars($k) . '</id>' : "<{$k}>"; $out .= api_output_xml($vv, $k); $out .= is_numeric($k) || strpos($k, ' ') ? '</match>' : "</{$k}>"; $out .= $verbose; } return $out; } else { return _htmlspecialchars($v); } }
# vim:sw=4:ts=4:et:nowrap include_once '../../includes/easyparliament/init.php'; include_once INCLUDESPATH . "easyparliament/member.php"; include_once INCLUDESPATH . "easyparliament/glossary.php"; // From http://cvs.sourceforge.net/viewcvs.py/publicwhip/publicwhip/website/ include_once INCLUDESPATH . "postcode.inc"; if (!DEVSITE) { header('Cache-Control: max-age=900'); } if (get_http_var('pid') == 16407) { header('Location: /search/?pid=10133'); exit; } $searchstring = construct_search_string(); twfy_debug('SEARCH', _htmlspecialchars($searchstring)); $this_page = 'search'; $warning = ''; if (preg_match('#^\\s*[^\\s]+\\.\\.[^\\s]+\\s*$#', $searchstring)) { $warning = 'You cannot search for just a date range, please select some other criteria as well.'; } if (preg_match('#\\.\\..*?\\.\\.#', $searchstring)) { $warning = 'You cannot search for more than one date range.'; } if (get_http_var('adv') || $warning || !$searchstring) { $PAGE->page_start(); $PAGE->stripe_start(); if ($warning) { echo "<p id='warning'>{$warning}</p>"; } $PAGE->advanced_search_form();
public function SEARCHENGINE($query) { if (!defined('XAPIANDB') || !XAPIANDB) { return null; } global $xapiandb, $PAGE, $hansardmajors, $parties; if (!$xapiandb) { if (strstr(XAPIANDB, ":")) { //ini_set('display_errors', 'On'); list($xapian_host, $xapian_port) = explode(":", XAPIANDB); twfy_debug("SEARCH", "Using Xapian remote backend: " . $xapian_host . " port " . $xapian_port); $xapiandb_remote = remote_open($xapian_host, intval($xapian_port)); $xapiandb = new XapianDatabase($xapiandb_remote); } else { $xapiandb = new XapianDatabase(XAPIANDB); } } $this->query = $query; if (!isset($this->stemmer)) { $this->stemmer = new XapianStem('english'); } if (!isset($this->enquire)) { $this->enquire = new XapianEnquire($xapiandb); } if (!isset($this->queryparser)) { $this->queryparser = new XapianQueryParser(); $this->datevaluerange = new XapianDateValueRangeProcessor(1); $this->queryparser->set_stemmer($this->stemmer); $this->queryparser->set_stemming_strategy(XapianQueryParser::STEM_SOME); $this->queryparser->set_database($xapiandb); $this->queryparser->set_default_op(Query_OP_AND); $this->queryparser->add_boolean_prefix('speaker', 'S'); $this->queryparser->add_boolean_prefix('major', 'M'); $this->queryparser->add_boolean_prefix('date', 'D'); $this->queryparser->add_boolean_prefix('batch', 'B'); $this->queryparser->add_boolean_prefix('segment', 'U'); $this->queryparser->add_boolean_prefix('department', 'G'); $this->queryparser->add_boolean_prefix('party', 'P'); $this->queryparser->add_boolean_prefix('column', 'C'); $this->queryparser->add_boolean_prefix('gid', 'Q'); $this->queryparser->add_valuerangeprocessor($this->datevaluerange); } # Force words to lower case $this->query = preg_replace('#(department|party):.+?\\b#ie', 'strtolower("$0")', $this->query); // Any characters other than this are treated as, basically, white space // (apart from quotes and minuses, special case below) // The colon is in here for prefixes speaker:10043 and so on. $this->wordchars = "A-Za-z0-9,.'&:_À-ÿ"; $this->wordcharsnodigit = "A-Za-z0-9'&_À-ÿ"; // An array of normal words. $this->words = array(); // All quoted phrases, as an (array of (arrays of words in each phrase)). $this->phrases = array(); // Items prefixed with a colon (speaker:10024) as an (array of (name, value)) $this->prefixed = array(); // Split words up into individual words, and quoted phrases preg_match_all('/(' . '"|' . '(?:(?<![' . $this->wordchars . '])-)?' . '[' . $this->wordchars . ']+' . ')/', $this->query, $all_words); if ($all_words) { $all_words = $all_words[0]; } else { $all_words = array(); } $in_quote = false; $from = ''; $to = ''; foreach ($all_words as $word) { if ($word == '"') { $in_quote = !$in_quote; if ($in_quote) { array_push($this->phrases, array()); } if (!$in_quote && !count($this->phrases[count($this->phrases) - 1])) { array_pop($this->phrases); } continue; } if ($word == '') { continue; } if (strpos($word, ':') !== false) { $items = explode(":", strtolower($word)); $type = $items[0]; if (substr($type, 0, 1) == '-') { $type = substr($type, 1); } $value = strtolower(join(":", array_slice($items, 1))); if ($type == 'section') { $newv = $value; if ($value == 'debates' || $value == 'debate') { $newv = 1; } elseif ($value == 'whall' || $value == 'westminster' || $value == 'westminhall') { $newv = 2; } elseif ($value == 'wrans' || $value == 'wran') { $newv = 3; } elseif ($value == 'wms' || $value == 'statements' || $value == 'statement') { $newv = 4; } elseif ($value == 'lordsdebates' || $value == 'lords') { $newv = 101; } elseif ($value == 'ni' || $value == 'nidebates') { $newv = 5; } elseif ($value == 'pbc' || $value == 'standing') { $newv = 6; } elseif ($value == 'sp') { $newv = 7; } elseif ($value == 'spwrans' || $value == 'spwran') { $newv = 8; } elseif ($value == 'uk') { $newv = array(1, 2, 3, 4, 6, 101); } elseif ($value == 'scotland') { $newv = array(7, 8); } elseif ($value == 'future') { $newv = 'F'; } if (is_array($newv)) { $newv = 'major:' . join(' major:', $newv); } else { $newv = "major:{$newv}"; } $this->query = str_ireplace("{$type}:{$value}", $newv, $this->query); } elseif ($type == 'groupby') { $newv = $value; if ($value == 'debates' || $value == 'debate') { $newv = 'debate'; } if ($value == 'speech' || $value == 'speeches') { $newv = 'speech'; } $this->query = str_ireplace("{$type}:{$value}", '', $this->query); array_push($this->prefixed, array($type, $newv)); } elseif ($type == 'from') { $from = $value; } elseif ($type == 'to') { $to = $value; } } elseif (strpos($word, '-') !== false) { } elseif ($in_quote) { array_push($this->phrases[count($this->phrases) - 1], strtolower($word)); } elseif (strpos($word, '..') !== false) { } elseif ($word == 'OR' || $word == 'AND' || $word == 'XOR' || $word == 'NEAR') { } else { array_push($this->words, strtolower($word)); } } if ($from && $to) { $this->query = str_ireplace("from:{$from}", '', $this->query); $this->query = str_ireplace("to:{$to}", '', $this->query); $this->query .= " {$from}..{$to}"; } elseif ($from) { $this->query = str_ireplace("from:{$from}", '', $this->query); $this->query .= " {$from}.." . date('Ymd'); } elseif ($to) { $this->query = str_ireplace("to:{$to}", '', $this->query); $this->query .= " 19990101..{$to}"; } # Merged people $db = new ParlDB(); $merged = $db->query('SELECT * FROM gidredirect WHERE gid_from LIKE :gid_from', array(':gid_from' => "uk.org.publicwhip/person/%")); for ($n = 0; $n < $merged->rows(); $n++) { $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); $this->query = preg_replace("#speaker:({$from_id}|{$to_id})#i", "(speaker:{$from_id} OR speaker:{$to_id})", $this->query); } twfy_debug("SEARCH", "prefixed: " . var_export($this->prefixed, true)); twfy_debug("SEARCH", "query -- " . $this->query); $flags = XapianQueryParser::FLAG_BOOLEAN | XapianQueryParser::FLAG_LOVEHATE | XapianQueryParser::FLAG_WILDCARD | XapianQueryParser::FLAG_SPELLING_CORRECTION; $flags = $flags | XapianQueryParser::FLAG_PHRASE; try { $query = $this->queryparser->parse_query($this->query, $flags); } catch (Exception $e) { # Nothing we can really do with a bad query $this->error = _htmlspecialchars($e->getMessage()); return null; } $this->enquire->set_query($query); # Now parse the parsed query back into a query string, yummy $qd = $query->get_description(); twfy_debug("SEARCH", "queryparser original description -- " . $qd); $qd = substr($qd, 14, -1); # Strip Xapian::Query() $qd = preg_replace('#:\\(.*?\\)#', '', $qd); # Don't need pos or weight # Date range $qd = preg_replace('#VALUE_RANGE 1 (\\d+) (\\d+)#e', 'preg_replace("#(\\d{4})(\\d\\d)(\\d\\d)#", "\\$3/\\$2/\\$1", $1) . ".." . preg_replace("#(\\d{4})(\\d\\d)(\\d\\d)#", "\\$3/\\$2/\\$1", $2)', $qd); # Replace phrases with the phrase in quotes preg_match_all('#\\(([^(]*? PHRASE [^(]*?)\\)#', $qd, $m); foreach ($m[1] as $phrase) { $phrase_new = preg_replace('# PHRASE \\d+#', '', $phrase); #$this->phrases[] = preg_split('#\s+#', $phrase_new); $qd = str_replace("({$phrase})", '"' . $phrase_new . '"', $qd); } preg_match_all('#\\(([^(]*? NEAR [^(]*?)\\)#', $qd, $m); foreach ($m[1] as $mm) { $mmn = preg_replace('# NEAR \\d+ #', ' NEAR ', $mm); $qd = str_replace("({$mm})", "({$mmn})", $qd); } # Awesome regexes to get rid of superfluous matching brackets $qd = preg_replace('/( \\( ( (?: (?>[^ ()]+) | (?1) ) (?: [ ](?:AND|OR|XOR|FILTER|NEAR[ ]\\d+|PHRASE[ ]\\d+)[ ] (?: (?>[^ ()]+) | (?1) ) )* ) \\) ) [ ] (FILTER|AND_NOT)/x', '$2 $3', $qd); $qd = preg_replace('/(?:FILTER | 0 [ ] \\* ) [ ] ( \\( ( (?: (?>[^ ()]+) | (?1) ) (?: [ ](?:AND|OR|XOR)[ ] (?: (?>[^ ()]+) | (?1) ) )* ) \\) )/x', '$2', $qd); $qd = preg_replace('/(?:FILTER | 0 [ ] \\* ) [ ] ( [^()] )/x', '$1', $qd); $qd = str_replace('AND ', '', $qd); # AND is the default $qd = preg_replace('/^ ( \\( ( (?: (?>[^()]+) | (?1) )* ) \\) ) $/x', '$2', $qd); # Other prefixes $qd = preg_replace('#\\bU(\\d+)\\b#', 'segment:$1', $qd); $qd = preg_replace('#\\bC(\\d+)\\b#', 'column:$1', $qd); $qd = preg_replace('#\\bQ(.*?)\\b#', 'gid:$1', $qd); $qd = preg_replace('#\\bP(.*?)\\b#e', '"party:" . (isset($parties[ucfirst("$1")]) ? $parties[ucfirst("$1")] : "$1")', $qd); $qd = preg_replace('#\\bD(.*?)\\b#', 'date:$1', $qd); $qd = preg_replace('#\\bG(.*?)\\b#', 'department:$1', $qd); # XXX Lookup to show proper name of dept if (strstr($qd, 'M1 OR M2 OR M3 OR M4 OR M6 OR M101')) { $qd = str_replace('M1 OR M2 OR M3 OR M4 OR M6 OR M101', 'section:uk', $qd); } elseif (strstr($qd, 'M7 OR M8')) { $qd = str_replace('M7 OR M8', 'section:scotland', $qd); } $qd = preg_replace('#\\bM(\\d+)\\b#e', '"in the \'" . (isset($hansardmajors[$1]["title"]) ? $hansardmajors[$1]["title"] . "\'" : "$1")', $qd); $qd = preg_replace('#\\bMF\\b#', 'in Future Business', $qd); # Replace stemmed things with their unstemmed terms from the query $used = array(); preg_match_all('#Z[^\\s()]+#', $qd, $m); foreach ($m[0] as $mm) { $iter = $this->queryparser->unstem_begin($mm); $end = $this->queryparser->unstem_end($mm); while (!$iter->equals($end)) { $tt = $iter->get_term(); if (!in_array($tt, $used)) { break; } $iter->next(); } $used[] = $tt; $qd = preg_replace('#' . preg_quote($mm, '#') . '#', $tt, $qd, 1); } # Speakers for ($n = 0; $n < $merged->rows(); $n++) { $from_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_from')); $to_id = str_replace('uk.org.publicwhip/person/', '', $merged->field($n, 'gid_to')); $qd = str_replace("(S{$from_id} OR S{$to_id})", "S{$to_id}", $qd); $qd = str_replace("S{$from_id} OR S{$to_id}", "S{$to_id}", $qd); } preg_match_all('#S(\\d+)#', $qd, $m); foreach ($m[1] as $mm) { $member = new MEMBER(array('person_id' => $mm)); $name = iconv('iso-8859-1', 'utf-8//TRANSLIT', $member->full_name()); # Names are currently in ISO-8859-1 $qd = str_replace("S{$mm}", "speaker:{$name}", $qd); } # Simplify display of excluded words $qd = preg_replace('#AND_NOT ([a-z0-9"]+)#', '-$1', $qd); preg_match_all('#AND_NOT \\((.*?)\\)#', $qd, $m); foreach ($m[1] as $mm) { $mmn = '-' . join(' -', explode(' OR ', $mm)); $qd = str_replace("AND_NOT ({$mm})", $mmn, $qd); } foreach ($this->prefixed as $items) { if ($items[0] == 'groupby') { if ($items[1] == 'debate') { $qd .= ' grouped by debate'; } elseif ($items[1] == 'speech') { $qd .= ' showing all speeches'; } else { $PAGE->error_message("Unknown group by '{$items['1']}' ignored"); } } } $qd = iconv('utf-8', 'iso-8859-1//TRANSLIT', $qd); # Xapian is UTF-8, site is ISO8859-1 $this->query_desc = trim($qd); #print 'DEBUG: ' . $query->get_description(); twfy_debug("SEARCH", "words: " . var_export($this->words, true)); twfy_debug("SEARCH", "phrases: " . var_export($this->phrases, true)); twfy_debug("SEARCH", "queryparser description -- " . $this->query_desc); $this->valid = true; }
} exit; } $PAGE->page_start(); $PAGE->stripe_start(); if ($pc) { $lookup = lookup($pc); print '<pre>'; print_r($lookup); print '</pre>'; } ?> <form action="./edm" method="get"> <p>Postcode: <input type="text" name="pc" value="<?php echo _htmlspecialchars($pc); ?> "> <input type="submit" value="Look up"></p> </form> <?php $PAGE->stripe_end(); $PAGE->page_end(); function lookup($pc) { $key = 'Gbr9QgCDzHExFzRwPWGAiUJ5'; $file = file_get_contents('http://www.theyworkforyou.com/api/getMP?output=php&key=' . $key . '&postcode=' . urlencode($pc)); $mp = unserialize($file); if (isset($mp['error'])) { print 'ERROR: ' . $mp['error']; return;