case 'US': $iconfile = $baseurl . '/images/6card-logos-small.gif'; //show 6 icons break; default: if (strpos($data['timezone'], 'Europe/') === 0) { $iconfile = $baseurl . '/images/3card-logos-small.gif'; } else { $iconfile = NULL; } break; } } else { $iconfile = NULL; } $symbol = StripeGate\Utils::GetSymbol($row['currency']); $t = StripeGate\Utils::GetPublicAmount(1999, $row['amountformat'], $symbol); $tplvars = $tplvars + array('currency_example' => $this->Lang('currency_example', $t), 'logos' => $iconfile, 'title_amount' => $this->Lang('payamount'), 'amount' => $amount, 'title_cvc' => $this->Lang('cardcvc'), 'cvc' => $cvc, 'title_expiry' => $this->Lang('cardexpiry'), 'MM' => $this->Lang('month_template'), 'month' => $month, 'YYYY' => $this->Lang('year_template'), 'year' => $year, 'title_number' => $this->Lang('cardnumber'), 'number' => $number, 'title_payfor' => $this->Lang('payfor'), 'payfor' => $payfor, 'title_paywhat' => $this->Lang('paywhat'), 'paywhat' => $paywhat, 'submit' => $this->Lang('submit')); if (isset($params['withcancel'])) { $tplvars['cancel'] = $this->Lang('cancel'); } if ($row['surchargerate'] > 0.0 && empty($params['nosur'])) { $surrate = $row['surchargerate']; $t = number_format($surrate * 100, 2); if (strrpos($t, '0') > 0) { $t = rtrim($t, '0.'); } $surstr = $this->Lang('percent', $t); $t = '<span id="surcharge">' . $surstr . '</span>'; $tplvars['surcharge'] = $this->Lang('surcharge', $t); } else {
/** CSV: @mod: reference to current StripeGate module object @account_id: index of account to process, or array of such indices, or FALSE if @record_id is provided @record_id: index of record to process, or array of such indices, or FALSE to process @account_id, default=FALSE @fp: handle of open file, if writing data to disk, or FALSE if constructing in memory, default = FALSE @$sep: field-separator in output data, assumed single-byte ASCII, default = ',' Constructs a CSV string for specified/all records belonging to @account_id, and returns the string or writes it progressively to the file associated with @fp (which must be opened and closed upstream) To avoid field-corruption, existing separators in headings or data are converted to something else, generally like &#...; (except when the separator is '&', '#' or ';', those become %...%) Returns: TRUE/string, or FALSE on error */ private function CSV(&$mod, $account_id = FALSE, $record_id = FALSE, $fp = FALSE, $sep = ',') { global $db; $pref = cms_db_prefix(); $adata = $db->GetAssoc('SELECT account_id,name,currency,amountformat FROM ' . $pref . 'module_sgt_account'); if (!$adata) { return FALSE; } if ($account_id) { if (is_array($account_id)) { $sql = 'SELECT record_id FROM ' . $pref . 'module_sgt_record WHERE account_id IN(' . implode('?,', count($account_id) - 1) . '?) ORDER BY account_id,recorded'; $all = $db->GetCol($sql, $account_id); } else { $sql = 'SELECT record_id FROM ' . $pref . 'module_sgt_record WHERE account_id=? ORDER BY recorded'; $all = $db->GetCol($sql, array($account_id)); } } elseif ($record_id) { if (is_array($record_id)) { $all = $record_id; } else { $all = array($record_id); } } else { return FALSE; } foreach ($adata as $id => &$row) { $row['symbol'] = StripeGate\Utils::GetSymbol($row['currency']); } unset($row); if ($fp && ini_get('mbstring.internal_encoding') !== FALSE) { //send to file, and conversion is possible $config = cmsms()->GetConfig(); if (!empty($config['default_encoding'])) { $defchars = trim($config['default_encoding']); } else { $defchars = 'UTF-8'; } $expchars = $mod->GetPreference('export_file_encoding', 'ISO-8859-1'); $convert = strcasecmp($expchars, $defchars) != 0; } else { $convert = FALSE; } $sep2 = $sep != ' ' ? ' ' : ','; switch ($sep) { case '&': $r = '%38%'; break; case '#': $r = '%35%'; break; case ';': $r = '%59%'; break; default: $r = '&#' . ord($sep) . ';'; break; } $strip = $mod->GetPreference('strip_on_export', FALSE); //header line $outstr = implode($sep, array('account', 'amount', 'recorded', 'stripe identifier', 'paywhat', 'payfor')); $outstr .= PHP_EOL; if ($all) { $sql = 'SELECT * FROM ' . $pref . 'module_sgt_record WHERE record_id IN(' . implode(',', $all) . ')'; $all = $db->GetArray($sql); //data lines(s) foreach ($all as &$row) { unset($row['record_id']); $aid = (int) $row['account_id']; unset($row['account_id']); $fv = $adata[$aid]['name']; if ($strip) { $fv = strip_tags($fv); } $fv = str_replace($sep, $r, $fv); $outstr .= preg_replace('/[\\n\\t\\r]/', $sep2, $fv); foreach ($row as $fn => $fv) { switch ($fn) { case 'amount': $outstr .= $sep . StripeGate\Utils::GetPublicAmount($fv, $adata[$aid]['amountformat'], $adata[$aid]['symbol']); break; case 'recorded': $outstr .= $sep . date('Y-m-d H:i:s', $fv); break; default: if ($strip) { $fv = strip_tags($fv); } $fv = str_replace($sep, $r, $fv); $outstr .= $sep . preg_replace('/[\\n\\t\\r]/', $sep2, $fv); } } $outstr .= PHP_EOL; if ($fp) { if ($convert) { $conv = mb_convert_encoding($outstr, $expchars, $defchars); fwrite($fp, $conv); unset($conv); } else { fwrite($fp, $outstr); } $outstr = ''; } } unset($row); if ($fp) { return TRUE; } else { return $outstr; } //encoding conversion upstream } else { //no data, produce just a header line if ($fp) { if ($convert) { $conv = mb_convert_encoding($outstr, $expchars, $defchars); fwrite($fp, $conv); unset($conv); } else { fwrite($fp, $outstr); } return TRUE; } return $outstr; //encoding conversion upstream } }