Esempio n. 1
0
 function loanApplicationPublicProfile()
 {
     global $session, $form;
     $_POST_ORG = $_POST;
     $_POST = sanitize_custom($_POST);
     $photo = $_POST['isPhoto_select'];
     if (is_uploaded_file($_FILES['bphoto']['tmp_name'])) {
         $photo = $_FILES['bphoto']['tmp_name'];
     }
     if (!empty($_POST["uploadfileanchor"])) {
         $supported = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png", "application/pdf");
         if (isset($_FILES['bphoto']['type'])) {
             $phototype = $_FILES['bphoto']['type'];
         }
         if (isset($_FILES['bphoto']['tmp_name']) && !empty($_FILES['bphoto']['tmp_name']) && in_array($phototype, $supported)) {
             chmod($_FILES['bphoto']['tmp_name'], 0644);
             $time = time();
             if ($_FILES['bphoto']['tmp_name'] == "image/gif") {
                 $photo = $time . ".gif";
             } else {
                 if ($_FILES['bphoto']['tmp_name'] == "image/jpeg" || $_FILES['bphoto']['tmp_name'] == "image/pjpeg") {
                     $photo = $time . ".jpeg";
                 } else {
                     if ($_FILES['bphoto']['tmp_name'] == "image/png" || $_FILES['bphoto']['tmp_name'] == "image/x-png") {
                         $photo = $time . ".png";
                     } else {
                         $photo = $_FILES['bphoto']['name'];
                     }
                 }
             }
             move_uploaded_file($_FILES['bphoto']['tmp_name'], TMP_IMAGE_DIR . $photo);
             $_SESSION['value_array'] = $_POST_ORG;
             $_SESSION['value_array']['isPhoto_select'] = $photo;
             $_SESSION['error_array'] = array();
             header("Location: /index.php?p=9&step=2");
             exit;
         }
     } else {
         $result = $session->loanApplicationPublicProfile(array_get($_POST, 'babout'), array_get($_POST, 'bbizdesc'), $photo);
         if ($result) {
             if (!empty($_POST['isPhoto_select']) && file_exists(TMP_IMAGE_DIR . $_POST['isPhoto_select'])) {
                 $img_file = TMP_IMAGE_DIR . $_POST['isPhoto_select'];
                 $ext[1] = end(explode(".", $img_file));
                 imageUpload($img_file, $ext, $session->userid);
                 removeProfileImageCache($session->userid);
             }
             $_SESSION['loanapplic']['step2'] = true;
             header("Location: /index.php?p=9&step=3");
         } else {
             $_SESSION['value_array'] = $_POST_ORG;
             $_SESSION['error_array'] = $form->getErrorArray();
             $errurl = "/index.php?p=9&step=2";
             if (!empty($_SESSION['error_array']['bphoto'])) {
                 $errurl = '/index.php?p=9&step=2#bphoto';
             } elseif (!empty($_SESSION['error_array']['babout'])) {
                 $errurl = '/index.php?p=9&step=2#babout';
             } elseif (!empty($_SESSION['error_array']['bbizdesc'])) {
                 $errurl = '/index.php?p=9&step=2#bbizdesc';
             }
             header("Location: {$errurl}");
         }
         exit;
     }
 }
