Skip to content
Browse files

First import

  • Loading branch information...
0 parents commit 9ed233ad8a9b8371f18740bef65066578cac9941 @rsayers committed Jan 22, 2009
Showing with 113 additions and 0 deletions.
  1. +14 −0 README
  2. +99 −0 index.php
14 README
@@ -0,0 +1,14 @@
+Scrinium - An ebook reader for net-connected phones
+-----------------------
+
+* About
+
+I hacked this together several years ago when I wanted to read a book on my phone. I had unlimited data, a web browser but no decent app for reading books. (Sidekick II if you are curious)
+
+Now I'm using a Blackberry Pearl and find that existing ebook readers for the platform are lacking, so I'm dusting this off and using it again. This app works simply by reading a directory of text files and allowing you to read them in an easy to view format. This program will let you view a file one page at a time and bookmark your location.
+
+* Usage
+
+The program by default reads the current directory for anything with a .txt extension. Changing this is easy, just follow the comments in the code. Create a subdirectory in your web space, upload the index.php and text files you wish to read. Once that is done, simply go to that url and start reading.
+
+No security is provided by default, placing the script in a directory not linked from anywhere should do the trick, .htaccess voodoo will work if you are more paranoid.
99 index.php
@@ -0,0 +1,99 @@
+<?
+
+$p=$_GET['p'];
+$b=$_GET['b'];
+$bookmark=$_GET['bookmark'];
+
+if (isset($bookmark)){
+ setcookie(str_replace('.','',$b),$p,time()+30*24*3600);
+}
+$dir='.'; // What dir to check for text files
+$lpp=30; // Lines per page
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<?
+
+
+if (!$p){
+ $p=1;
+ }
+ if ($b){
+ ?><title><?=$b;?> - Page: <?=$p;?></title><?
+ }else{
+ ?><title>Book List</title><?
+ }
+?>
+</head>
+<body>
+<?
+$d=dir($dir);
+$lpp=30;
+
+if ($b){
+
+ $lines=file($dir.'/'.$b);
+
+ $e=$p*$lpp;
+ $s=$e-$lpp;
+
+ ?>
+
+
+ <form method="get" action="index.php">
+ <div class='nav'>
+ <a href="index.php?b=<?=$b;?>&amp;p=<?=$p-1;?>">&lt;</a>
+ <input name="p" size="2" value="<?=$p;?>" />
+ <input type='hidden' name='b' value="<?=$b;?>" />
+ <input type='submit' value='Go' />
+ <a href="index.php?b=<?=$b;?>&amp;p=<?=$p+1;?>">&gt;</a><br/>
+ </div>
+ </form>
+
+
+ <div class='textbody'>
+ <?
+ for ($i=$s;$i<$e;$i++){
+ echo $lines[$i].'<br />';
+ }
+ ?>
+ </div>
+
+
+ <form method="get" action="index.php">
+ <div class='nav'>
+ <a href="index.php?b=<?=$b;?>&amp;p=<?=$p-1;?>">&lt;</a>
+ <input name="p" size="2" value="<?=$p;?>" />
+ <input type='hidden' name='b' value="<?=$b;?>" />
+ <input type='submit' value='Go' />
+ <a href="index.php?b=<?=$b;?>&amp;p=<?=$p+1;?>">&gt;</a><br/>
+ </div>
+ </form>
+ <div>
+ <a href='index.php?bookmark&amp;b=<?=$b;?>&amp;p=<?=$p;?>'>Set Bookmark</a><br />
+ <a href='index.php'>Book List</a>
+ </div>
+
+ <?
+}else{
+echo "<div class='toc'>";
+while (false !== ($entry = $d->read())) {
+ if ( eregi('txt',$entry)){
+ echo "<a href=\"index.php?b=$entry\">$entry</a>";
+ if ($_COOKIE[str_replace('.','',$entry)]){
+ echo "[<a href=\"index.php?b=$entry&amp;p=".$_COOKIE[str_replace('.','',$entry)]."\">Go to bookmark</a>]";
+ }
+
+ echo "<br />";
+ }
+}
+$d->close();
+echo "</div>";
+
+}
+?>
+</body>
+</html>

0 comments on commit 9ed233a

Please sign in to comment.
Something went wrong with that request. Please try again.