Example #1
0
function copyAlbum($album_id)
{
    global $cfg, $db;
    authenticate('access_admin', false, true);
    ini_set('max_execution_time', 0);
    if ($cfg['album_copy'] == false) {
        message(__FILE__, __LINE__, 'error', '[b]Error[/b][br]Album copy disabled');
    }
    if (is_dir($cfg['external_storage']) == false) {
        message(__FILE__, __LINE__, 'error', '[b]Failed to open directory:[/b][br]' . $cfg['external_storage'] . '[br][url=index.php?action=view3&album_id=' . $album_id . '][img]small_back.png[/img]Back to previous page[/url]');
    }
    $query = mysql_query('SELECT artist_alphabetic, album FROM album WHERE album_id = "' . mysql_real_escape_string($album_id) . '"');
    $album = mysql_fetch_assoc($query);
    if ($album == false) {
        message(__FILE__, __LINE__, 'error', '[b]Error[/b][br]album_id not found in database');
    }
    // formattedNavigator
    $nav = array();
    $nav['name'][] = 'Media';
    $nav['url'][] = 'index.php';
    $nav['name'][] = $album['artist_alphabetic'];
    $nav['url'][] = 'index.php?action=view2&artist=' . rawurlencode($album['artist_alphabetic']);
    $nav['name'][] = $album['album'];
    $nav['url'][] = 'index.php?action=view3&album_id=' . $album_id;
    $nav['name'][] = 'Copy album';
    require_once 'include/header.inc.php';
    ?>
<table cellspacing="0" cellpadding="0" class="border">
<tr class="header">
	<td class="space"></td>
	<td colspan="5"><span id="action"></span></td>
	<td class="space"></td>
</tr>
<tr class="line"><td colspan="7"></td></tr>
<?php 
    $i = 0;
    $query = mysql_query('SELECT title, artist FROM track WHERE album_id = "' . mysql_real_escape_string($album_id) . '" ORDER BY relative_file');
    while ($track = mysql_fetch_assoc($query)) {
        ?>
<tr class="<?php 
        echo $i++ & 1 ? 'even' : 'odd';
        ?>
">
	<td></td>
	<td><?php 
        echo html($track['artist']);
        ?>
</td>
	<td class="textspace"></td>
	<td><?php 
        echo html($track['title']);
        ?>
</td>
	<td class="textspace"></td>
	<td><span id="status<?php 
        echo $i;
        ?>
"></span></td>
	<td></td>
</tr>
<?php 
    }
    ?>
</table>
<?php 
    $cfg['footer'] = 'dynamic';
    require 'include/footer.inc.php';
    $query = mysql_query('SELECT artist_alphabetic, album, year FROM album WHERE album_id = "' . mysql_real_escape_string($album_id) . '"');
    $album = mysql_fetch_assoc($query);
    $destination = $cfg['external_storage'];
    $destination .= copyFilename($album['artist_alphabetic']) . '/';
    if (is_dir($destination) == false && @mkdir($destination, 0777) == false) {
        message(__FILE__, __LINE__, 'error', '[b]Failed to create directory:[/b][br]' . $destination);
    }
    $destination .= $album['year'] ? $album['year'] . ' - ' : '';
    $destination .= copyFilename($album['album']) . '/';
    if (is_dir($destination) == false && @mkdir($destination, 0777) == false) {
        message(__FILE__, __LINE__, 'error', '[b]Failed to create directory:[/b][br]' . $destination);
    }
    $i = 0;
    $query = mysql_query('SELECT track_id FROM track WHERE album_id = "' . mysql_real_escape_string($album_id) . '" ORDER BY relative_file');
    while ($track = mysql_fetch_assoc($query)) {
        $i++;
        echo '<script type="text/javascript">document.getElementById(\'action\').innerHTML=\'Transcode to ' . addslashes(html($cfg['encode_name'][$cfg['download_id']])) . '\';</script>' . "\n";
        echo '<script type="text/javascript">document.getElementById(\'status' . $i . '\').innerHTML=\'<img src="' . $cfg['img'] . 'small_animated_progress.gif" alt="" class="small">\';</script>' . "\n";
        @ob_flush();
        flush();
        $source = transcode($track['track_id'], $cfg['download_id']);
        $source = str_replace('\\', '/', $source);
        echo '<script type="text/javascript">document.getElementById(\'action\').innerHTML=\'Copy\';</script>' . "\n";
        @ob_flush();
        flush();
        $file = substr($source, strrpos($source, '/') + 1);
        $file = copyFilename($file);
        if (@copy($source, $destination . $file) == false) {
            message(__FILE__, __LINE__, 'error', '[b]Failed to copy[/b][br]from: ' . $source . '[br]to: ' . $destination . $file);
        }
        echo '<script type="text/javascript">document.getElementById(\'status' . $i . '\').innerHTML=\'<img src="' . $cfg['img'] . 'small_check.png" alt="" class="small">\';</script>' . "\n";
        @ob_flush();
        flush();
    }
    $cfg['footer'] = 'close';
    require 'include/footer.inc.php';
}
Example #2
0
/*
Logic handling upload of the streamlets
*/
if ($_FILES["uploaded"]["size"] < 20000000) {
    if ($_FILES["uploaded"]["error"] > 0) {
        $error = "Return Code: " . $_FILES["uploaded"]["error"];
        debug($error);
    } else {
        debug("Upload: " . $_FILES["uploaded"]["name"]);
        debug("Type: " . $_FILES["uploaded"]["type"]);
        debug("Size: " . $_FILES["uploaded"]["size"] / 1024 . " Kb");
        debug("Temp file: " . $_FILES["uploaded"]["tmp_name"]);
        $fullname = $_FILES["uploaded"]["name"];
        parseName($fullname);
        $videodir = "upload/" . $videoname . "/high";
        $videopath = "{$videodir}/{$videoname}-720*480---{$segmentNumber}.mp4";
        if (!file_exists($videodir)) {
            mkdir($videodir, 0777, true);
        }
        move_uploaded_file($_FILES["uploaded"]["tmp_name"], $videopath);
        debug("Stored in: {$videopath}");
        $tspath = "{$videodir}/{$videoname}-720*480---{$segmentNumber}.ts";
        system("/usr/local/bin/mp42ts {$videopath} {$tspath}");
        transcode();
        #      }
    }
} else {
    echo "Invalid file";
}
fclose($logfp);
exit;
Example #3
0
/**
 * This is being run to do stuff.
 */
