-
Notifications
You must be signed in to change notification settings - Fork 0
/
byb2.php
43 lines (32 loc) · 1.24 KB
/
byb2.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
<?php
/**
* file: byb2.php
* purpose: Create a BibTex file
*/
header("Content-type: text/html; charset=iso-8859-1"); // danish etc. charset ?>
<h1>Libri Modue: Create New BibTex File</h1>
<?php
/* Create the BibTex file */
$filename = "libri_".date('YmdHis').".bib";
$intro = "comment{This BibTex File Created by Per Thykjaer Jensen's Libri Module}\n\n";
$file = fopen($filename, "w") or die("Could not create the file!"); // open the file
fwrite($file,$intro);
print "<p>Download: <a href='".$filename."'>".$filename."</a></p>";
include_once "db.php"; // database connection ($mysqli)
$sql = "SELECT * FROM `libri` order by `Author`";
$result = $mysqli->query($sql);
while($row = $result->fetch_assoc()){
$books[] = "\n@". $row['Type'] ."{" . strtoupper( substr($row['Author'], 0,4)) . "_" . $row['Year']
. ",\n Author={" . $row['Author'] . "},\n"
. "Title={" . $row['Title'] . "},\n"
. "Publisher={" . $row['Where'] . "},\n"
. "Year=" . $row['Year'] . "}\n";
}
/* write all to the file */
foreach($books as $book){
fwrite($file,$book);
//file_put_contents($filename, $book, FILE_APPEND | LOCK_EX) or die("Shit Microsoft error " . rand(245452,474744777));
echo "$book <br>";
}
fclose($filename); // that's it
?>