-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetpinimagevideo.php
151 lines (135 loc) · 4.02 KB
/
getpinimagevideo.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
session_start();
require_once("lib/db.function.php");
include('config/config1.php');
if($_SESSION['login_user_id']=="")
{
echo '<h1 style="color:red;">You Should Login To www.alacut.com!!</h1>';
exit();
}
//print_r($_REQUEST);
$shareUrl =$_REQUEST['url'];
$objectVal='';
$name='';
$vid=0;
if(strstr($shareUrl, "youtu.be" ))
{
for($i=0;$i<strlen($shareUrl);$i++)
{
$last=$index;
if($index == '')
{
$start=0;
}
else
$start=$index+1;
$index=strpos($shareUrl,"/",$start);
if(!$index)
break;
}
$shareUrl=substr($shareUrl,$last+1,strlen($shareUrl));
$name = "youtube";
$objectVal = $shareUrl;
}
else if(strstr($shareUrl, "www.youtube.com"))
{
$pos=strpos($shareUrl,"v=",0);
$shareUrl=substr($shareUrl,$pos+2,strlen($shareUrl));
$pos2=strpos($shareUrl,"&",0);
if($pos2>0)
{
$shareUrl=substr($shareUrl,0,$pos2);
}
/*if(url.lastIndexOf("&")!=-1)
{
url=url.split("&")[0];
}*/
$name = "youtube";
$objectVal = $shareUrl;
}
else if(strstr($shareUrl,"vimeo.com"))
{
$pos1=strpos($shareUrl,"#",0);
if($pos1 >0)
{
$shareUrl=substr($shareUrl,0,$pos);
}
$pos2=strpos($shareUrl,"/",0);
if($pos2 >0)
{
$last='';
for($i=0;$i<strlen($shareUrl);$i++)
{
$last=$index;
if($index == '')
{
$start=0;
}
else
$start=$index+1;
$index=strpos($shareUrl,"/",$start);
if(!$index)
break;
}
$shareUrl=substr($shareUrl,$last+1,strlen($shareUrl));
}
/*url=url.split("#")[0];
if(url.lastIndexOf("/")!=-1)
url=url.substring(url.lastIndexOf("/")+1,url.length);
$("#div_youTube").attr("src","http://player.vimeo.com/video/"+url);*/
$name = "vimeo";
$objectVal = $shareUrl;
}
$user_check = $_SESSION['login_user_id'];
$qry='';
if($user_check !='')
{
if($name == "youtube" )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://gdata.youtube.com/feeds/api/videos/'.$objectVal);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
if ($response) {
$xml = new SimpleXMLElement($response);
$title = str_replace(array("'"),array(''),(string) $xml->title);
$desc=str_replace(array("'"),array(''),(string) $xml->content);
require_once("youtubeLength.php");
$lngth=getYouTubeVideoLength($objectVal);
if($lngth==0 || $lngth>240)
{
echo '<h1 style="color:red;">Video Length is more than 4 minute.Please pin video that are less than 4 minute!!</h1>';
exit();
}
} else {
$title='';$desc='';
}
$uploadVideoSql = "INSERT INTO `upload_video`(`video_upload_by`,`video_name`,`video_url`,`video_object`,`video_desc`,`video_type`,`video_image`) VALUES ('".$user_check."','".$title."','".$_REQUEST['url']."','".$objectVal."','".$desc."','".$name."','http://i1.ytimg.com/vi/".$objectVal."/mqdefault.jpg')";
$qry=mysql_query($uploadVideoSql);
$vid= mysql_insert_id();
/*$uploadVideoSql = "INSERT INTO `upload_video`(`video_upload_by`,`video_name`,`video_url`,`video_object`,`video_desc`,`video_type`) VALUES ('".$user_check."','$videoTitle','".$_REQUEST['url']."','".$videoObject."','$Description','".$name."')";*/
}
else if($name == "vimeo")
{
$videoObject = $objectVal;
$vimeoDetails = vimeoVideoDetails($videoObject);
$description = $vimeoDetails->description;
$desc = str_replace(array("'")," ",$description);
$title = $vimeoDetails->title;
$tit = str_replace(array("'")," ",$title);
$duration = $vimeoDetails->duration;
$img=$vimeoDetails->thumbnail_medium;
if($duration==0 || $duration > 240)
{
echo '<h1 style="color:red;">Video Length is more than 4 minute.Please pin video that are less than 4 minute!!</h1>';
exit();
}
$vimeoVideoSql = "INSERT INTO `upload_video`(`video_upload_by`,`video_name`,`video_url`,`video_object`,`video_desc`,`video_type`,`video_image`) VALUES ('".$user_check."','$tit','".$_REQUEST['url']."','".$videoObject."','$desc','".$name."','".$img."')";
$qry=mysql_query($vimeoVideoSql);
$vid= mysql_insert_id();
}
header("location:home.php");exit();
}
?>