mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
custom field cancel file
This commit is contained in:
@@ -3238,13 +3238,14 @@ foreach ($rows as $row)
|
||||
} else {
|
||||
print("<br />$tags");
|
||||
}
|
||||
//progress bar
|
||||
if (isset($torrentSeedingLeechingStatus[$row['id']])) {
|
||||
print('<div style="padding: 1px;margin-top: 2px;width: 100%;border: 1px solid #838383" title="' . $torrentSeedingLeechingStatus[$row['id']]['progress'] . '"><div style="width: 50%;background-color: red;height: 2px"></div></div>');
|
||||
echo $torrent->renderProgressBar($torrentSeedingLeechingStatus[$row['id']]['active_status'], $torrentSeedingLeechingStatus[$row['id']]['progress']);
|
||||
}
|
||||
print("</td>");
|
||||
if ($enablePtGen && !empty($row['pt_gen'])) {
|
||||
echo $ptGen->renderTorrentsPageAverageRating(json_decode($row['pt_gen'], true));
|
||||
} elseif ($enableImdb && !empty($row['url'])) {
|
||||
} elseif ($enableImdb) {
|
||||
echo $imdb->renderTorrentsPageAverageRating($row['url']);
|
||||
}
|
||||
$act = "";
|
||||
@@ -4687,222 +4688,6 @@ function displayHotAndClassic()
|
||||
}
|
||||
}
|
||||
|
||||
function saveAttachment($file)
|
||||
{
|
||||
$filesize = $file["size"];
|
||||
$filetype = $file["type"];
|
||||
$origfilename = $file['name'];
|
||||
$ext_l = strrpos($origfilename, ".");
|
||||
$ext = strtolower(substr($origfilename, $ext_l+1, strlen($origfilename)-($ext_l+1)));
|
||||
$banned_ext = array('exe', 'com', 'bat', 'msi');
|
||||
$img_ext = array('jpeg', 'jpg', 'png', 'gif');
|
||||
|
||||
if (!$file || $filesize == 0 || $file["name"] == "") // nothing received
|
||||
{
|
||||
$warning = $lang_attachment['text_nothing_received'];
|
||||
}
|
||||
elseif (!$count_left) //user cannot upload more files
|
||||
{
|
||||
$warning = $lang_attachment['text_file_number_limit_reached'];
|
||||
}
|
||||
elseif ($filesize > $size_limit || $filesize >= 5242880) //do not allow file bigger than 5 MB
|
||||
{
|
||||
$warning = $lang_attachment['text_file_size_too_big'];
|
||||
}
|
||||
elseif (!in_array($ext, $allowed_exts) || in_array($ext, $banned_ext)) //the file extension is banned
|
||||
{
|
||||
$warning = $lang_attachment['text_file_extension_not_allowed'];
|
||||
}
|
||||
else //everythins is okay
|
||||
{
|
||||
if (in_array($ext, $img_ext))
|
||||
$isimage = true;
|
||||
else $isimage = false;
|
||||
if ($savedirectorytype_attachment == 'onedir')
|
||||
$savepath = "";
|
||||
elseif ($savedirectorytype_attachment == 'monthdir')
|
||||
$savepath = date("Ym")."/";
|
||||
elseif ($savedirectorytype_attachment == 'daydir')
|
||||
$savepath = date("Ymd")."/";
|
||||
$filemd5 = md5_file($file['tmp_name']);
|
||||
$filename = date("YmdHis").$filemd5;
|
||||
$file_location = make_folder($savedirectory_attachment."/", $savepath) . $filename;
|
||||
do_log("file_location: $file_location");
|
||||
$db_file_location = $savepath.$filename;
|
||||
$abandonorig = false;
|
||||
$hasthumb = false;
|
||||
$width = 0;
|
||||
if ($isimage) //the uploaded file is a image
|
||||
{
|
||||
$maycreatethumb = false;
|
||||
$stop = false;
|
||||
$imagesize = getimagesize($file['tmp_name']);
|
||||
if ($imagesize){
|
||||
$height = $imagesize[1];
|
||||
$width = $imagesize[0];
|
||||
$it = $imagesize[2];
|
||||
if ($it != 1 || !$Attach->is_gif_ani($file['tmp_name'])){ //if it is an animation GIF, stop creating thumbnail and adding watermark
|
||||
if ($thumbnailtype_attachment != 'no') //create thumbnail for big image
|
||||
{
|
||||
//determine the size of thumbnail
|
||||
if ($altsize == 'yes'){
|
||||
$targetwidth = $altthumbwidth_attachment;
|
||||
$targetheight = $altthumbheight_attachment;
|
||||
}
|
||||
else
|
||||
{
|
||||
$targetwidth = $thumbwidth_attachment;
|
||||
$targetheight = $thumbheight_attachment;
|
||||
}
|
||||
$hscale=$height/$targetheight;
|
||||
$wscale=$width/$targetwidth;
|
||||
$scale=($hscale < 1 && $wscale < 1) ? 1 : (( $hscale > $wscale) ? $hscale : $wscale);
|
||||
$newwidth=floor($width/$scale);
|
||||
$newheight=floor($height/$scale);
|
||||
if ($scale != 1){ //thumbnail is needed
|
||||
if ($it==1)
|
||||
$orig=@imagecreatefromgif($file["tmp_name"]);
|
||||
elseif ($it == 2)
|
||||
$orig=@imagecreatefromjpeg($file["tmp_name"]);
|
||||
else
|
||||
$orig=@imagecreatefrompng($file["tmp_name"]);
|
||||
if ($orig && !$stop)
|
||||
{
|
||||
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
||||
imagecopyresized($thumb, $orig, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
if ($thumbnailtype_attachment == 'createthumb'){
|
||||
$hasthumb = true;
|
||||
imagejpeg($thumb, $file_location.".".$ext.".thumb.jpg", $thumbquality_attachment);
|
||||
}
|
||||
elseif ($thumbnailtype_attachment == 'resizebigimg'){
|
||||
$ext = "jpg";
|
||||
$filetype = "image/jpeg";
|
||||
$it = 2;
|
||||
$height = $newheight;
|
||||
$width = $newwidth;
|
||||
$maycreatethumb = true;
|
||||
$abandonorig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$watermarkpos = $watermarkpos_attachment;
|
||||
if ($watermarkpos != 'no' && !$stop) //add watermark to image
|
||||
{
|
||||
if ($width > $watermarkwidth_attachment && $height > $watermarkheight_attachment)
|
||||
{
|
||||
if ($abandonorig)
|
||||
{
|
||||
$resource = $thumb;
|
||||
}
|
||||
else
|
||||
{
|
||||
$resource=imagecreatetruecolor($width,$height);
|
||||
if ($it==1)
|
||||
$resource_p=@imagecreatefromgif($file["tmp_name"]);
|
||||
elseif ($it==2)
|
||||
$resource_p=@imagecreatefromjpeg($file["tmp_name"]);
|
||||
else
|
||||
$resource_p=@imagecreatefrompng($file["tmp_name"]);
|
||||
imagecopy($resource, $resource_p, 0, 0, 0, 0, $width, $height);
|
||||
}
|
||||
$watermark = imagecreatefrompng('pic/watermark.png');
|
||||
$watermark_width = imagesx($watermark);
|
||||
$watermark_height = imagesy($watermark);
|
||||
//the position of the watermark
|
||||
if ($watermarkpos == 'random')
|
||||
$watermarkpos = mt_rand(1, 9);
|
||||
switch ($watermarkpos)
|
||||
{
|
||||
case 1: {
|
||||
$wmx = 5;
|
||||
$wmy = 5;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
$wmx = ($width-$watermark_width)/2;
|
||||
$wmy = 5;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
$wmx = $width-$watermark_width-5;
|
||||
$wmy = 5;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
$wmx = 5;
|
||||
$wmy = ($height-$watermark_height)/2;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
$wmx = ($width-$watermark_width)/2;
|
||||
$wmy = ($height-$watermark_height)/2;
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
$wmx = $width-$watermark_width-5;
|
||||
$wmy = ($height-$watermark_height)/2;
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
$wmx = 5;
|
||||
$wmy = $height-$watermark_height-5;
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
$wmx = ($width-$watermark_width)/2;
|
||||
$wmy = $height-$watermark_height-5;
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
$wmx = $width-$watermark_width-5;
|
||||
$wmy = $height-$watermark_height-5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
imagecopy($resource, $watermark, $wmx, $wmy, 0, 0, $watermark_width, $watermark_height);
|
||||
if ($it==1)
|
||||
imagegif($resource, $file_location.".".$ext);
|
||||
elseif ($it==2)
|
||||
imagejpeg($resource, $file_location.".".$ext, $watermarkquality_attachment);
|
||||
else
|
||||
imagepng($resource, $file_location.".".$ext);
|
||||
$filesize = filesize($file_location.".".$ext);
|
||||
$maycreatethumb = false;
|
||||
$abandonorig = true;
|
||||
}
|
||||
}
|
||||
if ($maycreatethumb){ // if no watermark is added, create the thumbnail now for the above resized image.
|
||||
imagejpeg($thumb, $file_location.".".$ext, $thumbquality_attachment);
|
||||
$filesize = filesize($file_location.".".$ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
else $warning = $lang_attachment['text_invalid_image_file'];
|
||||
}
|
||||
if (!$abandonorig){
|
||||
if(!move_uploaded_file($file["tmp_name"], $file_location.".".$ext))
|
||||
$warning = $lang_attachment['text_cannot_move_file'];
|
||||
}
|
||||
if (!$warning) //insert into database and add code to editor
|
||||
{
|
||||
$dlkey = md5($db_file_location.".".$ext);
|
||||
sql_query("INSERT INTO attachments (userid, width, added, filename, filetype, filesize, location, dlkey, isimage, thumb) VALUES (".$CURUSER['id'].", ".$width.", ".sqlesc(date("Y-m-d H:i:s")).", ".sqlesc($origfilename).", ".sqlesc($filetype).", ".$filesize.", ".sqlesc($db_file_location.".".$ext).", ".sqlesc($dlkey).", ".($isimage ? 1 : 0).", ".($hasthumb ? 1 : 0).")") or sqlerr(__FILE__, __LINE__);
|
||||
$count_left--;
|
||||
if (!empty($_REQUEST['callback_func'])) {
|
||||
$url = $httpdirectory_attachment."/".$db_file_location . ".$ext";
|
||||
if ($hasthumb) {
|
||||
$url .= ".thumb.jpg";
|
||||
}
|
||||
echo sprintf('<script type="text/javascript">parent.%s("%s", "%s")</script>', $_REQUEST['callback_func'], $dlkey, $url);
|
||||
} else {
|
||||
echo("<script type=\"text/javascript\">parent.tag_extimage('". "[attach]" . $dlkey . "[/attach]" . "');</script>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,7 +12,6 @@ class Field
|
||||
const TYPE_CHECKBOX = 'checkbox';
|
||||
const TYPE_SELECT = 'select';
|
||||
const TYPE_IMAGE = 'image';
|
||||
const TYPE_FILE = 'file';
|
||||
|
||||
public static $types = [
|
||||
self::TYPE_TEXT => [
|
||||
@@ -45,11 +44,6 @@ class Field
|
||||
'has_option' => false,
|
||||
'is_value_multiple' => false,
|
||||
],
|
||||
self::TYPE_FILE => [
|
||||
'text' => 'file',
|
||||
'has_option' => false,
|
||||
'is_value_multiple' => false,
|
||||
],
|
||||
];
|
||||
|
||||
private $preparedTorrentCustomFieldValues = [];
|
||||
@@ -64,7 +58,6 @@ class Field
|
||||
self::TYPE_CHECKBOX => $lang_fields['field_type_checkbox'],
|
||||
self::TYPE_SELECT => $lang_fields['field_type_select'],
|
||||
self::TYPE_IMAGE => $lang_fields['field_type_image'],
|
||||
self::TYPE_FILE => $lang_fields['field_type_file'],
|
||||
];
|
||||
return $map[$type] ?? '';
|
||||
}
|
||||
@@ -367,8 +360,6 @@ HEAD;
|
||||
</script>
|
||||
JS;
|
||||
$html .= tr($row['label'], $y, 1);
|
||||
} elseif ($row['type'] == self::TYPE_FILE) {
|
||||
$html .= tr($row['label'], sprintf('<input type="file" name="%s" />', $name), 1);
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
@@ -451,7 +442,6 @@ JS;
|
||||
switch ($customFieldWithValue['type']) {
|
||||
case self::TYPE_TEXT:
|
||||
case self::TYPE_TEXTAREA:
|
||||
case self::TYPE_FILE:
|
||||
$result .= format_comment($fieldValue);
|
||||
break;
|
||||
case self::TYPE_IMAGE:
|
||||
|
||||
@@ -254,16 +254,18 @@ class Imdb
|
||||
|
||||
}
|
||||
|
||||
public function renderTorrentsPageAverageRating(int $imdbId)
|
||||
public function renderTorrentsPageAverageRating($imdbId)
|
||||
{
|
||||
$imdbId = parse_imdb_id($imdbId);
|
||||
if ($this->getCacheStatus($imdbId) != 1) {
|
||||
return '';
|
||||
if ($imdbId && $this->getCacheStatus($imdbId) == 1) {
|
||||
$movie = $this->getMovie($imdbId);
|
||||
$rating = $movie->rating();
|
||||
} else {
|
||||
$rating = 'N/A';
|
||||
}
|
||||
$movie = $this->getMovie($imdbId);
|
||||
|
||||
$site = 'imdb';
|
||||
$rating = $movie->rating();
|
||||
$result = '<td class="embedded" style="text-align: right; width: 40px;padding-right: 5px"><div style="display: flex;flex-direction: column">';
|
||||
$result = '<td class="embedded" style="text-align: right; width: 40px;padding: 4px"><div style="display: flex;flex-direction: column">';
|
||||
$result .= sprintf(
|
||||
'<div style="display: flex;align-content: center;justify-content: space-between;padding: 2px 0"><img src="%s" alt="%s" title="%s" style="max-width: 16px;max-height: 16px"/><span>%s</span></div>',
|
||||
'pic/imdb2.png', $site, $site, $rating
|
||||
|
||||
@@ -230,7 +230,7 @@ HTML;
|
||||
|
||||
public function renderTorrentsPageAverageRating(array $ptGenData)
|
||||
{
|
||||
$result = '<td class="embedded" style="text-align: right; width: 40px;padding-right: 5px"><div style="display: flex;flex-direction: column">';
|
||||
$result = '<td class="embedded" style="text-align: right; width: 40px;padding: 4px"><div style="display: flex;flex-direction: column">';
|
||||
$count = 1;
|
||||
foreach (self::$validSites as $site => $info) {
|
||||
$rating = $ptGenData[$site]['data']["{$site}_rating_average"] ?? '';
|
||||
|
||||
@@ -7,7 +7,7 @@ use Nexus\Database\DB;
|
||||
class Torrent
|
||||
{
|
||||
/**
|
||||
* get torrent seeching or downloading status, download progress for someone
|
||||
* get torrent seeding or leeching status, download progress of someone
|
||||
*
|
||||
* @param int $uid
|
||||
* @param array $torrentIdArr
|
||||
@@ -23,14 +23,14 @@ class Torrent
|
||||
$peerList = array_column($peerList,'to_go', 'torrent');
|
||||
//download progress, from snatched
|
||||
$sql = sprintf(
|
||||
"select snatched.finished, snatched.to_go, snatched.torrentid, torrents.size from snatched inner join torrents on snatched.torrentid = torrents.id where snatched.userid = %s and snatched.torrentid in (%s)",
|
||||
"select snatched.to_go, snatched.torrentid, torrents.size from snatched inner join torrents on snatched.torrentid = torrents.id where snatched.userid = %s and snatched.torrentid in (%s)",
|
||||
sqlesc($uid), $torrentIdStr
|
||||
);
|
||||
$snatchedList = [];
|
||||
$res = sql_query($sql);
|
||||
while ($row = mysql_fetch_assoc($res)) {
|
||||
$id = $row['torrentid'];
|
||||
$activeStatus = 'none';
|
||||
$activeStatus = 'inactivity';
|
||||
if (isset($peerList[$id])) {
|
||||
if ($peerList[$id]['to_go'] == 0) {
|
||||
$activeStatus = 'seeding';
|
||||
@@ -48,4 +48,21 @@ class Torrent
|
||||
}
|
||||
return $snatchedList;
|
||||
}
|
||||
|
||||
public function renderProgressBar($activeStatus, $progress)
|
||||
{
|
||||
$color = '#aaa';
|
||||
$title = $activeStatus;
|
||||
if ($activeStatus == 'seeding') {
|
||||
$color = 'green';
|
||||
} elseif ($activeStatus == 'leeching') {
|
||||
$color = 'red';
|
||||
}
|
||||
$progress = ($progress * 100) . '%';
|
||||
$result = sprintf(
|
||||
'<div style="padding: 1px;margin-top: 2px;border: 1px solid #838383" title="%s"><div style="width: %s;background-color: %s;height: 2px"></div></div>',
|
||||
$title . " $progress", $progress, $color
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ else {
|
||||
case "1" :
|
||||
{
|
||||
reset_cachetimestamp($row['id']);
|
||||
if (($photo_url = $movie->photo_localurl() ) != FALSE)
|
||||
if (($photo_url = $movie->photo() ) != FALSE)
|
||||
$smallth = "<img src=\"".$photo_url. "\" width=\"105\" onclick=\"Preview(this);\" alt=\"poster\" />";
|
||||
else
|
||||
$smallth = "<img src=\"pic/nophoto.gif\" alt=\"no poster\" />";
|
||||
|
||||
@@ -356,9 +356,8 @@ $id = mysql_insert_id();
|
||||
* add custom fields
|
||||
* @since v1.6
|
||||
*/
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if (!empty($_POST['custom_fields'])) {
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
foreach ($_POST['custom_fields'] as $customField => $customValue) {
|
||||
foreach ((array)$customValue as $value) {
|
||||
$customData = [
|
||||
@@ -372,18 +371,6 @@ if (!empty($_POST['custom_fields'])) {
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (!empty($_FILES['custom_fields'])) {
|
||||
// foreach ($_FILES['custom_fields'] as $customField => $customValue) {
|
||||
// $customData = [
|
||||
// 'torrent_id' => $id,
|
||||
// 'custom_field_id' => $customField,
|
||||
// 'custom_field_value' => $value,
|
||||
// 'created_at' => $now,
|
||||
// 'updated_at' => $now,
|
||||
// ];
|
||||
// \Nexus\Database\DB::insert('torrents_custom_field_values', $customData);
|
||||
// }
|
||||
//}
|
||||
|
||||
@sql_query("DELETE FROM files WHERE torrent = $id");
|
||||
foreach ($filelist as $file) {
|
||||
|
||||
Reference in New Issue
Block a user