Jump to content
Дизайн и модификация IPS Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
leonovich

HTTP ERROR 500 в (SD) Live Streams

Recommended Posts

Здравствуйте, снова проблема, помогите решить.

https://ps4.in.ua/streams/

Приложение работает, но при переходе на стрим пользователя вываливается 

Страница недоступна
Сайт пока не может обработать этот запрос.
HTTP ERROR 500

Ошибка 

FastCGI sent in stderr: "PHP message: PHP Fatal error:  Access level to IPS\sdlivestreams\modules\front\sdlivestreams\_view::changeAuthor() must be public (as in class IPS\Content\hook1246) in /www/***/applications/sdlivestreams/modules/front/sdlivestreams/view.php on line 29" while reading response header from upstream, client: 31.6.105.225, server: ***, request: "GET /streams/stream/2-bomzhi/ HTTP/1.1", upstream: "fastcgi://unix:/var/www/php-fpm/leonovich.sock:", host: "***", referrer: "https://***/streams/"

 

Файл view.php

Скрытый текст

<?php
/**
 * SolutionrDEVs Application
 * (SD) Live Streams
 *
 * @brief       View controller
 * @author      Dawid Baruch <dawid.baruch@solutiondevs.pl> <a href='https://www.solutiondevs.pl'>SolutionDEVs</a>
 * @copyright   (c) 2005 - 2018 SolutionDEVs
 * @package     SolutionDEVs Apps
 * @subpackage  (SD) Live Streams
 * @link        https://www.solutiondevs.pl
 * @link        https://www.ipsbeyond.pl
 * @since       04.01.2018
 * @version     1.0.0
 */

namespace IPS\sdlivestreams\modules\front\sdlivestreams;

/* To prevent PHP errors (extending class does not exist) revealing path */
if( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
    header( ( isset( $_SERVER[ 'SERVER_PROTOCOL' ] ) ? $_SERVER[ 'SERVER_PROTOCOL' ] : 'HTTP/1.0' ) . ' 403 Forbidden' );
    exit;
}

/**
 * view
 */
class _view extends \IPS\sdlivestreams\Stream\ControllerContent
{
    /**
     * [Content\Controller] Class
     */
    protected static $contentModel = 'IPS\sdlivestreams\Stream';

    /**
     * Stream
     *
     * @var \IPS\sdlivestreams\Stream
     */
    protected $stream;

    /**
     * Execute
     *
     * @return void
     */
    public function execute()
    {
        try
        {
            $this->stream = \IPS\sdlivestreams\Stream::load( \IPS\Request::i()->id );

            if( !$this->stream->canView( \IPS\Member::loggedIn() ) )
            {
                \IPS\Output::i()->error( $this->stream->container()->message( 'npv' ) ? : 'sd_livestreams_no_perm_to_view', '2SDLIVESTREAMS/7', 403 );
            }

            if( isset( $_SESSION[ 'ageVerification_coppa' ] ) && $this->stream->adult_content )
            {
                \IPS\Output::i()->error( $this->stream->container()->message( 'npa' ) ? : 'sd_livestreams_denied_age', '2SDLIVESTREAMS/8', 403 );
            }

            if( ( $this->stream->adult_content && !isset( $_SESSION[ 'ageVerification' ] ) ) && !\IPS\Request::i()->isAjax() && !( isset( \IPS\Request::i()->do ) && \IPS\Request::i()->do == 'embed' ) )
            {
                $form = new \IPS\Helpers\Form( 'ageverify', 'sd_livestreams_age_verify_button' );
                $form->add( new \IPS\Helpers\Form\Date( 'bday', null, true, array( 'max' => \IPS\DateTime::create() ) ) );

                if( $values = $form->values() )
                {
                    if( ( $values[ 'bday' ]->diff( \IPS\DateTime::create() )->y < 18 ) )
                    {
                        $_SESSION[ 'ageVerification_coppa' ] = true;
                        \IPS\Output::i()->error( $this->stream->container()->message( 'npa' ) ? : 'sd_livestreams_denied_age', '2SDLIVESTREAMS/9', 403 );
                    }

                    $_SESSION[ 'ageVerification' ] = true;
                    \IPS\Output::i()->redirect( $this->stream->url() );
                }

                \IPS\Output::i()->breadcrumb[] = array( null, \IPS\Member::loggedIn()->language()->addToStack( 'sd_livestreams_age_verify' ) );
                \IPS\Output::i()->title        = \IPS\Member::loggedIn()->language()->addToStack( 'sd_livestreams_age_verify' );
                \IPS\Output::i()->output       = \IPS\Theme::i()->getTemplate( 'view', 'sdlivestreams', 'front' )->formBox( $form );

                return;
            }

            if( $this->stream->_cover )
            {
                \IPS\Output::i()->metaTags[ 'og:image' ] = $this->stream->_cover;
            }
        }
        catch( \OutOfRangeException $e )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_perm_to_view', '2SDLIVESTREAMS/8', 404 );
        }

