HEX
Server: LiteSpeed
System: Linux 112.webhostingindonesia.co.id 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64
User: iyfwylsv (10313)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //proc/self/root/usr/local/psa/admin/sbin/fetch_url
#!/bin/bash
### Copyright 1999-2026. WebPros International GmbH. All rights reserved.

umask 022
output=`mktemp`
trap 'rm -f $output;' TERM INT EXIT

if [ -z "$output" ]; then
	echo "Cannot create temporary file for execution" >&2
	exit 1
fi

if [ -z "$1" ]; then
	echo "URL not specified" >&2
	exit 1
fi

http_code=`/usr/bin/curl -A "Plesk (fetch_url utility)" -sS -L -k -o "$output" -w "%{http_code}" "$1"`

if [ $? -ne 0 ]; then
	echo "Unable to fetch URL: $1" >&2
	exit 1
fi

# 2xx and 3xx are considered successful (however, 3xx shouldn't be present due to -L above)
rc=0
[ "$http_code" -ge 200 -a "$http_code" -lt 400 ] || rc=1

# In case of error all messages go to stderr
[ "$rc" -eq 0 ] || exec >&2

echo "Url '$1' fetched"
echo "Status: $http_code"
if [ -s "$output" ]; then
	echo "Output:"
	cat "$output"
fi
exit "$rc"