\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /usr/local/lsws/admin/html.5.4.4/utility/build_php/

Viewing File: build_prepare.template

###########################################
#   passed params

DL_METHOD="__dl_method__"
ENABLE_MAILHEADER=__enable_mailheader__
LSAPI_VERSION=__lsapi_version__

###########################################

echo "============================================================="
main_msg "Preparing all source code for building PHP ${PHP_VERSION} with LSAPI ${LSAPI_VERSION}"
echo "============================================================="
echo `date`
echo ""

echo "Changing to build directory ${PHP_BUILD_DIR}" 
cd ${PHP_BUILD_DIR}
check_errs $? "Could not get into build directory"

if [ -e "php-${PHP_VERSION}" ] ; then
	rm -rf php-${PHP_VERSION}
	check_errs $? "Could not delete old php directory ${PHP_BUILD_DIR}/php-${PHP_VERSION}"
fi

test_phpsrc_ok()
{
	main_msg "Extracting PHP source archive: tar -zxf ${1}" 
	tar -zxf ${1}
	if [ "$?" -ne "0" ] ; then
		## remove bad copy
		rm -f ${1}
		main_msg "Could not extract PHP source archive"
		return 1
	fi
	return 0
}


PHP_SRC=php-${PHP_VERSION}.tar.gz
PHP_SRC_READY=N

if [ -e "${PHP_SRC}" ] ; then
	main_msg "${PHP_SRC} already downloaded, use the saved copy."
	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] && [ `expr ${PHP_VERSION} : ".*alpha\|.*beta\|.*RC"` -gt 0 ] ; then
	DOWNLOAD_URL="https://downloads.php.net/~ab/${PHP_SRC}"
	main_msg "Retrieving PHP source archive from ${DOWNLOAD_URL}" 
	${DL_METHOD} ${PHP_SRC} ${DOWNLOAD_URL}

	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] ; then
	DOWNLOAD_URL="http://php.net/distributions/${PHP_SRC}"
	main_msg "Retrieving PHP source archive from ${DOWNLOAD_URL}" 
	${DL_METHOD} ${PHP_SRC} ${DOWNLOAD_URL}

	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] ; then
	DOWNLOAD_URL="http://us1.php.net/distributions/${PHP_SRC}"
	main_msg "Retrieving PHP source archive from ${DOWNLOAD_URL}" 
	${DL_METHOD} ${PHP_SRC} ${DOWNLOAD_URL}

	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] ; then
	DOWNLOAD_URL="http://us2.php.net/distributions/${PHP_SRC}"
	main_msg "Retrieving PHP source archive from ${DOWNLOAD_URL}" 
	${DL_METHOD} ${PHP_SRC} ${DOWNLOAD_URL}

	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] ; then
	DOWNLOAD_URL="http://us3.php.net/distributions/${PHP_SRC}"
	main_msg "Retrieving PHP source archive from ${DOWNLOAD_URL}" 
	${DL_METHOD} ${PHP_SRC} ${DOWNLOAD_URL}

	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] ; then
	MAIN_VER=`expr "${PHP_VERSION}" : "\(.\)"`
	DOWNLOAD_URL="http://museum.php.net/php${MAIN_VER}/${PHP_SRC}"
	main_msg "Try again, retrieving PHP source archive from ${DOWNLOAD_URL}" 
	${DL_METHOD} ${PHP_SRC} ${DOWNLOAD_URL}

	test_phpsrc_ok ${PHP_SRC}
	if [ "$?" -eq "0" ] ; then
		PHP_SRC_READY=Y
	fi
fi

if [ "${PHP_SRC_READY}" = "N" ] ; then
	check_errs $? "Fail to retrieve PHP source archive. Please try manually download."
fi
	
echo ""


if [ "${ENABLE_MAILHEADER}" -eq 1 ] ; then

	MAILHEADER_VER=`expr ${PHP_VERSION} : "\(.\..\)"`
	if [ "${MAILHEADER_VER}" = "5.2" ] ; then
		MAILHEADER_VER=5.2.x
	elif [ "${MAILHEADER_VER}" = "5.3" ] ; then 
		MAILHEADER_VER=5.3.x
	elif [ "${MAILHEADER_VER}" = "5.4" ] ; then 
		MAILHEADER_VER=5.4.x
	elif [ "${MAILHEADER_VER}" = "5.5" ] ; then 
		MAILHEADER_VER=5.5.x
	elif [ "${MAILHEADER_VER}" = "5.6" ] ; then 
		MAILHEADER_VER=5.6.x
	else
		MAILHEADER_VER=${PHP_VERSION}
	fi
	
	MHPATCH="php-${MAILHEADER_VER}-mail-header.patch"
	
	if [ -e ${MHPATCH} ] ; then
		rm -f ${MHPATCH}
		check_errs $? "Could not delete old copy ${MHPATCH}"
	fi

	DOWNLOAD_URL="http://choon.net/opensource/php/${MHPATCH}"
	main_msg "Retrieving mail header patch from ${DOWNLOAD_URL}"
	${DL_METHOD} ${MHPATCH} ${DOWNLOAD_URL}
	check_errs $? "Could not retrieve mail header patch"
	echo ""
	
	main_msg "Patching source with mail header patch"
	cd php-${PHP_VERSION}
	patch -p1 < ../${MHPATCH}
	check_errs $? "Could not patch source with mail header patch"
	cd ..
	echo ""
fi

# get LSAPI

if [ -e php-litespeed-${LSAPI_VERSION}.tgz ] ; then
	rm -f php-litespeed-${LSAPI_VERSION}.tgz
	check_errs $? "Could not delete old lsapi copy php-litespeed-${LSAPI_VERSION}.tgz"
fi

DOWNLOAD_URL="http://www.litespeedtech.com/packages/lsapi/php-litespeed-${LSAPI_VERSION}.tgz"
main_msg "Retrieving LSAPI from ${DOWNLOAD_URL}"
${DL_METHOD} "php-litespeed-${LSAPI_VERSION}.tgz" ${DOWNLOAD_URL}
check_errs $? "Could not retrieve LSAPI archive"

cd php-${PHP_VERSION}/sapi
check_errs $? "Could not get into php/sapi directory"

if [ -e litespeed/Makefile.frag ] ; then
	mv -f litespeed/Makefile.frag litespeed/Makefile.frag.package 
fi

main_msg "Extracting LSAPI archive: tar -xzf php-litespeed-${LSAPI_VERSION}.tgz" 
tar -xzf "../../php-litespeed-${LSAPI_VERSION}.tgz"
check_errs $? "Could not extract LSAPI archive"

if [ -e litespeed/Makefile.frag.package ] ; then
	mv -f litespeed/Makefile.frag.package litespeed/Makefile.frag 
fi

echo ""
echo "============================================================="
main_msg "Finished gathering all source code for building PHP ${PHP_VERSION}"
echo "============================================================="
echo `date`
echo ""