        \IPS\Output::i()->sidebar[ 'contextual' ] = false;

        parent::execute();
    }

    /**
     * Show stream
     *
     * @return void
     */
    protected function manage()
    {
        if( $this->stream->_previewImage != '' )
        {
            \IPS\Output::i()->metaTags[ 'og:image' ] = $this->stream->_previewImage;

            if( \count( $this->stream->tags() ) )
            {
                \IPS\Output::i()->metaTags[ 'og:object:tag' ] = $this->stream->tags();
            }
        }

        $class    = static::$contentModel;
        $idColumn = \IPS\sdlivestreams\Stream::$databaseColumnId;

        /* If this is an AJAX request (like the topic hovercard), we don't want to do any of the below like update views and mark read */
        if( \IPS\Request::i()->isAjax() && !$this->updateViewsAndMarkersOnAjax )
        {
            /* But we do want to mark read if we are paging through the content */
            if( $this->stream instanceof \IPS\Content\ReadMarkers && isset( \IPS\Request::i()->page ) && \IPS\Request::i()->page AND $this->stream->isLastPage() )
            {
                $this->stream->markRead();
            }

            /* We also want to update the views if we have a page parameter */
            if( $this->stream instanceof \IPS\Content\ReadMarkers && isset( \IPS\Request::i()->page ) && \IPS\Request::i()->page )
            {
                if( \in_array( 'IPS\Content\Views', class_implements( $class ) ) AND isset( \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'views' ] ) )
                {
                    \IPS\Db::i()->insert( 'core_view_updates', array(
                        'classname' => $class,
                        'id'        => $this->stream->$idColumn,
                    ) );
                }
            }
        }

        /* Do we need to convert any legacy URL parameters? */
        if( $redirectToUrl = $this->stream->checkForLegacyParameters() )
        {
            \IPS\Output::i()->redirect( $redirectToUrl );
        }

        /* Check we're on a valid page */
        $paginationType = 'comment';

        if( isset( \IPS\Request::i()->tab ) and \IPS\Request::i()->tab === 'reviews' )
        {
            $paginationType = 'review';
        }
        elseif( isset( \IPS\Request::i()->tab ) && \IPS\Request::i()->tab === 'status' )
        {
            $paginationType = 'status';
        }
        elseif( isset( \IPS\Request::i()->tab ) && \IPS\Request::i()->tab === 'donate' )
        {
            $paginationType = 'donate';
        }

        $pageCount = \call_user_func( array( $this->stream, "{$paginationType}PageCount" ) );

        if( isset( \IPS\Request::i()->page ) )
        {
            $paginationType = null;
            $container      = ( isset( \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'container' ] ) ) ? $this->stream->container() : null;

            if( \IPS\sdlivestreams\Stream::supportsComments( null, $container ) )
            {
                $paginationType = 'comment';
            }

            if( ( isset( \IPS\Request::i()->tab ) && \IPS\Request::i()->tab === 'reviews' && \IPS\sdlivestreams\Stream::supportsReviews( null, $container ) ) || ( \IPS\sdlivestreams\Stream::supportsReviews( null, $container ) && $paginationType === null ) )
            {
                $paginationType = 'review';
            }

            if( isset( \IPS\Request::i()->tab ) && \IPS\Request::i()->tab === 'status' && \IPS\Settings::i()->sdlivestreams_statuses_tab )
            {
                $paginationType = 'status';
            }

            if( isset( \IPS\Request::i()->tab ) && \IPS\Request::i()->tab === 'donate' && \IPS\Settings::i()->sdlivestreams_inside_logs && \IPS\Settings::i()->sdlivestreams_use_inside_donation )
            {
                $paginationType = 'donate';
            }

            if( $paginationType !== null )
            {
                $pageCount = \call_user_func( array( $this->stream, "{$paginationType}PageCount" ) );

                if( $pageCount and \IPS\Request::i()->page > $pageCount )
                {
                    \IPS\Output::i()->redirect( \call_user_func( array( $this->stream, 'last' . ucfirst( $paginationType ) . 'PageUrl' ) ), null, 303 );
                }
            }

            /* Add rel tags */
            if( \IPS\Request::i()->page != 1 )
            {
                \IPS\Output::i()->linkTags[ 'first' ] = (string) $this->stream->url();

                if( \IPS\Request::i()->page - 1 > 1 )
                {
                    \IPS\Output::i()->linkTags[ 'prev' ] = (string) $this->stream->url()->setQueryString( 'page', \IPS\Request::i()->page - 1 );
                }
                else
                {
                    \IPS\Output::i()->linkTags[ 'prev' ] = (string) $this->stream->url();
                }
            }
            /* If we literally requested ?page=1 add canonical tag to get rid of the page query string param */
            elseif( isset( $this->stream->url()->data[ \IPS\Http\Url::COMPONENT_QUERY ][ 'page' ] ) )
            {
                \IPS\Output::i()->linkTags[ 'canonical' ] = (string) $this->stream->url();
            }
        }

        /* Add rel tags */
        if( $pageCount > 1 && ( !\IPS\Request::i()->page || $pageCount > \IPS\Request::i()->page ) )
        {
            \IPS\Output::i()->linkTags[ 'next' ] = (string) $this->stream->url()->setQueryString( 'page', ( \IPS\Request::i()->page ? : 1 ) + 1 );
        }
        if( $pageCount > 1 && ( !\IPS\Request::i()->page || $pageCount != \IPS\Request::i()->page ) )
        {
            \IPS\Output::i()->linkTags[ 'last' ] = (string) $this->stream->url()->setQueryString( 'page', $pageCount );
        }

        /* Update Views */
        $idColumn = \IPS\sdlivestreams\Stream::$databaseColumnId;

        if( \in_array( 'IPS\Content\Views', class_implements( $class ) ) AND isset( \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'views' ] ) )
        {
            \IPS\Db::i()->insert( 'core_view_updates', array(
                'classname' => $class,
                'id'        => $this->stream->$idColumn,
            ) );
        }

        /* Mark read */
        if( $this->stream instanceof \IPS\Content\ReadMarkers )
        {
            /* Note time last read before we mark it read so that the line is in the right place */
            $this->stream->timeLastRead();

            if( $this->stream->isLastPage() )
            {
                $this->stream->markRead();
            }
        }

        /* Set navigation and title */
        $this->_setBreadcrumbAndTitle( $this->stream, false );

        /* Set meta tags */
        \IPS\Output::i()->linkTags[ 'canonical' ]      = (string) ( \IPS\Request::i()->page > 1 ) ? $this->stream->url()->setQueryString( 'page', \IPS\Request::i()->page ) : $this->stream->url();
        \IPS\Output::i()->metaTags[ 'description' ]    = $this->stream->metaDescription();
        \IPS\Output::i()->metaTags[ 'og:title' ]       = $this->stream->mapped( 'title' );
        \IPS\Output::i()->metaTags[ 'og:type' ]        = 'object';
        \IPS\Output::i()->metaTags[ 'og:url' ]         = (string) $this->stream->url();
        \IPS\Output::i()->metaTags[ 'og:description' ] = $this->stream->metaDescription();

        if( $this->stream->mapped( 'updated' ) || $this->stream->mapped( 'last_comment' ) || $this->stream->mapped( 'last_review' ) )
        {
            \IPS\Output::i()->metaTags[ 'og:updated_time' ] = \IPS\DateTime::ts( $this->stream->mapped( 'updated' ) ? $this->stream->mapped( 'updated' ) : ( $this->stream->mapped( 'last_comment' ) ? $this->stream->mapped( 'last_comment' ) : $this->stream->mapped( 'last_review' ) ) )->rfc3339();
        }

        $tags = array();

        if( $this->stream->prefix() !== null )
        {
            $tags[] = $this->stream->prefix();
        }

        if( $this->stream->tags() !== null )
        {
            $tags = array_merge( $tags, $this->stream->tags() );
        }

        if( \count( $tags ) )
        {
            \IPS\Output::i()->metaTags[ 'keywords' ] = implode( ', ', $tags );
        }

        /* Add contextual search options */
        \IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_' . \IPS\sdlivestreams\Stream::$title ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ), 'item' => $this->stream->$idColumn );

        try
        {
            $container                                                                                                                                         = $this->stream->container();
            \IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_' . $container::$nodeTitle ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ), 'nodes' => $container->_id );
        }
        catch( \BadMethodCallException $e )
        {
        }

        $tabs               = $this->stream->commentReviewTabs();
        $_tabs              = array_keys( $tabs );
        $tab                = isset( \IPS\Request::i()->tab ) ? \IPS\Request::i()->tab : array_shift( $_tabs );
        $activeTabContents  = $this->stream->commentReviews( $tab );
        $commentsAndReviews = \count( $tabs ) ? \IPS\Theme::i()->getTemplate( 'global', 'core' )->commentsAndReviewsTabs( \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $this->stream->url(), 'tab', false, true ), md5( $this->stream->url() ) ) : null;

        if( \IPS\Request::i()->isAjax() )
        {
            \IPS\Output::i()->output = $activeTabContents;

            return;
        }

        /* Online User Location */
        \IPS\Session::i()->setLocation( $this->stream->url(), $this->stream->onlineListPermissions(), 'loc_sdlivestreams_viewing_stream', array( $this->stream->name => false ) );

        /* Display */
        \IPS\Output::i()->sidebar[ 'sticky' ] = false;
        \IPS\Output::i()->output              = \IPS\Theme::i()->getTemplate( 'view', 'sdlivestreams', 'front' )->view( $this->stream, $commentsAndReviews, $this->stream->nextItem(), $this->stream->prevItem() );
    }

    /**
     * Donate form
     */
    protected function donation()
    {
        if( !\IPS\Member::loggedIn()->member_id )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_perm_to_donate', '2SDLIVESTREAMS/10', 403 );
        }

        if( \IPS\Member::loggedIn()->member_id == $this->stream->member_id )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_perm_to_donate', '2SDLIVESTREAMS/11', 404 );
        }

        $currency   = isset( $_SESSION[ 'currency' ] ) ? $_SESSION[ 'currency' ] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
        $currencies = \IPS\nexus\Money::currencies();
        $costs      = json_decode( \IPS\Settings::i()->sdlivestreams_inside_transaction_fee, true );

        $form        = new \IPS\Helpers\Form( 'donation', 'sd_livestreams_donate_button' );
        $form->class = 'ipsForm_vertical';
        $form->add( new \IPS\Helpers\Form\Number( 'sd_livestreams_donate_amount', 10, true, array( 'min' => 1 ) ) );
        $form->add( new \IPS\Helpers\Form\Select( 'sd_livestreams_donate_currencues', null, true, array( 'options' => $currencies ) ) );

        if( \IPS\Settings::i()->sdlivestreams_inside_commision && \is_array( $costs ) && \count( $costs ) )
        {
            if( isset( $costs[ $currency ][ 'amount' ] ) )
            {
                \IPS\Member::loggedIn()->language()->words[ 'sd_livestreams_donate_amount_desc' ] = sprintf( \IPS\Member::loggedIn()->language()->get( 'sd_livestreams_cost_desc_both' ), \IPS\Settings::i()->sdlivestreams_inside_commision, new \IPS\nexus\Money( $costs[ $currency ][ 'amount' ], $currency ) );
            }
            else
            {
                \IPS\Member::loggedIn()->language()->words[ 'sd_livestreams_donate_amount_desc' ] = sprintf( \IPS\Member::loggedIn()->language()->get( 'sd_livestreams_cost_desc_commision' ), \IPS\Settings::i()->sdlivestreams_inside_commision );
            }
        }
        elseif( \IPS\Settings::i()->sdlivestreams_inside_commision )
        {
            \IPS\Member::loggedIn()->language()->words[ 'sd_livestreams_donate_amount_desc' ] = sprintf( \IPS\Member::loggedIn()->language()->get( 'sd_livestreams_cost_desc_commision' ), \IPS\Settings::i()->sdlivestreams_inside_commision );
        }
        elseif( \is_array( $costs ) && \count( $costs ) )
        {
            if( isset( $costs[ $currency ][ 'amount' ] ) )
            {
                \IPS\Member::loggedIn()->language()->words[ 'sd_livestreams_donate_amount_desc' ] = sprintf( \IPS\Member::loggedIn()->language()->get( 'sd_livestreams_cost_desc_fee' ), new \IPS\nexus\Money( $costs[ $currency ][ 'amount' ], $currency ) );
            }
        }

        if( $values = $form->values() )
        {
            $item     = new \IPS\sdlivestreams\extensions\nexus\Item\StreamDonate( sprintf( \IPS\Member::loggedIn()->language()->get( 'sd_livestreams_donate_invoice' ), $this->stream->name ), new \IPS\nexus\Money( $values[ 'sd_livestreams_donate_amount' ], $currencies[ $values[ 'sd_livestreams_donate_currencues' ] ] ) );
            $item->id = $this->stream->id;

            $item->payTo      = $this->stream->author();
            $item->commission = \IPS\Settings::i()->sdlivestreams_inside_commision;

            if( $fees = json_decode( \IPS\Settings::i()->sdlivestreams_inside_transaction_fee, true ) )
            {
                if( isset( $fees[ $currency ][ 'amount' ] ) )
                {
                    $item->fee = new \IPS\nexus\Money( $fees[ $currency ][ 'amount' ], $currency );
                }
            }

            /* Generate the invoice */
            $invoice         = new \IPS\nexus\Invoice;
            $invoice->member = \IPS\nexus\Customer::loggedIn();
            $invoice->addItem( $item );
            $invoice->return_uri = "app=sdlivestreams&module=sdlivestreams&controller=view&id={$this->stream->id}";
            $invoice->save();

            /* Take them to it */
            \IPS\Output::i()->redirect( $invoice->checkoutUrl() );
        }

        $this->_setBreadcrumbAndTitle( $this->stream );
        \IPS\Output::i()->output       = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
        \IPS\Output::i()->breadcrumb[] = array( null, \IPS\Member::loggedIn()->language()->addToStack( 'sd_livestreams_donate_inside' ) );
    }

    /**
     * Edit Item
     *
     * @return void
     */
    protected function edit()
    {
        try
        {
            if( !$this->stream->canEdit() && !\IPS\Request::i()->form_submitted ) // We check if the form has been submitted to prevent the user loosing their content
            {
                throw new \OutOfRangeException;
            }

            $container = null;

            try
            {
                $container = $this->stream->container();
            }
            catch( \BadMethodCallException $e )
            {
            }

            $this->_setBreadcrumbAndTitle( $this->stream );
            /* Build the form */
            $form = $this->stream->buildEditForm();

            if( $values = $form->values() )
            {
                if( $this->stream->canEdit() )
                {
                    if(!\IPS\Settings::i()->sdlivestreams_use_mock)
                    {
                    if( !array_key_exists( $values[ 'sd_livestreams_form_type' ], \IPS\sdlivestreams\Stream::getAvailableStreams() ) )
                    {
                        $form = \IPS\Theme::i()->getTemplate( 'submit', 'sdlivestreams', 'front' )->warningMessage( array( 'sd_livestreams_wrong_stype' ) ) . $form;

                        \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', false, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\sdlivestreams\Stream::$title ) ) ) ), $form, $container );

                        return;
                    }

                    if( $values[ 'sd_livestreams_channel_name' ] == '' && $values[ 'sd_livestreams_form_url' ] == '' )
                    {
                        $form = \IPS\Theme::i()->getTemplate( 'submit', 'sdlivestreams', 'front' )->warningMessage( array( 'sd_livestreams_error_no_name' ) ) . $form;

                        \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', false, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\sdlivestreams\Stream::$title ) ) ) ), $form, $container );

                        return;
                    }

                    if( isset( $values[ 'sd_livestreams_form_url' ] ) && $values[ 'sd_livestreams_form_url' ] != '' && !\IPS\sdlivestreams\Stream::checkValidStreamUrl( $values[ 'sd_livestreams_form_url' ] ) )
                    {
                        $form = \IPS\Theme::i()->getTemplate( 'submit', 'sdlivestreams', 'front' )->warningMessage( array( 'sd_livestreams_error_no_name' ) ) . $form;

                        \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', false, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\sdlivestreams\Stream::$title ) ) ) ), $form, $container );

                        return;
                    }

                    if( isset( $values[ 'sd_livestreams_form_url' ] ) && $values[ 'sd_livestreams_form_url' ] != '' && \IPS\sdlivestreams\Stream::checkValidStreamUrl( $values[ 'sd_livestreams_form_url' ] ) )
                    {
                        $name                                    = trim( $values[ 'sd_livestreams_form_url' ], '/' );
                        $name                                    = explode( '/', $name );
                        $values[ 'sd_livestreams_channel_name' ] = array_pop( $name );
                    }

                    if( !\IPS\sdlivestreams\Stream::checkIsValid( $values[ 'sd_livestreams_channel_name' ], $values[ 'sd_livestreams_form_type' ] ) )
                    {
                        $form = \IPS\Theme::i()->getTemplate( 'submit', 'sdlivestreams', 'front' )->warningMessage( array( 'sd_livestreams_not_valid_stream' ) ) . $form;

                        \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', false, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\sdlivestreams\Stream::$title ) ) ) ), $form, $container );

                        return;
                    }
                    }

                    $this->stream->processForm( $values );

                    if( isset( \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'updated' ] ) )
                    {
                        $column                = \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'updated' ];
                        $this->stream->$column = time();
                    }

                    if( isset( \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'date' ] ) && isset( $values[ \IPS\sdlivestreams\Stream::$formLangPrefix . 'date' ] ) )
                    {
                        $column = \IPS\sdlivestreams\Stream::$databaseColumnMap[ 'date' ];

                        if( $values[ \IPS\sdlivestreams\Stream::$formLangPrefix . 'date' ] instanceof \IPS\DateTime )
                        {
                            $this->stream->$column = $values[ \IPS\sdlivestreams\Stream::$formLangPrefix . 'date' ]->getTimestamp();
                        }
                        else
                        {
                            $this->stream->$column = time();
                        }
                    }

                    $this->stream->save();
                    $this->stream->processAfterEdit( $values );

                    /* Moderator log */
                    \IPS\Session::i()->modLog( 'modlog__item_edit', array( \IPS\sdlivestreams\Stream::$title => false, $this->stream->url()->__toString() => false, \IPS\sdlivestreams\Stream::$title => true, $this->stream->mapped( 'title' ) => false ), $this->stream );

                    \IPS\Output::i()->redirect( $this->stream->url() );
                }
                else
                {
                    $form->error = \IPS\Member::loggedIn()->language()->addToStack( 'edit_no_perm_err' );
                }
            }

            \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'edit_title', false, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\sdlivestreams\Stream::$title ) ) ) ), $form, $container );
        }
        catch( \Exception $e )
        {
            \IPS\Log::debug( $e, 'content_debug' );
            \IPS\Output::i()->error( 'edit_no_perm_err', '2SDLIVESTREAMS/12', 404, '' );
        }
    }

    /**
     * Change Author
     */
    protected function changeAuthor()
    {
        /* Permission check */
        if( !$this->stream->canChangeAuthor() )
        {
            \IPS\Output::i()->error( 'no_module_permission', '2SDLIVESTREAMS/13', 403 );
        }

        /* Build form */
        $form = new \IPS\Helpers\Form;
        $form->add( new \IPS\Helpers\Form\Member( 'author', null, true ) );
        $form->class .= 'ipsForm_vertical';

        /* Handle submissions */
        if( $values = $form->values() )
        {
            $this->stream->changeAuthor( $values[ 'author' ] );
            \IPS\Output::i()->redirect( $this->stream->url() );
        }

        /* Display form */
        \IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
    }

    /**
     * Buy features
     */
    protected function buyFeature()
    {
        if( !$this->stream->canBuyFeature() )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_feature_perms', '2SDLIVESTREAMS/15', 403 );
        }

        $options = $this->stream->getFeaturesOptionsToBuy();

        if( !\count( $options ) )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_feature_perms', '2SDLIVESTREAMS/16', 403 );
        }

        $form = new \IPS\Helpers\Form( 'buy_form', 'sd_livestreams_buy_button' );
        $form->add( new \IPS\Helpers\Form\Radio( 'sd_livestreams_buy_choose', -1, true, array( 'options' => $options ) ) );

        if( $values = $form->values() )
        {
            $patern        = '\IPS\sdlivestreams\extensions\nexus\Item\Stream';
            $items         = array();
            $customer      = \IPS\nexus\Customer::loggedIn();
            $currency      = ( $customer->member_id === \IPS\nexus\Customer::loggedIn()->member_id ) ? ( isset( $_SESSION[ 'currency' ] ) ? $_SESSION[ 'currency' ] : $customer->defaultCurrency() ) : $customer->defaultCurrency();
            $promotionData = json_decode( \IPS\Settings::i()->sdlivestreams_promotion_data, true );

            $feature = $values[ 'sd_livestreams_buy_choose' ];

            $class = $patern . ucfirst( $feature );

            if( class_exists( $class ) )
            {
                $price    = new \IPS\nexus\Money( $promotionData[ $feature . '_price' ][ $currency ][ 'amount' ], $currency );
                $item     = new $class( sprintf( \IPS\Member::loggedIn()->language()->get( 'sd_livestreams_invoice_' . $feature ), $this->stream->name ), $price );
                $item->id = $this->stream->id;

                try
                {
                    $item->tax = \IPS\Settings::i()->sdlivestreams_promotion_tax ? \IPS\nexus\Tax::load( \IPS\Settings::i()->sdlivestreams_promotion_tax ) : null;
                }
                catch( \OutOfRangeException $e )
                {
                }

                $tax = null;

                try
                {
                    $tax = \IPS\Settings::i()->sdlivestreams_promotion_tax ? \IPS\nexus\Tax::load( \IPS\Settings::i()->sdlivestreams_promotion_tax ) : null;
                }
                catch( \OutOfRangeException $e )
                {
                }

                $item->renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( $price, new \DateInterval( "P{$promotionData[$feature .'_duration']}D" ), $tax );
                $items[]           = $item;
            }

            if( !\count( $items ) )
            {
                \IPS\Output::i()->error( 'sd_livestreams_no_feature_perms', '2SDLIVESTREAMS/17', 404 );
            }

            $invoice         = new \IPS\nexus\Invoice;
            $invoice->member = \IPS\nexus\Customer::loggedIn();

            foreach( $items as $item )
            {
                $invoice->addItem( $item );
            }

            $invoice->return_uri = "app=sdlivestreams&module=sdlivestreams&controller=view&id={$this->stream->id}";
            $invoice->save();

            \IPS\Output::i()->redirect( $invoice->checkoutUrl() );
        }

        \IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
    }

    /**
     * Set stream cover
     */
    protected function setCover()
    {
        if( !$this->stream->container()->bitoptions[ 'allowss' ] || !$this->stream->isOwner() )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_set_cover', '2SDLIVESTREAMS/18', 403 );
        }

        $form        = new \IPS\Helpers\Form;
        $form->class .= 'ipsForm_vertical';
        $image       = true;

        if( $this->stream->container()->maxdims )
        {
            $maxDims = explode( 'x', $this->stream->container()->maxdims );
            $image   = array( 'maxWidth' => $maxDims[ 0 ], 'maxHeight' => $maxDims[ 1 ] );
        }

        $form->add( new \IPS\Helpers\Form\Upload( 'sd_livestreams_cover', $this->stream->cover ? \IPS\File::get( 'sdlivestreams_StreamCover', $this->stream->cover ) : null, true, array(
            'storageExtension' => 'sdlivestreams_StreamCover',
            'image'            => $image,
            'maxFileSize'      => $this->stream->container()->maxss ? ( $this->stream->container()->maxss / 1024 ) : null,
            'multiple'         => false,
            'minimize'         => false,
        ) ) );

        if( $values = $form->values() )
        {
            $this->stream->cover = (string) $values[ 'sd_livestreams_cover' ];
            $this->stream->save();
            \IPS\Output::i()->redirect( $this->stream->url( 'changeCoverPosition' ) );
        }

        $this->_setBreadcrumbAndTitle( $this->stream );
        \IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
    }

    /**
     * Change cover position
     */
    protected function changeCoverPosition()
    {
        if( !$this->stream->container()->bitoptions[ 'allowss' ] || !$this->stream->isOwner() )
        {
            \IPS\Output::i()->error( 'sd_livestreams_no_set_cover', '2SDLIVESTREAMS/19', 403 );
        }

        if( $this->stream->cover == '' )
        {
            \IPS\Output::i()->redirect( $this->stream->url( 'setCover' ) );
        }

        if( isset( \IPS\Request::i()->offset ) )
        {
            $this->stream->cover_offset = \intval( \IPS\Request::i()->offset );
            $this->stream->save();

            if( \IPS\Request::i()->isAjax() )
            {
                \IPS\Output::i()->json( 'OK' );
            }
            else
            {
                \IPS\Output::i()->redirect( $this->stream->url() );
            }
        }

        $photo           = new \IPS\sdlivestreams\Helpers\CoverPhoto;
        $photo->file     = \IPS\File::get( 'sdlivestreams_StreamCover', $this->stream->cover );
        $photo->offset   = $this->stream->cover_offset;
        $photo->editable = true;
        $photo->object   = $this->stream;
        $this->_setBreadcrumbAndTitle( $this->stream );
        \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view', 'sdlivestreams', 'front' )->positionCover( $photo );
    }

    /**
     * Show hovercard
     */
    protected function hovercard()
    {
        \IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'view', 'sdlivestreams', 'front' )->hovercard( $this->stream ) );
    }
}

 

 

Edited by leonovich

Share this post


Link to post
Share on other sites

Ищите в приложении

	protected function changeAuthor( \IPS\Member $newAuthor, $log=TRUE )

Меняйте protected на public

  • Upvote 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...