No Matter How Poor The Code Is, It Can Simplify My Activity

in #manga6 years ago (edited)

Simple Offline Comic Reader Apps With PHP (Linux)

In this article I share tips on reading offline comic via browser using PHP programming. For those who like to read manga, surely often read manga online using browser. The advantages of reading manga using the browser is the picture looks more clear, easily zoom it it or out with simple shortcut 'ctrl +' or 'ctrl -' and can be directly scrolled down to change the page.

Equipment:

  1. PHP
  2. Text editor
  3. Browser
  4. Terminal

Step by step:

  1. Open a terminal with the shortcut ctrl + alt + T.
  2. Create a comic directory with the command "mkdir comic".
  3. Go to comic directory with command "cd comic".
  4. Create a stock directory as a comic storage location, "mkdir stock".
  5. Create a text file index.php with command "gedit index.php".
  6. Add code below then save and then close the text editor.
<html>
<head>
    <title>Offline reader</title>
</head>
<?php
//getting data
$data = `ls stock`;
$data = explode("\n", $data);
?>
<body bgcolor="#ccf"><center>
    <h1>READING COMIC OFFLINE<hr></h1>
    <form action="index.php">
    <select name="judul" required>
    <?php
    //getting title
    foreach($data as $d){echo '<option value="'.$d.'">'.$d.'</option>';}
    ?>
    </select>
    <input type="submit" value="SUBMIT">
    <form>
    <br>
    <?php
    //processing title
    if(isset($_GET['judul']) && $_GET['judul'] != "){
        $judul = str_replace(" ","\ ",$_GET[‘judul’]);
        $path = "stock/$_GET[judul]";
        chop($path);
        echo "<h3>Baca $_GET[judul]</h3>";
        $images = `ls stock/$judul`;
        $images = explode("\n", $images);
        //showing image
        foreach($images as $image){
            if(@is_array(getimagesize("$path/$image"))){
                echo "<lMG src=\"$path/$image\">";
                echo "<h5>—</h5>";
            }
        }
    }else{ echo "<h3>Comic not chosen!</h3>"; }
?>
    </center></body>
</html>
  1. Run the php server with the command "php -S localhost: 8000".
  2. Place the comic file in the stock directory.
  3. Run the browser and enter url localhost: 8000
  4. Done.

Screenshoot:

Sort:  

On this part
echo "<lMG src="$path/$image">";
the correct one is img not lMG
but steemit show error if I use that tag on my post.

@sonvd, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!

Please also take a moment to read this post regarding bad behavior on Steemit.

Congratulations @sonvd! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

3 years on Steem - The distribution of commemorative badges has begun!
Happy Birthday! The Steem blockchain is running for 3 years.
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Get your post resteemed to 72,000 followers. Go here https://steemit.com/@a-a-a

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 64038.60
ETH 3148.89
USDT 1.00
SBD 3.97