:(";
exit();
}
if (substr( $article_url, 0, 4 ) != "http") {
echo("That's not a web page :(");
die();
}
$host = parse_url($article_url, PHP_URL_HOST);
use fivefilters\Readability\Readability;
use fivefilters\Readability\Configuration;
use fivefilters\Readability\ParseException;
$configuration = new Configuration();
$configuration
->setArticleByLine(false)
->setFixRelativeURLs(true)
->setOriginalURL('http://' . $host);
$readability = new Readability($configuration);
if(!$article_html = file_get_contents($article_url)) {
$error_text .= "Failed to get the article :(
getImages() as $image_url):
//we can only do png and jpg
if (strpos($image_url, ".jpg") || strpos($image_url, ".jpeg") || strpos($image_url, ".png") === true) {
$img_num++;
$imgline_html .= " [$img_num] ";
}
endforeach;
if($img_num>0) {
echo $imgline_html ;
}
?>
";
}
try {
$readability->parse($article_html);
$readable_article = strip_tags($readability->getContent(), '');
$readable_article = str_replace( 'strong>', 'b>', $readable_article ); //change to
$readable_article = str_replace( 'em>', 'i>', $readable_article ); //change to
$readable_article = clean_str($readable_article);
$readable_article = str_replace( 'href="http', 'href="/read.php?a=http', $readable_article ); //route links through proxy
} catch (ParseException $e) {
$error_text .= 'Sorry! ' . $e->getMessage() . '
';
}
//replace chars that old machines probably can't handle
function clean_str($str) {
$str = str_replace( "‘", "'", $str );
$str = str_replace( "’", "'", $str );
$str = str_replace( "“", '"', $str );
$str = str_replace( "”", '"', $str );
$str = str_replace( "–", '-', $str );
return $str;
}
?>
getTitle());?>