Wednesday, February 3, 2016

PHP - Baca Folder Sharing Network pada Windows

<?php

// Define the parameters for the shell command
$location = "\\pc-share\Downloads";
$user = "administrator";
$pass = "password";
$letter = "Z";

// Map the drive
system("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");

// Open the directory
$dir = opendir($letter.":/tes");

$files = scandir($letter.":/tes", 0);
$n = 0;
for($i = 2; $i < count($files); $i++){
    $n++;
    //if($n%2==0){echo $n;}
    echo $files[$i]."</BR> ";
}
?>

Thursday, January 7, 2016

Listbox PHP value dari MYSQL

<?php
$koneksi_db = mysql_connect("localhost", "root", ""); //membuka koneksi ke database
mysql_select_db("db_hclab", $koneksi_db);  //proses masuk ke database
$sql = "
SELECT
  `tbl_getdata`.`instrument_id`
FROM
  `tbl_getdata`
GROUP BY
  `tbl_getdata`.`instrument_id`
";
$query = mysql_query($sql);
?>
    <select class="form-control" name="id_kategori">
        <option value=""></option>
<?php
    while($hasil = mysql_fetch_array($query)){
?>
      <option value="<?php echo $hasil["instrument_id"];?>"><?php echo $hasil["instrument_id"];?></option>
<?php
}
?>
</select>

Wednesday, January 6, 2016

Format Tanggal di PHP

<?php
$tanggal = "2016-01-01";

echo date("d F Y", strtotime($tanggal));    // 01 January 2016
echo "<BR>";
echo date("F j, Y, g:i a", strtotime($tanggal));                 // January 1, 2016, 12:00 am
echo "<BR>";
echo date("m.d.y", strtotime($tanggal));                         // 01.01.16
echo "<BR>";
echo date("j, n, Y, strtotime($tanggal)");                       // 6, 1, 2016, 2731Wed, 06 Jan 2016 11:12:27 +0700312016311201Asia/Jakarta(2016-01-01)
echo "<BR>";
echo date("Ymd", strtotime($tanggal));                           // 20160101
echo "<BR>";
echo date('h-i-s, j-m-y, it is w Day', strtotime($tanggal));     // 12-00-00, 1-01-16, 0031 0000 5 Friam16
echo "<BR>";
echo date('\i\t \i\s \t\h\e jS \d\a\y.', strtotime($tanggal));   // it is the 1st day.
echo "<BR>";
echo date("D M j G:i:s T Y", strtotime($tanggal));               // Fri Jan 1 0:00:00 WIB 2016
echo "<BR>";
echo date('H:m:s \m \i\s\ \m\o\n\t\h', strtotime($tanggal));     // 00:01:00 m is month
echo "<BR>";
echo date("H:i:s", strtotime($tanggal));                         // 00:00:00
echo "<BR>";
echo date("Y-m-d H:i:s", strtotime($tanggal));                   // 2016-01-01 00:00:00

?>

Tuesday, January 5, 2016

MYSQL - Mengelompokkan Berdasarkan Tanggal Pada format DATETIME

SELECT
  date(`tbl_getdata`.`created_dt`)
FROM
  `tbl_getdata`
GROUP BY
  date(`tbl_getdata`.`created_dt`);

Menampilkan Daftar Tanggal di Antara Dua Tanggal

<?php
// Start date
$tanggal_awal = '2016-01-01';
// End date
$tanggal_akhir = '2016-02-31';

while (strtotime($tanggal_awal) <= strtotime($tanggal_akhir)) {
            echo "$tanggal_awal<BR>";
            $tanggal_awal = date ("Y-m-d", strtotime("+1 day", strtotime($tanggal_awal)));
}
?>

Monday, March 2, 2015

Instal SSH pada Ubuntu

pada terminal ketik:
sudo apt-get install openssh-server

Secara default port yang digunakan adalah port 22, untuk anda dapat merubahnya dengan cara :
sudo vi /etc/ssh/sshd_config

Di dalam file tersebut, terdapat konfigurasi port pada "Port 22" lalu ubah sesuai dengan port yang anda inginkan kemudian simpan.

 lakukan restart service ssh anda.

sudo service ssh restart
atau
sudo /etc/init.d/ssh restart

Anda dapat melihat history login pada ubuntu server apada file /var/log/auth.log dan Anda bisa mengikuti secara real time dengan Command:
tail -f /var/log/auth.log

Somoga dapat membantu.

Mengatasi GRUB yang hilang

Loding dengan menggunakan ubuntu live cd

untuk mengetahui hardisk yg terdapat di komputer, pada terminal ketik
--------------------------
sudo fdisk -l
--------------------------

disini letak saya berada di /dev/sda5
langkah mounting partisi dimana instalasi ubuntu berada dengan mengetikan perintah
--------------------------
sudo mount /dev/sda5 /mnt
--------------------------

install grub di partisi yang sudah di mount
--------------------------
sudo grub-install --root-directory=/mnt/ /dev/sda
--------------------------
  
Restart komputer anda lalu booting dengan hardisk anda
--------------------------
sudo reboot
--------------------------

setelah berhasil masuk ke ubuntunya anda, ketik di terminal
--------------------------
sudo update-grub
--------------------------

Semoga berhasil