import file data di file *.csv jadi *.sql

script di bawah ini berfungsi untuk meng-konversi file berformat csv menjadi file berformat sql…

tinggal copy, lalu paste ke dalam file .php
simpan di dokumen root…
sesuaikan dengan konfigurasi anda
lalu jalankan di browser

———————————————————-

$host = “localhost”;
$databasename = “test”;
$databasetable = “test”;
$user =”root”;
$pass = “”;
$fieldseparator = “,”;
$lineseparator = “\n”;
$csvfile = “file.csv”;
/********************************/
/*apa anda ingin menambahkan field kosong di depan record?
/*ini berguna jika anda memiliki table dengan field pertama berupa auto_increment integer
/*dan file csv tidak mempunyai field kosong di awal record
/*ubah nilai $addauto jadi 1 untuk iya, dan 0 untuk tidak..PERHATIAN:jangan ubah jadi 1 jika anda tidak yakin
/********************************/
$addauto = 0;
/********************************/

//untuk menyimpan hasilnya ke dalam file, ubah nilai $save jadi 1
//buat file .sql di dalam folder
/********************************/
$save = 1;
$outputfile = “output.sql”;
/********************************/

if(!file_exists($csvfile)) {
echo “File not found. Make sure you specified the correct path.\n”;
exit;
}

$file = fopen($csvfile,”r”);

if(!$file) {
echo “Error opening data file.\n”;
exit;
}

$size = filesize($csvfile);

if(!$size) {
echo “File is empty.\n”;
exit;
}

$csvcontent = fread($file,$size);

fclose($file);

$con = @mysql_connect($host,$user,$pass) or die(mysql_error());
@mysql_select_db($databasename) or die(mysql_error());

$lines = 0;
$queries = “”;
$linearray = array();

foreach(split($lineseparator,$csvcontent) as $line) {

$lines++;

$line = trim($line,” \t”);

$line = str_replace(“\r”,””,$line);

/************************************
baris ini mengabaikan special character. hapus jika sudah ada special character di dalam file csv
************************************/
$line = str_replace(“‘”,”\'”,$line);
/*************************************/

$linearray = explode($fieldseparator,$line);

$linemysql = implode(“‘,'”,$linearray);

if($addauto)
$query = “insert into $databasetable values(”,’$linemysql’);”;
else
$query = “insert into $databasetable values(‘$linemysql’);”;

$queries .= $query . “\n”;

@mysql_query($query);
}

@mysql_close($con);

if($save) {

if(!is_writable($outputfile)) {
echo “File is not writable, check permissions.\n”;
}

else {
$file2 = fopen($outputfile,”w”);

if(!$file2) {
echo “Error writing to the output file.\n”;
}
else {
fwrite($file2,$queries);
fclose($file2);
}
}

}

echo “Found a total of $lines records in this csv file.\n”;

?>
———————————————————-

events OnChange with CodeCharge

OnChange berfungsi untuk merubah nilai value dari sebuah textbox ketika textbox yang lain berubah nilai

ilustrasi :

ada sebuah form bernama NewRecord1, di dalamnya terdapat textbox1 dan listbox1

nilai dari textbox1 akan berubah otomatis ketika nilai listbox1 berubah…

function employeeleave_id_OnChange()
{
var result = true;
var jumlah = document.NewRecord1.TextBox1.value;
var jenis = document.NewRecord1.ListBox1.selectedIndex;

document.NewRecord1.TextBox1.value = (jumlah – jenis);
return result;
}

di bawah ini adalah script lebih custom…..

<!–
//End Include Common JSFunctions

//NewRecord1ListBox1_OnChange @3-CE96F29C
function NewRecord1ListBox1_OnChange()
{
var result = true;
//End NewRecord1ListBox1_OnChange

//Custom Code @8-2A29BDB7
var jumlah = document.NewRecord1.TextBox1.value;
var jenis = document.NewRecord1.ListBox1.selectedIndex;

document.NewRecord1.TextBox1.value = (jumlah – jenis);
var jenis = document.NewRecord1.ListBox1.disabled = true;
//End Custom Code

//Close NewRecord1ListBox1_OnChange @3-BC33A33A
return result;
}
//End Close NewRecord1ListBox1_OnChange

//NewRecord1TextBox1_OnChange @7-11B1EC37
function NewRecord1TextBox1_OnChange()
{
var result = true;
//End NewRecord1TextBox1_OnChange

//Custom Code @9-2A29BDB7
document.NewRecord1.ListBox1.disabled = false;
//End Custom Code

//Close NewReco

Install Repo Ubuntu dari ISO

Langkah 1.
buat folder sebagai mount point dari file iso yang akan di mount.
sudo mkdir -p /media/disk1 /media/disk2 /media/disk3
/media/disk4 /media/disk5

Langkah 2.
mount repository berbentuk iso ke folder yang telah di buat.

sudo mount -o loop /tempat repository1.iso/ /media/disk1
sudo mount -o loop /tempat repository2.iso/ /media/disk2
sudo mount -o loop /tempat repository3.iso/ /media/disk3
sudo mount -o loop /tempat repository4.iso/ /media/disk4
sudo mount -o loop /tempat repository5.iso/ /media/disk5

Langkah 3.
Ubah file source.list di /etc/apt/
tambahkan symbol pagar di depan semua yang belum di beri pagar
contoh :
deb http://dl2.foss-id.web.id/ubuntu hardy main restricted universe multiverse
menjadi
#deb http://dl2.foss-id.web.id/ubuntu hardy main restricted universe multiverse

Langkah 4.
Tambahkan baris ini ke dalam source.list di /etc/apt/

deb file:/media/disk1 hardy main restricted
deb file:/media/disk2 hardy main multiverse universe
deb file:/media/disk3 hardy universe
deb file:/media/disk4 hardy universe
deb file:/media/disk5 hardy universe

Langkah 5.
jalankan apt-get update

buka terminal,
ketikkan : sudo apt-get update

kalau sudah selesai, jalan kan synaptic dan install yang ingin di install.

Create & Change SplashImage for GRUB in Ubuntu

before we start, you need :

– file with *.xpm.gz format type
(http://easylinux.info/uploads/ubuntu.xpm.gz)

if you want to use your own pic, you’ll need :

– Image Editor (ImageMagick | there are some at ubuntu repository)

Splash Image would show when we get to the boot menu (when we choose the OS we’d like to use)

Make your own .xpm.gz file

open terminal, execute this command :

convert -resize 640X480 -colors 14 file_name.(jpg/jpeg/png) file_name.xpm && gzip file_name.xpm.gz

if no error, file with .xpm.gz would show on the path you use up there

after that,

create some directory at /boot/grub/

sudo mkdir /boot/grub/images/

move the file we just created to that directory

sudo cp nama_file.xpm.gz /boot/grub/images/
don’t forget to change the ownership to root

make some backup for file menu.lst

sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_backup

change the content of file menu.lst by using any editor you’re friendly with

gksudo (gedit/vim/vi/dll) /boot/grub/menu.lst

find this part,

# menu.lst – see : grub(8), info grub, update-grub(8),
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

insert this line onto that file, anywhere.
splashimage (hd0,0)/boot/grub/images/file_name.xpm.gz

* I assumed that hd0,0 was location of ubuntu boot

when you’re done, save and reboot your komputer…


Happy Trying