Example #1
0
} else {
    fputs($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets($fp, 1024);
        if (strcmp($res, "VERIFIED") == 0) {
            $item_name = $_POST['item_name'];
            $item_number = $_POST['item_number'];
            $payment_status = $_POST['payment_status'];
            $payment_amount = $_POST['mc_gross'];
            $payment_currency = $_POST['mc_currency'];
            $txn_id = $_POST['txn_id'];
            $receiver_email = $_POST['receiver_email'];
            $payer_email = $_POST['payer_email'];
            $invoice = $_POST['invoice'];
            $message = $item_name . ' number ' . $item_number . ' status ' . $payment_status . ' item number ' . $item_number . ' amount ' . $payment_amount . ' currency ' . $payment_currency . ' txn id ' . $txn_id . 'email ' . $receiver_email . ' email ' . $payer_email . ' INOIVCE ' . $invoice;
            Logger($message, $level);
            require_once "../session.php";
            $database->updatePayPalTxn($invoice, $txn_id, $payment_amount, $payment_status);
            // check the payment_status is Completed
            // check that txn_id has not been previously processed
            // check that receiver_email is your Primary PayPal email
            // check that payment_amount/payment_currency are correct
            // process payment
        } else {
            if (strcmp($res, "INVALID") == 0) {
                // log for manual investigation
            }
        }
    }
    fclose($fp);
}
Example #2
0
function getLoanprofileUrl($userid, $loanid)
{
    global $database;
    $username = $database->getUserNameById($userid);
    if (empty($username)) {
        $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
        Logger("uname_empty_url_rewrite_loanprofile" . $referer . " " . $userid . " " . $loanid);
    }
    $username = str_replace(' ', '-', $username);
    $url = "microfinance/loan/{$username}/{$loanid}.html";
    return $url;
}
Example #3
0
<?php

