Initial commit
This commit is contained in:
108
fetch_bibel/#fetch_bib.php
Normal file
108
fetch_bibel/#fetch_bib.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
function htmlclean($html) {
|
||||
$html= str_replace('</blockquote>','',$html);
|
||||
$html= str_replace('<blockquote>','',$html);
|
||||
$html= preg_replace('/\\r\\n/', '', $html);
|
||||
$html= preg_replace_callback('/(\\n)\\n/', function ($m) {
|
||||
return "$m[1]";
|
||||
}, $html);
|
||||
$html= preg_replace('/\s{3,}/sm','',$html,PREG_SET_ORDER); //Mehr als zwei leerzeichen entfernen
|
||||
$html= preg_replace('/\s{2,}/sm',' ',$html,PREG_SET_ORDER); //Mehr als zwei leerzeichen entfernen
|
||||
# $html= trim($html);
|
||||
return $html;
|
||||
}
|
||||
|
||||
$url=fopen("1mo1_bibeltext.htm", "r");
|
||||
#$url=fopen("ps119_bibeltext.htm", "r");
|
||||
#$url=fopen("ps1_bibeltext.htm", "r");
|
||||
|
||||
if ($url == NULL) {
|
||||
return "Fehler (1)";
|
||||
exit;
|
||||
}
|
||||
while(!feof($url)) {
|
||||
$buffer .= fgets($url, 4096);
|
||||
}
|
||||
# Headline H0
|
||||
$pos_ab = "";
|
||||
$pos_bis = "";
|
||||
$buffer2 = "";
|
||||
$pos_ab =strpos($buffer, '<li class="name">');
|
||||
if($pos_ab != ''){
|
||||
$buffer2 = substr($buffer,$pos_ab);
|
||||
$pos_bis =strpos($buffer2, '</li>');
|
||||
$name = substr($buffer2,0,$pos_bis);
|
||||
$name ="<h1>".str_replace('<li class="name">', '',$name)."</h1>";
|
||||
}else{
|
||||
$name = "";
|
||||
}
|
||||
|
||||
|
||||
# H2
|
||||
$pos_ab = "";
|
||||
$pos_bis = "";
|
||||
$buffer2 = "";
|
||||
$pos_ab = preg_match('/<h1 id="h[0-9]">/', $buffer, $matches, PREG_OFFSET_CAPTURE) ? $matches[0][1] : '';
|
||||
if($pos_ab != ''){
|
||||
$buffer2 = substr($buffer,$pos_ab);
|
||||
$pos_bis =strpos($buffer2, '</h1>');
|
||||
$h2 = substr($buffer2,0,$pos_bis);
|
||||
$h2 = "<h2>".preg_replace('/<h1 id="h[0-9]">/', '',$h2)."</h2>";
|
||||
}else{
|
||||
$h2 = "";
|
||||
}
|
||||
|
||||
|
||||
# H3
|
||||
$pos_ab = "";
|
||||
$pos_bis = "";
|
||||
$buffer2 = "";
|
||||
$pos_ab = preg_match('/<h2 id="h[0-9]">/', $buffer, $matches, PREG_OFFSET_CAPTURE) ? $matches[0][1] : '';
|
||||
if($pos_ab != ''){
|
||||
$buffer2 = substr($buffer,$pos_ab);
|
||||
$pos_bis =strpos($buffer2, '</h2>');
|
||||
$h3 = substr($buffer2,0,$pos_bis);
|
||||
$h3 = "<h3>".preg_replace('/<h2 id="h[0-9]">/', '',$h3)."</h3>";
|
||||
}else{
|
||||
$h3 = "";
|
||||
}
|
||||
|
||||
# Schleife <20>ber Verse
|
||||
#<span class="verse" data-location="24:1:1:1">1</span>
|
||||
$pos_ab = "";
|
||||
$pos_bis = "";
|
||||
$buffer2 = "";
|
||||
# Bis zu 3 Kapitelstellen Psalm 150
|
||||
$pos_ab = preg_match('/<p><span class="chapter">[0-9][0-9]?[0-9]?<\/span>/', $buffer, $matches, PREG_OFFSET_CAPTURE) ? $matches[0][1] : '';
|
||||
if($pos_ab != ''){
|
||||
$buffer2 = substr($buffer,$pos_ab);
|
||||
$pos_bis =strpos($buffer2, '<nav class="bible-navigation bible-navigation--simple">');
|
||||
$verse_ges = substr($buffer2,0,$pos_bis);
|
||||
|
||||
$verse_ges = preg_replace('/<span class="chapter">[0-9][0-9]?[0-9]?<\/span>/', '',$verse_ges);
|
||||
|
||||
|
||||
|
||||
$verse_ges = preg_replace_callback('/<p><span class="verse" data-location=".*">([0-9]*)<\/span> (.*\n*.*\n*.*\n*.*\n*)<\/p>/',
|
||||
function ($m) {
|
||||
return "||$m[1]|" . "<p>$m[2]</p>";
|
||||
},
|
||||
$verse_ges);
|
||||
|
||||
$verse_ges = htmlclean($verse_ges);
|
||||
$verse_ges = preg_split('/\|\|/', $verse_ges);
|
||||
|
||||
|
||||
}else{
|
||||
$verse_ges = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "<pre>\n";
|
||||
echo print_r($verse_ges);
|
||||
echo "</pre>";
|
||||
?>
|
Reference in New Issue
Block a user