-
Problemi Script!
Salve a tutti ho trovato online uno script per il reader, e volevo implementarlo sul mio blog, ma non riesco a capire appieno il suo funzionamento.
Ho caricato i file .php sul mio server tramite filezilla, scrivo sulla barra degli indirizzi ilmiodomionio..blog/reader/ e compare la pagina con il menu a tendina dove seleziono il manga caricato sul server, alla fine però mi carica la pagina "Questo è leggermente imbarazzante, non è vero?Sembra che non riusciamo a trovare quanto cercato. Forse la ricerca, o uno dei link qui sotto, può aiutare."
qualcuno mi potrebbe dare una mano a capire cosa devo fare? Grazie in anticipo
Config.inc.php
Codice PHP:
<?php
// URL where the script is installed, it must end with a slash
$omv_base_url = "http://claimasoulfansub.altervista.org/blog/?p=336";
// page title
$omv_title = "Manga Viewer";
// supported image file types
$omv_img_types = array("jpg", "jpeg", "png", "bmp", "gif");
// chapters can be sorted by ascending or descending order
$omv_chapters_sorting = SORT_ASC; // SORT_ASC or SORT_DESC
// image auto-resizing
$omv_img_resize = true; // true or false
$omv_preferred_width = 800; // preferred width in pixels
// stylesheet name
$omv_theme = "default"; // theme's folder name
// Disqus Shortname
$disqus_shortname = "http://claimasoulfansub.altervista.org/blog/"; // theme's folder name
?>
<?php
-
functions.inc.php
Codice PHP:
require_once("config.inc.php");
require_once("comments.php");
function omv_encode($text) {
return str_replace(' ', '_', $text);
}
function omv_decode($encoded_text) {
return str_replace('_', ' ', $encoded_text);
}
function omv_get_mangas() {
$mangas = array();
$dirname = "mangas/";
$dir = @opendir($dirname);
if ($dir) {
while (($file = @readdir($dir)) !== false) {
if (is_dir($dirname . $file . '/') && ($file != ".") && ($file != "..")) {
$mangas[] = $file;
}
}
@closedir($dir);
}
sort($mangas);
return $mangas;
}
function omv_get_chapters($manga) {
global $omv_chapters_sorting;
$chapters = array();
$chapters_id = array();
$dirname = "mangas/$manga/";
$dir = @opendir($dirname);
if ($dir) {
while (($file = @readdir($dir)) !== false) {
if (is_dir($dirname . $file . '/') && ($file != ".") && ($file != "..")) {
$chapter = array();
$chapter["folder"] = $file;
$pos = strpos($file, '-');
if ($pos === false) {
$chapter["number"] = $file;
} else {
$chapter["number"] = trim(substr($file, 0, $pos - 1));
$chapter["title"] = trim(substr($file, $pos + 1));
}
$chapters_id[] = $chapter["number"];
$chapters[] = $chapter;
}
}
@closedir($dir);
}
array_multisort($chapters_id, $omv_chapters_sorting, $chapters);
return $chapters;
}
function omv_get_chapter_index($chapters, $chapter_number) {
$i = 0;
while (($i < count($chapters)) && ($chapters[$i]["number"] != $chapter_number)) $i++;
return ($i < count($chapters)) ? $i : -1;
}
function omv_get_pages($manga, $chapter, $commentPage) {
global $omv_img_types;
$pages = array();
$dirname = "mangas/$manga/$chapter/";
$dir = @opendir($dirname);
if ($dir) {
while (($file = @readdir($dir)) !== false) {
if (!is_dir($dirname . $file . '/')) {
$file_extension = strtolower(substr($file, strrpos($file, ".") + 1));
if (in_array($file_extension, $omv_img_types)) {
$pages[] = $file;
}
}
}
@closedir($dir);
}
sort($pages);
$pages[] = $commentPage;
return $pages;
}
function omv_get_previous_page($manga_e, $chapter_number_e, $current_page, $previous_chapter) {
if ($current_page > 1) {
return $manga_e . '/' . $chapter_number_e . '/' . ($current_page - 1);
} else if ($previous_chapter) {
$pages = omv_get_pages(omv_decode($manga_e), $previous_chapter["folder"]);
return $manga_e . '/' . omv_encode($previous_chapter["number"]) . '/' . count($pages);
} else {
return null;
}
}
function omv_get_next_page($manga_e, $chapter_number_e, $current_page, $nb_pages, $next_chapter) {
if ($current_page < $nb_pages) {
return $manga_e . '/' . $chapter_number_e . '/' . ($current_page + 1);
} else if ($next_chapter) {
return $manga_e . '/' . omv_encode($next_chapter["number"]);
} else {
return null;
}
}
function omv_get_image_size($img) {
global $omv_img_resize, $omv_preferred_width;
$size = array();
$imginfo = getimagesize($img);
$size["width"] = intval($imginfo[0]);
$size["height"] = intval($imginfo[1]);
if ($omv_img_resize) {
if ($size["width"] > $omv_preferred_width) {
$size["height"] = intval($size["height"] * ($omv_preferred_width / $size["width"]));
$size["width"] = $omv_preferred_width;
}
}
return $size;
}
?>
-
comments.inc.php
Codice PHP:
<?php
$commentPage = "<hr />";
$commentPage .="<div id='disqus_thread' style='width:800px;padding:0 20px;'></div>";
$commentPage .="<script type='text/javascript'>";
$commentPage .="var disqus_shortname = '".$disqus_shortname."';";
$commentPage .="(function() {";
$commentPage .="var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;";
$commentPage .="dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';";
$commentPage .="(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);";
$commentPage .="})();";
$commentPage .="</script>";
$commentPage .="<noscript>Please enable JavaScript to view the <a href='http://disqus.com/?ref_noscript'>comments powered by Disqus.</a></noscript>";
$commentPage .="<a href='http://disqus.com' class='dsq-brlink'>comments powered by <span class='logo-disqus'>Disqus</span></a>";
$commentPage .= "";
?>
-
index.php 1/2
Codice PHP:
<?php
require_once("config.inc.php");
require_once("functions.inc.php");
require_once("comments.php");
$theme = $omv_theme;
$manga = null;
$manga_escaped = null;
$chapter = null;
$chapter_number = null;
$chapter_number_escaped = null;
$previous_chapter = null;
$next_chapter = null;
$page = null;
$description = "";
$title = $omv_title;
$mangas = omv_get_mangas();
if (isset($_GET["manga"])) {
$manga_title = omv_decode($_GET["manga"]);
if (in_array($manga_title, $mangas)) {
$manga = $manga_title;
$manga_escaped = $_GET["manga"];
}
}
if ($manga) {
$description = "Read " . $manga . " Manga Online";
$title .= " - " . $manga;
$chapters = omv_get_chapters($manga);
if (isset($_GET["chapter"])) {
$chapter_number = omv_decode($_GET["chapter"]);
$index = omv_get_chapter_index($chapters, $chapter_number);
if ($index != -1) {
$chapter = $chapters[$index];
$chapter_number_escaped = $_GET["chapter"];
if ($omv_chapters_sorting == SORT_ASC) {
if ($index > 0) {
$previous_chapter = $chapters[$index - 1];
}
if ($index < (count($chapters) - 1)) {
$next_chapter = $chapters[$index + 1];
}
} else {
if ($index < (count($chapters) - 1)) {
$previous_chapter = $chapters[$index + 1];
}
if ($index > 0) {
$next_chapter = $chapters[$index - 1];
}
}
}
} else {
$chapter = $chapters[0];
$chapter_number = $chapters[0]["number"];
$chapter_number_escaped = omv_encode($chapter_number);
if (count($chapters) > 1) {
if ($omv_chapters_sorting == SORT_ASC) {
$next_chapter = $chapters[1];
} else {
$previous_chapter = $chapters[1];
}
}
}
if ($chapter) {
global $commentPage;
$pages = omv_get_pages($manga, $chapter["folder"], $commentPage);
if (isset($_GET["page"])) {
$_page = intval($_GET["page"]);
if (($_page >= 1) && ($_page <= count($pages))) {
$page = $_page;
}
} else if (count($pages) > 0) {
$page = 1;
}
$title .= " - Chapter " . $chapter_number;
if ($page) {
$title .= " - Page " . $page;
}
}
}
$msg = "<p class='btn btn-danger' style='margin:10px 0'>The last page of the chapter is the comments page</p>";
?>
-
index.php 2/2
Codice PHP:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<base href="<?php echo $omv_base_url ?>" />
<meta name="Keywords" content="<?php echo str_replace(' ', ',', $description) ?>" />
<meta name="Description" content="<?php echo $description ?>" />
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta http-equiv="Content-Language" content="en" />
<title><?php echo $title ?></title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/3.1.1/superhero/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="<?php echo $omv_base_url ?>themes/<?php echo $theme ?>/omv.css" type="text/css" media="screen" />
<script type="text/javascript">
function change_manga(manga) {
if (manga != 0) {
document.location = "<?php echo $omv_base_url ?>" + manga;
}
}
function change_chapter(manga, chapter) {
if (manga != 0) {
document.location = "<?php echo $omv_base_url ?>" + manga + "/" + chapter;
}
}
function change_page(manga, chapter, page) {
if (manga != 0) {
document.location = "<?php echo $omv_base_url ?>" + manga + "/" + chapter + "/" + page;
}
}
</script>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo $omv_base_url ?>">Free O.M.V</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="<?php echo $omv_base_url ?>">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Popular Mangas <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Naruto</a></li>
<li><a href="#">Bleach</a></li>
<li><a href="#">One Piece</a></li>
<li><a href="#">Toriko</a></li>
<li><a href="#">Beelzebub</a></li>
<li><a href="#">Fairy Tail</a></li>
<li><a href="#">Kingdom</a></li>
</ul>
</li>
<li style="padding-top:10px;">
<!-- Social -->
<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone" data-size="medium"></div>
<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
window.___gcfg = {lang: 'pt-BR'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="Akianimes" data-lang="pt" data-hashtags="Akianimes">Tweetar</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<!-- inicio facebook -->
<script type="text/javascript"><!--
urlb=window.location.href;document.write("<iframe src='//www.facebook.com/plugins/like.php?href="+urlb+"&layout=button_count&action=like&font=arial' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:80px; height:20px'></iframe>"); //--></script>
<!-- fim facebook -->
<!-- Fim Social -->
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Credits <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://www.stickytuts.com">Sticky TUTS</a></li>
<li><a href="http://bootswatch.com/superhero/">Using Super Hero - Bootswatch</a></li>
<li><a href="mailto:cool2309@gmail.com">Saif Lacrimosa</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div id="omv" class="container">
<table>
<tr>
<td class="mid">
<table>
<tr>
<td>
<?php
$omv_pager = "";
$omv_pager .= "<div class=\"well\">\n";
$omv_pager .= "<span>Manga <select class=\"form-control\" style='margin-bottom:10px;' name=\"manga\" onchange=\"change_manga(this.value)\">";
$omv_pager .= "<option class=\"form-control\" value=\"0\">Select a manga title...</option>";
for ($i = 0; $i < count($mangas); $i++) {
$m = $mangas[$i];
$omv_pager .= "<option value=\"" . omv_encode($m) . "\"" . (($m == $manga) ? " selected=\"selected\"" : "") . ">" . $m . "</option>";
}
$omv_pager .= "</select></span>\n";
if ($manga) {
if ($chapter) {
$omv_pager .= "<span>Chapter <select class=\"form-control chapter-form\" name=\"chapter\" onchange=\"change_chapter('$manga_escaped', this.value)\">";
for ($i = 0; $i < count($chapters); $i++) {
$cnumber = $chapters[$i]["number"];
$omv_pager .= "<option value=\"" . omv_encode($cnumber) . "\"" . (($cnumber == $chapter_number) ? " selected=\"selected\"" : "") . ">" . $cnumber . (isset($chapters[$i]["title"]) ? (" - " . $chapters[$i]["title"]) : "") . "</option>";
}
$omv_pager .= "</select></span>\n";
if ($page) {
$prevhtml = "";
if ($page <= 1) {
$prevhtml = "<img src='".$omv_base_url."themes/default/no-previous.png' alt='' />";
} else {
$prevhtml = "<a href=\"$manga_escaped/$chapter_number_escaped/" . ($page - 1) . "\"><img src=\"http://www.leitor.tk/themes/default/previous.png\" alt=\"Previous Page\" title=\"Previous Page\" /></a>";
}
$nexthtml = "";
if ($page >= count($pages)) {
$nexthtml = "<img src='".$omv_base_url."themes/default/no-next.png' alt=\"\" />";
} else {
$nexthtml = "<a href=\"$manga_escaped/$chapter_number_escaped/" . ($page + 1) . "\"><img src=\"http://www.leitor.tk/themes/default/next.png\" alt=\"Next Page\" title=\"Next Page\" /></a>";
}
$omv_pager .= "<span>$prevhtml Page <select class=\"form-control page-form\" name=\"page\" onchange=\"change_page('$manga_escaped', '$chapter_number_escaped', this.value)\">";
for ($p = 1; $p <= count($pages); $p++) {
$omv_pager .= "<option value=\"" . $p . "\"" . (($p == $page) ? " selected=\"selected\"" : "") . ">" . ($p == count($pages) ? "Comments" : $p) . "</option>";
}
$omv_pager .= "</select> of " . count($pages) . " $nexthtml</span>\n";
}
}
}
$omv_pager .= "<br /><p class='text-muted btn btn-info'>Use left and right arrows to navigate between pages</p></div>\n";
echo $omv_pager;
?>
</td>
</tr>
<tr>
<td>
<?php
if ($manga) {
if ($chapter) {
if ($page) {
$img = "mangas/" . $manga . "/" . $chapter["folder"] . "/" . $pages[$page - 1];
$imgsize = omv_get_image_size($img);
if ($page >= count($pages)) {
$comments = "<p class='btn btn-danger' style='margin:10px 0;'>".str_replace("mangas", "Comments of : ", $img)."</p>";
$imghtml = $comments;
} else {
$imghtml = $msg."<br /><img src=\"$img\" alt=\"\" width=\"" . $imgsize["width"] . "\" height=\"" . $imgsize["height"] . "\" class=\"picture\" />";
}
$prev_page_path = omv_get_previous_page($manga_escaped, $chapter_number_escaped, $page, $previous_chapter);
$next_page_path = omv_get_next_page($manga_escaped, $chapter_number_escaped, $page, count($pages), $next_chapter);
if ($next_page_path) {
$imghtml = "<a href=\"$next_page_path\">" . $imghtml . "</a>";
}
echo $imghtml;
} else {
echo "<p class=\"text-danger\">There is no selected page!</p>";
}
} else {
echo "<p class=\"text-danger\">There is no selected chapter!</p>";
}
} else {
echo "<p class=\"text-danger select-manga-msg\">Select a Manga to get started</p>";
}
?></td>
</tr>
<?php
if ($manga && $chapter && $page) {
?>
<tr>
<td>
<script type="text/javascript">
function omvKeyPressed(e) {
var keyCode = 0;
if (navigator.appName == "Microsoft Internet Explorer") {
if (!e) {
var e = window.event;
}
if (e.keyCode) {
keyCode = e.keyCode;
if ((keyCode == 37) || (keyCode == 39)) {
window.event.keyCode = 0;
}
} else {
keyCode = e.which;
}
} else {
if (e.which) {
keyCode = e.which;
} else {
keyCode = e.keyCode;
}
}
switch (keyCode) {
<?php
if ($prev_page_path) {
?>
case 37:
window.location = "<?php echo $omv_base_url . $prev_page_path ?>";
return false;
<?php
}
if ($next_page_path) {
?>
case 39:
window.location = "<?php echo $omv_base_url . $next_page_path ?>";
return false;
<?php
}
?>
default:
return true;
}
}
document.onkeydown = omvKeyPressed;
</script>
</td>
</tr>
<tr>
<td>
<?php
echo $omv_pager;
?>
</td>
</tr>
<?php
} else {
?>
<tr>
<td><br /></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="container">
<p class="text-info">All rights reserved to <a href="/"><?php echo $omv_title; ?></a> - © 2014</p>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
-
Se usi WordPress è meglio usare un plugin apposito, lo script che hai riportato non è pensato per essere integrato all'interno di un CMS.
-
cercando su altervista, ho trovato molti siti che lo utilizzano