diff --git a/files/www/cgi-bin/admin b/files/www/cgi-bin/admin index 4158cfa8..83e8da4b 100755 --- a/files/www/cgi-bin/admin +++ b/files/www/cgi-bin/admin @@ -102,6 +102,42 @@ $patch_install = 0; "http://downloads.arednmesh.org/firmware/ubnt" ); +$hardwaretype = `/usr/local/bin/get_hardwaretype`; +chomp($hardwaretype); + +# handle TPLink and Mikrotik exception conditions +$mfg=`/usr/local/bin/get_hardware_mfg`; +chomp($mfg); +$mfgprefix=""; +if($mfg=~ /Ubiquiti/i) +{ + $mfgprefix="ubnt"; +} elsif($mfg=~ /Mikrotik/i) { + $mfgprefix="mikrotik"; +} elsif($mfg=~ /TP-Link/i) { + $mfgprefix="cpe"; +} + +if($hardwaretype eq "nanostation-m") +{ + $hardwaretypev="nano-m"; +} elsif($hardwaretype eq "rb-952ui-5ac2nd") { + $hardwaretypev= "rb-nor-flash-16M-ac" ; # hAP AC Lite +} elsif($hardwaretype =~ /rb-912uag-[25]hpnd/i ) { + $hardwaretypev= "nand-large" ; # Basebox 2/5 +} elsif($mfgprefix eq "cpe" ) { + $hwmodel = `/usr/local/bin/get_model`; + chomp($hwmodel); + if($hwmodel =~ /CPE210 v1\.[01]/i) + { + $hardwaretypev= "210-220-v1" ; # v1.0/v1.1 + } elsif($hwmodel =~ /CPE210 v[23]\.0/i) { + $hardwaretypev= "210-v2" ; # v2.0/v3.0 + } elsif($hwmodel =~ /CPE510/i) { + $hardwaretypev= "510-520-v1" ; # CPE510 V1.0/v1.1/v2.0 + } +} + # refresh fw if($parms{button_refresh_fw}) { @@ -110,8 +146,6 @@ if($parms{button_refresh_fw}) push @fw_output, "Downloading firmware list...\n"; unlink "/tmp/web/firmware.list"; $ok = 0; - $hardwaretype = `/usr/local/bin/get_hardwaretype`; - chomp($hardwaretype); foreach $serverpath (@serverpaths) { system "$wget -O /tmp/web/firmware.list $serverpath/firmware.$hardwaretype.list >/dev/null 2>>$tmpdir/wget.err"; @@ -551,7 +585,36 @@ system "rm -rf /tmp/web/upload $tmpdir" unless $debug; # http_header(); -html_header("$node administration", 1); +html_header("$node administration", 0); +print < + function validateFirmwareFilename(elem){ + var hwmfg = "$mfgprefix"; + var hwtype = "$hardwaretypev"; + var searchstring = ""; + var efn = ""; + if(hwmfg != "cpe"){ + searchstring= ".*-" + hwtype + "-sysupgrade.bin$\"; + efn = "aredn-$fw_version-$mfgprefix-$hardwaretypev-sysupgrade.bin"; + } else { + searchstring= ".*cpe" + hwtype + "-sysupgrade.bin$\"; + efn = "aredn-$fw_version-$mfgprefix$hardwaretypev-sysupgrade.bin"; + } + var re = new RegExp(searchstring,"g"); + if(elem.value.match(re)){ + return true; + }else{ + if (confirm('This filename is NOT appropriate for this device!\\n\\nThis device expects a file such as: ' + efn + ' \\n\\n\\nClick OK to continue if you are CERTAIN that the file is correct.')) { + return true; + } else { + elem.value=""; + return false; + } + } + } + +EOF +print ""; print "
\n"; alert_banner(); print "
\n"; @@ -583,9 +646,11 @@ if(@fw_output) print "current version: $fw_version\n"; +print "hardware type: $mfgprefix ($hardwaretype)\n"; + print "\n"; print "Upload Firmware\n"; -print "\n"; +print "\n"; print "\n"; @@ -594,10 +659,10 @@ print "\n"; print "\n"; print "Download Firmware\n"; print "\n"; print "\n"; @@ -640,10 +705,10 @@ print "\n"; print "\n"; print "Download Package\n"; print "\n"; print "\n"; @@ -653,11 +718,11 @@ print "\n"; print "\n"; print "Remove Package\n"; print "\n"; print "\n"; @@ -693,10 +758,10 @@ print "\n"; print "\n"; print "Remove Key\n"; print "\n"; print "\n";