#!/bin/bash -a
# getflash 0.5 original code by technosaurus and by Barry K. http://bkhome.org/blog/?viewDetailed=01897
# 13 Nov 2011 01micko http://www.murga-linux.com/puppy/viewtopic.php?t=72805&start=201
# v0.6 - 21 Dec 2011 shinobar: puppy version independent (may work 4.0 and later), flashblock checkbox, registration, i18n
# v0.8 - 11 Jan 2012 shinobar: flashplayer version info (stu90), fix was not able to uninstall
# v0.9 - 25 Mar 2012 shinobar: fix was the ownership under /usr messing up
# v0.9.9 -  3 May 2012 shinobar: version choice, jwm -reload for no flicker(01mico)
# v1.0 - 5 May 2012 shinobar: flashplayer11-11.2.202.228, insert sudo line
# v1.1 - 9 Jun 2012 shinobar: URL changed, download size
# v1.2 - 21 Jul 2012 shinobar: fix download pets,flashplayer10.3.183.23
# v1.3 - 8 Oct 2013: change adobe url (ETP), forum URL by OscarTalks
# v1.4 - 23 Nov 2013: fix was always offer flashblock
# v1.5 - 4 Feb 2014: flashplayer10-10.3.183.90 from smokey01.com
#150305 BK adobe site now https:. fix pet repo. fix register with ppm.
#150310 BK: weird, some testers report that http: only works. test for either.
#150311 BK: Argolance: bug fixes. refer: http://murga-linux.com/puppy/viewtopic.php?p=833174#833174
#150311 yaf-splash (gtkdialog-splash) is deprecated in Quirky, in favour of 'popup'
#150315 ASRI: try to improve main GUI, improve gettext, add conf file. And more...
#150325 ASRI: substitute "strings" with "busybox strings" (Barry proposal)

AppVersion=1.5-6


## ANL = Application Name writing Lowercase => to be use in different parts of the script
ANL01="getflash"


## Get language settings (gettext method)
export TEXTDOMAIN=getflash
export TEXTDOMAINDIR=/usr/share/locale
export OUTPUT_CHARSET=UTF-8
LANG_USER=$LANG


## Application : name
AppTitle01="$(gettext 'GetFlashPlayer')"
AppTitle02="$(gettext '(get Flash player plugin)')"
AppTitle="$AppTitle01 $AppTitle02"


## Get Application dir (zigbert method)
APPDIR="`dirname $0`"
[ "$APPDIR" = "." ] && APPDIR="`pwd`"
export APPDIR="$APPDIR"
export APPDIR=`dirname $0`
[ $APPDIR = '.' ] && export APPDIR=`pwd`


## Check version of flash player installed
if [ ! -f /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so ];then
  FLASHVERSION="0"
  TEXT=$(gettext "Currently, Flash player is not installed.")
  TEXT2=$(gettext "Note: currently, flash player is not installed.")
else
  FLASHVERSION=$(busybox strings -n13 /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so  | grep 'FlashPlayer_' | cut -d '_' -f2-5| tr '_' '.')
  echo "INSTALLED=$FLASHVERSION" >&2
  TEXT=$(gettext "Currently, Flash player v%s is installed.")
  TEXT=$(printf "$TEXT" "$FLASHVERSION")
  TEXT2=$(gettext "Note: currently, Flash player v%s is installed.")
  TEXT2=$(printf "$TEXT2" "$FLASHVERSION")
fi


## Check data and variables/settings for script 
. /etc/DISTRO_SPECS
APP_CONF="/usr/sbin/$ANL01-conf"
. $APP_CONF


## Define messages for script
T_title="$AppTitle01 v$AppVersion"
WAIT_PLS=$(gettext "Please wait...")
_WHICH=$(gettext "Select the version to install")
_UNABLE_INTERNET="$(gettext 'No internet connection founded, please check your configuration, then restart') $AppTitle01.

$TEXT2"
_UNABLE_SERVER="$(gettext 'Unable to contact the server, please check your internet connection, then restart') $AppTitle01.

$TEXT2"


