-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideos.pl
executable file
·94 lines (71 loc) · 2.24 KB
/
videos.pl
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
#!/usr/bin/perl
use lib "lib";
use strict;
use template2;
use Profiles;
use Image::Magick;
use CM_Tags;
use List::Util qw(first);
use points;
use video::videoEgg;
{
my $P = Profiles->new();
$P->{page}{videoEgg} = 1;
if ($P->{command} eq "/minipicker") {
minipicker($P);
} elsif ($P->{command} eq "/picked") {
picked($P);
}
}
sub minipicker {
my ($P) = @_;
my $show = $P->{query}->param('show') || 5;
my $offset = $P->{query}->param('offset') || 0;
if ($offset < 0) { $offset = 0; }
my ($sql,$sth,$count);
$sql = "SELECT count(1) FROM videos WHERE userId=$P->{user}{user}{id}";
$sth = $P->{dbh}->prepare($sql);
$sth->execute;
my $count = $sth->fetchrow;
$sth->finish;
$sql = "SELECT * FROM videos WHERE userId=$P->{user}{user}{id} ORDER BY id DESC LIMIT $offset,$show;";
$sth = $P->{dbh}->prepare($sql);
$sth->execute;
my $shown = 0;
while (my $video = $sth->fetchrow_hashref) {
push(@{$P->{user}{videos}},{video => $video});
$shown++;
}
if ($count > ($offset+$shown)) {
$P->{user}{page}{more} = $offset + $shown;
}
if ($offset > 0) {
my $less =$offset - $show;
$less = 0 if ($less < 0);
$P->{user}{page}{less} = $less;
}
my $mode = $P->{query}->param('mode');
my $ve = video::videoEgg->new(dbh => $P->{dbh}, user => $P->{user}, cache => $P->{cache});
$P->{user}{page}{videoPublisher} = $ve->publisher;
print $P->Header();
if ($mode eq "" || $mode eq "qow") {
print processTemplate($P->{user},"videos.minipicker.html",1);
} elsif ($mode eq "videocontest") {
print processTemplate($P->{user},"videos.minipicker-videocontest.html",1);
}
}
sub picked {
my ($P) = @_;
$P->{user}{video} = $P->{dbh}->selectrow_hashref("SELECT * FROM videos WHERE id = ?",undef,$P->{query}->param('id'));
$P->{user}{page}{contest} = $P->{query}->param('contest');
$P->{user}{page}{remind} = $P->{query}->param('remind');
$P->{user}{entry}{ups} = $P->{query}->param('ups');
$P->{user}{entry}{downs} = $P->{query}->param('downs');
my $mode = $P->{query}->param('mode');
print $P->Header();
if ($mode eq "" || $mode eq "qow") {
print processTemplate($P->{user},"videos.picked.html",1);
} elsif ($mode eq "videocontest") {
print processTemplate($P->{user},"videos.picked-videocontest.html",1);
}
}