if (!isset($_REQUEST['version'])) {
    die($mod_strings['ERR_UW_NO_MODE']);
}
$version = $_REQUEST['version'];
if (!isset($_REQUEST['copy_count']) || $_REQUEST['copy_count'] == "") {
    die($mod_strings['ERR_UW_NO_FILES']);
}
if (!isset($_REQUEST['unzip_dir']) || $_REQUEST['unzip_dir'] == "") {
    die($mod_strings['ERR_UW_NO_TEMP_DIR']);
}
$unzip_dir = $_REQUEST['unzip_dir'];
if (empty($_REQUEST['install_file'])) {
    die($mod_strings['ERR_UW_NO_INSTALL_FILE']);
}
$install_file = hashToFile($_REQUEST['install_file']);
$install_type = getInstallType($install_file);
$id_name = '';
if (isset($_REQUEST['id_name'])) {
    $id_name = $_REQUEST['id_name'];
}
$s_manifest = '';
if (isset($_REQUEST['s_manifest'])) {
    $s_manifest = $_REQUEST['s_manifest'];
}
$previous_version = '';
if (isset($_REQUEST['previous_version'])) {
    $previous_version = $_REQUEST['previous_version'];
}
$previous_id = '';
if (isset($_REQUEST['previous_id'])) {
    $previous_id = $_REQUEST['previous_id'];
function validate_manifest($manifest)
{
    // takes a manifest.php manifest array and validates contents
    global $subdirs;
    global $sugar_version;
    global $sugar_flavor;
    global $mod_strings;
    if (!isset($manifest['type'])) {
        die($mod_strings['ERROR_MANIFEST_TYPE']);
    }
    $type = $manifest['type'];
    if (getInstallType("/{$type}/") == "") {
        die($mod_strings['ERROR_PACKAGE_TYPE'] . ": '" . $type . "'.");
    }
    if (isset($manifest['acceptable_sugar_versions'])) {
        $version_ok = false;
        $matches_empty = true;
        if (isset($manifest['acceptable_sugar_versions']['exact_matches'])) {
            $matches_empty = false;
            foreach ($manifest['acceptable_sugar_versions']['exact_matches'] as $match) {
                if ($match == $sugar_version) {
                    $version_ok = true;
                }
            }
        }
        if (!$version_ok && isset($manifest['acceptable_sugar_versions']['regex_matches'])) {
            $matches_empty = false;
            foreach ($manifest['acceptable_sugar_versions']['regex_matches'] as $match) {
                if (preg_match("/{$match}/", $sugar_version)) {
                    $version_ok = true;
                }
            }
        }
        if (!$matches_empty && !$version_ok) {
            die($mod_strings['ERROR_VERSION_INCOMPATIBLE'] . $sugar_version);
        }
    }
    if (isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0) {
        $flavor_ok = false;
        foreach ($manifest['acceptable_sugar_flavors'] as $match) {
            if ($match == $sugar_flavor) {
                $flavor_ok = true;
            }
        }
        if (!$flavor_ok) {
            die($mod_strings['ERROR_FLAVOR_INCOMPATIBLE'] . $sugar_flavor);
        }
    }
}
示例#3
0
 /**
  * Verifies a manifest from a patch or module to be compatible with the current Sugar version and flavor
  * @param array manifest Standard manifest array
  * @return string Error message, blank on success
  */
 function validate_manifest($manifest)
 {
     logThis('validating manifest.php file');
     // takes a manifest.php manifest array and validates contents
     global $subdirs;
     global $sugar_version;
     global $sugar_config;
     global $sugar_flavor;
     global $mod_strings;
     include_once 'suitecrm_version.php';
     if (!isset($manifest['type'])) {
         return $mod_strings['ERROR_MANIFEST_TYPE'];
     }
     $type = $manifest['type'];
     if (getInstallType("/{$type}/") == "") {
         return $mod_strings['ERROR_PACKAGE_TYPE'] . ": '" . $type . "'.";
     }
     if (isset($manifest['acceptable_php_versions'])) {
         $version_ok = false;
         $matches_empty = true;
         if (isset($manifest['acceptable_php_versions']['exact_matches'])) {
             $matches_empty = false;
             foreach ($manifest['acceptable_php_versions']['exact_matches'] as $match) {
                 if ($match == PHP_VERSION) {
                     $version_ok = true;
                 }
             }
         }
         if (!$version_ok && isset($manifest['acceptable_php_versions']['regex_matches'])) {
             $matches_empty = false;
             foreach ($manifest['acceptable_php_versions']['regex_matches'] as $match) {
                 if (preg_match("/{$match}/", PHP_VERSION)) {
                     $version_ok = true;
                 }
             }
         }
         if (!$matches_empty && !$version_ok) {
             return $mod_strings['ERROR_PHP_VERSION_INCOMPATIBLE'] . "<br />" . $mod_strings['ERR_UW_PHP_VERSION'] . PHP_VERSION;
         }
     }
     if (!isset($manifest['acceptable_suitecrm_versions'])) {
         // If sugarcrm version set 'acceptable_sugar_versions', and acceptable_suitecrm_versions not set check on sugar version.
         if (isset($manifest['acceptable_sugar_versions'])) {
             $version_ok = false;
             $matches_empty = true;
             if (isset($manifest['acceptable_sugar_versions']['exact_matches'])) {
                 $matches_empty = false;
                 foreach ($manifest['acceptable_sugar_versions']['exact_matches'] as $match) {
                     if ($match == $sugar_version) {
                         $version_ok = true;
                     }
                 }
             }
             if (!$version_ok && isset($manifest['acceptable_sugar_versions']['regex_matches'])) {
                 $matches_empty = false;
                 foreach ($manifest['acceptable_sugar_versions']['regex_matches'] as $match) {
                     if (preg_match("/{$match}/", $sugar_version)) {
                         $version_ok = true;
                     }
                 }
             }
             if (!$matches_empty && !$version_ok) {
                 return $mod_strings['ERROR_VERSION_INCOMPATIBLE'] . "<br />" . $mod_strings['ERR_UW_VERSION'] . $sugar_version;
             }
         } else {
             // if neither set reject
             return $mod_strings['ERROR_NO_VERSION_SET'];
         }
     } else {
         // If sugarcrm version set 'acceptable_sugar_versions', and acceptable_suitecrm_versions set check only on suitecrm version
         // If sugarcrm version not set 'acceptable_sugar_versions', and acceptable_suitecrm_versions set check only on suitecrm version
         $version_ok = false;
         $matches_empty = true;
         if (isset($manifest['acceptable_suitecrm_versions']['exact_matches'])) {
             $matches_empty = false;
             foreach ($manifest['acceptable_suitecrm_versions']['exact_matches'] as $match) {
                 if ($match == $suitecrm_version) {
                     $version_ok = true;
                 }
             }
         }
         if (!$version_ok && isset($manifest['acceptable_suitecrm_versions']['regex_matches'])) {
             $matches_empty = false;
             foreach ($manifest['acceptable_suitecrm_versions']['regex_matches'] as $match) {
                 if (preg_match("/{$match}/", $suitecrm_version)) {
                     $version_ok = true;
                 }
             }
         }
         if (!$matches_empty && !$version_ok) {
             return $mod_strings['ERROR_SUITECRM_VERSION_INCOMPATIBLE'] . "<br />" . $mod_strings['ERR_UW_SUITECRM_VERSION'] . $suitecrm_version;
         }
     }
     if (isset($manifest['acceptable_sugar_flavors']) && sizeof($manifest['acceptable_sugar_flavors']) > 0) {
         $flavor_ok = false;
         foreach ($manifest['acceptable_sugar_flavors'] as $match) {
             if ($match == $sugar_flavor) {
                 $flavor_ok = true;
             }
         }
         if (!$flavor_ok) {
             return $mod_strings['ERROR_FLAVOR_INCOMPATIBLE'] . "<br />" . $mod_strings['ERR_UW_FLAVOR'] . $sugar_flavor . "<br />" . $mod_strings['ERR_UW_FLAVOR_2'] . $manifest['acceptable_sugar_flavors'][0];
         }
     }
     return '';
 }