Ejemplo n.º 1
0
include '../includes/errors.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $errors = array();
    if (empty($_POST['url'])) {
        $errors[] = "url";
    } else {
        $url = mysqli_real_escape_string($dbc, $_POST['url']);
        $check = checkIDVideo($url);
        if (mysqli_num_rows($check) == 1) {
            $errors[] = "exist";
        } else {
            if (!youtube_id_from_url($url)) {
                $id_url = null;
                $fail = $lang['ADD_VIDEO_CHECK_ID'];
            } else {
                $id_url = youtube_id_from_url($url);
            }
        }
    }
    if (isset($errors) && in_array('url', $errors)) {
        $error = $lang['AD_REQUIRED'];
    } else {
        if (isset($errors) && in_array('exist', $errors)) {
            $error = $lang['ADD_VIDEO_ID_EXIST'];
        }
    }
}
// END main IF submit condition
?>
	<div class="content-wrapper">
        <div class="container">
Ejemplo n.º 2
0
        echo $propiedades->foto18;
        ?>
"><img style="position:relative; left: 2px;" src="images/propiedades/<?php 
        echo $propiedades->foto18;
        ?>
" class="thumbs " /></a>
			<?php 
    }
    ?>
		</div>
		<?php 
}
?>
		<div id="video">
		<?php 
$youtubeid = youtube_id_from_url($propiedades->video);
if ($youtubeid != "") {
    ?>
			<iframe width="300" height="169" src="http://www.youtube.com/embed/<?php 
    echo $youtubeid;
    ?>
" frameborder="0" allowfullscreen></iframe>
		<?php 
}
?>
		</div>
                <?php 
