message
This commit is contained in:
79
system/inc/newsimg/addimg.php
Normal file
79
system/inc/newsimg/addimg.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'DATALIFEENGINE' ) ) {
|
||||
die( "Hacking attempt!" );
|
||||
}
|
||||
require_once ROOT_DIR.'/language/'.$config['langs'].'/img.lng';
|
||||
|
||||
#### IMG
|
||||
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">
|
||||
function ShowOrHideEx(id, show) {
|
||||
var item = null;
|
||||
if (document.getElementById) {
|
||||
item = document.getElementById(id);
|
||||
} else if (document.all) {
|
||||
item = document.all[id];
|
||||
} else if (document.layers){
|
||||
item = document.layers[id];
|
||||
}
|
||||
if (item && item.style) {
|
||||
item.style.display = show ? \"\" : \"none\";
|
||||
}
|
||||
}
|
||||
|
||||
var total_allow_rows = {$config['max_file_count']};
|
||||
|
||||
function AddImages() {
|
||||
var tbl = document.getElementById('tblSample');
|
||||
var lastRow = tbl.rows.length;
|
||||
|
||||
if (total_allow_rows && lastRow == total_allow_rows ) return;
|
||||
|
||||
// if there's no header row in the table, then iteration = lastRow + 1
|
||||
var iteration = lastRow+1;
|
||||
var row = tbl.insertRow(lastRow);
|
||||
|
||||
var cellRight = row.insertCell(0);
|
||||
var el = document.createElement('input');
|
||||
el.setAttribute('type', 'file');
|
||||
el.setAttribute('name', 'addimg_' + iteration);
|
||||
el.setAttribute('size', '41');
|
||||
el.setAttribute('value', iteration);
|
||||
cellRight.appendChild(el);
|
||||
|
||||
document.getElementById('images_number').value = iteration;
|
||||
}
|
||||
|
||||
function RemoveImages() {
|
||||
var tbl = document.getElementById('tblSample');
|
||||
var lastRow = tbl.rows.length;
|
||||
if (lastRow > 1){
|
||||
tbl.deleteRow(lastRow - 1);
|
||||
document.getElementById('images_number').value = document.getElementById('images_number').value - 1;
|
||||
}
|
||||
}
|
||||
</script>";
|
||||
echo <<<HTML
|
||||
<tr><td height="29" style="padding-left:5px;" colspan="2"><div class="hr_line"></div></td></tr>
|
||||
<tr><td height="29" style="padding-left:5px;">{$lang['images_uphard']}</td>
|
||||
<td>
|
||||
<input type="hidden" name="images_number" id="images_number" value="1">
|
||||
<div id="dle_tabView1">
|
||||
<table id="tblSample" class="upload">
|
||||
<tr id="row">
|
||||
<td><input type="file" size="41" name="addimg_1"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<input type=button class=buttons value=' - ' style="width:30px;" title='{$lang['images_rem_tl']}' onClick="RemoveImages();return false;">
|
||||
<input type=button class=buttons value=' + ' style="width:30px;" title='{$lang['images_add_tl']}' onClick="AddImages();return false;">
|
||||
</div>
|
||||
|
||||
</td></tr>
|
||||
HTML;
|
||||
|
||||
#### IMG
|
||||
|
||||
?>
|
||||
72
system/inc/newsimg/doaddimg.php
Normal file
72
system/inc/newsimg/doaddimg.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
if( ! defined( 'DATALIFEENGINE' ) ) {
|
||||
die( "Hacking attempt!" );
|
||||
}
|
||||
$thumb_size = $config['poster_width'];
|
||||
$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['poster_width'] = $thumb_size;
|
||||
$images_number = intval($_POST['images_number']);
|
||||
for($image_i = 1; $image_i < ($images_number + 1); $image_i ++) {
|
||||
$file_prefix = time() + rand( 1, 100 );
|
||||
$file_prefix .= "_";
|
||||
$image_name = "";
|
||||
$type = "";
|
||||
$current_image = 'addimg_' . $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( strpos ( $type, "php" ) !== false ) die("Hacking attempt!");
|
||||
if( $image_name != "" ) {
|
||||
$curr_key = key( $img_name_arr );
|
||||
unset( $img_name_arr[$curr_key] );
|
||||
$image_name = totranslit( implode( ".", $img_name_arr ) ) . "." . $type;
|
||||
}
|
||||
@move_uploaded_file( $image, ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name );
|
||||
if( @file_exists( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name ) ) {
|
||||
@chmod( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name, 0666 );
|
||||
$url = '/covers/' . $file_prefix . $image_name;
|
||||
include_once SYSTEM_DIR . '/classes/thumb.class.php';
|
||||
$thumb = new thumbnail( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name );
|
||||
if( $thumb->size_auto( $config['poster_width'], 0 ) ) {
|
||||
$thumb->jpeg_quality( $config['jpeg_quality'] );
|
||||
if( $config['allow_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
|
||||
$thumb->save( ROOT_DIR . "/uploads/covers/thumbs/" . $file_prefix . $image_name );
|
||||
}
|
||||
@chmod( ROOT_DIR . "/uploads/covers/thumbs/" . $file_prefix . $image_name, 0666 );
|
||||
if( @file_exists( ROOT_DIR . "/uploads/covers/thumbs/" . $file_prefix . $image_name ) ) {
|
||||
$th = '/covers/thumbs/' . $file_prefix . $image_name;
|
||||
}
|
||||
if( ($config['allow_watermark'] == "yes" ) or $config['max_up_side'] ) {
|
||||
$thumb = new thumbnail( ROOT_DIR . "/uploads/covers/" . $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" ) $thumb->insert_watermark( $config['max_watermark'] );
|
||||
$thumb->save( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name );
|
||||
}}
|
||||
if ($url != '') {$db->query("INSERT INTO ".PREFIX."_covers VALUES ('0', '$row', '$url', '$th')");}
|
||||
}
|
||||
?>
|
||||
73
system/inc/newsimg/doeditimg.php
Normal file
73
system/inc/newsimg/doeditimg.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'DATALIFEENGINE' ) ) {
|
||||
die( "Hacking attempt!" );
|
||||
}
|
||||
$thumb_size = $config['poster_width'];
|
||||
$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['poster_width'] = $thumb_size;
|
||||
$images_number = intval($_POST['images_number']);
|
||||
for($image_i = 1; $image_i < ($images_number + 1); $image_i ++) {
|
||||
$file_prefix = time() + rand( 1, 100 );
|
||||
$file_prefix .= "_";
|
||||
$image_name = "";
|
||||
$type = "";
|
||||
$current_image = 'addimg_' . $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( strpos ( $type, "php" ) !== false ) die("Hacking attempt!");
|
||||
if( $image_name != "" ) {
|
||||
$curr_key = key( $img_name_arr );
|
||||
unset( $img_name_arr[$curr_key] );
|
||||
$image_name = totranslit( implode( ".", $img_name_arr ) ) . "." . $type;
|
||||
}
|
||||
@move_uploaded_file( $image, ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name );
|
||||
if( @file_exists( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name ) ) {
|
||||
@chmod( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name, 0666 );
|
||||
$url = '/covers/' . $file_prefix . $image_name;
|
||||
include_once SYSTEM_DIR . '/classes/thumb.class.php';
|
||||
$thumb = new thumbnail( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name );
|
||||
if( $thumb->size_auto( $config['poster_width'], 0 ) ) {
|
||||
$thumb->jpeg_quality( $config['jpeg_quality'] );
|
||||
if( $config['allow_watermark'] == "yes" ) $thumb->insert_watermark( $config['max_watermark'] );
|
||||
$thumb->save( ROOT_DIR . "/uploads/covers/thumbs/" . $file_prefix . $image_name );
|
||||
}
|
||||
@chmod( ROOT_DIR . "/uploads/covers/thumbs/" . $file_prefix . $image_name, 0666 );
|
||||
if( @file_exists( ROOT_DIR . "/uploads/covers/thumbs/" . $file_prefix . $image_name ) ) {$th = '/covers/thumbs/' . $file_prefix . $image_name;}
|
||||
if( ($config['allow_watermark'] == "yes" ) or $config['max_up_side'] ) {
|
||||
$thumb = new thumbnail( ROOT_DIR . "/uploads/covers/" . $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" ) $thumb->insert_watermark( $config['max_watermark'] );
|
||||
$thumb->save( ROOT_DIR . "/uploads/covers/" . $file_prefix . $image_name );
|
||||
}}
|
||||
if ($url != '') {
|
||||
$newsid = $_GET['id'];
|
||||
$db->query("INSERT INTO ".PREFIX."_covers VALUES ('0', '$newsid', '$url', '$th')");
|
||||
}
|
||||
}
|
||||
?>
|
||||
116
system/inc/newsimg/editimg.php
Normal file
116
system/inc/newsimg/editimg.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'DATALIFEENGINE' ) ) {
|
||||
die( "Hacking attempt!" );
|
||||
}
|
||||
|
||||
require_once ROOT_DIR.'/language/'.$config['langs'].'/img.lng';
|
||||
|
||||
#### IMG
|
||||
|
||||
$ms = '';
|
||||
|
||||
echo <<<HTML
|
||||
<tr>
|
||||
<tr><td height="29" style="padding-left:5px;">Çàãðóæåííûå êàðòèíêè</td>
|
||||
<td><table width="100%"><tr><td>
|
||||
HTML;
|
||||
|
||||
$newsimg_query = $db->query("SELECT * FROM ".PREFIX."_covers WHERE newsid='".$_GET['id']."' ORDER BY id DESC");
|
||||
while ($newsimg = $db->get_row($newsimg_query)) {
|
||||
echo <<<HTML
|
||||
<tr>
|
||||
<td height="29" style="width:150px;padding:5px;text-align:left;"><img src="/uploads{$newsimg['thumb']}" width="100px" /></td>
|
||||
<td><a href="/control.php?mod=editnews&action=editnews&id={$_GET['id']}&img={$newsimg['id']}">Óäàëèòü êàðòèíêó</a></td>
|
||||
</tr>
|
||||
HTML;
|
||||
}
|
||||
|
||||
echo '</td></tr></table></td></tr>';
|
||||
|
||||
if ($_GET['img']){
|
||||
$db->query("SELECT link, thumb FROM " . PREFIX . "_covers WHERE id = '".$_GET['img']."'");
|
||||
|
||||
while($row_covers = $db->get_row()){
|
||||
|
||||
@unlink(ROOT_DIR."/uploads".$row_covers['link']);
|
||||
@unlink(ROOT_DIR."/uploads".$row_covers['thumb']);
|
||||
|
||||
}
|
||||
$db->query("DELETE FROM ".PREFIX."_covers WHERE id='".$_GET['img']."'");
|
||||
$ms = "Óäàëåíî";
|
||||
header("Location: /control.php?mod=editnews&action=editnews&id={$_GET['id']}");
|
||||
}
|
||||
|
||||
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">
|
||||
function ShowOrHideEx(id, show) {
|
||||
var item = null;
|
||||
if (document.getElementById) {
|
||||
item = document.getElementById(id);
|
||||
} else if (document.all) {
|
||||
item = document.all[id];
|
||||
} else if (document.layers){
|
||||
item = document.layers[id];
|
||||
}
|
||||
if (item && item.style) {
|
||||
item.style.display = show ? \"\" : \"none\";
|
||||
}
|
||||
}
|
||||
|
||||
var total_allow_rows = {$config['max_file_count']};
|
||||
|
||||
function AddImages() {
|
||||
var tbl = document.getElementById('tblSample');
|
||||
var lastRow = tbl.rows.length;
|
||||
|
||||
if (total_allow_rows && lastRow == total_allow_rows ) return;
|
||||
|
||||
// if there's no header row in the table, then iteration = lastRow + 1
|
||||
var iteration = lastRow+1;
|
||||
var row = tbl.insertRow(lastRow);
|
||||
|
||||
var cellRight = row.insertCell(0);
|
||||
var el = document.createElement('input');
|
||||
el.setAttribute('type', 'file');
|
||||
el.setAttribute('name', 'addimg_' + iteration);
|
||||
el.setAttribute('size', '41');
|
||||
el.setAttribute('value', iteration);
|
||||
cellRight.appendChild(el);
|
||||
|
||||
document.getElementById('images_number').value = iteration;
|
||||
}
|
||||
|
||||
function RemoveImages() {
|
||||
var tbl = document.getElementById('tblSample');
|
||||
var lastRow = tbl.rows.length;
|
||||
if (lastRow > 1){
|
||||
tbl.deleteRow(lastRow - 1);
|
||||
document.getElementById('images_number').value = document.getElementById('images_number').value - 1;
|
||||
}
|
||||
}
|
||||
</script>";
|
||||
echo <<<HTML
|
||||
<tr><td height="29" style="padding-left:5px;" colspan="2"><div class="hr_line"></div></td></tr>
|
||||
<tr><td height="29" style="padding-left:5px;">{$lang['images_uphard']}</td>
|
||||
<td>
|
||||
<input type="hidden" name="images_number" id="images_number" value="1">
|
||||
<div id="dle_tabView1">
|
||||
<table id="tblSample" class="upload">
|
||||
<tr id="row">
|
||||
<td><input type="file" size="41" name="addimg_1"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<input type=button class=buttons value=' - ' style="width:30px;" title='{$lang['images_rem_tl']}' onClick="RemoveImages();return false;">
|
||||
<input type=button class=buttons value=' + ' style="width:30px;" title='{$lang['images_add_tl']}' onClick="AddImages();return false;">
|
||||
</div>
|
||||
|
||||
</td></tr>
|
||||
HTML;
|
||||
|
||||
#### IMG
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user