function dok_update_album() { global $VARS; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_update_album', 'e'); return false; } if (!isset($VARS['name']) || !strlen(trim($VARS['name']))) { return 'view_album'; } $name = substr(trim($VARS['name']), 0, 255); $res = mysql_query('select * from ' . dok_tn('album') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_update_album', 'e'); return false; } $artist = mysql_fetch_array($res); if (strtolower($artist['name']) == strtolower($name)) { return 'view_album'; } $res = dok_uquery('update ' . dok_tn('album') . ' set name = \'' . addslashes(ucwords($name)) . '\' where id = ' . $VARS['id']); if ($res) { return 'view_album'; } else { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_album', 'e'); return false; } }
function dok_create_album() { global $VARS, $USER; if (!isset($VARS['name'])) { dok_msg(MSG_ERR_NO_ALBUM_NAME, 'dok_create_album', 'e'); return false; } if (!strlen(trim($VARS['name']))) { dok_msg(MSG_ERR_NO_ALBUM_NAME, 'dok_create_album', 'e'); return false; } $album_name = ucwords(substr($VARS['name'], 0, 255)); $res = mysql_query('select id from ' . dok_tn('album') . ' where name = \'' . addslashes($album_name) . '\''); if (mysql_numrows($res)) { dok_msg(sprintf(MSG_ERR_DUP_ALBUM_NAME, $album_name), 'dok_create_album', 'e'); return false; } if (DOK_ENABLE_USER) { $creation_uid = $USER->id; } else { $creation_uid = 0; } //add artist $res = dok_uquery('insert into ' . dok_tn('album') . ' (name,creation,creation_uid) values (\'' . addslashes($album_name) . '\',' . time() . ',' . $creation_uid . ')'); if (!$res) { dok_msg(mysql_error(), 'dok_create_album', 'e'); return false; } $VARS['id'] = mysql_insert_id(); $_SESSION['song_select_album'] = $VARS['id']; return 'view_album'; }
function dok_update_user() { global $VARS, $USER; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { dok_msg(MSG_ERR_USER_NOT_FOUND, 'dok_update_user', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_USER_NOT_FOUND, 'dok_update_user', 'e'); return false; } $user = mysql_fetch_array($res); if (DOK_ENABLE_USER && !$USER->admin && $USER->id != $user['id']) { dok_msg(MSG_ERR_USER_UPDATE_NOT_ALLOWED, 'dok_update_user', 'e'); return false; } $set = array(); if (isset($VARS['password']) && strlen(trim($VARS['password'])) > 0) { $VARS['password'] = substr($VARS['password'], 0, 255); $set[] = 'password = \'' . md5($VARS['password']) . '\''; } if (!DOK_ENABLE_USER || $USER->admin) { if ($VARS['editor'] != '1') { $VARS['editor'] = 0; } if ($VARS['admin'] != '1') { $VARS['admin'] = 0; } if ($VARS['disabled'] != '1') { $VARS['disabled'] = 0; } if (isset($VARS['name']) && trim($VARS['name']) != $user['name']) { $VARS['name'] = substr($VARS['name'], 0, 255); $res = mysql_query('select id from ' . dok_tn('user') . ' where name = \'' . addslashes($VARS['name']) . '\''); if (!mysql_numrows($res)) { $set[] = 'name = \'' . addslashes($VARS['name']) . '\''; } } if ($VARS['editor'] xor $user['editor']) { $set[] = 'editor = \'' . $VARS['editor'] . '\''; } if ($VARS['admin'] xor $user['admin']) { $set[] = 'admin = \'' . $VARS['admin'] . '\''; } if ($VARS['disabled'] xor $user['disabled']) { $set[] = 'disabled = \'' . $VARS['disabled'] . '\''; } } if (sizeof($set)) { $query = 'update ' . dok_tn('user') . ' set ' . implode(', ', $set) . ' where id = ' . $VARS['id']; $res = dok_uquery($query); if (!$res) { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_user', 'e'); } } return 'view_user'; }
function dok_song_track() { global $VARS; //check input if (!isset($VARS['song_id']) || !is_numeric($VARS['song_id']) || $VARS['song_id'] < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND, 'dok_song_track', 'e'); return false; } $res = mysql_query('select name from ' . dok_tn('song') . ' where id = ' . $VARS['song_id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_SONG_NOT_FOUND, 'dok_song_track', 'e'); return false; } $song_name = mysql_result($res, 0, 'name'); if (!isset($VARS['album_id']) || !is_numeric($VARS['album_id']) || $VARS['album_id'] < 1) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_song_track', 'e'); return false; } $res = mysql_query('select name from ' . dok_tn('album') . ' where id = ' . $VARS['album_id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_song_track', 'e'); return false; } if (!isset($VARS['track']) || !is_numeric($VARS['track']) || $VARS['track'] < 1) { dok_msg(MSG_ERR_NO_TRACK, 'dok_song_track', 'e'); return false; } $res = mysql_query('select song_id from ' . dok_tn('rel_song_album') . ' where album_id = ' . $VARS['album_id'] . ' and track = ' . $VARS['track'] . ' and song_id != ' . $VARS['song_id']); if (mysql_numrows($res)) { dok_msg(sprintf(MSG_ERR_ALBUM_TRACK_ASSIGNED, $VARS['track']), 'dok_song_track', 'e'); return false; } $res = dok_uquery('delete from ' . dok_tn('rel_song_album') . ' where song_id = ' . $VARS['song_id'] . ' and album_id = ' . $VARS['album_id']); if (!$res) { echo mysql_error(); return false; } $res = dok_uquery('insert into ' . dok_tn('rel_song_album') . ' (song_id, album_id, track) values (' . $VARS['song_id'] . ',' . $VARS['album_id'] . ',' . $VARS['track'] . ')'); if (!$res) { echo mysql_error(); return false; } $VARS['id'] = $VARS['album_id']; return 'view_album'; }
function dok_unlink_song_link() { global $VARS, $GENRES, $USER; if (!isset($VARS['id']) || !strlen(trim($VARS['id'])) || !is_numeric(trim($VARS['id'])) || trim($VARS['id']) < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND, 'dok_create_song_link', 'e'); return false; } if (!isset($VARS['other_id']) || !strlen(trim($VARS['other_id'])) || !is_numeric(trim($VARS['other_id'])) || trim($VARS['other_id']) < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND, 'dok_create_song_link', 'e'); return false; } $options = dok_songs_links_array(); if (!in_array($VARS['link'], array_keys($options))) { dok_msg(MSG_ERR_SONG_NO_LINK_NAME, 'dok_create_song_link', 'e'); return false; } $VARS['other_id'] = trim($VARS['other_id']); $VARS['id'] = trim($VARS['id']); $VARS['nohit'] = 1; $relation = explode('-', $VARS['link']); $query = 'delete from ' . dok_tn('rel_songs') . ' where link = ' . $relation[0] . ' '; if (sizeof($relation)) { if ($relation[1]) { $query .= 'AND song_id1=' . $VARS['other_id'] . ' AND song_id2=' . $VARS['id'] . ' '; } else { $query .= 'AND song_id1=' . $VARS['id'] . ' AND song_id2=' . $VARS['other_id'] . ' '; } } else { if ($VARS['id'] <= $VARS['other_id']) { $query .= 'AND song_id1=' . $VARS['id'] . ' AND song_id2=' . $VARS['other_id'] . ' '; } else { $query .= 'AND song_id1=' . $VARS['other_id'] . ' AND song_id2=' . $VARS['id'] . ' '; } } $res = dok_uquery($query); if ($res) { return 'view_song'; } else { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_unlink_song_link', 'e'); return false; } }
function dok_update_song_album_link() { global $VARS; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_update_song_album_link', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_update_song_album_link', 'e'); return false; } $song = mysql_fetch_array($res); if (!isset($VARS['album']) || !is_numeric($VARS['album']) || $VARS['album'] < 1) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_update_song_album_link', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('album') . ' where id = ' . $VARS['album']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_update_song_album_link', 'e'); return false; } $album = mysql_fetch_array($res); if (!isset($VARS['track']) || !is_numeric($VARS['track']) || $VARS['track'] < 1) { $VARS['track'] = 1; } $res = mysql_query('select r.song_id, s.name from ' . dok_tn('rel_song_album') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where r.album_id = ' . $album['id'] . ' and r.track = ' . $VARS['track']); if (mysql_numrows($res)) { dok_msg(sprintf(MSG_ERR_SONG_TRACK_DUP, mysql_result($res, 0, 'name'), $VARS['track']), 'dok_update_song_album_link', 'e'); return false; } //cool we could update $res = dok_uquery('insert into ' . dok_tn('rel_song_album') . ' (song_id, album_id, track) values (' . $song['id'] . ',' . $album['id'] . ',' . $VARS['track'] . ')'); if ($res) { $VARS['id'] = $album['id']; return 'view_album'; } else { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_song_album_link', 'e'); return false; } }
function dok_create_artist() { global $VARS, $USER; if (!isset($VARS['name'])) { dok_msg(MSG_ERR_NO_ARTIST_NAME, 'dok_create_artist', 'e'); return false; } if (!strlen(trim($VARS['name']))) { dok_msg(MSG_ERR_NO_ARTIST_NAME, 'dok_create_artist', 'e'); return false; } $artist_name = ucwords(substr($VARS['name'], 0, 255)); $res = mysql_query('select id from ' . dok_tn('artist') . ' where name = \'' . addslashes($artist_name) . '\''); if (mysql_numrows($res)) { dok_msg(sprintf(MSG_ERR_DUP_ARTIST_NAME, $artist_name), 'dok_create_artist', 'e'); return false; } //test for soundex if (DOK_USE_SOUNDEX && !$VARS['soundex_checked']) { $query = 'select id, name from ' . dok_tn('artist') . ' where substring(soundex(name) from 2) = substring(soundex(\'' . addslashes($artist_name) . '\') from 2)'; $res = dok_oquery($query); if ($res->numrows()) { $VARS['soundex'] = $res->fetch_col_array('name', 'id'); return 'ask_sound_artist'; } } if (DOK_ENABLE_USER) { $creation_uid = $USER->id; } else { $creation_uid = 0; } //add artist $res = dok_uquery('insert into ' . dok_tn('artist') . ' (name,creation,creation_uid) values (\'' . addslashes($artist_name) . '\',' . time() . ',' . $creation_uid . ')'); if (!$res) { dok_msg(mysql_error(), 'dok_create_artist', 'e'); return false; } $VARS['id'] = mysql_insert_id(); $_SESSION['song_select_artist'] = $VARS['id']; return 'view_artist'; }
function dok_update_song_artist_link() { global $VARS, $ARTIST_SONG_LINKS; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_update_song_artist_link', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_update_song_artist_link', 'e'); return false; } $song = mysql_fetch_array($res); if (!isset($VARS['artist']) || !is_numeric($VARS['artist']) || $VARS['artist'] < 1) { dok_msg(MSG_ERR_ARTIST_NOT_FOUND, 'dok_update_song_artist_link', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_ARTIST_NOT_FOUND, 'dok_update_song_artist_link', 'e'); return false; } $artist = mysql_fetch_array($res); if (!in_array($VARS['link'], array_keys($ARTIST_SONG_LINKS))) { $VARS['link'] = 0; } //cool we could update $res = dok_uquery('insert into ' . dok_tn('rel_song_artist') . ' (song_id, artist_id, link) values (' . $song['id'] . ',' . $artist['id'] . ',' . $VARS['link'] . ')'); if ($res) { $VARS['nohit'] = 1; if (isset($VARS['back2edit'])) { return 'link_song_artist'; } else { return 'view_song'; } } else { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_song_artist_link', 'e'); return false; } }
function dok_create_user() { global $VARS, $USER; if (!isset($VARS['name'])) { dok_msg(MSG_ERR_NO_USER_NAME, 'dok_create_user', 'e'); return false; } $VARS['name'] = substr($VARS['name'], 0, 255); if (!isset($VARS['password']) || !strlen($VARS['password'])) { dok_msg(MSG_ERR_NO_USER_PASSWORD, 'dok_create_user', 'e'); return false; } if ($VARS['password'] != $VARS['password_again']) { dok_msg(MSG_ERR_PASSWORD_MISMATCH, 'dok_create_user', 'e'); return false; } $VARS['password'] = substr($VARS['password'], 0, 255); $res = mysql_query('select id from ' . dok_tn('user') . ' where name = \'' . addslashes($VARS['name']) . '\''); if (mysql_numrows($res)) { dok_msg(sprintf(MSG_ERR_USER_NAME_EXISTS, $VARS['name']), 'dok_create_user', 'e'); return false; } if ($VARS['editor'] != '1') { $VARS['editor'] = 0; } if ($VARS['admin'] != '1') { $VARS['admin'] = 0; } $res = dok_uquery('insert into ' . dok_tn('user') . ' (name, password, editor, admin, creation) values (\'' . addslashes($VARS['name']) . '\', \'' . md5($VARS['password']) . '\', \'' . $VARS['editor'] . '\', \'' . $VARS['admin'] . '\', ' . time() . ')'); if (!$res) { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_create_user', 'e'); return false; } $VARS['id'] = mysql_insert_id(); return 'view_user'; }
function dok_unlink_song_album() { global $VARS; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_unlink_song_album', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_unlink_song_album', 'e'); return false; } $song = mysql_fetch_array($res); if (!isset($VARS['album']) || !is_numeric($VARS['album']) || $VARS['album'] < 1) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_unlink_song_album', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('album') . ' where id = ' . $VARS['album']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_ALBUM_NOT_FOUND, 'dok_unlink_song_album', 'e'); return false; } $album = mysql_fetch_array($res); $res = mysql_query('select album_id from ' . dok_tn('rel_song_album') . ' where song_id = ' . $VARS['id'] . ' AND album_id != ' . $album['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_song_album_link', 'e'); return false; } $res = dok_uquery('delete from ' . dok_tn('rel_song_album') . ' where song_id = ' . $song['id'] . ' and album_id = ' . $album['id']); if ($res) { return 'edit_song'; } else { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_song_album_link', 'e'); return false; } }
function dok_update_song() { global $VARS, $SONGS_LABELS; if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_update_song', 'e'); return false; } $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_SONG_NOT_FOUND_UPDATE, 'dok_update_song', 'e'); return false; } $song = mysql_fetch_array($res); $set = array(); $name = ucwords(trim($VARS['name'])); if (is_string($name) && strlen($name) && $name != $song['name']) { if (!$VARS['dup_checked']) { //check if name is already known $res = dok_oquery('select id from ' . dok_tn('song') . ' where name = \'' . addslashes($name) . '\' and id != ' . $VARS['id']); if ($res->numrows()) { $VARS['duplicates'] = $res->fetch_col_array('id'); return 'ask_dup_song'; } } $set[] = 'name = \'' . addslashes($name) . '\''; } $comment = dok_textarea_2_db($VARS['comment']); if ($comment != $song['comment']) { $set[] = 'comment = \'' . addslashes($VARS['comment']) . '\''; } if (!isset($VARS['release']) || !is_numeric($VARS['release']) || $VARS['release'] < 1901 || $VARS['release'] > 2155) { $VARS['release'] = 0; } if ($VARS['release'] != $song['release']) { $set[] = 'release = ' . $VARS['release']; } $length = 0; if (isset($VARS['length'])) { if (preg_match('/:/', $VARS['length'])) { $test = explode(':', $VARS['length']); if (sizeof($test) > 1) { $sec = 0; if (is_numeric($test[0])) { $sec = $test[0] * 60; } if (is_numeric($test[1])) { $sec += $test[1]; } $length = $sec; } } elseif (is_numeric($VARS['length']) && $VARS['length'] > 0) { $length = $VARS['length']; } } if ($length != $song['length']) { $set[] = 'length = ' . $length; } if (is_numeric($VARS['genre']) && $VARS['genre'] >= 0 && $VARS['genre'] != $song['genre']) { $set[] = 'genre = ' . $VARS['genre']; } if (is_numeric($VARS['label']) && $VARS['label'] != $song['label'] && (in_array($VARS['label'], array_keys($SONGS_LABELS)) && strlen($SONGS_LABELS[$VARS['label']]['label']) || $VARS['label'] == 0)) { $set[] = 'label = ' . $VARS['label']; } // print_r($set); if (sizeof($set)) { $res = dok_uquery('update ' . dok_tn('song') . ' set ' . implode(',', $set) . ' where id = ' . $VARS['id']); } if ($res) { $VARS['nohit'] = 1; return 'view_song'; } else { dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'dok_update_song', 'e'); return false; } }
function dok_song_link_add($id, $other_id, $link, $old_link = 0) { $relation = explode('-', $link); $query = 'insert into ' . dok_tn('rel_songs') . ' (song_id1, song_id2, link) values ('; if (sizeof($relation) == 2) { if (!$relation[1]) { $query .= $id . ', ' . $other_id; } else { $query .= $other_id . ', ' . $id; } } elseif (sizeof($relation) == 1) { if ($id <= $other_id) { $query .= $id . ', ' . $other_id; } else { $query .= $other_id . ', ' . $id; } } else { dok_msg(MSG_ERR_SONG_NO_LINK_NAME, 'utils:dok_song_link_add', 'e'); return false; } $query .= ', ' . $relation[0] . ')'; if ($old_link > 0) { $res = mysql_query('delete from ' . dok_tn('rel_songs') . ' where link = ' . $relation[0] . ' and ( ( song_id1 = ' . $id . ' AND song_id2 = ' . $other_id . ') OR ( song_id1 = ' . $other_id . ' AND song_id2 = ' . $id . '))'); if (!$res) { echo mysql_error(); dok_msg(MSG_ERR_DB_UPDATE_FAILED, 'utils:dok_song_link_add', 'e'); return false; } } return dok_uquery($query); }
function dok_create_song() { global $VARS, $GENRES, $USER, $SONGS_LABELS; if (!isset($VARS['name']) || !strlen(trim($VARS['name']))) { dok_msg(MSG_ERR_SONG_NO_NAME, 'dok_create_song', 'e'); return false; } if (!is_numeric($VARS['album']) || $VARS['album'] < 1) { $VARS['album'] = 0; } $res = mysql_query('select name from ' . dok_tn('album') . ' where id = ' . $VARS['album']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_NO_ALBUM_NAME, 'dok_create_song', 'e'); return false; } $album_name = mysql_result($res, 0, 'name'); $_SESSION['song_select_album'] = $VARS['album']; if (!is_numeric($VARS['artist']) || $VARS['artist'] < 1) { $VARS['artist'] = 0; } $res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist']); if (!mysql_numrows($res)) { dok_msg(MSG_ERR_NO_ARTIST_NAME, 'dok_create_song', 'e'); return false; } $artist_name = mysql_result($res, 0, 'name'); $_SESSION['song_select_artist'] = $VARS['artist']; $song_name = substr($VARS['name'], 0, 255); if (!$VARS['dup_checked']) { $res = dok_oquery('select id from ' . dok_tn('song') . ' where name = \'' . addslashes($song_name) . '\''); if ($res->numrows()) { //dok_msg(MSG_ERR_SONG_DUP_NAME,'dok_create_song','e'); $VARS['duplicates'] = $res->fetch_col_array('id'); return 'ask_dup_song'; } } $song_name = ucwords($song_name); if ($VARS['album_track'] != 'text') { $t_res = mysql_query('select max(track) as m from ' . dok_tn('rel_song_album') . ' where album_id = ' . $VARS['album']); $VARS['track'] = mysql_result($t_res, 0, 'm') + 1; $_SESSION['album_track'] = 'next'; } else { if (!is_numeric($VARS['track']) || $VARS['track'] < 1) { dok_msg(MSG_ERR_NO_TRACK, 'dok_create_song', 'e'); return false; } $_SESSION['album_track'] = 'text'; } $res = mysql_query('select song_id from ' . dok_tn('rel_song_album') . ' where album_id = ' . $VARS['album'] . ' and track = ' . $VARS['track']); if (mysql_numrows($res)) { $dup_song_id = mysql_result($res, 0, 'song_id'); $res = mysql_query('select name from ' . dok_tn('song') . ' where id = ' . $dup_song_id); $dup_song_name = mysql_result($res, 0, 'name'); dok_msg(sprintf(MSG_ERR_SONG_TRACK_DUP, $dup_song_name, $VARS['track']), 'dok_create_song', 'e'); return false; } //check comment $comment = dok_textarea_2_db($VARS['comment']); if (!isset($VARS['release']) || !is_numeric($VARS['release']) || $VARS['release'] < 1901 || $VARS['release'] > 2155) { $VARS['release'] = 0; } $length = dok_str2sec($VARS['length']); if ($VARS['genre'] >= sizeof($GENRES)) { $genre = 0; } else { $genre = $VARS['genre']; $_SESSION['song_select_genre'] = $genre; } if ($VARS['label'] && $VARS['label'] > 0 && in_array($VARS['label'], array_keys($SONGS_LABELS)) && strlen($SONGS_LABELS[$VARS['label']]['label'])) { $label = $VARS['label']; } else { $label = 0; } if (DOK_ENABLE_USER) { $creation_uid = $USER->id; } else { $creation_uid = 0; } //add $res = dok_uquery('insert into ' . dok_tn('song') . ' (name, length, creation, creation_uid, release, comment, genre, label) values (\'' . addslashes($song_name) . '\', ' . $length . ', ' . time() . ',' . $creation_uid . ',' . $VARS['release'] . ',\'' . addslashes($comment) . '\',' . $genre . ', ' . $label . ')'); if (!$res) { echo mysql_error(); return false; } $my_id = mysql_insert_id(); $res = dok_uquery('insert into ' . dok_tn('rel_song_artist') . ' (song_id, artist_id) values (' . $my_id . ',' . $VARS['artist'] . ')'); if (!$res) { echo mysql_error(); return false; } $res = dok_uquery('insert into ' . dok_tn('rel_song_album') . ' (song_id, album_id,track ) values (' . $my_id . ',' . $VARS['album'] . ',' . $VARS['track'] . ')'); if (!$res) { echo mysql_error(); return false; } $VARS['id'] = $my_id; $VARS['nohit'] = 1; if (sizeof($VARS['link'])) { $links = array_keys(dok_songs_links_array()); foreach ($VARS['link'] as $key => $val) { if (is_numeric($key) && $key > 0 && strlen($val) && in_array($val, $links)) { $res = mysql_query('select name from ' . dok_tn('song') . ' where id = ' . $key); if (mysql_numrows($res)) { $res = dok_song_link_add($VARS['id'], $key, $val); } } } } return 'view_song'; }