if (isset($_GET['bymap'])) {
    ?>
                <p><a href="propiedades.php">Volver</a></p>
                <?php 
Ejemplo n.º 3
0
 public function ajax_add_attachment($article_id)
 {
     if (!bonus()) {
         $response['status'] = "Permission denied. Log in (on any tab) and try again.";
         $response['success'] = false;
         exit(json_encode($response));
     }
     $type = trim(urldecode($this->input->post("type")));
     $content1 = trim(urldecode($this->input->post("content1")));
     $content2 = trim(urldecode($this->input->post("content2")));
     if ($type == 'video') {
         $yt_id = youtube_id_from_url($content1);
         $vimeo_id = vimeo_id_from_url($content1);
         if ($yt_id) {
             $type = 'youtube';
             $content1 = $yt_id;
         } elseif ($vimeo_id) {
             $type = 'vimeo';
             $content1 = $vimeo_id;
         } else {
             $response['status'] = "Error: unsupported video URL";
             $response['success'] = false;
             exit(json_encode($response));
         }
         // #todo: twitter widgets
         // #todo: soundcloud
         // #todo: flickr slideshows
         // #todo: raw html
         // #todo: rich text sidebars
     } else {
         if ($type == 'html') {
         } else {
             $response['status'] = "Error: unsupported attachment type, " . $type;
             $response['success'] = false;
             exit(json_encode($response));
         }
     }
     $db_data = array('article_id' => $article_id, 'type' => $type, 'content1' => $content1, 'content2' => $content2);
     $attachment_id = $this->attachments_model->add_attachment($db_data);
     $attachment = $this->attachments_model->get_attachment($attachment_id);
     if ($attachment) {
         // return json serialized object
         $response = array('attachmentId' => $attachment_id, 'authorId' => $attachment->author_id, 'type' => $type, 'content1' => $attachment->content1, 'content2' => $attachment->content2, 'view' => $this->load->view('template/attachment-' . $type, $attachment, true), 'success' => true, 'status' => "Attachment added.");
         exit(json_encode($response));
     } else {
         $response['success'] = false;
         $response['status'] = "Adding the attachment failed.";
         exit(json_encode($response));
     }
 }
Ejemplo n.º 4
0
if (strlen($data['suggestedBy']) < 3 || strlen($data['suggestedBy']) > 20) {
    $errors[] = 'Ehdottajan nimen tulee olla 3-20 merkkiä pitkä.';
}
if (strlen($data['title']) < 3 || strlen($data['title']) > 20) {
    $errors[] = 'Videon nimen tulee olla 3-20 merkkiä pitkä.';
}
if (empty($data['url']) || !youtube_id_from_url($data['url'])) {
    $errors[] = 'Videon URL on pakollinen ja videon tulee olla YouTubesta';
}
if (!empty($errors)) {
    include '../controllers/showDVD.php';
} else {
    $video = new Video();
    $video->suggestedBy = htmlspecialchars($data['suggestedBy']);
    $video->title = htmlspecialchars($data['title']);
    $video->url = youtube_id_from_url($data['url']);
    $video->dvd = $dvd;
    $video->create();
    header('Location: ' . SITE_URL . '/' . $dvd . '/' . urlencode($URL[1]));
}
/**
 * Get youtube video ID from URL
 *
 * @param string $url
 * @return mixed Youtube video id or false if none found. 
 */
function youtube_id_from_url($url)
{
    $pattern = '%^# Match any youtube URL
		(?:https?://)?  # Optional scheme. Either http or https
		(?:www\\.)?      # Optional www subdomain
Ejemplo n.º 5
0
 $form = $form->add('type_video', 'choice', array('required' => true, 'choices' => array('YouTube' => 'YouTube', 'Dailymotion' => 'Dailymotion', 'Vimeo' => 'Vimeo')));
 $form = $form->add('video_link', 'text', array('required' => true));
 $form = $form->add('synopsis', 'textarea', array('required' => true));
 $form = $form->add('modules', 'choice', array('choices' => $selectmodules, 'required' => true));
 $form = $form->add('student_infos', 'choice', array('multiple' => true, 'choices' => $selectusers));
 $form = $form->add('prix', 'textarea');
 $form = $form->getForm();
 if ("POST" == $app['request']->getMethod()) {
     $form->handleRequest($app["request"]);
     if ($form->isValid()) {
         $data = $form->getData();
         $type = $data['type_video'];
         switch ($type) {
             case 'YouTube':
                 if (preg_match($rxyoutube, $data['video_link'])) {
                     $idvideo = youtube_id_from_url($data['video_link']);
                     if (!empty($id)) {
                         $imageurl = 'http://img.youtube.com/vi/' . $idvideo . '/0.jpg';
                     }
                 }
                 break;
             case 'Dailymotion':
                 $iddaylimotion = daylimotion_id_by_url($data['video_link']);
                 if (!empty($iddaylimotion)) {
                     $idvideo = $iddaylimotion;
                     $result = file_get_contents('https://api.dailymotion.com/video/' . $idvideo . '?fields=thumbnail_url');
                     $urlarray = json_decode($result);
                     $imageurl = $urlarray->{'thumbnail_url'};
                 }
                 break;
             case 'Vimeo':
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, $param1 = null, $param2 = null)
 {
     //Get a specific item
     $entry = Contentful::entries()->limitByType('2wKn6yEnZewu2SCCkus4as')->includeLinks(10)->get();
     /**
      * get youtube video ID from URL
      *
      * @param string $url
      * @return string Youtube video id or FALSE if none found. 
      */
     function youtube_id_from_url($url)
     {
         $pattern = '%^# Match any youtube URL
         (?:https?://)?  # Optional scheme. Either http or https
         (?:www\\.)?      # Optional www subdomain
         (?:             # Group host alternatives
           youtu\\.be/    # Either youtu.be,
         | youtube\\.com  # or youtube.com
           (?:           # Group path alternatives
             /embed/     # Either /embed/
           | /v/         # or /v/
           | /watch\\?v=  # or /watch\\?v=
           )             # End path alternatives.
         )               # End host alternatives.
         ([\\w-]{10,12})  # Allow 10-12 for 11 char youtube id.
         $%x';
         $result = preg_match($pattern, $url, $matches);
         if (false !== $result) {
             return $matches[1];
         }
         return false;
     }
     foreach ($entry['items'] as $key => $post) {
         if ($post['fields']['slug'] == $id) {
             //global $post;
             //content
             $blog['title'] = $post['fields']['title'];
             $blog['body'] = Markdown::parse($post['fields']['body']);
             $blog['slug'] = $post['fields']['slug'];
             //media
             $blog['imageId'] = $post['fields']['featuredImage']['sys']['id'];
             if (isset($post['fields']['gallery'])) {
                 //Prepare the gallery of images
                 foreach ($post['fields']['gallery'] as $keyId => $imgId) {
                     $id = $imgId['sys']['id'];
                     foreach ($entry['includes']['Asset'] as $key => $asset) {
                         if ($id == $asset['sys']['id']) {
                             $gallery[$key]['id'] = $asset['sys']['id'];
                             $gallery[$key]['imageUrl'] = $asset['fields']['file']['url'];
                         }
                     }
                 }
                 $blog['gallery'] = $gallery;
             }
             if (isset($post['fields']['location'])) {
                 $blog['location'] = $post['fields']['location'];
             }
             if (isset($post['fields']['video3'])) {
                 $blog['video'] = youtube_id_from_url($post['fields']['video3']);
             }
             if (isset($post['fields']['image'])) {
                 $blog['image'] = Image::cache(function ($image) use($post) {
                     $image->make($post['fields']['image'])->encode('data-url');
                 }, null, false);
             }
             //metadeta
             $blog['createdAt'] = $post['sys']['createdAt'];
         }
     }
     //get a specific asset
     $assets = Contentful::assets()->where('sys.id', '=', $blog['imageId'])->get();
     //setting the width of the image on the fly!
     $blog['imageUrl'] = Image::cache(function ($image) use($assets) {
         $image->make('http:' . $assets['items'][0]['fields']['file']['url'] . '?' . 'w=400&fm=jpg')->greyscale()->encode('data-url');
     }, null, false);
     $params = display($param1, $param2);
     $params['blog'] = $blog;
     return view('blog.item')->with($params);
 }
<?php

include_once 'api/youtube_api.php';
?>
<div class="rev-video">
	<?php 
$url_data = (string) $fields['field_video_embed']->raw;
$vid_id = youtube_id_from_url($url_data);
$view_count = get_view_count_v3($vid_id);
//print_r(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$vid_id}?alt=json"));
//print_r($vid_id);
print $fields['field_video_embed']->content;
?>
</div>
<div class="rev-video-caption">
	<div class="rev-video-title"><?php 
print $fields['field_video_title']->content;
?>
</div>
	<p><span>
	<?php 
//print !empty($fields['field_video_description']->content) ? $fields['field_video_description']->content : "0x";
if (!empty($view_count) && $view_count > $fields['field_video_description']->content) {
    echo $view_count . ' ';
} else {
    print !empty($fields['field_video_description']->content) ? $fields['field_video_description']->content : "0x";
}
?>
 views / <?php 
print $fields['field_video_duration']->content;
?>
Ejemplo n.º 8
0
     break;
 case 'image':
     $img = $row_w['image'];
     $alt = $row_w['content'];
     if (copy(CO_PATH . '/books/' . $book_owner . '/uploads/' . $img, $book_dir . '/Contents/images/' . $img)) {
         $img_url = '<p><img src="' . $img . '" alt="' . $alt . '" /></p>';
         $widget_content = $img_url;
     } else {
         echo "Canot Copy file";
     }
     break;
 case 'pagebreak':
     $widget_content = "{pagebreak}<br />";
     break;
 case 'video':
     $is_youtube = youtube_id_from_url($row_w['content']);
     if ($is_youtube) {
         copy('http://img.youtube.com/vi/' . $is_youtube . '/0.jpg', $book_dir . '/Contents/images/' . $is_youtube . '.jpg');
         $widget_content = '<img src="' . $is_youtube . '.jpg" alt="*" /><br />';
     } else {
         $widget_content = '<img src="video.jpg" alt="*" /><br />';
     }
     $widget_content .= '<a href="' . $row_w['content'] . '">' . $row_w['content'] . '</a><br />';
     if ($row_w['content2'] != '') {
         $widget_content .= '<em class="caption">' . $row_w['content2'] . '</em>' . "<br />";
     }
     $widget_content .= '<p>&nbsp;</p>';
     break;
 case 'quiz':
     $widget_content = '<br /><p><img src="quiz.jpg" alt="*" /></p>';
     $widget_content .= '<p><a href="' . $row_w['content'] . '">' . $row_w['content'] . '</a></p>';