Обновлена логика загрузки index.php
This commit is contained in:
58
install.sh
58
install.sh
@@ -314,55 +314,23 @@ echo "</html>";
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! curl -f -s --max-time 10 --head "$DOWNLOAD_URL" >/dev/null 2>&1; then
|
find "$WEBROOT" -type f ! -name "db_config.php" -delete 2>/dev/null || true
|
||||||
create_fallback_index
|
|
||||||
else
|
if curl -f -L --max-time 30 -o "$WEBROOT/index.php" "$DOWNLOAD_URL" 2>/dev/null; then
|
||||||
find "$WEBROOT" -type f ! -name "db_config.php" -delete 2>/dev/null || true
|
if ! head -n 1 "$WEBROOT/index.php" | grep -q "<?php" && ! grep -q "<?php" "$WEBROOT/index.php" 2>/dev/null; then
|
||||||
|
|
||||||
if curl -f -L --max-time 30 -o "$TEMP_DOWNLOAD" "$DOWNLOAD_URL" 2>/dev/null; then
|
|
||||||
|
|
||||||
FILE_TYPE=$(file -b "$TEMP_DOWNLOAD" 2>/dev/null || echo "unknown")
|
|
||||||
|
|
||||||
if file "$TEMP_DOWNLOAD" | grep -qi "zip\|archive"; then
|
|
||||||
if unzip -q "$TEMP_DOWNLOAD" -d "$WEBROOT" 2>/dev/null; then
|
|
||||||
true
|
|
||||||
else
|
|
||||||
unzip -o "$TEMP_DOWNLOAD" -d "$WEBROOT" >/dev/null 2>&1 || create_fallback_index
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif file "$TEMP_DOWNLOAD" | grep -qi "gzip"; then
|
|
||||||
if gunzip -c "$TEMP_DOWNLOAD" > "$WEBROOT/index.php" 2>/dev/null; then
|
|
||||||
true
|
|
||||||
else
|
|
||||||
create_fallback_index
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif head -n 1 "$TEMP_DOWNLOAD" | grep -q "<?php\|<!DOCTYPE\|<html"; then
|
|
||||||
cp "$TEMP_DOWNLOAD" "$WEBROOT/index.php"
|
|
||||||
|
|
||||||
elif head -n 1 "$TEMP_DOWNLOAD" | grep -q "{"; then
|
|
||||||
create_fallback_index
|
|
||||||
|
|
||||||
else
|
|
||||||
if head -10 "$TEMP_DOWNLOAD" | grep -qi "error\|404\|403\|500\|<title"; then
|
|
||||||
create_fallback_index
|
|
||||||
else
|
|
||||||
cp "$TEMP_DOWNLOAD" "$WEBROOT/index.php"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$TEMP_DOWNLOAD"
|
|
||||||
|
|
||||||
else
|
|
||||||
if curl -L -k --user-agent "Mozilla/5.0 (Linux) Setup Script" --max-time 30 -o "$TEMP_DOWNLOAD" "$DOWNLOAD_URL" 2>/dev/null; then
|
|
||||||
cp "$TEMP_DOWNLOAD" "$WEBROOT/downloaded_file"
|
|
||||||
rm -f "$TEMP_DOWNLOAD"
|
|
||||||
fi
|
|
||||||
|
|
||||||
create_fallback_index
|
create_fallback_index
|
||||||
|
log_error "Скачанный файл не является PHP-скриптом, создана резервная страница"
|
||||||
|
else
|
||||||
|
log_success "Файл index.php успешно загружен"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
create_fallback_index
|
||||||
|
log_error "Не удалось загрузить файл с $DOWNLOAD_URL, создана резервная страница"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chown $WEBSERVER_USER:$WEBSERVER_USER "$WEBROOT/index.php"
|
||||||
|
chmod 644 "$WEBROOT/index.php"
|
||||||
|
|
||||||
cat > "$WEBROOT/.htaccess" << 'EOF'
|
cat > "$WEBROOT/.htaccess" << 'EOF'
|
||||||
<Files "db_config.php">
|
<Files "db_config.php">
|
||||||
Require all denied
|
Require all denied
|
||||||
|
|||||||
Reference in New Issue
Block a user