idxpage1img.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Copyright 2021, 2026 5 Mode
  4. *
  5. * This file is part of GrandePuffo.
  6. *
  7. * GrandePuffo 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. * GrandePuffo 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 GrandePuffo. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * mrouter.php
  21. *
  22. * The main router.
  23. *
  24. * @author Daniele Bonini <my25mb@has.im>
  25. * @copyrights (c) 2016, 2026 5 Mode
  26. */
  27. use fivemode\fivemode\Cookie;
  28. use fivemode\fivemode\Puffi;
  29. // FUNCTION AND VARIABLE DECLARATIONS
  30. // Cookie reset..
  31. function resetCookies() {
  32. Cookie::set($mySha, "0", Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  33. Cookie::set($mySha."0", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  34. Cookie::set($mySha."1", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  35. Cookie::set($mySha."2", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  36. Cookie::set($mySha."3", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  37. Cookie::set($mySha."4", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  38. }
  39. // Increment image instance counter..
  40. function setCookieCounter() {
  41. // set iteraction counter..
  42. global $ROUTING;
  43. global $myShaCounter;
  44. global $mySha;
  45. while(true) {
  46. $myShaCounter++;
  47. if (!defined("ROUTING_RES".$myShaCounter)) {
  48. Cookie::set($mySha, 0, Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  49. break;
  50. }
  51. if ($ROUTING['RES_TYPE'][$myShaCounter]==="image") {
  52. Cookie::set($mySha, $myShaCounter, Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  53. break;
  54. }
  55. }
  56. }
  57. $myTmpResPath = "";
  58. // PARAMETERS VALIDATION
  59. //$myDisplaiedSha = substr($url,7,strlen($url)-11);
  60. $myDisplaiedSha = substr($url,7,strlen($url));
  61. $myResIdx=getRes($myDisplaiedSha);
  62. // echo("**".$myResIdx."**");
  63. $mySha = $ROUTING['RES_SHA'][$myResIdx];
  64. $myShaCounter = Cookie::get($mySha, 0);
  65. //echo("**".$myShaCounter."**");
  66. $myResType = $ROUTING['RES_TYPE'][$myShaCounter];
  67. // echo("**".$myResType."**");
  68. if ($myResType==="image") {
  69. //$mySha = $ROUTING['RES_SHA'][$myResIdx];
  70. $myPageElementID = $ROUTING['WEBPAGE_ELEMENT'][$myShaCounter];
  71. $myRes = Puffi::getres($mySha,$myShaCounter);
  72. //echo("--".$myRes."--");
  73. $cookiePath = Cookie::get($mySha.$myShaCounter, PHP_STR);
  74. if ( $cookiePath !== $cookiePath) {
  75. $myTmpResPath = $cookiePath;
  76. $myTmpResRelPath = substr($myTmpResPath, strlen(APP_PUBLIC_PATH));
  77. } else {
  78. $myTmpResRoot = APP_PUBLIC_PATH . DIRECTORY_SEPARATOR . "tmpres";
  79. $myTmpResPath = getNewTmpFileName($myTmpResRoot, pathinfo($myRes, PATHINFO_EXTENSION));
  80. $myTmpResRelPath = substr($myTmpResPath, strlen(APP_PUBLIC_PATH));
  81. genTmpRes(APP_PUBLIC_PATH . DIRECTORY_SEPARATOR . $myRes, $myTmpResPath);
  82. Cookie::set($mySha.$myShaCounter, $myTmpResPath, Cookie::EXPIRE_ONEDAY, "/", APP_HOST);
  83. }
  84. }
  85. if (is_readable($myTmpResPath)) {
  86. $filecont = file_get_contents($myTmpResPath);
  87. echo($filecont);
  88. }
  89. setCookieCounter();