$mus = $music->getMusicInfo($id); if (!$mus) { $page->show404(); } switch ($action) { case 'submit': $coverLoc = WWW_DIR . "covers/music/" . $id . '.jpg'; if ($_FILES['cover']['size'] > 0) { $tmpName = $_FILES['cover']['tmp_name']; $file_info = getimagesize($tmpName); if (!empty($file_info)) { move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc); } } $_POST['cover'] = file_exists($coverLoc) ? 1 : 0; $_POST['salesrank'] = empty($_POST['salesrank']) || !ctype_digit($_POST['salesrank']) ? "null" : $_POST['salesrank']; $_POST['releasedate'] = empty($_POST['releasedate']) || !strtotime($_POST['releasedate']) ? $mus['releasedate'] : date("Y-m-d H:i:s", strtotime($_POST['releasedate'])); $music->update($id, $_POST["title"], $_POST['asin'], $_POST['url'], $_POST["salesrank"], $_POST["artist"], $_POST["publisher"], $_POST["releasedate"], $_POST["year"], $_POST["tracks"], $_POST["cover"], $_POST["genre"]); header("Location:" . WWW_TOP . "/music-list.php"); die; break; case 'view': default: $page->title = "Music Edit"; $page->smarty->assign('music', $mus); $page->smarty->assign('genres', $gen->getGenres(Genres::MUSIC_TYPE)); break; } } $page->content = $page->smarty->fetch('music-edit.tpl'); $page->render();
public function save_order() { $music_array = $_POST['music_id']; $order_array = $_POST['order']; $music = new Music(); foreach ($music_array as $key => $value) { $music_id = $value; $music_order = $order_array[$key]; $music->update('Music', array('sequence' => $music_order), 'id=' . $music_id); } redirect(get_url('music')); }