Example #1
0
function api_converturl_url($url) {
	$db = new ParlDB;
	$url_nohash = preg_replace('/#.*/', '', $url);
	$q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = "' . mysql_real_escape_string($url) . '" order by gid limit 1');
	if ($q->rows())
		return api_converturl_url_output($q);

	$q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like "' . mysql_real_escape_string($url_nohash) . '%" order by gid limit 1');
	if ($q->rows())
		return api_converturl_url_output($q);

	$url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
	if ($url_bound != $url_nohash) {
		$q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like "' . mysql_real_escape_string($url_bound) . '%" order by gid limit 1');
		if ($q->rows())
			return api_converturl_url_output($q);
	}
	api_error('Sorry, URL could not be converted');
}
Example #2
0
function api_converturl_url($url)
{
    $db = new ParlDB();
    $url_nohash = preg_replace('/#.*/', '', $url);
    $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = :url order by gid limit 1', array(':url' => $url));
    if ($q->rows()) {
        return api_converturl_url_output($q);
    }
    $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(':url' => $url_nohash . '%'));
    if ($q->rows()) {
        return api_converturl_url_output($q);
    }
    $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
    if ($url_bound != $url_nohash) {
        $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(':url' => $url_bound . '%'));
        if ($q->rows()) {
            return api_converturl_url_output($q);
        }
    }
    api_error('Sorry, URL could not be converted');
}