Witam. Przerobiłem sobie wtyczkę Master Download Panel z PFv6 na PHP-Fusion v7. Infusions udało mi się przerobić ale mam trudności z przerobieniem pliku download.php oto on:
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."master_download.php";
// ----------------------------------------
// Funkcje
// ----------------------------------------
// Formatowanie rozmiaru pliku
function format_filesize($size) {
if ($size >= 1024*1024)
$result = sprintf("%2.2f", $size/(1024*1024)).' GB';
else if ($size >= 1024)
$result = sprintf("%2.2f", $size/1024).' MB';
else
$result = $size.' KB';
return($result);
}
// Czas w sekundach
function get_sectime() {
list($ms, $sec) = explode(" ", microtime());
return($sec);
}
// ----------------------------------------
// Pobieranie
// ----------------------------------------
if (($action == 'get') and ((isset($id)) or (isset($shortcut)))) {
// Plik
if (isset($id))
$files_list = dbquery("SELECT * FROM ".$db_prefix."master_download_files WHERE file_id='".$id."' LIMIT 1");
elseif (isset($shortcut))
$files_list = dbquery("SELECT * FROM ".$db_prefix."master_download_files WHERE file_shortcut='".$shortcut."' LIMIT 1");
else {
redirect(FUSION_SELF);
exit;
}
$files_count = mysql_num_rows($files_list);
// Brak pliku
if ($files_count == 0) {
redirect(FUSION_SELF);
exit;
}
$file_details = mysql_fetch_array($files_list);
// Dostepne mirrory
$av_mirrors_list = dbquery("SELECT rel_id FROM ".$db_prefix."master_download_rels WHERE rel_fileid='".$file_details['file_id']."'");
$av_mirrors_count = mysql_num_rows($av_mirrors_list);
if ($av_mirrors_count == 0) {
// URL downloadu
$file_url = $file_details['file_url'];
}
else {
// Reset wykozystania transferu mirror'ow
$ac_date = showdate("%Y.%m", get_sectime());
$tmp_mirrors_list = dbquery("SELECT mirror_id, mirror_lastdown FROM ".$db_prefix."master_download_mirrors");
while ($tmp_mirror_details = mysql_fetch_array($tmp_mirrors_list))
if (($tmp_mirror_details['mirror_lastdown']) and (showdate("%Y.%m", $tmp_mirror_details['mirror_lastdown']) != $ac_date))
dbquery("UPDATE ".$db_prefix."master_download_mirrors SET mirror_used='0', mirror_lastdown='0' WHERE mirror_id='".$tmp_mirror_details['mirror_id']."'");
// Lista mirrorow
$mirrors_list = dbquery("
SELECT *,
(mirror_used*100)/mirror_limit AS mirror_load
FROM ".$db_prefix."master_download_mirrors
LEFT JOIN ".$db_prefix."master_download_rels ON ".$db_prefix."master_download_rels.rel_mirrorid = ".$db_prefix."master_download_mirrors.mirror_id
WHERE rel_fileid='".$file_details['file_id']."' AND mirror_used+".$file_details['file_size']." <= mirror_limit
ORDER BY mirror_load
LIMIT 1
");
$mirrors_count = mysql_num_rows($mirrors_list);
if ($mirrors_count == 0) {
// Brak dostepnego mirror'a
opentable($locale['400']);
print("<center><br>".$locale['432']."</center>");
closetable();
}
else {
$mirror_details = mysql_fetch_array($mirrors_list);
// Zaleznosc
$rels_list = dbquery("
SELECT * FROM ".$db_prefix."master_download_rels
WHERE rel_fileid='".$file_details['file_id']."' AND rel_mirrorid='".$mirror_details['mirror_id']."'
LIMIT 1
");
$rels_count = mysql_num_rows($rels_list);
if ($rels_count == 0) {
redirect(FUSION_SELF);
exit;
}
else
$rel_details = mysql_fetch_array($rels_list);
// Brak jakiejkolwiek nazwy pliku
if (!(($rel_details['rel_url']) or ($file_details['file_url']))) {
redirect(FUSION_SELF);
exit;
}
// URL downloadu
if (!$rel_details['rel_url']) $rel_details['rel_url'] = $file_details['file_url'];
$file_url = $mirror_details['mirror_url'].$rel_details['rel_url'];
// Aktualizacja danych
dbquery("UPDATE ".$db_prefix."master_download_mirrors SET mirror_used=mirror_used+".$file_details['file_size'].", mirror_lastdown='".get_sectime()."' WHERE mirror_id='".$mirror_details['mirror_id']."'");
}
}
if ($file_url) {
// Aktualizacja danych
dbquery("UPDATE ".$db_prefix."master_download_files SET file_count=file_count+1 WHERE file_id='".$file_details['file_id']."'");
// Pobranie pliku
redirect($file_url);
}
else
redirect(FUSION_SELF);
}
// ----------------------------------------
// Pliki
// ----------------------------------------
elseif (($action == 'cat') and (isset($id)) and ($id >= 1)) {
// Nazwa kategorii
$cats_list = dbquery("SELECT cat_name FROM ".$db_prefix."master_download_cats WHERE cat_id='".$id."' LIMIT 1");
if (mysql_num_rows($cats_list) == 0) {
redirect(FUSION_SELF);
exit;
}
else
$cat_details = mysql_fetch_array($cats_list);
// Lista plikow
$files_list = dbquery("SELECT * FROM ".$db_prefix."master_download_files WHERE file_cat='".$id."' ORDER BY file_order");
$files_count = mysql_num_rows($files_list);
if ($files_count == 0) {
// Brak plikow
opentable($locale['400'].': '.$cat_details['cat_name']);
print("<center><br>".$locale['431']."</center>");
closetable();
}
else {
// Strona
opentable($locale['400'].': '.$cat_details['cat_name']);
while ($file_details = mysql_fetch_array($files_list)) {
// Sposob pobrania pliku
if ($file_details['file_shortcut'])
$getmethod = 'shortcut='.$file_details['file_shortcut'];
else
$getmethod = 'id='.$file_details['file_id'];
print("
<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td colspan='4' class='forum-caption'><b>".$file_details['file_name']."</b></td>
</tr>
<tr>
<td colspan='4' class='tbl1'>
");
// Obraz pliku
if ($file_details['file_img'])
print("<img src='".$file_details['file_img']."' alt='".$file_details['file_name']."' border='0' align='left' style='margin: 5px;'>");
print("
".$file_details['file_desc']."</td>
</tr>
<tr>
<td width='25%' class='tbl2'>".$locale['411']." ".showdate("%d.%m.%y", $file_details['file_date'])."</td>
<td width='25%' class='tbl1'>".$locale['412']." ".$file_details['file_count']."</td>
<td width='25%' class='tbl2'>".$locale['413']." ".format_filesize($file_details['file_size'])."</td>
<td width='25%' class='tbl1'><center><a href='".FUSION_SELF."?action=get&".$getmethod."'>".$locale['414']."</a></center></td>
</tr>
</table>
<div align='center'><img src='".THEME."images/blank.gif' alt='' height='15' width='1'></div>
");
}
closetable();
}
}
// ----------------------------------------
// Kategorie
// ----------------------------------------
else {
// Lista kategorii
$cats_list = dbquery("SELECT * FROM ".$db_prefix."master_download_cats ORDER BY cat_order");
$cats_count = mysql_num_rows($cats_list);
if ($cats_count == 0) {
// Brak kategorii
opentable($locale['400'].': '.$cat_details['cat_name']);
print("<center><br>".$locale['430']."</center>");
closetable();
}
else {
// Strona
opentable($locale['400']);
while ($cat_details = mysql_fetch_array($cats_list)) {
print("
<a href='".FUSION_SELF."?action=cat&id=".$cat_details['cat_id']."'>".$cat_details['cat_name']."</a> <span class='small'>(".$cat_details['cat_count'].")</span><br>
<span class='small'>".$cat_details['cat_desc']."</span><br><br>
");
}
closetable();
}
}
require_once "side_right.php";
require_once "footer.php";
?>
Co jest w nim nie tak bo nie mogę dojść. Proszę o pomoc w przekodowaniu.
PW od moderatora:
- Zmiana nazwy tematu - Pieka 16.06 - 20:00
Edytowane przez Pieka dnia 25.08.2009 19:13:39
|