-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drag and drop only takes one object at a time
- Loading branch information
1 parent
84099de
commit 07d6a91
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
function recurse_copy($src,$dst) { | ||
$dir = opendir($src); | ||
@mkdir($dst); | ||
while(false !== ( $file = readdir($dir)) ) { | ||
if (( $file != '.' ) && ( $file != '..' )) { | ||
if ( is_dir($src . '/' . $file) ) { | ||
recurse_copy($src . '/' . $file,$dst . '/' . $file); | ||
} | ||
else { | ||
copy($src . '/' . $file,$dst . '/' . $file); | ||
} | ||
} | ||
} | ||
closedir($dir); | ||
} | ||
|
||
function create_uuid() | ||
{ | ||
#29eeddc3-4149-4249-b053-d7d3f046802a | ||
#758e65c5-30d7-4a11-9b09-8fbff26ad763 | ||
$index = 0; | ||
$hex[$index] = bin2hex(random_bytes(4)) ."-"; | ||
$index++; | ||
$hex[$index] = bin2hex(random_bytes(2)) ."-"; | ||
$index++; | ||
$hex[$index] = bin2hex(random_bytes(2)) ."-"; | ||
$index++; | ||
$hex[$index] = bin2hex(random_bytes(2)) ."-"; | ||
$index++; | ||
$hex[$index] = bin2hex(random_bytes(6)); | ||
|
||
$uuid = ""; | ||
for($i = 0;$i <= $index;$i++) | ||
{ | ||
$uuid .= $hex[$i]; | ||
} | ||
|
||
return $uuid; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
require_once("functions.php"); | ||
|
||
$book_title = "test"; | ||
$infiles_folder = scandir($book_title); | ||
|
||
$infiles = array(); | ||
foreach($infiles_folder as $infile) | ||
{ | ||
if($infile != "." && $infile != "..") | ||
{ | ||
$infiles[] = $infile; | ||
} | ||
} | ||
|
||
$basefiles_folder = "basefiles/"; | ||
$book_uuid = create_uuid(); | ||
|
||
|
||
$epub_name = $book_title; | ||
$extenension = ".epub"; | ||
|
||
|
||
//create all static stuff | ||
$epub_name .= $extenension; | ||
mkdir($epub_name); | ||
|
||
$basefiles[] = "cover.jpeg"; | ||
$basefiles[] = "mimetype"; | ||
$basefiles[] = "page_styles.css"; | ||
$basefiles[] = "stylesheet.css"; | ||
$basefiles[] = "titlepage.xhtml"; | ||
foreach($basefiles as $basefile) | ||
{ | ||
copy($basefiles_folder.$basefile, $epub_name."/".$basefile); | ||
} | ||
|
||
recurse_copy($basefiles_folder."META-INF", $epub_name."/META-INF"); | ||
|
||
//copy the images | ||
$page_number = 1; | ||
foreach($infiles as $infile) | ||
{ | ||
copy($book_title."/".$infile, $epub_name."/".$page_number.".jpg"); | ||
$page_number++; | ||
} | ||
$pages = $page_number; | ||
|
||
//dynamic files | ||
$book_uuid = create_uuid(); | ||
require_once($basefiles_folder."content.opf.php"); | ||
require_once($basefiles_folder."page_n.xhtml.php"); | ||
for($i = 1;$i <= $pages;$i++) | ||
{ | ||
write_page_xhtml($i); | ||
} | ||
|
||
require_once($basefiles_folder."toc.nx.php"); | ||
?> |