예제 #1
0
파일: Access.php 프로젝트: m3uzz/onionsrv
 public static function hasAccess()
 {
     $lsIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "";
     $lsClient = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
     $lsToken = isset($_SERVER['HTTP_TOKEN']) ? $_SERVER['HTTP_TOKEN'] : "";
     $lbReturn = false;
     $lsStatus = "DENIED";
     Debug::debug(array($lsIp, $lsClient, $lsToken));
     $laAccess = Config::getOptions('access');
     Debug::debug($laAccess);
     if (isset($laAccess[$lsIp])) {
         Debug::debug('1');
         if (isset($laAccess[$lsIp]['user-agent'][$lsClient])) {
             Debug::debug('1.1');
             if ($laAccess[$lsIp]['user-agent'][$lsClient] == $lsToken) {
                 Debug::debug('1.1.1');
                 $lbReturn = true;
             }
         } elseif (isset($laAccess[$lsIp]['user-agent']['*'])) {
             Debug::debug('1.2');
             if ($laAccess[$lsIp]['user-agent']['*'] == $lsToken) {
                 Debug::debug('1.2.1');
                 $lbReturn = true;
             }
         }
     } elseif (isset($laAccess['*'])) {
         Debug::debug('2');
         if (isset($laAccess['*']['user-agent'][$lsClient])) {
             Debug::debug('2.1');
             if ($laAccess['*']['user-agent'][$lsClient] == $lsToken) {
                 Debug::debug('2.1.1');
                 $lbReturn = true;
             }
         } elseif (isset($laAccess['*']['user-agent']['*'])) {
             Debug::debug('2.2');
             if ($laAccess['*']['user-agent']['*'] == $lsToken) {
                 Debug::debug('2.2.2');
                 $lbReturn = true;
             }
         }
     }
     if ($lbReturn) {
         $lsStatus = "PERMITED";
     }
     Event::log(array("ip:[{$lsIp}]", "user-agent:[{$lsClient}]", "token:[{$lsToken}]", "status:[{$lsStatus}]"), 'access');
     return $lbReturn;
 }
예제 #2
0
파일: System.php 프로젝트: m3uzz/onionsrv
 /**
  * Shell command
  *
  * @param string $psCommand	string a ser executada no sistema
  * @param string $psCommand2        	
  * @return array
  */
 public static function execute($psCommand, $psCommand2 = "")
 {
     $laOutput = array();
     $lnReturn = 0;
     $lsReturn = exec($psCommand . " 2>&1 " . $psCommand2, $laOutput, $lnReturn);
     if ($lnReturn != 0) {
         Event::log("FILESYSTEM: " . $lsReturn, 'execute', 'error');
     }
     return $laOutput;
 }