<?php
$title = _("Software Downloads | Exacq");
$meta = "<meta name='description' content='" . _("Download page for exacqVision software and updates.") . "' />";

$links = "<link rel='stylesheet' type='text/css' href='css/downloads.css'/>";

include("/var/www/PHPwebsite/olde_header.php");

require_once('/opt/php_includes/aws/vendor/autoload.php');
require_once('/opt/php_includes/aws.conf.php');
require_once('/opt/php_includes/signAmazon.php');

$s3 = Aws\S3\S3Client::factory($development[0]);
$s3->registerStreamWrapper();

// Today's date in unix time.
$time = time();
$div = 86400;
$days = $time / $div;

global $verArray, $ipcams;

// setup context to close connection instantly after data recieved
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));

// get edge ipcams
$ipcams = json_decode(file_get_contents("https://cdn.exacq.com/zdata/sugar/ipcams/edge-cameras.json?time=" . time(), false, $context), true);

// get the version array
$verArray = parse_ini_file($_SERVER['DOCUMENT_ROOT'] . '/downloads/evFileInfo.txt', true);

// find linux servers and set their data as mr
$version = array();
foreach ($verArray as $key => $data) {

    if (strpos($key, "ev-Server-Linux") !== false && strpos($key, "ev-Server-Linux-") === false) {

        $keyExplode = explode("ev-Server-Linux-", $key);

        $verArray['ev-Server-Linux-MR'] = $data;

        break;
    }
}
?>

<div class='ui-header-container'>
	<div class='ui-header-ev-image-container'>
		<img src='/menu/images/exacqVision-logo-gray.png' alt='exacqVision grey logo'/>
	</div>
	
	<div class='ui-header-text-container'>
		<div class='ui-header-bg-start'>
			<div class='ui-header-h1-container-full'><h1><?php echo _("Software Downloads"); ?></h1></div>
		</div>
	</div>
</div>

