function getImagePath($fileUrl, $smarty) { // Store the image url $paths['fileUrl'] = $fileUrl; // The name of the file: image.jpg $paths['fileName'] = basename($fileUrl); // The paths to the document we are working with $scriptName = $smarty->_supers['server']['SCRIPT_NAME']; $paths['docPath'] = removeFileFromPath(removeDoubleSlashes(str_replace($smarty->_supers['server']['SCRIPT_NAME'], '', $smarty->_supers['server']['SCRIPT_FILENAME']) . '/' . $smarty->_supers['server']['REQUEST_URI'])); // The relative path to the document $docUri = $smarty->_supers['server']['REDIRECT_URL'] ? $smarty->_supers['server']['REDIRECT_URL'] : dirname($smarty->_supers['server']['SCRIPT_NAME']); $docUri = removeDoubleSlashes('/' . $docUri . '/'); // If we've got an absolute image url...make it relative! $fileUri = str_replace('http://' . $smarty->_supers['server']['HTTP_HOST'], '', $fileUrl); $fileUri = str_replace('https://' . $smarty->_supers['server']['HTTP_HOST'], '', $fileUri); if (substr($fileUri, 0, 1) == DIRECTORY_SEPARATOR) { $docSegments = explode(DIRECTORY_SEPARATOR, $docUri); $fileSegments = explode(DIRECTORY_SEPARATOR, $fileUri); // Cycle through the url segments, working back from the current url to the image url while (count($docSegments) || count($fileSegments)) { $docSegment = array_shift($docSegments); $fileSegment = array_shift($fileSegments); if ($docSegment != $fileSegment || $up) { $up = $docSegment ? '../' : ''; $relativeUri = $up . $relativeUri . $fileSegment . '/'; } } $fileUrl = rtrim($relativeUri, '/'); } // Get the actual path to the file on the server $filePath = '/' . get_absolute_path(removeDoubleSlashes($paths['docPath'] . '/' . $fileUrl)); // Make sure there is actually an image at that path if (!is_readable($filePath)) { echo "<!-- Imagesizer Error: Could not find the file {$filePath} -->"; return false; } // Calculate all the other paths we will need $pathInfo = pathinfo($filePath); $paths['filePath'] = $pathInfo['dirname']; $paths['fileExt'] = $pathInfo['extension']; $paths['fileBasename'] = $pathInfo['filename'] ? $pathInfo['filename'] : substr($paths['fileName'], 0, strrpos($paths['fileName'], '.')); $paths['fileSrc'] = removeDoubleSlashes($paths['filePath'] . '/' . $paths['fileName']); $paths['cachePath'] = removeDoubleSlashes($paths['filePath'] . '/cache/'); // Make sure the cache folder exists if (!is_dir($paths['cachePath'])) { // Try to create it if (!@mkdir($paths['cachePath'], 0777)) { echo "<!-- Imagesizer Error: Could not create cache directory. Please create {$paths['cachePath']} manually and try again. -->"; return false; } // Make sure it's really writable if (!is_writable($paths['cachePath'])) { echo '<!-- Imagesizer Error: The cache directory is not writeable -->'; return false; } } // The url to the cached image $paths['cacheUrl'] = removeDoubleSlashes('/' . get_absolute_path($docUri . '/' . dirname($fileUrl)) . '/cache/'); return $paths; }
function removeFileFromPath($file, $path, $deleteNot = array()) { $removed = 0; $cur = $path . '/' . $file; if (file_exists($cur)) { $del = true; foreach ($deleteNot as $dn) { if ($cur == $dn) { $del = false; } } if ($del) { unlink($cur); $removed++; } } if (!file_exists($path)) { return $removed; } $d = dir($path); while (false !== ($e = $d->read())) { // Fixed bug. !== is required to literally match the type and value of false, so that a filename that could evaluate and cast to false, ie "false" or "0", still allows the while loop to continue. From example at http://www.php.net/manual/en/function.dir.php $next = $path . '/' . $e; if (substr($e, 0, 1) != '.' && is_dir($next)) { $removed += removeFileFromPath($file, $next, $deleteNot); } } $d->close(); // from example at http://www.php.net/manual/en/function.dir.php return $removed; }
function removeFileFromPath($file, $path, $deleteNot = array()) { $removed = 0; $cur = $path . '/' . $file; if (file_exists($cur)) { $del = true; foreach ($deleteNot as $dn) { if ($cur == $dn) { $del = false; } } if ($del) { unlink($cur); $removed++; } } if (!file_exists($path)) { return $removed; } $d = dir($path); while ($e = $d->read()) { $next = $path . '/' . $e; if (substr($e, 0, 1) != '.' && is_dir($next)) { $removed += removeFileFromPath($file, $next, $deleteNot); } } return $removed; }
} if ($upgradeStepFile == 'end') { //if(isset($_SESSION['current_db_version']) && substr($_SESSION['current_db_version'],0,1) == 4){ ob_start(); include 'modules/ACL/install_actions.php'; include 'modules/Administration/RebuildRelationship.php'; //also add the cache cleaning here. if (function_exists('deleteCache')) { deleteCache(); } ob_end_clean(); if (isset($_SESSION['current_db_version']) && substr($_SESSION['current_db_version'], 0, 1) == 4) { //Remove footer from themes except default, love and link themes logThis('Start removing footer.php file from themes...'); $deleteNot = array('themes/default/footer.php', 'themes/Love/footer.php', 'themes/Links/footer.php'); removeFileFromPath('footer.php', 'themes', $deleteNot); logThis('End removing footer.php file from themes...'); } //} } require 'modules/UpgradeWizard/' . $upgradeStepFile . '.php'; $afterCurrentStep = $_REQUEST['step'] + 1; //// END LOGIC /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// UPGRADE HISTORY // display installed pieces and versions $installeds = $uh->getAll(); $upgrades_installed = 0; $uwHistory = '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view"><tr><td>' . $mod_strings['LBL_UW_DESC_MODULES_INSTALLED'] . "<br>\n"; $uwHistory .= "<ul>\n";