function newgenresave()
{
    global $xoopsDB, $groups, $xoopsModule, $newid;
    $groups = isset($_POST['groups']) ? $_POST['groups'] : array();
    $xoopsDB->query("\r\n\tINSERT INTO " . $xoopsDB->prefix('debaser_genre') . " (genretitle, imgurl, catweight) \r\n\tVALUES (" . $xoopsDB->quoteString($_POST['genrenew']) . ", " . $xoopsDB->quoteString($_POST['imgurl']) . ", " . intval($_POST['catweight']) . ") ");
    $newid = $xoopsDB->getInsertId();
    debaser_save_Perm($groups, $newid, 'DebaserCatPerm');
    $notification_handler =& xoops_gethandler('notification');
    $tags = array();
    $tags['GENRE_NAME'] = $_POST['genrenew'];
    $notification_handler->triggerEvent('global', 0, 'new_genre', $tags);
    redirect_header('index.php', 1, _AM_DEBASER_DBUPDATE);
}
    if ($_POST['bitrate'] != '') {
        $bitrate = $_POST['bitrate'];
    }
    if ($_POST['frequence'] != '') {
        $frequence = $_POST['frequence'];
    }
    if ($_POST['length'] != '') {
        $length = $_POST['length'];
    }
    /* -- */
    /* insert file into database and show sucess or not */
    $sql = "\r\n\t\t\tINSERT INTO " . $xoopsDB->prefix('debaser_files') . " (filename, added, title, artist, album, year, addinfo, track, genre, length, bitrate, link, frequence, approved, fileext, weight) \r\n\t\t\tVALUES ('" . $filename . "', " . intval($added) . ", " . $xoopsDB->quoteString($title) . ", " . $xoopsDB->quoteString($artist) . ", " . $xoopsDB->quoteString($album) . ", " . intval($year) . ", " . $xoopsDB->quoteString($addinfo) . ", " . intval($track) . ", " . $xoopsDB->quoteString($genre) . ", " . $xoopsDB->quoteString($length) . ", " . intval($bitrate) . ", '" . $link . "', " . intval($frequence) . ", " . intval($approved) . ", " . $xoopsDB->quoteString($mimetyp) . ", " . intval($_POST['weight']) . ")";
    $result = $xoopsDB->query($sql);
    $xfid = $xoopsDB->getInsertId();
    $groups = isset($_POST['groups']) ? $_POST['groups'] : array();
    debaser_save_Perm($groups, $xfid, 'DebaserFilePerm');
    // Notification
    $notification_handler =& xoops_gethandler('notification');
    $tags = array();
    $tags['SONG_NAME'] = $artist . " - " . $title;
    $tags['SONG_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlefile.php?id=' . $xfid;
    if ($xoopsModuleConfig['autofileapprove'] == 1) {
        $notification_handler->triggerEvent('global', 0, 'new_song', $tags);
    } else {
        $tags['WAITINGSONG_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=approve';
        $notification_handler->triggerEvent('global', 0, 'song_submit', $tags);
    }
    if ($result) {
        redirect_header('upload.php', 1, _AM_DEBASER_SINGLEUPSUCC);
    }
}
function saveapprove()
{
    global $xoopsDB, $xoopsModuleConfig;
    $groups = isset($_POST['groups']) ? $_POST['groups'] : array();
    if (isset($_POST['approved']) && $_POST['approved'] == 1) {
        $approved = 1;
        // Notification
        global $xoopsModule;
        $notification_handler =& xoops_gethandler('notification');
        $tags = array();
        $tags['SONG_NAME'] = $_POST['artist'] . " - " . $_POST['title'];
        $tags['SONG_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlefile.php?id=' . $_POST['mpegid'];
        $notification_handler->triggerEvent('global', 0, 'new_song', $tags);
    } else {
        $approved = 0;
    }
    $sqlb = "SELECT genretitle FROM " . $xoopsDB->prefix('debaser_genre') . " WHERE genreid = " . intval($_POST['genrefrom']) . "";
    $resultb = $xoopsDB->query($sqlb);
    list($fromgenre) = $xoopsDB->fetchRow($resultb);
    $sql = "\r\n\tUPDATE " . $xoopsDB->prefix('debaser_files') . "\r\n\tSET\r\n\t\ttitle=" . $xoopsDB->quoteString($_POST['title']) . ",\r\n\t\tartist=" . $xoopsDB->quoteString($_POST['artist']) . ",\r\n\t\talbum=" . $xoopsDB->quoteString($_POST['album']) . ",\r\n\t\tyear=" . intval($_POST['year']) . ",\r\n\t\taddinfo=" . $xoopsDB->quoteString($_POST['addinfo' . $_POST['i']]) . ",\r\n\t\ttrack=" . intval($_POST['track']) . ",\r\n\t\tgenre=" . $xoopsDB->quoteString($fromgenre) . ",\r\n\t\tlength=" . $xoopsDB->quoteString($_POST['length']) . ",\r\n\t\tbitrate=" . intval($_POST['bitrate']) . ",\r\n\t\tfrequence=" . intval($_POST['frequence']) . ",\r\n\t\tlink=" . $xoopsDB->quoteString($_POST['link']) . ",\r\n\t\tapproved=" . intval($approved) . ",\r\n\t\tfileext=" . $xoopsDB->quoteString($_POST['fileext']) . ",\r\n\t\tweight = " . intval($_POST['weight']) . "\r\n\tWHERE xfid=" . intval($_POST['mpegid']) . " ";
    $result = $xoopsDB->query($sql);
    if ($xoopsModuleConfig['usefileperm'] == 1) {
        debaser_save_Perm($groups, $_POST['mpegid'], 'DebaserFilePerm');
    }
    redirect_header('index.php?op=approve', 1, _AM_DEBASER_DBUPDATE);
}