<div id="accordion">

	<!-- WINDOWS DOWNLOADS -->
    <h3><a href="#">exacqVision Software - Windows</a></h3>
    <div>
	
		<?php 
		
			// output 64 bit stuff
			outputCustomAccordion("64-bit exacqVision Installers", array(
				"ev-Client-x64" => "exacqVision Client",
				"ev-Combo-x64" => "exacqVision Server Bundle",
                                "ev-WebService-x64" => "exacqVision Web Service",
				"custom" => 
				"<tr class='six-four-bit-dl'>
					<td colspan=4>".sprintf(_("If you are upgrading a Hybrid %s unit from 32-bit to 64-bit you must upgrade your sDVR or tDVR drivers first.  Hybrid units with eDVR capture boards cannot be upgraded."), "Exacq")."</td>
				</tr>"
			), true);
						
			// output capture stuff
			outputCustomAccordion("64-bit Hybrid Capture Card Installers", array(
				"s7-Stretch-Setup-Win-x64" => "exacqVision Hybrid s7DVR Driver",
				"s7e-Stretch-Setup-Win-x64" => "exacqVision Hybrid s7eDVR Driver",
				"tdvr-Setup-Win-x64" => "exacqVision Hybrid tDVR Driver",
				"custom" => 
				"<tr class='six-four-bit-dl'>
					<td colspan=4>".sprintf(_("Driver installation is only required after OS re-installation on hybrid servers. See knowledge base article %s to determine the appropriate driver."), "<a href='https://exacq.com/kb/?kbid=49987' target='_blank'>#49987</a>")."</td>
				</tr>"
			));
			
			// output capture stuff
			outputCustomAccordion("Windows .MSI Installers", array(
				"ev-Client-x64-msi" => "exacqVision Client (64-bit)"
			));
			
			// output accessory stuff
			outputCustomAccordion("Accessory Installers", array("usbdio-Setup-Win" => "exacqVision USB DIO Setup Package"));
		?>

        <span class='dl-permalink'><a href="downloads.php?section=windows">Windows <?php echo _("Downloads Permalink") ?></a></span>
    </div>

	<!-- LINUX DOWNLOADS -->
    <h3><a href="#">exacqVision <?php echo _("Software") ?> - Linux</a></h3>
    <div>
	
		<?php 
			
			// ouptut 64 bit stuff
			outputCustomAccordion("64-bit exacqVision Installers", array(
				"ev-Client-Linux-x64" => "exacqVision Client",
				"ev-Server-Linux-x64" => "exacqVision Server",
                                "ev-WebService-Linux-x64" => "exacqVision Web Service"
				
			), true);
			
			outputCustomAccordion("64-bit Hybrid Capture Card Installers", array(
				"tdvr-Setup-Linux-x64" => "exacqVision Hybrid tDVR Driver",
				"s7e-Stretch-Setup-Linux-x64" => "exacqVision Hybrid s7eDVR Driver"
			));
			
			outputCustomAccordion("Accessory Installers", array(
				"usbdio-Setup-Linux~#Link:/usbio_linux" => "exacqVision USB DIO"
			));
			
		?>
		
        <span class='dl-permalink'><a href="downloads.php?section=linux">Linux <?php echo _("Downloads Permalink") ?></a></span>
    </div>

	<!-- MAC DOWNLOADS -->
    <h3><a href="#">exacqVision <?php echo _("Software") ?> - macOS</a></h3>
    <div>
	
		<?php 
	
			// ouptut 64 bit stuff
			outputCustomAccordion("64-bit exacqVision Installers", array(
				"ev-Client-Mac" => "exacqVision Client"
			), true);
			
                        // ouptut arm64 bit stuff
			outputCustomAccordion("arm64 exacqVision Installers", array(
				"ev-Client-Mac-arm64" => "exacqVision Client"
			), true);
			
		?>
        <span class='dl-permalink'><a href="downloads.php?section=osx">macOS <?php echo _("Downloads Permalink") ?> </a></span>
    </div> 

	<!-- EDGE DOWNLOADS -->
    <h3><a href="#">exacqVision Edge</a></h3>
    <div>
	
		<?php 
	
			// ouptut axis stuff
			outputCustomAccordion("Axis Camera Installers", array(

                				"ev-Server-ARTPEC-8-OS12" => array(
					"display" => "exacqVision Edge for Axis ARTPEC-8 OS12 Cameras",
					"edge" => array("artpec8OS12")
				),            
                                "ev-Server-ARTPEC-8" => array(
					"display" => "exacqVision Edge for Axis ARTPEC-8 or Ambarella CV25 Cameras",
					"edge" => array("artpec8", "cv25")
				),
                            
                                "ev-Server-axis-armhf" => array(
					"display" => "exacqVision Edge for Axis ArmHF or ARTPEC-6 or ARTPEC-7 Cameras",
					"edge" => array("AxisARMHF", "artpec6", "artpec7")
				),
                            
                                "ev-Server-axis-arm" => array(
					"display" => "exacqVision Edge for Axis Arm Cameras",
					"edge" => array("ARM")
				),
                            
                                "ev-Server-ARTPEC-4" => array(
					"display" => "exacqVision Edge for Axis ARTPEC-4 or ARTPEC-5 Cameras",
					"edge" => array("artpec4", "artpec5")
				),                                
			
				"ev-Server-ARTPEC-3" => array(
					"display" => "exacqVision Edge for Axis ARTPEC-3 Cameras",
					"edge" => array("artpec3")
				)
			));
			
			// output illustra stuff
			outputCustomAccordion("Illustra Camera Installers", array(	
			
				"ev-Server-illustra-aarch64-v2" => array(
					"display" => "exacqVision Edge for Illustra Cameras with Firmware 25.09 and Newer",
					"edge" => array("illustraV2") 
				),
				"ev-Server-illustra-aarch64" => array(
					"display" => "exacqVision Edge for Illustra Pro Gen3 and Gen4 Series Cameras",
					"edge" => array("Progen3")
				),	
				"ev-Server-illustra-825" => array(
					"display" => "exacqVision Edge for Illustra Pro Cameras",
					"edge" => array("illustra")
				),
				
				"ev-Server-illustra-610" => array(
					"display" => "exacqVision Edge for Illustra 6XX compact mini-domes, mini-bullet, and 2MP LT Pro Bullet Cameras",
					"edge" => array("illustra6xx")
				)
			));
			
			// ouptut vivotek stuff
			outputCustomAccordion("Vivotek Camera Installers", array(
			
				"ev-Server-vivotek-mozart" => array(
					"display" => "exacqVision Edge for Mozart models",
					"edge" => array("VivotekMozart")
				),
				
				"ev-Server-vivotek-vivaldi" => array(
					"display" => "exacqVision Edge for Vivaldi models",
					"edge" => array("VivotekVivaldi")
				)
			));
		?>
		
        <span class='dl-permalink'><a href="downloads.php?section=edge">Edge <?php echo _("Downloads Permalink") ?></a></span>
    </div>
	

	<!-- M-Series DOWNLOADS -->
    <h3><a href="#">exacqVision M-<?php echo _("Series") ?></a></h3>
    <div>
	
		<?php 
		
			// ouptut vivotek stuff
			outputCustomAccordion("M-Series Installers", array(
			
				"ev-Client-Linux-arm" => "exacqVision M-Series Client",
				"ev-Server-Linux-arm" => "exacqVision M-Series Server",
				"ev-WebService-Linux-arm" => "exacqVision M-Series Web Service",
			), true);
		?>
        <span class='dl-permalink'><a href="downloads.php?section=mseries">M-Series <?php echo _("Downloads Permalink") ?> </a></span>
    </div>

	
	
	<!-- Enterprise Manager DOWNLOADS -->
    <h3><a href="#">exacqVision Enterprise <?php echo _("Manager") ?></a></h3>
    <div>
	
		<?php 
                        
                        // ouptut Enterprise Manager 64 bit stuff
			outputCustomAccordion("64-bit Enterprise Manager Installers", array(
			
                                "ev-ESM-x64" => "Enterprise Manager download for Windows",
                                "ev-ESM-Linux-x64" => "Enterprise Manager download for Linux"
			), true);
		?>

        <span class='dl-permalink'><a href="downloads.php?section=esm">Enterprise Manager <?php echo _("Downloads Permalink") ?></a></span>
    </div>

	<!-- MOBILE DOWNLOADS -->
    <h3><a href="#">exacqVision Mobile App</a></h3>
    <div>
	
		<div class='mobile-container' style='text-align: center;'>
			<a href='https://apps.apple.com/us/app/exacqvision-mobile/id1583070424' target='_blank'><img src='/products/images/EM/apple_icon.jpg'></a>
			<a href='https://play.google.com/store/apps/details?id=com.exacq.ExacqVisionLite' target='_blank'><img src='/products/images/EM/googleplay_icon.jpg'></a>
		</div>
		
        <span class='dl-permalink'><a href="downloads.php?section=mobile">Exacq <?php echo _("Mobile Downloads Permalink") ?></a></span>
    </div>

    <h3><a href="#"><?php echo _("Integration Plugins") ?></a></h3>
    <div> 
		<?php 
		
			// output Lenel
			$plugins = array(
				
				array(
					"filepath" => "s3://exacqprivate/exacq-lenel_03_2011.zip",
					"version" => "2.0.1",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 6.3 and 6.4",
				),
				array(
					"filepath" => "s3://exacqprivate/6.5.624_Accessory_Add-On_for_Exacq_Support_1.0.3.zip",
					"version" => "2.1.0",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 6.5",
				),
				array(
					"filepath" => "s3://exacqprivate/6.6.287 Accessory Add-On for Exacq Support 1.0.1.zip",
					"version" => "2.1.1",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 6.6",
				),
				array(
					"filepath" => "s3://exacqprivate/exacq-lenel_7.0_Accessory_Add-On.zip",
					"version" => "3.0.8",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.0",
				),
				array(
					"filepath" => "s3://exacqprivate/7.1.481 Accessory Add-On for Exacq Support.zip",
					"version" => "3.1.1",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.1",
				),
				array(
					"filepath" => "s3://exacqprivate/7.2.252 Accessory Add-On for Exacq Support.zip",
					"version" => "3.1.1",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.2",
				),
				array(
					"filepath" => "s3://exacqprivate/7.3_Accessory_Add-On_for_Exacq.zip",
					"version" => "3.1.4",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.3",
				),
				array(
					"filepath" => "s3://exacqprivate/7.4 Accessory Add-On for Exacq.msi",
					"version" => "3.1.6",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.4",
				),
				array(
					"filepath" => "s3://exacqprivate/7.5 Accessory Add-On for Exacq.msi",
					"version" => "3.1.6",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.5",
				),
				array(
					"filepath" => "s3://exacqprivate/7.6 Accessory Add-On for Exacq.exe",
					"version" => "3.2.1",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 7.6", 
				),
				array(
					"filepath" => "s3://exacqprivate/8.0 Accessory Add-On for Exacq.exe",
					"version" => "3.2.1",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 8.0",
				),
				array(
					"filepath" => "s3://exacqprivate/8.1 Accessory Add-On for exacqVision Server 1.0.0.zip",
					"version" => "3.3.0",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 8.1",
				),
				array(
					"filepath" => "s3://exacqprivate/8.2 Accessory Add-On for exacqVision Server 1.0.1.zip",
					"version" => "3.3.0",
					"linktext" => "exacqVision plug-in for Lenel OnGuard",
					"addtext" => "for Lenel OnGuard vers. 8.2",
				)
			);
			
			@outputPluginTable("Lenel", $plugins);
			
			// output DSX
			$plugins = array(
				array(
					"filepath" => "s3://exacqprivate/exacqVision DSX Driver-1.1.5.83761.exe",
					"version" => "1.1.5.83761",
					"linktext" => "exacqVision plug-in for WinDSX"
				),
                                array(
					"filepath" => "s3://exacqprivate/evDSX_1.2.1.0_x86.exe",
					"version" => "1.2.1",
					"linktext" => "exacqVision plug-in for WinDSX"
				)
			);
			
			@outputPluginTable("DSX", $plugins);
			
			// ouptut virtual stuff
			@outputCustomAccordion("S2", array(
			
				"ev-OVID-Setup-Win" => "exacqVision-S2 OVID driver for Windows",
				"ev-OVID-Setup-Linux" => "exacqVision-S2 OVID driver for Linux"
			));
		
			// output AMAG
			$plugins = array(
				array(
					"filepath" => "s3://exacqprivate/exacqVisionSymmetry-1_3_2_149868.exe",
					"version" => "1.3.2.149868",
					"linktext" => "exacqVision eVsymmetry plug-in for Windows",
					"addtext" => "",
				)
			);
		
			@outputPluginTable("AMAG-G4S", $plugins);
                        
                        // output evSentry
                        @outputCustomAccordion("evSentry", array(
				"ev-Sentry-Setup-Win" => "exacqVisionSentry Service for Windows",
				"ev-SentryControl-Setup-Win" => "exacqVisionSentryControl User Interface for Windows",
                                "ev-Sentry-Setup-Linux" => "exacqVisionSentry Service for Linux",
                                "ev-SentryControl-Setup-Linux" => "exacqVisionSentryControl User Interface for Linux"
			));
                        
                        // output MASterMind
			$plugins = array(
				array(
					"filepath" => "s3://exacqprivate/evMASvideo_1.0.8.150713_x86.exe",
					"version" => "1.0.8.150713",
					"linktext" => "exacqVision MASterMind plug-in",
					"addtext" => "",
				)
			);
		
			@outputPluginTable("MASterMind", $plugins);
                        
                        
                        
                        // output Exacq Legacy Camera Support 
                        @outputCustomAccordion("Exacq Legacy Camera Support", array(			
				"elcs-Win-x64" => "Exacq Legacy Camera Support for Windows 64-bit",
                                "elcs-Linux-x64" => "Exacq Legacy Camera Support for Linux 64-bit"
			));
                        
                        
                        // output Archive Sync 
                        @outputCustomAccordion("Archive Sync", array(			
				"archive-sync-Linux-x64" => "Archive Sync for Linux 64-bit"
			));
                        
                        // output transacq stuff
			outputCustomAccordion("Transacq Installers", array(
                                "ev-Transacq-Setup-Win" => "Transacq Client Windows",
				"ev-Transacq-Setup-Linux" => "Transacq Client Linux"
			));
                        
                        // output videoguard
			outputCustomAccordion("VideoGuard Installers", array(
                                "ev-videoguard-x64" => "VideoGuard for Windows 64-bit",
				"ev-videoguard-Linux-x64" => "VideoGuard for Linux 64-bit"
			));
                        
                        // output evLPR - Hikvision
                        outputCustomAccordion("evLPR - Hikvision", array(
                                "ev-lpr-x64" => "evLPR for Windows",
				"ev-lpr-Linux-x64" => "evLPR for Linux"
			));
		?>
		
        <span class='dl-permalink'><a href="downloads.php?section=integration">Integration Plugins <?php echo _("Downloads Permalink") ?></a></span>
    </div><!-- END ACCESS CONTROL DOWNLOADS -->

    <h3><a href="#">exacqVision <?php echo _("Software Release Notes") ?></a></h3>
    <div class='legacy-downloads'>
		
	
        <table border="0" class='downloadTable'>
            <tr>
                <td>
                    <b>Release Announcements</b><br>
                    <div><a target="_blank" href="/about/news/?select=updates"><?php echo _("Product Updates") ?></a></div>
                    <div><a target="_blank" href="/products/ssa.html"><?php echo _("SSA Info") ?></a></div>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Engineering Release Notes</b><br>
					<?php 
                                                $versionNumber = substr($verArray['ev-Combo-x64']['Version'], 0, strrpos($verArray['ev-Combo-x64']['Version'], '.'));
                                                $versionNumberEM = substr($verArray['ev-ESM-x64']['Version'], 0, strrpos($verArray['ev-ESM-x64']['Version'], '.'));
						$files = array(
							"evclientRelNotes.txt?ver=$versionNumber" => "Client",
							"evserverRelNotes.txt?ver=$versionNumber" => "Server",
							"evwebserviceRelNotes.txt" => "Webservice",
							"evESMRelNotes.txt?ver=$versionNumberEM" => "Enterprise Manager",
                                                        "exacqMobileRelNotes.txt" => "Mobile"
						);
						
						foreach ($files as $filebase => $filename) {
							
                                                          $url = "https://cdnpublic.exacq.com/".$filebase;
                                                          echo "<div><a target='_blank' href='$url'>".$filename."</a></div>";
						}
					?>
                </td>
            </tr>
        </table>
        <br>
        <br>
        <span class='dl-permalink'><a href="downloads.php?section=notes"><?php echo _("Release Notes Downloads Permalink") ?></a></span>
    </div><!-- END RELEASE NOTES DOWNLOADS -->
    
    <h3><a href="#"><?php echo _("Legacy Downloads") ?></a></h3>
    <div class='legacy-downloads'>
		
	
        <table border="0" class='downloadTable'>
            
            <tr>
                <td>
                    <b><?php echo _("Legacy Downloads") ?> - <?php echo _("Download Previous Versions") ?></b><br>
                    <div><a target="_blank" href="/reseller/Legacy/index.html"><?php echo _("Legacy Downloads") ?></a></div>                    
                </td>
            </tr>
			<tr>
                <td>
					<b>exacqVision Virtual Appliance</b>
					<?php echo "<div><a href='".$verArray["ev-VirtualAppliance"]["Link"]."'>exacqVision Virtual Appliance</a></div>";?>
					<div><a href='https://exacqpublic.s3.amazonaws.com/exacqvision-virtual-appliance-legacy.pdf'>exacqVision Virtual Appliance - User Manual</a></div>
				</td>
            </tr>
            
            <tr>
                <td>
                    <b><?php echo _("E-Series firmware") ?></b><br>
                    <div><a target="_blank" href="https://cdnpublic.exacq.com/e-series/DVS_EN_NEU_V1.2.0_140801.zip">exacqVision firmware for E-Series 1.2.0_140801</a></div>
                    <div><a target="_blank" href="https://cdnpublic.exacq.com/e-series/DZ_DVS_DM8107_EN_NEU_V1.2.0_150420.zip">exacqVision firmware for E-Series 1.2.0_150420</a></div></td>
            </tr>
            <tr>
                <td>
                    <b><?php echo _("32-bit Hybrid Capture Card Installers") ?></b><br>
                    
                        <?php
                        // output capture stuff
                        outputCustomAccordion("Windows Hybrid Capture Card Installers", array(
                            "edvr-Stretch-Setup-Win" => "exacqVision Hybrid eDVR Driver",
                            "sdvr-Stretch-Setup-Win" => "exacqVision Hybrid sDVR Driver",
                            "s7-Stretch-Setup-Win" => "exacqVision Hybrid s7DVR Driver",
                            "s7e-Stretch-Setup-Win" => "exacqVision Hybrid s7eDVR Driver",
                            "tdvr-Setup-Win" => "exacqVision Hybrid tDVR Driver",
                            "xsdvr-Stretch-Setup-Win" => "exacqVision Hybrid xsDVR Driver",
                            "custom" =>
                            "<tr class='six-four-bit-dl'>
					<td colspan=4>" . sprintf(_("Driver installation is only required after OS re-installation on hybrid servers. See knowledge base article %s to determine the appropriate driver."), "<a href='https://exacq.com/kb/?kbid=49987' target='_blank'>#49987</a>") . "</td>
				</tr>"
                        ));
                        // ouptut capture stuff
                        outputCustomAccordion("Linux Hybrid Capture Card Installers", array(
                            "edvr-Stretch-Setup-Linux" => "exacqVision Hybrid eDVR Driver",
                            "sdvr-Stretch-Setup-Linux" => "exacqVision Hybrid sDVR Driver",
                            "s7-Stretch-Setup-Linux" => "exacqVision Hybrid s7DVR Driver",
                            "s7e-Stretch-Setup-Linux" => "exacqVision Hybrid s7eDVR Driver",
                            "tdvr-Setup-Linux" => "exacqVision Hybrid tDVR Driver",
                            "xsdvr-Stretch-Setup-Linux" => "exacqVision Hybrid xsDVR Driver",
                            "dahua-Setup-Linux" => "exacqVision LC Driver",
                            "<tr class='six-four-bit-dl'>
					<td colspan=4>" . sprintf(_("Driver installation is only required after OS re-installation on hybrid servers. See knowledge base article %s to determine the appropriate driver."), "<a href='https://exacq.com/kb/?kbid=49987' target='_blank'>#49987</a>") . "</td>
				</tr>"
                        ));
                        ?>
                   
                </td>
            </tr>
            <tr>
                <td>
                    <b><?php echo _("Integration Plugins") ?></b><br>
                    
                        <?php
                        // output RTSP
                        @outputCustomAccordion("RTSP Server", array(			
				"ev-rtsp-server-Win-x64" => "exacqVision RTSP Server for Windows 64-bit",
				"ev-rtsp-server-Linux" => "exacqVision RTSP Server for Linux 32-bit",
                                "ev-rtsp-server-Linux-x64" => "exacqVision RTSP Server for Linux 64-bit",
                                "ev-rtsp-server-Linux-arm" => "exacqVision RTSP Server for Linux ARM"
			));
                        ?>
                   
                </td>
            </tr>
   	   <tr>
                <td>
                    <b><?php echo _("Exacq Mobile 3") ?></b><br>
                    <div><a target="_blank" href="http://itunes.apple.com/us/app/exacq-mobile-2/id416566873?mt=8">App Store</a></div>
                    <div><a target="_blank" href="https://play.google.com/store/apps/details?id=com.exacq.nvrclient">Play Store</a></div>
		</td>
            </tr>

        </table>
        <br>
        <br>
        <span class='dl-permalink'><a href="downloads.php?section=legacy"><?php echo _("Legacy Downloads Permalink") ?></a></span>
    </div><!-- END LEGACY DOWNLOADS -->

    <h3><a href="#"><?php echo _("Software Updates Packaging Utility") ?></a></h3>
    <div>
        <b><?php echo _("Download software updates for offline use") ?></b>

        <br><br>
        <div><a href='/webapps/packaging-utility/' style='color: #007AC3;'><?php echo _("Click here") ?></a> <?php echo _("to create and download an updates package for use on the updates tab of exacqVision 5.4 or later or any version of Enterprise System Manager. Not required for systems with internet access.") ?></div>

        <span class='dl-permalink'><a href="downloads.php?section=softwareUpdatesPackagingUtil"><?php echo _("Software Updates Packing Utility") ?></a></span>
    </div>
