Exemplo n.º 1
0
function your_mp_bullet_point()
{
    global $THEUSER, $MPURL;
    print "<li>";
    $pc_form = true;
    if ($THEUSER->constituency_is_set()) {
        // (We don't allow the user to search for a postcode if they
        // already have one set in their prefs.)
        $MEMBER = new MEMBER(array('constituency' => $THEUSER->constituency()));
        if ($MEMBER->valid) {
            $pc_form = false;
            $CHANGEURL = new URL('userchangepc');
            $mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
            $former = "";
            $left_house = $MEMBER->left_house();
            if ($left_house[1]['date'] != '9999-12-31') {
                $former = 'former';
            }
            ?>
	<p><a href="<?php 
            echo $MPURL->generate();
            ?>
"><strong>Find out more about <?php 
            echo $mpname;
            ?>
, your <?php 
            echo $former;
            ?>
 Representative</strong></a>
	(<a href="<?php 
            echo $CHANGEURL->generate();
            ?>
">Change</a>)</p>
<?php 
        }
    }
    if ($pc_form) {
        ?>
		<form action="<?php 
        echo $MPURL->generate();
        ?>
" method="get">
		<p><strong>Find out more about your Representative</strong><br>
		<label for="pc">Enter your Australian postcode here:</label>&nbsp; <input type="text" name="pc" id="pc" size="8" maxlength="10" class="text">&nbsp;&nbsp;<input type="submit" value=" GO " class="submit"></p>
		</form>
	<?php 
    }
    print "</li>";
}
Exemplo n.º 2
0
function fetch_mp($pc, $constituencies, $house = null)
{
    global $THEUSER;
    $args = array('constituency' => $constituencies['WMC']);
    if ($house) {
        $args['house'] = $house;
    }
    try {
        $MEMBER = new MEMBER($args);
    } catch (MySociety\TheyWorkForYou\MemberException $e) {
        postcode_error($e->getMessage());
    }
    if ($MEMBER->person_id()) {
        $THEUSER->set_postcode_cookie($pc);
    }
    return $MEMBER;
}
Exemplo n.º 3
0
function load_member($pid)
{
    $member = new MEMBER(array('person_id' => $pid));
    if (!$member->valid) {
        output_error('Unknown ID');
    }
    $member->load_extra_info();
    return $member;
}
Exemplo n.º 4
0
 public static function manage($email)
 {
     $db = new \ParlDB();
     $q = $db->query('SELECT * FROM alerts WHERE email = :email
         AND deleted != 1 ORDER BY created', array(':email' => $email));
     $out = '';
     for ($i = 0; $i < $q->rows(); ++$i) {
         $row = $q->row($i);
         $criteria = explode(' ', $row['criteria']);
         $ccc = array();
         $current = true;
         foreach ($criteria as $c) {
             if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
                 $MEMBER = new \MEMBER(array('person_id' => $m[1]));
                 $ccc[] = 'spoken by ' . $MEMBER->full_name();
                 if (!$MEMBER->current_member_anywhere()) {
                     $current = false;
                 }
             } else {
                 $ccc[] = $c;
             }
         }
         $criteria = join(' ', $ccc);
         $token = $row['alert_id'] . '-' . $row['registrationtoken'];
         $action = '<form action="/alert/" method="post"><input type="hidden" name="t" value="' . $token . '">';
         if (!$row['confirmed']) {
             $action .= '<input type="submit" name="action" value="Confirm">';
         } elseif ($row['deleted'] == 2) {
             $action .= '<input type="submit" name="action" value="Resume">';
         } else {
             $action .= '<input type="submit" name="action" value="Suspend"> <input type="submit" name="action" value="Delete">';
         }
         $action .= '</form>';
         $out .= '<tr><td>' . $criteria . '</td><td align="center">' . $action . '</td></tr>';
         if (!$current) {
             $out .= '<tr><td colspan="2"><small>&nbsp;&mdash; <em>not a current member of any body covered by TheyWorkForYou</em></small></td></tr>';
         }
     }
     if ($out) {
         print '<table cellpadding="3" cellspacing="0"><tr><th>Criteria</th><th>Action</th></tr>' . $out . '</table>';
     } else {
         print '<p>You currently have no email alerts set up.</p>';
     }
 }
Exemplo n.º 5
0
 public static function meta($e)
 {
     $private = false;
     if ($e['committee_name']) {
         $title = $e['committee_name'];
         if ($e['title'] == 'to consider the Bill') {
         } elseif ($e['title'] && $e['title'] != 'This is a private meeting.') {
             $title .= ': ' . $e['title'];
         } else {
             $private = true;
         }
     } else {
         $title = $e['title'];
         if ($pid = $e['person_id']) {
             $MEMBER = new \MEMBER(array('person_id' => $pid));
             $name = $MEMBER->full_name();
             $title .= " &#8211; <a href='/mp/?p={$pid}'>{$name}</a>";
         }
     }
     $meta = array();
     if ($d = $e['debate_type']) {
         if ($d == 'Adjournment') {
             $d = 'Adjournment debate';
         }
         $meta[] = $d;
     }
     if ($e['time_start'] || $e['location']) {
         if ($e['time_start']) {
             $time = format_time($e['time_start'], TIMEFORMAT);
             if ($e['time_end']) {
                 $time .= ' &#8211; ' . format_time($e['time_end'], TIMEFORMAT);
             }
             $meta[] = $time;
         }
         if ($e['location']) {
             $meta[] = $e['location'];
         }
     }
     if ($private) {
         $meta[] = 'Private meeting';
     }
     return array($title, $meta);
 }
Exemplo n.º 6
0
 function __construct($end_switch = false)
 {
     CORE::summon(__FILE__);
     if ($end_switch) {
         self::$endClass = __CLASS__ . "_BACKEND";
     } else {
         self::$endClass = __CLASS__ . "_FRONTEND";
     }
     new self::$endClass();
 }
Exemplo n.º 7
0
    function _get_committee($bill_id)
    {
        include_once INCLUDESPATH . "easyparliament/member.php";
        $q = $this->db->query('select count(*) as c from hansard where major=6 and minor=' . mysql_escape_string($bill_id) . ' and htype=10');
        $sittings = $q->field(0, 'c');
        $q = $this->db->query('select member_id,sum(attending) as attending, sum(chairman) as chairman
			from pbc_members where bill_id=' . mysql_escape_string($bill_id) . ' group by member_id');
        $comm = array('sittings' => $sittings);
        for ($i = 0; $i < $q->rows(); $i++) {
            $member_id = $q->field($i, 'member_id');
            $mp = new MEMBER(array('member_id' => $member_id));
            $attending = $q->field($i, 'attending');
            $chairman = $q->field($i, 'chairman');
            $arr = array('name' => $mp->full_name(), 'attending' => $attending);
            if ($chairman) {
                $comm['chairmen'][$member_id] = $arr;
            } else {
                $comm['members'][$member_id] = $arr;
            }
        }
        return $comm;
    }
Exemplo n.º 8
0
function find_constituency($args)
{
    // We see if the user is searching for a postcode or constituency.
    global $PAGE, $db;
    if ($args['s'] != '') {
        $searchterm = $args['s'];
    } else {
        $PAGE->error_message('No search string');
        return false;
    }
    $constituencies = array();
    $constituency = '';
    $validpostcode = false;
    if (validate_postcode($searchterm)) {
        // Looks like a postcode - can we find the constituency?
        $constituencies = postcode_to_constituency($searchterm);
        if ($constituencies == '') {
            $constituencies = array();
        } else {
            $validpostcode = true;
        }
        if (!is_array($constituencies)) {
            $constituencies = array($constituencies);
        }
    }
    if ($constituencies == array() && $searchterm) {
        // No luck so far - let's see if they're searching for a constituency.
        $try = strtolower($searchterm);
        if (normalise_constituency_name($try)) {
            $constituency = normalise_constituency_name($try);
        } else {
            $query = "select distinct\n                    (select name from constituency where cons_id = o.cons_id and main_name) as name \n                from constituency AS o where name like '%" . mysql_real_escape_string($try) . "%'\n                and from_date <= date(now()) and date(now()) <= to_date";
            $q = $db->query($query);
            for ($n = 0; $n < $q->rows(); $n++) {
                $constituencies[] = $q->field($n, 'name');
            }
        }
    }
    if (count($constituencies) == 1) {
        $constituency = $constituencies[0];
    }
    if ($constituency != '') {
        // Got a match, display....
        $MEMBER = new MEMBER(array('constituency' => $constituency));
        $URL = new URL('mp');
        if ($MEMBER->valid) {
            $URL->insert(array('m' => $MEMBER->member_id()));
            print '<h3>MP for ' . preg_replace("#{$searchterm}#i", '<span class="hi">$0</span>', $constituency);
            if ($validpostcode) {
                // Display the postcode the user searched for.
                print ' (' . htmlentities(strtoupper($args['s'])) . ')';
            }
            ?>
</h3>
            
            <p><a href="<?php 
            echo $URL->generate();
            ?>
"><strong><?php 
            echo htmlentities($MEMBER->first_name()) . ' ' . htmlentities($MEMBER->last_name());
            ?>
</strong></a> (<?php 
            echo $MEMBER->party();
            ?>
)</p>
    <?php 
        }
    } elseif (count($constituencies)) {
        print "<h3>MPs in constituencies matching '" . htmlentities($searchterm) . "'</h3><ul>";
        foreach ($constituencies as $constituency) {
            $MEMBER = new MEMBER(array('constituency' => $constituency));
            $URL = new URL('mp');
            if ($MEMBER->valid) {
                $URL->insert(array('m' => $MEMBER->member_id()));
            }
            print '<li><a href="' . $URL->generate() . '"><strong>' . htmlentities($MEMBER->first_name()) . ' ' . htmlentities($MEMBER->last_name()) . '</strong></a> (' . preg_replace("#{$searchterm}#i", '<span class="hi">$0</span>', $constituency) . ', ' . $MEMBER->party() . ')</li>';
        }
        print '</ul>';
    }
}
Exemplo n.º 9
0
 function addTeamMember($memberid, $admin)
 {
     global $manager;
     $memberid = intval($memberid);
     $admin = intval($admin);
     // check if member is already a member
     $tmem = MEMBER::createFromID($memberid);
     if ($tmem->isTeamMember($this->getID())) {
         return 0;
     }
     $manager->notify('PreAddTeamMember', array('blog' => &$this, 'member' => &$tmem, 'admin' => &$admin));
     // add to team
     $query = 'INSERT INTO ' . sql_table('team') . ' (TMEMBER, TBLOG, TADMIN) ' . 'VALUES (' . $memberid . ', ' . $this->getID() . ', "' . $admin . '")';
     sql_query($query);
     $manager->notify('PostAddTeamMember', array('blog' => &$this, 'member' => &$tmem, 'admin' => $admin));
     $logMsg = sprintf(_TEAM_ADD_NEWTEAMMEMBER, $tmem->getDisplayName(), $memberid, $this->getName());
     ACTIONLOG::add(INFO, $logMsg);
     return 1;
 }
Exemplo n.º 10
0
            <?php 
}
?>
        </form>
    </div>
    <div>
        <h3>Your representative</h3>
        <?php 
$MPURL = new URL('yourmp');
global $THEUSER;
$pc_form = true;
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
    // User is logged in and has a postcode, or not logged in with a cookied postcode.
    // (We don't allow the user to search for a postcode if they
    // already have one set in their prefs.)
    $MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode()));
    if ($MEMBER->valid) {
        $pc_form = false;
        if ($THEUSER->isloggedin()) {
            $CHANGEURL = new URL('useredit');
        } else {
            $CHANGEURL = new URL('userchangepc');
        }
        $mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
        $former = "";
        $left_house = $MEMBER->left_house();
        if ($left_house[1]['date'] != '9999-12-31') {
            $former = 'former';
        }
        ?>
 
Exemplo n.º 11
0
        $errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a known postcode";
    } elseif (isset($constituencies['SPE']) || isset($constituencies['SPC'])) {
        $MEMBER = new MEMBER(array('constituency' => $constituencies['WMC']));
        if ($MEMBER->person_id()) {
            $THEUSER->set_postcode_cookie($pc);
        }
        list($out, $sidebars) = pick_multiple($pc, $constituencies, 'SPE', 'MSP');
    } elseif (isset($constituencies['NIE'])) {
        $MEMBER = new MEMBER(array('constituency' => $constituencies['WMC']));
        if ($MEMBER->person_id()) {
            $THEUSER->set_postcode_cookie($pc);
        }
        list($out, $sidebars) = pick_multiple($pc, $constituencies, 'NIE', 'MLA');
    } else {
        # Just have an MP, redirect instantly to the canonical page
        $MEMBER = new MEMBER(array('constituency' => $constituencies['WMC']));
        if ($MEMBER->person_id()) {
            $THEUSER->set_postcode_cookie($pc);
        }
        member_redirect($MEMBER);
    }
} else {
    $errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a valid postcode";
    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
}
$PAGE->page_start();
$PAGE->stripe_start();
if (isset($errors['pc'])) {
    $PAGE->error_message($errors['pc']);
    $PAGE->postcode_form();
}
Exemplo n.º 12
0
Arquivo: dat.php Projeto: palfrey/twfy
<?php

