Sabtu, 30 Juni 2018

Belajar Dasar Proses Stemming






    <?php
$isidokumen="Jokowi Minta Kasus Beras Plastik Jangan Dibesar-besarkan
SOLO, KOMPAS.com — Presiden Joko Widodo (Jokowi) meminta masyarakat sabar dan tidak gegabah dalam menanggapi kasus beras sintetis. Jokowi juga meminta media untuk tidak membesar-besarkan masalah beras sintetis karena masih dalam tahap penelitian para ahli.
mnu=orderdetailKamu enggak usah gede-gedein, wong di satu tempat saja kok. Ini baru dilihat di labnya IPB, di labnya BPOM. Kalau sudah kami simpulkan, baru kita bicara. Jangan semua bicara, semua bicara, tetapi membesarkan masalah saja,mnu=orderdetail kata Jokowi saat mengikuti car free day di Solo, Minggu (24/5/2015).
Jokowi menegaskan akan mencari akar masalah beras sintetis tersebut. (Baca: Wapres JK: Beras Plastik Bukan Masalah Besar)
mnu=orderdetailYang paling penting, akar masalahnya apa? Dicek bener. Apakah hanya di Bekasi atau hanya di satu warung saja? Motivasinya apa?mnu=orderdetail katanya.
Jokowi meragukan peredaran beras plastik tersebut dilatarbelakangi mencari keuntungan karena harga plastik lebih mahal daripada beras. (Baca: Ada yang Janggal di Kasus Beras Plastik, Pengusaha Duga Ada Persaingan Tak Sehat)
mnu=orderdetailSecara logika, enggak masuk kalau motifnya mencari untung karena harga plastik lebih mahal dari beras,mnu=orderdetail katanya.
Direktur Jenderal Pengolahan dan Pemasaran Hasil Pertanian Kementerian Pertanian Yusni Emilia Harahap, seperti dikutip harian Kompas, mengatakan, kasus beras sintetis perlu dituntaskan agar tidak meresahkan masyarakat dan pedagang. (Baca: Bahaya Jangka Pendek dan Jangka Panjang Beras Plastik)
Kasus ini juga menunjukkan bahwa keamanan dan tata niaga pangan perlu diperbaiki. Asal-usul semua beras yang beredar harus bisa ditelusuri melalui pendaftaran merek dan pelaku usaha. Lokasi pengemasan beras pun harus terdaftar sehingga terkontrol.
Ketua Persatuan Penggilingan Padi dan Beras Indonesia Wilayah DKI Jakarta Nellys Soekidi serta Sekjen Asosiasi Pedagang Pasar Seluruh Indonesia Ngadiran mengatakan, kasus beras sintetis menyebabkan pendapatan pedagang beras turun sekitar 30 persen. Banyak konsumen yang memilih membeli beras hanya di toko modern daripada di pasar tradisional.
";
if(isset($_POST["STEM"])){
$isidokumen=$_POST["isidokumen"];
}
?>

 <div class="container">
    <form action="" method="post" enctype="multipart/form-data">
    <p align="center">
    <label for="kata"></label>
    <h3 align="center"> Masukan Kata</h3>
    <div align="center">
        <textarea name="isidokumen" cols="85" rows="15" id="isidokumen"><?php echo $isidokumen;?>
</textarea>
        </p>
<input type="submit" value="Stem" name="STEM" />
   </div>
   </form>
 
 
   <div class="row">
   <div class="col-lg-4 col-lg-offset-1">
   
    <?php
if(isset($_POST['STEM'])){
require_once __DIR__ . '/vendor/autoload.php';

$bacapdf=$_POST["isidokumen"];
$initos = new \Sastrawi\Stemmer\StemmerFactory();
$bikinos = $initos->createStemmer();
$stemming=$bikinos->stem($bacapdf);
$stemming=strtolower($stemming);
echo $stemming;

}//isset

?>
</div>
</div>
</div>


Naive Bayes Klasifikasi Judul


Perintah StopWord:

