Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

109 Zeilen
2.8 KiB

<?php
// ---
// --- La config globale
// ---
chdir('/opt/TOPISTO/apps');
require_once '/opt/TOPISTO/apps/global/inc/config.php';
// ---
// --- External dependances
// ---
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
// ---
// --- Internal dependances
// ---
require_once APP_PATH.'/blockchain/inc/block.php';
// ---
// --- Par défaut on cherche le dernier block
// ---
$block_hash = '*';
$methode='hasard';
$mode=9999;
// ---
// --- Le cas échéant, on cherche block passé en argument
// ---
if (isset($_REQUEST['hash']))    $block_hash = $_REQUEST['hash'];
if (isset($_REQUEST['methode'])) $methode    = $_REQUEST['methode'];
if (isset($_REQUEST['mode']))    $mode       = intval($_REQUEST['mode']);
//$methode = str_replace('full_', '', $methode);
$img = null;
$imagefilename = DATA_PATH.'/'.$methode.'/'.$block_hash.'-'.$mode.'.png';
echo $imagefilename;
if (file_exists($imagefilename)) echo ' <font color="green">OK</font><br>'.PHP_EOL;
else echo ' <font color="red">KO</font><br>'.PHP_EOL;
//
// "strict" est un flag qui indique que l'on veut précisément
//             ce que les paramètres demandent
//
if (($img==null)&&(!isset($_REQUEST['strict'])))
{  
  //
  // On n'a pas passé de HASH
  // 
  if (($img==null)&&(!isset($_REQUEST['hash'])))
  {
    //
    // On prend le dernier connu pour la méthode et le mode
    // 
    $myarray = glob(DATA_PATH.'/'.$methode.'/*-'.$mode.'.png');
    if (isset($myarray[0]))
    {
      usort( $myarray, function( $a, $b ) { return filemtime($a) - filemtime($b); } );
      echo $myarray[0].' <font color="green">OK</font><br>'.PHP_EOL;
      $img=true;
    }
    //
    // On prend le dernier connu pour la méthode tout mode confondu
    // 
    if ($img==null)
    {
      $myarray = glob(DATA_PATH.'/'.$methode.'/*.png');
      if (isset($myarray[0]))
      {
        usort( $myarray, function( $a, $b ) { return filemtime($a) - filemtime($b); } );
        echo $myarray[0].' <font color="green">OK</font><br>'.PHP_EOL;
        $img=true;
      }
    }
  }
  //
  // On a passé un HASH
  //
  if (($img==null)&&(isset($_REQUEST['hash'])))
  {
    //
    // On cherche le bon HASH et la bonne méthode
    //
    $imagefilename = DATA_PATH.'/'.$methode.'/'.$block_hash.'.png';
    if (($img==null)&&(file_exists($imagefilename)))
    {
      echo $imagefilename.' <font color="green">OK</font><br>'.PHP_EOL;
      $img=true;
    }
    //
    // En fait on s'en fiche de la méthode tant qu'on a le bon HASH
    //
    $imagefilename = DATA_PATH.'/hasard/'.$block_hash.'.png';
    if (($img==null)&&(file_exists($imagefilename)))
    {
      echo $imagefilename.' <font color="green">OK</font><br>'.PHP_EOL;
      $img=true;
    }
  }  
}
//
// On n'a rien trouvé, donc on dessine ce qui est demandé
//
if ($img==null) echo '<font color="red">KO</font><br>';
?>