Example #1
0
 public static function book($showId, $seats)
 {
     $qfx = new self();
     $qfx->showId = $showId;
     $qfx->seatsToBook = $seats;
     return $qfx->login() && $qfx->getSeats() && $qfx->addSeats() && $qfx->confirmSeats();
 }
Example #2
0
 /**
  * @param array $params
  * @return UTIL_Ftp
  */
 public static function getConnection(array $params)
 {
     if (!function_exists('ftp_connect')) {
         throw new LogicException(self::ERROR_FTP_FUNCTION_IS_NOT_AVAILABLE);
     }
     if (empty($params['host'])) {
         throw new InvalidArgumentException(self::ERROR_EMPTY_HOST_PROVIDED);
     }
     if (empty($params['login']) || empty($params['password'])) {
         throw new InvalidArgumentException(self::ERROR_EMPTY_CREDENTIALS_PROVIDED);
     }
     $connection = new self();
     if (!empty($params['timeout'])) {
         $connection->setTimeout((int) $params['timeout']);
     }
     if (!$connection->connect(trim($params['host']), !empty($params['port']) ? (int) $params['port'] : 21)) {
         throw new LogicException(self::ERROR_CANT_CONNECT_TO_HOST);
     }
     if (!$connection->login(trim($params['login']), trim($params['password']))) {
         throw new LogicException(self::ERROR_INVALID_CREDENTIALS_PROVIDED);
     }
     $connection->init();
     return $connection;
 }
Example #3
0
 /**
  * @param array $params
  * @return UTIL_Ftp
  */
 public static function getConnection(array $params)
 {
     if (empty($params['host'])) {
         throw new InvalidArgumentException('Empty host provided for connection');
     }
     $connection = new self();
     if (!empty($params['timeout'])) {
         $connection->setTimeout((int) $params['timeout']);
     }
     $connected = $connection->connect(trim($params['host']), !empty($params['port']) ? (int) $params['port'] : 21);
     if (!$connected) {
         throw new LogicException("Can't connect to host `" . trim($params['host']) . "` by FTP");
     }
     if (!empty($params['login']) && !empty($params['password'])) {
         $connection->login(trim($params['login']), trim($params['password']));
     }
     $connection->init();
     return $connection;
 }
Example #4
0
 public static function loginGuest()
 {
     if (Yii::$app->user->isGuest) {
         $usr = new self();
         if ($usr->login()) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }