safesql( strip_tags( urldecode( $_REQUEST['author'] ) ) ); else $author = ""; if( intval( $_REQUEST['news_id'] ) ) $news_id = intval( $_REQUEST['news_id'] ); else $news_id = 0; $config_path_image_upload = ROOT_DIR . "/uploads/" . $userdir . $sub_dir; $config['max_image'] = $_POST['t_size'] ? $_POST['t_size'] : $config['max_image']; $thumb_size = $config['max_image']; $thumb_size = explode ("x", $thumb_size); if ( count($thumb_size) == 2) {$thumb_size = intval($thumb_size[0]) . "x" . intval($thumb_size[1]); } else {$thumb_size = intval( $thumb_size[0] );} $config['max_image'] = $thumb_size; if( ! @is_dir( $config_path_image_upload ) ) msg( "error", $lang['addnews_denied'], "Directory {$userdir} not found" ); if( $action == "doimagedelete" ) { if( $_REQUEST['user_hash'] == "" or $_REQUEST['user_hash'] != $dle_login_hash ) {die( "Hacking attempt! User not found" );} if( ! isset( $_POST['images'] ) ) {msg( "info", $lang['images_delerr'], $lang['images_delerr_1'], "$PHP_SELF?mod=files" );} foreach ( $_POST['images'] as $image ) { @unlink( $config_path_image_upload . $image ); @unlink( $config_path_image_upload . "thumbs/" . $image ); } $action = ""; } if( $action == "quick" ) { header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); $sess_id = session_id(); if( $user_group[$member_id['user_group']]['allow_file_upload'] or $user_group[$member_id['user_group']]['allow_tor_upload'] ) { if( ! $config['max_file_size'] ) $max_file_size = 0; elseif( $config['max_file_size'] > $config['max_up_size'] ) $max_file_size = ( int ) $config['max_file_size']; else $max_file_size = ( int ) $config['max_up_size']; if( $max_file_size ) $max_file_size = $max_file_size . " KB"; } else { $max_file_size = $config['max_up_size'] . " KB"; } $config['max_file_count'] = intval( $config['max_file_count'] ); echo << Upload
HTML; echo << JSCRIPT; echo ""; } else { echoheader( "files", $lang['images_head'] ); echo <<
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 <<
HTML; if( $action == "quick" ) { echo <<
HTML; echofooter(); } else { echo <<
HTML; } ?>