headerContent.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of MacSwap.
  6. *
  7. * SnipSwap is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * SnipSwap is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with SnipSwap. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * headerContent.php
  21. *
  22. * headerContent file.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2016, 2024, 5 Mode
  26. */
  27. use fivemode\fivemode\CatUtil;
  28. // VARIABLES AND FUNCTION DECLARATIONS
  29. settype($q, "string");
  30. // PARAMETERS VALIDATION AND NORMALIZATION
  31. $q = (string)substr((string)filter_input1(INPUT_GET, "q", FILTER_SANITIZE_QM), 0, 100);
  32. $catMaskedPath = (string)substr((string)filter_input(INPUT_GET, "catMaskedPath", FILTER_SANITIZE_STRING), 0, 100);
  33. $platform = (string)substr((string)filter_input(INPUT_GET, "platform", FILTER_SANITIZE_STRING), 0, 1);
  34. $styleTag = PHP_STR;
  35. $cat1=PHP_STR;
  36. $cat2=PHP_STR;
  37. $cat3=PHP_STR;
  38. $aCats=explode(PHP_TILDE, $catMaskedPath);
  39. if(isset($aCats[0]) && ($aCats[0]!=="*")){
  40. $cat1=$aCats[0];
  41. }
  42. if(isset($aCats[1])){
  43. $cat2=$aCats[1];
  44. }
  45. if(isset($aCats[2])){
  46. $cat3=$aCats[2];
  47. }
  48. //echo("catMaskedPath=" . $catMaskedPath . "<br>");
  49. //echo("cat1=" . $cat1 . "<br>");
  50. //echo("cat2=" . $cat2 . "<br>");
  51. //echo("cat3=" . $cat3 . "<br>");
  52. $aCats1 = CatUtil::getCatsList();
  53. $aCats2 = CatUtil::getSubCatsList($cat1);
  54. ?>
  55. <script>
  56. // show/hide the image preview of the search results
  57. //var bHideResultsPreview = false;
  58. $(document).ready(function() {
  59. $("div#linkOpenGallery").on("click", function (e) {
  60. e.preventDefault();
  61. e.stopPropagation();
  62. window.open("http://5mode.com","_blank");
  63. });
  64. });
  65. //
  66. // SEARCH FORM
  67. //
  68. $(document).ready(function() {
  69. $("#cbCategory1").on("change", function() {
  70. if ($(this).val() === "") {
  71. $("#cbCategory2").val("");
  72. window.open("/<?php echo($platform);?>/*", "_self");
  73. } else {
  74. window.open("/<?php echo($platform);?>/" + $(this).val(), "_self");
  75. }
  76. });
  77. $("#cbCategory2").on("change", function() {
  78. if ($(this).val() !== "") {
  79. if ($("#cbCategory1").val()!=="") {
  80. window.open("/<?php echo($platform);?>/" + $(this).val().replace("~","/"), "_self");
  81. }
  82. } else {
  83. window.open("/<?php echo($platform);?>/" + $("#cbCategory1").val(), "_self");
  84. }
  85. });
  86. $("input#q").on("keydown",function(e) {
  87. key = e.which;
  88. if (key===13) {
  89. e.preventDefault();
  90. $("#butSearch-addon").click();
  91. }
  92. });
  93. $("#butSearch-addon").on("click",function(e) {
  94. e.preventDefault();
  95. //filterKeysQ(document.getElementById("q"));
  96. if ($("input#q").val()!=="") {
  97. //frmSearch.submit();
  98. if ($("#cbCategory2").val() !== "") {
  99. if ($("#cbCategory1").val()!=="") {
  100. if ($("input#q").val()!=="") {
  101. window.open("/<?php echo($platform);?>/" + $("#cbCategory2").val().replace("~","/") + "?q=" + $("input#q").val(), "_self");
  102. } else {
  103. window.open("/<?php echo($platform);?>/" + $("#cbCategory2").val().replace("~","/"), "_self");
  104. }
  105. }
  106. } else if ($("#cbCategory1").val() !== "") {
  107. if ($("input#q").val()!=="") {
  108. window.open("/<?php echo($platform);?>/" + $("#cbCategory1").val() + "?q=" + $("input#q").val(), "_self");
  109. } else {
  110. window.open("/<?php echo($platform);?>/" + $("#cbCategory1").val(), "_self");
  111. }
  112. } else {
  113. window.open("/<?php echo($platform);?>/*" + "?q=" + $("input#q").val(), "_self");
  114. }
  115. }
  116. });
  117. });
  118. </script>
  119. <div class="header" style="height: fit-content;" role="navigation" align="center">
  120. <?php
  121. $GET_SCRIPT_NAME = basename(filter_input(INPUT_GET, "SCRIPT_NAME"));
  122. if (stripos(APP_SCRIPTS_WITHOUT_SEARCH_MENU, "|". $GET_SCRIPT_NAME . "|") || (mb_strrchr($GET_SCRIPT_NAME, PHP_UNDERSCORE, false) === "_a")) {
  123. ?>
  124. <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-strd">
  125. <table class="header-table" align="center">
  126. <tr>
  127. <td class="col-burger-menu-icon">
  128. <div id="burgerMenuIco" onclick="popupMenu()" style="position: relative; left:0px; border:0px solid blue; width: 48px; display:none;"><a id="aBurger-Menu" class="navbar-brand-nml" href="#" title="Tap here for options"><img src="/res/burger-menu2.png" width="42px"></a></div>
  129. <div id="logo-div" style="width:180px; position:relative; top:-52; margin-left:46%; color:#ed6a43;"><a href="/" style="color:#ed6e48;font-size:30px;font-style:italic;font-weight:900;"><?php echo(strtoupper(APP_NAME));?></a></div>
  130. </td>
  131. </tr>
  132. </table>
  133. </div>
  134. <?php } else { ?>
  135. <div class="col-strd">
  136. <table class="col-xs-12 col-sm-10 col-md-10 col-lg-10 header-table" align="center">
  137. <tr>
  138. <td class="col-burger-menu-icon">
  139. <div id="burgerMenuIco" onclick="popupMenu()" style="position: absolute; left:+10px; top:+4px; border:0px solid blue; width: 46px; display:none;"><a id="aBurger-Menu" class="navbar-brand-nml" href="#" title="Tap here for options"><img src="/res/burger-menu2<?php echo($styleTag);?>.png" width="42px"></a></div>
  140. </td>
  141. <td align="left" style="text-align:center;">
  142. <div id="logo-div" style="width:180px; position:relative; top:-55; left:-44px; margin-left:46%; color:#ed6a43;"><a href="/" style="color:#ed6e48;font-size:30px;font-style:italic;font-weight:900;"><!--<?php echo(APP_NAME);?>--></a></div>
  143. <form id="frmSearch" style="width:200px; float:left; position:relative; top:+15px; left:+25px; " role="search" method="get" action="/search" target="_self">
  144. <select id="cbCategory1" class="form-control input-search" style="width:200px; position:relative; top:+1px;">
  145. <option value=""></option>
  146. <?php foreach($aCats1 as $cat) { ?>
  147. <option value="<?php echo($cat);?>" <?php echo($cat1 === $cat ? "selected": "");?>><?php echo($cat);?></option>
  148. <?php } ?>
  149. </select>
  150. <br>
  151. <select id="cbCategory2" class="form-control input-search" style="width:200px; position:relative; top:-10px;">
  152. <option value=""></option>
  153. <?php foreach($aCats2 as $cat) {
  154. $ipos=strripos($cat, PHP_TILDE);
  155. $displayText=substr($cat,$ipos+1); ?>
  156. <option value="<?php echo($cat);?>" <?php echo($cat2 === strtolower($displayText) ? "selected": "");?>><?php echo($displayText);?></option>
  157. <?php } ?>
  158. </select>
  159. <div class="input-group">
  160. <input id="q" name="q" type="search" class="form-control input-search" style="font-style: italic;" value="<?php echo $q;?>" maxlength="100" placeholder="SEARCH" title="Type here the search text" autocomplete="off" spellcheck="false" aria-describedby="butSearch-addon">
  161. <span id="butSearch-addon" class="input-group-addon btn-search-addon btn-blue" title="Search"><span class="glyphicon glyphicon-search"></span></span>
  162. </div>
  163. </form>
  164. <div id="form-ori-sep1" style="display:none;"><br><br></div>
  165. <img id="form-vert-bar" src="/res/pxl.gif" style="width:1px;height:160px;float:left;position:relative;left:+55px;background-color:gray;">
  166. <div id="catList" style="width:70%;float:left;position:relative;top:14px;left:75px;">
  167. <?php
  168. $i=1;
  169. if ($cat1===PHP_STR) {
  170. foreach($aCats1 as $cat) { ?>
  171. <div id="linkCat<?php echo($i);?>" class="cat-div"><a href="/<?php echo($platform);?>/<?php echo($cat);?>"><?php echo($cat);?></a></div>
  172. <?php $i++; ?>
  173. <?php } ?>
  174. <?php } else if ($cat2===PHP_STR) {
  175. if (Empty($aCats2)) {
  176. echo("<div class=\"cat-div\" style=\"width:200px;background-color:transparent;\">no subcat found.</div>");
  177. } else {
  178. foreach($aCats2 as $cat) {
  179. $ipos=strripos($cat, PHP_TILDE);
  180. $displayText=substr($cat,$ipos+1);
  181. $link=PHP_SLASH . $platform . PHP_SLASH . str_replace(PHP_TILDE, PHP_SLASH, $cat);?>
  182. <div id="linkCat<?php echo($i);?>" class="cat-div"><a href="<?php echo($link);?>"><?php echo($displayText);?></a></div>
  183. <?php $i++; ?>
  184. <?php } ?>
  185. <?php } ?>
  186. <?php } else {
  187. echo("<div class=\"cat-div\" style=\"width:200px;background-color:transparent;\">no subcat found.</div>");
  188. } ?>
  189. </div>
  190. </td>
  191. </tr>
  192. </table>
  193. </div>
  194. <?php } ?>
  195. </div>