File manager - Edit - /usr/local/cpanel/whostmgr/docroot/templates/easyapache4/services/ea4Util.min.js
Back
define(["angular","cjt/util/locale","lodash","cjt/io/api","cjt/io/whm-v1-request","cjt/io/whm-v1","cjt/services/APIService"],(function(angular,LOCALE,_){"use strict";var app=angular.module("whm.easyapache4.ea4Util",[]);app.factory("ea4Util",["wizardState",function(wizardState){var util={eaRegex:/^ea-/i,phpVerRegex:/^ea-php(\d{2})$/i,phpExtRegex:/^ea-php(\d{2}-)/i,apacheVerRegex:/^ea-apache(\d{2})$/i,rubyVerRegex:/^ea-ruby(\d{2})/i,apacheModulesRegex:/^ea-apache(\d{2}-)/i,additionalPkgList:[],defaultMeta:{filterList:{},filterValue:"",isEmptyList:false,showPager:true,maxPages:0,totalItems:0,currentPage:1,pageSize:10,pageSizes:[10,20,50,100],start:0,limit:10},pkgActions:{removeList:[],addList:[],actionNeeded:false},vhostWarning:{exist:false,text:""},multiRequirements:{exist:false,orList:[],chosenPackage:""},autoSelectExt:{list:[],text:"",errorList:[],show:false,showError:false,showCommonExtensions:false},checkUpdateInfo:{isLoading:true,pkgNumber:0,btnText:LOCALE.maketext("Checking for updates …"),btnTitle:LOCALE.maketext("Checking for updates …"),btnCss:"btn-ea4-looking-updates disabled"}};util.cachedPrefixes=null;util.cachePrefixes=function(prefixes){util.cachedPrefixes=prefixes};util.getCachedPrefixes=function(){return util.cachedPrefixes||[]};util.cachedMetaInfo=null;util.cacheMetaInfo=function(metaInfo){util.cachedMetaInfo=metaInfo};util.getCachedMetaInfo=function(){return util.cachedMetaInfo||{}};util.getOutdatedLabel=function(){return LOCALE.maketext("Outdated")};util.isOutdatedPhpVersion=function(pkgName){if(PAGE&&PAGE.suppress_php_eol_status){return false}var metaInfo=util.getCachedMetaInfo();var oldestSupported=metaInfo.oldest_supported_version;if(!oldestSupported||!pkgName){return false}var phpVersionMatch=pkgName.match(/^([^-]+)-php(\d{2})(?:-|$)/i);if(!phpVersionMatch){return false}var prefix=phpVersionMatch[1].toLowerCase();if(prefix==="alt"){return false}var versionDigits=phpVersionMatch[2];var packageMajor=parseInt(versionDigits.charAt(0),10);var packageMinor=parseInt(versionDigits.charAt(1),10);var oldestParts=oldestSupported.split(".");var oldestMajor=parseInt(oldestParts[0],10);var oldestMinor=parseInt(oldestParts[1]||"0",10);if(packageMajor<oldestMajor){return true}if(packageMajor===oldestMajor&&packageMinor<oldestMinor){return true}return false};util.appendOutdatedLabel=function(displayName,pkgName,outdatedLabel){if(!util.isOutdatedPhpVersion(pkgName)){return displayName}if(!outdatedLabel){outdatedLabel=util.getOutdatedLabel()}if(displayName.indexOf(outdatedLabel)!==-1){return displayName}return displayName+" ("+outdatedLabel+")"};util.gatherAllRequirementsOfPkgs=function(pkgsToConsider,packageListDetails){var allRequires=[];_.each(pkgsToConsider,(function(pkg){if(!_.includes(allRequires,pkg)){var pkgInfo=packageListDetails[pkg];if(typeof pkgInfo!=="undefined"){var result=util.recurseForRequires(pkgInfo,pkg,allRequires,packageListDetails);if(result!==undefined){allRequires=result}}allRequires.push(pkg)}}));return allRequires};util.recurseForRequires=function(pkgInfo,origPkgName,allPkgList,packageListDetails){var pkgName=pkgInfo.package;var additionalPrefixes=util.getCachedPrefixes();var allPrefixes=["ea","alt"].concat(additionalPrefixes);var matchesAnyPrefix=_.some(allPrefixes,(function(prefix){return pkgName.startsWith(prefix+"-")}));if(!matchesAnyPrefix){return}if(_.includes(allPkgList,pkgName)){return}if(typeof origPkgName!=="undefined"&&pkgName!==origPkgName){allPkgList.push(pkgName)}var recurseArray=[];if(pkgInfo.pkg_dep.requires.length>0){recurseArray=_.clone(pkgInfo.pkg_dep.requires);recurseArray=_.filter(recurseArray,(function(pkg){if(typeof pkg!=="string"||_.isArray(pkg)){return false}var reqMatchesPrefix=_.some(allPrefixes,(function(prefix){return pkg.startsWith(prefix+"-")}));return reqMatchesPrefix}));recurseArray=_.difference(recurseArray,allPkgList)}_.forEach(recurseArray,(function(reqPkg){var reqPkgInfo=packageListDetails[reqPkg];if(typeof reqPkgInfo!=="undefined"){util.recurseForRequires(reqPkgInfo,origPkgName,allPkgList,packageListDetails)}}));return allPkgList};util.getFormattedPackageList=function(pkgList,regex){var formattedList=[];var additionalPrefixes=util.getCachedPrefixes()||[];var allPrefixes=["ea"].concat(additionalPrefixes);_.each(pkgList,(function(pkg){var formattedName;var pkgPrefix="ea";var match=_.find(allPrefixes,(function(prefix){return pkg.startsWith(prefix+"-")}));if(match){pkgPrefix=match}if(pkgPrefix==="ea"){formattedName=util._getReadableName(pkg,regex)}else{formattedName=pkg}formattedList.push(formattedName)}));return formattedList};util.getFormattedPackageName=function(pkg,regex){return util._getReadableName(pkg,regex)};util._getReadableName=function(pkg,replaceRegex){var strippedName=pkg;if(typeof replaceRegex!=="undefined"&&replaceRegex!==""){strippedName=pkg.replace(replaceRegex,"")}else{if(util.apacheModulesRegex.test(pkg)){strippedName=pkg.replace(util.apacheModulesRegex,"")}else{var additionalPrefixes=util.getCachedPrefixes()||[];var allPrefixes=["ea"].concat(additionalPrefixes);var prefixPattern="^("+allPrefixes.join("|")+")-";var prefixRegex=new RegExp(prefixPattern);if(prefixRegex.test(pkg)){strippedName=pkg.replace(prefixRegex,"")}else{strippedName=pkg}}}if(strippedName==="php"){strippedName="php (DSO)"}return strippedName};util.getProfilePackagesByCategories=function(pkgList){var pkgCategories=util._pkgByCategory(pkgList);return pkgCategories};util._pkgByCategory=function(pkgList){var categories={},apacheList=[],phpExtList=[],others=[],phpVersions=[],apacheVersion="";var apachePrefix="ea";var additionalPrefixes=util.getCachedPrefixes();var allPrefixes=["ea"].concat(additionalPrefixes);_.each(pkgList,(function(pkg){if(util.apacheVerRegex.test(pkg)){apacheVersion=pkg;var match=pkg.match(new RegExp("^("+allPrefixes.join("|")+")-apache"));if(match){apachePrefix=match[1]}}else if(util.apacheModulesRegex.test(pkg)){apacheList=_.concat(apacheList,pkg)}else if(util.phpVerRegex.test(pkg)){phpVersions=_.concat(phpVersions,pkg)}else if(util.phpExtRegex.test(pkg)){phpExtList=_.concat(phpExtList,pkg)}else{others=_.concat(others,pkg)}}));if(apacheList.length>0){apacheVersion=util._getReadableName(apacheVersion,util.eaRegex);var categoryKey=apachePrefix+"_"+apacheVersion;categories[categoryKey]={name:util.versionToString(apacheVersion),prefix:apachePrefix!=="ea"?apachePrefix:null,packages:util.getFormattedPackageListForProfile(apacheList,util.apacheModulesRegex)}}if(phpVersions.length>0){_.each(phpVersions.sort(),(function(version){var verRegex=new RegExp("^"+_.escapeRegExp(version)+"-");var extensions=_.filter(phpExtList,(function(pkg){return verRegex.test(pkg)}));phpExtList=_.difference(phpExtList,extensions);var phpversion=util._getReadableName(version,util.eaRegex);var phpPrefix="ea";var match=version.match(new RegExp("^("+allPrefixes.join("|")+")-php"));if(match){phpPrefix=match[1]}var categoryKey=phpPrefix+"_"+phpversion;var phpVersionName=util.versionToString(phpversion).replace("Php","PHP");var phpVersionOutdated=util.isOutdatedPhpVersion(version);categories[categoryKey]={name:phpVersionName,prefix:phpPrefix!=="ea"?phpPrefix:null,isOutdated:phpVersionOutdated,packages:util.getFormattedPackageListForProfile(extensions,util.phpExtRegex)}}))}if(others.length>0){categories["others"]={name:LOCALE.maketext("Additional Packages"),prefix:null,packages:util.getFormattedPackageListForProfile(others,/^ea-/)}}return categories};util.getFormattedPackageListForProfile=function(pkgList,regex){var formattedList=[];_.each(pkgList,(function(pkg){var formattedName=util._getReadableName(pkg,regex);formattedList.push(formattedName)}));return formattedList};util.versionToString=function(version){return version.replace(/^([a-z]+)(\d)(\d)$/,(function(match,p1,p2,p3){return _.capitalize(p1)+" "+p2+"."+p3}))};util.getPackageLabel=function(selected,state){var str="";if(selected){if(state==="updatable"){str="Update"}else if(state!=="installed"&&state!=="updatable"){str="Install"}else if(state==="installed"){str="Unaffected"}}else if(state==="installed"||state==="updatable"){str="Uninstall"}return str};util.getPackageClass=function(selected,state){var classString;if(selected){classString="callout";if(state==="updatable"){classString+=" callout-info"}else{classString+=" callout-success"}}else{if(state==="installed"||state==="updatable"){classString="callout callout-warning"}else{classString="no-callout"}}return classString};util.getDefaultMetaData=function(){return _.clone(util.defaultMeta)};util.getDefaultPageSizes=function(){return util.defaultMeta.pageSizes};util.getUpdatedMetaData=function(list,meta){if(typeof list!=="undefined"&&_.keys(list).length<=0){meta.isEmptyList=true;meta.totalItems=0;return meta}var searchStr=meta.filterValue;if(searchStr){var searchString=new RegExp(".*"+searchStr+".*","i");list=_.pickBy(list,(function(value,key){return searchString.test(value.package)||searchString.test(value.short_description)}))}var pkgKeys=_.keys(list);var pgSizes=util.getDefaultPageSizes();pgSizes=_.filter(pgSizes,(function(size){return size<=pkgKeys.length}));meta.pageSizes=pgSizes;var totalItems=pkgKeys.length;if(totalItems>_.min(pgSizes)){var startIdx=(meta.currentPage-1)*meta.pageSize;var endIdx=startIdx+meta.pageSize;endIdx=endIdx>totalItems?totalItems:endIdx;list=_.pick(list,_.slice(pkgKeys,startIdx,endIdx));meta.start=startIdx+1;meta.limit=endIdx;meta.showPager=true}else{meta.showPager=false;if(pkgKeys.length===0){meta.start=0}else{meta.start=1}meta.limit=pkgKeys.length}meta.totalItems=totalItems;meta.filterList=list;meta.isEmptyList=_.keys(meta.filterList).length<=0;return meta};util.getPageShowingText=function(meta){var newString="";if(meta&&typeof meta.start!=="undefined"&&typeof meta.limit!=="undefined"&&typeof meta.totalItems!=="undefined"){newString=LOCALE.maketext("[output,strong,Showing] [_1] - [_2] of [_3] items",meta.start,meta.limit,meta.totalItems)}return newString};util.getExtensionsForPHPVersion=function(version,pkgList){var testString=new RegExp(version+".*","i");var list=_.filter(pkgList,(function(name){return testString.test(name)}));return list};util.decideShowHideRecommendations=function(recommendations,pkgListToCheck,onSelect,pkg){_.each(recommendations,(function(reco){if(_.isUndefined(reco)){return}if(typeof onSelect!=="undefined"){if(onSelect){reco.show=reco.on==="add"}else{reco.show=reco.on==="remove"}}else{reco.show=false}if(reco.show){var pkgDisplayName=pkg;if(util.phpVerRegex.test(pkg)){pkgDisplayName=util._getReadableName(pkg,util.eaRegex);pkgDisplayName=util.versionToString(pkgDisplayName).replace("Php","PHP")}var localizedName=LOCALE.makevar(reco.name);reco.displayName=LOCALE.maketext("Recommendations for “[_1]”: [_2]",pkgDisplayName,localizedName);reco.desc=LOCALE.makevar(reco.desc);reco.showFootnote=false;var showReco=true;_.each(reco.options,(function(option){if(!_.isNil(option.recommended)){option.title=option.recommended?LOCALE.maketext("Recommended"):LOCALE.maketext("Not Recommended")}option.text=LOCALE.makevar(option.text);option.show=true;if(!_.isEmpty(option.items)){showReco=option.show=_.isEmpty(_.intersection(option.items,pkgListToCheck));if(!reco.showFootnote){reco.showFootnote=option.show}}else{option.show=showReco}}));reco.show=!_.every(reco.options,["show",false])}}));return recommendations};util.getExtensionsOfSelectedPHPVersions=function(pkgInfoList,currPkgInfoList,selectedPkgs){var extToConsider=[];var noPHPSelected=false;var allPhpVersions=_.filter(_.keys(pkgInfoList),(function(pkg){return util.phpVerRegex.test(pkg)})).sort();var versionsToConsider=_.filter(selectedPkgs,(function(pkg){return util.phpVerRegex.test(pkg)})).sort();if(!_.isEqual(allPhpVersions,versionsToConsider)){if(versionsToConsider.length>0){var workingExt=_.keys(currPkgInfoList);_.each(versionsToConsider,(function(ver){var testString=new RegExp(ver+".*","i");var verExt=_.remove(workingExt,(function(ext){return testString.test(ext)}));extToConsider=_.concat(extToConsider,verExt)}))}else{noPHPSelected=true}}else{versionsToConsider=allPhpVersions;extToConsider=_.keys(currPkgInfoList)}return{versions:versionsToConsider,extensions:extToConsider,noPHPSelected:noPHPSelected}};util.validateFilename=function(filename){var valData={valid:true,valMsg:""};if(/^\.{1,2}$/.test(filename)){valData.valid=false;valData.valMsg=LOCALE.maketext("Filename [output,strong,cannot] be “[output,strong,_1]”.",filename)}else if(/\/|\0/.test(filename)){valData.valid=false;valData.valMsg=LOCALE.maketext("Filename [output,strong,cannot] include the following characters: [list_and,_1]",["/","NUL"])}return valData};util.setupVhostWarning=function(pkgInfo,vhostsCount){pkgInfo.vhostWarning.exist=true;var localizedText=LOCALE.maketext("[quant,_1,virtual host currently uses,virtual hosts currently use] this version of PHP. If you remove this PHP version, your virtual hosts may not work properly.",vhostsCount);localizedText=localizedText.replace(/^(\d+)/,"<span class='vhost-emphasis'>$1</span>");pkgInfo.vhostWarning.text=localizedText;return pkgInfo};util.resetVhostWarning=function(pkgInfo){pkgInfo.vhostWarning=angular.copy(util.vhostWarning)};util.createTagsForActiveProfile=function(packages){var tags=[];var skipRuby=false;var foundPhpVersions=new Set;var additionalPrefixes=util.getCachedPrefixes()||[];var allPrefixes=["ea","alt"].concat(additionalPrefixes);var phpTagRegex=new RegExp("^("+allPrefixes.join("|")+")-php(\\d{2})$","i");var apacheTagRegex=new RegExp("^("+allPrefixes.join("|")+")-apache(\\d{2})$","i");var rubyTagRegex=new RegExp("^("+allPrefixes.join("|")+")-ruby(\\d{2})","i");_.each(packages,(function(pkg){var newTag;var apacheMatch=pkg.match(apacheTagRegex);if(apacheMatch){var apacheVersion=apacheMatch[2];newTag="Apache "+apacheVersion.replace(/(\d)(\d)$/,"$1.$2");tags=_.concat(tags,newTag)}else{var phpMatch=pkg.match(phpTagRegex);if(phpMatch){var phpPrefix=phpMatch[1];var phpVersion=phpMatch[2];var formattedVersion="PHP "+phpVersion.replace(/(\d)(\d)$/,"$1.$2");phpPrefix="ea";if(pkg.startsWith("alt-")){phpPrefix="alt"}else if(!pkg.startsWith("ea-")&&!pkg.startsWith("alt-")){phpPrefix=phpMatch[1]}var tagKey=phpPrefix.toLowerCase()+"-"+formattedVersion;if(!foundPhpVersions.has(tagKey)){foundPhpVersions.add(tagKey);if(phpPrefix.toLowerCase()==="alt"){if(!(PAGE&&PAGE.suppress_php_eol_status)){var securedTag=LOCALE.maketext("Secured");tags=_.concat(tags,formattedVersion+" (alt)("+securedTag+")")}else{tags=_.concat(tags,formattedVersion+" (alt)")}}else if(phpPrefix.toLowerCase()!=="ea"){var prefixedTag=formattedVersion+" ("+phpPrefix+")";prefixedTag=util.appendOutdatedLabel(prefixedTag,pkg,util.getOutdatedLabel());tags=_.concat(tags,prefixedTag)}else{var tagToAdd=util.appendOutdatedLabel(formattedVersion,pkg,util.getOutdatedLabel());tags=_.concat(tags,tagToAdd)}}}}var rubyMatch=pkg.match(rubyTagRegex);if(rubyMatch&&!skipRuby){var rubyVersion=rubyMatch[2];newTag="Ruby "+rubyVersion.replace(/(\d)(\d)$/,"$1.$2");tags=_.concat(tags,newTag);skipRuby=true}}));return tags};util.checkMPMRequirement=function(pkgData,resolvedData,selectedPkgs,whenSelected){var mpmRegex=/mod[-_]mpm/;var mpmInRemoveList=_.filter(_.uniq(resolvedData.removeList),(function(pkg){return mpmRegex.test(pkg)}));if(!whenSelected&&mpmRegex.test(pkgData.package)){mpmInRemoveList=_.union(mpmInRemoveList,[pkgData.package])}var subList=_.difference(selectedPkgs,mpmInRemoveList);var mpmIndexInRemove=_.findIndex(subList,(function(pkg){return mpmRegex.test(pkg)}));var mpmIndexInAdd=_.findIndex(resolvedData.addList,(function(pkg){return mpmRegex.test(pkg)}));if(mpmIndexInRemove===-1&&mpmIndexInAdd===-1){pkgData.mpmMissing=true;pkgData.mpmMissingMsg=LOCALE.maketext("Your selection removed [list_and,_1].",mpmInRemoveList)+" "+LOCALE.maketext("An [asis,MPM] package must exist on your system. Click “Continue” to select a new [asis,MPM] package.")+" "+LOCALE.maketext("Click “Cancel” to cancel this operation.");pkgData.actions.actionNeeded=false}return pkgData};util.getCommonlyInstalledExtensions=function(allExtensions,installedPhpVersions){var installedExt=_.map(_.filter(allExtensions,["selectedPackage",true]),"package");var extGroupByVersions=[];_.each(installedPhpVersions,(function(version,index){extGroupByVersions[index]=_.chain(installedExt).filter((function(ext){return _.startsWith(ext,version)})).map((function(ext){return _.replace(ext,util.phpExtRegex,"")})).value()}));var commonExtensions=[];if(extGroupByVersions.length===1){commonExtensions=extGroupByVersions[0]}else{var normalizeForComparison=function(ext){return ext.indexOf("php-")===0?ext.substring(4):ext};var normalizedGroups=_.map(extGroupByVersions,(function(group){var map={};_.each(group,(function(ext){var normalizedName=normalizeForComparison(ext);if(!map[normalizedName]||ext.indexOf("php-")===0){map[normalizedName]=ext}}));return map}));var commonNormalized=_.keys(normalizedGroups[0]);for(var i=1;i<normalizedGroups.length;i++){commonNormalized=_.intersection(commonNormalized,_.keys(normalizedGroups[i]))}commonExtensions=_.map(commonNormalized,(function(normalizedName){for(var j=0;j<normalizedGroups.length;j++){var original=normalizedGroups[j][normalizedName];if(original&&original.indexOf("php-")===0){return original}}return normalizedGroups[0][normalizedName]}))}var excludeList=["php","scldevel"];_.pullAll(commonExtensions,excludeList);return commonExtensions};util.doRubyPkgsExist=function(pkgList){return _.some(pkgList,(function(pkg){return util.rubyVerRegex.test(pkg.package)}))};util.updateRegexForPrefixes=function(additionalPrefixes){var allPrefixes=["ea"].concat(additionalPrefixes||[]);var prefixPattern="("+allPrefixes.join("|")+")";util.eaRegex=new RegExp("^("+allPrefixes.join("|")+")-","i");util.phpVerRegex=new RegExp("^"+prefixPattern+"-php(\\d{2})$","i");util.phpExtRegex=new RegExp("^"+prefixPattern+"-php(\\d{2}-)","i");util.apacheVerRegex=new RegExp("^"+prefixPattern+"-apache(\\d{2})$","i");util.apacheModulesRegex=new RegExp("^"+prefixPattern+"-apache(\\d{2}-)","i");util.rubyVerRegex=new RegExp("^"+prefixPattern+"-ruby(\\d{2})","i")};util.doAdditionalPkgsExist=function(additionalPkgsList,pkgList){return _.some(additionalPkgsList,(function(addlPkg){return _.includes(_.keys(pkgList),addlPkg)}))};util.showFooter=function(){wizardState.showFooter=true};util.hideFooter=function(){wizardState.showFooter=false};return util}])}));
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings