View Single Post
Old 04-14-2009, 08:35 PM   #5
Junior Member
DigitalFeonix began at the beginning.
DigitalFeonix's Avatar
Posts: 8
Karma: 10
Join Date: Dec 2008
Device: Sony PRS-505
Originally Posted by ilovejedd View Post
Need some (major) help...

I have a modified PHP script (based on FLAG) that dynamically creates a Stanza catalog for my favorite FanFiction.Net categories. It basically allows me to browse FanFiction.Net in real-time and creates epub-format ebooks on the fly using Calibre for reading in Stanza iPhone. The script currently runs on my Windows PC running XAMPP.

I have a shared Linux hosting account on 1and1 and I wish to upload the script there. My current dilemma is the epub creation part. I'm currently researching what methods I can use to create epub files using utilities/etc already installed or are user-installable on the shared account. The Linux host has Perl, Python and PHP installed and the operating system is CentOS, iirc.

Options I'm considering:
  1. Install Calibre on Linux Host
    • no changes to the PHP script required
    • no idea how to do this or if it's even feasible
  2. BookGlutton API
    • seems like this might be the easiest to implement
    • dependent on another website
    • don't know how I'm supposed to handle the post request
  3. DocBook+XSLT
    • seems like the dependencies should already be installed or are user-installable (no admin rights required)
    • don't know a thing about docbook
    • don't know a thing about xslt
  4. Code my own PHP script to create epubs
    • highly customizable
    • I might be able to finish this in 2 years if I'm lucky
Right now, I'm thinking using the BookGlutton API might be the best option for me (unless, of course, it's possible to install Calibre or at least html2epub on a shared host). I'm just not sure how I'm supposed to handle the post requests via PHP. Currently, I have an epub.php script that calls html2epub and returns the epub file. I guess I could modify this to send a post request to BookGlutton instead. I just don't know how, particularly the part where you upload the html file.

Anyway, not really looking for a discussion on the merits of the different methods. Just asking for help on the how. If you know of another way to do this (preferably something even an inexperienced coder can do), please post it here.

I created my own script similar to FLAG some time ago to create .oeb files for my EB-1150 from stories on and I have updated it to output .epub using a class to zip up the data. If you have customized FLAG, this is pretty easy to integrate as an output method.

Usage as follows:

PHP Code:
$tstamp time(); // timestamp for zip entries
$epub   = new ZipCreate();

$prev_encoding $epub->ztype;
$epub->ztype 'store';
$epub->ztype $prev_encoding;

// add container

// add opf

// add toc

// add your xhtml and CSS and pictures and fonts here

// finish it up and download
$output_file $epub->build_zip();
$output_name $story['title'] . '.epub';
$output_mime 'application/epub+zip';

header('Content-Type: application/x-download');
header('Content-Length: 'strlen($output_file));
header('Content-Disposition: attachment; filename="' $output_name '"');
header('Content-Transfer-Encoding: binary');

Attached Files
File Type: zip (4.6 KB, 690 views)
DigitalFeonix is offline   Reply With Quote