124 lines
4.4 KiB
PHP
124 lines
4.4 KiB
PHP
<?php
|
|
require_once("config.inc.php");
|
|
header("Content-Type: text/html; charset=utf-8");
|
|
/*
|
|
create table bibel_chapter_2017
|
|
as
|
|
SELECT DISTINCT anz_buch, buch, kapitel, NULL as verarbeitet FROM `bibel_lut_1984`;
|
|
ALTER TABLE `bibel_lut_2017` ADD PRIMARY KEY(`bid`);
|
|
ALTER TABLE `bibel_lut_2017` CHANGE `bid` `bid` INT(11) NOT NULL AUTO_INCREMENT;
|
|
ALTER TABLE `bibel_chapter_2017` CHANGE `verarbeitet` `verarbeitet` VARCHAR(1) NULL DEFAULT NULL;
|
|
ALTER TABLE `bibel_lut_2017` CHANGE `anz_buch` `anz_buch` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, CHANGE `buch` `buch` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, CHANGE `vers` `vers` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, CHANGE `bibelstelle` `bibelstelle` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, CHANGE `inhalt` `inhalt` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
|
*/
|
|
|
|
$db = dbconnect();
|
|
$db->query("SET NAMES 'utf8'");
|
|
|
|
|
|
$query = "SELECT anz_buch, buch, kapitel
|
|
FROM `bibel_chapter_2017`
|
|
WHERE verarbeitet is NULL
|
|
limit 10000";
|
|
$result = $db->query( $query)
|
|
or die ("Cannot execute query: result");
|
|
|
|
while ($row = $result->fetch_array()){
|
|
$suche= "$row[anz_buch]$row[buch]$row[kapitel]";
|
|
$url= "http://anonymouse.org/cgi-bin/anon-www_de.cgi/http://www.bibleserver.com/text/LUT/$suche";
|
|
|
|
$handle = file_get_contents($url);
|
|
$handle = strstr($handle, '<div class="content">');
|
|
$handle = strstr($handle, '<div class="copyright">', true);
|
|
$handle = strip_tags($handle, '<h3>');
|
|
$handle = str_replace("</h3>","</h3>\n",$handle);
|
|
|
|
$data = explode("\n", $handle); // preg_split('#\n#', $data); Please don't
|
|
|
|
$row2[] = '';
|
|
for($i=0; $i < count($data)-1; $i++){
|
|
|
|
|
|
|
|
|
|
$zeile_rep = str_replace('<h3 class="caption">',"<h3>",$data[$i]);
|
|
$inhalt= explode(' ', $zeile_rep); // preg_split('#\s#', $row); Seriously
|
|
|
|
/* Ausgabe von $inhalt. Überschriften haben nur ein Array. Sonst Verse[0] und Inhalt[1]
|
|
[6] => Array
|
|
(
|
|
[0] => 7
|
|
[1] => Die Furcht des Herrn ist der Anfang der Erkenntnis. Die Toren verachten Weisheit und Zucht.
|
|
)
|
|
|
|
[7] => Array
|
|
(
|
|
[0] => <h3>Warnung vor Verführern</h3>
|
|
)
|
|
|
|
[8] => Array
|
|
(
|
|
[0] => 8
|
|
[1] => Mein Sohn, gehorche der Zucht deines Vaters und verlass nicht das Gebot deiner Mutter;
|
|
)
|
|
|
|
*/
|
|
|
|
$bibelstelle = "$row[anz_buch] $row[buch] $row[kapitel]";
|
|
|
|
if(isset($inhalt[1])){
|
|
$vers = $inhalt[0];
|
|
$inhalt_neu = trim(addslashes($inhalt[1]));
|
|
$bibelstelle .= ", $vers";
|
|
}else{
|
|
$vers = '';
|
|
$inhalt_neu = trim(addslashes($inhalt[0]));
|
|
}
|
|
|
|
$sql1 = $db->query("INSERT INTO bibel_lut_2017 ( anz_buch
|
|
, buch
|
|
, kapitel
|
|
, vers
|
|
, bibelstelle
|
|
, inhalt
|
|
)
|
|
VALUES
|
|
( '$row[anz_buch]'
|
|
, '$row[buch]'
|
|
, '$row[kapitel]'
|
|
, '$vers'
|
|
, '$bibelstelle'
|
|
, '$inhalt_neu'
|
|
)"
|
|
);
|
|
|
|
}
|
|
|
|
$sql2 = $db->query("UPDATE bibel_chapter_2017
|
|
SET verarbeitet='Y'
|
|
WHERE anz_buch='$row[anz_buch]'
|
|
AND buch = '$row[buch]'
|
|
AND kapitel = '$row[kapitel]'
|
|
");
|
|
# Zufälltige Anzahl Sekunden pausieren
|
|
$random = rand(5,20);
|
|
sleep($random);
|
|
|
|
echo "UPDATE bibel_chapter_2017
|
|
SET verarbeitet='Y'
|
|
WHERE anz_buch='$row[anz_buch]'
|
|
AND buch = '$row[buch]'
|
|
AND kapitel = '$row[kapitel]'\t ->\t $random
|
|
<br>";
|
|
|
|
|
|
# print_r($inhalt);
|
|
/*
|
|
echo"
|
|
<pre>
|
|
$handle
|
|
</pre>
|
|
";
|
|
*/
|
|
}
|
|
?>
|