## Test processor arch
ARCH=$(uname -m)
lsuffix=
case "$ARCH" in #01micko, support 64 bit. 150305 BK now https: 150310 maybe either:
 i?86)CHECKURL=$CHECKURL_32
      FORUMURL=$FORUMURL_FLASKPKGS_32
 ;;
 *64)CHECKURL=$CHECKURL_64
     lsuffix=64
 ;;
 *)exit 1
 ;;
esac


## Various tests/configs
[ "$UID" != "0" ] && which sudo &>/dev/null exec sudo $0

[ "$HOME" ] || HOME='/root'


## Check gtkdialog version
GTKDIALOG=gtkdialog3
which gtkdialog4 &>/dev/null && GTKDIALOG=gtkdialog4


## Various tests to define applications used
#for P in $BROWSER defaultbrowser seamonkey firefox $DEFAULTBROWSER; do
  #which $P &>/dev/null && MYBROWSER=$P && break
#done
MYBROWSER=defaultbrowser # defaulthtmlviewer is possible

RXVT=urxvt
which $RXVT &>/dev/null || RXVT=rxvt
TERMCONF="$RXVT -bg orange -geometry 80x4 -e"









#### Function part

export X1PID=""

#150311 yaf-splash (gtkdialog-splash) is deprecated in Quirky, in favour of 'popup'
POPUPFLAG=0
[ `which popup` ] && POPUPFLAG=1
#[ `which popadd` ] || POPUPFLAG=0


mysplash() {
  if [ $POPUPFLAG -eq 1 ];then #150311
   [ `pidof popup` ] && killall popup #popadd 'name=gfpop terminate=now|'
  else
	[ "$X1PID" ] && kill $X1PID
	killall yaf-splash &>/dev/null
	X1PID=""
	BGCOLOR="orange"
	MYICON="gtk-info"
	TIMEOUT=50
  fi
  while [ "$1" ]; do
	case "$1" in
	-*stop) return;;
	-*bg) shift; BGCOLOR=$1; shift;;
	-*timeout) shift; TIMEOUT=$1; shift;;
	-*icon) shift; MYICON=$1; shift;;
	-*text) shift;;
	-*) shift; shift;;
	*) break;;
	esac
  done
  if [ $POPUPFLAG -eq 1 ];then #150311
   case $BGCOLOR in #hack
    yellow)    BACKCOL='#FFFF00' ;;
    LightPink|hotpink) BACKCOL='#FF30FF' ;;
    orange)    BACKCOL='#FFB030' ;;
    *)         BACKCOL='#FFFF00' ;;
   esac
   LANG=$LANG_USER popup "name=gfpop placement=center fontname='Sans 14' background=${BACKCOL} terminate=${TIMEOUT} level=top|${@}" #daemonizes
  else
	if which gtkdialog-splash &>/dev/null ; then
	  LANG=$LANG_USER gtkdialog-splash -fontsize "large" -icon $MYICON -placement center -bg $BGCOLOR -timeout $TIMEOUT -close never -text "$@" & #150311
	else
	  LANG=$LANG_USER gxmessage -center -wrap -bg $BGCOLOR -title "$T_title" -buttons ''  -timeout $TIMEOUT -nofocus "$@" &
	fi
	X1PID=$!
  fi
}
mysplash -bg yellow "$WAIT_PLS"


internet_status() {
  LANG=C route | grep -q 'default[ ].*[ ]0\.0\.0\.0[ ]' && grep -wq 'nameserver' /etc/resolv.conf #&& ping -c1 google.com &>/dev/null
}


help_gui() {
Xdialog --title "$T_title" --left --wrap --msgbox "$(gettext 'This utility allows to install the Flash player plugin.

Technical notes:
- Flash player plugin is used by web browsers installed in your system.
- Flash player plugin is saved in folder /usr/lib/mozilla/plugins.
- Latest Flash player is not compatible with some old CPU, in this case choose older version of the plugin.
- The latest version of Flash player is downloaded directly from the Adobe server ; older versions of Flash Player are downloaded from servers of Puppy users.

For expert users:
- If need, you can edit manualy the configuration file of GetFlashPlayer (/usr/sbin/getflash-conf).

Licence: Flash Player is a proprietary software proposed by the Adobe company. You can consult the general terms at http://www.adobe.com/legal/general-terms.html')" 0 100
}


