curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $page = curl_exec($ch); if (strlen($page) < 10) { echo "Failed to fetch page.\n"; exit(1); } $fetched_page = explode('<div id="free-learning-banner"', $page); $tmp = explode('<div class="dotd-main-book cf">', $fetched_page[1]); #free book div $parsed_page = $tmp[1]; if (!$parsed_page) { echo "Error parsing page!\n"; exit(1); } if (preg_match($KEYWORDS, book_info())) { echo "Found interesting free e-book\n" . book_url() . "\n"; mail($toemail, "PacktPub Free E-Book Bot", $url . "\n" . book_url(), "From: PacktPub Free E-Book Bot <{$fromemail}>\r\n"); } else { echo "No interesting book found " . book_url() . "\n"; } function book_url() { global $parsed_page; $t = explode('<div class="dotd-main-book-image float-left">', $parsed_page); $url = explode('<noscript>', $t[1]); preg_match('/"(.*)"/', trim($url[0]), $m); return 'https://www.packtpub.com' . $m[1]; } function book_info() {
$errors[] = "<u>Stacking Error</u><br>Item is stackable but stack size is " . $vars['stacksize']; } if ($vars['book'] > 0 && $vars['filename'] == "") { $errors[] = "<u>Missing Text Error</u><br>Item is marked as a book/message but not assigned any text"; } if ($errors) { $body->set("errors", $errors); } break; case 3: // Book Text check_authorization(); $body = new Template("templates/items/items.book.tmpl.php"); $body->set('id', $_GET['id']); $body->set('name', $_GET['name']); $vars = book_info(); if ($vars) { foreach ($vars as $key => $value) { $body->set($key, $value); } } break; case 4: //Update Book Text check_authorization(); $id = $_POST['id']; update_book(); header("Location: index.php?editor=items&id={$id}&action=2"); exit; case 5: // Delete Item
$title = $dvd_info['dvd_title']; $img_url = $dvd_info['img_url_med']; $item_desc = $dvd_info['dvd_desc']; create_dvd($title, $img_url, $item_desc, $id_num); ?> <script> document.location="index3.php"; //redo this with php </script> <?php } else { dvd_info_neat($id_num); } } elseif ($id_type == 'id_num_isbn') { if (isset($_GET['add'])) { //die("test3"); $book_info = book_info($id_num); $title = $book_info['book_title']; $author = $book_info['book_author']; $item_desc = $book_info['book_desc']; $img_url = $book_info['book_img_url']; create_book($title, $img_url, $item_desc, $author, $id_num); ?> <script> document.location="index3.php"; </script> <?php } else { //print_r(book_info($id_num)); // die("test4"); book_info_neat($id_num); }
function DeltaImport($mysql_db, $date) { $mysql_db->query("CREATE TABLE myrulib_update(date integer primary key, aid integer, bid integer, sid integer, zid integer)"); $sqltest = "SELECT * FROM myrulib_update WHERE date=(SELECT MAX(date) FROM myrulib_update WHERE date<{$date})"; $query = $mysql_db->query($sqltest); if ($row = $query->fetch_array()) { $code = $row["date"]; $sqlite_db = new PDO("sqlite:./{$code}.upd"); create_tables($sqlite_db, $date); setup_params($sqlite_db, $date, "DELTA"); convert_authors($mysql_db, $sqlite_db, $row['aid']); convert_seqnames($mysql_db, $sqlite_db, $row['sid']); convert_books($mysql_db, $sqlite_db, $row['bid']); convert_sequences($mysql_db, $sqlite_db, $row['bid']); convert_genres($mysql_db, $sqlite_db, $row['bid']); convert_dates($mysql_db, $sqlite_db, $row['bid']); convert_zips($mysql_db, $sqlite_db, $row['zid']); convert_files($mysql_db, $sqlite_db, $row['zid'], $row['bid']); author_info($mysql_db, $sqlite_db, $row['aid']); book_info($mysql_db, $sqlite_db, $row['bid']); system("zip {$code}.zip {$code}.upd"); } $mysql_db->query("INSERT INTO myrulib_update(date) VALUES(" . $date . ")"); $mysql_db->query("\n\tUPDATE myrulib_update SET \n\t aid=(SELECT MAX(AvtorId) FROM libavtorname),\n\t bid=(SELECT MAX(BookId) FROM libbook),\n\t sid=(SELECT MAX(SeqId) FROM libseq),\n\t zid=(SELECT MAX(zid) FROM myrulib_zip)\n\tWHERE date={$date}"); }