コード例 #1
0
ファイル: toCsv.php プロジェクト: nicoworq/pgame
<?php

include_once '../../php/Pascal.php';
$pg = new Pascal();
$ranking = $pg->getRankingCSV();
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="pascalNavidad.csv";');
$f = fopen('php://output', 'w');
fputcsv($f, array("ID", "Nombre", "Email", "Telefono", "Dni"), ',');
foreach ($ranking as $line) {
    fputcsv($f, $line, ',');
}
コード例 #2
0
ファイル: ajax.php プロジェクト: nicoworq/pgame
//Descarto por ser un bot!
if (isset($sex) && $sex !== '') {
    echo json_encode(array('enviado' => TRUE, 'trucho' => TRUE));
    die;
}
//Descarto por ser un bot!
if (!isset($email) && $email === '' || !isset($name) && $name === '') {
    echo json_encode(array('enviado' => TRUE, 'trucho' => TRUE));
    die;
}
if (!$tk->verifyFormToken('send-score', $code)) {
    echo json_encode(array('enviado' => TRUE, 'CRFF' => TRUE));
    die;
}
$puntaje = intval($score);
$tiempo = intval($time);
$coincidencias = intval($matches);
$intentos = intval($tries);
$pascal = new Pascal();
$insertedID = $pascal->insertParticipant($name, $email, $dni, $puntaje, $phone, $tiempo, $coincidencias, $intentos);
if ($insertedID[0]) {
    if ($pascal->sendEmail($email)) {
        echo json_encode(array('enviado' => TRUE, 'idParticipante' => $insertedID[1]));
    } else {
        echo json_encode(array('enviado' => FALSE, 'MAILFAIL' => TRUE));
    }
} elseif ($insertedID[1] === 'existente') {
    echo json_encode(array('enviado' => FALSE, 'existente' => TRUE));
} else {
    echo json_encode(array('enviado' => FALSE, 'DBFAIL' => TRUE));
}
コード例 #3
0
ファイル: ajaxShare.php プロジェクト: nicoworq/pgame
<?php

include_once './TokenCSRF.php';
include_once './Pascal.php';
header('Content-type: application/json');
$tk = new TokenCSRF();
$token = $_POST['code'];
if (!$tk->verifyFormToken('code-fb', $token)) {
    echo json_encode(array('enviado' => TRUE, 'CRFF' => TRUE));
    die;
}
$id_participante = intval($_POST['idParticipante']);
$puntaje = intval($_POST['totalScore']);
$pg = new Pascal();
if ($pg->participantShared($id_participante, $puntaje)) {
    echo json_encode(array('enviado' => TRUE));
} else {
    echo json_encode(array('enviado' => FALSE, 'DB' => FALSE));
}
コード例 #4
0
ファイル: ajaxRanking.php プロジェクト: nicoworq/pgame
<?php

include_once './TokenCSRF.php';
include_once './Pascal.php';
header('Content-type: application/json');
$tk = new TokenCSRF();
$token = $_POST['code'];
if (!$tk->verifyFormToken('get-ranking', $token)) {
    echo json_encode(array('enviado' => TRUE, 'CRFF' => TRUE));
    die;
}
$pg = new Pascal();
echo json_encode($pg->getRanking());
コード例 #5
0
ファイル: PascalTest.php プロジェクト: markrogoyski/math-php
 /**
  * @dataProvider dataProviderForPMF
  */
 public function testPMF(int $x, int $r, float $P, float $neagative_binomial_distribution)
 {
     $this->assertEquals($neagative_binomial_distribution, Pascal::PMF($x, $r, $P), '', 0.001);
 }
コード例 #6
0
ファイル: proyecto_beta.php プロジェクト: nicoworq/pgame
<?php

include_once '../php/Pascal.php';
$pg = new Pascal();
$participantes = $pg->getRankingBackend();
?>

<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Pascal Navidad</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="apple-touch-icon" href="apple-touch-icon.png">

        <link rel="stylesheet" href="css/bootstrap.min.css">
        <style>
            body {
                padding-top: 50px;
                padding-bottom: 20px;
            }
        </style>
        <link rel="stylesheet" href="css/bootstrap-theme.min.css">
        <link rel="stylesheet" href="css/main.css">

        <script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
コード例 #7
0
        return $this->data[$index];
    }
    public function set($index, $value)
    {
        $this->data[$index] = $value;
    }
}
class Pascal
{
    public function getRow($n)
    {
        if ($n == 1) {
            return new Row(array(1));
        }
        $thePreviousRow = $this->getRow($n - 1);
        $theRow = new Row();
        for ($i = 0; $i < $n; $i++) {
            $theRow->set($i, $thePreviousRow->get($i - 1) + $thePreviousRow->get($i));
        }
        return $theRow;
    }
}
$pascal = new Pascal();
foreach (file($argv[1]) as $line) {
    $numRow = trim($line);
    $result = array();
    for ($i = 1; $i <= $numRow; $i++) {
        $result = array_merge($result, $pascal->getRow($i)->data);
    }
    echo implode(" ", $result) . "\n";
}