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

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

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

  if ($data['aemail'] != "") {
    $data[tpl]->define(array(body=>"/activate-reactivate.html"));
    $query = "SELECT uid,active,firstname,lastname FROM users WHERE email LIKE '$data[aemail]'";
    $res = mysql_query($query);
    if (mysql_num_rows($res) > 0) {
      if (mysql_result($res,0,'active') != 1) {
        $active = time();
        $uid = mysql_result($res,0,'uid');
        $query = "UPDATE users SET active = $active WHERE uid = $uid";
        mysql_query($query);

        $firstname = mysql_result($res,0,'firstname');
        $lastname = mysql_result($res,0,'lastname');
        send_mail("$firstname $lastname <$data[aemail]>","Thank you for registering with TUve<br><br>Please Click or goto the following link to confirm your email address <A HREF=\"http://www.tuve.tv/activate.php?data[active]=$active&data[email]=$data[aemail]\">http://www.tuve.tv/activate.php?data[active]=$active&data[email]=$data[aemail]</A><br><br>Thank you,<br>The TUve Staff<br>","Please Confirm Your E-Mail Address","support@tuve.tv","TUve Support");
        }
      }
    }
  else {
    $query = "SELECT uid,active,firstname,lastname,username FROM users WHERE (active = $data[active] || active = 1) AND email LIKE '$data[email]'";
    $res = mysql_query($query);
    if (mysql_num_rows($res) == 0)
      $data[tpl]->define(array(body=>"/activate-failed.html"));
    else {
      $data[tpl]->define(array(body=>"/activate-success.html"));
      if (mysql_result($res,0,'active') != 1) {
        $uid = mysql_result($res,0,'uid');
        $rDate = time();
        $query = "UPDATE users SET active = 1,registered = $rDate WHERE uid = $uid";
        mysql_query($query);

        $firstname = mysql_result($res,0,'firstname');
        $lastname = mysql_result($res,0,'lastname');
        $username = mysql_result($res,0,'username');
        send_mail("$firstname $lastname <$data[email]>","Your registration is now complete.<br>Thank you,<br>The TUve Staff<br>","Registation Complete","support@tuve.tv","TUve Support");
        $query = "INSERT INTO artists (artist,bio,photo,oid,sbio) VALUES('$username','No Description','http://www.ubixonline.com/images/UbixCube.swf',$uid,'No Description')";
        mysql_query($query);
        }
      }
    }

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