示例#1
0
     $query_select = $modx->db->select('pitem.id AS pitem_id,ppay.id ppay_id', "{$mod_tab_items} pitem, {$mod_tab_payments} ppay", "pitem.payid = ppay.id AND ppay.orderid='{$payment_orderid}' AND pitem.paid='N'", "", "1");
     if ($modx->db->getRecordCount($query_select) > 0) {
         $ppay = $modx->db->getRow($query_select);
         $payment_no = $ppay['ppay_id'];
     } else {
         $last_id = $modx->db->getValue($modx->db->select("MAX(id)", $mod_tab_payments));
         $payment_no = $last_id + 1;
         $needInsert = 1;
         if ($debug) {
             echo "{$payment_no} - {$needInsert}<br />";
         }
     }
     unset($ppay);
 }
 $chunkArr = array();
 $chunk = fetchTpl($template[$payment_method]['pay']);
 switch ($payment_method) {
     ##########################################
     case "webmoney":
         $browser_ie = strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") === false ? false : true;
         $pay_action = $browser_ie && $charset == "UTF-8" ? $site_url . "assets/snippets/paykeeper/webmoney/utf8_to_cp1251.php" : "https://merchant.webmoney.ru/lmi/payment.asp";
         $crc = getSignature($site_url, $wm_secret_key, $payment_value . ":" . $pay_purse_type, $payment_orderid, $payment_no);
         $h_inputs = '
   <input type="hidden" name="LMI_PAYMENT_AMOUNT" value="' . $payment_value . '" />
   <input type="hidden" name="LMI_PAYMENT_DESC" value="' . $paymentDesc . '" />
   <input type="hidden" name="LMI_PAYMENT_NO" value="' . $payment_no . '" />
   <input type="hidden" name="LMI_PAYEE_PURSE" value="' . $pay_to_purse . '" />
   <input type="hidden" name="SignatureValue" value="' . $crc . '" />
   <input type="hidden" name="OrderID" value="' . $payment_orderid . '" />
 ';
         if ($resultURL) {
            $pay_unit = $row['unit'];
            $pay_link = strpos($pay_url, "?") === false ? $pay_url . "?pay=" . $pay_signature : $pay_url . "&amp;pay=" . $pay_signature;
            $payment_method = $pay_unit == 'RKR' ? 'robokassa' : 'webmoney';
            $payment_value = number_format(floatval($price), 2, '.', '');
            $config_file = MODX_BASE_PATH . "assets/snippets/paykeeper/" . $payment_method . "/config.php";
            if (file_exists($config_file)) {
                require $config_file;
            } else {
                return;
            }
            if ($payment_method == 'robokassa') {
                $crc = md5("{$mrh_login}:{$payment_value}:{$pay_id}:{$mrh_pass1}:Shp_item={$order_id}");
            } else {
                $crc = md5("{$site_url}:{$payment_value}:{$pay_unit}:{$pay_id}:{$wm_secret_key}:Shp_item={$order_id}");
            }
            $modx->db->update("reserved = NULL, price='{$payment_value}'", $modx->getFullTableName('paykeeper_items'), "payid='{$pay_id}' AND paid='N'");
            $modx->db->update("date = NOW(), signature='{$crc}'", $modx->getFullTableName('paykeeper_payments'), "orderid = '{$order_id}' AND state = 'I'");
            $mail_body = fetchTpl($mail_tpl);
            foreach (array('order_id' => $order_id, 'status_name' => $status_name, 'pay_link' => $pay_link, 'site_name' => $site_name) as $key => $value) {
                $mail_body = str_replace('[+' . $key . '+]', $value, $mail_body);
            }
            $output = $mail_body;
        }
        //if registered user
    } else {
        $pay_link_href = $modx->makeUrl($user_orders_doc, '', '', 'full');
        //.'?act=purchase&pid='.$order_id;
        $output = str_replace('pay_link_href', ' href="' . $pay_link_href . '"', $mail_user_text);
    }
    $e->output($output);
}
            if (substr($tpl, 0, 6) == "@CODE:") {
                $template = substr($tpl, 6);
            } else {
                if ($modx->getChunk($tpl) != "") {
                    $template = $modx->getChunk($tpl);
                } else {
                    $template = false;
                }
            }
        }
        return $template;
    }
}
$TVout = $modx->getTemplateVars(array($tvName), "id", $docId);
if (!empty($TVout[0]['value'])) {
    $rowChunk = preg_split('/(\\[\\+loop\\+\\]|\\[\\+end_loop\\+\\])/s', fetchTpl($tpl));
    $output .= $rowChunk[0];
    $fields = explode('||', $TVout[0]['value']);
    foreach ($fields as $key => $val) {
        $row = explode('==', $val);
        $pl_names = array();
        $pl_values = array();
        foreach ($row as $k => $v) {
            $pl_names[] = '[+field' . ($k + 1) . '+]';
            $pl_values[] = $v;
            $pl_names[] = '[+selected' . ($k + 1) . '+]';
            if (isset($_POST[$postName])) {
                $pl_values[] = $_POST[$postName] == $v ? ' selected="selected"' : '';
            } else {
                $pl_values[] = isset($modx->placeholders['form_' . $postName]) && $modx->placeholders['form_' . $postName] == $v ? ' selected="selected"' : '';
            }
         $output = strpos($order_data, $chk_string) !== false ? true : false;
     } else {
         $chk_query = $modx->db->select("id", $modx->getFullTableName('web_user_additdata'), "webuser = '******' AND setting_name = '{$chk_field}' AND setting_value = '1'");
         $output = $modx->db->getRecordCount($chk_query) ? true : false;
     }
     return $output;
 }
 $order_data = $modx->db->getRow($modx->db->select("*", $modx->getFullTableName('manager_shopkeeper'), "id = '{$order_id}'"), 'assoc');
 $phone = $order_data['userid'] == 0 ? $order_data['phone'] : $modx->db->getValue($modx->db->select('setting_value', $modx->getFullTableName('web_user_additdata'), "webuser = '******'userid'] . "' AND setting_name = '{$user_phone_fieldname}'"));
 $phone = preg_replace('/\\D/', '', $phone);
 if ($status_tpl[$status] && checkNecessitySend($order_data['userid'], $order_data['short_txt'], $chk_order_string, $chk_order_user_fieldname)) {
     if (strlen($status_tpl[$status]) == 1) {
         $chnum = intval($status_tpl[$status]);
         $status_tpl[$status] = $status_tpl[$chnum];
     }
     $body = fetchTpl($status_tpl[$status]);
     $body = preg_replace('/[\\r\\n]+/', '', $body);
     $chunkArr = array('orderID' => $order_id, 'status_name' => $phaseName[$status], 'site_name' => $site_name, 'site_url' => $site_url);
     foreach (array_merge($chunkArr, $order_data) as $key => $value) {
         $body = str_replace('[+' . $key . '+]', $value, $body);
     }
     $body = strip_tags(translit($body));
     //send SMS
     if (strlen($phone) == 10 && strlen($body) > 0 && !$sms_testmode) {
         $ch = curl_init();
         $curl_url = $sms_serv_protocol . "://{$sms_serv_login}:{$sms_serv_password}@{$sms_serv_path}?sender={$sms_serv_sender}&phone=+7{$phone}&text=" . urlencode($body);
         curl_setopt($ch, CURLOPT_URL, $curl_url);
         curl_setopt($ch, CURLOPT_REFERER, $site_url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         $send_result = curl_exec($ch);
示例#5
0
 /**
  *
  * @param string $chunkname
  * @param array $chankArr
  * @return string
  */
 function parseTplChunk($chunkname, $chankArr = array())
 {
     $chunk = fetchTpl($chunkname);
     foreach ($chankArr as $key => $value) {
         $chunk = str_replace("[+" . $key . "+]", $value, $chunk);
     }
     return $chunk;
 }
示例#6
0
                    $template = $modx->getChunk($tpl);
                } else {
                    $template = false;
                }
            }
        }
        return $template;
    }
}
if (!$tvValue) {
    $tv = $modx->getObject('modTemplateVar', array('name' => $tvName));
    if ($tv) {
        $tvValue = $tv->getValue($docId);
    }
}
$rowChunk = explode('<!--tpl_separator-->', fetchTpl($tpl));
$fields = $tvValue ? explode('||', $tvValue) : array();
if (strlen($rowIndex) > 0) {
    $fields = array_slice($fields, $rowIndex, 1);
}
$row_unique = uniqid();
$col_unique = uniqid();
if (count($fields) > 0 && count($fields) >= $minCount) {
    foreach ($fields as $key => $val) {
        $row = explode('==', $val);
        $rowArr = array();
        foreach ($row as $k => $v) {
            if (!empty($v) || !$noEmpty) {
                $index = $separateCols ? $k : 0;
                $rowArr[$index][$placeholderPrefix . 'field' . ($separateCols ? '1' : $k + 1)] = $v;
                if (isset($postName_arr[$k])) {