function getStop($hasil){
$ar=getStopWords();
$p=count($ar);

for($i=0;$i<$p;$i++){
$hasil=str_replace($ar[$i]." ","",$hasil);
}
return $hasil;
}



function getStopWords(){
        return array(
            'yang', 'untuk', 'pada', 'ke', 'para', 'namun', 'menurut', 'antara', 'dia', 'dua',
            'ia', 'seperti', 'jika', 'jika', 'sehingga', 'kembali', 'dan', 'tidak', 'ini', 'karena',
            'kepada', 'oleh', 'saat', 'harus', 'sementara', 'setelah', 'belum', 'kami', 'sekitar',
            'bagi', 'serta', 'di', 'dari', 'telah', 'sebagai', 'masih', 'hal', 'ketika', 'adalah',
            'itu', 'dalam', 'bisa', 'bahwa', 'atau', 'hanya', 'kita', 'dengan', 'akan', 'juga',
            'ada', 'mereka', 'sudah', 'saya', 'terhadap', 'secara', 'agar', 'lain', 'anda',
            'begitu', 'mengapa', 'kenapa', 'yaitu', 'yakni', 'daripada', 'itulah', 'lagi', 'maka',
            'tentang', 'demi', 'dimana', 'kemana', 'pula', 'sambil', 'sebelum', 'sesudah', 'supaya',
            'guna', 'kah', 'pun', 'sampai', 'sedangkan', 'selagi', 'sementara', 'tetapi', 'apakah',
            'kecuali', 'sebab', 'selain', 'seolah', 'seraya', 'seterusnya', 'tanpa', 'agak', 'boleh',
            'dapat', 'dsb', 'dst', 'dll', 'dahulu', 'dulunya', 'anu', 'demikian', 'tapi', 'ingin',
            'juga', 'nggak', 'mari', 'nanti', 'melainkan', 'oh', 'ok', 'seharusnya', 'sebetulnya',
            'setiap', 'setidaknya', 'sesuatu', 'pasti', 'saja', 'toh', 'ya', 'walau', 'tolong',
            'tentu', 'amat', 'apalagi', 'bagaimanapun','bas',
        );
    }

=======================

Perintah Stemming

<form id="form1" name="form1" method="post" action="">
 <strong> Tulis Judul:</strong><br />
  <label for="textarea"></label>
  <textarea name="judul" id="judul" cols="100" rows="5"><?php echo $judul;?></textarea><br />
  <input type="submit" name="Proses" id="Proses" value="Hitung Klasifikasi Menggunakan Stemming -> Naive Bayes" />
</form>
<?php 



if(isset($_POST["Proses"])){
$kalimat=$_POST["judul"];
         $stemming=strtolower($kalimat);

require_once __DIR__ . '/vendor/autoload.php';
 $initos = new \Sastrawi\Stemmer\StemmerFactory();
 $bikinos = $initos->createStemmer();

$stemming=$bikinos->stem($stemming);
$stopword=getStop($stemming);

echo"<h4>";
echo "judul=".$kalimat."<hr>";
echo "stemming=".$stemming."<hr>";
echo "stopword=".$stopword."<hr>";

}
=====================================


 






Download Vendor Lib

Minggu, 03 Juni 2018

PHP COde cek IP and Browser


