This commit is contained in:
OMGiTzPomPom 2022-11-18 10:58:35 +01:00
parent a655ebe44d
commit 21d6c67985
9 changed files with 262 additions and 0 deletions

Binary file not shown.

18
TD/TD3/a.php Normal file
View File

@ -0,0 +1,18 @@
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://recettesiam9.cstb.fr/api-cours/users.php'
));
$resultsJson = curl_exec($curl);
curl_close($curl);
$results = json_decode($resultsJson);
foreach($results as $result){
echo '<ul>';
echo '<li>' . $result->firstname . ' ' . $result->lastname . '</li>';
echo '</ul>';
}

17
TD/TD3/b.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$curl = curl_init();
$pauline = hash('sha256', 'srifi');
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/test-user.php?user=$pauline"
));
$resultsJson = curl_exec($curl);
curl_close($curl);
$results = json_decode($resultsJson);
print_r($results);

30
TD/TD3/c.php Normal file
View File

@ -0,0 +1,30 @@
<?php
$pauline = hash('sha256', 'srifi');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-hash.php?file=applejack.txt"
));
$ret = curl_exec($curl);
$tab = json_decode($ret);
$file = $tab -> hash;
curl_close($curl);
$curl2 = curl_init();
curl_setopt_array($curl2, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-jeton.php?file=$file&user=$pauline"
));
$resultsJson = curl_exec($curl2);
curl_close($curl2);
$results = json_decode($resultsJson);
print_r($results);

30
TD/TD3/d.php Normal file
View File

@ -0,0 +1,30 @@
<?php
$pauline = hash('sha256', 'srifi');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-hash.php?file=applejack.txt"
));
$ret = curl_exec($curl);
$tab = json_decode($ret);
$file = $tab -> hash;
curl_close($curl);
$curl2 = curl_init();
curl_setopt_array($curl2, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-journal.php?file=$file"
));
$resultsJson = curl_exec($curl2);
curl_close($curl2);
$results = json_decode($resultsJson);
print_r($results);

30
TD/TD3/e.php Normal file
View File

@ -0,0 +1,30 @@
<?php
$pauline = hash('sha256', 'srifi');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-hash.php?file=applejack.txt"
));
$ret = curl_exec($curl);
$tab = json_decode($ret);
$file = $tab -> hash;
curl_close($curl);
$curl2 = curl_init();
curl_setopt_array($curl2, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/update-jeton.php?file=$file&user=$pauline"
));
$resultsJson = curl_exec($curl2);
curl_close($curl2);
$results = json_decode($resultsJson);
print_r($results);

76
TD/TD3/f.php Normal file
View File

@ -0,0 +1,76 @@
<?php
$pauline = hash('sha256', 'srifi');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-hash.php?file=applejack.txt"
));
$ret = curl_exec($curl);
$tab = json_decode($ret);
$file = $tab -> hash;
curl_close($curl);
$curl2 = curl_init();
curl_setopt_array($curl2, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-journal.php?file=$file"
));
$resultsJson = curl_exec($curl2);
curl_close($curl2);
$results = json_decode($resultsJson);
?>
<html>
<style>
.demo {
width:100%;
border:1px solide #C0C0C0;
border-collapse:effondrer;
padding:5px;
}
.demo th {
border:1px solide #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.demo td {
border:1px solide #C0C0C0;
padding:5px;
}
</style>
<?php
foreach($results->journal as $r){
echo '<table class="demo">';
echo '<thead>';
echo '<tr>';
echo '<th>File_id</th>';
echo '<th>Date</th>';
echo '<th>Action</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
echo '<tr>';
echo '<td>' .$r->file_id .'</td>';
echo '<td>' .date('d/m/Y h:i:s', $r->time) .'</td>';
echo '<td>' .$r->action .'</td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
}
?>
</html>

61
TD/TD3/g.php Normal file
View File

@ -0,0 +1,61 @@
<?php
$pauline = hash('sha256', 'srifi');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "http://recettesiam9.cstb.fr/api-cours/get-journal-user.php?user=$pauline"
));
$resultsJson = curl_exec($curl);
curl_close($curl);
$results = json_decode($resultsJson);
?>
<html>
<style>
.demo {
width:100%;
border:1px solide #C0C0C0;
border-collapse:effondrer;
padding:5px;
}
.demo th {
border:1px solide #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.demo td {
border:1px solide #C0C0C0;
padding:5px;
}
</style>
<?php
foreach($results->journal as $r){
echo '<table class="demo">';
echo '<thead>';
echo '<tr>';
echo '<th>File_id</th>';
echo '<th>Date</th>';
echo '<th>Action</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
echo '<tr>';
echo '<td>' .$r->file_id .'</td>';
echo '<td>' .date('d/m/Y h:i:s', $r->time) .'</td>';
echo '<td>' .$r->action .'</td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
}
?>
</html>