-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonverse.php
109 lines (95 loc) · 4.45 KB
/
jsonverse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?
header('Content-Type: text/javascript; charset=UTF-8');
$docroot = $_SERVER['DOCUMENT_ROOT'];
require_once $docroot."/includes/config.php";
require_once $docroot."/includes/functionsjson.php";
$ref = (isset($_REQUEST['ref']))?$_REQUEST['ref']:'40,1,1,1,1';
$ar = explode(',', $ref);
$book = (int) ((isset($ar[0]))?$ar[0]:40);
if($book==0) $book=40;
$test= ($book<40)?0:1;
$chap = (int) ((isset($ar[1]))?$ar[1]:1);
if($chap==0) $chap=1;
$vers = (int) ((isset($ar[2]))?$ar[2]:-1);
$chp2 = (int) ((isset($ar[3]))?$ar[3]:-1);
$vrs2 = (int) ((isset($ar[4]))?$ar[4]:-1);
//$book= $ar[0];
//$chap= $ar[1];
//$vers= $ar[2];
//$chp2= $ar[3];
//$vrs2= $ar[4];
$dbg = 'b='.$book.': c='.$chap.': v='.$vers.': c2='.$chp2.': v2='.$vrs2;
if($chp2 < $chap) $chp2 = $chap;
if($vers < 1 && $vrs2 < 1){ $vers = 1; $vrs2 = 199;}
if($vers < 1) $vers = 1;
if($vrs2 < 1) $vrs2 = $vers;
$oldc= $chap;
$vcnt = 0;
$dbg.= '<br />b='.$book.': c='.$chap.': v='.$vers.': c2='.$chp2.': v2='.$vrs2;
$cbk = (isset($_REQUEST['callback']))?$_REQUEST['callback']:'callback100000';
$sql = 'select chapter, verse, versetext from verse
where testament = '.$test.'
and book = '.$book.' ';
if($chap!=$chp2){
$sql.= 'and ((chapter >= '.$chap.' and (case when chapter = '.$chap.' then verse >= '.$vers.' else verse > 0 end))
and (chapter <= '.$chp2.' and (case when chapter = '.$chp2.' then verse <= '.$vrs2.' else verse < 199 end))) ';
}else{
$sql.= 'and chapter = '.$chap.'
and verse between '.$vers.' and '.$vrs2.' ';
}
$sql.='order by chapter, verse ';
$vrss = dbquery($sql);
$out=$cbk.'({"content":"';
while(($row = mysqli_fetch_array($vrss)) && $vcnt < 999){
if($row[0] != $oldc){
$out.='<span style=\"display:block;margin-top:7px;\"></span><strong>'.(($book==19)?'Psalm':'Chapter').' '.$row[0].'</strong><br />';
$oldc = $row[0];
}
$vtxt = $row[2];
$vtxt = str_replace('"', '\\"',$vtxt); // escape double quotes for json
$vtxt = str_replace('[fn]', '', $vtxt); // remove footnote indicators
$vtxt = str_replace('[mvh]',' ', $vtxt); // remove mid-verse header indicators
$vtxt = str_replace('[mvs]',' ', $vtxt); // remove mid-verse superscript indicators
$vtxt = str_replace('[pg]', ' ', $vtxt); // remove paragraph indicators
$vtxt = str_replace('[bq]', ' ', $vtxt); // remove blockquote indicators
$vtxt = str_replace('[/bq]',' ', $vtxt); // remove end blockquote indicators
if(left($vtxt, 4) == '[br]') // remove beginning [br] indicators
$vtxt = substr($vtxt, 4);
$vtxt = str_replace('[br]', ' ', $vtxt); // remove remaining <br /> indicators
$vtxt = str_replace('[hpbegin]',' ', $vtxt); // remove hebrew poetry indicators
$vtxt = str_replace('[hpend]',' ', $vtxt); // remove hebrew poetry indicators
$vtxt = str_replace('[hp]',' ', $vtxt); // remove hebrew poetry indicators
$vtxt = str_replace('[listbegin]',' ', $vtxt); // remove list indicators
$vtxt = str_replace('[listend]',' ', $vtxt); // remove list indicators
$vtxt = str_replace('[lb]',' ', $vtxt); // remove list indicators
$needclosingtag = ((strpos($vtxt, '[[') !== false && strpos($vtxt, ']]') === false)?1:0);
$vtxt = str_replace('[[', '<span class=\"rNotInText\">[[', $vtxt);
$vtxt = str_replace(']]',']]</span>', $vtxt);
if($needclosingtag) $vtxt.='</span>';
// no longer doing this, requires prefs..
// not that big of a dead
if(1==2 && $test==1 && $ucaseot==1 && strpos($vtxt, '<strong>')!==false){
$vtxt = str_replace('“', '[ldq]', $vtxt);
$vtxt = str_replace('”', '[rdq]', $vtxt);
$vtxt = str_replace('‘', '[lsq]', $vtxt);
$vtxt = str_replace('’', '[rsq]', $vtxt);
$vtxt = str_replace('—', '[mdh]', $vtxt);
$vtxt = preg_replace_callback('#(.*?)<strong>(.*?)</strong>(.*?)#', function($m){return $m[1].'<strong>'.strtoupper($m[2]).'</strong>'.$m[3];}, $vtxt);
$vtxt = str_ireplace('[ldq]', '“', $vtxt);
$vtxt = str_ireplace('[rdq]', '”', $vtxt);
$vtxt = str_ireplace('[lsq]', '‘', $vtxt);
$vtxt = str_ireplace('[rsq]', '’', $vtxt);
$vtxt = str_ireplace('[mdh]', '—', $vtxt);
}
if(left($vtxt,1)=='~'){
$vtxt = str_replace('~','<span class=\"rNotInText\">', $vtxt);
$vtxt = str_replace('<em>','<em class=\"rNotInText\">', $vtxt);
$vtxt.= '</span>';
}
$out.='<span style=\"display:block;margin-top:7px;\"></span><sup class=\"versenum\">'.$row[1].'</sup>'.$vtxt.'<br/>';
$vcnt++;
}
$out.='"});';
print($out);
mysqli_close($db);
?>