CEKBROWSER
<?php
function getBrowser()
{
    $u_agent = $_SERVER['HTTP_USER_AGENT'];
    $bname = 'Unknown';
    $platform = 'Unknown';
    $version= "";

    //First get the platform?
    if (preg_match('/linux/i', $u_agent)) {
        $platform = 'linux';
    }
    elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
        $platform = 'mac';
    }
    elseif (preg_match('/windows|win32/i', $u_agent)) {
        $platform = 'windows';
    }

    // Next get the name of the useragent yes seperately and for good reason
    if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
    {
        $bname = 'Internet Explorer';
        $ub = "MSIE";
    }
    elseif(preg_match('/Firefox/i',$u_agent))
    {
        $bname = 'Mozilla Firefox';
        $ub = "Firefox";
    }
    elseif(preg_match('/OPR/i',$u_agent))
    {
        $bname = 'Opera';
        $ub = "Opera";
    }
    elseif(preg_match('/Chrome/i',$u_agent))
    {
        $bname = 'Google Chrome';
        $ub = "Chrome";
    }
    elseif(preg_match('/Safari/i',$u_agent))
    {
        $bname = 'Apple Safari';
        $ub = "Safari";
    }
    elseif(preg_match('/Netscape/i',$u_agent))
    {
        $bname = 'Netscape';
        $ub = "Netscape";
    }

    // finally get the correct version number
    $known = array('Version', $ub, 'other');
    $pattern = '#(?<browser>' . join('|', $known) .
    ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
    if (!preg_match_all($pattern, $u_agent, $matches)) {
        // we have no matching number just continue
    }

    // see how many we have
    $i = count($matches['browser']);
    if ($i != 1) {
        //we will have two since we are not using 'other' argument yet
        //see if version is before or after the name
        if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
            $version= $matches['version'][0];
        }
        else {
            $version= $matches['version'][1];
        }
    }
    else {
        $version= $matches['version'][0];
    }

    // check if we have a number
    if ($version==null || $version=="") {$version="?";}

    return array(
        'userAgent' => $u_agent,
        'name'      => $bname,
        'version'   => $version,
        'platform'  => $platform,
        'pattern'    => $pattern
    );
}

// now try it
$ua=getBrowser();
$yourbrowser= "Your browser: " . $ua['name'] . " " . $ua['version'] . " on " .$ua['platform'] . " reports: <br >" . $ua['userAgent'];
print_r($yourbrowser);
?>





CEKIP


<?php
echo get_client_ip();
echo"<br>";
echo get_IP_address();
echo"<hr>";


function get_IP_address()
{
    foreach (array('HTTP_CLIENT_IP',
                   'HTTP_X_FORWARDED_FOR',
                   'HTTP_X_FORWARDED',
                   'HTTP_X_CLUSTER_CLIENT_IP',
                   'HTTP_FORWARDED_FOR',
                   'HTTP_FORWARDED',
                   'REMOTE_ADDR') as $key){
        if (array_key_exists($key, $_SERVER) === true){
            foreach (explode(',', $_SERVER[$key]) as $IPaddress){
                $IPaddress = trim($IPaddress); // Just to be safe

                if (filter_var($IPaddress,
                               FILTER_VALIDATE_IP,
                               FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)
                    !== false) {

                    return $IPaddress;
                }
            }
        }
    }
}

function get_client_ip()
 {
      $ipaddress = '';
      if (getenv('HTTP_CLIENT_IP'))
          $ipaddress = getenv('HTTP_CLIENT_IP');
      else if(getenv('HTTP_X_FORWARDED_FOR'))
          $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
      else if(getenv('HTTP_X_FORWARDED'))
          $ipaddress = getenv('HTTP_X_FORWARDED');
      else if(getenv('HTTP_FORWARDED_FOR'))
          $ipaddress = getenv('HTTP_FORWARDED_FOR');
      else if(getenv('HTTP_FORWARDED'))
          $ipaddress = getenv('HTTP_FORWARDED');
      else if(getenv('REMOTE_ADDR'))
          $ipaddress = getenv('REMOTE_ADDR');
      else
          $ipaddress = 'UNKNOWN';

      return $ipaddress;
 }

 ?>

PHP COde Download File



<?php
$file="lp2maray.png";
 echo"<link href='mycss/gradient.css' rel='stylesheet' type='text/css' />";
 echo "<span class=judul_head>&#187; <b>File Download :</b></span>";
echo "<li><a href='downloadget.php?file=$file' title='$file'>$file</a> </li>";
?>


downloadget.php

<?php
$direktori = "ypathfile/";
$namafile=$_GET["file"];