function main($argv)
{
    $input = $argv[1];
    $csv = readCsvFile($input);
    $persons = transcode($csv);
    $groups = [];
    $counts = [];
    foreach ($persons as $k => $p) {
        $others = array_diff_key($persons, [$k => $p]);
        // remove person to avoid duplicate in group
        $group = createGroupFor($p, $others, $counts);
        $groups[] = $group;
    }
    saveIntoCsvFile($argv[2], $groups);
}
Example #4
0
            echo '[' . date('d/m/Y h:i:s') . '] DOING SHELL COMMAND: ' . $shell_command . chr(10);
            shell_exec($shell_command . ' 2>&1 >> log.txt');
        } else {
            return $path;
        }
    }
    return $path;
}
while (true) {
    $queue_dir = preg_replace('#\\\\#', '/', getcwd()) . '/queue';
    $fail_dir = preg_replace('#\\\\#', '/', getcwd()) . '/fail';
    $dh = opendir($queue_dir);
    while (($file = readdir($dh)) !== false) {
        if ($file != '.' && $file != '..' && is_file($queue_dir . '/' . $file)) {
            echo '[' . date('d/m/Y h:i:s') . '] Doing: "' . $file . '"' . chr(10);
            $done_path = transcode($queue_dir . '/' . $file);
            // Hopefully this will only create the actual file once it is fully done, if not we might need to have a temp directory also
            clearstatcache();
            if (file_exists($done_path) && filesize($done_path) != 0) {
                echo '[' . date('d/m/Y h:i:s') . '] Done: "' . $done_path . '"' . chr(10);
                unlink($queue_dir . '/' . $file);
                if (is_string(strstr($done_path, '/done/'))) {
                    $relative_url = 'done/' . rawurlencode(str_replace(dirname($done_path) . '/', '', $done_path));
                    $call = $liveserver . '/data_custom/receive_transcoded_file.php?url=' . $transcoder_server . $relative_url;
                    echo '[' . date('d/m/Y h:i:s') . '] Calling: ' . $call . chr(10);
                    file_get_contents($call);
                }
            } else {
                echo '[' . date('d/m/Y h:i:s') . '] Could not find output file (' . $done_path . ')' . chr(10);
                @unlink($queue_dir . '/' . $file);
                rename($queue_dir . '/' . $file, $fail_dir . '/' . $file);