## Check Internet connection, define messages, then start main GUI
   #mysplash -bg yellow "$WAIT_PLS"
    if ! internet_status; then
      #mysplash -bg hotpink -timeout 5 -icon gtk-dialog-error "$_UNABLE_INTERNET"
      mysplash --stop
      Xdialog --title "$T_title" --left --wrap --msgbox "$_UNABLE_INTERNET" 0 80
      exit 1
    fi

     #111113 changed url, scrapped ping
     #DOWNLOADURL="`curl -s 'http://get.adobe.com/flashplayer/completion/?installer=Flash_Player_11_for_other_Linux_(.tar.gz)_32-bit'|tr ' ' '\n'|grep fpdownload|tr -d ';'`"
     #v1.1: CHECKURL, grep -o
     #DOWNLOADURL=$(curl -s "$CHECKURL" | grep -o 'http://fpdownload.*inux.i386.tar.gz')
     
     case "$ARCH" in #150305 now https
      i?86)DOWNLOADURL=$(curl -s "https${CHECKURL}" | grep -o 'http.://fpdownload.*inux.i386\.tar\.gz') ;;
      *64)DOWNLOADURL=$(curl -s "https${CHECKURL}" | grep -o 'http.://fpdownload.*inux.x86_64\.tar\.gz') ;;
     esac
     if [ ! "$DOWNLOADURL" ];then #150310
      case "$ARCH" in
       i?86)DOWNLOADURL=$(curl -s "http${CHECKURL}" | grep -o 'http.://fpdownload.*inux.i386\.tar\.gz') ;;
       *64)DOWNLOADURL=$(curl -s "http${CHECKURL}" | grep -o 'http.://fpdownload.*inux.x86_64\.tar\.gz') ;;
      esac
     fi
     if [ ! "$DOWNLOADURL" ];then 
      #mysplash -bg hotpink -timeout 5 -icon gtk-dialog-error "$_UNABLE_SERVER"
      mysplash --stop
      Xdialog --title "$T_title" --left --wrap --msgbox "$_UNABLE_SERVER" 0 80
      exit 1
     fi
    echo "$DOWNLOADURL" >&2
     NEWVERSION=$(dirname "$DOWNLOADURL")
     NEWVERSION=$(basename "$NEWVERSION")
     echo "NEWVERSION=$NEWVERSION"
     #v1.1 download size
     LENGTH=$(curl -s -I "$DOWNLOADURL" | grep -i 'Content-Length:' | cut -s -f2 -d':'| tr -dc '0-9') || LENGTH=0
     NEWMB=$((($LENGTH + 52429) / 104858))
     if [ $NEWMB -gt 0 ] ; then
       L=$(echo -n $NEWMB | wc -c)
       M=$(($L -1))
       NEWMB="$(echo $NEWMB -n | cut -c-$M).$(echo -n $NEWMB | cut -c$L) $(gettext 'MB')"
     else
      #NEWMB='---' #150311
      NEWMB="$(gettext "unknown size")"
     fi
#DOWNTEXT=$(gettext "Click the 'Yes' button to download and install FlashPlayer-%s (6MB).")
#DOWNTEXT=$(printf "$DOWNTEXT" "$NEWVERSION")
  if [ "$FLASHVERSION" = "$NEWVERSION" ]; then
    TEXT="$TEXT $(gettext "This is the latest version available, so you do not need to update it.")"
  else
    TEXT="$TEXT $(gettext "It is recommended to install the latest version available") (v$NEWVERSION)."
  fi


update_conf_file() {
cd /tmp
$TERMCONF wget -L "$CONFFILE_URL"
sleep 2 # may be need for slower computers

if [ ! -f /tmp/getflash-conf ]; then
Xdialog --title "$T_title" --left --wrap --msgbox "$(gettext 'No configuration file was found on the server. Please try again later.
If the problem persists permanently, thank you to report on the GetFlashPlayer forum.')" 0 100
	else
	mv -f "/tmp/getflash-conf" "$APPDIR/getflash-conf"
fi
}