if (!file_exists($direktori.$namafile)) {
  echo "<h1>Access forbidden!</h1>
        <p>Maaf, file $namafile yang Anda download sudah tidak tersedia atau filenya (direktorinya) telah diproteksi. <br />
        Silahkan hubungi <a href='mailto:adiarray@gmail.com'>Administrator MAIL</a>.</p>";
  exit();
}
else {
  header("Content-Type: octet/stream");
  header("Content-Disposition: attachment; filename=\"".$namafile."\"");
  $fp = fopen($direktori.$namafile, "r");
  $data = fread($fp, filesize($direktori.$namafile));
  fclose($fp);
  print $data;
}
?>











PHP Code Read .PDF


PHP Code Read .PDF
<?php
$file = 'SISTEM PENUNJANG KEPUTUSAN - M4 - PEMODELAN DAN ANALISIS.pdf';
$filename = $file ;
header ('Content-type:application/pdf');
header ('Content-Disposition:inline; filename="$filename"');
header ('Content-Transfer-Encoding: binart');
header ('Accept-Ranges: bytes');
@readfile ($file);
?>







Trik Membuat Accordeon



<html>
  <head>
   <link href="js/jquery-ui.css" rel="stylesheet">
   <script src="js/jquery-1.8.2.js"></script>
   <script src="js/jquery-ui-1.9.0.custom.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
          $("#isi").accordion({
          animated: "easeOutBounce"   
          });
      });
    </script>
  </head>
    <body style="font-size:65%;">
      <div id="isi">
        <h2><a href="#">Web Designer</a></h2>
            <div>Web designer bertugas sebagai juru gambar, yaitu mendesain website.</div>
        <h2><a href="#">Web Programmer</a></h2>
            <div>Web programmer bertugas sebagai juru coding, yaitu melakukan pemrograman website.</div>
        <h2><a href="#">Web Administrator</a></h2>
            <div>Web administrator bertugas sebagai juru maintenance, yaitu melakukan pemeliharaan dan penjagaan website.</div>
      </div>
    </body>
</html>



SIlakan Download dimari

Download LibPHP

PHP +Database Code Generate .PDF

Codenya sbb:

<?php
require_once"koneksivar.php";

$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if ($conn->connect_error) {
  trigger_error('Database connection failed: '  . $conn->connect_error, E_USER_ERROR);
}

define('FPDF_FONTPATH', 'libPDF/fpdf/font/');
require('libPDF/fpdf/fpdf.php');

class PDF extends FPDF{
  function Header(){
$this->Image("aray.jpg", 1, 0 ,2.5, 2, "JPG", "http://www.lp2maray.com");
    $this->SetTextColor(128,0,0);
    $this->SetFont('Arial','B','14');// $this->SetFont('Times','',12);
$this->Cell(20,0,'                    Data Jabatan',5,1,'L');
    $this->Ln();
    $this->Cell(20,1,'                    YAYASAN LP2M ARAY JAKARTA SELATAN',0,1,'L');
 
  }
 
  function Footer(){
$this->SetY(-4,5);
    $this->SetY(-2,5);
    $this->Cell(0,1,$this->PageNo(),0,0,'C');

  }
}

$sql = "select * from `$tbjabatan`";
$jml =  getJum($conn,$sql);

$i=0;
$arr=getData($conn,$sql);
foreach($arr as $d) {
  $cell[$i][0]=$d["kode_jabatan"];
  $cell[$i][1]=$d["nama_jabatan"];
  $cell[$i][2]=RP($d["gaji_pokok"]);
  $cell[$i][3]=RP($d["uang_makan"]);
  $cell[$i][4]=RP($d["uang_transport"]);
  $cell[$i][5]=$d["keterangan"];
  $i++;
}


$pdf=new PDF('L','cm','A4');//$pdf=new PDF("P","in","Letter");
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','B','9');
$pdf->SetFillColor(192,192,192);
$pdf->Cell(1,1,'no','LR',0,'L',1);
//$pdf->MultiCell(0, 0.5, $lipsum1, 'LR', "L");

