function parseAndAddSRT($text, &$tree, $type) { $eregEvent = '/\\d+\\n(\\d\\d:\\d\\d:\\d\\d),(\\d\\d)\\d --> (\\d\\d:\\d\\d:\\d\\d),(\\d\\d)\\d\\n(.+?(\\n.+?)*)\\n\\n/'; preg_match_all($eregEvent, $text, $matches); if (count($matches[0]) === 0) { sendHTML('No subtitles found in SRT file for ' . strtolower($type) . '.'); } for ($i = 0; $i < count($matches[0]); $i++) { $tree[] = array('start' => $matches[1][$i] . '.' . $matches[2][$i], 'end' => $matches[3][$i] . '.' . $matches[4][$i], 'type' => $type, 'text' => str_replace("\n", '\\N', $matches[5][$i])); } return null; }
if (!try_get($_POST, 'send', $send) || $send != 'yes') { sendHTML(); } // set cookies try_get($_POST, 'fontname', $fontname, 'Arial'); try_get($_POST, 'fontsize', $fontsize, '16'); try_get($_POST, 'topColor', $topColor, '#FFFFF9'); try_get($_POST, 'botColor', $botColor, '#F9FFF9'); set_infinite_cookie('fontname', $fontname); set_infinite_cookie('fontsize', $fontsize); set_infinite_cookie('topColor', $topColor); set_infinite_cookie('botColor', $botColor); // Process if (!DEBUG2SRT2ASS) { if (!try_get($_FILES, 'top', $top) || $top['error'] !== 0 || !try_get($_FILES, 'bot', $bot) || $bot['error'] !== 0) { sendHTML('Error while uploading. Try again.'); } $outputName = preg_replace('/(\\.[a-zA-Z]{2,3})?\\.srt$/', '.ass', $bot['name']); $contentTop = file_get_contents($top['tmp_name']); $contentBot = file_get_contents($bot['tmp_name']); } else { $outputFile = 'file:///volume1/web/2srt2ass2/Hannibal.ass'; $contentTop = file_get_contents('file:///volume1/web/2srt2ass2/Hannibal.en.srt'); $contentBot = file_get_contents('file:///volume1/web/2srt2ass2/Hannibal.fr.srt'); } getStyles($fontname, $fontsize, $topColor, $botColor, $styles, $stylesKeys); cleanSRT($contentTop); cleanSRT($contentBot); $tree = array(array('start' => '00:00:01.00', 'end' => '00:00:03.00', 'type' => 'Mid', 'text' => 'Merged with 2SRT2ASS\\N(http://pas-bien.net/2srt2ass/)')); parseAndAddSRT($contentTop, $tree, 'Top'); parseAndAddSRT($contentBot, $tree, 'Bot');