#### GUI part

## Define messages, icons and size of GUI
MAIN_ICON="flash-player-properties"
FLASH_ICON="/usr/share/doc/flashlogo.gif"
MAIN_ICON_WIDTH1="60"
TEXT_WIDTH_CHARS1="10"
TEXT_WIDTH1="500"
SEE_TITLE=$(gettext "Find more on forums")
SEE_MSG_01_32=$(gettext "Flash player packages")
SEE_MSG_01_64=$(gettext "No 64-bit package available in forum.")
SEE_MSG_02=$(gettext "GetFlashPlayer utility")
SEE_LABEL=$(gettext "Forum")
SEE_INSTALL=$(gettext "Install")
SEE_INSTALL_TOOLTIP=$(gettext "Install selected version.")
SEE_HELP_TOOLTIP=$(gettext "Consult help for GetFlashPlayer.")
SEE_EDITCONF_TOOLTIP=$(gettext "For expert users! Use default text editor to edit configuration file of GetFlashPlayer. Note: after edit, you will need to click on Refresh button to update informations (available versions of Flash player).")
SEE_REFRESH_TOOLTIP=$(gettext "Restart GetFlashPlayer to refresh informations (available versions of Flash player).")
SEE_UPDATECONF_TOOLTIP=$(gettext "Update configuration file of GetFlashPlayer. It is need if last version of Flash player is not detected. If this does not work, thank you to report on the GetFlashPlayer forum.")
SEE_QUITAPP_TOOLTIP=$(gettext "Quit GetFlashPlayer.")
SEE_FORUM_TOOLTIP=$(gettext "Use the web browser to consult the forum.")
SEE_LICENSE_TOOLTIP=$(gettext "Use the web browser to consult general terms about Adobe flash player.")
SEE_FORUM=


## Check if libstardust (zigbert prod) is installed
CHECK_LIBSTARDUST="/usr/lib/gtkdialog/xml_scalegrip"
if [ ! -f "$CHECK_LIBSTARDUST" ]; then
SCALEGRIP=""
	else
	SCALEGRIP="`/usr/lib/gtkdialog/xml_scalegrip`"
fi


## Define forum buttons
if [ "$FORUMURL_FLASKPKGS_32" ]; then
 if [ "$DISTRO_TARGETARCH" == "x86" ];then #150305
  SEE_FORUM='<frame '$SEE_TITLE'>
  <hbox><text><label>"'$SEE_MSG_01_32'"</label></text>
  <button tooltip-text="'$SEE_FORUM_TOOLTIP'"><input file stock="gtk-network"></input><label>"'$SEE_LABEL'"</label>
  <action>'$MYBROWSER' '$FORUMURL_FLASKPKGS_32' &</action>
  </button></hbox>
  <hbox><text><label>"'$SEE_MSG_02'"</label></text>
  <button tooltip-text="'$SEE_FORUM_TOOLTIP'"><input file stock="gtk-network"></input><label>"'$SEE_LABEL'"</label>
  <action>'$MYBROWSER' '$FORUMURL_GETFLASHAPP' &</action>
  </button></hbox>
  </frame>'
 else
  SEE_FORUM='<frame '$SEE_TITLE'>
  <text><label>"'$SEE_MSG_01_64'"</label></text>
  <hbox><text><label>"'$SEE_MSG_02'"</label></text>
  <button tooltip-text="'$SEE_FORUM_TOOLTIP'"><input file stock="gtk-network"></input><label>"'$SEE_LABEL'"</label>
  <action>'$MYBROWSER' '$FORUMURL_GETFLASHAPP' &</action>
  </button></hbox>
  </frame>'
 fi
fi