# Compile data for MP page in Google gadget
# XXX Lots here copied from elsewhere... Damn you deadlines.
include_once 'min-init.php';
include_once INCLUDESPATH . 'easyparliament/member.php';
include_once '../api/api_functions.php';
$pid = $_GET['pid'];
if (!$pid) {
    print '<error>No ID</error>';
    exit;
}
$member = new MEMBER(array('person_id' => $pid));
if (!$member->valid) {
    print '<error>Unknown ID</error>';
    exit;
}
$member->load_extra_info();
$row = array('person_id' => $pid, 'full_name' => $member->full_name(), 'constituency' => $member->constituency(), 'party' => $member->party_text(), 'majority_in_seat' => number_format($member->extra_info['majority_in_seat']), 'swing_to_lose_seat_today' => number_format($member->extra_info['swing_to_lose_seat_today']));
list($image, $sz) = find_rep_image($pid, true);
if ($image) {
    $row['image'] = $image;
}
foreach ($member->extra_info['office'] as $office) {
    if ($office['to_date'] == '9999-12-31' && $office['source'] == 'chgpages/selctee') {
        $row['selctee'][] = prettify_office($office['position'], $office['dept']);
    }
}
$none = false;
$output = array();
$pw_keys = array_filter(array_keys($member->extra_info), create_function('$a', '
Exemplo n.º 13
0
Arquivo: page.php Projeto: archoo/twfy
    function search_form($value = '')
    {
        global $SEARCHENGINE;
        // Search box on the search page.
        // If $value is set then it will be displayed in the form.
        // Otherwise the value of 's' in the URL will be displayed.
        $wtt = get_http_var('wtt');
        $URL = new URL('search');
        $URL->reset();
        // no need to pass any query params as a form action. They are not used.
        if ($value == '') {
            $value = get_http_var('s');
        }
        echo '<div class="mainsearchbox">';
        if ($wtt < 2) {
            echo '<form action="', $URL->generate(), '" method="get">';
            if (get_http_var('o')) {
                echo '<input type="hidden" name="o" value="', htmlentities(get_http_var('o')), '">';
            }
            if (get_http_var('house')) {
                echo '<input type="hidden" name="house" value="', htmlentities(get_http_var('house')), '">';
            }
            echo '<input type="text" name="s" value="', htmlentities($value), '" size="20"> ';
            echo '<input type="submit" value=" ', $wtt ? 'Modify search' : 'Search', ' "><br>';
            if ($wtt) {
                print '<input type="hidden" name="wtt" value="1">';
            }
        } else {
            ?>
	<form action="http://www.writetothem.com/lords" method="get">
	<input type="hidden" name="pid" value="<?php 
            echo htmlentities(get_http_var('pid'));
            ?>
">
	<input type="submit" style="font-size: 150%" value=" I want to write to this Lord "><br>
<?php 
        }
        if (!$wtt) {
            echo '<div style="margin-top: 5px">';
            $orderUrl = new URL('search');
            $ordering = get_http_var('o');
            if ($ordering != 'r' && $ordering != 'd' && $ordering != 'p') {
                $ordering = 'd';
            }
            if ($ordering == 'r') {
                print '<strong>Most relevant results are first</strong>';
            } else {
                printf("<a href='%s'>Show most relevant results first</a>", $orderUrl->generate('html', array('o' => 'r')));
            }
            print "&nbsp;|&nbsp;";
            if ($ordering == 'd') {
                print '<strong>Most recent results are first</strong>';
            } else {
                printf("<a href='%s'>Show most recent results first</a>", $orderUrl->generate('html', array('o' => 'd')));
            }
            print "&nbsp;|&nbsp;";
            if ($ordering == 'p') {
                print '<strong>Use by person</strong>';
            } else {
                printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o' => 'p')));
            }
            echo '</div>';
            $person_id = get_http_var('pid');
            if ($person_id != "") {
                $member = new MEMBER(array('person_id' => $person_id));
                if ($member->valid) {
                    $name = $member->full_name();
                    ?>
                    <p>
                    <input type="radio" name="pid" value="<?php 
                    echo htmlentities($person_id);
                    ?>
" checked>Search only <?php 
                    echo htmlentities($name);
                    ?>
 
                    <input type="radio" name="pid" value="">Search all speeches
                    </p>
                <?php 
                }
            }
        }
        echo '</form> </div>';
    }
Exemplo n.º 14
0
 /**
  * Adds a new comment to the database
  * @param string $timestamp
  * @param array $comment
  * @return mixed
  */
 function addComment($timestamp, $comment)
 {
     global $CONF, $member, $manager;
     $blogid = getBlogIDFromItemID($this->itemid);
     $settings =& $manager->getBlog($blogid);
     $settings->readSettings();
     // begin if: comments disabled
     if (!$settings->commentsEnabled()) {
         return _ERROR_COMMENTS_DISABLED;
     }
     // end if
     // begin if: public cannot comment
     if (!$settings->isPublic() && !$member->isLoggedIn()) {
         return _ERROR_COMMENTS_NONPUBLIC;
     }
     // end if
     // begin if: comment uses a protected member name
     if ($CONF['ProtectMemNames'] && !$member->isLoggedIn() && MEMBER::isNameProtected($comment['user'])) {
         return _ERROR_COMMENTS_MEMBERNICK;
     }
     // end if
     // begin if: email required, but missing (doesn't apply to members)
     if ($settings->emailRequired() && strlen($comment['email']) == 0 && !$member->isLoggedIn()) {
         return _ERROR_EMAIL_REQUIRED;
     }
     // end if
     ## Note usage of mb_strlen() vs strlen() below ##
     // begin if: commenter's name is too long
     if (mb_strlen($comment['user']) > 40) {
         return _ERROR_USER_TOO_LONG;
     }
     // end if
     // begin if: commenter's email is too long
     if (mb_strlen($comment['email']) > 100) {
         return _ERROR_EMAIL_TOO_LONG;
     }
     // end if
     // begin if: commenter's url is too long
     if (mb_strlen($comment['userid']) > 100) {
         return _ERROR_URL_TOO_LONG;
     }
     // end if
     $comment['timestamp'] = $timestamp;
     $comment['host'] = gethostbyaddr(serverVar('REMOTE_ADDR'));
     $comment['ip'] = serverVar('REMOTE_ADDR');
     // begin if: member is logged in, use that data
     if ($member->isLoggedIn()) {
         $comment['memberid'] = $member->getID();
         $comment['user'] = '';
         $comment['userid'] = '';
         $comment['email'] = '';
     } else {
         $comment['memberid'] = 0;
     }
     // spam check
     $continue = FALSE;
     $plugins = array();
     if (isset($manager->subscriptions['ValidateForm'])) {
         $plugins = array_merge($plugins, $manager->subscriptions['ValidateForm']);
     }
     if (isset($manager->subscriptions['PreAddComment'])) {
         $plugins = array_merge($plugins, $manager->subscriptions['PreAddComment']);
     }
     if (isset($manager->subscriptions['PostAddComment'])) {
         $plugins = array_merge($plugins, $manager->subscriptions['PostAddComment']);
     }
     $plugins = array_unique($plugins);
     while (list(, $plugin) = each($plugins)) {
         $p = $manager->getPlugin($plugin);
         $continue = $continue || $p->supportsFeature('handleSpam');
     }
     $spamcheck = array('type' => 'comment', 'body' => $comment['body'], 'id' => $comment['itemid'], 'live' => TRUE, 'return' => $continue);
     // begin if: member logged in
     if ($member->isLoggedIn()) {
         $spamcheck['author'] = $member->displayname;
         $spamcheck['email'] = $member->email;
     } else {
         $spamcheck['author'] = $comment['user'];
         $spamcheck['email'] = $comment['email'];
         $spamcheck['url'] = $comment['userid'];
     }
     // end if
     $manager->notify('SpamCheck', array('spamcheck' => &$spamcheck));
     if (!$continue && isset($spamcheck['result']) && $spamcheck['result'] == TRUE) {
         return _ERROR_COMMENTS_SPAM;
     }
     // isValidComment returns either "1" or an error message
     $isvalid = $this->isValidComment($comment, $spamcheck);
     if ($isvalid != 1) {
         return $isvalid;
     }
     // begin if: send email to notification address
     if ($settings->getNotifyAddress() && $settings->notifyOnComment()) {
         $mailto_msg = _NOTIFY_NC_MSG . ' ' . $this->itemid . "\n";
         //			$mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $this->itemid . "\n\n";
         $temp = parse_url($CONF['Self']);
         if ($temp['scheme']) {
             $mailto_msg .= createItemLink($this->itemid) . "\n\n";
         } else {
             $tempurl = $settings->getURL();
             if (substr($tempurl, -1) == '/' || substr($tempurl, -4) == '.php') {
                 $mailto_msg .= $tempurl . '?itemid=' . $this->itemid . "\n\n";
             } else {
                 $mailto_msg .= $tempurl . '/?itemid=' . $this->itemid . "\n\n";
             }
         }
         if ($comment['memberid'] == 0) {
             $mailto_msg .= _NOTIFY_USER . ' ' . $comment['user'] . "\n";
             $mailto_msg .= _NOTIFY_USERID . ' ' . $comment['userid'] . "\n";
         } else {
             $mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n";
         }
         $mailto_msg .= _NOTIFY_HOST . ' ' . $comment['host'] . "\n";
         $mailto_msg .= _NOTIFY_COMMENT . "\n " . $comment['body'] . "\n";
         $mailto_msg .= getMailFooter();
         $item =& $manager->getItem($this->itemid, 0, 0);
         $mailto_title = _NOTIFY_NC_TITLE . ' ' . strip_tags($item['title']) . ' (' . $this->itemid . ')';
         $frommail = $member->getNotifyFromMailAddress($comment['email']);
         $notify =& new NOTIFICATION($settings->getNotifyAddress());
         $notify->notify($mailto_title, $mailto_msg, $frommail);
     }
     $comment = COMMENT::prepare($comment);
     $manager->notify('PreAddComment', array('comment' => &$comment, 'spamcheck' => &$spamcheck));
     $name = sql_real_escape_string($comment['user']);
     $url = sql_real_escape_string($comment['userid']);
     $email = sql_real_escape_string($comment['email']);
     $body = sql_real_escape_string($comment['body']);
     $host = sql_real_escape_string($comment['host']);
     $ip = sql_real_escape_string($comment['ip']);
     $memberid = intval($comment['memberid']);
     $timestamp = date('Y-m-d H:i:s', $comment['timestamp']);
     $itemid = $this->itemid;
     $qSql = 'SELECT COUNT(*) AS result ' . 'FROM ' . sql_table('comment') . ' WHERE ' . 'cmail   = "' . $url . '"' . ' AND cmember = "' . $memberid . '"' . ' AND cbody   = "' . $body . '"' . ' AND citem   = "' . $itemid . '"' . ' AND cblog   = "' . $blogid . '"';
     $result = (int) quickQuery($qSql);
     if ($result > 0) {
         return _ERROR_BADACTION;
     }
     $query = 'INSERT INTO ' . sql_table('comment') . ' (CUSER, CMAIL, CEMAIL, CMEMBER, CBODY, CITEM, CTIME, CHOST, CIP, CBLOG) ' . "VALUES ('{$name}', '{$url}', '{$email}', {$memberid}, '{$body}', {$itemid}, '{$timestamp}', '{$host}', '{$ip}', '{$blogid}')";
     sql_query($query);
     // post add comment
     $commentid = sql_insert_id();
     $manager->notify('PostAddComment', array('comment' => &$comment, 'commentid' => &$commentid, 'spamcheck' => &$spamcheck));
     // succeeded !
     return TRUE;
 }
Exemplo n.º 15
0
	function criteria_pretty($html = false) {
		$criteria = explode(' ',$this->criteria);
		$words = array(); $spokenby = '';
		foreach ($criteria as $c) {
			if (preg_match('#^speaker:(\d+)#',$c,$m)) {
				$MEMBER = new MEMBER(array('person_id'=>$m[1]));
				$spokenby = $MEMBER->full_name();
			} else {
				$words[] = $c;
			}
		}
		$criteria = '';
		if (count($words)) $criteria .= ($html?'<li>':'* ') . 'Containing the ' . make_plural('word', count($words)) . ': ' . join(' ', $words) . ($html?'</li>':'') . "\n";
		if ($spokenby) $criteria .= ($html?'<li>':'* ') . "Spoken by $spokenby" . ($html?'</li>':'') . "\n";
		return $criteria;
	}
Exemplo n.º 16
0
/**
 * Returns one item (Nucleus version)
 */
function _getItem($itemid, $username, $password)
{
    global $manager;
    // 1. login
    $mem = new MEMBER();
    if (!$mem->login($username, $password)) {
        return _error(1, "Could not log in");
    }
    // 2. check if allowed
    if (!$manager->existsItem($itemid, 1, 1)) {
        return _error(6, "No such item ({$itemid})");
    }
    $blogid = getBlogIDFromItemID($itemid);
    if (!$mem->teamRights($blogid)) {
        return _error(3, "Not a team member");
    }
    // 3. return the item
    // Structure returned has dateCreated, userid, blogid and content
    $item =& $manager->getItem($itemid, 1, 1);
    // (also allow drafts and future items)
    $blog = new BLOG($blogid);
    if ($blog->convertBreaks()) {
        $item['body'] = removeBreaks($item['body']);
    }
    $newstruct = new xmlrpcval(array("publishDate" => new xmlrpcval(iso8601_encode($item['timestamp']), "dateTime.iso8601"), "userid" => new xmlrpcval($item['authorid'], "string"), "blogid" => new xmlrpcval($blogid, "string"), "title" => new xmlrpcval($item['title'], "string"), "body" => new xmlrpcval($item['body'], "string"), "more" => new xmlrpcval($item['more'], "string"), "draft" => new xmlrpcval($item['draft'], "boolean"), "closed" => new xmlrpcval($item['closed'], "boolean")), 'struct');
    return new xmlrpcresp($newstruct);
}
Exemplo n.º 17
0
        if ($cconstituency == "") {
            $constituency = postcode_to_constituency($pc);
        } else {
            $constituency = $cconstituency;
        }
        if ($constituency == "connection_timed_out") {
            $errors['pc'] = "Sorry, we couldn't check your postcode right now, as our postcode lookup server is under quite a lot of load. Please use the 'All MPs' link above to browse all the MPs.";
        } elseif ($constituency == "") {
            $errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a known postcode";
            twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
        } elseif (is_array($constituency)) {
            $PAGE->page_start_mobile();
            $PAGE->stripe_start();
            print '<p>There are several electoral divisions within your postcode. Please select from the following:</p><ul>';
            foreach ($constituency as $c) {
                $member = new MEMBER(array('constituency' => $c));
                print '<li><a href="' . WEBPATH . 'mp/?pc=' . $pc . '&c=' . $c . '">' . ucwords(strtolower($member->full_name())) . ', ' . $member->constituency() . '</a></li>';
            }
            print '</ul>';
            $MPSURL = new URL('mps');
            $sidebar = array('type' => 'html', 'content' => '<div class="block">
						<h4><a href="' . $MPSURL->generate() . '">Browse all MPs</a></h4>
					</div>');
            //$PAGE->stripe_end(array($sidebar));
        } else {
            // Redirect to the canonical MP page, with a person id.
            $MEMBER = new MEMBER(array('constituency' => $constituency));
            if ($MEMBER->person_id()) {
                if ($THEUSER->isloggedin()) {
                    # Updates too much in the database to make one change
                    $details = array('firstname' => $THEUSER->firstname(), 'lastname' => $THEUSER->lastname(), 'email' => $THEUSER->email(), 'emailpublic' => $THEUSER->emailpublic(), 'postcode' => $pc, 'constituency' => $constituency, 'url' => $THEUSER->url(), 'optin' => $THEUSER->optin());
Exemplo n.º 18
0
function display_user($user_id = "")
{
    global $THEUSER, $PAGE, $DATA, $this_page, $who;
    // We're either going to be:
    //	Displaying the details of a user who's just been edited
    //		(their user_id will be in $user_id now).
    //	Viewing THEUSER's own data.
    //	Viewing someone else's data (their id will be in the GET string
    //		user_id variable).
    // We could do something cleverer so that if THEUSER has sufficient
    // privileges we display more data when they're viewing someone else's info
    // than what your average punter sees.
    // If $user_id is a user id, we've just edited that user's info.
    // FIRST: Work out whose info we're going to show.
    $edited = false;
    // Have we just edited someone's info?
    if (is_numeric($user_id) && $user_id == $THEUSER->user_id()) {
        // Display this user's just edited info.
        $display = "this user";
        $edited = true;
    } elseif (is_numeric($user_id)) {
        // Display someone else's just edited info.
        $display = "another user";
        $edited = true;
    } elseif (is_numeric(get_http_var("u"))) {
        // Display someone else's info.
        $user_id = get_http_var("u");
        $display = "another user";
    } elseif ($THEUSER->isloggedin()) {
        // Display this user's info.
        $display = "this user";
        $user_id = $THEUSER->user_id();
    } else {
        // Nothing to show!
        $URL = new URL('userlogin');
        $URL->insert(array('ret' => '/user/'));
        $loginurl = $URL->generate();
        header("Location: {$loginurl}");
        exit;
    }
    // SECOND: Get the data for whoever we're going to show.
    if ($display == "another user") {
        // Viewing someone else's info.
        $USER = new USER();
        $valid = $USER->init($user_id);
        if ($valid && $USER->confirmed() && !$USER->deleted()) {
            // Don't want to display unconfirmed or deleted users.
            $name = $USER->firstname() . " " . $USER->lastname();
            $url = $USER->url();
            if ($USER->emailpublic() == true) {
                $email = $USER->email();
            }
            $status = $USER->status();
            $registrationtime = $USER->registrationtime();
            // Change the page title to reflect whose info we're viewing.
            $DATA->set_page_metadata($this_page, "title", "{$name}");
        } else {
            // This user_id doesn't exist.
            $display = "none";
        }
    } elseif ($display == "this user") {
        // Display THEUSER's info.
        $name = $THEUSER->firstname() . " " . $THEUSER->lastname();
        $url = $THEUSER->url();
        if ($edited) {
            // We want to show all the info to the user.
            $email = $THEUSER->email();
            $emailpublic = $THEUSER->emailpublic() == true ? "Yes" : "No";
            $optin = $THEUSER->optin() == true ? "Yes" : "No";
            $postcode = $THEUSER->postcode();
        } else {
            // We're showing them how they're seen to other people.
            if ($THEUSER->emailpublic()) {
                $email = $THEUSER->email();
            }
            $registrationtime = $THEUSER->registrationtime();
            $status = $THEUSER->status();
        }
        // Change the page title to make it clear we're viewing THEUSER's
        // own info. Make them less worried about other people seeing some of the
        // info that shouldn't be public.
        $DATA->set_page_metadata($this_page, "title", "Your details");
    } else {
        // There's nothing to display!
    }
    // THIRD: Print out what we've got.
    $PAGE->page_start();
    if ($display != "none") {
        $PAGE->stripe_start();
        if (isset($registrationtime)) {
            // Make registration time more user-friendly.
            list($date, $time) = explode(' ', $registrationtime);
            $registrationtime = format_date($date, LONGDATEFORMAT);
        }
        if ($edited) {
            print "\t\t\t\t<p><strong>" . ucfirst($who) . " details have been updated:</strong></p>\n";
        }
        if ($this_page == 'userviewself' && !$edited) {
            $EDITURL = new URL('useredit');
            ?>
				<p><strong>This is how other people see you.</strong> <a href="<?php 
            echo $EDITURL->generate();
            ?>
">Edit your details</a>.</p>
<?php 
        }
        ?>
				<div class="row">
				<span class="label">Name</span>
				<span class="formw"><?php 
        if (substr($name, -3) == ' MP') {
            print '<a href="/mp/' . make_member_url(substr($name, 0, -3)) . '">';
        }
        echo htmlentities($name);
        if (substr($name, -3) == ' MP') {
            print '</a>';
        }
        ?>
</span>
				</div>

				<div class="row">
				<span class="label">Email</span>
				<span class="formw"><?php 
        if (isset($email)) {
            $escaped_email = str_replace('@', '&#64;', htmlentities($email));
            ?>
<a href="mailto:<?php 
            echo $escaped_email . "\">" . $escaped_email;
            ?>
</a><?php 
        } else {
            ?>
Not public<?php 
        }
        ?>
</span>
				</div>

<?php 
        if (isset($postcode)) {
            if ($postcode == '') {
                $postcode = 'none';
            }
            ?>
				<div class="row">&nbsp;<br>
				<span class="label">UK Postcode</span>
				<span class="formw"><?php 
            echo htmlentities($postcode);
            ?>
 <small>(not public)</small></span>
				</div>

<?php 
        }
        if (isset($url)) {
            if ($url == '') {
                $url = 'none';
            } else {
                $url = '<a href="' . htmlentities($url) . '">' . htmlentities($url) . '</a>';
            }
            ?>
				<div class="row">
				<span class="label">Website</span>
				<span class="formw"><?php 
            echo $url;
            ?>
</span>
				</div>

<?php 
        }
        if (isset($emailpublic)) {
            ?>
				<div class="row">&nbsp;<br>Let other people see your email address? <strong><?php 
            echo htmlentities($emailpublic);
            ?>
</strong></div>

<?php 
        }
        if (isset($optin)) {
            ?>
				<div class="row">Receive TheyWorkForYou.com emails? <strong><?php 
            echo htmlentities($optin);
            ?>
</strong></div>

<?php 
        }
        if (isset($status)) {
            ?>
				<div class="row">
				<span class="label">Status</span>
				<span class="formw"><?php 
            echo htmlentities($status);
            ?>
</span>
				</div>
<?php 
        }
        if (isset($registrationtime)) {
            ?>
				<div class="row">
				<span class="label">Joined</span>
				<span class="formw"><?php 
            echo htmlentities($registrationtime);
            ?>
</span>
				</div>
<?php 
        }
        if ($edited && $this_page == 'userviewself') {
            $EDITURL = new URL('useredit');
            $VIEWURL = new URL('userviewself');
            ?>
				<p>&nbsp;<br><a href="<?php 
            echo $EDITURL->generate();
            ?>
">Edit again</a> or <a href="<?php 
            echo $VIEWURL->generate();
            ?>
">see how others see you</a>.</p>
<?php 
        }
        $PAGE->stripe_end();
        # Email alerts
        if ($this_page == 'userviewself') {
            $PAGE->stripe_start();
            print '<h3>Your email alerts</h3>';
            $db = new ParlDB();
            $q = $db->query('SELECT * FROM alerts WHERE email = "' . mysql_escape_string($THEUSER->email()) . '" ORDER BY confirmed,deleted,alert_id');
            $out = '';
            for ($i = 0; $i < $q->rows(); ++$i) {
                $row = $q->row($i);
                $criteria = explode(' ', $row['criteria']);
                $ccc = array();
                foreach ($criteria as $c) {
                    if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
                        $MEMBER = new MEMBER(array('person_id' => $m[1]));
                        $ccc[] = 'spoken by ' . $MEMBER->full_name();
                    } else {
                        $ccc[] = $c;
                    }
                }
                $criteria = join(' ', $ccc);
                $token = $row['alert_id'] . '-' . $row['registrationtoken'];
                if (!$row['confirmed']) {
                    $action = '<a href="/A/' . $token . '">Confirm</a>';
                } elseif ($row['deleted']) {
                    $action = '<form action="/alert/undelete/" method="post"><input type="hidden" name="t" value="' . $token . '"><input type="submit" value="Undelete"></form>';
                } else {
                    $action = '<form action="/alert/delete/" method="post"><input type="hidden" name="t" value="' . $token . '"><input type="submit" value="Delete"></form>';
                }
                $out .= '<tr><td>' . $criteria . '</td><td>' . $action . '</td></tr>';
            }
            print '<p>To add a new alert, simply visit an MP or Peer\'s page or conduct a search &#8212; to be given the option of turning them into alerts automatically &#8212; or visit <a href="/alert/">the manual addition page</a>.</p>';
            if ($out) {
                print '<p>Here are your email alerts:</p>';
                print '<table cellpadding="3" cellspacing="0"><tr><th>Criteria</th><th>Action</th></tr>' . $out . '</table>';
            } else {
                print '<p>You currently have no email alerts set up.</p>';
            }
            $PAGE->stripe_end();
        }
        if (!$edited) {
            $args = array('user_id' => $user_id, 'page' => get_http_var('p'));
            $COMMENTLIST = new COMMENTLIST();
            $COMMENTLIST->display('user', $args);
        }
    } else {
        $message = array('title' => 'Sorry...', 'text' => "We don't have a user ID, so we can't show you anyone's details.");
        $PAGE->message($message);
    }
    $PAGE->page_end();
}
Exemplo n.º 19
0
 /**
  * Inidicates that an activation link has been clicked and any forms displayed
  * there have been successfully filled out.
  * @author dekarma
  */
 function activate($key)
 {
     // get activate info
     $info = MEMBER::getActivationInfo($key);
     // no active key
     if (!$info) {
         return false;
     }
     switch ($info->vtype) {
         case 'forgot':
             // nothing to do
             break;
         case 'register':
             // set canlogin value
             global $CONF;
             sql_query('UPDATE ' . sql_table('member') . ' SET mcanlogin='******'NewMemberCanLogon']) . ' WHERE mnumber=' . intval($info->vmember));
             break;
         case 'addresschange':
             // reset old 'canlogin' value
             list($oldEmail, $oldCanLogin) = explode('/', $info->vextra);
             sql_query('UPDATE ' . sql_table('member') . ' SET mcanlogin='******' WHERE mnumber=' . intval($info->vmember));
             break;
     }
     // delete from activation table
     sql_query('DELETE FROM ' . sql_table('activation') . ' WHERE vkey=\'' . sql_real_escape_string($key) . '\'');
     // success!
     return true;
 }
Exemplo n.º 20
0
umask(02);
$HANSARDLIST = new HANSARDLIST();
$db = $HANSARDLIST->db;
// Get all the person ids we need feeds for...
$q = $db->query("SELECT person_id, group_concat(member_id order by member_id separator ',') as member_ids\n\t\t\tFROM member GROUP BY person_id HAVING max(left_house)='9999-12-31'");
if ($q->rows() <= 0) {
    exit;
}
$starttime = time();
for ($personrow = 0; $personrow < $q->rows(); $personrow++) {
    $person_id = $q->field($personrow, 'person_id');
    $member_ids = $q->field($personrow, 'member_ids');
    $args = array('member_ids' => $member_ids);
    $speeches = $HANSARDLIST->display('person', $args, 'none');
    // Some data about this person that we'll need for the feed.
    $MEMBER = new MEMBER(array('person_id' => $person_id));
    $MPURL = new URL('mp');
    $MPURL->insert(array('pid' => $person_id));
    $mpurl = $MPURL->generate();
    $date = gmdate('Y-m-d');
    $time = gmdate('H:i:s');
    $datenow = $date . 'T' . $time . '+00:00';
    // Prepare the meat of the RSS file.
    $items = '';
    $entries = '';
    if (isset($speeches['rows']) && count($speeches['rows']) > 0) {
        foreach ($speeches['rows'] as $n => $row) {
            // While we're linking to individual speeches,
            // the text is the body of the parent, ie (sub)section.
            $title = htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
            $link = isset($row['listurl']) ? $row['listurl'] : '';
Exemplo n.º 21
0
 function confirm($token)
 {
     // The user has clicked the link in their confirmation email
     // and the confirm page has passed the token from the URL to here.
     // If all goes well they'll be confirmed and then logged in.
     // Split the token into its parts.
     $arg = '';
     if (strstr($token, '::')) {
         $arg = '::';
     }
     if (strstr($token, '-')) {
         $arg = '-';
     }
     list($user_id, $registrationtoken) = explode($arg, $token);
     if (!is_numeric($user_id) || $registrationtoken == '') {
         return false;
     }
     $q = $this->db->query("SELECT email, password, postcode\n\t\t\t\t\t\tFROM\tusers\n\t\t\t\t\t\tWHERE\tuser_id = '" . mysql_escape_string($user_id) . "'\n\t\t\t\t\t\tAND\t\tregistrationtoken = '" . mysql_escape_string($registrationtoken) . "'\n\t\t\t\t\t\t");
     if ($q->rows() == 1) {
         // We'll need these to be set before logging the user in.
         $this->user_id = $user_id;
         $this->email = $q->field(0, 'email');
         $this->password = $q->field(0, 'password');
         // Set that they're confirmed in the DB.
         $r = $this->db->query("UPDATE users\n\t\t\t\t\t\t\tSET\t\tconfirmed = '1'\n\t\t\t\t\t\t\tWHERE\tuser_id = '" . mysql_escape_string($user_id) . "'\n\t\t\t\t\t\t\t");
         if ($q->field(0, 'postcode')) {
             $MEMBER = new MEMBER(array('postcode' => $q->field(0, 'postcode')));
             $pid = $MEMBER->person_id();
             # This should probably be in the ALERT class
             $this->db->query('update alerts set confirmed=1 where email="' . mysql_escape_string($this->email) . '" and criteria="speaker:' . mysql_escape_string($pid) . '"');
         }
         if ($r->success()) {
             $this->confirmed = true;
             // Log the user in, redirecting them to the confirm page
             // where they should get a nice welcome message.
             $URL = new URL('userconfirmed');
             $URL->insert(array('welcome' => 't'));
             $redirecturl = $URL->generate();
             $this->login($redirecturl, 'session');
         } else {
             // Couldn't set them as confirmed in the DB.
             return false;
         }
     } else {
         // Couldn't find this user in the DB. Maybe the token was
         // wrong or incomplete?
         return false;
     }
 }
Exemplo n.º 22
0
include_once "../../includes/easyparliament/init.php";
include_once INCLUDESPATH . "easyparliament/member.php";
include_once INCLUDESPATH . "postcode.inc";
$pc = get_http_var('pc');
$pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
if (!$pc) {
    exit;
}
if (validate_postcode($pc)) {
    $constituency = strtolower(postcode_to_constituency($pc));
    if ($constituency == "CONNECTION_TIMED_OUT") {
        $errors['pc'] = "Sorry, we couldn't check your postcode right now. Please use the 'All Mps' link above to browse MPs";
    } elseif ($constituency == "") {
        $errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a known postcode";
        twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
    } else {
        $MEMBER = new MEMBER(array('constituency' => $constituency));
        if ($MEMBER->person_id()) {
            // This will cookie the postcode.
            $THEUSER->set_postcode_cookie($pc);
            $THEUSER->set_constituency_cookie($constituency);
        }
        if ($MEMBER->person_id()) {
            header('Location: http://' . DOMAIN . '/rss/mp/' . $MEMBER->person_id() . '.rdf');
        }
    }
} else {
    $errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a valid postcode";
    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
}
Exemplo n.º 23
0
function display_form($details = array(), $errors = array())
{
    global $this_page, $ALERT, $PAGE, $THEUSER;
    $ACTIONURL = new URL($this_page);
    $ACTIONURL->reset();
    ?>

<p>This page allows you to request an email alert from OpenAustralia.org.</p>

<?php 
    if (!get_http_var('only')) {
        ?>
<ul>
<li>To receive an alert <strong>every time a particular person appears</strong>,
select their name from the drop-down list and
leave the word/phrase box blank.</li>

<li>To receive an alert <strong>every time a particular keyword or phrase appears</strong>,
select "Any Representative or Senator" from the drop-down list, and enter your search term in
the box underneath.  The results are selected using the same rules as for a
normal search (see the box to the right for help on setting your criteria).</li>

<li>You can also <strong>combine</strong> both types of criteria to be alerted
<strong>only</strong> when a particular person uses the keywords you have defined.
To do this, select the person from the drop-down list <em>and</em> enter the keyword(s) as
above.</li>
</ul>

<p>Please note that you should only enter one topic per alert - if you wish to receive alerts on more than one topic, or for more than one person, simply fill in this form as many times as you need.</p>
<?php 
    }
    ?>

	<form method="post" action="<?php 
    echo $ACTIONURL->generate();
    ?>
">
	
	<?php 
    if (!$THEUSER->loggedin()) {
        if (isset($errors["email"]) && (get_http_var('submitted') || get_http_var('only'))) {
            $PAGE->error_message($errors["email"]);
        }
        ?>
				<div class="row">
				<span class="label"><label for="email">Your email address:</label></span>
				<span class="formw"><input type="text" name="email" id="email" value="<?php 
        if (isset($details["email"])) {
            echo htmlentities($details["email"]);
        }
        ?>
" maxlength="255" size="30" class="form"></span>
				</div>
	<?php 
    }
    if (!get_http_var('only') || !$details['keyword']) {
        if (isset($errors['pid'])) {
            $PAGE->error_message($errors['pid']);
        }
        ?>
				<div class="row">
				<span class="label"><label for="pid">Person you wish to receive alerts for:</label></span>
				<span class="formw"><?php 
        if (get_http_var('only') && $details['pid']) {
            $MEMBER = new MEMBER(array('person_id' => $details['pid']));
            print $MEMBER->full_name();
            print '<input type="hidden" name="pid" value="' . htmlspecialchars($details['pid']) . '">';
        } else {
            ?>
<select name="pid">
				<option value="Any">Any Representative or Senator</option>
				<?php 
            // Get a list of MPs/Lords for displaying in the form using the PEOPLE class
            $LIST = new PEOPLE();
            $args['order'] = 'last_name';
            if ($details['pid']) {
                $args['pid'] = $details['pid'];
            }
            $LIST->listoptions($args);
            ?>
				</select>
			<?php 
        }
        ?>
				</span>
				</div>
	<?php 
    }
    if (!get_http_var('only') || !$details['pid']) {
        if (isset($errors["keyword"])) {
            $PAGE->error_message($errors["keyword"]);
        }
        ?>
				<div class="row"> 
				<span class="label"><label for="keyword">Word or phrase you wish to receive alerts for:</label></span>
				<span class="formw"><input type="text" name="keyword" id="keyword" value="<?php 
        if ($details['keyword']) {
            echo htmlentities($details['keyword']);
        }
        ?>
" maxlength="255" size="30" class="form"></span>
				</div>
	<?php 
    }
    $submittext = "Request Email Alert";
    ?>
						
				<div class="row">
				<span class="label">&nbsp;</span>
				<span class="formw"><input type="submit" class="submit" value="<?php 
    echo $submittext;
    ?>
"><!-- this space makes the submit button appear on Mac IE 5! --> </span>
				</div>
	<?php 
    if (!$THEUSER->loggedin()) {
        ?>
				<div class="row">
				If you join or log in, you won't need to confirm your email address for every alert you set.
				</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')) . '">';
    }
    // MJ OA-437 Recommendations
    if (get_http_var('r')) {
        echo '<input type="hidden" name="r" value="' . htmlspecialchars(get_http_var('r')) . '">';
    }
    echo '<input type="hidden" name="submitted" value="true"> </form>';
}
Exemplo n.º 24
0
 public function criteria_pretty($html = false)
 {
     $criteria = explode(' ', $this->criteria);
     $words = array();
     $spokenby = '';
     foreach ($criteria as $c) {
         if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
             $MEMBER = new MEMBER(array('person_id' => $m[1]));
             $spokenby = $MEMBER->full_name();
         } else {
             $words[] = $c;
         }
     }
     $criteria = '';
     if (count($words)) {
         $criteria .= ($html ? '<li>' : '* ') . 'Mentions of [' . join(' ', $words) . ']' . ($html ? '</li>' : '') . "\n";
     }
     if ($spokenby) {
         $criteria .= ($html ? '<li>' : '* ') . "Things by {$spokenby}" . ($html ? '</li>' : '') . "\n";
     }
     return $criteria;
 }
Exemplo n.º 25
0
umask(02);
$HANSARDLIST = new HANSARDLIST();
$db = $HANSARDLIST->db;
// Get all the person ids we need feeds for...
$q = $db->query("SELECT person_id, group_concat(member_id order by member_id separator ',') as member_ids\n\t\t\tFROM member GROUP BY person_id HAVING max(left_house)='9999-12-31'");
if ($q->rows() <= 0) {
    exit;
}
$starttime = time();
for ($personrow = 0; $personrow < $q->rows(); $personrow++) {
    $person_id = $q->field($personrow, 'person_id');
    $member_ids = $q->field($personrow, 'member_ids');
    $args = array('member_ids' => $member_ids);
    $speeches = $HANSARDLIST->display('person', $args, 'none');
    // Some data about this person that we'll need for the feed.
    $MEMBER = new MEMBER(array('person_id' => $person_id));
    $MPURL = new URL('mp');
    $MPURL->insert(array('pid' => $person_id));
    $mpurl = $MPURL->generate();
    $date = gmdate('Y-m-d');
    $time = gmdate('H:i:s');
    $datenow = $date . 'T' . $time . '+00:00';
    // Prepare the meat of the RSS file.
    $items = '';
    $entries = '';
    if (isset($speeches['rows']) && count($speeches['rows']) > 0) {
        foreach ($speeches['rows'] as $n => $row) {
            // While we're linking to individual speeches,
            // the text is the body of the parent, ie (sub)section.
            $title = htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
            $link = isset($row['listurl']) ? $row['listurl'] : '';
     # Only do lookup of constituency via postcode if the constituency isn't set
     if ($cconstituency == "") {
         $constituency = postcode_to_constituency($pc);
     } else {
         $constituency = $cconstituency;
     }
     if ($constituency == "connection_timed_out") {
         $errors['pcerr'] = "Sorry, we couldn't check your postcode right now, as our postcode lookup server is under quite a lot of load. Please use the 'All MPs' link above to browse all the MPs.";
     } elseif ($constituency == "") {
         $errors['pcerr'] = "Sorry, " . htmlentities($pc) . " isn't a known postcode.";
         twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency");
     } elseif (is_array($constituency)) {
         # @@JR
         # Collect the member names and email addresses
         foreach ($constituency as $c) {
             $member = new MEMBER(array('constituency' => $c));
             $member_email = $member->email();
             $members[$member_email] = $member->full_name();
         }
     } else {
         $member = new MEMBER(array('constituency' => $constituency));
         $member_email = makeMemberEmail($member);
         $members[$member_email] = $member->full_name();
     }
 } else {
     $errors['pcerr'] = "Sorry, " . htmlentities($pc) . " isn't a valid postcode";
     twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
 }
 if (sizeof($errors) > 0) {
     echo $jsonp_callback . '(' . json_encode($errors) . ')';
 } else {
Exemplo n.º 27
0
 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;
 }
Exemplo n.º 28
0
 /**
  * @static
  * @todo document this
  */
 function deleteOneMember($memberid)
 {
     global $manager;
     $memberid = intval($memberid);
     $mem = MEMBER::createFromID($memberid);
     if (!$mem->canBeDeleted()) {
         return _ERROR_DELETEMEMBER;
     }
     $manager->notify('PreDeleteMember', array('member' => &$mem));
     /* unlink comments from memberid */
     if ($memberid) {
         $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="******" WHERE cmember=' . $memberid;
         sql_query($query);
     }
     $query = 'DELETE FROM ' . sql_table('member') . ' WHERE mnumber=' . $memberid;
     sql_query($query);
     $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tmember=' . $memberid;
     sql_query($query);
     $query = 'DELETE FROM ' . sql_table('activation') . ' WHERE vmember=' . $memberid;
     sql_query($query);
     // delete all associated plugin options
     NucleusPlugin::_deleteOptionValues('member', $memberid);
     $manager->notify('PostDeleteMember', array('member' => &$mem));
     return '';
 }
 function doSkinVar($skinType, $numberOfWritebacks = 5, $filter = '', $TBorCm = 'all', $numberOfCharacters = 60, $numberOfTitleCharacters = 40, $toadd = "...")
 {
     global $manager, $CONF, $blog;
     if (!is_numeric($numberOfWritebacks)) {
         $filter = $numberOfWritebacks;
         $numberOfWritebacks = 5;
         // defaults to 5
     }
     $b =& $manager->getBlog($CONF['DefaultBlog']);
     $this->defaultblogurl = $b->getURL();
     if (!$this->defaultblogurl) {
         $this->defaultblogurl = $CONF['IndexURL'];
     }
     if ($blog) {
         $b =& $blog;
     }
     $blogid = $b->getID();
     //for select
     $filter = trim($filter);
     if ($filter == 'current') {
         $filter = 'cblog = ' . $blogid;
     } elseif (strstr($filter, '=')) {
         $filter = str_replace('=', '', $filter);
         $filter = ' cblog IN(' . str_replace('/', ',', $filter) . ')';
     } elseif (strstr($filter, '<>')) {
         $filter = str_replace('<>', '', $filter);
         $filter = ' cblog <> ' . str_replace('/', ' AND cblog <> ', $filter);
     }
     setlocale(LC_TIME, $this->getOption('timelocale'));
     $arr_res = array();
     if ($TBorCm != 't') {
         $join = '';
         $query = 'SELECT' . ' c.cnumber as commentid,' . ' c.cuser   as commentator,' . ' c.cbody   as commentbody,' . ' c.citem   as itemid,' . ' c.cmember as memberid,' . ' SUBSTRING(c.ctime, 6, 5) as commentday,' . ' UNIX_TIMESTAMP(c.ctime)  as ctimest';
         if ($EzComment2 = $this->pluginCheck('EzComment2')) {
             if (method_exists($EzComment2, 'getTemplateParts')) {
                 $query .= ', s.comid   as cid, ' . 's.secflg  as secret, ' . 's.module  as modname, ' . 's.userID  as identity ';
                 $join = ' LEFT OUTER JOIN ' . sql_table('plug_ezcomment2') . ' as s ' . ' ON c.cnumber = s.comid ';
             }
         }
         // select
         $query .= ' FROM ' . sql_table('comment') . ' as c ' . $join;
         if ($filter) {
             $query .= ' WHERE ' . $filter;
         }
         $query .= ' ORDER by c.ctime DESC LIMIT 0, ' . $numberOfWritebacks;
         $comments = sql_query($query);
         if (sql_num_rows($comments)) {
             while ($row = sql_fetch_object($comments)) {
                 $content = (array) $row;
                 $tempBody = strip_tags($content['commentbody']);
                 $tempBody = htmlspecialchars($tempBody, ENT_QUOTES, _CHARSET);
                 $tempBody = shorten($tempBody, $numberOfCharacters, $toadd);
                 $tempBody = htmlspecialchars($tempBody, ENT_QUOTES, _CHARSET);
                 $tempBody = str_replace("\r\n", ' ', $tempBody);
                 $tempBody = str_replace("&amp;", '&', $tempBody);
                 $tempBody = str_replace("&gt;", '>', $tempBody);
                 $tempBody = str_replace("&lt;", '<', $tempBody);
                 $content['commentdate'] = strftime($this->getOption('cmdateformat'), $content['ctimest']);
                 $content['commentbody'] = str_replace("&amp;amp;", '&amp;', $tempBody);
                 if (!empty($row->memberid)) {
                     $mem = new MEMBER();
                     $mem->readFromID(intval($row->memberid));
                     $content['commentator'] = $mem->getRealName();
                 }
                 if ($EzComment2) {
                     $bid = intval(getBlogIDFromItemID(intval($comment['itemid'])));
                     if ($EzComment2->getBlogOption($bid, 'secret') == 'yes') {
                         $b = $manager->getBlog($bid);
                         global $member;
                         $judge = $EzComment2->setSecretJudge($bid, $member, $b);
                     }
                 }
                 if ($judge && $content['secret']) {
                     $content = $EzComment2->JudgementCommentSecrets($content, $judge);
                 }
                 /*					$cid  = $row->cnumber;
                 					$ct  = $row->ctimest;
                 					$ctst  = date("y-m-d H:i",$ct);
                 					$text = strip_tags($row->cbody);
                 					$text = htmlspecialchars($text, ENT_QUOTES,_CHARSET);
                 					$ctext = shorten($text,$numberOfCharacters,$toadd);
                  
                 					if (!$row->cmember) $myname = $row->cuser;
                 					else {
                 						$mem = new MEMBER;
                 						$mem->readFromID(intval($row->cmember));
                 						$myname = $mem->getRealName();
                 					}*/
                 //					$itemlink = $this->_createItemLink($row->citem, '');
                 //					$arr_res[$ct] =  "<li>&clubs;<a href=\"".$itemlink."#c".$cid."\">$ctst|".$myname."&gt;".$ctext."</a></li>" ;
                 $itemlink = $this->_createItemLink($content['itemid']);
                 $content['itemlink'] = $itemlink;
                 $arr_res[$content['ctimest']] = TEMPLATE::fill($this->getOption('cmttemplate'), $content);
             }
         }
     }
     //=========================
     if ($manager->pluginInstalled('NP_TrackBack') && $TBorCm != 'c') {
         $query = 'SELECT' . ' t.id        as tbid,' . ' t.title     as entrytitle,' . ' t.excerpt   as expect,' . ' t.url       as tburl,' . ' t.tb_id     as trackbackid,' . ' t.blog_name as blogname,' . ' t.timestamp as tbdate,' . ' SUBSTRING(t.timestamp, 6, 5) as tbday,' . ' UNIX_TIMESTAMP(t.timestamp)  as ttimest' . ' FROM ' . sql_table('plugin_tb') . ' t,' . sql_table('item') . ' i' . ' WHERE t.tb_id = i.inumber';
         if ($this->checkTBVersion()) {
             $query .= ' and t.block = 0';
         }
         if ($filter) {
             $tfilter = str_replace('c.cblog', 'i.iblog', $filter);
             $query .= ' and ' . $tfilter;
         }
         $query .= ' ORDER by t.timestamp DESC LIMIT 0, ' . $numberOfWritebacks;
         $comments = sql_query($query);
         if (sql_num_rows($comments)) {
             while ($row = sql_fetch_object($comments)) {
                 $content = (array) $row;
                 $entrytitle = strip_tags($content['entrytitle']);
                 $entrytitle = htmlspecialchars($entrytitle, ENT_QUOTES, _CHARSET);
                 $entrytitle = shorten($entrytitle, $numberOfCharacters, $toadd);
                 $entrytitle = htmlspecialchars($entrytitle, ENT_QUOTES, _CHARSET);
                 $content['entrytitle'] = $entrytitle;
                 $content['expect'] = str_replace("\r\n", ' ', $content['expect']);
                 $blogname = htmlspecialchars($content['blogname'], ENT_QUOTES, _CHARSET);
                 $content['blogname'] = $blogname;
                 $content['tbdate'] = strftime($this->getOption('tbdateformat'), $content['ttimest']);
                 /*					$title = strip_tags($row->title);
                 					$title = htmlspecialchars($title, ENT_QUOTES,_CHARSET);
                 					$ctitle = shorten($title,$numberOfCharacters,$toadd);
                 					$blogname = htmlspecialchars($row->blog_name, ENT_QUOTES,_CHARSET);
                 					$tbtime = $row->ttimest;
                 					$ttst  = date("y-m-d H:i",$tbtime);*/
                 //					$itemlink = $this->_createItemLink($row->tb_id, '');
                 //					$arr_res[$tbtime] = '<li>&hellip;<a href="'.$itemlink.'#trackback">'.$ttst.'|'.$blogname.' ping: "'.$ctitle.'"</a></li>';
                 $itemlink = $this->_createItemLink($content['trackbackid']);
                 $content['itemlink'] = $itemlink;
                 $arr_res[$content['ttimest']] = TEMPLATE::fill($this->getOption('tbktemplate'), $content);
             }
         }
     }
     //=========================
     krsort($arr_res);
     $ress = array_values($arr_res);
     $show_rescnt = min(intval($numberOfWritebacks), count($arr_res));
     switch ($TBorCm) {
         case 'c':
             $head = $this->getOption('cmlisthead');
             $foot = $this->getOption('cmlistfoot');
             break;
         case 't':
             $head = $this->getOption('tblisthead');
             $foot = $this->getOption('tblistfoot');
             break;
         default:
             $head = ' <ul class="nobullets"> ';
             $foot = ' </ul> ';
             break;
     }
     //		echo ' <ul class="nobullets"> ';
     echo $head;
     for ($j = 0; $j < $show_rescnt; $j++) {
         echo $ress[$j] . "\n";
     }
     echo $foot;
     //		echo " </ul> ";
 }
Exemplo n.º 30
0
umask(02);
$HANSARDLIST = new HANSARDLIST();
$db = $HANSARDLIST->db;
// Get all the person ids we need feeds for...
$q = $db->query("SELECT person_id, group_concat(member_id order by member_id separator ',') as member_ids\n\t\t\tFROM member GROUP BY person_id HAVING max(left_house)='9999-12-31'");
if ($q->rows() <= 0) {
    exit;
}
$starttime = time();
for ($personrow = 0; $personrow < $q->rows(); $personrow++) {
    $person_id = $q->field($personrow, 'person_id');
    $member_ids = $q->field($personrow, 'member_ids');
    $args = array('member_ids' => $member_ids);
    $speeches = $HANSARDLIST->display('person', $args, 'none');
    // Some data about this person that we'll need for the feed.
    $MEMBER = new MEMBER(array('person_id' => $person_id));
    $MPURL = new URL('mp');
    $MPURL->insert(array('pid' => $person_id));
    $mpurl = $MPURL->generate();
    $date = gmdate('Y-m-d');
    $time = gmdate('H:i:s');
    $datenow = $date . 'T' . $time . '+00:00';
    // Prepare the meat of the RSS file.
    $items = '';
    $entries = '';
    if (isset($speeches['rows']) && count($speeches['rows']) > 0) {
        foreach ($speeches['rows'] as $n => $row) {
            // While we're linking to individual speeches,
            // the text is the body of the parent, ie (sub)section.
            $title = htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
            $link = isset($row['listurl']) ? $row['listurl'] : '';