byId('uploads')->getAbsPath() . '/' . $destinationRelHtaccess; } elseif ($dirIdOfHtaccess == 'cache') { return $imageRoots->byId('wp-content')->getAbsPath() . '/webp-express/webp-images/' . $destinationRelHtaccess; } /* $pathTokens = explode('/', $destinationRelCacheRoot); $imageRootId = array_shift($pathTokens); $destinationRelSpecificCacheRoot = implode('/', $pathTokens); $imageRootId = SanityCheck::pregMatch( '#^[a-z\-]+$#', $imageRootId, 'The image root ID is not a valid root id' ); // TODO: Validate that the root id is in scope if (count($pathTokens) == 0) { throw new \Exception('invalid destination argument. It must contain dashes.'); } return $imageRoots->byId($imageRootId)->getAbsPath() . '/' . $destinationRelSpecificCacheRoot; /* if ($imageRootId !== false) { //$imageRootId = self::getEnvPassedInRewriteRule('WE_IMAGE_ROOT_ID'); if ($imageRootId !== false) { $imageRootId = SanityCheck::pregMatch('#^[a-z\-]+$#', $imageRootId, 'The image root ID passed in ENV is not a valid root-id'); $destinationRelImageRoot = self::getEnvPassedInRewriteRule('WE_DESTINATION_REL_IMAGE_ROOT'); if ($destinationRelImageRoot !== false) { $destinationRelImageRoot = SanityCheck::pathWithoutDirectoryTraversal($destinationRelImageRoot); } $imageRoots = self::getImageRootsDef(); return $imageRoots->byId($imageRootId)->getAbsPath() . '/' . $destinationRelImageRoot; } if (isset($_GET['xdestination-rel-image-root'])) { $xdestinationRelImageRoot = SanityCheck::noControlChars($_GET['xdestination-rel-image-root']); $destinationRelImageRoot = SanityCheck::pathWithoutDirectoryTraversal(substr($xdestinationRelImageRoot, 1)); $imageRootId = SanityCheck::noControlChars($_GET['image-root-id']); SanityCheck::pregMatch('#^[a-z\-]+$#', $imageRootId, 'Not a valid root-id'); $imageRoots = self::getImageRootsDef(); return $imageRoots->byId($imageRootId)->getAbsPath() . '/' . $destinationRelImageRoot; } throw new \Exception('Argument for destination file missing'); //WE_DESTINATION_REL_IMG_ROOT*/ /* $destAbs = SanityCheck::noControlChars(self::getEnvPassedInRewriteRule('WEDESTINATIONABS')); if ($destAbs !== false) { return SanityCheck::pathWithoutDirectoryTraversal($destAbs); } // Check querystring (relative path) if (isset($_GET['xdest-rel-to-root-id'])) { $xdestRelToRootId = SanityCheck::noControlChars($_GET['xdest-rel-to-root-id']); $destRelToRootId = SanityCheck::pathWithoutDirectoryTraversal(substr($xdestRelToRootId, 1)); $rootId = SanityCheck::noControlChars($_GET['root-id']); SanityCheck::pregMatch('#^[a-z]+$#', $rootId, 'Not a valid root-id'); return self::getRootPathById($rootId) . '/' . $destRelToRootId; } */ } private static function getDestination() { self::$checking = 'destination path'; if (self::$usingDocRoot) { $destination = self::getDestinationDocRoot(); } else { $destination = self::getDestinationNoDocRoot(); } SanityCheck::pregMatch('#\.webp$#', $destination, 'Does not end with .webp'); return $destination; } private static function processRequestNoTryCatch() { self::loadConfig(); $options = self::$options; $wodOptions = self::$wodOptions; $serveOptions = $options['webp-convert']; $convertOptions = &$serveOptions['convert']; //echo '
' . print_r($wodOptions, true) . ''; exit; // Validate that WebPExpress was configured to redirect to this conversion script // (but do not require that for Nginx) // ------------------------------------------------------------------------------ self::$checking = 'settings'; if (stripos($_SERVER["SERVER_SOFTWARE"], 'nginx') === false) { if (!isset($wodOptions['enable-redirection-to-webp-realizer']) || ($wodOptions['enable-redirection-to-webp-realizer'] === false)) { throw new ValidateException('Redirection to webp realizer is not enabled'); } } // Get destination // -------------------------------------------- self::$checking = 'destination'; // Decode URL in case file contains encoded symbols (#413) $destination = urldecode(self::getDestination()); //self::exitWithError($destination); // Validate source path // -------------------------------------------- $checking = 'source path'; $source = ConvertHelperIndependent::findSource( $destination, $wodOptions['destination-folder'], $wodOptions['destination-extension'], self::$usingDocRoot ? 'doc-root' : 'image-roots', self::$webExpressContentDirAbs, self::getImageRootsDef() ); //self::exitWithError('source:' . $source); //echo '