}
// check, if user has changed it to his domain
if ($tmp['domain'] == 'www.example.com' || $tmp['domain'] == 'www.heise.de' || empty($tmp['domain'])) {
    $tmp['domain'] = $_SERVER['HTTP_HOST'];
}
// check mandatory services array
if (!is_array($tmp["services"])) {
    $tmp["services"] = array("0" => "GooglePlus", "1" => "Twitter", "2" => "Facebook", "3" => "LinkedIn", "4" => "Reddit", "5" => "Flattr", "6" => "StumbleUpon", "7" => "Pinterest", "8" => "Xing", "9" => "Tumblr");
}
// force a short init because we only need WP core
define('SHORTINIT', true);
// build the wp-load.php path
$wp_root_path = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
// if wp-load.php doesn't exist at $wp_root_path, then search for it.
if (!file_exists($wp_root_path . '/wp-load.php')) {
    $wp_load = rsearch($wp_root_path, '/wp-load.php/');
    // set $wp_root_path to the location of wp-load.php
    $wp_root_path = $wp_load['path'];
}
// search in the subfolders of $wp_root_path for a given file (regex)
function rsearch($folder, $pattern)
{
    $dir = new RecursiveDirectoryIterator($folder);
    $iterator = new RecursiveIteratorIterator($dir);
    $files = new RegexIterator($iterator, $pattern, RegexIterator::GET_MATCH);
    $fileList = array();
    foreach ($files as $file) {
        $fileList[] = array('file' => $file, 'path' => $iterator->getPath());
    }
    // return only the first result
    return $fileList[0];
 if ($mageFile) {
     include $mageFile;
     $mageVersion = Mage::getVersionInfo();
     $mageEdition = Mage::getEdition();
     if ($mageEdition == Mage::EDITION_COMMUNITY) {
         $vanillaVersionPrefix = 'CE';
     } else {
         $vanillaVersionPrefix = 'EE';
     }
     $mageVersionString = $mageVersion['major'] . '.' . $mageVersion['minor'] . '.' . $mageVersion['revision'] . '.' . $mageVersion['patch'];
     $vanillaVersion = $vanillaVersionPrefix . '-' . $mageVersionString;
     if (!file_exists('./vanillas/' . $vanillaVersion)) {
         throw new RuntimeException(sprintf('The version %s is not available for comparison!', $vanillaVersion));
     }
     $vanillaMagentoFolder = realpath("./vanillas/" . $vanillaVersion);
     $appliedPatchesFile = rsearch('./tmp/', '/applied\\.patches\\.list/');
     if (!empty($appliedPatchesFile)) {
         $appliedPatches = getAppliedPatches($appliedPatchesFile);
         shell_exec('rm -rf ./vanillas/' . $vanillaVersion . '-patched');
         shell_exec('cp -R ./vanillas/' . $vanillaVersion . ' ./vanillas/' . $vanillaVersion . '-patched');
         foreach ($appliedPatches as $appliedPatch) {
             $patchFile = getPatchFile($appliedPatch, $vanillaVersionPrefix, $mageVersionString);
             if ($patchFile === null) {
                 $warnings[] = sprintf('Patch %s not found!', $appliedPatch);
             }
             shell_exec('cp ./vanillas/patches/' . $patchFile . ' ./vanillas/' . $vanillaVersion . '-patched/');
             shell_exec('cd ./vanillas/' . $vanillaVersion . '-patched/ && sh ' . $patchFile);
         }
         $vanillaMagentoFolder = './vanillas/' . $vanillaVersion . '-patched';
     }
     $mageRootFolder = realpath(dirname($mageFile) . '/../');
Exemple #3
0
 function rsearch($path)
 {
     $dirs = array();
     while (($file = readdir($dir)) !== false) {
         if ($file[0] == '.') {
             continue;
         } else {
             if (is_dir($path . "/" . $file)) {
                 if ($file == "nls") {
                     $dirs[] = $path . "/" . $nls;
                 } else {
                     $search = rsearch($path . "/" . $file);
                     $dirs = array_merge($dirs, $search);
                 }
             }
         }
     }
 }