<?
  /* 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","ubixonline.com");

  /* Main defines */
  $data[tpl]->define(array(index=>"index/index.html"));
  $data[tpl]->define(array(menu=>"menu/blank.html"));
  $data[tpl]->define(array(body=>"videos/main.html"));
  $data['tpl']->define(array(row=>"videos/row.html"));

  DoSession($data);
  if ($data[gid] == 1)
    $data[tpl]->define(array(menu=>"menu/admin.html"));
  else
    $data[tpl]->define(array(menu=>"menu/user.tpl"));

  if ($data[update] != "") {

  if ($data[artist]) {
    foreach ($data[artist] as $key => $val) {
      $query = "UPDATE videos SET artist = '$val' WHERE vid = '$key'";
      mysql_query($query);
      }
    }
  if ($data[title]) {
    foreach ($data[title] as $key => $val) {
      $query = "UPDATE videos SET title = '$val' WHERE vid = '$key'";
      mysql_query($query);
      }
    }
  if ($data[genre]) {
    foreach ($data[genre] as $key => $val) {
      $query = "UPDATE videos SET genre = '$val' WHERE vid = '$key'";
      mysql_query($query);
      }
    }
  if ($data[length]) {
    foreach ($data[length] as $key => $val) {
      $query = "UPDATE videos SET length = '$val' WHERE vid = '$key'";
      mysql_query($query);
      }
    }
  if ($data[rating]) {
    foreach ($data[rating] as $key => $val) {
      $query = "UPDATE videos SET rating = '$val' WHERE vid = '$key'";
      mysql_query($query);
      }
    }
  if ($data[file]) {
    foreach ($data[file] as $key => $val) {
      $query = "UPDATE videos SET file = '$val' WHERE vid = '$key'";
      mysql_query($query);
      }
    }
    }

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

  for ($i=0;$i<mysql_numrows($result);$i++) {
    $data['tpl']->assign("VID",mysql_result($result,$i,'vid'));
    $data['tpl']->assign("ARTIST",mysql_result($result,$i,'artist'));
    $data['tpl']->assign("TITLE",mysql_result($result,$i,'title'));
    $data[tpl]->parse(ROWS,".row");
    }



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