|
HTML;
}
if( $_REQUEST['subaction'] == "deluploads" ) {
if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) {die( "Hacking attempt! User not found" );}
$row = $db->super_query( "SELECT images FROM " . PREFIX . "_images where author = '$author' AND news_id = '$news_id'" );
$listimages = explode( "|||", $row['images'] );
if( isset( $_POST['images'] ) ) foreach ( $_POST['images'] as $image ) {
$i = 0;
sort( $listimages );
reset( $listimages );
foreach ( $listimages as $dataimages ) {
if( $dataimages == $image ) {
$url_image = explode( "/", $image );
if( count( $url_image ) == 2 ) {
$folder_prefix = $url_image[0] . "/";
$image = $url_image[1];
} else {
$folder_prefix = "";
$image = $url_image[0];
}
unset( $listimages[$i] );
@unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . $image );
@unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . "thumbs/" . $image );
}
$i ++;
}
}
if( count( $listimages ) ) $row['images'] = implode( "|||", $listimages );
else $row['images'] = "";
$db->query( "UPDATE " . PREFIX . "_images set images='$row[images]' where author = '$author' AND news_id = '$news_id'" );
if( count( $_POST['static_files'] ) ) {
foreach ( $_POST['static_files'] as $file ) {
$file = intval( $file );
$row = $db->super_query( "SELECT id, name, onserver FROM " . PREFIX . "_static_files WHERE author = '$author' AND static_id = '$news_id' AND id='$file'" );
if( $row['id'] and $row['onserver'] ) {
@unlink( ROOT_DIR . "/uploads/files/" . $row['onserver'] );
$db->query( "DELETE FROM " . PREFIX . "_static_files WHERE id='{$row['id']}'" );
} else {
if( $row['id'] ) {
$url_image = explode( "/", $row['name'] );
if( count( $url_image ) == 2 ) {
$folder_prefix = $url_image[0] . "/";
$image = $url_image[1];
} else {
$folder_prefix = "";
$image = $url_image[0];
}
@unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . $image );
@unlink( ROOT_DIR . "/uploads/posts/" . $folder_prefix . "thumbs/" . $image );
$db->query( "DELETE FROM " . PREFIX . "_static_files WHERE id='{$row['id']}'" );
}
}
}
}
if( count( $_POST['files'] ) ) {
foreach ( $_POST['files'] as $file ) {
$file = intval( $file );
$row = $db->super_query( "SELECT id, onserver FROM " . PREFIX . "_files where author = '$author' AND news_id = '$news_id' AND id='$file'" );
@unlink( ROOT_DIR . "/uploads/files/" . $row['onserver'] );
$db->query( "DELETE FROM " . PREFIX . "_files WHERE id='{$row['id']}'" );
}
}
if( count( $_POST['torrents'] ) ) {
foreach ( $_POST['torrents'] as $file ) {
$file = intval( $file );
$row = $db->super_query( "SELECT id, onserver FROM " . PREFIX . "_torrents where author = '$author' AND news_id = '$news_id' AND id='$file' AND flags='0'" );
@unlink( ROOT_DIR . "/uploads/torrents/" . $row['onserver'] );
$db->query( "UPDATE " . PREFIX . "_torrents SET flags='1' where id='{$row['id']}'" );
}
}
}
if( $_REQUEST['subaction'] == "upload" ) {
$images_number = intval($_POST['images_number']);
if( $action == "quick" ) {
$userdir = "posts/";
if( ! is_dir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX ) ) {
@mkdir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777 );
@chmod( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX, 0777 );
@mkdir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs", 0777 );
@chmod( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs", 0777 );
}
if( ! is_dir( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX ) ) {msg( "error", $lang['opt_error'], $lang['upload_error_0']." /uploads/posts/" . FOLDER_PREFIX . "/" );}
if( ! is_writable( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX ) ) {msg( "error", $lang['opt_error'], $lang['upload_error_1']." /uploads/posts/" . FOLDER_PREFIX . "/ ".$lang['upload_error_2'] );}
if( ! is_writable( ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/thumbs" ) ) {msg( "error", $lang['opt_error'], $lang['upload_error_1']." /uploads/posts/" . FOLDER_PREFIX . "/thumbs/ ".$lang['upload_error_2'] );}
$config_path_image_upload = ROOT_DIR . "/uploads/posts/" . FOLDER_PREFIX . "/";
}
for($image_i = 1; $image_i < ($images_number + 1); $image_i ++) {
$file_prefix = time() + rand( 1, 100 );
$file_prefix .= "_";
$current_image = 'file_' . $image_i;
$image = $_FILES[$current_image]['tmp_name'];
$image_name = $_FILES[$current_image]['name'];
$image_size = $_FILES[$current_image]['size'];
$error_code = $_FILES[$current_image]['error'];
if ($error_code !== UPLOAD_ERR_OK) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
$error_code = 'PHP Error: The uploaded file exceeds the upload_max_filesize directive in php.ini'; break;
case UPLOAD_ERR_FORM_SIZE:
$error_code = 'PHP Error: The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; break;
case UPLOAD_ERR_PARTIAL:
$error_code = 'PHP Error: The uploaded file was only partially uploaded'; break;
case UPLOAD_ERR_NO_FILE:
$error_code = 'PHP Error: No file was uploaded'; break;
case UPLOAD_ERR_NO_TMP_DIR:
$error_code = 'PHP Error: Missing a PHP temporary folder'; break;
case UPLOAD_ERR_CANT_WRITE:
$error_code = 'PHP Error: Failed to write file to disk'; break;
case UPLOAD_ERR_EXTENSION:
$error_code = 'PHP Error: File upload stopped by extension'; break;
default:
$error_code = 'Unknown upload error'; break;
}}
$img_name_arr = explode( ".", $image_name );
$type = totranslit( end( $img_name_arr ) );
if( $image_name != "" ) {
$curr_key = key( $img_name_arr );
unset( $img_name_arr[$curr_key] );
$image_name = totranslit( implode( ".", $img_name_arr ) ) . "." . $type;
}
if( $config['files_allow'] == "yes" and $user_group[$member_id['user_group']]['allow_file_upload'] and $_REQUEST['action'] == "quick" and (in_array( strtolower( $type ), $allowed_files )) ) {
/*
=====================================================
Загрузка файлов, но не картинок
=====================================================
*/
if( ! is_dir( ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX ) ){
mkdir( ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX, 0777 );
chmod( ROOT_DIR . "/uploads/files/" . FOLDER_PREFIX, 0777 );
}
$file_prefix = FOLDER_PREFIX.'/'.$file_prefix;
@move_uploaded_file( $image, ROOT_DIR . "/uploads/files/" . $file_prefix . $image_name ) or $img_result = " {$lang['images_uperr_3']}
{$error_code} ";
if( @file_exists( ROOT_DIR . "/uploads/files/" . $file_prefix . $image_name ) ) {
if( intval( $config['max_file_size'] ) and @filesize( ROOT_DIR . "/uploads/files/" . $file_prefix . $image_name ) > ($config['max_file_size'] * 1024) ) {
@unlink( ROOT_DIR . "/uploads/files/" . $file_prefix . $image_name );
$img_result .= "$image_name -> $lang[files_too_big] ";
} else {
@chmod( ROOT_DIR . "/uploads/files/" . $file_prefix . $image_name, 0666 );
$img_result .= "$image_name -> $lang[files_upok] ";
$added_time = time() + ($config['date_adjust'] * 60);
if( $area == "template" ) {
$db->query( "INSERT INTO " . PREFIX . "_static_files (static_id, author, date, name, onserver) values ('$news_id', '$author', '$added_time', '$image_name', '{$file_prefix}{$image_name}')" );
} else {
$db->query( "INSERT INTO " . PREFIX . "_files (news_id, name, onserver, author, date) values ('$news_id', '$image_name', '{$file_prefix}{$image_name}', '$author', '$added_time')" );
}
}
}
} elseif( $image_name == "" ) {
$img_result .= "$current_image -> $lang[images_uperr] ";
} elseif( ! isset( $overwrite ) and file_exists( $config_path_image_upload . $image_name ) ) {
$img_result .= "$current_image -> $lang[images_uperr_1] ";
} elseif( ! (in_array( $type, $allowed_extensions ) or in_array( strtolower( $type ), $allowed_extensions )) ) {
$img_result .= "$current_image -> $lang[images_uperr_2] ";
} elseif( $image_size > ($config['max_up_size'] * 1024) and ! $config['max_up_side'] ) {
$img_result .= "$current_image -> $lang[images_big] ";
} else {
/*
=====================================================
Загрузка картинок, но не файлов
=====================================================
*/
@move_uploaded_file( $image, $config_path_image_upload . $file_prefix . $image_name ) or $img_result = "{$lang['images_uperr_3']}
{$error_code} ";
if( @file_exists( $config_path_image_upload . $file_prefix . $image_name ) ) {
@chmod( $config_path_image_upload . $file_prefix . $image_name, 0666 );
$img_result .= "$image_name -> $lang[images_upok] ";
if( $action == "quick" and $area != "template" ) {
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_images where author = '$author' AND news_id = '$news_id'" );
if( ! $row['count'] ) {
$added_time = time() + ($config['date_adjust'] * 60);
$inserts = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$db->query( "INSERT INTO " . PREFIX . "_images (images, author, news_id, date) values ('$inserts', '$author', '$news_id', '$added_time')" );
} else {
$row = $db->super_query( "SELECT images FROM " . PREFIX . "_images where author = '$author' AND news_id = '$news_id'" );
if( $row['images'] == "" ) $listimages = array ();
else $listimages = explode( "|||", $row['images'] );
foreach ( $listimages as $dataimages ) {
if( $dataimages == FOLDER_PREFIX . "/" . $file_prefix . $image_name ) $error_image = "stop";
}
if( $error_image != "stop" ) {
$listimages[] = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$row['images'] = implode( "|||", $listimages );
$db->query( "UPDATE " . PREFIX . "_images set images='{$row['images']}' where author = '$author' AND news_id = '$news_id'" );
}
}
}
if( $area == "template" and $action == "quick" ) {
$added_time = time() + ($config['date_adjust'] * 60);
$inserts = FOLDER_PREFIX . "/" . $file_prefix . $image_name;
$db->query( "INSERT INTO " . PREFIX . "_static_files (static_id, author, date, name) values ('$news_id', '$author', '$added_time', '$inserts')" );
}
include_once SYSTEM_DIR . '/classes/thumb.class.php';
if( $member_id['user_group'] > 3 ) {
$_POST['make_thumb'] = true;
$_POST['make_watermark'] = $config['allow_watermark'];
}
if( isset( $_POST['make_thumb'] ) ) {
$thumb = new thumbnail( $config_path_image_upload . $file_prefix . $image_name );
if( $thumb->size_auto( $config['max_image'], $_POST['t_seite'] ) ) {
$thumb->jpeg_quality( $config['jpeg_quality'] );
if( $config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
$thumb->save( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name );
}
if( @file_exists( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name ) ) $img_result_th .= "$image_name -> $lang[images_thok] ";
@chmod( $config_path_image_upload . "thumbs/" . $file_prefix . $image_name, 0666 );
}
if( ($config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes") or $config['max_up_side'] ) {
$thumb = new thumbnail( $config_path_image_upload . $file_prefix . $image_name );
$thumb->jpeg_quality( $config['jpeg_quality'] );
if( $config['max_up_side'] ) $thumb->size_auto( $config['max_up_side'] );
if( $config['allow_watermark'] == "yes" and $_POST['make_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
$thumb->save( $config_path_image_upload . $file_prefix . $image_name );
}
} //if file is uploaded succesfully
}
}
/*
=====================================================
Загрузка Торрентов, но не файлов
=====================================================
*/
$image = $_FILES["torfile"]['tmp_name'];
$image_name = $_FILES["torfile"]['name'];
$image_size = $_FILES["torfile"]['size'];
$error_code = $_FILES["torfile"]['error'];
if (!empty ($image))
{
$img_name_arr = explode( ".", $image_name );
$type = totranslit( end( $img_name_arr ) );
if( $image_name != "" ) {
$curr_key = key( $img_name_arr );
unset( $img_name_arr[$curr_key] );
$image_name = totranslit( implode( ".", $img_name_arr ) ) . "." . $type;
}
$tfile_prefix = FOLDER_PREFIX.'/'.$file_prefix;
if(substr($image_name, -8) == ".torrent") {
if( ! is_dir( ROOT_DIR . "/uploads/torrents/" . FOLDER_PREFIX ) ){
mkdir( ROOT_DIR . "/uploads/torrents/" . FOLDER_PREFIX, 0777 );
chmod( ROOT_DIR . "/uploads/torrents/" . FOLDER_PREFIX, 0777 );
}
@move_uploaded_file( $image, ROOT_DIR . "/uploads/torrents/" . $tfile_prefix . $image_name );
if( @file_exists( ROOT_DIR . "/uploads/torrents/" . $tfile_prefix . $image_name ) )
{
@chmod( ROOT_DIR . "/uploads/torrents/" . $tfile_prefix . $image_name, 0666 );
$img_result .= "$image_name -> $lang[files_upok] ";
//********* Tracker by MSW *** start *********//
require_once( ROOT_DIR."/system/classes/torrent.class.php" );
$tr_file = ROOT_DIR."/uploads/torrents/".$tfile_prefix.$image_name;
$torrent = new Torrent($tr_file);
if($error = $torrent->errors()){
}else{
$files_size = $torrent->size();
$hash = $torrent->hash_info();
$e_hash = addslashes(pack("H*", $hash));
$tr_fild = ", info_hash, size, ctime";
$tr_info = ", '{$e_hash}', '{$files_size}', '".time()."'";
//********* Tracker by MSW *** stop *********//
$db->query( "INSERT INTO " . PREFIX . "_torrents (news_id, name, onserver, author {$tr_fild}) values ('$news_id', '$image_name', '{$tfile_prefix}{$image_name}', '$author' {$tr_info})" );
}
}
}
}
}
echo "";
echo <<
{$lang['images_uptitle']} |
HTML;
if( $action == "quick" ) {
echo <<
HTML;
}
echo ' ';
if ($user_group[$member_id['user_group']]['allow_tor_upload'])
{
echo <<
Загрузить торрент
|
HTML;
}
if ($user_group[$member_id['user_group']]['allow_file_upload'])
{
echo <<
{$lang['images_uphard']}
|
HTML;
}
echo <<
HTML;
if( $action == "quick" ) {
if( $user_group[$member_id['user_group']]['allow_file_upload'] ) {
if( $config['max_file_size'] ) {
$lang['files_max_info'] = $lang['files_max_info'] . " " . mksize( $config['max_file_size'] * 1024 );
} else {
$lang['files_max_info'] = $lang['files_max_info_2'];
}
$lang['files_max_info_1'] = $lang['files_max_info'] . " " . $lang['files_max_info_1'] . " " . mksize( $config['max_up_size'] * 1024 );
} else {
$lang['files_max_info_1'] = $lang['files_max_info_1'] . " " . mksize( $config['max_up_size'] * 1024 );
}
echo <<
{$lang['upload_mass_info']}
{$lang['files_max_info_1']}
HTML;
}
//if( $member_id['user_group'] < 4 ) {
$_POST['t_seite'] = intval( $_POST['t_seite'] );
$t_seite_selected[$_POST['t_seite']] = "selected";
echo <<
{$lang['upload_t_size']} px
HTML;
//}
if( $action != "quick" ) echo " ";
if( $member_id['user_group'] < 4 ) {
if( ! extension_loaded( "gd" ) ) echo "$lang[images_nogd]";
else echo " ";
if( $config['allow_watermark'] == "yes" ) echo " ";
}
echo <<{$img_result}{$img_result_th}
HTML;
if( $action == "quick" ) {
$image_align = array ();
$image_align[$config['image_align']] = "selected";
echo <<
{$lang['images_align']}
HTML;
}
if( $action == "quick" ) {
echo <<
HTML;
$config_path_image_upload = ROOT_DIR . "/uploads/";
if( $area != "template" ) {
$row = $db->super_query( "SELECT images FROM " . PREFIX . "_images where author = '$author' AND news_id = '$news_id'" );
$listimages = explode( "|||", $row['images'] );
$i = 0;
$this_size_2 = 0;
$total_size = 0;
if( $row['images'] != "" ) foreach ( $listimages as $dataimages ) {
$i ++;
$url_image = explode( "/", $dataimages );
if( count( $url_image ) == 2 ) {
$folder_prefix = $url_image[0] . "/";
$dataimages = $url_image[1];
} else {
$folder_prefix = "";
$dataimages = $url_image[0];
}
if( file_exists( $config_path_image_upload . "posts/" . $folder_prefix . $dataimages ) ) {
$this_size = @filesize( $config_path_image_upload . "posts/" . $folder_prefix . $dataimages );
$img_info = @getimagesize( $config_path_image_upload . "posts/" . $folder_prefix . $dataimages );
$total_size += $this_size + $this_size_2;
if( file_exists( $config_path_image_upload . "posts/" . $folder_prefix . "thumbs/" . $dataimages ) ) {
$this_size_2 = @filesize( $config_path_image_upload . "posts/" . $folder_prefix . "thumbs/" . $dataimages );
$img_info_th = @getimagesize( $config_path_image_upload . "posts/" . $folder_prefix . "thumbs/" . $dataimages );
$thumb_link="";
$original_link = "[ {$lang['img_orig_ins']} ] ";
$link_id = "thumbimage";
} else {
$thumb_link = "";
$original_link = "";
$link_id = "fullimage";
}
echo "
$thumb_link |
{$original_link}[ " . $lang['images_view'] . " ] |
$img_info[0]x$img_info[1] |
|
| ";
}
}
$db->query( "SELECT id, name, onserver FROM " . PREFIX . "_files where author = '$author' AND news_id = '$news_id'" );
while ( $row = $db->get_row() ) {
$this_size = mksize( @filesize( ROOT_DIR . "/uploads/files/" . $row['onserver'] ) );
$file_link = "{$row['name']}";
$file_type = explode( ".", $row['name'] );
$file_type = totranslit( end( $file_type ) );
if( in_array( $file_type, $allowed_video ) ) {
if( $file_type == "mp3" ) {
$video_link = "{$lang['inset_audio_link']}";
} elseif ($file_type == "swf") {
$url = $config['http_home_url'].'uploads/files/'.$row['onserver'];
list($width, $height)=getimagesize($url);
$width = intval($width);
$height = intval($height);
$video_link = "{$lang['inset_flash_link']}";
} else {
$video_link = "{$lang['inset_video_link']}";
}
} else {
$video_link = "";
}
echo "
$file_link |
$video_link |
{$this_size} |
|
| ";
}
$db->free();
$db->query ("SELECT id, name, onserver FROM " . PREFIX . "_torrents where author = '$author' AND news_id = '$news_id' and flags='0'");
while ($row = $db->get_row ())
{
$this_size = mksize (@filesize (ROOT_DIR . "/uploads/torrents/" . $row['onserver']));
$file_link = "{$row['name']}";
$file_type = explode (".", $row['name']);
$file_type = totranslit (end ($file_type));
echo "
$file_link |
{$this_size} |
|
| ";
}
$db->free();
}
if( $area == "template" ) {
$db->query( "SELECT id, name FROM " . PREFIX . "_static_files WHERE static_id = '$news_id' AND onserver = ''" );
while ( $row = $db->get_row() ) {
$url_image = explode( "/", $row['name'] );
if( count( $url_image ) == 2 ) {
$folder_prefix = $url_image[0] . "/";
$dataimages = $url_image[1];
} else {
$folder_prefix = "";
$dataimages = $url_image[0];
}
if( file_exists( $config_path_image_upload . "posts/" . $folder_prefix . $dataimages ) ) {
$this_size = @filesize( $config_path_image_upload . "posts/" . $folder_prefix . $dataimages );
$img_info = @getimagesize( $config_path_image_upload . "posts/" . $folder_prefix . $dataimages );
$total_size += $this_size + $this_size_2;
if( file_exists( $config_path_image_upload . "posts/" . $folder_prefix . "thumbs/" . $dataimages ) ) {
$this_size_2 = @filesize( $config_path_image_upload . "posts/" . $folder_prefix . "thumbs/" . $dataimages );
$img_info_th = @getimagesize( $config_path_image_upload . "posts/" . $folder_prefix . "thumbs/" . $dataimages );
$thumb_link = "$dataimages";
$original_link = "[ {$lang['img_orig_ins']} ] ";
$link_id = "thumbstatic";
} else {
$thumb_link = "$dataimages";
$link_id = "fullstatic";
$original_link = "";
}
echo "
$thumb_link |
{$original_link}[ " . $lang['images_view'] . " ] |
$img_info[0]x$img_info[1] |
|
| ";
}
}
$db->query( "SELECT id, name, onserver FROM " . PREFIX . "_static_files where author = '$author' AND static_id = '$news_id' AND onserver != ''" );
while ( $row = $db->get_row() ) {
$this_size = mksize( @filesize( ROOT_DIR . "/uploads/files/" . $row['onserver'] ) );
$file_link = "{$row['name']}";
$file_type = explode( ".", $row['name'] );
$file_type = totranslit( end( $file_type ) );
if( in_array( $file_type, $allowed_video ) ) {
if( $file_type == "mp3" ) {
$video_link = "{$lang['inset_audio_link']}";
} else {
$video_link = "{$lang['inset_video_link']}";
}
} else {
$video_link = "";
}
echo "
$file_link |
$video_link |
{$this_size} |
|
| ";
}
$db->free();
}
echo "
|
| ";
}
echo "
';
if( $action != "quick" ) {
echo <<
|
|
|
|
HTML;
echofooter();
} else {
echo <<
| |