include"../include/conn.php";
session_start();
$userId=$_SESSION["userId"];
$loginid=$_SESSION["loginid"];
if(!isset($userId))
header("Location: ../profile/newaccount.php?a=displayLogin");
$display_sql= "select count(*) as COUNT from CSS_APP_GENERAL where CSS_APPLICANT_ID=$userId";
$rpos=OCIParse($conn,$display_sql);
OCIExecute($rpos);
OCIFetchInto($rpos,$disarr,OCI_ASSOC);
$iocoount=$disarr["COUNT"];
if($iocoount==0)
header("Location: ../profile/applicationdetail.php?a=Add&aid=$userId");
if(count($_POST)){
//foreach ($HTTP_POST_VARS as $key => $value) {
foreach ($_POST as $key => $value) {
$$key = $value;
}
}
$a=$_REQUEST["a"];
switch (@$a) {
case "upload":
$v = CheckImage();
if ($v == 1) {
insert_data($conn,1);
displayform();
}else{
$errMsg ="Note: Picture not uploaded.
You can upload a JPG, GIF, or PNG file. (Maximum size of 30KB) This picture will reflect as one of the identities on your Admission Certificate. So, it should be your own and latest photograph. (Please note that uploading irrelevant photograph may lead to disqualification of applicant) ";
displayform();
}
break;
default:
displayform();
}
function displayform()
{
global $conn,$temp,$userId,$errMsg;
?>
include("../include/top.php"); ?>
include("../include/userleft.php"); ?>
include("../include/profileleft.php"); ?>
include("../include/bottom.php"); ?>
}
function insert_data($conn,$flage)
{
global $conn,$userId;
//code added here on 28-03-2013 to check record exist against this appliant_id in GR_APPLICANT_DETAIL
$app_sql = "select count(*) as count from CSS_APP_GENERAL where CSS_APPLICANT_ID = $userId";
$app_rq = OCIParse($conn,$app_sql);
OCIExecute($app_rq);
OCIFetchInto($app_rq,$app_rq_id,OCI_ASSOC);
if($app_rq_id["COUNT"]==0)
{ ?>
header("Location: ../profile/applicationdetail.php?a=display");
}
else {
$lob = OCINewDescriptor($conn, OCI_D_LOB);
$sql="Update CSS_APP_GENERAL set CSS_PHOTO=EMPTY_BLOB() where CSS_APPLICANT_ID=$userId RETURNING CSS_PHOTO INTO :CSS_PHOTO";
$stmt = OCIParse($conn, $sql);
OCIBindByName($stmt, ':CSS_PHOTO', $lob, -1, OCI_B_BLOB);
OCIExecute($stmt, OCI_DEFAULT);
// echo $sql; exit;
// The function $lob->savefile(...) reads from the uploaded file.
// If the data was already in a PHP variable $myv, the
// $lob->save($myv) function could be used instead.
if(strlen($_FILES['imgfile']['name'])>0)
{
if(isset($_FILES['imgfile']['name']))
{
if ($lob->savefile($_FILES['imgfile']['tmp_name'])) {
OCICommit($conn);
}else {
echo "Couldn't upload Blob\n";
}
}
}
$lob->free();
OCIFreeStatement($stmt);
}
?>
}
function CheckImage(){
// echo $_FILES['imgfile']['name']; exit;
if ($_FILES['imgfile']['name'] != "" and ($_FILES['imgfile']['name'] != "none") )
{
$FILE_NAME = $_FILES['imgfile']['name'];
$FILE_SIZE = $_FILES['imgfile']['size'];
$FILE_TYPE = $_FILES['imgfile']['type'];
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
//echo $FILE_TYPE;
switch($FILE_TYPE)
{
case 'image/gif':
$ext = '.gif';
break;
case 'image/jpeg':
$ext = '.jpg';
break;
case 'image/pjpeg':
$ext = '.jpg';
break;
case 'image/x-png':
$ext = '.png';
break;
case 'image/png':
$ext = '.png';
break;
default:
$ext = '.zip';
break;
}
$real_name = $FILE_NAME.$ext;
$FILE_SIZE=intval($FILE_SIZE/1024);
if($ext=='.zip'){
$return = 0;
}else {
// if($FILE_SIZE > 500)
if($FILE_SIZE > 30)
$return = 0;
else
$return = 1;
}
}
return $return;
}
/*
function insert_data($conn,$flage)
{
global $conn,$userId;
$lob = OCINewDescriptor($conn, OCI_D_LOB);
$sql="Update CSS_APP_GENERAL set CSS_PHOTO=EMPTY_BLOB() where CSS_APPLICANT_ID=$userId RETURNING CSS_PHOTO INTO :CSS_PHOTO";
// echo $sql; exit;
$stmt = OCIParse($conn, $sql);
OCIBindByName($stmt, ':CSS_PHOTO', $lob, -1, OCI_B_BLOB);
OCIExecute($stmt, OCI_DEFAULT);
// echo $sql; exit;
// The function $lob->savefile(...) reads from the uploaded file.
// If the data was already in a PHP variable $myv, the
// $lob->save($myv) function could be used instead.
if(strlen($_FILES['imgfile']['name'])>0)
{
if(isset($_FILES['imgfile']['name']))
{
if ($lob->savefile($_FILES['imgfile']['tmp_name'])) {
OCICommit($conn);
}else {
echo "Couldn't upload Blob\n";
}
}
}
$lob->free();
OCIFreeStatement($stmt);
}
function CheckImage(){
// echo $_FILES['imgfile']['name']; exit;
if ($_FILES['imgfile']['name'] != "" and ($_FILES['imgfile']['name'] != "none") )
{
$FILE_NAME = $_FILES['imgfile']['name'];
$FILE_SIZE = $_FILES['imgfile']['size'];
$FILE_TYPE = $_FILES['imgfile']['type'];
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
//echo $FILE_TYPE;
switch($FILE_TYPE)
{
case 'image/gif':
$ext = '.gif';
break;
case 'image/jpeg':
$ext = '.jpg';
break;
case 'image/pjpeg':
$ext = '.jpg';
break;
case 'image/x-png':
$ext = '.png';
break;
default:
$ext = '.zip';
break;
}
$real_name = $FILE_NAME.$ext;
$FILE_SIZE=intval($FILE_SIZE/1024);
if($ext=='.zip'){
$return = 0;
}else {
if($FILE_SIZE > 500)
$return = 0;
else
$return = 1;
}
}
return $return;
}*/
?>