<?php

/**
 * OurResortsController
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class InternalVideosController extends Zend_Controller_Action {

    private static function getVideoPath() {
        // Default video url is /videos/ from the same server
        $gVideoURL = "file://gcmain03/video$/";

        // For remote sites, change the video URL to the local server.
        $clientIP = $_SERVER['REMOTE_ADDR'];
        $ip = explode('.', $clientIP);
        if ($ip[2] == "120") { $gVideoURL = "file://nzmadca1/video$/"; }                            // Marama
        if ($ip[2] == 206) {
            if (($ip[3] > 129) &&  ($ip[3] < 190)) { $gVideoURL = "file://auwadca2/video$/"; }
            if (($ip[3] > 65)  &&  ($ip[3] < 94))  { $gVideoURL = "file://auwadca1/video$/"; }      // Outram
        }
        if ($ip[2] == "207") { $gVideoURL = "file://nzmadca0/video$/"; }
        if ($ip[2] == "208") { $gVideoURL = "file://fjnadca1/video$/"; }    // Fiji
        if ($ip[2] == "210") { $gVideoURL = "file://nzwadca0/video$/"; }    // Wannaka
        if ($ip[2] == "211") { $gVideoURL = "file://aunsdca2/video$/"; }    // 
        if ($ip[2] == "212") { $gVideoURL = "file://auqldcb0/video$/"; }    // Golden Beach
        if ($ip[2] == "213") { $gVideoURL = "file://auqldca1/video$/"; }    //
        if ($ip[2] == "214") { 
            if (($ip[3] > 1) &&  ($ip[3] < 65)) { $gVideoURL = "file://auvidca0/video$/"; }
            if (($ip[3] > 65)  &&  ($ip[3] < 126))  { $gVideoURL = "file://auvidca2/video$/"; }
        }
        if ($ip[2] == "215") { 
            if (($ip[3] > 1) &&  ($ip[3] < 65)) { $gVideoURL = "file://aunsdca0/video$/"; }         // Coffs Harbour 
            if (($ip[3] > 65)  &&  ($ip[3] < 126))  { $gVideoURL = "file://auqldca2/video$/"; }
            if (($ip[3] > 129)  &&  ($ip[3] < 254))  { $gVideoURL = "file://auqldca1/video$/"; }    // Kirra
        }
        if ($ip[2] == "216") { 
            if (($ip[3] > 1) &&  ($ip[3] < 65)) { $gVideoURL = "file://tssydneydc/video$/"; }       // Sydney Resort
            if (($ip[3] > 65)  &&  ($ip[3] < 126))  { $gVideoURL = "file://aunsdca1/video$/"; }     // Sydney Sales
            if (($ip[3] > 129)  &&  ($ip[3] < 190))  { $gVideoURL = "file://auqldca7/video$/"; }    // Surfers Sales
        }
        if ($ip[2] == "219") { $gVideoURL = "file://autadca0/video$/"; }                            // Hobart

        return $gVideoURL;
    }   
    
    /**
	 * The default action - show the home page
	 */
	public function indexAction() {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
    
        $v = $_GET["v"];
        if ($v) {

            header('Location:'. $this->getVideoPath().$v);
            return;
        }


        echo '<ul>';
        echo '<li><a href="'.$this->getVideoPath().'Barry Q2 Message 2010.wmv">Barry\'s Q2 Message 2010</a></li>';
        echo '<li><a href="'.$this->getVideoPath().'Barry\'s Q3 Message.wmv">Barry\'s Q3 Message</a></li>';
        echo '</ul>';
	}

    public function q22010Action() {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        echo '<ul>';
        echo '<li><a href="'.$this->getVideoPath().'Barry Q2 Message 2010.wmv">Barry\'s Q2 Message 2010</a></li>';
        echo '</ul>';
    }

    public function q32010Action() {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        echo '<ul>';
        echo '<li><a href="'.$this->getVideoPath().'Barry\'s Q3 Message.wmv">Barry\'s Q3 Message</a></li>';
        echo '</ul>';
    }

    public function townhall2010Action() {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        echo '<ul>';
        echo '<li><a href="'.$this->getVideoPath().'2011TownHall.wmv ">2011 Town Hall</a></li>';
        echo '</ul>';
    }
}
?>