## Define arch to select available packages
      _V11X="flashplayer11-$NEWVERSION ($NEWMB) - $(gettext "Latest version available")"
      case "$ARCH" in
        i?86)RADIOBTNS='<radiobutton><label>'$_V11_name' ('$_V11_size' '$(gettext "MB")')</label><variable>V11</variable></radiobutton>
        <radiobutton><label>'$_V10_name' ('$_V10_size' '$(gettext "MB")')</label><variable>V10</variable></radiobutton>
        <radiobutton><label>'$_V9_name' ('$_V9_size' '$(gettext "MB")')</label><variable>V9</variable></radiobutton>'
      esac
      #LANG=C Xdialog --center --title "Adobe Flash Player" --icon "/usr/share/doc/flashlogo.gif" --yesno "$TEXT" 0 0
      export FDLG='<window title="'$T_title'" icon-name="'$MAIN_ICON'">
      <vbox>
      <hbox>
      <pixmap><width>"'$MAIN_ICON_WIDTH1'"</width><input file>"'$FLASH_ICON'"</input></pixmap>
      <text width-chars="'$TEXT_WIDTH_CHARS1'" width-request="'$TEXT_WIDTH1'"><label>'"$TEXT"'</label></text>
      </hbox>
      <frame '$_WHICH'>
        <radiobutton><label>'$_V11X'</label><variable>V11X</variable></radiobutton>
        '$RADIOBTNS'
		<hbox>
		<button tooltip-text="'$SEE_INSTALL_TOOLTIP'">
		<label>'"$SEE_INSTALL"'</label>
		<input file stock="gtk-apply"></input>
		<action type="exit">OK</action>
		</button>
		</hbox>
      </frame>
        '$SEE_FORUM'
		<hbox>
		<button tooltip-text="'$SEE_HELP_TOOLTIP'">
		<input file stock="gtk-help"></input>
		<action>help_gui &</action>
		</button>
		<button tooltip-text="'$SEE_LICENSE_TOOLTIP'">
		<input file stock="gtk-info"></input>
		<action>$MYBROWSER $ADOBE_GENERAL_TERMS &</action>
		</button>
		<button tooltip-text="'$SEE_REFRESH_TOOLTIP'">
		<input file stock="gtk-refresh"></input>
		<action>$APPDIR/$ANL01 &</action>
		<action>exit:ok</action>
		</button>
		<button tooltip-text="'$SEE_UPDATECONF_TOOLTIP'">
		<input file stock="gtk-network"></input>
		<action>update_conf_file</action>
		<action>$APPDIR/$ANL01 &</action>
		<action>exit:ok</action>
		</button>
		<button tooltip-text="'$SEE_EDITCONF_TOOLTIP'">
		<input file stock="gtk-edit"></input>
		<action>defaulttexteditor $APP_CONF</action>
		</button>
		<button tooltip-text="'$SEE_QUITAPP_TOOLTIP'">
		<input file stock="gtk-quit"></input>
		<action type="exit">quit_now</action>
		</button>
		'$SCALEGRIP'
		</hbox>
      </vbox></window>'
      #echo "$FDLG" >&2
      mysplash --stop
      REPLY=$($GTKDIALOG -p FDLG -c |grep '=') || echo "$FDLG" >&2
      #echo "$REPLY"
      eval "$REPLY"
      [ "$EXIT" = "OK" ] || exit 0
      CHOICE=$(echo "$REPLY" | grep '=.*true'| head -n1| cut -f1 -d'=')
      if [ "$CHOICE" = "V11X" ]; then
       cd /usr/lib${lsuffix}/mozilla/plugins
       #echo -e "#!/bin/sh\nwget -O - http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_11_linux.i386.tar.gz | tar -xz" > /tmp/delayedrun_flashdl
       # v0.9: fix the ownership
       if [ "$(echo -n "$DOWNLOADURL" | grep 'https')" == "" ];then #150305
        echo -e "#!/bin/sh\nwget -O - $DOWNLOADURL | tar --no-same-owner -xz" > /tmp/delayedrun_flashdl
       else
        echo -e "#!/bin/sh\nwget --no-check-certificate -O - $DOWNLOADURL | tar --no-same-owner -xz" > /tmp/delayedrun_flashdl
       fi
       chmod 777 /tmp/delayedrun_flashdl
       $TERMCONF /tmp/delayedrun_flashdl
       mysplash -bg yellow "$WAIT_PLS"
       ldd /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so > /dev/null 2>&1
       [ $? -ne 0 ] && rm -f /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so 2>/dev/null
       if [ -f /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so ];then
        FLASHSIZE=$(du /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so| cut -f1)
        echo /usr/lib${lsuffix}/mozilla/plugins/libflashplayer.so > /tmp/flashplayer.files #register
        if [ -d /usr/lib${lsuffix}/mozilla/plugins/usr ];then #150305
         rm -rf /usr/lib${lsuffix}/mozilla/plugins/usr/lib 2>/dev/null
         rm -rf /usr/lib${lsuffix}/mozilla/plugins/usr/lib64 2>/dev/null
         rm -rf /usr/lib${lsuffix}/mozilla/plugins/usr/share/kde4 2>/dev/null
         cp -r -f /usr/lib${lsuffix}/mozilla/plugins/usr /
         #find /usr/lib${lsuffix}/mozilla/plugins/usr -type d -printf '/usr/%P/\n'  >> /tmp/flashplayer.files
         #find /usr/lib${lsuffix}/mozilla/plugins/usr -type l -printf '/usr/%P\n'  >> /tmp/flashplayer.files
         find /usr/lib${lsuffix}/mozilla/plugins/usr -type f -printf '/usr/%P\n'  >> /tmp/flashplayer.files
         cd $HOME
         rm -rf /usr/lib${lsuffix}/mozilla/plugins/usr
         grep -vw '^flashplayer11' $HOME/.packages/user-installed-packages > /tmp/user-installed-packages
         NEWENTRY="flashplayer11-$NEWVERSION|flashplayer11|$NEWVERSION||Internet|17580K||flashplayer11-$NEWVERSION.pet||Adobe Flash Player 11 browser plugin and Preferences. Note, this may not work on older PCs, use instead an earlier 11.x or even 10.x||||"
         echo "$NEWENTRY" >> /tmp/user-installed-packages
         PACKAGE_ROOT=flashplayer11-$NEWVERSION	#v1.0
         mv -f /tmp/flashplayer.files /tmp/$PACKAGE_ROOT.files
         cp -f /tmp/$PACKAGE_ROOT.files /tmp/user-installed-packages $HOME/.packages/
         if [ -f /usr/share/applications/flash-player-properties.desktop ];then #fix .desktop for menu
          OLDNAME="`grep "^Name" /usr/share/applications/flash-player-properties.desktop`"
          OLDCATEGORY="`grep "^Categories" /usr/share/applications/flash-player-properties.desktop`"
          #NEWCATEGORY="Categories=X-Internet;" #now info is in getflash-conf file
          OLDICON="`grep "^Icon" /usr/share/applications/flash-player-properties.desktop`"
          #NEWICON="Icon=/usr/share/icons/flash-player-properties.png" #now info is in getflash-conf file
          sed -i -e "s%$OLDNAME%$NEWNAME%" \
			  -e "s%$OLDCATEGORY%$NEWCATEGORY%" \
			  -e "s%$OLDICON%$NEWICON%" /usr/share/applications/flash-player-properties.desktop
         fi
         fixmenus
         if [ "`pidof jwm`" != "" ] ; then
           jwm -reload || jwm -restart	#v1.0
         fi
         SUCCESS="y"
        fi
       fi
      else  # v1.5 - 4 Feb 2014: flashplayer10-10.3.183.90 from smokey01.com
         #DOWNLOADURL="http://distro.ibiblio.org/quirky/quirky6/${DISTRO_TARGETARCH}/packages/pet_packages-common" #150305
         #case "$CHOICE" in
         #V11) PACKAGE_ROOT="flashplayer11-11.2.202.228";;
         #V10) DOWNLOADURL="http://www.smokey01.com/OscarTalks"
              #PACKAGE_ROOT="flashplayer10-10.3.183.90";;
         #V9) PACKAGE_ROOT="flashplayer9_pretend10-20110327";;
         DOWNLOADURL="$_V11_url" #150305
         case "$CHOICE" in
         V11) DOWNLOADURL="$_V11_url"
			  PACKAGE_ROOT="$_V11_name";;
         V10) DOWNLOADURL="$_V10_url"
              PACKAGE_ROOT="$_V10_name";;
         V9) DOWNLOADURL="$_V9_url"
             PACKAGE_ROOT="$_V9_name";;
         *) exit 0;;
         esac
         DOWNLOADURL="$DOWNLOADURL/$PACKAGE_ROOT.pet"
         cd /tmp
         DOWNLOAD_FILE=$(which download_file)
         if [ "$DOWNLOAD_FILE" ]; then
           $DOWNLOAD_FILE "$DOWNLOADURL"
         else
          if [ "$(echo -n "$DOWNLOADURL" | grep 'https')" == "" ];then #150305
           echo -e "#!/bin/sh\nwget -O - $DOWNLOADURL" > /tmp/delayedrun_flashdl
          else
           echo -e "#!/bin/sh\nwget --no-check-certificate -O - $DOWNLOADURL" > /tmp/delayedrun_flashdl
          fi
           chmod 777 /tmp/delayedrun_flashdl
           $TERMCONF /tmp/delayedrun_flashdl
         fi
         #cd $HOME #V1.2 fix download pets
         if [ -s "$PACKAGE_ROOT.pet" ]; then
           petget +$PACKAGE_ROOT.pet
           [ -s $HOME/.packages/$PACKAGE_ROOT.files ] && SUCCESS="y"
           rm -f $PACKAGE_ROOT.pet
         fi
      fi
      if [ "$SUCCESS" ]; then
        #http://flashblock.mozdev.org/
        #LANG=C Xdialog --center --title "Adobe Flash Player" --icon "/usr/share/doc/flashlogo.gif" --msgbox "The Adobe Flash Player has been downloaded to:\\n /usr/lib/mozilla/plugins/libflashplayer.so\\nYou will need to exit from your web browser and restart it for the player to load" 0 0
        NOFB="`grep -i '^flashblock' $HOME/.packages/*-installed-packages`"
        if [ "$OFFERFB" -a "$NOFB" = "" ];then
         FLASHBLOCK='<hbox>
            <pixmap><input file>/usr/share/icons/flashblock.png</input></pixmap>
         <checkbox>
           <label>'$(gettext "Open your browser at the mozilla Flashblock page.")'</label>
           <variable>OPENFB</variable>
           <default>true</default>
          </checkbox></hbox>'
          else FLASHBLOCK='';
        fi
        TEXT="$(gettext 'The Adobe Flash Player has been installed in:')\n/usr/lib${lsuffix}/mozilla/plugins\n$(gettext 'You need to restart your web browser to load the new Flash player.')" #150311
        export FDLG='<window title="'$T_title'">
        <vbox>
         <frame><hbox>
          <pixmap><width>60</width><input file>/usr/share/doc/flashlogo.gif</input></pixmap>
          <text usemarkup="true"><input>echo -en "'$TEXT'"</input></text>
         </hbox></frame>
         '"$FLASHBLOCK"'
         <hbox>
          <button ok></button>
         </hbox>
        </vbox>
       </window>'
       mysplash --stop
       #I=$IFS; IFS="" 
		STATEMENTS=$($GTKDIALOG -p FDLG -c) || echo "$FLDG" >&2 
		STATEMENTS=$(echo "$STATEMENTS"|grep '^[A-Z][A-Z]*=')
		eval "$STATEMENTS"
		#IFS=$I
		[ "$EXIT" = "OK" -a "$OPENFB" = "true" ] && \
		exec $MYBROWSER $FLASHBLOCK_URL
		exit 0
      else
        #LANG=C Xdialog --center --title "Adobe Flash Player" --icon "/usr/share/doc/flashlogo.gif" --msgbox "Sorry, the Player did not download. Try the Puppy Package Manager." 0 0
        TEXT=$(gettext "Sorry, the Player did not download. Try the Puppy Package Manager.")
        export FDLG='<window title="'$T_title'">
        <vbox>
        <hbox>
        <pixmap><width>60</width><input file>/usr/share/doc/flashlogo.gif</input></pixmap>
        <text><input>echo -en "'$TEXT'"</input></text>
        </hbox>
        <hbox><button ok></button></hbox>
        </vbox></window>'
         mysplash --stop
         $GTKDIALOG -p FDLG -c
      fi

exit
