Beispiel #1
0
/**
 * Generer le contexte pour le formulaire de requete de paiement
 * il faut avoir un id_transaction et un transaction_hash coherents
 * pour se premunir d'une tentative d'appel exterieur
 *
 * @param int $id_transaction
 * @param string $transaction_hash
 * @param $config
 *   configuration du module
 * @return array
 */
function presta_ogone_call_request_dist($id_transaction, $transaction_hash, $config)
{
    if (!($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction) . " AND transaction_hash=" . sql_quote($transaction_hash)))) {
        return array();
    }
    if (!$row['id_auteur'] and isset($GLOBALS['visiteur_session']['id_auteur']) and $GLOBALS['visiteur_session']['id_auteur']) {
        sql_updateq("spip_transactions", array("id_auteur" => intval($row['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'])), "id_transaction=" . intval($id_transaction));
    }
    $cartes = array('VISA', 'MasterCard', 'American Express');
    if (isset($config['cartes']) and is_array($config['cartes']) and $config['cartes']) {
        $cartes = $config['cartes'];
    }
    include_spip('inc/filtres');
    $contexte = array();
    $contexte['PSPID'] = $config['PSPID'];
    $contexte['orderID'] = $id_transaction . "/" . modulo($row['transaction_hash'], 999999);
    $contexte['operation'] = "SAL";
    // c'est un paiement a l'acte immediat
    // passage en centimes d'euros : round en raison des approximations de calcul de PHP
    $contexte['currency'] = "EUR";
    $contexte['amount'] = intval(round(100 * $row['montant'], 0));
    #if (strlen($montant)<3)
    #	$montant = str_pad($montant,3,'0',STR_PAD_LEFT);
    $contexte['language'] = ogone_language_code($GLOBALS['spip_lang']);
    // recuperer l'email
    $contexte['EMAIL'] = bank_porteur_email($row);
    $contexte['CN'] = "";
    $contexte['ownerZIP'] = "";
    $contexte['owneraddress'] = "";
    $contexte['ownercty'] = "";
    $contexte['ownertown'] = "";
    $contexte['ownertelno'] = "";
    // Urls de retour
    include_spip("inc/bank");
    $contexte['accepturl'] = bank_url_api_retour($config, 'response', "id={$id_transaction};{$transaction_hash}");
    $contexte['declineurl'] = bank_url_api_retour($config, 'cancel', "id={$id_transaction};{$transaction_hash}");
    $contexte['cancelurl'] = bank_url_api_retour($config, 'cancel', "id={$id_transaction};{$transaction_hash}");
    $contexte['exceptionurl'] = bank_url_api_retour($config, 'response', "id={$id_transaction};{$transaction_hash}");
    $hidden = "";
    foreach ($contexte as $k => $v) {
        $hidden .= "<input type='hidden' name='{$k}' value='" . str_replace("'", "&#39;", $v) . "' />";
    }
    include_spip('inc/filtres_mini');
    $contexte = array('hidden' => $hidden, 'action' => ogone_url_serveur($config), 'backurl' => url_absolue(self()), 'id_transaction' => $id_transaction, 'transaction_hash' => $transaction_hash);
    $cartes_possibles = ogone_available_cards($config);
    $contexte['cards'] = array();
    foreach ($cartes as $carte) {
        if (isset($cartes_possibles[$carte])) {
            $contexte['cards'][$carte] = $cartes_possibles[$carte];
        }
    }
    return $contexte;
}
Beispiel #2
0
/**
 * Generer le contexte pour le formulaire de requete de paiement
 * il faut avoir un id_transaction et un transaction_hash coherents
 * pour se premunir d'une tentative d'appel exterieur
 *
 * @param int $id_transaction
 * @param string $transaction_hash
 * @return array
 */
