Binário para Hexadecimais
Galera já procurei de tudo mas não está dando certo.
Vou postar um script que estou utilizando para conversão de binário para Hexadecimais, quase todas as consultas dão certas porém acredito que ainda exista alguma correção a ser feita. Alguem poderia me dar uma ajuda? Segue script.
<?php
error_reporting(0);
ini_set("display_errors", 0 );
?>
<html>
<head>
<meta name="viewport" content="width=480px,height=640px,inicial-scale=1" />
<meta name ="viewport" content="width=240px,inicial-scale=0.5" />
<meta name ="viewport" content="width=680px,user-scale=no" / >
<style type="text/css">
strong {
color: #F00;
}
</style>
<style type="text/css">
<!--
.style4 {color: #FF0000; font-weight: bold; }
-->
</style>
<style type="text/css">
body {
background-color: #ECECEC;
}
strong {
color: #F00;
}
c {color: #262121; font-weight: bold; padding: 11px;font: bold 11px/20px Arial, Helvetica;}
k {color: #262121; font-weight: bold; padding: 22px;font: bold 20px/20px Arial, Helvetica;}
kt {color: #FF4000; font-weight: bold; padding: 40px;font: bold 40px/40px Arial, Helvetica;}
</style>
</head>
<body id="page2">
<!-- header -->
<time datetime="2011-06-07" class="tdate-2 indent-bot"></time>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-8">
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
//troca fundo de linhas pares
$('table#dg body tr:even').css('background','#FFFF99');
//troca fundo de linhas impares
$('table#dg body tr:odd').css('background','#FFFFCC');
});
</script>
<script>
var form = document.getElementById('binario');
form.reset();</script>
<style type="text/css">
thead tr th {
text-align:center;
border-bottom:solid 2px #000000;
border-left:solid 2px #000000;
}
tr td, tr th {
border:dotted 1px #999999;
}
tfoot tr td {
text-align:center;
border-top:solid 2px #000000;
}.cor{background:red;}
.cor_{background:gold;}
input[type=checkbox] {
display:none;
}input[type=checkbox] + label {
background-size:cover;
background-position:center;
background-repeat: no-repeat;
height: 30px;
width: 30px;
display:inline-block;
}input#input_1_0 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_0:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_1 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_1:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_2 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_2:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_3 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_3:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_4 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_4:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_5 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_5:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_6 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_6:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_7 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_7:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_8 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_8:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_9 + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_9:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_a + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_a:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_b + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_b:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_c + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_c:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_d + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_d:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_e + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_e:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
input#input_1_f + label {
background-image: url('hexa_image/imagen_green.png');
}input#input_1_f:checked + label {
background-image: url('hexa_image/imagen_black.png');
}
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
table.comBordaSimples {
border-collapse: collapse; /* CSS2 */
}
table.comBordaSimples td {
border: 1px solid black;
}
table.comBordaSimples th {
border: 1px solid black;
}
</style>
</head>
<?php
if(isset($_POST['cbox0'])) {
$cbox0 = $_POST['cbox0'] ;
$cbox0 = '1';
$checkbox0 = 'checked';
}else {
$cbox0 = $_POST['cbox0'] ;
$cbox0 = '0';
}
if(isset($_POST['cbox1'])) {
$cbox1 = $_POST['cbox1'] ;
$cbox1 = '1';
$checkbox1 = 'checked';
}else {
$cbox1 = $_POST['cbox1'] ;
$cbox1 = '0';
}
if(isset($_POST['cbox2'])) {
$cbox2 = $_POST['cbox2'] ;
$cbox2 = '1';
$checkbox2 = 'checked';
}else {
$cbox2 = $_POST['cbox2'] ;
$cbox2= '0';
}
if(isset($_POST['cbox3'])) {
$cbox3 = $_POST['cbox3'] ;
$cbox3 = '1';
$checkbox3 = 'checked';
}else {
$cbox3 = $_POST['cbox3'] ;
$cbox3= '0';
}
if(isset($_POST['cbox4'])) {
$cbox4 = $_POST['cbox4'] ;
$cbox4 = '1';
$checkbox4 = 'checked';
}else {
$cbox4 = $_POST['cbox4'] ;
$cbox4= '0';
}
if(isset($_POST['cbox5'])) {
$cbox5 = $_POST['cbox5'] ;
$cbox5 = '1';
$checkbox5 = 'checked';
}else {
$cbox5 = $_POST['cbox5'] ;
$cbox5= '0';
}
if(isset($_POST['cbox6'])) {
$cbox6 = $_POST['cbox6'] ;
$cbox6 = '1';
$checkbox6 = 'checked';
}else {
$cbox6 = $_POST['cbox6'] ;
$cbox6= '0';
}
if(isset($_POST['cbox7'])) {
$cbox7 = $_POST['cbox7'] ;
$cbox7= '1';
$checkbox7 = 'checked';
}else {
$cbox7 = $_POST['cbox7'] ;
$cbox7= '0';
}
if(isset($_POST['cbox8'])) {
$cbox8 = $_POST['cbox8'] ;
$cbox8= '1';
$checkbox8 = 'checked';
}else {
$cbox8 = $_POST['cbox8'] ;
$cbox8= '0';
}
if(isset($_POST['cbox9'])) {
$cbox9 = $_POST['cbox9'] ;
$cbox9 = '1';
$checkbox9 = 'checked';
}else {
$cbox9 = $_POST['cbox9'] ;
$cbox9= '0';
}
if(isset($_POST['cboxa'])) {
$cboxa= $_POST['cboxa'] ;
$cboxa = '1';
$checkboxa = 'checked';
}else {
$cboxa = $_POST['cboxa'] ;
$cboxa= '0';
}
if(isset($_POST['cboxb'])) {
$cboxb= $_POST['cboxb'] ;
$cboxb = '1';
$checkboxb = 'checked';
}else {
$cboxb = $_POST['cboxb'] ;
$cboxb= '0';
}
if(isset($_POST['cboxc'])) {
$cboxc = $_POST['cboxc'] ;
$cboxc = '1';
$checkboxc = 'checked';
}else {
$cboxc = $_POST['cboxc'] ;
$cboxc= '0';
}
if(isset($_POST['cboxd'])){
$cboxd = $_POST['cboxd'] ;
$cboxd = '1';
$checkboxd = 'checked';
}else {
$cboxd = $_POST['cboxd'] ;
$cboxd= '0';
}
if(isset($_POST['cboxe'])) {
$cboxe = $_POST['cboxe'] ;
$cboxe = '1';
$checkboxe = 'checked';
}else {
$cboxe = $_POST['cboxe'] ;
$cboxe= '0';
}
if(isset($_POST['cboxf'])) {
$cboxf = $_POST['cboxf'] ;
$cboxf = '1';
$checkboxf = 'checked';
}else {
$cboxf = $_POST['cboxf'] ;
$cboxf= '0';
}
?>
<body>
<table width="200" height="195" class="combordasimples">
<tbody>
<tr>
<td><form id="binario" name="binario" method="POST" action="">
<input type='checkbox' name='cboxf' <?=$checkboxf?> id="input_1_f"/>
<label for="input_1_f"> </label>
<br>
<input type='checkbox' name='cboxe' <?=$checkboxe?> id="input_1_e"/>
<label for="input_1_e"></label>
<br>
<input type='checkbox' name='cboxd' <?=$checkboxd?> id="input_1_d"/>
<label for="input_1_d"></label>
<br>
<input type='checkbox' name='cboxc' <?=$checkboxc?> id="input_1_c"/>
<label for="input_1_c"></label>
<br>
<input type='checkbox' name='cboxb' <?=$checkboxb?> id="input_1_b"/>
<label for="input_1_b"></label>
<br>
<input type='checkbox' name='cboxa' <?=$checkboxa?> id="input_1_a"/>
<label for="input_1_a"></label>
<br>
<input type='checkbox' name='cbox9' <?=$checkbox9?> id="input_1_9"/>
<label for="input_1_9"></label>
<br>
<input type='checkbox' name='cbox8' <?=$checkbox8?> id="input_1_8"/>
<label for="input_1_8"></label>
<br>
<input type='checkbox' name='cbox7' <?=$checkbox7?> id="input_1_7"/>
<label for="input_1_7"></label>
<br>
<input type='checkbox' name='cbox6' <?=$checkbox6?> id="input_1_6"/>
<label for="input_1_6"></label>
<br>
<input type='checkbox' name='cbox5' <?=$checkbox5?> id="input_1_5"/>
<label for="input_1_5"></label>
<br>
<input type='checkbox' name='cbox4' <?=$checkbox4?> id="input_1_4"/>
<label for="input_1_4"></label>
<br>
<input type='checkbox' name='cbox3' <?=$checkbox3?> id="input_1_3"/>
<label for="input_1_3"></label>
<br>
<input type='checkbox' name='cbox2' <?=$checkbox2?> id="input_1_2"/>
<label for="input_1_2"></label>
<br>
<input type='checkbox' name='cbox1' <?=$checkbox1?> id="input_1_1"/>
<label for="input_1_1"></label>
<br>
<input type='checkbox' name='cbox0' <?=$checkbox0?> id="input_1_0"/>
<label for="input_1_0"></label>
<br>
<a href="index.php"><button><img src="hexa_image/converter.png" /></button></a>
</form>
<a href="index.php"><button><img src="hexa_image/limparconsulta.png" /></button></a>
</td>
<td><?
$binary = "$cbox0$cbox1$cbox2$cbox3$cbox4$cbox5$cbox6$cbox7$cbox8$cbox9$cboxa$cboxb$cboxc$cboxd$cboxe$cboxf";
$binary1 = ltrim($binary,0);
$hex = dechex(bindec($binary1));
echo "<h3 align='center'><kt>" .$hex."<kt></h3>";
?>
</td>
</tr>
</tbody>
</table>
</body>
</html>Discussão (0)
Carregando comentários...