Skrip Menukar Password - Moodle

Ada 2 masalah besar apabila upgrade database, iaitu tidak dapat logon dan perubahan format database (utf-8 bin).

1. Skrip ini digunakan untuk menukar password. Password yang ditukar adalah sama dengan nama pengguna (username).
2. Skrip ini hendaklah disimpan dengan nama tukarpass.php.
3. Simpan dalam folder program moodle.
4. Anda perlu ubah 3 perkara iaitu nama database, username dan password. Sila rujuk fail config.php sekiranya anda tidak faham.
5. Inilah skripnya.
<?php
// please increase max execution time to 300, example max_execution_time = 300
//mysql_connect("localhost","db_user","db_password");
mysql_connect("localhost","root","root");
//mysql_select_db("db_name");
$dbname=mysql_select_db("lmssmach");
// convert database to format utf8_bin
// ALTER DATABASE `database-name` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin
echo "------------convert database to format utf8-bin -------------";
mysql_query("ALTER DATABASE $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_bin");
// convert all table
$res = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_array($res))
{
foreach ($row as $key => $table)
{
mysql_query("ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin");
echo $key . " => " . $table . " CONVERTED
";
}
}
echo "----------all table was converted-----------"
?>

Comments

Popular posts from this blog

Working with Columns on the Joomla Frontpage

Create your own Nameserver using TinyDns on Pfsense

Block Facebook on Pfsense using WPAD Autodiscover feature