preparing for uploading chapters

This commit is contained in:
saintly2k 2021-11-05 22:23:15 +01:00 committed by GitHub
parent b4baa0738d
commit eb1f2e69df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,57 @@
<?php
if(isset($_POST["btn_zip"]))
{
$output = '';
if($_FILES['zip_file']['name'] != '')
{
$file_name = $_FILES['zip_file']['name'];
$array = explode(".", $file_name);
$name = $array[0];
$ext = $array[1];
if($ext == 'zip')
{
$path = 'upload/';
$location = $path . $file_name;
if(move_uploaded_file($_FILES['zip_file']['tmp_name'], $location))
{
$zip = new ZipArchive;
if($zip->open($location))
{
$zip->extractTo($path);
$zip->close();
}
$files = scandir($path . $name);
//$name is extract folder from zip file
foreach($files as $file)
{
$file_ext = end(explode(".", $file));
$allowed_ext = array('jpg', 'png');
if(in_array($file_ext, $allowed_ext))
{
$new_name = md5(rand()).'.' . $file_ext;
$output .= '<div class="col-md-6"><div style="padding:16px; border:1px solid #CCC;"><img src="upload/'.$new_name.'" width="170" height="240" /></div></div>';
copy($path.$name.'/'.$file, $path . $new_name);
unlink($path.$name.'/'.$file);
}
}
unlink($location);
rmdir($path . $name);
}
}
}
}
?>
<div id="content">
<form method="post" enctype="multipart/form-data">
<label>Please Select Zip File</label>
<input type="file" name="zip_file" />
<br />
<input type="submit" name="btn_zip" class="btn btn-info" value="Upload" />
</form>
<?php
if(isset($output)) {
echo $output;
}
?>
</div>

View File

@ -0,0 +1,31 @@
<title>Add Chapter .::. <?php echo $config["name"]; ?></title>
<?php
$energy = $_GET["file"];
?>
<link href="assets/themes/<?php echo $config["theme"]; ?>/css/edit.css" type="text/css" rel="stylesheet">
<?php if(isset($_SESSION["username"])) { ?>
<form name="add-chapter" method="POST" action="">
<div class="row">
<?php if(!isset($energy)) {
include("views/pages/mini/unzip.php");
} else { ?>
<div class="col-9">
<h3>Add a Chapter for <a href="?page=view&manga=<?php echo $manga["url"]; ?>"><?php echo $manga["title"]; ?></a></h3>
<input type="text" name="manga_title" placeholder="Manga Title" value="<?php echo $mTITLE; ?>"><br><br>
<textarea name="manga_alternates" placeholder="Alternate Manga Titles" style="width:100%;"><?php echo $mALTER; ?></textarea><br><br>
<input type="text" name="manga_scanlating" placeholder="Scanlation Status (1 for Scanlating, 0 for Dropped/Finished)" value="<?php echo $mSCANL; ?>"><br><br>
<textarea name="manga_description" placeholder="Manga Description" style="width:100%;"><?php echo $mDESC; ?></textarea><br><br>
<input type="text" name="manga_url" value="<?php echo $mURL; ?>" style="display:none"><br><br>
<input type="text" name="manga_cover" value="<?php echo $kami; ?>" style="display:none"><br><br>
</div>
<div class="col-12">
<input id="submit" type="submit" name="edit-manga" value="Update Manga!">
</div>
<?php } ?>
</div>
</form>
<?php } else {
echo "<script type='text/javascript'> document.location = 'index.php?page=login'; </script>";
} ?>

View File

@ -34,7 +34,7 @@ if ($result2->num_rows > 0) {
<div id="content" style="height:100%;background:cornsilk;">
<?php if($action=="add") { ?>
ww
<?php include("views/pages/reader/edit/achapter.php"); ?>
<?php } elseif($action=="edit") { ?>
<?php include("views/pages/reader/edit/manga.php"); ?>
<?php } elseif($action=="view") { ?>