function presta_ogone_call_request_dist($id_transaction, $transaction_hash)
{
    if (!($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction) . " AND transaction_hash=" . sql_quote($transaction_hash)))) {
        return array();
    }
    if (!$row['id_auteur'] and $GLOBALS['visiteur_session']['id_auteur']) {
        sql_updateq("spip_transactions", array("id_auteur" => intval($row['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'])), "id_transaction=" . intval($id_transaction));
    }
    include_spip('inc/filtres');
    $contexte = array();
    $contexte['PSPID'] = ogone_pspid();
    $contexte['orderID'] = $id_transaction . "/" . modulo($row['transaction_hash'], 999999);
    $contexte['operation'] = "SAL";
    // c'est un paiement a l'acte immediat
    // passage en centimes d'euros
    $contexte['currency'] = "EUR";
    $contexte['amount'] = intval(100 * $row['montant']);
    #if (strlen($montant)<3)
    #	$montant = str_pad($montant,3,'0',STR_PAD_LEFT);
    $contexte['language'] = ogone_language_code($GLOBALS['spip_lang']);
    // recuperer l'email
    $contexte['EMAIL'] = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($row['id_auteur']));
    $contexte['CN'] = "";
    $contexte['ownerZIP'] = "";
    $contexte['owneraddress'] = "";
    $contexte['ownercty'] = "";
    $contexte['ownertown'] = "";
    $contexte['ownertelno'] = "";
    // Urls de retour
    $contexte['accepturl'] = generer_url_action('bank_response', "bankp=ogone&id={$id_transaction};{$transaction_hash}", true, true);
    $contexte['declineurl'] = generer_url_action('bank_cancel', "bankp=ogone&id={$id_transaction};{$transaction_hash}", true, true);
    $contexte['cancelurl'] = generer_url_action('bank_cancel', "bankp=ogone&id={$id_transaction};{$transaction_hash}", true, true);
    $contexte['exceptionurl'] = generer_url_action('bank_response', "bankp=ogone&id={$id_transaction};{$transaction_hash}", true, true);
    $hidden = "";
    foreach ($contexte as $k => $v) {
        $hidden .= "<input type='hidden' name='{$k}' value='" . str_replace("'", "&#39;", $v) . "' />";
    }
    include_spip('inc/filtres_mini');
    $contexte = array('hidden' => $hidden, 'action' => _OGONE_URL, 'backurl' => url_absolue(self()), 'id_transaction' => $id_transaction);
    return $contexte;
}
Beispiel #3
0
<?php 
$page = "default";
if (isset($_GET['g'])) {
    $page = $_GET['g'];
}
switch ($page) {
    case 'emisoras':
        modulo('listaEmisoras');
        # code...
        break;
    case 'musica':
        modulo('musica');
        # code...
        break;
    default:
        modulo('default');
        # code...
        break;
}
?>


</div>
</div>





<div class="row audioBar" style="padding-top:5px; padding-right:5px; padding-left:5px; margin-left:0px; height:80px; border-bottom-left-radius:25px; border-bottom-right-radius:25px; width:100%; background-color: rgba(3, 63, 119, 0.49);">
  
Beispiel #4
0
<html>
	<form method="get">
		<input name="chiave" type="text"> 
		<input type="submit"> 
	</form>
</html>

<?php 
/*
 * 
 * $numero = ???
 */
function modulo($numero)
{
    if ($numero < 0) {
        return $numero * -1;
    } else {
        return $numero;
    }
}
$result = modulo($_GET["chiave"]);
echo $result;
Beispiel #5
0
function ToUint32($x)
{
    return modulo(ToInteger($x), pow(2, 32));
}
Beispiel #6
0
function getArcCords($cords, $start, $end, $dir, $prev_lat = 0, $prev_lon = 0)
{
    $start = modulo($start, 360);
    $end = modulo($end, 360);
    $out = "";
    $out2 = "";
    $angularDistance = $cords[2] / 6371000;
    $count = 0;
    if ($dir < 0) {
        $total_angle = -($end - $start);
    } else {
        $total_angle = $end - $start;
    }
    $total_angle = modulo($total_angle, 360);
    if ($total_angle == 0) {
        $total_angle = 360;
    }
    for ($i = $start; $count <= 48; $i += $dir * $total_angle / 48) {
        //$out.= "$i";
        $bearing = deg2rad($i);
        $lat = Asin(Sin($cords[0]) * Cos($angularDistance) + Cos($cords[0]) * Sin($angularDistance) * Cos($bearing));
        $dlon = Atan2(Sin($bearing) * Sin($angularDistance) * Cos($cords[0]), Cos($angularDistance) - Sin($cords[0]) * Sin($lat));
        $lon = fmod($cords[1] + $dlon + M_PI, 2 * M_PI) - M_PI;
        $latOut = rad2deg($lat);
        $lonOut = rad2deg($lon);
        $out .= encode($latOut - $prev_lat) . encode($lonOut - $prev_lon);
        $out2 .= "{$lonOut},{$latOut},0 ";
        $prev_lat = $latOut;
        $prev_lon = $lonOut;
        $count++;
    }
    return array($out, $out2);
}
Beispiel #7
0
<?php

// Código exemplo abaixo
$code = " inteiro a, b\n\t\t\t  a = 4\n\t\t\t  b = a\n\t\t\t  saida(a+b)";
// Esta é a função que receberá o código do professor no multiprova e retornará a saída para o arquivo "/tmp/minhasaida.txt"
//A função está com esta aparência não estética, porque ao tentar colocar de outro modo, o código parou de funcionar
function modulo($codigo)
{
    $arquivo = fopen('teste.por', 'w');
    fwrite($arquivo, $codigo);
    fclose($arquivo);
    $lua = new Lua();
    $saida = $lua->eval(<<<CODE
  
   local var = require "parser"
   local var2 = require "interpretador"
   var.interpreta("/var/www/html/mportugol/teste.por")
   local f = var2.retornaSaida()
   return f
   
CODE
);
    return $saida;
}
$valorFinal = modulo($code);
echo "</br> A saída é: {$valorFinal} ";
Beispiel #8
0
list($a, $b) = array($b, $a);
echo $a . "</br>" . $b . "<br />";
?>