include_once "library/session.php";
include_once "./editables/admin.php";
include_once "./editables/active-b.php";
?>
<div class='span12'>
<?php 
if ($session->userlevel != PARTNER_LEVEL && $session->userlevel != ADMIN_LEVEL && $session->userlevel != BORROWER_LEVEL && $session->userlevel != LENDER_LEVEL) {
    Logger("UNauthorized access activated partner" . $session->userid);
    echo $lang['active-b']['not_allowed '];
}
$co_access = $database->isBorrowerAlreadyAccess($session->userid);
if ($session->userlevel == BORROWER_LEVEL && $co_access == 0) {
    Logger("Non-loggedin Or Uauthorized access activated partner" . $session->userid);
    echo $lang['active-b']['not_allowed '];
} else {
    $page = 1;
    $limit = 500;
    $prt = 0;
    if (isset($_GET['page']) && !empty($_GET['page'])) {
        $page = $_GET['page'];
    }
    $start = ($page - 1) * $limit;
    $ord = "ASC";
    $ordClass = "headerSortDown";
    if (isset($_GET["ord"]) && $_GET["ord"] == 'DESC') {
        $ord = 'DESC';
        $ordClass = "headerSortUp";
    }
    $type = 1;
Example #4
0
 function saveRepayReport($id, $name, $number, $date, $note, $borrowerid, $loanid, $isedit, $mentor)
 {
     global $db;
     $res = 0;
     $res1 = 0;
     $currentdate = time();
     if (!empty($id)) {
         //            $q = "UPDATE ! set rec_form_offcr_name = ?, rec_form_offcr_num = ?, mentor_id=? where userid = ?";
         //            $res = $db->query($q, array('borrowers_extn', $name, $number, $mentor, $borrowerid ));
         $q = "UPDATE ! SET mentor_id=? where userid = ?";
         $res = $db->query($q, array('borrowers_extn', $mentor, $borrowerid));
     }
     if (!empty($borrowerid)) {
         $p = "SELECT id, note from ! where borrowerid = ?";
         $repaydet = $db->getRow($p, array('repay_report_detail', $borrowerid));
         if (!empty($repaydet['id'])) {
             $new_note = $repaydet['note'] . " " . $note;
             if ($isedit == 1) {
                 $q1 = "UPDATE ! set expected_repaydate = ?, note = ?, modified = {$currentdate} where id = ?";
                 $res1 = $db->query($q1, array('repay_report_detail', $date, $note, $repaydet['id']));
             } else {
                 $q1 = "UPDATE ! set expected_repaydate = ?, note = ?, modified = {$currentdate} where id = ?";
                 $res1 = $db->query($q1, array('repay_report_detail', $date, $new_note, $repaydet['id']));
             }
         } else {
             $q1 = "INSERT INTO ! (borrowerid, expected_repaydate, note, created) VALUES  (?,?,?,?)";
             $res1 = $db->query($q1, array('repay_report_detail', $borrowerid, $date, $note, $currentdate));
         }
     } else {
         Logger("REPAYRPT: blank data bid = " . $borrowerid . "loanid =" . $loanid . "\n");
     }
     if ($res1 === 1) {
         if ($isedit == 1) {
             return 2;
         } else {
             return 1;
         }
     } else {
         return 0;
     }
 }
Example #5
0
if (!empty($borrowerid)) {
    $p = "SELECT id, note from ! where borrowerid = ?";
    $repaydet = $db->getRow($p, array('repay_report_detail', $borrowerid));
    if (!empty($repaydet['id'])) {
        $new_note = $repaydet['note'] . " " . $note;
        if ($isedit == 1) {
            $q1 = "UPDATE ! set expected_repaydate = ?, note = ?, modified = {$currentdate} where id = ?";
            $res1 = $db->query($q1, array('repay_report_detail', $date, $note, $repaydet['id']));
            Logger("REPAYRPT: update tbl: repay_report_detail expected_repaydate=" . $date . "note" . $note . "id = " . $repaydet['id'] . "logged in user: "******"\n");
        } else {
            $q1 = "UPDATE ! set expected_repaydate = ?, note = ?, modified = {$currentdate} where id = ?";
            $res1 = $db->query($q1, array('repay_report_detail', $date, $new_note, $repaydet['id']));
            Logger("REPAYRPT: update tbl: repay_report_detail expected_repaydate=" . $date . "note" . $new_note . "id = " . $repaydet['id'] . "logged in user: "******"\n");
        }
    } else {
        $q1 = "INSERT INTO ! (borrowerid, expected_repaydate, note, created) VALUES  (?,?,?,?)";
        $res1 = $db->query($q1, array('repay_report_detail', $borrowerid, $date, $note, $currentdate));
        Logger("REPAYRPT: insert tbl: repay_report_detail expected_repaydate=" . $date . "note" . $note . "bid = " . $borrowerid . "loanid =" . $loanid . " logged in user: "******"\n");
    }
} else {
    Logger("REPAYRPT: blank data bid = " . $borrowerid . "loanid =" . $loanid . "\n");
}
if ($res1 === 1) {
    if ($isedit == 1) {
        echo 2;
    } else {
        echo 1;
    }
} else {
    echo 0;
}
Example #6
0
 function ProcessCart($userid, $donation = 0)
 {
     global $database, $session;
     $availableamount = $this->amountToUseForBid($userid);
     $BidsinCart = $database->getBidsFromCart($userid);
     Logger("bids in cart " . serialize($BidsinCart));
     $returnarr = array();
     $donation_details = $database->getDonationFromCart($userid);
     if ($donation > 0 && $availableamount > $donation) {
         $donationamt = -1 * $donation;
         $database->startDbTxn();
         $res = $database->setTransaction(ADMIN_ID, $donation, 'Donation from lender', 0, 0, DONATION);
         if ($res != 0) {
             $res1 = $database->setTransaction($userid, $donationamt, 'Donation to Zidisha', 0, 0, DONATION);
             if ($res1 != 0) {
                 $this->sendDonationMail($userid, $donation);
                 $database->commitTxn();
             } else {
                 $database->rollbackTxn();
             }
         } else {
             $database->rollbackTxn();
         }
     }
     foreach ($donation_details as $donation_detail) {
         $donation = $donation_detail['amount'];
         if ($donation > 0 && $availableamount >= $donation) {
             $donationamt = -1 * $donation;
             $database->startDbTxn();
             $res = $database->setTransaction(ADMIN_ID, $donation, 'Donation from lender', 0, 0, DONATION);
             if ($res != 0) {
                 $res1 = $database->setTransaction($userid, $donationamt, 'Donation to Zidisha', 0, 0, DONATION);
                 if ($res1 != 0) {
                     $database->updateCartStatus($donation_detail['id'], 'COMPLETED');
                     $this->sendDonationMail($userid, $donation);
                     $database->commitTxn();
                     $_SESSION['donation_give'] = $donation_detail['id'];
                 } else {
                     $database->rollbackTxn();
                 }
             } else {
                 $database->rollbackTxn();
             }
         }
     }
     if (!empty($BidsinCart)) {
         foreach ($BidsinCart as $bid) {
             $loanstatus = $database->getUserLoanStatus($bid['borrowerid'], $bid['loanid']);
             if ($loanstatus['active'] == LOAN_OPEN) {
                 $LoanbidId = $this->placebid($bid['loanid'], $bid['borrowerid'], $bid['bidamt'], $bid['bidint'], 0, true, $userid, 1);
                 // last sent argument added so that we can check if the place bid function called by Processcart
                 Logger("loanbid id after placebid in processcart \n" . serialize($LoanbidId));
                 if (is_array($LoanbidId)) {
                     $database->updateCartStatus($bid['id'], 'COMPLETED');
                     Logger("updating cart status COMPLETED \n");
                     $lastCartbid = $bid['loanid'];
                     $lastCartbrwr = $bid['borrowerid'];
                     $_SESSION['lender_bid_success1'] = 1;
                     $_SESSION['lender_bid_success_amt'] = $bid['bidamt'];
                     $_SESSION['lender_bid_success_int'] = $bid['bidint'];
                     $returnarr['borrowerid'] = $bid['borrowerid'];
                     $returnarr['loanid'] = $bid['loanid'];
                 }
             } else {
                 $database->updateCartStatus($bid['id'], 'EXPIRED');
             }
         }
     }
     $GiftcardsinCart = $database->getGiftcardsFromCart($userid);
     $availamount = $this->amountToUseForBid($userid);
     foreach ($GiftcardsinCart as $giftcard) {
         Logger("gift cards in carts \n", serialize($giftcard));
         if ($availamount >= $giftcard['card_amount']) {
             $database->startDbTxn();
             $amount = $giftcard['card_amount'] * -1;
             $txn_id_trans = $database->setTransaction($giftcard['userid'], $amount, 'Gift Card Purchase', 0, 0, GIFT_PURCHAGE, 1);
             if ($txn_id_trans != 0) {
                 sleep(1);
                 $txn_id = $database->setTransaction(ADMIN_ID, $giftcard['card_amount'], 'Gift Card Purchase', 0, 0, GIFT_PURCHAGE, 1);
                 if ($txn_id != 0) {
                     $res1 = $database->updateGiftTransactionCart($txn_id_trans, $giftcard['txn_id']);
                     if ($res1 === 1) {
                         $database->updateCartStatus($giftcard['id'], 'COMPLETED');
                         $this->sendGiftCardMailsToReciever($giftcard['txn_id']);
                         $this->sendGiftCardMailsToSender($giftcard['txn_id']);
                         Logger_Array("gift cards process completed in carts", $giftcard);
                         $database->commitTxn();
                         $_SESSION['gifcardids'][] = $giftcard['id'];
                     } else {
                         $database->rollbackTxn();
                     }
                 } else {
                     $database->rollbackTxn();
                 }
             } else {
                 $database->rollbackTxn();
             }
         } else {
             break;
         }
     }
     return $returnarr;
 }
Example #7
0
if ($valid) {
    $payment_amount = $mc_gross;
    $payment_currency = $mc_currency;
    $message = $item_name . ' number ' . $item_number . ' status ' . $payment_status . ' item number ' . $item_number . ' amount ' . $payment_amount . ' currency ' . $payment_currency . ' txn id ' . $txn_id . 'email ' . $receiver_email . ' email ' . $payer_email . ' INOIVCE ' . $invoice;
    Logger($message, $level);
    $rtn = $database->updatePayPalTxn($txn_id, $payment_amount, $payment_status, $custom, $invoice);
    Logger("PayPal IPN In root \n" . serialize($rtn));
    if (!empty($rtn) && $rtn['txn_type'] == 'fund') {
        /* code commented to stop fund upload mail to lenders. fund upload mail only will sent on manual upload by admin */
        //$session->sendFundUploadMail($rtn['userid'],$rtn['amount']);
        if ($rtn['donation'] > 0) {
            $session->sendDonationMail($rtn['userid'], $rtn['donation']);
            Logger("PayPal IPN In root Sending donation mail \n");
        }
    } elseif (!empty($rtn) && $rtn['txn_type'] == 'gift') {
        $res2 = $session->sendGiftCardMailsToSender($rtn['order_id']);
        $res3 = $session->sendGiftCardMailsToReciever($rtn['order_id']);
        if ($rtn['donation'] > 0) {
            if ($rtn['userid'] != 0) {
                $session->sendDonationMail($rtn['userid'], $rtn['donation']);
            } else {
                if (!empty($rtn['senderEmail'])) {
                    $session->sendDonationMail($rtn['userid'], $rtn['donation'], $rtn['senderEmail'], $rtn['senderName']);
                }
            }
            /*$session->sendDonationReminderMailToAdmin($rtn['donation']);*/
        }
    }
} else {
    Logger('invalid IPN from Paypal', $level);
}
Example #8
0
function mailSender($hdr_from, $hdr_to, $email, $subject, $header, $body, $attachment = '', $templet = 0, $html = 0, $tag = 0, $info = 0, $replyTo = null)
{
    global $database, $session;
    Logger("ZDISHAEMAILSENTTEST");
    $body_original = $body;
    $body2 = isset($info['emailmssg2']) ? $info['emailmssg2'] : null;
    $body3 = isset($info['emailmssg3']) ? $info['emailmssg3'] : null;
    /*
    This is a wrapper function for sending emails
      $hdr_from  - THe from address to be kept in the header
      $hdr_to    - The to name and address to be kept in the Header
      $email     - Email address to which the mail to be sent
      $subject   - Subject of the email
      $body      - The body of the email
      $attachment - Mail Attachment
    */
    if (!defined('ECHO_EMAILS')) {
        define('ECHO_EMAILS', false);
    }
    if (!defined('PHP_EMAILS')) {
        define('PHP_EMAILS', false);
    }
    if (!defined('HTTP_METHOD')) {
        define('HTTP_METHOD', 'http://');
    }
    if (!defined('DOC_ROOT')) {
        define('DOC_ROOT', '/i/');
    }
    if (!defined('MAIL_TYPE')) {
        define('MAIL_TYPE', 'mail');
    }
    $encodeArray = array('en' => 'UTF-8', 'fr' => 'iso-8859-1');
    /* Construct the header portion */
    /* clear html injects Begin */
    if (!empty($templet)) {
        $templet = forReadFile($templet);
    } else {
        $templet = forReadFile("editables/email/simplemail.html");
    }
    if ($html == 2) {
        $templet = str_replace('%user_msg%', $info['user_msg'], $templet);
        $templet = str_replace('%image_link%', $info['image_link'], $templet);
        $templet = str_replace('%site_link%', $info['site_link'], $templet);
        $templet = str_replace('%image_src%', $info['image_src'], $templet);
        $templet = str_replace('%lend_image_src%', $info['lend_image_src'], $templet);
        $templet = str_replace('%borrower_link%', $info['borrower_link'], $templet);
        $templet = str_replace('%borrower_name%', $info['borrower_name'], $templet);
        $templet = str_replace('%fbrating%', $info['fbrating'], $templet);
        $templet = str_replace('%fbrating_count%', $info['fbrating_count'], $templet);
        $templet = str_replace('%fbrating_link%', $info['fbrating_link'], $templet);
        $templet = str_replace('%location%', $info['location'], $templet);
        $templet = str_replace('%loan_use%', $info['loan_use'], $templet);
        $templet = str_replace('%lend_link%', $info['lend_link'], $templet);
        $templet = str_replace('%amount_req%', $info['amount_req'], $templet);
        $templet = str_replace('%interest%', $info['interest'], $templet);
        $templet = str_replace('%statusbar%', $info['statusbar'], $templet);
        $templet = str_replace('%content_mail%', $body, $templet);
    } else {
        if ($html == 3) {
            error_log('HTML: ' . $html);
            $templet = str_replace('%header%', $header, $templet);
            $templet = str_replace('%content_mail%', $body, $templet);
            if (!empty($info['image_src'])) {
                $templet = str_replace('%image_src%', '<img class="" id="mainImage" src="' . $info['image_src'] . '" style="width:100%; cursor:auto" width="100%">', $templet);
            } else {
                $templet = str_replace('%image_src%', '', $templet);
            }
            if (!empty($info['link']) && !empty($info['anchor'])) {
                $templet = str_replace('%linked_text%', "<a href='" . $info['link'] . "'>" . $info['anchor'] . "</a>", $templet);
            } else {
                $templet = str_replace('%linked_text%', '', $templet);
            }
            if (!empty($info['footer'])) {
                $footer = $info['footer'];
            } else {
                $footer = "View our latest loan projects here!";
            }
            if (!empty($info['button_url'])) {
                $button_url = $info['button_url'];
            } else {
                $button_url = "https://www.zidisha.org/microfinance/lend.html";
            }
            if (!empty($info['button_text'])) {
                $button_text = $info['button_text'];
            } else {
                $button_text = "View Loans";
            }
            if (empty($tag)) {
                $tag = ACCOUNT_NOTIFICATIONS_TAG;
            }
            if ($tag == ACCOUNT_NOTIFICATIONS_TAG) {
                $template = SENDWITHUS_TEMPLATE_ACCOUNT;
            } elseif ($tag == BORROWER_NOTIFICATIONS_TAG) {
                $template = SENDWITHUS_TEMPLATE_BORROWER_ACCOUNT;
            } elseif ($tag == COMMENT_NOTIFICATIONS_TOBORROWER_TAG) {
                $template = SENDWITHUS_TEMPLATE_COMMENTS_TOBORROWER;
            } elseif ($tag == COMMENT_NOTIFICATIONS_TAG) {
                $template = SENDWITHUS_TEMPLATE_COMMENTS;
            } elseif ($tag == NEWS_TAG) {
                $template = SENDWITHUS_TEMPLATE_NEWS;
            } elseif ($tag == NEW_THIS_WEEK_TAG) {
                $template = SENDWITHUS_TEMPLATE_3FEATURES;
            } elseif ($tag == PROMOTE_LOAN_TAG) {
                $template = SENDWITHUS_TEMPLATE_PROMOTELOAN;
            } elseif ($tag == LENDER_FIRSTLOAN_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_FIRSTLOAN;
            } elseif ($tag == LENDER_FULLY_FUNDED_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_FULLYFUNDED;
            } elseif ($tag == LENDER_DISBURSED_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_DISBURSED;
            } elseif ($tag == LENDER_REPAYMENT_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_REPAYMENT;
            } elseif ($tag == INVITE_CREDIT_TAG) {
                $template = SENDWITHUS_TEMPLATE_INVITE_CREDIT;
            } elseif ($tag == INVITE_ACCEPTED_TAG) {
                $template = SENDWITHUS_TEMPLATE_INVITE_ACCEPTED_CREDIT;
            } elseif ($tag == NEW_LENDER_INTRO_TAG) {
                $template = SENDWITHUS_TEMPLATE_NEW_LENDER_INTRO;
            }
        }
    }
    $hdr_from = stripslashes(clearPost($hdr_from));
    $hdr_to = stripslashes(clearPost($hdr_to));
    if ($replyTo != null) {
        $replyTo = stripslashes(clearPost($replyTo));
    }
    $email = clearPost($email);
    $subject = clearPost($subject);
    $body = clearPost($body);
    /* Html inject removed */
    include_once PEAR_DIR . 'Mail/mime.php';
    global $bannerURL, $config, $smarty;
    $crlf = chr(10);
    // as required in the PEAR manuals for use with PEAR mail. We use chr(10) instead of /n, because /n was displayed as the last line of the email.
    $uname = $database->getUserNamesByEmail($email);
    $cc = '';
    if (count($uname) > 1) {
        Logger("Multiple users found on same email " . $email);
    } elseif (isset($uname[0]['username'])) {
        $ulevel = $database->getUserLevel($uname[0]['username']);
        $brwrid = $database->getUserId($uname[0]['username']);
        if ($ulevel == BORROWER_LEVEL) {
            $behalfid = $database->getborrowerbehalfid($brwrid);
            if ($behalfid > 0) {
                $behalfdetail = $database->getBorrowerbehalfdetail($behalfid);
                $cc = $behalfdetail['email'];
            }
        }
    } else {
        Logger("No user with email address " . $email);
    }
    $headers = array('From' => $hdr_from, 'Subject' => stripslashes($subject), 'Reply-To' => $replyTo, 'Cc' => $cc);
    $mime = new Mail_mime($crlf);
    $language = "en";
    if (isset($_GET["language"])) {
        $language = $_GET["language"];
    }
    /* modify the encoding in mine with what is given for chosen language */
    $mime->_build_params['text_encoding'] = '7bit';
    //get_lang('mail_text_encoding');
    $mime->_build_params['html_encoding'] = '7bit';
    //get_lang('mail_html_encoding');
    $mime->_build_params['html_charset'] = isset($encodeArray[$language]) ? $encodeArray[$language] : $encodeArray['en'];
    //get_lang('mail_html_charset');
    $mime->_build_params['text_charset'] = isset($encodeArray[$language]) ? $encodeArray[$language] : $encodeArray['en'];
    //get_lang('mail_text_charset');
    $mime->_build_params['head_charset'] = isset($encodeArray[$language]) ? $encodeArray[$language] : $encodeArray['en'];
    // get_lang('mail_head_charset');
    if ($html) {
        $body = str_replace('#content#', $body, $templet);
    }
    $siteurl = SITE_URL;
    $body = str_replace('#link#', $siteurl, $body);
    $body = str_replace('#SiteUrl#', $siteurl, $body);
    $parserfile = 'css_parser.php';
    require_once $parserfile;
    $cssparser = new cssParser();
    //$css is css stylesheet string
    //$cssparser->ParseStr($css);
    $cssfile = FULL_PATH . 'css/default/style.css';
    $cssparser->parseFile($cssfile);
    $htmlholder = new htmlholder($body);
    $htmlholder->replaceCSS($cssparser->codestr_holder);
    $page = $htmlholder->out();
    $page = str_replace('#SiteUrl#', $siteurl, $page);
    $mime->setHTMLBody($page);
    if (!is_array($attachment)) {
        $attach_files = explode(',', $attachment);
    } else {
        $attach_files = $attachment;
    }
    if (count($attach_files) > 0) {
        foreach ($attach_files as $file) {
            if ($file != '') {
                $mime->addAttachment("../emailimages/" . $file);
            }
        }
    }
    $body = $mime->get();
    $hdrs = $mime->headers($headers);
    $params = false;
    if (MAIL_TYPE == 'smtp') {
        $params['host'] = SMTP_HOST;
        $params['port'] = SMTP_PORT;
        $params['auth'] = SMTP_AUTH == '1' ? true : false;
        $params['username'] = SMTP_USER;
        $params['password'] = SMTP_PASS;
    }
    if (1) {
        $mail_type = 'mail';
    } else {
        $mail_type = MAIL_TYPE;
    }
    if (ECHO_EMAILS === true) {
        echo $email . "<br/>";
        print_r($hdrs);
        echo "<br/>" . $body . "<br/>";
        $result = 1;
    } elseif (PHP_EMAILS) {
        include_once PEAR_DIR . 'Mail.php';
        $mailer = Mail::factory('mail');
        $mailer->send($email, $hdrs, $body);
        $result = 1;
    } else {
        $sendwithus_api = new API(SENDWITHUS_API_KEY);
        if (empty($body2)) {
            $email_data = array('subject' => $headers['Subject'], 'header' => $header, 'image_src' => $info['image_src'], 'content' => $body_original, 'content2' => $info['content2'], 'link' => array('text' => $info['anchor'], 'url' => $info['link']), 'loan_use' => $info['loan_use'], 'statusbar' => $info['statusbar'], 'footer' => $footer, 'button' => array('url' => $button_url, 'text' => $button_text));
        } else {
            $email_data = array('subject' => $headers['Subject'], 'header' => $header, 'heading' => $info['heading'], 'title' => $info['title'], 'percent' => $info['percent'], 'image_src' => $info['image_src'], 'content' => $body_original, 'link' => array('text' => $info['anchor'], 'url' => $info['link']), 'heading2' => $info['heading2'], 'title2' => $info['title2'], 'percent2' => $info['percent2'], 'image_src2' => $info['image_src2'], 'content2' => $body2, 'link2' => array('text2' => $info['anchor2'], 'url2' => $info['link2']), 'heading3' => $info['heading3'], 'title3' => $info['title3'], 'percent3' => $info['percent3'], 'image_src3' => $info['image_src3'], 'content3' => $body3, 'link3' => array('text3' => $info['anchor3'], 'url3' => $info['link3']), 'footer' => $footer, 'button' => array('url' => $button_url, 'text' => $button_text));
            $template = SENDWITHUS_TEMPLATE_3FEATURES;
        }
        $result = $sendwithus_api->send($template, array('address' => $email), $email_data);
    }
    return $result;
}
Example #9
0
<?php

include_once "../library/session.php";
global $db;
$res = 0;
$brwrid = $_POST["id"];
$lastvisited = strtotime($_POST["lastvisited"]);
$admin_notes = $_POST["admin_notes"];
$currentdate = time();
if (!empty($brwrid)) {
    $p = "SELECT id, note from ! where borrowerid = ?";
    $repaydet = $db->getRow($p, array('repay_report_detail', $brwrid));
    if (!empty($repaydet)) {
        $q = "UPDATE ! set lastVisited = ?, note = ?, modified = ? where borrowerid = ?";
        $res = $db->query($q, array('repay_report_detail', $lastvisited, $admin_notes, $currentdate, $brwrid));
        Logger("UPDATE activated borrower : logged in user id \n" . $session->userid);
        Logger("UPDATE activated borrower : last visited , admin notes , currntdate,borrower id \n" . $lastvisited . "  " . $admin_notes . "  " . $currentdate . "  " . $brwrid);
    } else {
        $q1 = "INSERT INTO ! (borrowerid, lastVisited, note, created) VALUES  (?,?,?,?)";
        $res = $db->query($q1, array('repay_report_detail', $brwrid, $lastvisited, $admin_notes, $currentdate));
    }
}
if ($res === 1) {
    echo "<font color=green>saved</font>";
} else {
    echo "<font color=red>failed</font>";
}
Example #10
0
 /**
  * setError - Records new form error given the form
  * field name and the error message attached to it.
  */
 function setError($field, $errmsg)
 {
     $this->errors[$field] = $errmsg;
     $this->num_errors = count($this->errors);
     Logger(__METHOD__ . $errmsg, 1);
 }
Example #11
0
 function processStripe($stripe_token, $amount, $fee_amount)
 {
     global $database;
     require_once "extlibs/stripe-php-1.11.0/lib/Stripe.php";
     $country = getCountryCodeByIP();
     if (in_array($country['code'], array('CN', 'ID', 'SG', 'KE', 'MZ'))) {
         $_SESSION['stripe_error'] = "blocked";
         return false;
     }
     Stripe::setApiKey(STRIPE_SECRET_KEY);
     $payment_success = false;
     try {
         $email = $database->getEmail($this->userid);
         $charge = Stripe_Charge::create(array("amount" => $amount * 100, "currency" => "usd", "card" => $stripe_token, "description" => $email['email']));
         $payment_success = true;
     } catch (Stripe_Error $e) {
         $_SESSION['stripe_error'] = "charge";
         Logger("Stripe error: userid  " . $this->userid);
         Logger("Stripe error: token   " . $stripe_token);
         Logger("Stripe error: message " . $e->getMessage());
         Logger("Stripe error: status  " . $e->getHttpStatus());
         Logger("Stripe error: body    " . $e->getHttpBody());
     }
     if ($payment_success) {
         $stripe_tran_fee = $fee_amount * -1;
         for ($retry = 0; $retry < 3; $retry++) {
             $database->startDbTxn();
             $res1 = $database->setTransaction($this->userid, $amount, 'Funds upload to lender account', 0, 0, FUND_UPLOAD, 0, 0, UPLOADED_BY_STRIPE);
             $res2 = $res3 = 1;
             if ($fee_amount > 0) {
                 $res2 = $database->setTransaction($this->userid, $stripe_tran_fee, 'Stripe transaction fee', 0, 0, STRIPE_FEE);
                 $res3 = $database->setTransaction(ADMIN_ID, $fee_amount, 'Lender transaction fee', 0, 0, STRIPE_FEE);
             }
             if ($res1 == 1 && $res2 == 1 && $res3 == 1) {
                 $database->commitTxn();
                 return true;
             } else {
                 $database->rollbackTxn();
             }
         }
         $_SESSION['stripe_error'] = "transaction";
         Logger("Stripe error: userid  " . $this->userid);
         Logger("Stripe error: token   " . $stripe_token);
         // TODO send mail
     }
     return false;
 }
Example #12
0
            echo "<br/><br/>";
            echo "<div align='left'>You now have USD " . number_format($availAmt, 2, ".", ",") . " available for lending.  <a href='microfinance/lend.html'>Make a loan</a></div>";
        }
        if (!empty($bidData)) {
            $_SESSION['bidPaymentSuccess'] = 1;
            echo "<SCRIPT type='text/javascript'>\n\t\t\t\t\tbidRedirect(" . $bidData['loanid'] . ", " . $bidData['borrowerid'] . ", " . $bidData['bidup'] . ");\n\t\t\t\t\t</SCRIPT>";
        }
        if (!empty($processCart)) {
            if (is_array($processCart)) {
                Logger("In Paypaldetails redirecting to bid page\n");
                $_SESSION['lender_bid_success1'] = 1;
                $_SESSION['lender_bid_success_amt'] = $processCart['bidamt'];
                $_SESSION['lender_bid_success_int'] = $processCart['bidint'];
                echo "<SCRIPT type='text/javascript'>\n\t\t\t\t\t\tbidRedirect(" . $processCart['loanid'] . ", " . $processCart['borrowerid'] . ", " . '1' . ");     \n\t\t\t\t\t</SCRIPT>";
            } else {
                Logger("In Paypaldetails redirecting to giftcard page \n" . $_GET['cm']);
                $_SESSION['PaidGiftcardCart'] = $_GET['cm'];
                echo "<SCRIPT type='text/javascript'>\n\t\t\t\t\t\t\t\thdrRedirect();     \n\t\t\t\t\t\t\t</SCRIPT>";
            }
        }
    } elseif (!empty($rtn) && $rtn['txn_type'] == 'gift') {
        echo "<SCRIPT type='text/javascript'>\n\t\t\t\thdrRedirect();     \n\t\t\t\t</SCRIPT>";
    } else {
        Logger_Array("cvError", 'paypal transaction update failed, transaction-id', $_GET['tx']);
        echo "<div align='center'><font color=green><b>Thank you! The transaction is not yet complete. We will update your <a href='index.php?p=16&u={$session->userid}'>Account</a> when the transaction is completed by Paypal.</b></font></div>";
        echo "<br/><br/>";
        echo "<div align='left'><b>Paypal Transaction Id:</b> " . $_GET['tx'] . "</div>";
    }
} else {
    if (isset($_GET['tx'])) {
        echo "<div align='center'><font color=green><b>Thank you! The transaction is not yet complete. We will update your <a href='index.php?p=16&u={$session->userid}'>Account</a> when the transaction is completed by Paypal.</b></font></div>";
Example #13
0
 function ProcessCart()
 {
     global $session;
     $_POST = sanitize_custom($_POST);
     if (empty($session->userid)) {
         // We cannot use $_SESSION['value_array'] because $form is global
         // and the login form is already using it
         $_SESSION['lending_cart_values'] = $_POST;
         $_SESSION['lending_cart_login'] = true;
         $_SESSION['login_alert'] = "Please log in to continue.";
         header("Location: index.php?p=116");
         exit;
     }
     $result = $session->ProcessMyCart($session->userid, $_POST['paypal_donation']);
     Logger("ProcessCart PayNow \n" . serialize($result) . "session lender bid success \n" . $_SESSION['lender_bid_success1']);
     if (isset($_SESSION['lender_bid_success1']) && isset($result['borrowerid'])) {
         $loanprurl = getLoanprofileUrl($result['borrowerid'], $result['loanid']);
         header("Location: {$loanprurl}#e5");
     } else {
         if (isset($_SESSION['gifcardids'])) {
             header("Location: index.php?p=28");
         } else {
             header("Location: index.php?p=75");
         }
     }
     exit;
 }
Example #14
0
 /**
  * callback from one hour translation
  */
 function on_ajax_nopriv_tp_ohtcallback()
 {
     $ohtp = get_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, array());
     tp_logger($ohtp);
     if ($ohtp[$_POST['projectid']]) {
         Logger($_POST['projectid'] . " was found and will be processed");
         do_action('transposh_oht_callback');
         tp_logger($_POST);
         $ohtp[$_POST['projectid']] -= $_POST['items'];
         if ($ohtp[$_POST['projectid']] <= 0) {
             unset($ohtp[$_POST['projectid']]);
         }
         tp_logger($ohtp);
         update_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, $ohtp);
         $this->database->update_translation("OHT");
     }
     die;
 }
