-
Notifications
You must be signed in to change notification settings - Fork 11
/
youtubegeneratevideo.php
79 lines (66 loc) · 1.88 KB
/
youtubegeneratevideo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
$pageTitle = 'Generating YouTube Video';
ini_set( 'implicit_flush', 1 );
include_once( 'includes/session.php' );
// are we logged in? no → leave
if ( ! login_check( ) ) {
header( 'Location: /' );
exit( );
} else {
$me = $_SESSION['u'];
}
// are we admin? no → leave
if ( in_array( $me, getAdmins( ) ) ) {
} else {
header( 'Location: /' );
exit( );
}
include_once( 'includes/functions_cast.php' );
include_once( 'includes/functions_castvideo.php' );
include_once( 'includes/header.php' );
ob_flush( );
$action = 'Failure';
$body = '';
$style = ' panel-success';
/* Force rebuilding video, even if we have already uploaded one. */
$force = isset( $_GET[ 'force' ] ) ? true : false;
/* User wanting to see a specific cast, and shownotes file exists */
if ( $season !== '00' && $episode !== '00' && ( $meta = getCastHeader( $slug ) ) ) {
if ( file_exists( $meta[ 'ABSFILENAME' ] . '.ogg' ) ) {
if ( empty( $meta[ 'YOUTUBE' ] ) or $force ) {
flush( ); /* visitor should get better indication that the page is actually loading now */
ob_start( );
$reply = generateVideo( $season, $episode );
$debugoutput = ob_get_clean( );
} else {
$reply = false;
$debugoutput = 'This cast already has a YouTube Video';
}
} else {
$reply = false;
$debugoutput = 'Audio file missing on server?';
}
if ( $reply === false ) {
$style = 'panel-danger';
} else {
$action = 'Success';
}
/* XXX debug */
$body .= '<pre>' . print_r( $debugoutput, true ) . '</pre>';
$body .= '<p>' . print_r( $reply, true ) . '</p>';
} else {
$body = '<p>You didn’t supply a valid episode.</p>';
}
if ( $body !== '' ) {
echo <<<ACTIONMSG
<article class="panel panel-default {$style}">
<header class="panel-heading">
<h3 class="panel-title">{$action}</h3>
</header>
<div class="panel-body">
{$body}
</div>
</article>
ACTIONMSG;
}
include_once( 'includes/footer.php' );