Ссылка скачать после видеоплеера

artrozik
На сайте с 19.02.2008
Offline
180
395

Помогите пожалуйста решить вопрос. Есть страница где выводится видеоплеер, нужно чтобы после видео выводилась ссылка на скачивания этого файла из папки download в корне.

<?php


/**
* Template user class - render photo gallery.
*
* @package Templates
* @copyright 2006 FPIC
*/

class VideoGalleryUser extends TemplateUser
{
var $tableName = "ds_video";

var $block_table =
'<table>
{table_content}
</table>';

var $block_tpl =
'<tr class="news-one-block">
<td class="image">
{img}
</td>
<td>
<span><b>
{date}
</b></span>
<div class="activity_title">
<h2>{title}</h2>
</div>
<div class="text">
<p>{content}</p>
</div>
</td>
</tr>';

function render()
{
// Render video list
$index = 0;
$storage = $this->framework->_uplDir."pages/";
// echo $storage.'<hr/>';
// echo $this->tableName.'<hr/>';
// echo $this->sql.'<hr/>';
// exit;

$videoResult = $this->db->query("select * from `$this->tableName` where {$this->sql} order by `index` asc");

$records = array();

while ($videoRow = $this->db->fa($videoResult))
if (@is_file($storage.$videoRow['page_id']."/".$videoRow['file']))
{
$text = stripSlashes($videoRow['text']);
$url = '/player?file='.urlencode("/upload/pages/".$videoRow['page_id']."/".$videoRow['file']);

// $file_size = fileSize($storage.$videoRow['page_id']."/".$videoRow['file']);

// if ($file_size < 1024) { $size = $file_size.' байт';}
// elseif ($file_size < 1024*1024) { $size = number_format($file_size/1024, 2).' кб'; }
// elseif ($file_size < 1024*1024*1024) { $size = number_format($file_size/(1024*1024), 2).' мб'; }

$title = stripSlashes($videoRow['title']);

// echo "<div class=\"news1".(!$index ? " " : "")."\">";
// if (@is_file($storage.$videoRow['page_id']."/".$videoRow['image_small']))
// {
// list($width, $height) = @getImageSize($storage.$videoRow['page_id']."/".$videoRow['image_small']);
// echo "<span class=\"related-images\"><a href=\"$url\" title=\"$title\"><img src=\"/upload/pages/{$videoRow['page_id']}/{$videoRow['image_small']}\" alt=\"\" /></a></span><h2><span>".convertDate($videoRow['date'])."</span><a href=\"$url\">$title</a></h2>";
// }
// else
//echo "<h3><a href=\"$url\" title=\"$title\">$title</a></h3>";
// echo "<h3><a href=\"$url\" title=\"$title\">$title</a></h3>";
// echo $text ? "<p>$text</p>" : "";
// echo "</div>";

$records[] = strtr($this->block_tpl, array(
'{img}' => is_file($storage.$videoRow['page_id']."/".$videoRow['image_small'])
? "<a href=\"$url\" title=\"$title\"><img src=\"/upload/pages/{$videoRow['page_id']}/{$videoRow['image_small']}\" alt=\"\" /></a>"
: '',
'{date}' => convertDate($videoRow['date']),
'{title}' => "<a href=\"$url\" title=\"$title\">$title</a>",
'{content}' => ($text != '') ? $text : ""
));

$index++;
}

if ($index == 0) {echo "<p>Записи отсутствуют</p>";}
else
{
echo strtr($this->block_table, array('{table_content}' => implode('', $records)));
}

}//end function
}

?>
melkozaur
На сайте с 06.04.2010
Offline
536
#1

artrozik,

А в чем проблема? Просто ставите ссылку на файл.

artrozik
На сайте с 19.02.2008
Offline
180
#2

melkozaur, файлов много, надо чтобы автоматом проставлялась ссылка на тот файл, который проигрывается. Да и в php не очень силен.

дани мапов
На сайте с 06.09.2012
Offline
204
#3

Так попробуйте


<?php
class VideoGalleryUser extends TemplateUser
{
var $tableName = "ds_video";

var $block_table =
'<table>
{table_content}
</table>';

var $block_tpl =
'<tr class="news-one-block">
<td class="image">
{img}
</td>
<td>
<span><b>
{date}
</b></span>
<div class="activity_title">
<h2>{title}</h2>
</div>
<div class="text">
<p>{content}</p>
<br />
<p>{download_link}</p>
</div>
</td>
</tr>';

function render()
{
// Render video list
$index = 0;
$storage = $this->framework->_uplDir."pages/";
// echo $storage.'<hr/>';
// echo $this->tableName.'<hr/>';
// echo $this->sql.'<hr/>';
// exit;

$videoResult = $this->db->query("select * from `$this->tableName` where {$this->sql} order by `index` asc");

$records = array();

while ($videoRow = $this->db->fa($videoResult))
if (@is_file($storage.$videoRow['page_id']."/".$videoRow['file']))
{
$text = stripSlashes($videoRow['text']);
$url = '/player?file='.urlencode("/upload/pages/".$videoRow['page_id']."/".$videoRow['file']);

// $file_size = fileSize($storage.$videoRow['page_id']."/".$videoRow['file']);

// if ($file_size < 1024) { $size = $file_size.' байт';}
// elseif ($file_size < 1024*1024) { $size = number_format($file_size/1024, 2).' кб'; }
// elseif ($file_size < 1024*1024*1024) { $size = number_format($file_size/(1024*1024), 2).' мб'; }

$title = stripSlashes($videoRow['title']);

// echo "<div class=\"news1".(!$index ? " " : "")."\">";
// if (@is_file($storage.$videoRow['page_id']."/".$videoRow['image_small']))
// {
// list($width, $height) = @getImageSize($storage.$videoRow['page_id']."/".$videoRow['image_small']);
// echo "<span class=\"related-images\"><a href=\"$url\" title=\"$title\"><img src=\"/upload/pages/{$videoRow['page_id']}/{$videoRow['image_small']}\" alt=\"\" /></a></span><h2><span>".convertDate($videoRow['date'])."</span><a href=\"$url\">$title</a></h2>";
// }
// else
//echo "<h3><a href=\"$url\" title=\"$title\">$title</a></h3>";
// echo "<h3><a href=\"$url\" title=\"$title\">$title</a></h3>";
// echo $text ? "<p>$text</p>" : "";
// echo "</div>";

$records[] = strtr($this->block_tpl, array(
'{img}' => is_file($storage.$videoRow['page_id']."/".$videoRow['image_small'])
? "<a href=\"$url\" title=\"$title\"><img src=\"/upload/pages/{$videoRow['page_id']}/{$videoRow['image_small']}\" alt=\"\" /></a>"
: '',
'{date}' => convertDate($videoRow['date']),
'{title}' => "<a href=\"$url\" title=\"$title\">$title</a>",
'{content}' => ($text != '') ? $text : "",
'{download_link}' => '<a href="/downloads/'.$videoRow['file'].'" title="Download file">Download file</a>'
));

$index++;
}

if ($index == 0) {echo "<p>Записи отсутствуют</p>";}
else
{
echo strtr($this->block_table, array('{table_content}' => implode('', $records)));
}

}//end function
}
?>
Написание и доработка скриптов (PHP, MySQL, JavaScript, jQuery) (/ru/forum/811046)

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий