<?
  /* Main include info */
  ini_set('include_path',"/usr/web/sites/ubixonline.com/include/");
  include("site.inc");

  /* Assign the page title */
  $data[tpl]->assign("PAGE_TITLE","www.ubixonline.com");

  /* Main defines */
  $data[tpl]->define(array(index=>"add.html"));

  //DoSession($data);
  if ($data[artist] && $data[title] && $data[url] && $data[file]) {
    $data[file] = str_replace("%20"," ",$data[file]);
    $query = "INSERT into videos (artist,title,genre,length,file,rating,classification) VALUES('$data[artist]','$data[title]','$data[genre]',0,'$data[file]',$data[rating],$data[class])";
    mysql_query($query);
    }

  $query = "SELECT * FROM videos ORDER BY artist,title";
  $result = mysql_query($query);

  /*
  for ($i=0;$i<mysql_numrows($result);$i++) {
    $file = str_replace("http://www.ubixonline.com/","",mysql_result($result,$i,'file'));
    $vid = mysql_result($result,$i,'vid');
    $qry = "UPDATE videos SET file = \"$file\" WHERE vid = $vid";
    mysql_query($qry);
    }

  $query = "SELECT * FROM videos";
  $result = mysql_query($query);

*/
  $rating[0] = "NA";
  $rating[1] = "G";
  $rating[2] = "PG";
  $rating[3] = "13+";
  $rating[4] = "MA";
  $rating[5] = "AD";


  $class[0] = "NA";
  $class[1] = "Music Video";
  $class[2] = "TV";
  $class[3] = "Anime/Toons";
  $class[4] = "Movie";
  $class[5] = "Documentary";

  for ($i=0;$i<mysql_numrows($result);$i++) {
    $added .= "<TR><TD>" . mysql_result($result,$i,'vid');
    $added .= "</TD><TD>" . mysql_result($result,$i,'artist');
    $added .= "</TD><TD>" . mysql_result($result,$i,'title');
    $added .= "</TD><TD>" . mysql_result($result,$i,'genre');
    $added .= "</TD><TD>" . mysql_result($result,$i,'length');
    $added .= "</TD><TD>" . mysql_result($result,$i,'file');
    $added .= "</TD><TD>" . $rating[mysql_result($result,$i,'rating')];
    $added .= "</TD><TD>" . $class[mysql_result($result,$i,'classification')];
    $added .= "</TD></TR>\n";
    }

  $data[tpl]->assign("SONGS",$added);

  /* Parse and print */
  $data[tpl]->parse(INDEX, array("index"));
  $data[tpl]->FastPrint("INDEX");
?>
