Index of /lamp_chmearl
ChmEarl Ebook Repository
This is a small LAMP+KDE project to make a client/server repository for CHM
files. In your workgroup, a single machine acting as a CHM web server can allow an unlimited number of client
machines to view a (arbitrarily large) library of CHM files with a web browser. All the CHM files are stored and managed on a
single machine. The clients are freed to view the ebooks without the trouble of managing them.
Win32 clients must use Internet Explorer and Linux clients must use Konqueror -- this
restriction is tied to the io-slave support provided by these two Applications.
The CHM compressed file format is quite well thought out. It's not widely known that every individual component
HTML page can be separately addressed in a browser. When each chapter's URL and title are stored in a MySQL DB,
we can quickly search for our desired chapter, then instantly bring up that page in our web browser, in Linux or Win32.
Furthermore, many CHM compilation tools add a binary index into the resulting CHM file. Now we have the feature called
full-text search. We are currently using package python-chm for this.
Target EnvironmentThe included gzip file is setup for Fedora Core 4 Linux. IOW your single CHM server should run in
FC4, while the clients can be almost anything, whether Win32 or Linux.
You will need Apache2, MySQL, phpMyAdmin, and Mod_Perl installed. I find that Mod_Perl is upto
5 times faster than forked CGI.
It is recommended to store the CHM files in a vfat partition. The default mount point is
/windows/d (vfat). Then the root path to the library will be /windows/d/ebooks. This
project assumes you are running SAMBA on the FC4 host. Hence you need to make public/writable/browsable
the ebooks folder.
#cat ./conf/smbadd.conf >> /etc/samba/smb.conf
or open the Samba system configuration dialog.
My partition is 55 GB. My 550 CHM files require around 5 GB. The rest of the space I plan to use
for other multimedia files used cross-platform.
RequirementsYou will need some FC4 RPM packages and a single Perl module
FC4 RPMs: python-chm chmlib chmlib-devel kchmviewer
Support for the ms-its io-slave comes in package kdevelop, via kchmpart. As you can see this
project is for the KDE (kdm) desktop -- the Gnome (gdm) desktop is not supported. AFAIK, there are no
io-slaves for CHM in Gnome/Nautilus. If you don't want to install kdevelop, then your clients will have
no ms-its until they install kchmviewer (yum install kchmviewer --enablerepo=dries). With kdevelop you
can readily compile kchm, which provides chmnewpart support into konqueror. The kchm io-slave is [chm:].
CPAN module: Text::CHM
/* this should be packaged as RPM now (>2008)- do #yum install perl-Text-CHM */
#perl -MCPAN -e 'install Text::CHM'
Integration with phpmyadminThis project adds a new table to the phpmyadmin database.
The table is called pma_access. It is used for password storage. You can setup it up for your users by running
the script ./script/AutoGenSQL/AutoGenSQL.pl. There is an anonymous array for your user/pwd pairs.
For defaults, simply open the mysql cli by doing
#mysql -u root -p
be sure to use your pma password that you included in ./phpmyadmin/config.inc.php
Our necessary MySQL usersSee the script ./sql/grants.sql to add the 2 users to MySQL
needed for our project.
That script also adds privileges.
Project RootYou will want to extract the gzip file into /usr/share. Do
#tar xvzf /path_to/chmearl.tar.gz
Apache2 Configurationto tell Apache2 about us,
copy ./conf.d/* to /etc/httpd/conf.d/
copy ./images to /var/www/html/images
Once Apache2 is restarted
then you can launch the main window (later) as http://localhost/chmearl/SQL_Test.shtml
The two CONF files setup the registry handler for mp2, turn on SSI, make an alias for our
html folder, and add an mp2 startup script.
Your System ConfigurationThis folder ./conf contains your system configuration files.
The insertion scripts mentioned below need this data to be right for your system. Go there
now and make changes. Especially change all instances of LMP-7053DF1FAFC to the name of your box.
Doing Insertions and loading the dataStart by adding the folder:
There are three PL scripts that grab our data from the CHM files.
1)earl_populate.pl -- will define the DB tables and get the basic data.
2)CoversPublisher.pl -- will add the css style paths and cover images to the DB.
3)ImgRip_Earl.pl -- will finally extract all the cover images and put them in your web image folder defined earlier.
Run these three in the order shown as root from the CLI. You should redirect output
#perl earl_populate.pl > myout.out (to speed things up)
Logging from myadmin.cgiYou can create a debug log, but it must be
#chown apache:apache myadmin.my
the variable is chmlog in ./conf/earl.conf
CHM File ViewersYou need to use a viewer that provides an io-slave available to your
browser. At this time there are only limited choices of viewer/browser pairs. I use kchmviewer/konqueror in
Linux and InternetExplorer/ms-its in Win32. Its easy to also use kchm in FC4. The project compiles with no
trouble if you setup your machine for kde-develop.
Linux clients will need to mount an ebooks folder for best results -- something Windows does for you.
The server script will detect a Linux client and use the mount point: /mnt/ebooks.
I get best results with NFS in this situation -- tests with SAMBA (Linux-Linux) showed poor/slow response. SAMBA
works best for Windows-Linux. To mount I use this
#mount -t nfs 192.168.1.100:/windows/d/ebooks /mnt/ebooks
To share a folder on the server via NFS, use the python applet:
then add the folder /windows/d/ebooks (whatever you choose).
KDE-Konqueror untrusts http-->ms-its redirectsAppend the following file (indexed above) to kdeglobals to restore trust for this operation.
>cat url_restrict >> .kde/share/config/kdeglobals
Without this reconfig, you will see a warning from konqie when redirecting to an ms-its file from an http-web page.
Windows blocks viewing CHM files over LANIf you are running WinXP sp2+ (or Vista|Win7) with all updates as of Feb 2006 (or Win2k3), you
will need to add this registry fix to view CHM files remotely over the LAN:
Merge chmreg.reg into registry to fix the security restriction. At the same time
remember that any CHM file that you want to be part of the library should be pre-checked for virus. I use a
perl script to do this. Any embedded BAT,COM, or EXE means trouble.
Project HistoryI started development in January 2004 in Win2k. By June 2005, I had a prototype for
SuSE 9.2. I have since installed it on 2 FC4 boxes setup as dev/web boxes. Amazingly it all began on Windows.
It runs much cleaner and faster on Linux thanks in part to the great reverse engineering needed to code chmlib!
UpdateAs of January 2006, Chmearl now can run as a server on SuSE x86_64. The author of chmlib has
a new release that supports 64 bit platforms. Before that work, several needed modules failed to compile for SuSE x86_64.
December 4, 2005