$Itemid = intval(mosGetParam($_REQUEST, 'Itemid', 0)); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); if (file_exists("components/com_bible/language/" . $mosConfig_lang . ".php")) { include_once "components/com_bible/language/" . $mosConfig_lang . ".php"; } else { include_once "components/com_bible/language/brazilian_portuguese.php"; } switch (strtolower($task)) { case "viewbooks": showBooks($Itemid); break; case "viewbook": showBook($Itemid, $id, $limitstart); break; default: showBooks($Itemid); break; } function showBooks($Itemid) { global $database, $mainframe, $mosConfig_offset; $noauth = !$mainframe->getCfg('shownoauth'); $database->setQuery("SELECT ordering, bookName, location " . "\nFROM #__bible_book" . "\nORDER BY location desc, ordering, bookName "); $books = $database->loadObjectList(); HTML_bible::showBooksList($books, $Itemid); } function showBook($Itemid, $id, $limitstart) { global $database, $mainframe, $mosConfig_offset, $mosConfig_list_limit; $noauth = !$mainframe->getCfg('shownoauth'); if ($limitstart == null) {
} $author = $_GET['author']; if (mb_check_encoding($author, $default_encoding) && !mb_check_encoding($author, 'UTF-8')) { $author = mb_convert_encoding($author, 'UTF-8', $default_encoding); } if (!empty($author)) { $books = $db->searchBooksByAuthor($author); showBooks($opds, $books, $page, "Search results: " . $author); exit; } } else { $books = $db->searchBooksByTitle($terms); showBooks($opds, $books, $page, "Search results: " . $terms); exit; } } elseif ($count > 1) { $lvl_parent = $levels[$count - 2]; if ($lvl_parent === 'genres') { $books = $db->getBooksByGenre($lvl_last); showBooks($opds, $books, $page, "Genre: " . $lvl_last); } if ($lvl_parent === 'authors') { $books = $db->getBooksByAuthor($lvl_last); showBooks($opds, $books, $page, "Author: " . $lvl_last); } } } else { showRoot(); } } }
function getBooks() { $fp = fopen("books.txt","r"); rewind($fp); $searched = $_GET['type']; $_SESSION['search'] = $_GET['search']; if(isset($searched)) { if($_SESSION['search'] != '') { $searchType = $_GET['type']; $titles = array("title","author","category","year","pages","notes","ISBN","status","keywords"); for($counter=0;$counter<count($titles);$counter++) { if($searchType == $titles[$counter]) { $arrayNum = $counter; } } while(!feof($fp)) { $line = fgets($fp); $element = split("\|", $line); if(stristr($element[$arrayNum],$_SESSION['search']) == TRUE) { echoLine($element); if(strcmp($element[$arrayNum],$_SESSION['search']) == 0) { borrow_button(); } } } } } else { showBooks($fp); } }
function unsetCatId() { $option = 'com_booklibrary'; $mainframe = JFactory::getApplication(); $catid = $mainframe->getUserStateFromRequest("catid{$option}", 'catid', '-1'); unset($catid); showBooks($option); }
function getBooks() { $fp = fopen("books.txt","r"); rewind($fp); $searched = $_POST['searched']; $edit = $_POST['edit']; $submit = $_POST['submit']; $add = $_POST['add']; $addbook = $_POST['addbook']; $delete = $_POST['delete']; if(isset($delete)) { $cfp = fopen("bookcopy.txt","w"); while(!feof($fp)) { $line = fgets($fp); $element = split("\|", $line); if(strcasecmp($element[0], $_SESSION['search_book']) != 0) { fwrite($cfp,$line); } } fclose($fp); fclose($cfp); $bookFile = "books.txt"; $copyFile = "bookcopy.txt"; $fp = fopen($bookFile, "w+"); $cfp = fopen($copyFile, "r"); $file_contents = fread($cfp, filesize($copyFile)); fwrite($fp, $file_contents); rewind($fp); showBooks($fp); add_button(); fclose($fp); fclose($cfp); } else if(isset($add)) { addForm(); } else if(isset($addbook)) { $isMatch = false; $fp = fopen("books.txt","a"); fwrite($fp,"\n"); $title = trim($_POST['title']); $author = trim($_POST['author']); $category = trim($_POST['category']); $year = trim($_POST['year']); $pages = trim($_POST['pages']); $notes = trim($_POST['notes']); $cnumber = trim($_POST['cnumber']); $status = trim($_POST['status']); $keywords = trim($_POST['keywords']); $borrower = "|"; $due = "|"; $write_values = array("$title","$author","$category","$year","$pages","$notes","$cnumber","$status","$keywords", "$borrower","$due"); echoLine($write_values); //Need to echo this to so I can use the echoLine function before imploding. add_button(); echo "<tr><td></td><td><p>Display all books on <a href='books.php'>Item Management</a> page.</p></td>"; $write_values = implode("|",$write_values); fwrite($fp, $write_values); rewind($fp); fclose($fp); } else if(isset($submit)) { $cfp = fopen("bookcopy.txt","w"); while(!feof($fp)) { $line = fgets($fp); $element = split("\|", $line); if(strcasecmp($element[0], $_SESSION['search_book']) == 0) { $title = trim($_POST['title']); $author = trim($_POST['author']); $category = trim($_POST['category']); $year = trim($_POST['year']); $pages = trim($_POST['pages']); $notes = trim($_POST['notes']); $cnumber = trim($_POST['cnumber']); $status = trim($_POST['status']); $keywords = trim($_POST['keywords']); $borrower = trim($_POST['borrower']); $due = trim($_POST['due']) . " |"; $write_values = array("$title","$author","$category","$year","$pages","$notes","$cnumber","$status","$keywords","$borrower","$due"); echoLine($write_values); echo "<tr><td></td><td><p>Display all books on <a href='books.php'>Item Management</a> page.</p></td>"; $write_values = implode("|",$write_values); fwrite($cfp, $write_values); fwrite($cfp,"\n"); } else { fwrite($cfp,$line); } } fclose($fp); fclose($cfp); $bookFile = "books.txt"; $copyFile = "bookcopy.txt"; $fp = fopen($bookFile, "w+"); $cfp = fopen($copyFile, "r"); $file_contents = fread($cfp, filesize($copyFile)); fwrite($fp, $file_contents); rewind($fp); fclose($fp); fclose($cfp); } else if(isset($edit)) { $isMatch = false; while(!feof($fp) and $isMatch == false) { $line = fgets($fp); $element = split("\|", $line); if(strcasecmp(trim($element[0]), $_SESSION['search_book']) == 0) { $isMatch = true; editForm($element); } else { $isMatch = false; } } } else if(isset($searched)) { $_SESSION['search_book'] = $_POST['search_book']; $isMatch = false; while(!feof($fp) and $isMatch == false) { $line = fgets($fp); $element = split("\|", $line); if(strcasecmp($element[0], $_SESSION['search_book']) == 0) { $isMatch = true; echoLine($element); delEditButtons(); } else { $isMatch = false; } } } else { showBooks($fp); add_button(); } }