C:\xampp\htdocs\kptv\admin\modules\top20plus\act_top20plusDetailsFrm.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
        
    
require_once($BASEPATH."common/database.php");
    require_once(
$BASEPATH."common/SimpleImage.php");
    
    function 
saveImage($mImage$oldFile$target) {
        
        
unlink($target.$oldFile);
    
        
$image = new SimpleImage();
        
        
$name rand(0,10000).date('Ymd',time())."-".str_replace(array("\"","'""-"), "_",$mImage['name']);
                        
        if(
getimagesize($mImage['tmp_name'])){
            
$image->load($mImage['tmp_name']);                                    
            
$image->resizeToHeight($height 150);                    
            
$image->save($target.$name);
            
            return 
$name;
        }
        
        return 
"";
    }
    
    function 
uploadMusic($music$oldFile,  $target){
        
        
unlink($target.$oldFile);
    
        
$name rand(0,10000).date('Ymd',time())."-".str_replace(array("\"","'""-"), "_",$music['name']);
        
        
$tmp_name $music['tmp_name'];
        if(
move_uploaded_file($tmp_name,$target.$name)) {
            return 
$name;
        }
        return 
"";
    }
    
    
$db = new Database($db_host$db_name$db_usrName$db_password);
    
$oldData $db->selectById("top20plus"$_POST['ID']);
    
    
    if(isset(
$_FILES['coverimg']) && $_FILES['coverimg']['name'] != "") {
        
$fileName             saveImage($_FILES['coverimg'],$oldData['coverimg'], '../ro/images/top20/');
        
$_POST['coverimg']  = $fileName;
    } else {
        unset(
$_POST['coverimg']);
        
$fileName null;
    }
    
    if(isset(
$_FILES['mp3']) && $_FILES['mp3']['name'] != "") {
        
$mp3FileName  uploadMusic($_FILES['mp3'],$oldData['mp3'], '../ro/music/');
        
$_POST['mp3'] = $mp3FileName;    
    } else {
        unset(
$_POST['mp3']);
        
$mp3FileName null;
    }

    if(!isset(
$_POST['active'])) {
        
$_POST['active'] = 0;
    }
    
    
$db->update($table "top20plus"$data $_POST$_POST['ID'], $ignore = array('hdadded_date''ID' 'hdmp3''hdcoverimg''Submit'));
    
    
//redirect to the expected page
    
header('Location:index.php?cnt_=top20plus&type_of_list='.$_POST['type_of_list']); ///top20plusDetails&ID='.$_POST['ID']
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586