################################################################
## Hack Title: Music Song Image Edit on Music Song Image Hack
## (Music Center Mod)
##
## Hack Version: 2.0.6 (for MOM 2.0.6)
## Hack Author: OryNider < orynider@rdslink.ro > (Florin Ciprian Bodin)
## Support: http://mx-system.com/ @ mx_music release thread
##
## Description: Add the Song Image to the section of each song.
## (Maybe CD Cover, Artist Photo or any image you want ;)
##
##
## Compatibility: 2.0.21 --> 2.0.22
##
## Installation Level: Advanced
## Installation time: 5 - 10 min
## Files to edit: 2
## music_edit.php
## templates/xxx/music_edit_body.tpl
##
## Included Files: 0
##
################################################################
## Installation/Author Notes:
##
## This MOD is based on mxBB mx_music module by OryNider
## and mxBB Development Team
## and require Music Song Image Hack
################################################################
## Hack History:
## 19/04/2007 v2.0.6: First Release :)
################################################################
## This HACK is released under the GPL License.
################################################################
## Before Adding This HACK To Your Forum, You Should Back Up All Files Related To This HACK
################################################################
################################################################
#
#-----[ OPEN ]--------------------------------------------------
#
music_edit.php
#
#-----[ FIND ]--------------------------------------------------
#
$music_root_path = $phpbb_root_path . 'music_box/';
#
#-----[ AFTER ADD ]---------------------------------------------
# The directory of song images
$song_image_path = $phpbb_root_path . 'music_box/upload/song_image/';
#
#-----[ FIND ]--------------------------------------------------
#
if( empty($thissong) )
{
message_die(GENERAL_ERROR, $lang['Song_not_exist']);
}
#
#-----[ AFTER ADD ]---------------------------------------------
#
if( !empty($thissong['song_imagename']) )
{
$old_pic_filename = $thissong['song_imagename'];
$no_image = ( !empty($lang['No_change']) ? $lang['No_change'] : 'No Change' );
}
else
{
$old_pic_filename = '';
$no_image = $lang['No_image'];
}
#
#-----[ FIND ]--------------------------------------------------
#
'L_SUBMIT' => $lang['Submit'],
#
#-----[ AFTER ADD ]---------------------------------------------
#
'L_SONG_IMAGE' => $lang['Song_image'],
'L_SONG_IMAGE_DESC' => $lang['Song_image_desc'],
'L_NO_IMAGE' => $no_image,
'L_UPLOAD_IMAGE' => $lang['Upload_image'],
#
#-----[ FIND ]--------------------------------------------------
#
$song_url = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['song_url'])));
#
#-----[ AFTER ADD ]---------------------------------------------
#
$image_system = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['image_system'])));
#
#-----[ FIND ]--------------------------------------------------
#
else
{
if( $song_url != '' )
{
message_die(GENERAL_ERROR, 'Bad edit');
}
}
#
#-----[ AFTER ADD ]---------------------------------------------
#
// --------------------------------
// Get Song Image Upload Info
// --------------------------------
$imagetype = ( !empty($HTTP_POST_FILES['song_image']['type']) ) ? $HTTP_POST_FILES['song_image']['type'] : '';
$imagesize = ( !empty($HTTP_POST_FILES['song_image']['size']) ) ? $HTTP_POST_FILES['song_image']['size'] : 0;
$imagetmp = ( !empty($HTTP_POST_FILES['song_image']['tmp_name']) ) ? $HTTP_POST_FILES['song_image']['tmp_name'] : '';
// --------------------------------
// Check image size
// --------------------------------
if( $image_system == '1' )
{
// --------------------------------
// Check image type
// --------------------------------
switch ($imagetype)
{
case 'image/jpeg':
case 'image/jpg':
case 'image/pjpeg':
$song_imagetype = '.jpg';
break;
case 'image/gif':
$song_imagetype = '.gif';
break;
case 'image/png':
case 'image/x-png':
$song_imagetype = '.png';
break;
default:
message_die(GENERAL_ERROR, $lang['Not_allowed_image_type'] . ': ' . $imagetype);
}
if( $imagesize > $music_config['max_image_size'] )
{
message_die(GENERAL_MESSAGE, $lang['Bad_upload_image_size']);
}
// --------------------------------
// If exits old image deleate it
// --------------------------------
if( !empty($old_pic_filename) && file_exists($song_image_path . $old_pic_filename) )
{
@unlink($song_image_path . $old_pic_filename);
}
// --------------------------------
// Generate imagename
// --------------------------------
do
{
$song_imagename = md5(uniqid(rand())) . $song_imagetype;
}
while( file_exists($song_image_path . $song_imagename) );
// --------------------------------
// Move song image to directory
// --------------------------------
if( !empty($HTTP_POST_FILES['song_image']['tmp_name']) )
{
$ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
if ( @$ini_val('open_basedir') != '' )
{
if ( @phpversion() < '4.0.3' )
{
message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file
Please contact your server admin', '', __LINE__, __FILE__);
}
$move_file = 'move_uploaded_file';
}
else
{
$move_file = 'copy';
}
$move_file($imagetmp, $song_image_path . $song_imagename);
@chmod($song_image_path . $song_imagename, 0777);
}
// --------------------------------
// Check its image size
// --------------------------------
if( !empty($HTTP_POST_FILES['song_image']['size']) )
{
$image_size = getimagesize($song_image_path . $song_imagename);
$image_width = $image_size[0];
$image_height = $image_size[1];
if ( ($image_width > $music_config['max_image_width']) or ($image_height > $music_config['max_image_height']) )
{
@unlink($song_image_path . $song_imagename);
message_die(GENERAL_ERROR, 'Your uploaded image size is too big');
}
}
}
else if( !empty($old_pic_filename) )
{
$song_imagename = $old_pic_filename;
}
else
{
$song_imagename = '';
}
#
#-----[ FIND ]--------------------------------------------------
#
$sql = "UPDATE ". MUSIC_TABLE ."
SET song_title = '$song_title', song_url = '$song_url', song_singer = '$song_singer', song_desc = '$song_desc'
#
#-----[ REPLACE WITH ]---------------------------------------------
#
$sql = "UPDATE ". MUSIC_TABLE ."
SET song_imagename = '$song_imagename', song_title = '$song_title', song_url = '$song_url', song_singer = '$song_singer', song_desc = '$song_desc'
#
#-----[ OPEN ]--------------------------------------------------
#
templates/subSilver/music_edit_body.tpl
#
#-----[ FIND ]--------------------------------------------------
#