frontend/controllers/ProxyController.php
/**
     * Prepares request and redirects to stream URL
     *
     * @param  string $hash
     * @return mixed
     */
Prepares request and redirects to stream URL
@param  string $hash
@return mixed
Prepares request and redirects to stream URL @param string $hash @return mixed
public function actionProcessStream($hash)
    {
        $user = Yii::$app->user->identity;
        $link = UnrestrainedLink::findByHash($hash);
        if ($link == null) {
            throw new NotFoundHttpException('Page not found.');
        }
        $ticket = new Ticket();
        $ticket->setScenario(Ticket::SCENARIO_CREATE);
        $ticket->setOwner($user);
        if (!$ticket->save()) {
            Yii::error('Failed to create ticket.');
            throw new HttpException(500, 'Internal server error occured. Please try again later.');
        }
        $query = ArrayHelper::merge(['ticket' => $ticket->ticket], $this->processHeaders());
        if ($this->canProceed($user, $link)) {
            return $this->redirect($link->stream_link.'?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986));
        } else {
            return $this->redirect(Url::to(['/credits']));
        }
    }
public function actionProcessStream ( $ hash ) { $ user = Yii :: $ app -> user -> identity ; $ link = UnrestrainedLink :: findByHash ( $ hash ) ; if ( $ link == null ) { throw new NotFoundHttpException ( 'Page not found.' ) ; } $ ticket = new Ticket ( ) ; $ ticket -> setScenario ( Ticket :: SCENARIO_CREATE ) ; $ ticket -> setOwner ( $ user ) ; if ( ! $ ticket -> save ( ) ) { Yii :: error ( 'Failed to create ticket.' ) ; throw new HttpException ( 500 , 'Internal server error occured. Please try again later.' ) ; } $ query = ArrayHelper :: merge ( [ 'ticket' => $ ticket -> ticket ] , $ this -> processHeaders ( ) ) ; if ( $ this -> canProceed ( $ user , $ link ) ) { return $ this -> redirect ( $ link -> stream_link . '?' . http_build_query ( $ query , '' , '&' , PHP_QUERY_RFC3986 ) ) ; } else { return $ this -> redirect ( Url :: to ( [ '/credits' ] ) ) ; } }
Prepares request and redirects to stream URL
 @param  string $hash
 @return mixed
Prepares request and redirects to stream URL @param string $hash @return mixed
//Find link //Create new ticket //Proxy HTTP headers //Go to stream