$pdf->Cell(3,1,'kode_jabatan','LR',0,'C',1);
$pdf->Cell(7,1,'nama_jabatan','LR',0,'C',1);
$pdf->Cell(3,1,'gaji_pokok','LR',0,'C',1);
$pdf->Cell(3,1,'uang_makan','LR',0,'C',1);
$pdf->Cell(3,1,'uang_transport','LR',0,'C',1);
$pdf->Cell(8,1,'keterangan','LR',0,'C',1);
$pdf->Ln();
$pdf->SetFont('Arial','','8');

for ($j=0;$j<$i;$j++){
  $pdf->Cell(1,1,$j+1,'B',0,'L');         // no
  $pdf->Cell(3,1,$cell[$j][0],'B',0,'L'); // kode_jabatan
  $pdf->Cell(7,1,$cell[$j][1],'B',0,'L'); // nama_jabatan
  $pdf->Cell(3,1,$cell[$j][2],'B',0,'L'); // gaji_pokok
  $pdf->Cell(3,1,$cell[$j][3],'B',0,'L'); // uang_makan
  $pdf->Cell(3,1,$cell[$j][4],'B',0,'L'); // uang_transport
  $pdf->Cell(8,1,$cell[$j][5],'B',0,'L'); // keterangan
  $pdf->Ln();
}
$pdf->Output();
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

function getJum($conn,$sql){
  $rs=$conn->query($sql);
  $jum= $rs->num_rows;
$rs->free();
return $jum;
}

function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$arr = $rs->fetch_all(MYSQLI_ASSOC);

$rs->free();
return $arr;
}

function RP($rupiah){return number_format($rupiah,"2",",",".");}
?>


Atau silakan Download dimari





PHP Code Generate PDF SIMPLE



<?php
require('fpdf/fpdf.php');

class PDF extends FPDF{

function PDF($orientation='P', $unit='mm', $size='A4'){
    $this->FPDF($orientation,$unit,$size);
}

function Header(){
    $this->SetFont('Times','B',14);
    $this->Cell(80);
    $this->Cell(30,10,'PROSES BELAJAR DI LP2M ARAY',0,0,'C');
    $this->Ln(20);
}

function Footer(){
    $this->SetY(-15);
    $this->SetFont('Times','',8);
    $this->Cell(0,10,$this->PageNo(),0,0,'R');
}

}



$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Times','B',14);
$pdf->Cell(40,10,'Nilai Alternatif Kriteria',0,0,'L');
$pdf->ln();
$pdf->SetFont('Times','B',12);
$pdf->Cell(40,7,'Kriteria/Alternatif',1,0,'L');

for($i=1;$i<=5;$i++){
$pdf->Cell(30,7,"Header".$i,1,0,'L');
}

$pdf->ln();
$pdf->SetFont('Times','',12);


for($i=1;$i<=5;$i++){
$pdf->Cell(40,7,"Baris".$i,1,0,'L');
for($ii=1;$ii<=5;$ii++){
$pdf->Cell(30,7,"Kolom".$i."-".$ii,1,0,'L');
}
$pdf->ln();
}

$pdf->SetFont('Times','B',14);
$pdf->Cell(40,10,'Normalisasi R',0,0,'L');
$pdf->ln();

$pdf->SetFont('Times','B',12);
$pdf->Cell(40,7,'Kriteria/Alternatif',1,0,'L');
for($i=1;$i<=5;$i++){
$pdf->Cell(30,7,"Kolom".$i,1,0,'L');
}

$pdf->ln();
$pdf->SetFont('Times','',12);


$pdf->Output();
?>

Atau SIlakan Download dimari

PHP Code QRCODE Generate

Kita akan membuat QRCODe sbb


Jadi sat aplikasi di jalankan kita akan memperoleh QRCOde sesuai isi pesan kita dan langsung kebentuk nama file baru .png

dengan perintah sbb:

<?php   
 
    $NF="lp2maray.png";//Nama File hasil generate
   
    include "qrlib.php";   
  $errorCorrectionLevel = 'L';//'L','M','Q','H'
    $matrixPointSize = 4;//sd 10

$PNG_WEB_DIR = 'ypathfile/';
$namaPathFile=$PNG_WEB_DIR.$NF;

