require_once("/home/castalbums/website/includes/cr-functions.php");
require_once("/home/castalbums/website/includes/cr-ezsql.php");
require_once("/home/castalbums/website/includes/cr-users.php");
require_once("/home/castalbums/website/includes/cr-template.php");
require_once("/home/castalbums/website/includes/cr-star_rating.php");
require_once("/home/castalbums/website/includes/cr-tracks.php");
require_once("/home/castalbums/website/includes/cr-editing.php");
if ($force_recache) $crdb->force_recache = TRUE;
//$id = mysql_real_escape_string($id);
$id = $crdb->escape($id);
if ($flag && $id && $admin) $crdb->query("UPDATE recordings SET marked_for_deletion=1 WHERE recording_id='$id'");
if ($review_recording && $id && ($logged_in_id==1)) $crdb->query("UPDATE recordings SET needs_review=2 WHERE recording_id='$id'");
if ($review_release && $id && ($logged_in_id==1)) $crdb->query("UPDATE releases SET needs_review=2 WHERE release_id='$review_release'");
if ($remove_recording_review && $id && $admin) $crdb->query("UPDATE recordings SET needs_review=0 WHERE recording_id='$id'");
if ($remove_release_review && $id && $admin) $crdb->query("UPDATE releases SET needs_review=0 WHERE release_id='$remove_release_review'");
//if ($default_image && $id && $admin) $crdb->query("UPDATE recordings SET cover_cheat='$default_image' WHERE recording_id='$id'");
if (HavePriv('db_default_image') && isset($default_image) && $id)
{
$crdb->query("UPDATE recordings SET recording_image_id='$default_image' WHERE recording_id='$id'");
RedirectPage(R_URL_to_Recording($id));
}
//if (!$id) header("Location: /recordings/");
$recording = $crdb->get_row('SELECT * FROM recordings WHERE recording_id="'.$id.'"');
//if (!$slug) { RedirectPage(URL_to_Recording($recording)); }
if ($_GET['which_recording_page'])
{
setcookie('which_recording_page', $_GET['which_recording_page'], (time()+60*60*24*30), '/', COOKIE_PATH);
RedirectPage(URL_to_Recording($recording));
}
//if ($_COOKIE['which_recording_page']=='new') { require_once("/home/castalbums/website/recordings/single_new.php"); exit; }
$show_id=$recording->show_id;
if ($recording->show_id) $show=$crdb->get_row('SELECT * FROM shows WHERE show_id="'.$recording->show_id.'"');
$threads = $crdb->get_results('SELECT * FROM forum_taxonomy LEFT JOIN forum_threads USING (thread_id)
LEFT JOIN forums ON (forum_threads.forum_id=forums.forum_id)
WHERE related_type="recording" AND related_id="'.$id.'"
ORDER BY main DESC, thread_last_reply_date DESC');
//$history = $crdb->get_results('SELECT * FROM history LEFT JOIN users ON (user_id_credit=user_id) WHERE id_type="recording" AND id="'.$id.'" ORDER BY submitted DESC');
$cr_page->breadcrumbs[] = 'Database';
$cr_page->breadcrumbs[] = 'Recordings';
if ($show) $cr_page->breadcrumbs[] = Link_to_Show($show);
$cr_page->shortlink = 'r'.$id;
$cr_page->current_nav = 'Database';
$cr_page->id_of_cover_in_title = $recording->recording_image_id;
$cr_page->title = "$recording->recording_title > $recording->source";
if ($include=='stats')
{
$cr_page->breadcrumbs[] = Link_to_Recording($recording);
$cr_page->title = 'Stats: '.$cr_page->title;
}
$cr_page->og->title = strip_tags(Link_to_Recording($recording));
$cr_page->og->url = URL_to_Recording($recording);
if ($recording->type=='Video') $cr_page->og->type = 'video.movie';
else $cr_page->og->type = 'music.album';
$cr_page->og->image = 'http://castalbu.ms'.Thumbnail_Link_from_ID($recording->recording_image_id);
/* //$cover = recordingCover($id);
$cover = coverThumbnail($recording->cover_cheat);
$cover = str_replace(DOMAIN, '', $cover);
if ($cover != '/covers/t/no_cover.png') $cr_page->og->image = 'http://castalbu.ms/'.$cover;
*/
if ($ps = $crdb->get_results('SELECT person_id, person_name, variation FROM roles LEFT JOIN people USING (person_id, variation) WHERE id_type="recording" AND id="'.$id.'" AND role="Performer" ORDER BY credits DESC'))
{
foreach ($ps as $p) $desc .= ', '.FlipName($p->person_name);
$desc = substr($desc, 2);
$cr_page->og->description = str_replace(' ', ' ', $desc);
}
$links=$crdb->get_results("SELECT * FROM links WHERE (db_id='$id' AND db_type='recording') OR (db_id='$show_id' AND db_type='show') ORDER BY db_type");
$blog_posts = R_Blog_Posts($id, 'recording');
//$cr_page->tabs[] = array(URL_to_Recording($recording).'#releases', 'Releases ('.$recording->num_releases.')', ((!$include)?1:0));
$cr_page->tabs[] = array(R_URL_to_Recording($recording).'#releases', 'Releases'.R_Badge($recording->num_releases), ((!$include)?1:0));
//$cr_page->tabs[] = array(URL_to_Recording($recording).'#discussion', 'Discussion ('.(sizeof($threads)+sizeof($blog_posts)).')');
//if (count($links)) $cr_page->tabs[] = array(URL_to_Recording($recording).'#links', 'Discussion ('.count($links).')');
//$cr_page->tabs[] = array(URL_to_Recording($recording).'/stats/', ' '.$recording->collectors);
//$cr_page->tabs[] = array(URL_to_Recording($recording).'/stats/', ' '.$recording->wishers);
$cr_page->tabs[] = array(R_URL_to_Recording($recording).'/stats/', 'Stats', (($include=='stats')?1:0));
//if ($history) $cr_page->tabs[] = array(R_URL_to_Recording($recording).'/history/', 'History'.R_Badge(count($history)), (($include=='history')?1:0));
if ($recording->history_count)
$cr_page->tabs[] = array(R_URL_to_Recording($recording).'/history/', 'History'.R_Badge($recording->history_count), (($include=='history')?1:0));
if (HavePriv('super'))
{
$cr_page->tabs[] = array('/recordings/'.($id-1), '«');
$cr_page->tabs[] = array('/recordings/'.($id+1), '»');
}
if ($logged_in_id) $cr_page->tabs[] = array('/contribute/recording.php?id='.$id, 'Edit Recording');
if ($include=='history') require_once($_SERVER['DOCUMENT_ROOT'].'/recordings/single_history.php');
elseif ($include=='contributors') require_once($_SERVER['DOCUMENT_ROOT'].'/recordings/single_contributors.php');
elseif ($include=='stats') require_once($_SERVER['DOCUMENT_ROOT'].'/recordings/single_stats.php');
elseif ($_COOKIE['which_recording_page']=='new') require_once($_SERVER['DOCUMENT_ROOT'].'/recordings/single_main_new.php');
//elseif (HavePriv('super')) require_once($_SERVER['DOCUMENT_ROOT'].'/recordings/single_main_new.php');
else require_once($_SERVER['DOCUMENT_ROOT'].'/recordings/single_main.php');
?>