Exemplo n.º 1
0
 /**
  * Tests to make sure bad arguments are caught
  *
  * @expectedException RuntimeException
  * @return  void
  **/
 public function testInvalidArgumentThrowsException()
 {
     $ip = new \Hubzero\Utility\Ip('172.16.0.1');
     $ip->isBetween('rock', 'hard place');
 }
Exemplo n.º 2
0
 /**
  * Validate tool session data
  * 
  * @param   string  $toolSessionId     Tool session id
  * @param   string  $toolSessionToken  Tool session token
  * @return  bool    Result of test
  */
 public function validateToolSessionData($toolSessionId, $toolSessionToken)
 {
     // include neede libs
     require_once PATH_CORE . DS . 'components' . DS . 'com_tools' . DS . 'helpers' . DS . 'utils.php';
     // instantiate middleware database
     $mwdb = \Components\Tools\Helpers\Utils::getMWDBO();
     // attempt to load session from db
     $query = "SELECT * \n\t\t\t\t  FROM `session`\n\t\t\t\t  WHERE `sessnum`= " . $mwdb->quote($toolSessionId) . " \n\t\t\t\t  AND `sesstoken`=" . $mwdb->quote($toolSessionToken);
     $mwdb->setQuery($query);
     // only continue if a valid session was found
     if (!($session = $mwdb->loadObject())) {
         return false;
     }
     $ip = new \Hubzero\Utility\Ip(\App::get('request')->ip());
     // ip should be coming from a private address
     if (!$ip->isPrivate()) {
         return false;
     }
     // return user id
     $profile = \Hubzero\User\User::oneByUsername($session->username);
     return $profile->get('id');
 }