$isipesan="LP2M ARAY JAKARTA";
    QRcode::png($isipesan, $namaPathFile, $errorCorrectionLevel, $matrixPointSize, 2);   
       
    echo '<img src="'.$namaPathFile.'" /><hr/>'; 
   
 
   ?>
   
Atau teman2 bisa download dimari:

Download QRCODE Generator






PHP Code Barcode Batang

Kita mau buat Barcode Batang sbb:


Code nya sbb:

<?php

$filepath="";
$text="LP2M ARAY JAKARTA";
$size=strlen($text);
$orientation="horizontal";
$code_type="code128";
$print="true";
$sizefactor ="1";

barcode( $filepath, $text, $size, $orientation, $code_type, $print, $sizefactor );

function barcode( $filepath="", $text="0", $size="20", $orientation="horizontal", $code_type="code128", $print=false, $SizeFactor=1 ) {
$code_string = "";
if ( in_array(strtolower($code_type), array("code128", "code128b")) ) {
$chksum = 104;
// Must not change order of array elements as the checksum depends on the array's key to validate final code
$code_array = array(" "=>"212222","!"=>"222122","\""=>"222221","#"=>"121223","$"=>"121322","%"=>"131222","&"=>"122213","'"=>"122312","("=>"132212",")"=>"221213","*"=>"221312","+"=>"231212",","=>"112232","-"=>"122132","."=>"122231","/"=>"113222","0"=>"123122","1"=>"123221","2"=>"223211","3"=>"221132","4"=>"221231","5"=>"213212","6"=>"223112","7"=>"312131","8"=>"311222","9"=>"321122",":"=>"321221",";"=>"312212","<"=>"322112","="=>"322211",">"=>"212123","?"=>"212321","@"=>"232121","A"=>"111323","B"=>"131123","C"=>"131321","D"=>"112313","E"=>"132113","F"=>"132311","G"=>"211313","H"=>"231113","I"=>"231311","J"=>"112133","K"=>"112331","L"=>"132131","M"=>"113123","N"=>"113321","O"=>"133121","P"=>"313121","Q"=>"211331","R"=>"231131","S"=>"213113","T"=>"213311","U"=>"213131","V"=>"311123","W"=>"311321","X"=>"331121","Y"=>"312113","Z"=>"312311","["=>"332111","\\"=>"314111","]"=>"221411","^"=>"431111","_"=>"111224","\`"=>"111422","a"=>"121124","b"=>"121421","c"=>"141122","d"=>"141221","e"=>"112214","f"=>"112412","g"=>"122114","h"=>"122411","i"=>"142112","j"=>"142211","k"=>"241211","l"=>"221114","m"=>"413111","n"=>"241112","o"=>"134111","p"=>"111242","q"=>"121142","r"=>"121241","s"=>"114212","t"=>"124112","u"=>"124211","v"=>"411212","w"=>"421112","x"=>"421211","y"=>"212141","z"=>"214121","{"=>"412121","|"=>"111143","}"=>"111341","~"=>"131141","DEL"=>"114113","FNC 3"=>"114311","FNC 2"=>"411113","SHIFT"=>"411311","CODE C"=>"113141","FNC 4"=>"114131","CODE A"=>"311141","FNC 1"=>"411131","Start A"=>"211412","Start B"=>"211214","Start C"=>"211232","Stop"=>"2331112");
$code_keys = array_keys($code_array);
$code_values = array_flip($code_keys);
for ( $X = 1; $X <= strlen($text); $X++ ) {
$activeKey = substr( $text, ($X-1), 1);
$code_string .= $code_array[$activeKey];
$chksum=($chksum + ($code_values[$activeKey] * $X));
}
$code_string .= $code_array[$code_keys[($chksum - (intval($chksum / 103) * 103))]];

$code_string = "211214" . $code_string . "2331112";
} elseif ( strtolower($code_type) == "code128a" ) {
$chksum = 103;
$text = strtoupper($text); // Code 128A doesn't support lower case
// Must not change order of array elements as the checksum depends on the array's key to validate final code
$code_array = array(" "=>"212222","!"=>"222122","\""=>"222221","#"=>"121223","$"=>"121322","%"=>"131222","&"=>"122213","'"=>"122312","("=>"132212",")"=>"221213","*"=>"221312","+"=>"231212",","=>"112232","-"=>"122132","."=>"122231","/"=>"113222","0"=>"123122","1"=>"123221","2"=>"223211","3"=>"221132","4"=>"221231","5"=>"213212","6"=>"223112","7"=>"312131","8"=>"311222","9"=>"321122",":"=>"321221",";"=>"312212","<"=>"322112","="=>"322211",">"=>"212123","?"=>"212321","@"=>"232121","A"=>"111323","B"=>"131123","C"=>"131321","D"=>"112313","E"=>"132113","F"=>"132311","G"=>"211313","H"=>"231113","I"=>"231311","J"=>"112133","K"=>"112331","L"=>"132131","M"=>"113123","N"=>"113321","O"=>"133121","P"=>"313121","Q"=>"211331","R"=>"231131","S"=>"213113","T"=>"213311","U"=>"213131","V"=>"311123","W"=>"311321","X"=>"331121","Y"=>"312113","Z"=>"312311","["=>"332111","\\"=>"314111","]"=>"221411","^"=>"431111","_"=>"111224","NUL"=>"111422","SOH"=>"121124","STX"=>"121421","ETX"=>"141122","EOT"=>"141221","ENQ"=>"112214","ACK"=>"112412","BEL"=>"122114","BS"=>"122411","HT"=>"142112","LF"=>"142211","VT"=>"241211","FF"=>"221114","CR"=>"413111","SO"=>"241112","SI"=>"134111","DLE"=>"111242","DC1"=>"121142","DC2"=>"121241","DC3"=>"114212","DC4"=>"124112","NAK"=>"124211","SYN"=>"411212","ETB"=>"421112","CAN"=>"421211","EM"=>"212141","SUB"=>"214121","ESC"=>"412121","FS"=>"111143","GS"=>"111341","RS"=>"131141","US"=>"114113","FNC 3"=>"114311","FNC 2"=>"411113","SHIFT"=>"411311","CODE C"=>"113141","CODE B"=>"114131","FNC 4"=>"311141","FNC 1"=>"411131","Start A"=>"211412","Start B"=>"211214","Start C"=>"211232","Stop"=>"2331112");
$code_keys = array_keys($code_array);
$code_values = array_flip($code_keys);
for ( $X = 1; $X <= strlen($text); $X++ ) {
$activeKey = substr( $text, ($X-1), 1);
$code_string .= $code_array[$activeKey];
$chksum=($chksum + ($code_values[$activeKey] * $X));
}
$code_string .= $code_array[$code_keys[($chksum - (intval($chksum / 103) * 103))]];

$code_string = "211412" . $code_string . "2331112";
} elseif ( strtolower($code_type) == "code39" ) {
$code_array = array("0"=>"111221211","1"=>"211211112","2"=>"112211112","3"=>"212211111","4"=>"111221112","5"=>"211221111","6"=>"112221111","7"=>"111211212","8"=>"211211211","9"=>"112211211","A"=>"211112112","B"=>"112112112","C"=>"212112111","D"=>"111122112","E"=>"211122111","F"=>"112122111","G"=>"111112212","H"=>"211112211","I"=>"112112211","J"=>"111122211","K"=>"211111122","L"=>"112111122","M"=>"212111121","N"=>"111121122","O"=>"211121121","P"=>"112121121","Q"=>"111111222","R"=>"211111221","S"=>"112111221","T"=>"111121221","U"=>"221111112","V"=>"122111112","W"=>"222111111","X"=>"121121112","Y"=>"221121111","Z"=>"122121111","-"=>"121111212","."=>"221111211"," "=>"122111211","$"=>"121212111","/"=>"121211121","+"=>"121112121","%"=>"111212121","*"=>"121121211");

// Convert to uppercase
$upper_text = strtoupper($text);

for ( $X = 1; $X<=strlen($upper_text); $X++ ) {
$code_string .= $code_array[substr( $upper_text, ($X-1), 1)] . "1";
}

$code_string = "1211212111" . $code_string . "121121211";
} elseif ( strtolower($code_type) == "code25" ) {
$code_array1 = array("1","2","3","4","5","6","7","8","9","0");
$code_array2 = array("3-1-1-1-3","1-3-1-1-3","3-3-1-1-1","1-1-3-1-3","3-1-3-1-1","1-3-3-1-1","1-1-1-3-3","3-1-1-3-1","1-3-1-3-1","1-1-3-3-1");

for ( $X = 1; $X <= strlen($text); $X++ ) {
for ( $Y = 0; $Y < count($code_array1); $Y++ ) {
if ( substr($text, ($X-1), 1) == $code_array1[$Y] )
$temp[$X] = $code_array2[$Y];
}
}

for ( $X=1; $X<=strlen($text); $X+=2 ) {
if ( isset($temp[$X]) && isset($temp[($X + 1)]) ) {
$temp1 = explode( "-", $temp[$X] );
$temp2 = explode( "-", $temp[($X + 1)] );
for ( $Y = 0; $Y < count($temp1); $Y++ )
$code_string .= $temp1[$Y] . $temp2[$Y];
}
}

$code_string = "1111" . $code_string . "311";
} elseif ( strtolower($code_type) == "codabar" ) {
$code_array1 = array("1","2","3","4","5","6","7","8","9","0","-","$",":","/",".","+","A","B","C","D");
$code_array2 = array("1111221","1112112","2211111","1121121","2111121","1211112","1211211","1221111","2112111","1111122","1112211","1122111","2111212","2121112","2121211","1121212","1122121","1212112","1112122","1112221");

// Convert to uppercase
$upper_text = strtoupper($text);

for ( $X = 1; $X<=strlen($upper_text); $X++ ) {
for ( $Y = 0; $Y<count($code_array1); $Y++ ) {
if ( substr($upper_text, ($X-1), 1) == $code_array1[$Y] )
$code_string .= $code_array2[$Y] . "1";
}
}
$code_string = "11221211" . $code_string . "1122121";
}

// Pad the edges of the barcode
$code_length = 20;
if ($print) {
$text_height = 30;
} else {
$text_height = 0;
}

for ( $i=1; $i <= strlen($code_string); $i++ ){
$code_length = $code_length + (integer)(substr($code_string,($i-1),1));
        }

if ( strtolower($orientation) == "horizontal" ) {
$img_width = $code_length*$SizeFactor;
$img_height = $size;
} else {
$img_width = $size;
$img_height = $code_length*$SizeFactor;
}

$image = imagecreate($img_width, $img_height + $text_height);
$black = imagecolorallocate ($image, 0, 0, 0);
$white = imagecolorallocate ($image, 255, 255, 255);

imagefill( $image, 0, 0, $white );
if ( $print ) {
imagestring($image, 5, 31, $img_height, $text, $black );
}

$location = 10;
for ( $position = 1 ; $position <= strlen($code_string); $position++ ) {
$cur_size = $location + ( substr($code_string, ($position-1), 1) );
if ( strtolower($orientation) == "horizontal" )
imagefilledrectangle( $image, $location*$SizeFactor, 0, $cur_size*$SizeFactor, $img_height, ($position % 2 == 0 ? $white : $black) );
else
imagefilledrectangle( $image, 0, $location*$SizeFactor, $img_width, $cur_size*$SizeFactor, ($position % 2 == 0 ? $white : $black) );
$location = $cur_size;
}

// Draw barcode to the screen or save in a file
if ( $filepath=="" ) {
header ('Content-type: image/png');
imagepng($image);
//imagedestroy($image);
} else {
imagepng($image,$filepath);
//imagedestroy($image);
}
}

?>



Oh  Mudah yaaaa.....
Silakan Download Code sbb



Mencari Tanggal Terakhir Suatu Bulan

  $a_date = "$tahun-$bulan-01"; $lastdate= date('t',strtotime($a_date));//Y-m-t <?php require_once"koneksivar.php&...