aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/gallery/preview/index.php
blob: e033cc0212c98ad82975403ad77e9e9cc98815c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php require_once "../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?>
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php";

if (isset($_GET['return'])) {
    $callback = $_GET['return'];
}

?>
<!DOCTYPE html>
<html lang="en" style="height:100%;overflow:hidden;">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="<?= $GLOBALS['SYSTEM_ROOT'] ?>/resources/css/preview.css">
    <script src="<?= $GLOBALS['SYSTEM_ROOT'] ?>/resources/js/jquery.js"></script>
    <title><?= $lang["gallery"]["preview"]['title'] ?></title>
</head>
<?php

    if (isset($_GET['url'])) {
        if (strpos($_GET['url'], '..') !== false) {
            require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["gallery"]["preview"]['invalid']);
        } else {
            if (file_exists($GLOBALS['ORIGINAL_DOCUMENT_ROOT'] . "/" . $_GET['url'])) {
                $ext1 = explode(".", $_GET['url']);
                $ext2 = end($ext1);
                $ext = strtoupper($ext2);
            } else {
                require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["gallery"]["preview"]['notfound']);
            }
        }
    } else {
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["gallery"]["preview"]['none']);
    }

?>
<body style="background-size:contain;background-position:center;height: 100%;margin: 0;background-repeat: no-repeat;background-color: #222;">
    <div class="container">
        <img class="image" id="scroll" src="<?= $_GET['url'] ?>" draggable="false" onmouseup="clearTimeout(mdt);--mousedown;" onclick="return false;">
        <script>
          document.getElementsByClassName('image')[0].style.transform = "scale(1)";
        </script>
    </div>
    <?php if (isset($callback)): ?><a class="close" title="<?= $lang["gallery"]["preview"]['close'] ?>"><img class="icon" src="<?= $GLOBALS['SYSTEM_ROOT'] ?>/resources/image/close.svg" onclick="location.href = &quot;<?= $callback ?>&quot;"></a><?php endif ?>
    <a class="download" href="<?= $_GET['url'] ?>" title="<?= $lang["gallery"]["preview"]['placeholder'][0] ?> <?= $ext ?> <?= $lang["gallery"]["preview"]['placeholder'][1] ?>" download><?= $lang["gallery"]["preview"]['download'] ?> (<?= $ext ?>)</a>
    <span class="zoom">
        <a class="zoomin" onclick="zoomin();"></a>
        <a class="zoomout" onclick="zoomout();"></a>
    </span>
</body>
<script>

function zoomin() {
    tf = document.getElementsByClassName("image")[0].style.transform.split("(")[1].split(")")[0] - 1 + 1;
    if (tf < 8) {
        tf++;
        document.getElementsByClassName('image')[0].style.transform = `scale(${tf})`;
        document.getElementsByClassName('image')[0].style['margin-top'] = (((1055 / 6) * (window.innerHeight / 480)) * tf) + 'px';
        document.getElementsByClassName('image')[0].style['margin-left'] = (((1055 / 6) * (window.innerWidth / 480)) * tf) + 'px';
    }
}

function zoomout() {
    tf = document.getElementsByClassName("image")[0].style.transform.split("(")[1].split(")")[0] - 1 + 1;
    if (tf > 1) {
        tf--;
        if (tf > 1) {
            document.getElementsByClassName('image')[0].style.transform = `scale(${tf})`;
            document.getElementsByClassName('image')[0].style['margin-top'] = (((1055 / 6) * (window.innerHeight / 480)) * tf) + 'px';
            document.getElementsByClassName('image')[0].style['margin-left'] = (((1055 / 6) * (window.innerWidth / 480)) * tf) + 'px';
        } else {
            document.getElementsByClassName('image')[0].style.transform = `scale(${tf})`;
            document.getElementsByClassName('image')[0].style['margin-top'] = (((1055 / 6) / 422) * tf) + 'px';
            document.getElementsByClassName('image')[0].style['margin-left'] = (((1055 / 6) / 422) * tf) + 'px';
        }
    }
}

window.onload = () => {setTimeout(() => {Array.from(document.getElementsByClassName('ppreview')).forEach((el) => {el.classList.add('loaded')});}, 1000)}

(function($) {
  $.dragScroll = function(options) {
    var settings = $.extend({
      scrollVertical: true,
      scrollHorizontal: true,
      cursor: null
    }, options);

    var clicked = false,
      clickY, clickX;

    var getCursor = function() {
      if (settings.cursor) return settings.cursor;
      if (settings.scrollVertical && settings.scrollHorizontal) return 'move';
      if (settings.scrollVertical) return 'row-resize';
      if (settings.scrollHorizontal) return 'col-resize';
    }

    var updateScrollPos = function(e, el) {
      $('html').css('cursor', getCursor());
      var $el = $(el);
      settings.scrollVertical && $el.scrollTop($el.scrollTop() + (clickY - e.pageY));
      settings.scrollHorizontal && $el.scrollLeft($el.scrollLeft() + (clickX - e.pageX));
    }

    $(document).on({
      'mousemove': function(e) {
        clicked && updateScrollPos(e, this);
      },
      'mousedown': function(e) {
        clicked = true;
        clickY = e.pageY;
        clickX = e.pageX;
      },
      'mouseup': function() {
        clicked = false;
        $('html').css('cursor', 'auto');
      }
    });
  }
}(jQuery))

$.dragScroll();

</script>
</html>