Example #1
0
             $filename = substr($file['name'], strrpos($file['name'], DIRECTORY_SEPARATOR) + 1);
             $ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
             $size = filesize($file['tmp_name']);
             if (in_array($ext, $exts)) {
                 if ($size < 2 * 1024 * 1024) {
                     $thumb = TRUE;
                 }
             }
         }
     }
 }
 if (!$thumb) {
     $errors[] = 'Please upload at least one video thumb!';
 }
 if (!$errors) {
     $sql = "INSERT INTO video\n\t\t                SET UID = " . $uid . ",\n\t\t\t\t\t\t    title = '" . mysql_real_escape_string($title) . "',\n\t\t\t\t\t\t\tkeyword = '" . mysql_real_escape_string($tags) . "',\n\t\t\t\t\t\t\tchannel = '" . $category . "',\n\t\t\t\t\t\t\ttype = '" . $video['type'] . "',\n\t\t\t\t\t\t\tembed_code = '" . mysql_real_escape_string($embed_code) . "',\n\t\t\t\t\t\t\tduration = " . duration_to_seconds($duration) . ",\n\t\t\t\t\t\t\tvkey = '" . mt_rand() . "',\n\t\t\t\t\t\t\taddtime = " . time() . ",\n\t\t\t\t\t\t\tadddate = '" . date('Y-m-d') . "',\n\t\t\t\t\t\t\tactive = '0'";
     $conn->execute($sql);
     $vid = mysql_insert_id();
     require $config['BASE_DIR'] . '/classes/image.class.php';
     $image = new VImageConv();
     $tmb_dir = $config['BASE_DIR'] . '/media/videos/tmb/' . $vid;
     $tmp_dir = $config['BASE_DIR'] . '/tmp/thumbs/' . $vid;
     @mkdir($tmb_dir);
     @mkdir($tmp_dir);
     $width = (int) $config['img_max_width'];
     $height = (int) $config['img_max_height'];
     $i = 1;
     foreach ($_FILES as $file) {
         $tmb = $i . '.jpg';
         if (move_uploaded_file($file['tmp_name'], $tmp_dir . '/' . $tmb)) {
             $src = $tmp_dir . '/' . $tmb;
Example #2
0
 }
 if ($embed) {
     if ($embed_code == '') {
         $errors[] = 'Please enter video embed code!';
     } else {
         $video['embed_code'] = $embed_code;
     }
     if (!$thumbs) {
         $errors[] = 'Failed to get the video thumbs. Are you sure the url is correct!?';
     } else {
         $video['thumbs'] = $thumbs;
     }
     if ($duration == '') {
         $errors[] = 'Please enter video duration';
     } else {
         $duration_seconds = duration_to_seconds($duration);
         if (!$duration_seconds) {
             $errors[] = 'Invalid video duration! Please use minutes:seconds (eg: 12:03, 00:17, 08:51...)!';
         } else {
             $video['duration'] = $duration;
         }
     }
 } else {
     if ($url == '') {
         $errors[] = 'Please enter a url for the flash video to be downloaded!';
     } else {
         $video['url'] = $url;
     }
     $video['size'] = trim($_POST['size']);
 }
 $video['site'] = trim($_POST['site']);
<?php

$duration = '1h m 49s';
echo duration_to_seconds($duration);
function duration_to_seconds($duration)
{
    $modifiers = array('d' => 86400, 'h' => 3600, 'm' => 60, 's' => 1);
    $seconds = 0;
    foreach (explode(' ', $duration) as $segment) {
        if (($len = strlen($segment)) > 1) {
            list($num, $mod) = str_split($segment, $len - 1);
            if (isset($modifiers[$mod]) && ctype_digit($num)) {
                $seconds += $num * $modifiers[$mod];
                continue;
            }
        }
        trigger_error('Unknown time specifier "' . $segment . '"', E_USER_ERROR);
    }
    return $seconds;
}