Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, September 28, 2017

Coinhive: Capcha Example: Using PHP

<html>
<head></head>
<body>
<div>
<?php
if(isset($_POST["coinhive-captcha-token"])){
        $token = $_POST["coinhive-captcha-token"];
        $secret = 'bAbbbb5A9AbA0bbbA3bAAbAb8bAbAAAb';
        $url = 'https://api.coinhive.com/token/verify';

        $data = array('token'=> $token,
                      'hashes' => 1024,
                      'secret' => $secret);

        $options = array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',
                'content' => http_build_query($data)
        );
     
        $context  = stream_context_create(array('http' => $options));

        $response = json_decode(file_get_contents($url, false, $context));

        if ($result === FALSE) {
                echo "Error";
                exit;
        }
     
        $responseSuccess = $response->success;
}
?>
<?php if ($responseSuccess){ ?>
Verified<br/>
<?php } else { ?>
You must verify
<form action="?" method="post">
        <!-- other form fields -->

        <script src="https://coinhive.com/lib/captcha.min.js" async></script>
        <div class="coinhive-captcha" data-hashes="1024" data-key="AAAbAA33bAAbAbbAbAA4bA7dA4AAbA7b"></div>

        <input type="submit" value="Submit"/>
</form>
<?php } ?>
</div>
</body>
</html>

Thursday, September 21, 2017

Javascript: Prime Number Generator

HTML/Javascript Code:

<html><head>
<meta name="viewport" content="width=device-width">
<script>
var d=document;
var primes=[];

function Prime(){
   for (var i=2; i<=2000000;i++){
      if (this.check(i, primes)){
         primes.push(i);
         d.write(i+" ");
      }
   }
}

Prime.prototype.check=function(i, primes){
   var isOdd=i%2;
   var isPrime=true;
   var n=2;

   if(i==2 || isOdd){
      var to=Math.floor(i/2);

      if (primes.length>0){
         for (var j=0;j<primes.length; j++){
            n=primes[j];
            if(n>to){
               break;
            }
            if(i%n==0){
               isPrime=false;
               break;
            }
         }
      }

      for(;n<=to;n++){
         if(i%n==0){
            isPrime=false;
            break;
         }
      }
   } else {
      isPrime=false;
   }

   return isPrime;
}

function main(){
   var p=new Prime();
}
</script>
</head>
<body onload="main()">default</body>
</html>


Web Inspector:

23.51s



Thursday, April 28, 2016

David Brailsford: HTML: Poison or Panacea?

David Brailsford


  • Portable Document Format (PDF)
  • Tim Berners-Lee (ティム・バーナーズ=リー)
  • Overlapping markup
  • Standard Generalized Markup Language (SGML)
  • Document type definition (DTD)