. * * mrouter.php * * The main router. * * @author Daniele Bonini * @copyrights (c) 2016, 2026 5 Mode */ use fivemode\fivemode\Cookie; use fivemode\fivemode\Puffi; // FUNCTION AND VARIABLE DECLARATIONS // Cookie reset.. function resetCookies() { Cookie::set($mySha, "0", Cookie::EXPIRE_ONEDAY, "/", APP_HOST); Cookie::set($mySha."0", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST); Cookie::set($mySha."1", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST); Cookie::set($mySha."2", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST); Cookie::set($mySha."3", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST); Cookie::set($mySha."4", "", Cookie::EXPIRE_ONEDAY, "/", APP_HOST); } // Increment image instance counter.. function setCookieCounter() { // set iteraction counter.. global $ROUTING; global $myShaCounter; global $mySha; while(true) { $myShaCounter++; if (!defined("ROUTING_RES".$myShaCounter)) { Cookie::set($mySha, 0, Cookie::EXPIRE_ONEDAY, "/", APP_HOST); break; } if ($ROUTING['RES_TYPE'][$myShaCounter]==="image") { Cookie::set($mySha, $myShaCounter, Cookie::EXPIRE_ONEDAY, "/", APP_HOST); break; } } } $myTmpResPath = ""; // PARAMETERS VALIDATION //$myDisplaiedSha = substr($url,7,strlen($url)-11); $myDisplaiedSha = substr($url,7,strlen($url)); $myResIdx=getRes($myDisplaiedSha); // echo("**".$myResIdx."**"); $mySha = $ROUTING['RES_SHA'][$myResIdx]; $myShaCounter = Cookie::get($mySha, 0); //echo("**".$myShaCounter."**"); $myResType = $ROUTING['RES_TYPE'][$myShaCounter]; // echo("**".$myResType."**"); if ($myResType==="image") { //$mySha = $ROUTING['RES_SHA'][$myResIdx]; $myPageElementID = $ROUTING['WEBPAGE_ELEMENT'][$myShaCounter]; $myRes = Puffi::getres($mySha,$myShaCounter); //echo("--".$myRes."--"); $cookiePath = Cookie::get($mySha.$myShaCounter, PHP_STR); if ( $cookiePath !== $cookiePath) { $myTmpResPath = $cookiePath; $myTmpResRelPath = substr($myTmpResPath, strlen(APP_PUBLIC_PATH)); } else { $myTmpResRoot = APP_PUBLIC_PATH . DIRECTORY_SEPARATOR . "tmpres"; $myTmpResPath = getNewTmpFileName($myTmpResRoot, pathinfo($myRes, PATHINFO_EXTENSION)); $myTmpResRelPath = substr($myTmpResPath, strlen(APP_PUBLIC_PATH)); genTmpRes(APP_PUBLIC_PATH . DIRECTORY_SEPARATOR . $myRes, $myTmpResPath); Cookie::set($mySha.$myShaCounter, $myTmpResPath, Cookie::EXPIRE_ONEDAY, "/", APP_HOST); } } if (is_readable($myTmpResPath)) { $filecont = file_get_contents($myTmpResPath); echo($filecont); } setCookieCounter();