Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Deivid Santos

Binário para Hexadecimais

Recommended Posts

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>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por Rafael_Ferreira
      Não consigo carregar a imagem do captcha do meu formulário. Foi testado com o xampp e easyphp. Também não carregou a imagem de outros captcha. 
       
       
    • Por luiz monteiro
      Olá, tudo bem?
       
      Estou melhorando meu conhecimento em php e mysql e, me deparei com o seguinte. A tabela da base de dados tem um campo do tipo varchar(8) o qual armazena números. Eu não posso alterar o tipo desse campo. O que preciso é fazer um select para retornar o números que contenham zeros a direita ou a esquerda.
      O que tentei até agora
       
      Ex1
      $busca = $conexao->prepare("select campo form tabela where (campo = :campo) ");
      $busca->bindParam('campo', $_REQUEST['campo_form']);
       
      Se a direita da string $_REQUEST['campo_form'] termina ou inicia com zero ou zeros, a busca retorna vazio.
      Inseri dados numéricos, da seguinte maneira para testar: 01234567;  12345670: 12345678: 12340000... entre outros nessa coluna. Todos os valores que não terminam ou não iniciam com zero ou zeros, o select funciona.
       
       
      Ex2
      $busca = $conexao->prepare("select campo form tabela where (campo = 0340000) ");
      Esse número está cadastrado, mas não retorna.
       
      Ex3
      $busca = $conexao->prepare("select campo form tabela where (campo = '02340001' ) ");
      Esse número está cadastrado, mas não retorna.
       
       
      Ex4
      $busca = $conexao->prepare("select campo form tabela where (campo like 2340000) ");
      Esse número está cadastrado, mas não retorna.
       
      Ex5
      $busca = $conexao->prepare("select campo form tabela where (campo like '12340000') ");
      Esse número está cadastrado, mas não retorna.
       
      Ex6
      $busca = $conexao->prepare("select campo form tabela where (campo like '"12340000"' ) ");
      Esse número está cadastrado, mas não retorna.
       
       
      Ex7
      $busca = $conexao->prepare("select campo form tabela where (campo like :campo) ");
      $busca->bindParam('campo', $_REQUEST['campo_form'])
      Não retorna dados.
       
      O  $_REQUEST['campo_form'] é envio via AJAX de um formulário. 
      Usei o gettype para verificar o post, e ele retorna string.
      Fiz uma busca com número 12345678 para verificar o que o select retorna, e também retrona como string.
       
      Esse tipo de varchar foi usado porque os números que serão gravados nesse campo,  terão zeros a direita ou na esquerda. Os tipos number do mysql não gravam zeros, então estou usando esse. O problema é a busca.
      Agradeço desde já.
       
       
    • Por daemon
      Boa tarde,
       
      Eu tenho uma rotina que faz uma leitura do arquivo .xml de vários sites.

      Eu consigo pegar o tópico e a descrição, e mostrar a imagem que esta na pagina do link.
      Para isso utilizo esta função:
      function getPreviewImage($url) { // Obter o conteúdo da página $html = file_get_contents($url); // Criar um novo objeto DOMDocument $doc = new DOMDocument(); @$doc->loadHTML($html); // Procurar pela tag meta og:image $tags = $doc->getElementsByTagName('meta'); foreach ($tags as $tag) { if ($tag->getAttribute('property') == 'og:image') { return $tag->getAttribute('content'); } } // Se não encontrar og:image, procurar pela primeira imagem na página $tags = $doc->getElementsByTagName('img'); if ($tags->length > 0) { return $tags->item(0)->getAttribute('src'); } // Se não encontrar nenhuma imagem, retornar null return null; } // Uso: $url = "https://example.com/article"; $imageUrl = getPreviewImage($url); if ($imageUrl) { echo "<img src='$imageUrl' alt='Preview'>"; } else { echo "Nenhuma imagem encontrada"; }  
      Mas estou com um problema, esta funcão funciona quando coloco em uma pagina de teste.php. Preciso mostrar em uma página inicial diversas fotos de todos os links. (No caso acima só funciona 1).
    • Por violin101
      Caros amigos, saudações.
       
      Por favor, me permita tirar uma dúvida com os amigos.

      Tenho um Formulário onde o Usuário digita todos os Dados necessários.

      Minha dúvida:
      --> como faço após o usuário digitar os dados e salvar, o Sistema chamar uma Modal ou mensagem perguntando se deseja imprimir agora ?

      Grato,
       
      Cesar
    • Por Carcleo
      Tenho uma abela de usuarios e uma tabela de administradores e clientes.
      Gostaria de uma ajuda para implementar um cadastro
       
      users -> name, login, passord (pronta) admins -> user_id, registratiom, etc.. client -> user_id, registratiom, etc...
      Queria ajuda para extender de user as classes Admin e Client
      Olhem como estáAdmin
      <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Admin extends User {     use HasFactory;            protected $fillable = [         'name',         'email',         'password',         'registration'     ];      private string $registration;     public function create(         string $name,          string $email,          string $password,         string $registration     )     {         //parent::create(['name'=>$name, 'email'=>$email, 'password'=>$password]);         parent::$name = $name;         parent::$email = $email;         parent::$password = $password;         $this->registration = $registration;     } } User
      <?php namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Illuminate\Database\Eloquent\Relations\BelongsToMany; class User extends Authenticatable {     /** @use HasFactory<\Database\Factories\UserFactory> */     use HasFactory, Notifiable;     static string $name;     static string $email;     static string $password;     /**      * The attributes that are mass assignable.      *      * @var list<string>      */     protected $fillable = [         'name',         'email',         'password',     ];          /**      * The attributes that should be hidden for serialization.      *      * @var list<string>      */     protected $hidden = [         'remember_token',     ];     /**      * Get the attributes that should be cast.      *      * @return array<string, string>      */     protected function casts(): array     {         return [             'email_verified_at' => 'datetime',             'password' => 'hashed',         ];     }          public function roles() : BelongsToMany {         return $this->belongsToMany(Role::class);     }       public function hasHole(Array $roleName): bool     {                 foreach ($this->roles as $role) {             if ($role->name === $roleName) {                 return true;             }         }         return false;     }         public function hasHoles(Array $rolesName): bool     {                 foreach ($this->roles as $role) {             foreach ($rolesName as $rolee) {             if ($role->name === $rolee) {                 return true;             }          }         }         return false;     }         public function hasAbility(string $ability): bool     {         foreach ($this->roles as $role) {             if ($role->abilities->contains('name', $ability)) {                 return true;             }         }         return false;     }     } Como gravar um Admin na tabela admins sendo que ele é um User por extensão?
      Tentei assim mas é claro que está errado...
      public function store(Request $request, Admin $adminModel) {         $dados = $request->validate([             "name" => "required",             "email" => "required|email",             "password" => "required",             "registration" => "required"         ]);         $dados["password"] =  Hash::make($dados["password"]);                  $admin = Admin::where("registration",  $dados["registration"])->first();                  if ($admin)              return                    redirect()->route("admin.new")                             ->withErrors([                                 'fail' => 'Administrador já cadastrados<br>, favor verificar!'                   ]);                            $newAdmin = $adminModel->create(                                    $dados['name'],                                    $dados['email'],                                    $dados['password'],                                    $dados['registration']                                 );         dd($newAdmin);         $adminModel->save();         //$adminModel::create($admin);                  return redirect()->route("admin.new")->with("success",'Cadastrado com sucesso');     }  
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.