headerContent.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 = substr(filter_input1(INPUT_GET, "q", FILTER_SANITIZE_QM)??"", 0, 100);
  32. $catMaskedPath = filter_input(INPUT_GET, "catMaskedPath")??"";
  33. $catMaskedPath = strip_tags($catMaskedPath);
  34. $catMaskedPath = substr($catMaskedPath, 0, 100);
  35. $platform = filter_input(INPUT_GET, "platform")??"";
  36. $platform = strip_tags($platform);
  37. $platform = substr($platform, 0, 1);
  38. $styleTag = PHP_STR;
  39. $cat1=PHP_STR;
  40. $cat2=PHP_STR;
  41. $cat3=PHP_STR;
  42. $aCats=explode(PHP_TILDE, $catMaskedPath);
  43. if(isset($aCats[0]) && ($aCats[0]!=="*")){
  44. $cat1=$aCats[0];
  45. }
  46. if(isset($aCats[1])){
  47. $cat2=$aCats[1];
  48. }
  49. if(isset($aCats[2])){
  50. $cat3=$aCats[2];
  51. }
  52. //echo("catMaskedPath=" . $catMaskedPath . "<br>");
  53. //echo("cat1=" . $cat1 . "<br>");
  54. //echo("cat2=" . $cat2 . "<br>");
  55. //echo("cat3=" . $cat3 . "<br>");
  56. $aCats1 = CatUtil::getCatsList();
  57. $aCats2 = CatUtil::getSubCatsList($cat1);
  58. ?>
  59. <script>
  60. // show/hide the image preview of the search results
  61. //var bHideResultsPreview = false;
  62. $(document).ready(function() {
  63. $("div#linkOpenGallery").on("click", function (e) {
  64. e.preventDefault();
  65. e.stopPropagation();
  66. window.open("http://5mode.com","_blank");
  67. });
  68. });
  69. //
  70. // SEARCH FORM
  71. //
  72. $(document).ready(function() {
  73. $("#cbCategory1").on("change", function() {
  74. if ($(this).val() === "") {
  75. $("#cbCategory2").val("");
  76. window.open("/<?php echo($platform);?>/*", "_self");
  77. } else {
  78. window.open("/<?php echo($platform);?>/" + $(this).val(), "_self");
  79. }
  80. });
  81. $("#cbCategory2").on("change", function() {
  82. if ($(this).val() !== "") {
  83. if ($("#cbCategory1").val()!=="") {
  84. window.open("/<?php echo($platform);?>/" + $(this).val().replace("~","/"), "_self");
  85. }
  86. } else {
  87. window.open("/<?php echo($platform);?>/" + $("#cbCategory1").val(), "_self");
  88. }
  89. });
  90. $("input#q").on("keydown",function(e) {
  91. key = e.which;
  92. if (key===13) {
  93. e.preventDefault();
  94. $("#butSearch-addon").click();
  95. }
  96. });
  97. $("#butSearch-addon").on("click",function(e) {
  98. e.preventDefault();
  99. //filterKeysQ(document.getElementById("q"));
  100. if ($("input#q").val()!=="") {
  101. //frmSearch.submit();
  102. if ($("#cbCategory2").val() !== "") {
  103. if ($("#cbCategory1").val()!=="") {
  104. if ($("input#q").val()!=="") {
  105. window.open("/<?php echo($platform);?>/" + $("#cbCategory2").val().replace("~","/") + "?q=" + $("input#q").val(), "_self");
  106. } else {
  107. window.open("/<?php echo($platform);?>/" + $("#cbCategory2").val().replace("~","/"), "_self");
  108. }
  109. }
  110. } else if ($("#cbCategory1").val() !== "") {
  111. if ($("input#q").val()!=="") {
  112. window.open("/<?php echo($platform);?>/" + $("#cbCategory1").val() + "?q=" + $("input#q").val(), "_self");
  113. } else {
  114. window.open("/<?php echo($platform);?>/" + $("#cbCategory1").val(), "_self");
  115. }
  116. } else {
  117. window.open("/<?php echo($platform);?>/*" + "?q=" + $("input#q").val(), "_self");
  118. }
  119. }
  120. });
  121. });
  122. </script>
  123. <div class="header" style="height: fit-content;" role="navigation" align="center">
  124. <?php
  125. $GET_SCRIPT_NAME = basename(strip_tags(filter_input(INPUT_GET, "SCRIPT_NAME")??""));
  126. if (stripos(APP_SCRIPTS_WITHOUT_SEARCH_MENU, "|". $GET_SCRIPT_NAME . "|") || (mb_strrchr($GET_SCRIPT_NAME, PHP_UNDERSCORE, false) === "_a")) {
  127. ?>
  128. <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-strd">
  129. <table class="header-table" align="center">
  130. <tr>
  131. <td class="col-burger-menu-icon">
  132. <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>
  133. <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>
  134. </td>
  135. </tr>
  136. </table>
  137. </div>
  138. <?php } else { ?>
  139. <div class="col-strd">
  140. <table class="col-xs-12 col-sm-10 col-md-10 col-lg-10 header-table" align="center">
  141. <tr>
  142. <td class="col-burger-menu-icon">
  143. <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>
  144. </td>
  145. <td align="left" style="text-align:center;">
  146. <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>
  147. <form id="frmSearch" style="width:200px; float:left; position:relative; top:+15px; left:+25px; " role="search" method="get" action="/search" target="_self">
  148. <select id="cbCategory1" class="form-control input-search" style="width:200px; position:relative; top:+1px;">
  149. <option value=""></option>
  150. <?php foreach($aCats1 as $cat) { ?>
  151. <option value="<?php echo($cat);?>" <?php echo($cat1 === $cat ? "selected": "");?>><?php echo($cat);?></option>
  152. <?php } ?>
  153. </select>
  154. <br>
  155. <select id="cbCategory2" class="form-control input-search" style="width:200px; position:relative; top:-10px;">
  156. <option value=""></option>
  157. <?php foreach($aCats2 as $cat) {
  158. $ipos=strripos($cat, PHP_TILDE);
  159. $displayText=substr($cat,$ipos+1); ?>
  160. <option value="<?php echo($cat);?>" <?php echo($cat2 === strtolower($displayText) ? "selected": "");?>><?php echo($displayText);?></option>
  161. <?php } ?>
  162. </select>
  163. <div class="input-group">
  164. <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">
  165. <span id="butSearch-addon" class="input-group-addon btn-search-addon btn-blue" title="Search"><span class="glyphicon glyphicon-search"></span></span>
  166. </div>
  167. </form>
  168. <div id="form-ori-sep1" style="display:none;"><br><br></div>
  169. <img id="form-vert-bar" src="/res/pxl.gif" style="width:1px;height:160px;float:left;position:relative;left:+55px;background-color:gray;">
  170. <div id="catList" style="width:70%;float:left;position:relative;top:14px;left:75px;">
  171. <?php
  172. $i=1;
  173. if ($cat1===PHP_STR) {
  174. foreach($aCats1 as $cat) { ?>
  175. <div id="linkCat<?php echo($i);?>" class="cat-div"><a href="/<?php echo($platform);?>/<?php echo($cat);?>"><?php echo($cat);?></a></div>
  176. <?php $i++; ?>
  177. <?php } ?>
  178. <?php } else if ($cat2===PHP_STR) {
  179. if (Empty($aCats2)) {
  180. echo("<div class=\"cat-div\" style=\"width:200px;background-color:transparent;\">no subcat found.</div>");
  181. } else {
  182. foreach($aCats2 as $cat) {
  183. $ipos=strripos($cat, PHP_TILDE);
  184. $displayText=substr($cat,$ipos+1);
  185. $link=PHP_SLASH . $platform . PHP_SLASH . str_replace(PHP_TILDE, PHP_SLASH, $cat);?>
  186. <div id="linkCat<?php echo($i);?>" class="cat-div"><a href="<?php echo($link);?>"><?php echo($displayText);?></a></div>
  187. <?php $i++; ?>
  188. <?php } ?>
  189. <?php } ?>
  190. <?php } else {
  191. echo("<div class=\"cat-div\" style=\"width:200px;background-color:transparent;\">no subcat found.</div>");
  192. } ?>
  193. </div>
  194. </td>
  195. </tr>
  196. </table>
  197. </div>
  198. <?php } ?>
  199. </div>