-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpatchwhmcsgc
executable file
·99 lines (77 loc) · 3.14 KB
/
patchwhmcsgc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# WHMCS 5.1 Google Checkout Module Patch
# http://forum.whmcs.com/showthread.php?64778-Security-Advisory
# This script will download and patch the Google Checkout module for WHMCS versions 5.1
# Additional Features to come soon ...
# Copyright (c) 2012 Myles McNamara <[email protected]>
# This script is licensed under GNU GPL version 3.0 or above
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# -------------------------------------------------------------------------
# Last updated on : 12/04/2012
# -------------------------------------------------------------------------
# ZIPFILEPATH is the path to download the patch, zip format
ZIPFILEPATH="http://www.whmcs.com/members/dl.php?type=d&id=154"
# ZIPFILE is the full name of the ZIP file
ZIPFILE="whmcs_v513_patch.zip"
# ZIPMD5 is the MD5 of the ZIP file, skip md5 check with -s flag (not implimented yet)
ZIPMD5="68f3104d01b0c55ee1f938b09564bb7b"
LASTMODIFIED="12.04.2012"
# Functions
function line {
echo "=----------------------------------------------------------------------------="
}
function enter {
read -p "Press [enter] to continue ..."
}
function ayesno {
echo -n "$1 ? (n) "
read answer
case "$answer" in
Y|y|yes|YES|Yes) echo "File removed..."; return 0 ;;
*) echo "File not removed..."; return 1 ;;
esac
}
clear
line
echo -e "WHMCS Google Checkout Security Patch Update Script v1.0\nCreated by Myles McNamara ([email protected]) http://smyl.es\nLast Modified: $LASTMODIFIED"
line
if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then
echo "Usage: $0 [whmcs-path]" >&2
exit
fi
WHMCSPATH="$1"
# Remove trailing slash if entered
WHMCSPATH=${1%/}
# Check if directory from user input exists
if [ ! -d "$WHMCSPATH" ]; then
echo -e "\n$WHMCSPATH does NOT exist, are you sure you entered it correctly?\n"
exit
fi
enter
# Download security patch
line
echo -e "\nAttempting to download $ZIPFILE from\n$ZIPFILEPATH ...\n"
curl -o "$WHMCSPATH/$ZIPFILE" "$ZIPFILEPATH"
line
# Check if download succeded
if [ ! -f "$WHMCSPATH/$ZIPFILE" ]; then
echo -e "\n$ZIPFILE did not download from \n$ZIPFILEPATH\ncheck the ZIPFILEPATH in the script"
else
echo -e "\n$ZIPFILE download completed:\n$WHMCSPATH/$ZIPFILE\n"
fi
line
enter
# Extract specific files from zipfile and extract them to overwrite existing files
unzip -j "$WHMCSPATH/$ZIPFILE" "whmcs/modules/gateways/callback/googlecheckout.php" -d "$WHMCSPATH/modules/gateways/callback"
unzip -j "$WHMCSPATH/$ZIPFILE" "whmcs/dbconnect.php" -d "$WHMCSPATH"
ayesno "Would you like to remove the zip file?" && rm -rf "$WHMCSPATH/$ZIPFILE"
ayesno "Would you like to remove this script file as well?" && rm -rf $0
echo -e "\nPatch complete. Thank you come again.\n"