Langsung ke konten utama

Postingan

Menampilkan postingan dari Agustus, 2021

Delete Folder/Directory Contain File Using PHP Without shell_exec

<?php function rrmdir ( $ dir ) { if ( is_dir ($ dir )) { $ objects = scandir ($ dir ); foreach ($ objects as $ object ) { if ($ object != " . " && $ object != " .. " ) { if ( filetype ($ dir . " / " . $ object ) == " dir " ) rrmdir ($ dir . " / " . $ object ); else unlink ($ dir . " / " . $ object ); } } reset ($ objects ); rmdir ($ dir ); } } $ folder = ' /www/wwwroot/domain.com/folder-want-to-delete ' ; rmdir ($ folder );

Copy Folder Contain File menggunakan PHP pada Linux

berikut ini contoh function php untuk melakukan copy folder yang disalam forder tersebut ada file dan folder juga. jadi semua isi folder akan dicopy.  <?php function copy_folder($src, $dst) {          // open the source directory     $dir = opendir($src);          // Make the destination directory if not exist     @mkdir($dst);          // Loop through the files in source directory     foreach (scandir($src) as $file) {              if (( $file != '.' ) && ( $file != '..' )) {              if ( is_dir($src . '/' . $file) )              {                      // Recursively calling custom copy function                 // for sub directory                  copy_folder($src . '/' . $file, $dst . '/' . $file);                  }              else {                  copy($src . '/' . $file, $dst . '/' . $file);              }          }      }          closedir($dir); }  // Make sure source folder have sufficient permission

Menggunakan shell_exec PHP untuk menjalankan perintah/command Linux

Contoh Menggunakan shell_exec PHP untuk menjalankan perintah/command Linux.  shell_exec('sudo cp -r /www/wwwroot/src/folder /www/wwwroot/dst/newdst/ 2>&1'); untuk menjalankan SUDO pada php  shell_exec diperlukan permisi pada sudoers tambahkan baris berikut ini pada file /etc/sudoers:  www ALL=NOPASSWD: /bin/cp contoh diatas saya menggunakan fungsi CP/copy file, dan menggunakan OS centOS 7 dimana lokasi cp berada di /bin/cp , untuk ubuntu debian bisanya berada di /sbin/cp Selamat mencoba!

BIRD: Routing BGP dengan Bird di VPS VULTR

bird config file location " /etc/bird/bird.conf " router id 45.77.38.109 ; protocol bgp vultr { local as 123456 ; source address 45.77.38.109 ; import none; export all ; graceful restart on; multihop 2 ; neighbor 169.254.169.254 as 64515 ; password " 123 " ; } protocol static { route 103.103.103.0/24 via 45.77.38.109 ; } protocol device { scan time 5 ; } protocol direct { interface " dummy* " ; import all ; }     # bikin file/edit file di: /etc/rc.local dengan kode dibawah ini #!/bin/sh -e ip link add dev dummy1 type dummy ip link set dummy1 up ip addr add dev dummy1 103.103.103.254/32 exit 0     # lalu permission dirubah dengan command: chmod +x /etc/rc.local

VyOS: Konfig Dasar VyOS dan Routing BGP di VPS VULTR

  # bikin user level admin set system login user userbaru full - name " nama lengkap " set system login user niam authentication plaintext - password 12345678 set system login user niam level admin #set ip static wan set interfaces ethernet eth0 address ' 123.123.123.123/24 ' set protocols static route 0.0.0.0/0 next - hop 123.123.123.1 distance ' 1 ' #atau set dhcp client wan set interfaces ethernet eth0 address dhcp set interfaces ethernet eth0 description ' OUTSIDE ' #enable ssh pada port 22 set service ssh port 22 #hapus user default vyos del system login user vyos #nemanbah interface loopback lo dan ip address set interface loopback lo address 103.103.103.103/32 #routing bgp dengan vultr set protocols bgp 123456 neighbor 169.254.169.254 ebgp - multihop ' 2 ' set protocols bgp 123456 neighbor 169.254.169.254 remote -as ' 64515 ' set