Esempio n. 2
0
 function subEditBorrower()
 {
     global $session, $form;
     $id = $session->userid;
     $_POST_ORG = $_POST;
     //Logger_Array("FB LOG - updateprocess start",'fb_data', serialize($_POST['fb_data']).$_POST["busername"]);
     $_POST = sanitize_custom($_POST);
     for ($i = 1; $i <= 10; $i++) {
         $endorser_name[] = array_get($_POST, 'endorser_name' . $i);
         $endorser_email[] = array_get($_POST, 'endorser_email' . $i);
         $endorser_id[] = array_get($_POST, 'endorser_id' . $i);
     }
     if ($_POST['before_fb_data'] == '1') {
         $_SESSION['fb_data'] = $_POST;
         header('Location: index.php?p=13&fb_data=1#FB_cntct');
     } else {
         if (isset($_FILES['front_national_id']['tmp_name']) && !is_uploaded_file($_FILES['front_national_id']['tmp_name']) && !empty($_POST['isFrntNatid'])) {
             $_FILES['front_national_id']['tmp_name'] = $_POST['isFrntNatid'];
             $_FILES['front_national_id']['name'] = end(explode("/", $_POST['isFrntNatid']));
         }
         if (isset($_FILES['back_national_id']['tmp_name']) && !is_uploaded_file($_FILES['back_national_id']['tmp_name']) && !empty($_POST['isbcktnatid'])) {
             $_FILES['back_national_id']['tmp_name'] = $_POST['isbcktnatid'];
             $_FILES['back_national_id']['name'] = end(explode("/", $_POST['isbcktnatid']));
         }
         if (isset($_FILES['address_proof']['tmp_name']) && !is_uploaded_file($_FILES['address_proof']['tmp_name']) && !empty($_POST['isaddrprf'])) {
             $_FILES['address_proof']['tmp_name'] = $_POST['isaddrprf'];
             $_FILES['address_proof']['name'] = end(explode("/", $_POST['isaddrprf']));
         }
         if (isset($_FILES['legal_declaration']['tmp_name']) && !is_uploaded_file($_FILES['legal_declaration']['tmp_name']) && !empty($_POST['islgldecl'])) {
             $_FILES['legal_declaration']['tmp_name'] = $_POST['islgldecl'];
             $_FILES['legal_declaration']['name'] = end(explode("/", $_POST['islgldecl']));
         }
         if (isset($_FILES['legal_declaration2']['tmp_name']) && !is_uploaded_file($_FILES['legal_declaration2']['tmp_name']) && !empty($_POST['islgldecl2'])) {
             $_FILES['legal_declaration2']['tmp_name'] = $_POST['islgldecl2'];
             $_FILES['legal_declaration2']['name'] = end(explode("/", $_POST['islgldecl2']));
         }
         $photo = $_POST['isPhoto_select'];
         if (is_uploaded_file($_FILES['bphoto']['tmp_name'])) {
             $photo = $_FILES['bphoto']['tmp_name'];
         }
         if (!isset($_POST['repaidpast'])) {
             $repaidPast = 0;
         } else {
             $repaidPast = $_POST['repaidpast'];
         }
         if (!isset($_POST['debtfree'])) {
             $debtFree = 0;
         } else {
             $debtFree = $_POST['debtfree'];
         }
         if (!isset($_POST['share_update'])) {
             $share_update = 0;
         } else {
             $share_update = $_POST['share_update'];
         }
         if (!empty($_POST["uploadfileanchor"])) {
             $result = 2;
         } else {
             Logger_Array("FB LOG - updateprocess", 'fb_data', serialize($_POST['fb_data']) . $_POST["busername"]);
             $result = $session->editprofile_b(array_get($_POST, "busername"), array_get($_POST, "bfname"), array_get($_POST, "blname"), array_get($_POST, "bpass1"), array_get($_POST, "bpass2"), array_get($_POST, "bpostadd"), array_get($_POST, "bcity"), array_get($_POST, "bcountry"), array_get($_POST, "bemail"), array_get($_POST, "bmobile"), array_get($_POST, "balternate_mobile"), array_get($_POST, "reffered_by"), array_get($_POST, "bincome"), array_get($_POST, "babout"), array_get($_POST, "bbizdesc"), $photo, $id, array_get($_POST, "bnationid"), array_get($_POST, "labellang"), array_get($_POST, "community_name_no"), $_FILES, array_get($_POST, "abletocomplete"), array_get($_POST, "repaidpast"), array_get($_POST, "debtfree"), array_get($_POST, "share_update"), array_get($_POST, "borrower_behalf"), array_get($_POST, "behalf_name"), array_get($_POST, "behalf_number"), array_get($_POST, "behalf_email"), array_get($_POST, "behalf_town"), array_get($_POST, "borrower_behalf_id"), array_get($_POST, 'submitform'), array_get($_POST, 'uploadedDocs'), array_get($_POST, 'bhome_no'), array_get($_POST, 'refer_member'), array_get($_POST, 'volunteer_mentor'), array_get($_POST, 'cntct_type'), array_get($_POST, 'fb_data'), $endorser_name, $endorser_email, $endorser_id, $_POST);
         }
         if ($result == 0) {
             require "editables/register.php";
             $path = getEditablePath('register.php');
             require "editables/" . $path;
             if ($_POST['submitform'] != trim($lang['register']['RegisterComplete'])) {
                 $_SESSION['bedited'] = true;
             }
             if (is_uploaded_file($_FILES['bphoto']['tmp_name'])) {
                 $img_file = $_FILES['bphoto']['tmp_name'];
                 $ext = split('/', $_FILES['bphoto']['type']);
                 imageUpload($img_file, $ext, $id);
                 removeProfileImageCache($id);
             } else {
                 if (!empty($_POST['isPhoto_select'])) {
                     $img_file = TMP_IMAGE_DIR . $_POST['isPhoto_select'];
                     $ext[1] = end(explode(".", $img_file));
                     imageUpload($img_file, $ext, $id);
                     removeProfileImageCache($id);
                 }
             }
             if (isset($_POST["labellang"]) && $_POST["labellang"] != "en") {
                 $url = SITE_URL . $_POST["labellang"] . "/index.php?p=13";
             } else {
                 if (isset($_GET["language"])) {
                     $language = $_GET["language"];
                     $url = SITE_URL . $language . "/index.php?p=13";
                 } else {
                     $url = SITE_URL . "index.php?p=13";
                 }
             }
             if ($_POST['submitform'] == trim($lang['register']['RegisterComplete'])) {
                 $url = SITE_URL . "index.php?p=50";
             }
             header("Location: {$url}");
         } else {
             $_SESSION['value_array'] = $_POST_ORG;
             $_SESSION['error_array'] = $form->getErrorArray();
             $errurl1 = $_SERVER['HTTP_REFERER'];
             if (strstr($errurl1, "fb_join")) {
                 $errurl = $errurl1;
             } else {
                 $errurl = $errurl1 . "&fb_join=1";
             }
             $supported = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png", "application/pdf");
             if (isset($_FILES['bphoto']['type'])) {
                 $phototype = $_FILES['bphoto']['type'];
             }
             if (isset($_FILES['front_national_id']['type'])) {
                 $frntidtype = $_FILES['front_national_id']['type'];
             }
             if (isset($_FILES['back_national_id']['type'])) {
                 $bkidtype = $_FILES['back_national_id']['type'];
             }
             if (isset($_FILES['address_proof']['type'])) {
                 $addrsype = $_FILES['address_proof']['type'];
             }
             if (isset($_FILES['legal_declaration']['type'])) {
                 $legalype = $_FILES['legal_declaration']['type'];
             }
             if (isset($_FILES['legal_declaration2']['type'])) {
                 $legl2type = $_FILES['legal_declaration2']['type'];
             }
             if (isset($_FILES['bphoto']['tmp_name']) && !empty($_FILES['bphoto']['tmp_name']) && in_array($phototype, $supported)) {
                 chmod($_FILES['bphoto']['tmp_name'], 0644);
                 $time = time();
                 if ($_FILES['bphoto']['tmp_name'] == "image/gif") {
                     $photo = $time . ".gif";
                 } else {
                     if ($_FILES['bphoto']['tmp_name'] == "image/jpeg" || $_FILES['bphoto']['tmp_name'] == "image/pjpeg") {
                         $photo = $time . ".jpeg";
                     } else {
                         if ($_FILES['bphoto']['tmp_name'] == "image/png" || $_FILES['bphoto']['tmp_name'] == "image/x-png") {
                             $photo = $time . ".png";
                         } else {
                             $photo = $_FILES['bphoto']['name'];
                         }
                     }
                 }
                 move_uploaded_file($_FILES['bphoto']['tmp_name'], TMP_IMAGE_DIR . $photo);
                 $_SESSION['value_array']['isPhoto_select'] = $photo;
             }
             if (isset($_FILES['front_national_id']['tmp_name']) && !empty($_FILES['front_national_id']['tmp_name']) && in_array($frntidtype, $supported)) {
                 chmod($_FILES['front_national_id']['tmp_name'], 0644);
                 $time = time();
                 if ($_FILES['front_national_id']['tmp_name'] == "image/gif") {
                     $frntnatid = $time . ".gif";
                 } else {
                     if ($_FILES['front_national_id']['tmp_name'] == "image/jpeg" || $_FILES['front_national_id']['tmp_name'] == "image/pjpeg") {
                         $frntnatid = $time . ".jpeg";
                     } else {
                         if ($_FILES['front_national_id']['tmp_name'] == "image/png" || $_FILES['front_national_id']['tmp_name'] == "image/x-png") {
                             $frntnatid = $time . ".png";
                         } else {
                             $frntnatid = $_FILES['front_national_id']['name'];
                         }
                     }
                 }
                 move_uploaded_file($_FILES['front_national_id']['tmp_name'], TMP_IMAGE_DIR . $frntnatid);
                 $_SESSION['value_array']['isFrntNatid'] = TMP_IMAGE_DIR . $frntnatid;
             }
             if (isset($_FILES['back_national_id']['tmp_name']) && !empty($_FILES['back_national_id']['tmp_name']) && in_array($bkidtype, $supported)) {
                 chmod($_FILES['back_national_id']['tmp_name'], 0644);
                 $time = time();
                 if ($_FILES['back_national_id']['tmp_name'] == "image/gif") {
                     $bcktnatid = $time . ".gif";
                 } else {
                     if ($_FILES['back_national_id']['tmp_name'] == "image/jpeg" || $_FILES['back_national_id']['tmp_name'] == "image/pjpeg") {
                         $bcktnatid = $time . ".jpeg";
                     } else {
                         if ($_FILES['back_national_id']['tmp_name'] == "image/png" || $_FILES['back_national_id']['tmp_name'] == "image/x-png") {
                             $bcktnatid = $time . ".png";
                         } else {
                             $bcktnatid = $_FILES['back_national_id']['name'];
                         }
                     }
                 }
                 move_uploaded_file($_FILES['back_national_id']['tmp_name'], TMP_IMAGE_DIR . $bcktnatid);
                 $_SESSION['value_array']['isbcktnatid'] = TMP_IMAGE_DIR . $bcktnatid;
             }
             if (isset($_FILES['address_proof']['tmp_name']) && !empty($_FILES['address_proof']['tmp_name']) && in_array($addrsype, $supported)) {
                 chmod($_FILES['address_proof']['tmp_name'], 0644);
                 $time = time();
                 if ($_FILES['address_proof']['tmp_name'] == "image/gif") {
                     $addrprf = $time . ".gif";
                 } else {
                     if ($_FILES['address_proof']['tmp_name'] == "image/jpeg" || $_FILES['address_proof']['tmp_name'] == "image/pjpeg") {
                         $addrprf = $time . ".jpeg";
                     } else {
                         if ($_FILES['address_proof']['tmp_name'] == "image/png" || $_FILES['address_proof']['tmp_name'] == "image/x-png") {
                             $addrprf = $time . ".png";
                         } else {
                             $addrprf = $_FILES['address_proof']['name'];
                         }
                     }
                 }
                 move_uploaded_file($_FILES['address_proof']['tmp_name'], TMP_IMAGE_DIR . $addrprf);
                 $_SESSION['value_array']['isaddrprf'] = TMP_IMAGE_DIR . $addrprf;
             }
             if (isset($_FILES['legal_declaration']['tmp_name']) && !empty($_FILES['legal_declaration']['tmp_name']) && in_array($legalype, $supported)) {
                 chmod($_FILES['legal_declaration']['tmp_name'], 0644);
                 $time = time();
                 if ($_FILES['legal_declaration']['tmp_name'] == "image/gif") {
                     $lgldecl = $time . ".gif";
                 } else {
                     if ($_FILES['legal_declaration']['tmp_name'] == "image/jpeg" || $_FILES['legal_declaration']['tmp_name'] == "image/pjpeg") {
                         $lgldecl = $time . ".jpeg";
                     } else {
                         if ($_FILES['legal_declaration']['tmp_name'] == "image/png" || $_FILES['legal_declaration']['tmp_name'] == "image/x-png") {
                             $lgldecl = $time . ".png";
                         } else {
                             $lgldecl = $_FILES['legal_declaration']['name'];
                         }
                     }
                 }
                 move_uploaded_file($_FILES['legal_declaration']['tmp_name'], TMP_IMAGE_DIR . $lgldecl);
                 $_SESSION['value_array']['islgldecl'] = TMP_IMAGE_DIR . $lgldecl;
             }
             if (isset($_FILES['legal_declaration2']['tmp_name']) && !empty($_FILES['legal_declaration2']['tmp_name']) && in_array($legl2type, $supported)) {
                 chmod($_FILES['legal_declaration2']['tmp_name'], 0644);
                 $time = time();
                 if ($_FILES['legal_declaration2']['tmp_name'] == "image/gif") {
                     $lgldecl2 = $time . ".gif";
                 } else {
                     if ($_FILES['legal_declaration2']['tmp_name'] == "image/jpeg" || $_FILES['legal_declaration2']['tmp_name'] == "image/pjpeg") {
                         $lgldecl2 = $time . ".jpeg";
                     } else {
                         if ($_FILES['legal_declaration2']['tmp_name'] == "image/png" || $_FILES['legal_declaration2']['tmp_name'] == "image/x-png") {
                             $lgldecl2 = $time . ".png";
                         } else {
                             $lgldecl2 = $_FILES['legal_declaration2']['name'];
                         }
                     }
                 }
                 move_uploaded_file($_FILES['legal_declaration2']['tmp_name'], TMP_IMAGE_DIR . $lgldecl2);
                 $_SESSION['value_array']['islgldecl2'] = TMP_IMAGE_DIR . $lgldecl2;
             }
             if ($result == 1) {
                 if ($_SESSION['error_array']) {
                     $errurl .= '#' . key($_SESSION['error_array']);
                 }
                 header("Location: {$errurl}");
             } else {
                 $url = $_SERVER['HTTP_REFERER'];
                 if (strstr($url, "fb_join")) {
                     header("Location: {$url}" . $_POST["uploadfileanchor"]);
                 } else {
                     // redirect to borrower form after file upload. $_POST["uploadfileanchor"] contains an anchor
                     header("Location: {$url}&fb_join=1" . $_POST["uploadfileanchor"]);
                 }
             }
             //header('Location: index.php?p=13&err=1007');
         }
     }
 }