</div>

<div class='reseller-notes'>
	<ul>
		<li><i><?php echo _("Reseller password required for some downloads.") ?></i></li>
		<li><i>SDK <?php echo _("downloads are located on the") ?> <a href="integration.html"><?php echo _("Developers") ?></a> <?php echo _("page") ?>.</i></li>
	</ul>
</div>

<?php
include("/var/www/PHPwebsite/footer.php");

/**

  Get edge cameras for a specific edge manufacturer.
  @param edgeModel (String) Name of the edge model group of cameras.
  @param append (Boolean) The list is going to be appended to a previously populated list or not.
 */
function getEdgeCameras ($edgeModel, $append = false) {
	
	global $ipcams;
	
	$html = "";
	
	
    if ($append) {

        $html .= ", ";
    }

    $i = 1;
    foreach ($ipcams as $manuf => $edgeArray) {

		foreach ($edgeArray as $num => $edgeCam) {
			
			// if this edge camera matches the model type given
			if ($edgeCam["edge"] === $edgeModel) {
				
				if ($i > 1) {

					$html .= ", ";
				}

				$html .= "<a class='edge-camera-link' href='/integration/ipcams/#search=" . $edgeCam['name'] . "'>" . $edgeCam['name'] . "</a>";

				$i++;
			}
		}
    }
	
	return $html;
}

