<?php require_once('../Connections/globalclassroom.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "image_upload_form")) {
  $insertSQL = sprintf("INSERT INTO videos (name, videos, description) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_FILES['image_file']['name'], "text"),
                       GetSQLValueString($_POST['description'], "text"));

  mysql_select_db($database_globalclassroom, $globalclassroom);
  $Result1 = mysql_query($insertSQL, $globalclassroom) or die(mysql_error());
}
?><html>

<head><STYLE TYPE="text/css">

<style type="text/css">{ } 
body { scrollbar-face-color:#D0F3FF;
scrollbar-shadow-color:#6699FF;
scrollbar-highlight-color:#D0F3FF;
scrollbar-3dlight-color:#0066FF;
scrollbar-darkshadow-color:#FFE862;
scrollbar-track-color:seashall;
scrollbar-arrow-color:#0066FF}
.style4 {	font-size: 12px;
	font-family: "·s²Ó©úÅé";
}
.style5 {
	color: #0033FF;
	font-size: 14px;
	font-family: "Comic Sans MS";
}
.style6 {	color: #0066FF;
	font-family: "Comic Sans MS";
	font-size: 14px;
}
-->
  </STYLE>

<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>Here I Am Friendship Program</title>
</head>

<body bgcolor="#DDEEFF">

<p style="margin-top: 0; margin-bottom: 0"></p>
<p style="margin-top: 0; margin-bottom: 0">
<img border="0" src="videos.gif" width="165" height="60"></p>
<p><font color="#0066FF" face="Comic Sans MS" style="font-size: 16pt">- Upload a video 
</font></p>
<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?php echo $editFormAction; ?>">
  <p class="style5">
    <?
//print_r($_POST);

if($_POST["action"] == "Upload Video")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An video was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the video was not found.";

if(empty($error))
{
$newimage = "Videos/" . $imagename;
echo "<embed width='320' height='260' src= '$newimage'  >"  ;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}

}

?>
  </p>
  <p class="style5">Name: 
    <label>
    <input name="name" type="text" id="name">
      </label>
  </p>
  <span class="style5">Choose a video to upload  </span>
  <p class="style5">
    <input type="file" name="image_file" size="30">
  </p>
  <p class="style5">Description of Video</p>
  <p>
    <label>
    <textarea name="description" cols="40" rows="8" id="description"></textarea>
    </label>
</p>
  <p>
    <input type="submit" value="Upload Video" name="action">
  </p>
  <p><span class="style6">
      </span></p>
  <p><span class="style4">
    <?
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>
  </span></p>
  <input type="hidden" name="MM_insert" value="image_upload_form">
</form>
</body>

</html>
