PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Payam Khaninejad   License management class   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: main index
Class: License management class
Generate and validate license serial numbers
Author: By
Last change:
Date: 14 years ago
Size: 1,906 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<title>Licence</title>
</head>
<body>
<div id="res"></div>
<table width="200" border="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>ID :</td>
    <td><input type="text" id="id" /></td>
  </tr>
  <tr>
    <td>Serial :</td>
    <td><input type="text" id="serial" /></td>
  </tr>
</table>
<input type="button" id="validate" value="Validate" />

<script type="text/javascript">
$('#validate').click(function() {
  $.get("licence.php", { serial: $('#serial').val(), id: $('#id').val() },
   function(data){
     if(data==1)
     {
     $('div[id=res]').html("<p>Valid</p");
     }else{
     $('div[id=res]').html("Invalid");
     }
   });
});

</script><br />
<a href="generateSerials.php">Generate Serial</a>
<p>This page used to process licence operation in simple way like curl function or local way</p>
</body>
</html>


<?php
// local way
$serial="";
$num="";
require_once(
"licence.inc.php");
$mylicence=new licence;
if(
$mylicence->validate_my_licence($num,$serial)==0)
{
//echo "valid";
}
else
{
//echo "not valid";
}
// curl function
       
$ch = curl_init("http://127.0.0.1/licence/licence.php?serial=238W1W1W2-238W1W1W2-222323223&id=111212112");
       
curl_setopt($ch, CURLOPT_HEADER, 0);
       
curl_setopt($ch, CURLOPT_POST, 1);
       
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       
$output = curl_exec($ch);
       
curl_close($ch);
        if(
$output==1)
        {
           
//echo "valid serial";
       
}
        else
        {
           
//echo "invalid serial";
       
}
?>