Advertisement
cong88

Untitled

Aug 18th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.46 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="UTF-8">
  5.         <title>E-Learning | Tambah Data Operator</title>
  6.         <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
  7.         <!-- bootstrap 3.0.2 -->
  8.         <link href="http://localhost/e-learning/c-panel/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  9.         <!-- font Awesome -->
  10.         <link href="http://localhost/e-learning/c-panel/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
  11.         <!-- Ionicons -->
  12.         <link href="http://localhost/e-learning/c-panel/css/ionicons.min.css" rel="stylesheet" type="text/css" />
  13.         <!-- Theme style -->
  14.         <link href="http://localhost/e-learning/c-panel/css/AdminLTE.css" rel="stylesheet" type="text/css" />
  15.         <link href="http://localhost/e-learning/c-panel/css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
  16.     </head>
  17.     <body class="skin-blue">
  18.         <!-- header logo: style can be found in header.less -->
  19.         <?php
  20.             $droot = $_SERVER['DOCUMENT_ROOT'];
  21.             include $droot.'/e-learning/c-panel/include/header.php';
  22.             include $droot.'/e-learning/c-panel/include/ind-date.php';
  23.  
  24.             $msg = "";
  25.             $hashOrigi = '';
  26.             $hashDeff = '';
  27.             if(isset($_POST['btn_simpan']))
  28.             {
  29.                 $origi = preg_replace("/[^a-zA-Z 0-9]+/", "", str_replace(" ", "", strtolower($_POST['txt_in_original'])));
  30.                 $deff = preg_replace("/[^a-zA-Z 0-9]+/", "", str_replace(" ", "", strtolower($_POST['txt_in_deffrent'])));
  31.                 $gram = $_POST['cmb_gram'];
  32.                 $bsis = $_POST['cmb_basis'];
  33.                 $win = $_POST['cmb_window'];
  34.                 #k-gram
  35.                $k_gram_origi = k_gram($origi, $gram);
  36.                 $k_gram_deff = k_gram($deff, $gram);
  37.                 #rolling-hash
  38.                $rlhOrigi = hashing($origi, $gram, $bsis);
  39.                 $rlhDeff = hashing($deff, $gram, $bsis);
  40.                 #window
  41.                $windOrigi = window($rlhOrigi, $win);
  42.                 $windDeff = window($rlhDeff, $win);
  43.                
  44.             }
  45.  
  46.             #K-gram
  47.            function k_gram($text, $gram)
  48.             {
  49.                 $char = "";
  50.                 $i = 0;
  51.                 $strlen = strlen($text);
  52.                 while($i <= $strlen - $gram)
  53.                 {
  54.                     $char .= substr($text, $i, $gram).' ';
  55.                     $i++;
  56.                 }
  57.                 return $char;
  58.             }
  59.  
  60.             #rolling Hash
  61.            function rHash($text, $basis)
  62.             {
  63.                 $hash_value = 0;
  64.                 $prev_hash = 0;
  65.                 $c_awal = 0;
  66.                 $length = strlen($text)- 1;
  67.                 if($prev_hash == 0)
  68.                 {
  69.                     for($i = 0; $i <= $length; $i++)
  70.                     {
  71.                         $ascii = ord(substr($text, $i, 1));
  72.                         $hash_value += $ascii * pow($basis, $length - $i);
  73.                     }
  74.                 }else
  75.                     {
  76.                         $hash_value = $prev_hash - $c_awal * pow($basis, $length);
  77.                         $hash_value *= $basis;
  78.                         $hash_value += substr($text, $i, 1);
  79.                     }
  80.                 $c_awal = ord(substr($text, 0, 1));
  81.                 $prev_hash = $hash_value;
  82.                 return $hash_value." ";
  83.             }
  84.  
  85.             function hashing($text, $gram, $basis)
  86.             {
  87.                 $i = 0;
  88.                 $rolling_has = "";
  89.                 $strlen = strlen($text);
  90.                 while($i <= $strlen - $gram)
  91.                 {
  92.                     $char = substr($text, $i,$gram);
  93.                     $rolling_has .= rHash($char, $basis);
  94.                     $i++;
  95.                 }
  96.                 return $rolling_has;
  97.             }
  98.  
  99.             #window
  100.            function window($text, $window){
  101.                 $wind = "";
  102.                 $data=explode(' ',$text);
  103.                 $m=count($data) - $window -1;
  104.                 for($i = 0; $i <= $m; $i++)
  105.                 {
  106.                     $s=array();
  107.                     for($j = 0; $j < $window; $j++)
  108.                         $s[] = $data[$i+$j];
  109.                         $wind .= "{".implode(' ',$s)."}<br>";
  110.                 }
  111.                 return $wind;
  112.             }
  113.  
  114.             function fingerprint($text, $window){
  115.                 $temp = [];
  116.                 $data = [];
  117.                 $pieces = explode(" ", $text);
  118.                 $m = count($pieces) - $window;
  119.                 for ($i=0; $i <= $m; $i++) {
  120.                     $s = array();
  121.                     for($j = 0; $j < $window -1; $j++)
  122.                         $s[]=$pieces[$i+$j];
  123.                     // if (count($s) > 0) {
  124.                     //     $min_hash = min($s);
  125.                     //     $min_index = $i;
  126.                        
  127.                     //     echo "[".$min_hash.",".$min_index."]";
  128.                     // }
  129.                      
  130.                 }
  131.                 foreach ($s as $key => $value) {
  132.                     $explode = explode(',', $value);
  133.                  
  134.                     $current = current($explode);
  135.                     $end = end($explode);
  136.                  
  137.                     $temp[$current][] = $end;
  138.                 }
  139.                  
  140.                 foreach ($temp as $key => $value) {
  141.                     $data[] = $key . ',' . end($value);
  142.                 }
  143.                  
  144.                 echo '<pre>' .  print_r($data, true) . '</pre>';
  145.             }
  146.         ?>
  147.         <div class="wrapper row-offcanvas row-offcanvas-left">
  148.             <!-- Left side column. contains the logo and sidebar -->
  149.             <!-- Right side column. Contains the navbar and content of the page -->
  150.             <aside class="right-side">
  151.                 <!-- Content Header (Page header) -->
  152.                 <section class="content-header">
  153.                     <h1>
  154.                         Pilihan Ganda
  155.                         <small>Tambah Data</small>
  156.                     </h1>
  157.                     <ol class="breadcrumb">
  158.                         <li><a href="http://localhost/e-learning/c-panel/index.php"><i class="fa fa-dashboard"></i> E-Learning</a></li>
  159.                         <li><a href="#">Manajemen Soal</a></li>
  160.                         <li class="active">Tambah Data Pilihan Ganda</li>
  161.                     </ol>
  162.                 </section>
  163.  
  164.                 <!-- Main content -->
  165.                 <section class="content">
  166.                     <div class="row">
  167.                         <form action="" method="post" enctype="multipart/form-data">
  168.                             <div class="col-md-10">
  169.                                 <div class="box box-primary">
  170.                                     <div class="box-header">
  171.                                         <h3 class="box-title">Standart Text</h3>
  172.                                     </div>
  173.                                     <div class="box-body">
  174.                                         <table width="100%">
  175.                                             <tr>
  176.                                                 <td>
  177.                                                     <label>Original Text</label>
  178.                                                     <textarea name="txt_in_original" class="textarea" placeholder="Original Text" style="width: 100%; height: 100px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"><?php echo isset($_POST['txt_in_original']) ? $_POST['txt_in_original'] : "";?></textarea>
  179.                                                 </td>
  180.                                                 <td>
  181.                                                     <label>Defferent Text</label>
  182.                                                     <textarea name="txt_in_deffrent" class="textarea" placeholder="Defferent Text" style="width: 100%; height: 100px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"><?php echo isset($_POST['txt_in_deffrent']) ? $_POST['txt_in_deffrent'] : "";?></textarea>
  183.                                                 </td>
  184.                                             </tr>
  185.                                         </table>
  186.                                     </div>
  187.                                     <div class="box-header">
  188.                                         <h3 class="box-title">K-gram</h3>
  189.                                     </div>
  190.                                     <div class="box-body">
  191.                                         <table border="0" width="100%" style="table-layout:fixed;">
  192.                                             <tr>
  193.                                                 <td>
  194.                                                     <div class="callout callout-info">
  195.                                                         <h4>Original Text</h4>
  196.                                                         <?php
  197.                                                             if(isset($_POST['btn_simpan']))
  198.                                                             {
  199.                                                                 echo $k_gram_origi;
  200.                                                                
  201.                                                             }
  202.                                                          ?>
  203.                                                     </div>
  204.                                                 </td>
  205.                                                 <td>
  206.                                                     <div class="callout callout-info">
  207.                                                         <h4>Defferent Text</h4>
  208.                                                         <?php
  209.                                                             if(isset($_POST['btn_simpan']))
  210.                                                             {
  211.                                                                 echo $k_gram_deff;
  212.                                                             }
  213.                                                         ?>
  214.                                                     </div>
  215.                                                 </td>
  216.                                             </tr>
  217.                                         </table>
  218.                                     </div>
  219.                                     <div class="box-header">
  220.                                         <h3 class="box-title">Hashing</h3>
  221.                                     </div>
  222.                                     <div class="box-body">
  223.                                         <table width="100%" style="table-layout:fixed;">
  224.                                             <tr>
  225.                                                 <td>
  226.                                                     <div class="callout callout-info">
  227.                                                         <h4>Original Text</h4>
  228.                                                         <?php
  229.                                                             if(isset($_POST['btn_simpan']))
  230.                                                             {
  231.                                                                 echo $rlhOrigi;
  232.                                                                 #hashing($origi, $gram, $bsis);
  233.                                                            }
  234.                                                          ?>
  235.                                                     </div>
  236.                                                 </td>
  237.                                                 <td>
  238.                                                     <div class="callout callout-info">
  239.                                                         <h4>Original Text</h4>
  240.                                                         <?php
  241.                                                             if(isset($_POST['btn_simpan']))
  242.                                                             {
  243.                                                                 echo $rlhDeff;
  244.                                                                 #hashing($deff, $gram, $bsis);
  245.                                                            }
  246.                                                          ?>
  247.                                                     </div>
  248.                                                 </td>
  249.                                             </tr>
  250.                                         </table>
  251.                                     </div>
  252.                                     <div class="box-header">
  253.                                         <h3 class="box-title">Window</h3>
  254.                                     </div>
  255.                                     <div class="box-body">
  256.                                         <table width="100%" style="table-layout:fixed;">
  257.                                             <tr>
  258.                                                 <td>
  259.                                                     <div class="callout callout-info">
  260.                                                         <h4>Original Text</h4>
  261.                                                         <?php
  262.                                                             if(isset($_POST['btn_simpan']))
  263.                                                             {
  264.                                                                echo $windOrigi;
  265.                                                                 #window($rlhOrigi, $win);
  266.                                                            }
  267.                                                          ?>
  268.                                                     </div>
  269.                                                 </td>
  270.                                                 <td>
  271.                                                     <div class="callout callout-info">
  272.                                                         <h4>Original Text</h4>
  273.                                                         <?php
  274.                                                             if(isset($_POST['btn_simpan']))
  275.                                                             {
  276.                                                                 echo $windDeff;
  277.                                                                 #window($rlhDeff, $win);
  278.                                                            }
  279.                                                          ?>
  280.                                                     </div>
  281.                                                 </td>
  282.                                             </tr>
  283.                                         </table>
  284.                                     </div>
  285.                                     <div class="box-header">
  286.                                         <h3 class="box-title">Fingerprint</h3>
  287.                                     </div>
  288.                                     <div class="box-body">
  289.                                         <table width="100%" style="table-layout:fixed;">
  290.                                             <tr>
  291.                                                 <td>
  292.                                                     <div class="callout callout-info">
  293.                                                         <h4>Original Text</h4>
  294.                                                         <?php
  295.                                                             if(isset($_POST['btn_simpan']))
  296.                                                             {
  297.                                                                #echo $windOrigi;
  298.                                                                fingerprint($rlhOrigi, $win);
  299.                                                                 $temp = [];
  300.                                                                 $data = [];
  301.                                                                  
  302.                                                                
  303.                                                                 #echo count($windOrigi);
  304.                                                            }
  305.                                                          ?>
  306.                                                     </div>
  307.                                                 </td>
  308.                                                 <td>
  309.                                                     <div class="callout callout-info">
  310.                                                         <h4>Original Text</h4>
  311.                                                         <?php
  312.                                                             if(isset($_POST['btn_simpan']))
  313.                                                             {
  314.                                                                 #echo $windDeff;
  315.                                                                fingerprint($rlhDeff, $win);
  316.                                                             }
  317.                                                          ?>
  318.                                                     </div>
  319.                                                 </td>
  320.                                             </tr>
  321.                                         </table>
  322.                                     </div>
  323.                                 </div>
  324.                             </div>
  325.                             <div class="col-md-2">
  326.                                 <div class="box box-primary">
  327.                                     <div class="box-header">
  328.                                         <h3 class="box-title">Option</h3>
  329.                                     </div>
  330.                                     <div class="form-group">
  331.                                         <label>Basis</label>
  332.                                         <select class="form-control" name="cmb_basis">
  333.                                             <option value="<?php echo isset($_POST['cmb_basis']) ? $_POST['cmb_basis'] : '0';?>" ><?php echo isset($_POST['cmb_basis']) ? $_POST['cmb_basis'] : "0";?></option>
  334.                                             <?php
  335.                                                 for($i=1;$i<=100;$i++)
  336.                                                 {
  337.                                             ?>
  338.                                             <option value="<?php echo $i; ?>"> <?php echo $i; ?></option>
  339.                                             <?php
  340.                                                 }
  341.                                             ?>
  342.                                         </select>
  343.                                     </div>
  344.                                     <div class="form-group">
  345.                                         <label>Gram</label>
  346.                                         <select class="form-control" name="cmb_gram">
  347.                                             <option value="<?php echo isset($_POST['cmb_gram']) ? $_POST['cmb_gram'] : '0';?>"><?php echo isset($_POST['cmb_gram']) ? $_POST['cmb_gram'] : "0";?></option>
  348.                                             <?php
  349.                                                 for($i=1;$i<=100;$i++)
  350.                                                 {
  351.                                             ?>
  352.                                             <option value="<?php echo $i; ?>"> <?php echo $i; ?></option>
  353.                                             <?php
  354.                                                 }
  355.                                             ?>
  356.                                         </select>
  357.                                     </div>
  358.                                     <div class="form-group">
  359.                                         <label>Window</label>
  360.                                         <select class="form-control" name="cmb_window">
  361.                                             <option value="<?php echo isset($_POST['cmb_window']) ? $_POST['cmb_window'] : '0';?>"><?php echo isset($_POST['cmb_window']) ? $_POST['cmb_window'] : "0";?></option>
  362.                                             <?php
  363.                                                 for($i=1;$i<=100;$i++)
  364.                                                 {
  365.                                             ?>
  366.                                             <option value="<?php echo $i; ?>"> <?php echo $i; ?></option>
  367.                                             <?php
  368.                                                 }
  369.                                             ?>
  370.                                         </select>
  371.                                     </div>
  372.                                     <div class="box-footer">
  373.                                         <button type="submit" name="btn_simpan" class="btn btn-primary" data-toggle='tooltip' data-placement='auto' title='Simpan'><i class="fa fa-save"></i></button>
  374.                                         <button type="submit" name="btn_reset" class="btn btn-primary" data-toggle='tooltip' data-placement='auto' title='Reset'><i class="fa fa-refresh"></i></button>
  375.                                     </div>
  376.                                 </div>
  377.                             </div>
  378.                             <div class="col-md-2">
  379.                                 <div class="box box-primary">
  380.                                     <div class="box-header">
  381.                                         <h3 class="box-title">Result</h3>
  382.                                     </div>
  383.                                 </div>
  384.                             </div>
  385.                         </form>
  386.                     </div>
  387.                 </section>
  388.             </aside><!-- /.right-side -->
  389.         </div><!-- ./wrapper -->
  390.         <!-- jQuery 2.0.2 -->
  391.         <script src="http://localhost/e-learning/c-panel/js/jquery.min.js"></script>
  392.         <!-- Bootstrap -->
  393.         <script src="http://localhost/e-learning/c-panel/js/bootstrap.min.js" type="text/javascript"></script>
  394.         <!-- AdminLTE App -->
  395.         <script src="http://localhost/e-learning/c-panel/js/AdminLTE/app.js" type="text/javascript"></script>
  396.         <script src="http://localhost/e-learning/c-panel/js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
  397.         <script src="http://localhost/e-learning/c-panel/js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
  398.     </body>
  399. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement