!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/wincloud_gateway/node_modules/strapi-plugin-upload/admin/src/components/VideoPreview/   drwxr-xr-x
Free 13.23 GB of 57.97 GB (22.82%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     index.js (4.14 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import React, { useEffect, useReducer, useRef } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { FormattedMessage, useIntl } from 'react-intl';
import Duration from '../Duration';
import LoadingIndicator from '../LoadingIndicator';
import PlayIcon from '../PlayIcon';
import Wrapper from './Wrapper';
import CanvasWrapper from './CanvasWrapper';
import Thumbnail from './Thumbnail';
import reducer, { initialState } from './reducer';
import getTrad from '../../utils/getTrad';

const EmptyPreview = styled.div`
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: ${({ theme }) => theme.main.sizes.fonts.xs};
  color: ${({ theme }) => theme.main.colors.grey};
`;

const VideoPreview = ({ hasIcon, previewUrl, src }) => {
  const { formatMessage } = useIntl();
  const [reducerState, dispatch] = useReducer(reducer, initialState);
  const {
    duration,
    dataLoaded,
    isHover,
    metadataLoaded,
    snapshot,
    seeked,
    isError,
  } = reducerState.toJS();

  // Adapted from https://github.com/brothatru/react-video-thumbnail/blob/master/src/components/VideoThumbnail.js
  // And from https://github.com/soupette/poc-video-preview
  const canvasRef = useRef();
  const videoRef = useRef();

  useEffect(() => {
    const getSnapshot = () => {
      try {
        const video = videoRef.current;
        const canvas = canvasRef.current;

        canvas.height = video.videoHeight;
        canvas.width = video.videoWidth;
        canvas.getContext('2d').drawImage(video, 0, 0);

        const thumbnail = canvas.toDataURL('image/png');

        video.src = ''; // setting to empty string stops video from loading

        dispatch({
          type: 'SET_SNAPSHOT',
          snapshot: thumbnail,
        });
      } catch (e) {
        console.error(e);
      }
    };

    if (dataLoaded && metadataLoaded && videoRef.current) {
      videoRef.current.currentTime = 0;

      if (seeked && !snapshot) {
        getSnapshot();
      }
    }
  }, [dataLoaded, metadataLoaded, seeked, snapshot]);

  if (isError) {
    return (
      <EmptyPreview>
        <FormattedMessage id={getTrad('list.assets.not-supported-content')} />
      </EmptyPreview>
    );
  }

  return (
    <Wrapper
      // Specify isHover to prevent bad behavior when compo is under the cursor on modal open
      onMouseEnter={() => {
        dispatch({
          type: 'SET_IS_HOVER',
          isHover: true,
        });
      }}
      onMouseLeave={() => {
        dispatch({
          type: 'SET_IS_HOVER',
          isHover: false,
        });
      }}
    >
      {!snapshot && (
        <LoadingIndicator
          aria-label={formatMessage(
            {
              id: getTrad('list.assets.loading-asset'),
            },
            { path: src }
          )}
        />
      )}

      <CanvasWrapper>
        {previewUrl ? (
          <Thumbnail
            src={previewUrl}
            alt={formatMessage(
              {
                id: getTrad('list.assets.preview-asset'),
              },
              { path: src }
            )}
          />
        ) : (
          <>
            <video
              muted
              ref={videoRef}
              src={src}
              onError={() => dispatch({ type: 'SET_ERROR', isError: true })}
              onLoadedMetadata={() => {
                dispatch({
                  type: 'METADATA_LOADED',
                });
              }}
              onLoadedData={({ target: { duration } }) => {
                dispatch({
                  type: 'DATA_LOADED',
                  duration,
                });
              }}
              onSeeked={() => {
                dispatch({
                  type: 'SEEKED',
                });
              }}
            />
            <canvas ref={canvasRef} />
          </>
        )}
        <Duration duration={duration} />

        {(hasIcon || isHover) && <PlayIcon small />}
      </CanvasWrapper>
    </Wrapper>
  );
};

VideoPreview.defaultProps = {
  hasIcon: false,
  previewUrl: null,
  src: null,
};

VideoPreview.propTypes = {
  hasIcon: PropTypes.bool,
  previewUrl: PropTypes.string,
  src: PropTypes.string,
};

export default VideoPreview;

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0065 ]--