From f23cfb489c7a9ad4a585a91f37c2257b3881b2cc Mon Sep 17 00:00:00 2001
From: Paul Baranowski <paul.baranowski@sourcefabric.org>
Date: Tue, 12 Apr 2011 13:59:08 -0400
Subject: [PATCH] Moved function ExitIFNotRoot() to AirtimeInstall.php instead
 of AirtimeIni.php.

---
 install/airtime-install.php        |  4 ++--
 install/airtime-uninstall.php      |  4 ++--
 install/include/AirtimeIni.php     | 18 ++----------------
 install/include/AirtimeInstall.php | 14 ++++++++++++++
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/install/airtime-install.php b/install/airtime-install.php
index 8b203f6df..542ed18ff 100644
--- a/install/airtime-install.php
+++ b/install/airtime-install.php
@@ -8,13 +8,13 @@
 echo "******************************** Install Begin *********************************".PHP_EOL;
 
 require_once(dirname(__FILE__).'/include/AirtimeIni.php');
+require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
 
-AirtimeIni::ExitIfNotRoot();
+AirtimeInstall::ExitIfNotRoot();
 AirtimeIni::CreateIniFile();
 AirtimeIni::UpdateIniFiles();
 
 require_once(dirname(__FILE__).'/../application/configs/conf.php');
-require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
 
 echo PHP_EOL."*** Installing Airtime ".AIRTIME_VERSION." ***".PHP_EOL;
 
diff --git a/install/airtime-uninstall.php b/install/airtime-uninstall.php
index 298d3c945..ee96439a9 100644
--- a/install/airtime-uninstall.php
+++ b/install/airtime-uninstall.php
@@ -6,8 +6,9 @@
  */
 
 require_once(dirname(__FILE__).'/include/AirtimeIni.php');
+require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
 // Need to check that we are superuser before running this.
-AirtimeIni::ExitIfNotRoot();
+AirtimeInstall::ExitIfNotRoot();
 
 if (!file_exists('/etc/airtime/airtime.conf')) {
     echo PHP_EOL."Airtime config file '/etc/airtime/airtime.conf' does not exist.".PHP_EOL;
@@ -15,7 +16,6 @@ if (!file_exists('/etc/airtime/airtime.conf')) {
     exit();
 }
 require_once(dirname(__FILE__).'/../application/configs/conf.php');
-require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
 
 
 AirtimeInstall::RemoveSymlinks();
diff --git a/install/include/AirtimeIni.php b/install/include/AirtimeIni.php
index 7f199e81a..6cebc4bc2 100644
--- a/install/include/AirtimeIni.php
+++ b/install/include/AirtimeIni.php
@@ -35,7 +35,7 @@ class AirtimeIni{
                 exit(1);
             }
         }
-        
+
         if (!copy(__DIR__."/../../build/airtime.conf", "/etc/airtime/airtime.conf")){
             echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
             exit(1);
@@ -81,20 +81,6 @@ class AirtimeIni{
         }
     }
 
-    /**
-     * Ensures that the user is running this PHP script with root
-     * permissions. If not running with root permissions, causes the
-     * script to exit. 
-     */
-    static function ExitIfNotRoot()
-    {
-        // Need to check that we are superuser before running this.
-        if(exec("whoami") != "root"){
-            echo "Must be root user.\n";
-            exit(1);
-        }
-    }
-
     /**
      * This function generates a random string.
      *
@@ -132,7 +118,7 @@ class AirtimeIni{
      *      The property to look for in order to change its value.
      * @param string $p_value
      *      The value the property should be changed to.
-     *      
+     *
      */
     static function UpdateIniValue($p_filename, $p_property, $p_value)
     {
diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php
index bd3a568c2..9612cd9ed 100644
--- a/install/include/AirtimeInstall.php
+++ b/install/include/AirtimeInstall.php
@@ -4,6 +4,20 @@ require_once(dirname(__FILE__).'/../../library/pear/DB.php');
 require_once(dirname(__FILE__).'/../../application/configs/conf.php');
 
 class AirtimeInstall {
+    /**
+     * Ensures that the user is running this PHP script with root
+     * permissions. If not running with root permissions, causes the
+     * script to exit.
+     */
+    static function ExitIfNotRoot()
+    {
+        // Need to check that we are superuser before running this.
+        if(exec("whoami") != "root"){
+            echo "Must be root user.\n";
+            exit(1);
+        }
+    }
+
 
     static function DbTableExists($p_name)
     {