-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.php
63 lines (55 loc) · 2.03 KB
/
index.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
<?php
ini_set('memory_limit','160M');
// Debug
require_once 'debug.php';
// Helper functions
require_once 'functions.php';
if ( isset( $_GET['translation'] ) && ! empty( $_GET['translation'] ) ) {
$translation = get_translation( strtolower( $_GET['translation'] ) );
}
else {
$translation = get_translation( 'kjv' );
}
// Create connection
$con = mysqli_connect( "localhost", "root", "root", "TEST_bible" );
// Check connection
if ( mysqli_connect_errno() ) {
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
$r = mysqli_query($con, "SELECT * FROM $bible_book ORDER BY number ASC");
$book = array();
while( $b = mysqli_fetch_array( $r, MYSQLI_ASSOC ) ) {
$b['filename'] = str_replace( " ", "-", strtolower( $b['fullname'] ) );
$b['anchor'] = str_replace( " ", "-", strtolower( $b['short'] ) );
$book[ $b['number'] ] = $b;
}
foreach ( $book as $key => $value ) {
$prev = $key - 1;
$next = $key + 1;
$book[ $key ]['prev_link'] = $book[ $key ]['filename'] . '-intro.html';
if ( isset( $book[ $prev ] ) ) {
$book[ $key ]['prev_chap'] = $book[ $prev ]['filename'] . '.html#' . $book[ $prev ]['anchor'] . '-ch' . $book[ $prev ]['chapters'];
$book[ $key ]['prev_book'] = $book[ $prev ]['filename'] . '-intro.html';
$book[ $key ]['prev_book_title'] = $book[ $prev ]['fullname'];
}
if ( isset( $book[ $next ] ) ) {
$book[ $key ]['next_link'] = $book[ $next ]['filename'] . '-intro.html';
$book[ $key ]['next_book'] = $book[ $next ]['filename'] . '-intro.html';
$book[ $key ]['next_book_title'] = $book[ $next ]['fullname'];
}
$book[ $key ]['next_chap'] = $book[ $key ]['filename'] . '.html#' . $book[ $key ]['anchor'] . '-ch1';
}
if ( isset( $_GET['import'] ) ) {
// require_once 'import.php';
}
else {
$header = get_html_header();
$footer = get_html_footer();
build_ncx2( $book );
build_spine_manifest( $book );
build_html_intro( $book, $header, $footer );
build_html_toc( $book, $header, $footer );
build_html_body( $book, $header, $footer, $con );
// build_html_appendix( $book, $header, $footer, $con );
}
mysqli_close($con);