| Server IP : 103.82.32.14 / Your IP : 216.73.217.121 Web Server : Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 System : Linux cloud.lonmanhoabinh.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : lonmakmf ( 524) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/rubymnik/public_html/admin/ |
Upload File : |
<?php
include '../configchannel.php';
include 'configtotal.php';
$resultDate = mysqli_fetch_assoc(Select('SoLieuChannel', false, "" ,'`SoLieuChannel`.`NgayUpdate` DESC'));
$resultDateCheck = Select('SoLieuChannel', true, "`DoanhThu` > 0 AND `NgayUpdate` = '".$resultDate['NgayUpdate']."'" ,'`SoLieuChannel`.`NgayUpdate` DESC');
if($resultDateCheck > 0)
{
$ngaySQL = $resultDate['NgayUpdate'];
}
else
{
$thoiGianGioiHan = date('d/m/Y', strtotime('-1 day', strtotime($resultDate['NgayUpdate'])));
$date = explode('/', $thoiGianGioiHan);
$time = mktime(0,0,0,$date[1],$date[0],$date[2]);
$mysqldate = date( 'Y-m-d H:i:s', $time);
$ngaySQL = $mysqldate;
}
$ngayCapNhat = date("d/m/Y", strtotime($ngaySQL));
// get tổng ngày
$result = Select('SoLieuChannel', false, "`NgayUpdate` = '".$ngaySQL."'");
$tongDoanhThuNgay = 0;
$tongViewNgay = 0;
$tongGioXemNgay = 0;
while($res = mysqli_fetch_array($result))
{
$tongDoanhThuNgay = $tongDoanhThuNgay+$res['DoanhThu'];
$tongViewNgay = $tongViewNgay+$res['SoLuotXem'];
$tongGioXemNgay = $tongGioXemNgay+$res['GioXem'];
}
$thoiGianXemTrungBinhNgay = gmdate("i:s", ($tongGioXemNgay*60*60/$tongViewNgay));
// get tổng 28 ngày
$thoiGianGioiHan = date('d/m/Y', strtotime('-28 day', strtotime($ngaySQL)));
$date = explode('/', $thoiGianGioiHan);
$time = mktime(0,0,0,$date[1],$date[0],$date[2]);
$mysqldate = date( 'Y-m-d H:i:s', $time);
?>
<?php
// get danh sách channel
$resultchannel = SelectAll('QuanLyChannel',"SELECT QuanLyChannel.id AS IDChannelSQL, NameChannel, QuanLyChannel.IdChannel as IdKenh, NgayUpdate, SUM(SoLuotXem) AS TongLuotXem, ROUND(SUM(DoanhThu),0) AS TongDoanhThu, IdNguoiLam FROM QuanLyChannel JOIN SoLieuChannel ON QuanLyChannel.id = SoLieuChannel.IdChannel WHERE `DoanhThu` > 0 AND `NgayUpdate` <= '".$ngaySQL."' AND `NgayUpdate` >= '".$mysqldate."' GROUP BY SoLieuChannel.IdChannel ORDER BY TongDoanhThu DESC LIMIT 10");
$dem = 1;
while($res = mysqli_fetch_array($resultchannel))
{
$dem++;
?>
<?php
$thoiGianGioiHan56 = date('d/m/Y', strtotime('-56 day', strtotime($ngaySQL)));
$date = explode('/', $thoiGianGioiHan56);
$time = mktime(0,0,0,$date[1],$date[0],$date[2]);
$mysqldate = date( 'Y-m-d H:i:s', $time);
$resultChannelGet = Select('SoLieuChannel', false, "`SoLieuChannel`.`IdChannel` = ".$res['IDChannelSQL']." AND `NgayUpdate` <= '".$ngaySQL."' AND `NgayUpdate` > '".$mysqldate."'", "`SoLieuChannel`.`NgayUpdate` DESC");
while($resChannelGet = mysqli_fetch_array($resultChannelGet))
{
$listDuLieuKenh[] = $resChannelGet;
}
$resultDoanhThuChannel = $listDuLieuKenh[0];
$soLuotXem = $resultDoanhThuChannel['SoLuotXem'];
$thoiGianXemTrungBinh = $resultDoanhThuChannel['ThoiGianXemTrungBinh'];
$thoiGianGet = date("d/m/Y", strtotime($resultDoanhThuChannel['NgayUpdate']));
$thoiGian = '<span style="color: green;">'.$thoiGianGet.'</span>';
if($ngayCapNhat > $thoiGianGet)
{
$thoiGian = '<span style="color: red;">'.$thoiGianGet.'</span>';
}
// tính tăng trưởng
// phút xem
$phutXemMoi = strtotime($listDuLieuKenh[0]['ThoiGianXemTrungBinh']);
$phutXemCu = strtotime($listDuLieuKenh[1]['ThoiGianXemTrungBinh']);
$thoiGianXemTrungBinhTangTruong = '<i style="color: #5dec7c;" class="fa fa-caret-up text-primary m-r-5"></i>';
if($phutXemMoi < $phutXemCu)
{
$thoiGianXemTrungBinhTangTruong = '<i class="fa fa-caret-down text-danger m-r-5"></i>';
}
// doanh thu
$doanhThuMoi = $listDuLieuKenh[0]['DoanhThu'];
$doanhThucu = $listDuLieuKenh[1]['DoanhThu'];
$doanhThuTangTruong = '<i style="color: #5dec7c;" class="fa fa-caret-up text-primary m-r-5"></i> <span style="color: #5dec7c;">$ ' . number_format(($doanhThuMoi - $doanhThucu)) . '</span>';
if($doanhThuMoi < $doanhThucu)
{
$doanhThuTangTruong = '<i class="fa fa-caret-down text-danger m-r-5"></i> <span style="color: #f05050;">$ ' . number_format(($doanhThucu - $doanhThuMoi)) . '</span>';
}
else if($doanhThuMoi == $doanhThucu && $doanhThuMoi == 0 && $doanhThu28Moi == 0)
{
$doanhThuTangTruong = "Chưa BKT";
}
// lượt xem
$luotXemMoi = $listDuLieuKenh[0]['SoLuotXem'];
$luotXemCu = $listDuLieuKenh[1]['SoLuotXem'];
$luotXemTangTruong = '<i style="color: #5dec7c;" class="fa fa-caret-up text-primary m-r-5"></i> <span style="color: #5dec7c;">' . number_format(($luotXemMoi - $luotXemCu)) . '</span>';
if($luotXemMoi < $luotXemCu)
{
$luotXemTangTruong = '<i class="fa fa-caret-down text-danger m-r-5"></i> <span style="color: #f05050;">' . number_format(($luotXemCu - $luotXemMoi)) . '</span>';
}
else if($luotXemMoi == $luotXemCu && $luotXemMoi == 0)
{
$luotXemTangTruong = "";
}
// tang truong 28 ngay doanh thu
$doanhThu28Moi = 0;
$luotXem28NgayMoi = 0;
for($ba = 0; $ba < 28; $ba++)
{
if($ba >= count($listDuLieuKenh)) break;
$doanhThu28Moi += $listDuLieuKenh[$ba]['DoanhThu'];
$luotXem28NgayMoi += $listDuLieuKenh[$ba]['SoLuotXem'];
}
$doanhThu28Cu = 0;
$luotXem28NgayCu = 0;
for($ia = 28; $ia < 56; $ia++)
{
if($ia >= count($listDuLieuKenh)) break;
$doanhThu28Cu += $listDuLieuKenh[$ia]['DoanhThu'];
$luotXem28NgayCu += $listDuLieuKenh[$ia]['SoLuotXem'];
}
$doanhThuTangTruong28 = '<i style="color: #5dec7c;" class="fa fa-caret-up text-primary m-r-5"></i> <span style="color: #5dec7c;">$ ' . number_format(($doanhThu28Moi - $doanhThu28Cu)) . '</span>';
if($doanhThu28Moi < $doanhThu28Cu)
{
$doanhThuTangTruong28 = '<i class="fa fa-caret-down text-danger m-r-5"></i> <span style="color: #f05050;">$ ' . number_format(($doanhThu28Cu - $doanhThu28Moi)) . '</span>';
}
else if($doanhThu28Moi == $doanhThu28Cu && $doanhThu28Moi == 0)
{
$doanhThuTangTruong28 = "";
}
$luotXemTangTruong28Ngay = '<i style="color: #5dec7c;" class="fa fa-caret-up text-primary m-r-5"></i> <span style="color: #5dec7c;"> ' . number_format(($luotXem28NgayMoi - $luotXem28NgayCu)) . '</span>';
if($luotXem28NgayMoi < $luotXem28NgayCu)
{
$luotXemTangTruong28Ngay = '<i class="fa fa-caret-down text-danger m-r-5"></i> <span style="color: #f05050;"> ' . number_format(($luotXem28NgayCu - $luotXem28NgayMoi)) . '</span>';
}
else if($luotXem28NgayMoi == $luotXem28NgayCu && $luotXem28NgayMoi == 0)
{
$luotXemTangTruong28Ngay = "";
}
// tính RPM
$rpmMoi = $listDuLieuKenh[0]['DoanhThu']/($listDuLieuKenh[0]['SoLuotXem']/1000);
$rpmCu = $listDuLieuKenh[1]['DoanhThu']/($listDuLieuKenh[1]['SoLuotXem']/1000);
$rpmTangTruong = '<i style="color: #5dec7c;" class="fa fa-caret-up text-primary m-r-5"></i> <span style="color: #5dec7c;">' . number_format(($rpmMoi - $rpmCu), 2) . '</span>';
if($rpmMoi < $rpmCu)
{
$rpmTangTruong = '<i class="fa fa-caret-down text-danger m-r-5"></i> <span style="color: #f05050;">' . number_format(($rpmCu - $rpmMoi), 2) . '</span>';
}
else if($rpmMoi == $rpmCu && $rpmMoi == 0)
{
$rpmTangTruong = "";
}
$listDuLieuKenh = "";
?>
<tr>
<td>
<h5 class="m-0 fw-normal"><a href="https://www.youtube.com/channel/<?php echo $res['IdKenh']; ?>" target="_blank">
<?php
$namesplit = split(' ',$res['NameChannel']);
if(count($namesplit) > 2)
{
echo $namesplit[0] . ' ' . $namesplit[1];
}
else
{
echo $res['NameChannel'];
}
?></a></h5>
</td>
<td>
<?php
$resultQL = mysqli_fetch_assoc(Select('NguoiLam', false, "`id` = ".$res['IdNguoiLam']."" ,''));
if(isset($resultQL['id']))
{
echo split(' ', $resultQL['TenNhanVien'])[count(split(' ', $resultQL['TenNhanVien']))-1];
}
else
{
echo "NONE";
}
?>
</td>
<td>
<div style="float: left;"> <?php echo number_format($res['TongLuotXem']); ?></div>
<div style="margin-top: 6px; margin-left: 5px; float: left;">
<div style="font-size: 9px;">
<?php echo $luotXemTangTruong28Ngay; ?>
</div>
</div>
</td>
<td>
<div style="float: left;"> <?php echo '$ ' . number_format($res['TongDoanhThu']); ?></div>
<div style="margin-top: 6px; margin-left: 5px; float: left;">
<div style="font-size: 9px;">
<?php echo $doanhThuTangTruong28; ?>
</div>
</div>
</td>
<td>
<div style="float: left;"><?php echo '$ ' . number_format($resultDoanhThuChannel['DoanhThu']) . ''; ?></div>
<div style="margin-top: -2px; margin-left: 10px; float: left;">
<div style="font-size: 8px;">
<?php echo $thoiGian; ?>
</div>
<div style="font-size: 9px;">
<?php echo $doanhThuTangTruong; ?>
</div>
</div>
</td>
</tr>
<?php
}
if($dem == 1)
{
?>
<tr><td>Không có kênh có doanh thu</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
}
?>