function outputCustomAccordion ($name, $installers, $active = false) {
	
	global $verArray;
	
	 // Today's date in unix time.
    $time = time();
    $div = 86400;
    $days = $time / $div;
	
	$activeClass = "";
	if ($active) $activeClass = "active-on-start";
	
	$installCount = 0;
	
        if($name == 'evSentry'){
          $customAccordion = "
	<div class='custom-downloads-accordion ".$activeClass."'>
		<h3><a href='#'>".$name."</a></h3>
		<div>
		
			<table>
                        <tr>
                        <th><a href='https://cdn.exacq.com/auto/manspec/files/04ebcacd-6fcf-0044-d55f-788d716983b7.pdf?response-content-disposition=attachment;filename=%22Sentry%20-%20Rail%20Cam.pdf%22&rand=0.6267076056934623'>Vital Installation Instructions - Read Before Downloading</a></th>
                    <td></td>
                    <td></td>
                    <td></td>
                        </tr>
				<tr>
					<th>Download Link</th>
					<th>Version</th>
					<th>Date</th>
					<th></th>
				</tr>";  
        }else{
	$customAccordion = "
	<div class='custom-downloads-accordion ".$activeClass."'>
		<h3><a href='#'>".$name."</a></h3>
		<div>
		
			<table>
				<tr>
					<th>Download Link</th>
					<th>Version</th>
					<th>Date</th>
					<th></th>
				</tr>";
        }
		foreach ($installers as $evName => $item) {
			
			$downloadLink = false;
			
			// if the download link has an override in the name, we want to use this link instead
			if (stripos($evName, "~#Link:") !== false) {
				
				$exName = explode("~#Link:", $evName);
				
				$downloadLink = $exName[1];
				$evName = $exName[0];
			}
			
			// check to make sure the fire exists in evFileInfo
			if (@$verArray[$evName]) {
				
				$version = $verArray[$evName]['Version'];
				$date = $verArray[$evName]['Date'];
				
				
					
					$installCount++;
					
					// check to see if we have nested items
					if (is_array($item)) {
						
						$displayName = $item["display"];
						$edge = $item["edge"];
					}
					else {
						
						$edge = array();
						$displayName = $item;
					}
					
					// set the download link
					if ($downloadLink === false) $downloadLink = str_replace(array('http://www.exacq.com', 'http://'), array('..', 'https://'), $verArray[$evName]['Link']);
					
					// set the version
					if (empty($version)) $version = "";
					
					// set the date
					if (empty($date)) $formattedDate = "";
					else {
						
						// format the date string
						$formattedDate = str_replace('/', '-', $verArray[$evName]['Date']);
						
						// remove leading zeroes
						if (intval($formattedDate[0]) === 0) {
							
							$temp = substr($formattedDate, 1);
							$formattedDate = $temp;
						}
					}
					
					// if the item is less than 30 days old, mark it as a new item
					$isNew = "";
					if (($days - (strtotime($verArray[$evName]['Date'])) / $div) < 30) {
						$isNew = "<span class='new'>" . _("New") . "</span>";
					}
					
					// check to see if we have custom text or not
					if ($evName === "custom") {
						
						$customAccordion .= $displayName;
					}
					else {
						
						// output the installer
						$customAccordion .= "
						<tr class='dl-item'>
							<td><a href='".$downloadLink."'>".$displayName."</a></td>
							<td>".$version."</td>
							<td>".$formattedDate."</td>
							<td>".$isNew."</td>
						</tr>";
					}
					
					// if this is the server bundle
					if ($evName === "ev-Combo" || $evName === "ev-Combo-x64") {
						$customAccordion .= "
						<tr>
							<td class='dl-indented'>
								". _("Client - Version") . " " . $verArray['ev-Client-x64']['Version'] . "<br>
								". _("Server - Version") . " " . $verArray['ev-Server-x64']['Version'] . "<br>
								". _("Web Service - Version") . " " . $verArray['ev-WebService-x64']['Version'] . "
							</td>
						</tr>";
					}
                                        
					else if ($evName === "ev-Server-Linux-MR") {
						
						$customAccordion .= "
						<tr>
							<td class='dl-indented'>" . sprintf(_("Recommended for use on %s"), "Ubuntu 14.04") . "</td>
						</tr>";
					}
					else if ($evName === "ev-VirtualAppliance14") {
						
						$customAccordion .= "
						<tr>
							<td class='vm-note'>
								<div>
									<span class='ui-icon ui-icon-carat-1-sw'></span>
									<div class='vm-add'>"._("Built on Ubuntu 14.04 LTS - Requires vSphere ESX/i with vCenter versions 5.1 Update 2 to 6.0")."</div> - 
									<div class='vm-add'>".sprintf(_("Requires %s or higher"), "VMware ESXi 5.1 U2")."</div>
								</div>
								<div>
									<span class='ui-icon ui-icon-carat-1-sw'></span>
									<div class='vm-add'>".sprintf(_("Currently not compatible with %s"), "vSphere 6.5")."</div>
								</div>
							</td>
						</tr>";
					}
					
					if (count($edge) > 0) {
						
						$customAccordion .= "
						<tr>
							<td class='dl-indented'>Compatible Models: ";
							
							$count = 0;
							foreach ($edge as $name) {
								
								if ($count > 0) $customAccordion .= ", ";
								
								$customAccordion .= getEdgeCameras($name);
								
								$count++;
							}
							
						$customAccordion .= "</td>
						</tr>";
					} 
			}
		}
		
		$customAccordion .= "
			</table>
		</div>
	</div>";
	
	if ($installCount > 0) echo $customAccordion;
}

