daily pastebin goal
80%
SHARE
TWEET

Manga Dex

a guest Feb 13th, 2018 174 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if (in_array($_SERVER["HTTP_CF_CONNECTING_IP"], array("82.118.236.79", "202.169.217.46", "49.150.43.112"))) die("Your IP has been banned due to abnormal behaviour which may indicate that you are a bot.");
  3.  
  4. require_once ($_SERVER["DOCUMENT_ROOT"] . "/config.req.php");
  5.  
  6. require_once (ABSPATH . "/scripts/header.req.php");
  7.  
  8. $timestamp = time();
  9.  
  10. session_start();
  11.  
  12.  
  13. $_SESSION["token"] = $_SESSION["token"] ?? "";
  14. $token = $_COOKIE['mangadex'] ?? $_SESSION["token"];
  15. $user = new User($db, $token, "token");
  16.                
  17. //pages
  18. $folder_array = array_diff(scandir(ABSPATH . "/pages"), array("..", "."));
  19.  
  20. $_GET["page"] = $_GET["page"] ?? "";
  21. $page = in_array($_GET["page"] . ".req.php", $folder_array) ? $_GET["page"] : "main"; //redirect if $page does not exist
  22.  
  23. if (!$user->user_id) {
  24.     $logged_in_pages = array("follows", "upload", "settings", "messages", "message", "send_message", "activation", "admin", "mod", "group_new", "manga_new"); //pages which require login
  25.     if (in_array($page, $logged_in_pages))
  26.         $page = "login";
  27. }
  28. elseif (($user->level_id < 15 && $page == "admin") || ($user->level_id < 10 && $page == "mod"))
  29.     $page = "main";
  30.  
  31. if ($user->user_id)
  32.     $db->query(" UPDATE mangadex_users SET last_seen_timestamp = $timestamp WHERE user_id = $user->user_id LIMIT 1 "); //update last_seen
  33.    
  34.  
  35. visit_log_cumulative($db, $ip, $table = "visit");
  36.  
  37. visit_log($db, $_SERVER, $ip, $user->user_id, $hentai_toggle); //$hentai_toggle set in header.req.php
  38.  
  39. switch ($page) {
  40.     case "main":
  41.         if (empty($_GET['lang_id']))
  42.             $title = "Latest updates - " . TITLE;
  43.         else {
  44.             $lang_name = $db->get_var(" SELECT lang_name FROM mangadex_languages WHERE lang_id = '{$_GET['lang_id']}'; ");
  45.             $title = "Latest updates ($lang_name) - " . TITLE;
  46.         }
  47.         break;
  48.  
  49.     case "chapter":
  50.         $chapter = $db->get_row(" SELECT mangadex_mangas.manga_name, mangadex_chapters.volume, mangadex_chapters.chapter, mangadex_chapters.title
  51.             FROM mangadex_mangas, mangadex_chapters
  52.             WHERE mangadex_chapters.manga_id = mangadex_mangas.manga_id
  53.                 AND mangadex_chapters.chapter_id = '{$_GET['id']}'; ");
  54.         if ($chapter)
  55.             $title = (($chapter->volume) ? "Vol. $chapter->volume " : "" ).(($chapter->chapter) ? "Ch. $chapter->chapter " : "").((!$chapter->volume && !$chapter->chapter) ? "$chapter->title " : "" )."($chapter->manga_name) - " . TITLE;
  56.         else
  57.             $title = TITLE;
  58.         break;
  59.        
  60.     case "manga":
  61.         $manga_name = $db->get_var(" SELECT manga_name FROM mangadex_mangas WHERE manga_id = '{$_GET['id']}'; ");
  62.         $title = $manga_name . " (Manga) - " . TITLE;
  63.         break;
  64.        
  65.     case "user":
  66.         $username = $db->get_var(" SELECT username FROM mangadex_users WHERE user_id = '{$_GET['id']}'; ");
  67.         $title = $username . " (User) - " . TITLE;
  68.         break;
  69.        
  70.     case "group":
  71.         $group_name = $db->get_var(" SELECT group_name FROM mangadex_groups WHERE group_id = '{$_GET['id']}'; ");
  72.         $title = $group_name . " (Group) - " . TITLE;
  73.         break;
  74.        
  75.     case "groups":
  76.         if (empty($_GET['lang_id']))
  77.             $title = "Groups (All) - " . TITLE;
  78.         else {
  79.             $lang_name = $db->get_var(" SELECT lang_name FROM mangadex_languages WHERE lang_id = '{$_GET['lang_id']}'; ");
  80.             $title = "Groups ($lang_name) - " . TITLE;
  81.         }
  82.         break;
  83.  
  84.     case "titles":
  85.         $_GET['alpha'] = $_GET['alpha'] ?? "";
  86.         $letter = ($_GET['alpha']) ?: "All";
  87.         $title = "Manga titles ($letter) - " . TITLE;
  88.         break;
  89.        
  90.     default:
  91.         $title = ($page) ? ucfirst($page) . " - " . TITLE : TITLE;
  92.         break;
  93. }
  94.  
  95. $ignore_pages   = array("login", "torrent", "group", "signup");
  96.  
  97. $dynamic_url    = $_SERVER["QUERY_STRING"] . "-" . $hentai_toggle; // requested dynamic page (full url)
  98. $cache_file     = ABSPATH . "/cache/" . $dynamic_url; // construct a cache file
  99. //$ignore = strpos_arr($dynamic_url, $ignore_pages); //check if url is in ignore list
  100.  
  101.  
  102.            
  103.            
  104.  
  105.  
  106. if (!$token && !$_SERVER["QUERY_STRING"] && file_exists($cache_file) && time() - CACHE_TIME < filemtime($cache_file) && $caching) { //check Cache exist and it's not expired.
  107.     ob_start('ob_gzhandler'); //Turn on output buffering, "ob_gzhandler" for the compressed page with gzip.
  108.     readfile($cache_file); //read Cache file
  109.    
  110.     print "<p class='text-center'><samp>Cached " . get_time_ago(filemtime($cache_file)) . ".</samp></p>";
  111.    
  112.     ob_end_flush(); //Flush and turn off output buffering
  113.     exit(); //no need to proceed further, exit the flow.
  114. }
  115. //Turn on output buffering with gzip compression.
  116. ob_start('ob_gzhandler');
  117. ######## Your Website Content Starts Below #########
  118.  
  119.  
  120. ?>
  121.  
  122. <!DOCTYPE html>
  123. <html lang="en">
  124.  
  125. <head>
  126.     <meta charset="utf-8">
  127.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  128.     <meta name="viewport" content="width=device-width, initial-scale=1">
  129.     <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  130.     <meta name="author" content="MangaDex">
  131.     <meta name="description" content="<?= DESCRIPTION ?>">
  132.     <meta name="keywords" content="manga, reader">
  133.  
  134.     <meta property="og:site_name" content="<?= TITLE ?>">
  135.     <meta property="og:title" content="<?= $title ?>">
  136.     <meta property="og:image" content="/images/user_logos/default.png">
  137.  
  138.     <link rel="icon" href="/favicon.ico">
  139.  
  140.     <title><?= $title ?> </title>
  141.  
  142.     <!-- Bootstrap core CSS -->
  143.     <link href="/bootstrap/css/bootstrap.<?= ($user->style) ?: 1 ?>.css" rel="stylesheet">
  144.    
  145.     <!-- Bootstrap select CSS -->
  146.     <link href="/bootstrap/css/bootstrap-select.min.css" rel="stylesheet">
  147.    
  148.     <!-- Bootstrap checkbox CSS -->
  149.     <link href="/bootstrap/css/bootstrap-checkbox.css" rel="stylesheet">
  150.    
  151.     <!-- Custom styles for this template -->
  152.     <link href="/scripts/css/theme.css?v=12" rel="stylesheet">
  153.  
  154.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  155.     <!--[if lt IE 9]>
  156.         <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  157.         <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  158.     <![endif]-->
  159.     <!-- Fontawesone glyphicons -->
  160.     <link href="/fontawesome/web-fonts-with-css/css/fontawesome-all.min.css" rel="stylesheet">
  161. </head>
  162.  
  163. <body>
  164. <?php require_once(ABSPATH . "/scripts/analytics.req.php"); ?>
  165.  
  166.     <!-- Fixed navbar -->
  167.     <nav id="top_nav" class="navbar navbar-default navbar-fixed-top">
  168.         <div class="container">
  169.             <div class="navbar-header">
  170.                 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  171.                     <span class="sr-only">Toggle navigation</span>
  172.                     <span class="icon-bar"></span>
  173.                     <span class="icon-bar"></span>
  174.                     <span class="icon-bar"></span>
  175.                 </button>
  176.                 <a class="navbar-brand" id="home_button" href="/"><?= TITLE ?></a>
  177.             </div>
  178.             <div id="navbar" class="navbar-collapse collapse">
  179.                 <ul class="nav navbar-nav" id="nav_links"><?php require_once(ABSPATH . "/pages/nav_links.req.php"); ?></ul>
  180.                
  181.                 <ul class="nav navbar-nav navbar-right" id="username"><?php require_once(ABSPATH . "/pages/username.req.php"); ?></ul>
  182.                
  183.                 <ul class="nav navbar-nav navbar-right" id="pm">
  184.                     <li class="dropdown">
  185.                         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
  186.                             <?= display_glyphicon("envelope", "fas", "Messages", "fa-fw") ?> <span class="nav-label-1440">Mail <?= $user->get_unread_threads($db) ?></span> <span class="caret"></span>
  187.                         </a>
  188.                         <ul class="dropdown-menu">
  189.                             <li class="" id="messages"><a href="/messages"><?= display_glyphicon("envelope", "fas", "Messages", "fa-fw") ?> Messages</a></li>
  190.                             <li class="" id="send_message"><a href="/send_message"><?= display_glyphicon("pencil-alt", "fas", "", "fa-fw") ?> Send</a></li>
  191.                         </ul>
  192.                     </li>
  193.                 </ul>
  194.                
  195.                 <?php if (!isset($_GET['alpha'])) { ?>
  196.                 <form id="h_toggle_form" class="navbar-form navbar-right">
  197.                     <select class="form-control selectpicker show-tick" data-width="120px" id="h_toggle" name="h_toggle">
  198.                         <option value="1" <?= ($hentai_toggle == 1) ? "selected" : "" ?>>Show all</option>
  199.                         <option value="0" <?= (!$hentai_toggle) ? "selected" : "" ?> data-content="Hide <span class='label label-danger'>R18+</span>">Hide R18+</option>
  200.                         <option value="2" <?= ($hentai_toggle == 2) ? "selected" : "" ?> data-content="Only <span class='label label-danger'>R18+</span>">Only R18+</option>
  201.                     </select>
  202.                 </form>
  203.                 <?php } ?>
  204.                
  205.                 <form id="quick_search_form" role="search" class="navbar-form navbar-right" action="/?page=titles">
  206.                     <div class="input-group">  
  207.                         <input type="text" class="form-control quick_search_input" placeholder="Quick search" name="manga_name" id="quick_search_input" >
  208.                         <span class="input-group-btn">
  209.                             <button class="btn btn-default" type="submit" id="quick_search_button"><?= display_glyphicon("search", "fas") ?></button>
  210.                         </span>
  211.                     </div>
  212.                 </form>              
  213.                
  214.             </div><!--/.nav-collapse -->
  215.         </div>
  216.     </nav>
  217.  
  218.     <div class="container" role="main">
  219.         <?php if (!$user->activated) { ?>
  220.         <div class="alert alert-warning text-center" role="alert"><strong>Warning:</strong> Your account is currently unactivated. Please enter your activation code <a href="/activation">here</a> for access to all of <?= TITLE ?>'s features.</div>
  221.         <?php } ?>
  222.        
  223.         <?php if ((!$user->read_announcement || !$user->user_id) && $page != "chapter") { ?>
  224.         <div id="announcement" class="alert alert-success alert-dismissible text-center" role="alert">
  225.             <?php if ($user->user_id) { ?>
  226.                 <button id="read_announcement_button" type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  227.             <?php } ?>
  228.             <strong>Update (5-Feb)</strong> <strong>Notice:</strong> If you have problems logging in, reset your cookies.</div>
  229.         <?php } ?>
  230.        
  231.         <div id="content">
  232.             <?php
  233.             $time = explode(" ", microtime());
  234.             $start = $time[1] + $time[0];
  235.             require_once (ABSPATH . "/pages/" . $page . ".req.php");
  236.            
  237.             ?>
  238.             <?php
  239.                
  240.                 $time = explode(' ', microtime());
  241.                 $finish = $time[1] + $time[0];
  242.                 $total_time = round(($finish - $start), 3) * 1000;
  243.                 print "<!--<p class='text-center'><samp>Page generated in $total_time ms.</samp></p>-->";
  244.             ?>
  245.         </div>
  246.        
  247.     </div> <!-- /container -->
  248.  
  249.     <!-- message_container -->
  250.     <div id="message_container" class="display-none"></div>
  251.     <!-- /container -->
  252.    
  253.     <footer class="footer">
  254.         <p class="text-center text-muted">Copyright &copy; <?= date("Y") ?> <a href="/">MangaDex</a> - <a href="https://hologfx.com" target="_blank" title="Project AniDex Portal">Project AniDex</a></p>
  255.     </footer>
  256.    
  257.  
  258.     <!-- Bootstrap core JavaScript
  259.     ================================================== -->
  260.     <!-- Placed at the end of the document so the pages load faster -->
  261.     <script src="/scripts/jquery.min.js"></script>
  262.     <script src="/scripts/jquery.touchSwipe.min.js"></script>
  263.     <script src="/bootstrap/js/bootstrap.min.js"></script>
  264.     <script src="/bootstrap/js/bootstrap-select.min.js"></script>
  265.     <script src="/bootstrap/js/docs.min.js"></script>
  266.     <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  267.     <script src="/bootstrap/js/ie10-viewport-bug-workaround.js"></script>
  268.     <script type="text/javascript">
  269.     var $ = jQuery;
  270.    
  271.     $(document).on('change', '.btn-file :file', function() {
  272.         var input = $(this),
  273.             numFiles = input.get(0).files ? input.get(0).files.length : 1,
  274.             label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
  275.         input.trigger('fileselect', [numFiles, label]);
  276.     });
  277.  
  278.     function capitalizeFirstLetter(string) {
  279.         return string.charAt(0).toUpperCase() + string.slice(1);
  280.     }
  281.    
  282.     function commaMultipleSelect(id) {
  283.         var list = document.getElementById(id);
  284.         var selected = new Array();
  285.      
  286.         for (i = 0; i < list.options.length; i++) {
  287.             if (list.options[ i ].selected) {
  288.                  selected.push(list.options[ i ].value);
  289.             }
  290.         }
  291.      
  292.         return selected.join(',');
  293.     }
  294.    
  295.     $(document).ready(function(){
  296.         var query = location.search;
  297.        
  298.         $("#read_announcement_button").click(function(event){
  299.             $.ajax({
  300.                 url: "/ajax/actions.ajax.php?function=read_announcement",
  301.                 type: 'GET',
  302.                 async: false,
  303.                 success: function (data) {
  304.                     $("#announcement").hide();
  305.                 },
  306.                 cache: false,
  307.                 contentType: false,
  308.                 processData: false
  309.             });
  310.             event.preventDefault();
  311.         });
  312.        
  313.         $("#h_toggle").change(function() {
  314.             val = $("#h_toggle").val();
  315.             $.ajax({
  316.                 url: "/ajax/actions.ajax.php?function=hentai_toggle&mode="+val,
  317.                 type: 'GET',
  318.                 async: false,
  319.                 success: function (data) {
  320.                     $("#message_container").html(data).show().delay(1500).fadeOut();
  321.                     location.reload();
  322.                     //alert(data);
  323.                 },
  324.                 cache: false,
  325.                 contentType: false,
  326.                 processData: false
  327.                
  328.             });
  329.            
  330.         });
  331.        
  332.         $("#logout").click(function(event){
  333.             $.ajax({
  334.                 type: "POST",
  335.                 url: "/ajax/actions.ajax.php?function=logout",
  336.                 success: function(data) {
  337.                     $("#message_container").html(data).show().delay(1500).fadeOut();
  338.                     location.reload();
  339.                 }
  340.             });
  341.             event.preventDefault();
  342.         });
  343.  
  344.         $("#quick_search_form").submit(function(event) {
  345.  
  346.             var search_title = encodeURIComponent($("#quick_search_input").val());
  347.            
  348.             $("#quick_search_button").html("<?= display_glyphicon("spinner", "fas", "", "fa-pulse") ?>").attr("disabled", true);
  349.            
  350.             location.href = "/?page=search&title="+search_title;
  351.  
  352.             event.preventDefault();
  353.  
  354.         });
  355.  
  356.         <?php
  357.         $folder_array = array_diff(scandir(ABSPATH . "/scripts/js"), array("..", "."));
  358.  
  359.         if (in_array($page . ".req.js", $folder_array))
  360.             require_once (ABSPATH . "/scripts/js/" . $page . ".req.js");
  361.         ?>
  362.        
  363.     });
  364.    
  365.     </script>
  366. </body>
  367. </html>
  368.  
  369. <?php
  370.  
  371. ######## Your Website Content Ends here #########
  372.  
  373. if(!$token && !$_SERVER["QUERY_STRING"] && $caching){
  374.     $fp = fopen($cache_file, 'w');  //open file for writing
  375.     fwrite($fp, ob_get_contents()); //write contents of the output buffer in Cache file
  376.     fclose($fp); //Close file pointer
  377. }
  378. ob_end_flush(); //Flush and turn off output buffering
  379.  
  380. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top