Example #15
0
    $value = urlencode(stripslashes($value));
    $req .= "&" . $key . "=" . $value;
    $ipn_email .= $key . " = " . urldecode($value) . '<br />';
    $ipn_data_array[$key] = urldecode($value);
}
// Store IPN data serialized for RAW data storage later
$ipn_serialized = serialize($ipn_data_array);
// Store RAW IPN log in the DB
require_once "../session.php";
global $db;
$invoice = $ipn_data_array[UMinvoice];
if ($invoice == 0) {
    echo "There was a problem processing your transaction. Please contact admin to complete the transaction.";
} else {
    $txn_status = $database->getTransactionStatus($invoice);
    Logger_Array("cvError_txn_status", $txn_status, $invoice);
    if (strtoupper($txn_status) == 'START') {
        $ret = $database->saveRawIPNPaySimple($ipn_serialized);
        $q = "select * from ! where ipn_data_serialized = ?";
        $row = $db->getRow($q, array('paysimple_ipn_raw_log', $ipn_serialized));
        Logger($ipn_serialized, $level);
        if ($ipn_data_array[UMstatus] == "Approved" && $ipn_data_array[UMerrorcode] == 00) {
            $database->updatePaySimpleTxn($invoice, $row['id']);
            echo "Your payment transaction has been completed, and funds credited to your lender account.  Please click <a href='../../index.php?p=16&u=" . $session->userid . "'><strong>here</strong></a> to view your current account status.";
        } else {
            Logger('invalid IPN from PaySimple', $level);
        }
    } else {
        echo "Your payment transaction has been completed, and funds credited to your lender account.  Please click <a href='../../index.php?p=16&u=" . $session->userid . "'><strong>here</strong></a> to view your current account status.";
    }
}
Example #16
0
 function ProcessCart()
 {
     global $session;
     $_POST = sanitize_custom($_POST);
     $result = $session->ProcessMyCart($session->userid, $_POST['paypal_donation']);
     Logger("ProcessCart PayNow \n" . serialize($result) . "session lender bid success \n" . $_SESSION['lender_bid_success1']);
     if (isset($_SESSION['lender_bid_success1']) && isset($result['borrowerid'])) {
         $loanprurl = getLoanprofileUrl($result['borrowerid'], $result['loanid']);
         header("Location: {$loanprurl}#e5");
     } else {
         if (isset($_SESSION['gifcardids'])) {
             header("Location: index.php?p=28");
         } else {
             header("Location: index.php?p=75");
         }
     }
     exit;
 }