function outputPluginTable ($tableName, $itemArray, $active = false) {
	
	// Today's date in unix time.
	$time = time();
	$div = 86400;
	$days = $time / $div;
	
	$activeClass = "";
	if ($active) $activeClass = "active-on-start";
	
	echo "
	<div class='custom-downloads-accordion ".$activeClass."'>
		<h3><a href='#'>".$tableName."</a></h3>
		<div>
		
			<table>
				<tr>
					<th>Download Link</th>
					<th>Version</th>
					<th>Date</th>
					<th></th>
				</tr>";
	
	foreach ($itemArray as $item) {
		
		$physicalPath = $item["filepath"];
		$version = $item["version"];
		$linktext = $item["linktext"];
		$addtext = $item["addtext"];
		
		$filepath = $physicalPath;
		
		if (stripos($physicalPath, "exacqpublic") > -1) {
			
			$filepath = str_replace("s3://exacqpublic/", "https://exacqpublic.s3.amazonaws.com/", $physicalPath);
		}
		else if (stripos($physicalPath, "exacqprivate") > -1) {
			
			$url = str_replace("s3://exacqprivate/", "https://d7lx6lpz67xnj.cloudfront.net/", $physicalPath);
			$url = str_replace(" ", "+", $url);
			$fileparts = pathinfo($url);
			$signedUrlCannedPolicy = getSignedURL($url,$fileparts['basename'],'application/octet-stream','attachment');
			
			if ($signedUrlCannedPolicy) $filepath = $signedUrlCannedPolicy;
		}
		
		echo "
		<tr class='itemrow'>
			<td><a href='".$filepath."'>".$linktext."</a> ".$addtext."</td>
			<td>".$version."</td>
			<td>";
				
				if (file_exists($physicalPath))
					echo date('m-d-Y', filemtime($physicalPath));
				else
					echo 'N/A';
				
				echo "</td>
			<td>"; 
			
			if ($days - (filemtime($physicalPath) / $div) < 30) echo "<span class='new'>"._("New")."</span>";
			
			echo "</td>
		</tr>";
	}
	
	echo "</table></div></div>";
}
?>