-----------esercizio2-------
<?php 
$numero = -5;
function modulo($numero)
{
    if ($numero < 0) {
        $numero = -$numero;
    }
    return $numero;
}
$num = -5;
$result = modulo($num);
echo 8 + $result;
?>
----------esercizio2 con  CLASSI modulo-------
<?php 
class Numero
{
    private $n;
    public function __construct($numero)
    {
        $this->n = $numero;
    }
    public function modulo()
    {
        if ($this->n < 0) {
            return -$this->n;
Beispiel #9
0
/**
 * Generer un numero de transaction sur 6 chiffres unique pour une journee
 * Utilise par systempay et sips
 * pour le generer on utilise
 * le nombre de secondes depuis le debut de la journee x 10 + id_transaction%10
 * soit 864009
 * ce qui autorise 10 paiements/secondes. Au pire si collision il suffit de recommencer
 * deux presentations de la meme transaction donnent 2 vads_trans_id differents
 *
 * @param array $row
 * @return string
 */
function bank_transaction_id($row)
{
    $now = time();
    $id = 10 * (date('s', $now) + 60 * (date('i', $now) + 60 * date('H', $now)));
    $id += modulo($row['id_transaction'], 10);
    return str_pad($id, 6, "0", STR_PAD_LEFT);
}
Beispiel #10
0
// end SortZoneLevelList
print "<table border=0 width=100%><tr valign=top><td width=100%>";
print "<center><table border=1>";
print "<tr class='menuh'><th>Name</th>\n       <th class=tab_title>Short name</th>";
$LevelMax = 0;
for ($i = 0; $i <= $ServerMaxNPCLevel / 5; $i++) {
    $LevelMax += 5;
    $LevelMin = $LevelMax - 4;
    print "<th class=tab_title>" . $LevelMin . " - " . $LevelMax . "</th>";
}
print "</tr>";
$nb = 0;
for ($i = 0; $i <= $cpt; $i++) {
    if ($zones[$i]["npcs"] > $lowlimit) {
        $nb++;
        if (modulo($nb, 10) == 1) {
            print "<tr>\n       <td class=tab_title>Name</td>\n       <td class=tab_title>Short name</td>";
            if ($SortZoneLevelList == TRUE) {
                print "<td class=tab_title>Avg Lvl</td>";
            }
            foreach ($levels as $key2 => $val2) {
                print "<td class=tab_title>{$val2}</td>";
            }
            print "</tr>";
        }
        print "<tr>\n           <td><a href=zone.php?name=" . $zones[$i]["shortname"] . ">" . $zones[$i]["longname"] . "</a></td>\n           <td>" . $zones[$i]["shortname"] . "</td>";
        if ($SortZoneLevelList == TRUE) {
            print "<td align=center>" . round($zones[$i]["val"]) . "</td>";
        }
        foreach ($levels as $lkey => $lval) {
            print "<td align=center>";
Beispiel #11
0
     $leap = false;
 }
 if ($leap == true and $_POST['fmonth'] == '02' and ($_POST['fday'] == '30' or $_POST['fday'] == '31')) {
     $_POST['fday'] = '29';
 }
 if ($leap == false and $_POST['fmonth'] == '02' and ($_POST['fday'] == '29' or $_POST['fday'] == '30' or $_POST['fday'] == '31')) {
     $_POST['fday'] = '28';
 }
 if (($_POST['fmonth'] == '04' or $_POST['fmonth'] == '06' or $_POST['fmonth'] == '09' or $_POST['fmonth'] == '11') and $_POST['fday'] == '31') {
     $_POST['fday'] = '30';
 }
 $UK_time = new DateTimeZone("Europe/London");
 $target_timezone = new DateTimeZone($_POST['timezone']);
 $start_date = new dateTime($_POST['fyear'] . $_POST['fmonth'] . $_POST['fday'] . $_POST['ftime'], $target_timezone);
 $start_date->setTimezone($UK_time);
 if (modulo($_POST['tyear'], 4) == 0 and modulo($_POST['tyear'], 100) != 0 or modulo($_POST['tyear'], 400) == 0) {
     $leap = true;
 } else {
     $leap = false;
 }
 if ($leap == true and $_POST['tmonth'] == '02' and ($_POST['tday'] == '30' or $_POST['tday'] == '31')) {
     $_POST['tday'] = '29';
 }
 if ($leap == false and $_POST['tmonth'] == '02' and ($_POST['tday'] == '29' or $_POST['tday'] == '30' or $_POST['tday'] == '31')) {
     $_POST['tday'] = '28';
 }
 if (($_POST['tmonth'] == '04' or $_POST['tmonth'] == '06' or $_POST['tmonth'] == '09' or $_POST['tmonth'] == '11') and $_POST['tday'] == '31') {
     $_POST['tday'] = '30';
 }
 $end_date = new dateTime($_POST['tyear'] . $_POST['tmonth'] . $_POST['tday'] . $_POST['ttime'], $target_timezone);
 $end_date->setTimezone($UK_time);
Beispiel #12
0
function is_leap($year)
{
    if (modulo($year, 4) == 0 and modulo($year, 100) != 0 or modulo($year, 400) == 0) {
        return true;
    } else {
        return false;
    }
}