コード例 #1
0
 public function versionNotify()
 {
     if (Application_Model_Preference::GetPlanLevel() != 'disabled') {
         return "";
     }
     // retrieve and validate current and latest versions,
     $current = Application_Model_Preference::GetAirtimeVersion();
     $latest = Application_Model_Preference::GetLatestVersion();
     $link = Application_Model_Preference::GetLatestLink();
     $currentExploded = explode('.', $current);
     $latestExploded = explode('.', $latest);
     if (count($currentExploded) != 3 || count($latestExploded) != 3) {
         return "";
     }
     // Calculate the version difference;
     // Example: if current = 1.9.5 and latest = 3.0.0, diff = 105
     // Note: algorithm assumes the number after 1st dot never goes above 9
     $versionDifference = intval($latestExploded[0]) * 100 + intval($latestExploded[1]) * 10 + intval($latestExploded[2]) - (intval($currentExploded[0]) * 100 + intval($currentExploded[1] * 10 + intval($currentExploded[2])));
     // Pick icon based on distance this version is to the latest version available
     if ($versionDifference <= 0) {
         // current version is up to date or newer
         $class = "uptodate";
     } else {
         if ($versionDifference < 20) {
             // 2 or less major versions back
             $class = "update";
         } else {
             if ($versionDifference < 30) {
                 // 3 major versions back
                 $class = "update2";
             } else {
                 // more than 3 major versions back
                 $class = "outdated";
             }
         }
     }
     $result = "<div id='version-diff' style='display:none'>" . $versionDifference . "</div>" . "<div id='version-current' style='display:none'>" . $current . "</div>" . "<div id='version-latest' style='display:none'>" . $latest . "</div>" . "<div id='version-link' style='display:none'>" . $link . "</div>" . "<div id='version-icon' class='" . $class . "'></div>";
     return $result;
 }
コード例 #2
0
 public function statusAction()
 {
     $request = $this->getRequest();
     $getDiskInfo = $request->getParam('diskinfo') == "true";
     $status = array("platform" => Application_Model_Systemstatus::GetPlatformInfo(), "airtime_version" => Application_Model_Preference::GetAirtimeVersion(), "services" => array("pypo" => Application_Model_Systemstatus::GetPypoStatus(), "liquidsoap" => Application_Model_Systemstatus::GetLiquidsoapStatus(), "media_monitor" => Application_Model_Systemstatus::GetMediaMonitorStatus()));
     if ($getDiskInfo) {
         $status["partitions"] = Application_Model_Systemstatus::GetDiskInfo();
     }
     $this->view->status = $status;
 }
コード例 #3
0
ファイル: LoginController.php プロジェクト: nidzix/Airtime
 public function indexAction()
 {
     global $CC_CONFIG;
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('Showbuilder');
     }
     //uses separate layout without a navigation.
     $this->_helper->layout->setLayout('login');
     $error = false;
     $request = $this->getRequest();
     $baseUrl = $request->getBaseUrl();
     $this->view->headScript()->appendFile($baseUrl . '/js/airtime/login/login.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $form = new Application_Form_Login();
     $message = "Please enter your user name and password";
     if ($request->isPost()) {
         // if the post contains recaptcha field, which means form had recaptcha field.
         // Hence add the element for validation.
         if (array_key_exists('recaptcha_response_field', $request->getPost())) {
             $form->addRecaptcha();
         }
         if ($form->isValid($request->getPost())) {
             //get the username and password from the form
             $username = $form->getValue('username');
             $password = $form->getValue('password');
             if (Application_Model_Subjects::getLoginAttempts($username) >= 3 && $form->getElement('captcha') == NULL) {
                 $form->addRecaptcha();
             } else {
                 $authAdapter = Application_Model_Auth::getAuthAdapter();
                 //pass to the adapter the submitted username and password
                 $authAdapter->setIdentity($username)->setCredential($password);
                 $auth = Zend_Auth::getInstance();
                 $result = $auth->authenticate($authAdapter);
                 if ($result->isValid()) {
                     //all info about this user from the login table omit only the password
                     $userInfo = $authAdapter->getResultRowObject(null, 'password');
                     //the default storage is a session with namespace Zend_Auth
                     $authStorage = $auth->getStorage();
                     $authStorage->write($userInfo);
                     Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']);
                     Application_Model_Subjects::resetLoginAttempts($username);
                     $tempSess = new Zend_Session_Namespace("referrer");
                     $tempSess->referrer = 'login';
                     $this->_redirect('Showbuilder');
                 } else {
                     $message = "Wrong username or password provided. Please try again.";
                     Application_Model_Subjects::increaseLoginAttempts($username);
                     Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']);
                     $form = new Application_Form_Login();
                     $error = true;
                 }
             }
         }
     }
     $this->view->message = $message;
     $this->view->error = $error;
     $this->view->form = $form;
     $this->view->airtimeVersion = Application_Model_Preference::GetAirtimeVersion();
     $this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE;
     if (isset($CC_CONFIG['demo'])) {
         $this->view->demo = $CC_CONFIG['demo'];
     }
 }
コード例 #4
0
 public function aboutAction()
 {
     $this->view->airtime_version = Application_Model_Preference::GetAirtimeVersion();
 }
コード例 #5
0
ファイル: Bootstrap.php プロジェクト: nidzix/Airtime
require_once __DIR__ . "/configs/conf.php";
require_once __DIR__ . "/configs/ACL.php";
require_once 'propel/runtime/lib/Propel.php';
Propel::init(__DIR__ . "/configs/airtime-conf-production.php");
require_once __DIR__ . "/configs/constants.php";
require_once 'Preference.php';
require_once "DateHelper.php";
require_once "OsPath.php";
require_once "Database.php";
require_once __DIR__ . '/controllers/plugins/RabbitMqPlugin.php';
date_default_timezone_set('UTC');
require_once APPLICATION_PATH . "/logging/Logging.php";
Logging::setLogPath('/var/log/airtime/zendphp.log');
date_default_timezone_set(Application_Model_Preference::GetTimezone());
global $CC_CONFIG;
$airtime_version = Application_Model_Preference::GetAirtimeVersion();
$uniqueid = Application_Model_Preference::GetUniqueId();
$CC_CONFIG['airtime_version'] = md5($airtime_version . $uniqueid);
require_once __DIR__ . "/configs/navigation.php";
Zend_Validate::setDefaultNamespaces("Zend");
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new RabbitMqPlugin());
/* The bootstrap class should only be used to initialize actions that return a view.
   Actions that return JSON will not use the bootstrap class! */
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initDoctype()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
コード例 #6
0
ファイル: conf.php プロジェクト: RadioCampusFrance/airtime
 public static function setAirtimeVersion()
 {
     $airtime_version = Application_Model_Preference::GetAirtimeVersion();
     $uniqueid = Application_Model_Preference::GetUniqueId();
     self::$CC_CONFIG['airtime_version'] = md5($airtime_version . $uniqueid);
 }