<script type="text/javascript">
$(document).ready(function() {
	
	var params = getQueryParams();
	console.log(params.section);
	var activeSection = "none";
	
	if (typeof params.section == "undefined") {
		
		var OSName="Unknown OS";
		if (navigator.appVersion.indexOf("Win")!=-1) OSName="windows";
		if (navigator.appVersion.indexOf("Mac")!=-1) OSName="osx";
		if (navigator.appVersion.indexOf("Linux")!=-1) OSName="linux";
		
		activeSection = OSName;
	}
	else activeSection = params.section;
	
	switch (activeSection) {
		
		case "windows" :
			activeSection = 0;
		break;
		
		case "linux" :
			activeSection = 1;
		break;
		
		case "osx" :
			activeSection = 2;
		break;
		
		case "edge" :
			activeSection = 3;
		break;
		
		case "mseries" :
			activeSection = 4;
		break;
		
		case "esm" :
			activeSection = 5;
		break;
		
		case "mobile" :
			activeSection = 6;
		break;
		
		case "integration" :
			activeSection = 7;
		break;
		
		case "notes" :
			activeSection = 8;
		break;
		
                case "legacy" :
			activeSection = 9;
		break;
                
		case "softwareUpdatesPackagingUtil" :
			activeSection = 10;
		break;
		
		default : activeSection = 0; break;
	}
	
	$("#accordion").accordion({
		autoHeight: false,
		collapsible: true,
		heightStyle: 'content',
		active: parseInt(activeSection)
	});
	
	
	$(".custom-downloads-accordion").each(function (x) {
		
		var active = false;
		if ($(this).hasClass("active-on-start")) active = 0;
		
		$(this).accordion({
			autoHeight: false,
			collapsible: true,
			heightStyle: 'content',
			active: active
		});
	});
	
	function getQueryParams () {
			
		function identity (e) { return e; }
		
		function toKeyValue (params, param) {
			
			var keyValue = param.split('=');
			var key = keyValue[0], value = keyValue[1];

			params[key] = params[key]?[value].concat(params[key]):value;
                        console.log(params);
			return params;
		}
		//console.log(window.location.search.replace(/^\?/, '').split('&'));
		// this used to be decoded
		return window.location.search.
		replace(/^\?/, '').split('&').
		filter(identity).
		reduce(toKeyValue, {});
	}
});
</script>
