The script of the BTC cryptocurrency converter

<?php

    $summ = !empty($_POST['summ'])?$_POST['summ']:NULL;
    $content = !empty($_POST['content'])?$_POST['content']:NULL;
    $currency = !empty($_POST['currency'])?$_POST['currency']:NULL;
    
  if(isset($_POST['ok']))
  {


// we output the paired text.

    switch($currency)
    {
        case 'btc': 
        echo '<p>'. $summ .' USD corresponds to '. $summ * 0.00014 .' BTC</p>'; 
        break;
        
        case 'dollar': 
        echo '<p>'. $summ .' The dollar corresponds to '. $summ * $content .' руб</p>'; 
        break;
        
        case 'pound': 
        echo '<p>'. $summ .' The pound corresponds to '. $summ * 27.60 .' руб</p>'; 
        break;
        
        default:
        echo  'Enter the amount';
    }
  }
?>

<?php

//where will we parse the information from
 $content = file_get_contents('https://ru.ratesviewer.com/chart/usd-btc/year/');

// We determine the position of the line to which everything needs to be cut off
 $pos = strpos($content, '<div class="value">');

//We cut off everything that goes to the position we need
 $content = substr($content, $pos);

// In exactly the same way, we find the position of the final line
 $pos = strpos($content, '<div class="change">');

// We cut off the required number of characters from zero
 $content = substr($content, 0, $pos);

//if there is a text in the text that we don't need, we cut it out
 $content = str_replace('<div class="value"><div class="flag alt" style="background-position:-560px -64px"></div>','', $content);

 $content = str_replace('BTC','', $content);
  $content = str_replace('</div>','', $content);
  $content = str_replace(' ','', $content);

// we output the paired text.
//echo $content;


 ?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<select size="1" name="currency">
<option value="btc">btc</option>
<option value="dollar">dollar</option>
<option value="pound">pound</option>
</select>
<p><b>Сумма</b></p>
<input type="hidden" name="content" size="20" value="<?php echo $content;?>" />
<input type="text" name="summ" size="20" value="<?php echo (int)$summ;?>" />
<input type="submit" name="ok" />
</form>

Check Also

CashWars roulette script

CashWars roulette script

CashWars roulette script Password is the word password ➜ [ᴠɪᴘ] ᴅᴏᴡɴʟᴏᴀᴅ ᴅᴏᴡɴʟᴏᴀᴅ ɪs ᴀᴠᴀɪʟᴀʙʟᴇ ꜰᴏʀ …

Leave a Reply

Your email address will not be published. Required fields are marked *