Problem in Moodle 1.9 and PHP 5.3
Today someone ask me to check his Moodle installation in his website. He used to add resource(s) easily in any course he made and lately he’s unable to add any resource. In the resource page, Moodle just displays blank page. No error message at all.
After googling around, I found that the problem is (likely) caused by PHP upgrade from 5.2.x to 5.3.x. And thanks to Andrey who posted a script for a quick hack.
The trick is by adding a new function inside HTML_QuickForm_element class in moodle/lib/pear/HTML/QuickForm/element.php.
< ?php
public function __call($name, $args) {
$name = str_replace('MoodleQuickForm_', '', $name);
if ($name == 'passwordunmask') {
$name = 'password';
}
return call_user_func_array(array($this, 'HTML_QuickForm_'.$name), $args);
}
?>
It works like a magic!
Error 404 on Drupal Admin Section
My Drupal installation was fine until I uploaded it into my web hosting. It always returned error 404 page (not found) every time I clicked on any admin section (i.e http://domain.com/admin/build, http://domain.com/admin/settings, etc).
I have tried bypassing clean URLs by using http://domain.com/?q=admin, renamed .htaccess file and so on. But all of my efforts still bring me the same error page.
Huft..
After many minutes, I figured out that the problem was caused by the update module that always loaded every time I open admin section. Thus I decided to disable this module.
Just open PHPMyAdmin, click my database and run this query:
update system set status=0 where name='update'
And…… it works! All my admin sections are now working fine with this little trick.
Install Nginx, PHP-FPM & MySQL in Centos
After reading a tutorial of how to install Nginx, PHP and MySQL in a difficult way, now I would like to tell ya how to install them in a very easy way.
I found this method was very effective and completed just within few minutes in my Centos VPS.
- Download this shell script to your VPS
[root@power ~]# wget http://freevps.us/downloads/nginx-centos.sh
- Run that bash script
[root@power ~]# bash nginx-centos.sh
then wait..
- Voila! Nginx, PHP-FPM and MySQL are installed at glance!
Not only that, this shell script also installed a tool to create virtual host in Nginx named setup-vhost
.
When I made virtual host for this blog, I just need to run this command:
[root@power ~]# setup-vhost sandalian.com
Then I uploaded all my files at /var/www/sandalian.com
and configure database connection etc.
Thanks to you guys at freevps.us, installing this stack never been easier than this!
Wrong mail quota in CPanel
Today I found my CPanel displays wrong disk quota for an email account. It shows 58/100 MB (58 MB used, of 100 MB preserved) while actually the mailbox is empty.
I have checked with du -sh
command (a command to check disk usage) and it returned 100 KB or something, so there must be something wrong.
After googling around, I got some trick to solve this problem. Perform this action from shell/SSH or simply using file manager in CPanel:
- Go to
/home/usercpanel/mail/domain.com/emailaccount/
. - Delete file named maildirsize, this file stores disk usage information
- Change the number of disk quota for that email account from CPanel (inside menu Email Accounts), it will regenerate a new maildirsize file.
Refresh your browser and now you should see the correct disk quota for that email account.
Create PDF Files For Free
I was wondering why many people still using Adobe Acrobat for creating PDF files from their documents. It’s bloated –or you can say my computer is too old– and of course expensive! Some minutes ago I’ve checked the price on their website, it costs US$ 299.
Why don’t people find an alternative PDF-maker software which is free and lightweight? I know that you can get any serial number from Internet for Adobe Acrobat to turn that pricey software into a free one. But hey, it’s like stealing from a kid’s pocket.
A few days ago –when I needed a software to convert my documents into PDFs– I found doPDF which is free and lightweight. And most of all, it doesn’t require any Ghostscript installation just like any other PDF printers.
Perhaps it doesn’t have all the features you want and requires you to upgrade to the paid version but it’s enough for me. Awesome PDF printer.
This way I thank to doPDF developer(s) for their great work.
Redirect Old URLs to New URLs
When we have a completely new website and uses different CMS, there will be old URLs that already spread everywhere on the Net. Discarding old URLs is not an option because we will lost visitors from search engines. So we must redirect all old URLs into new URLs.
Using redirect in .htaccess is great, but when your old URLs contain question mark, most likely it will fail to redirect.
Following code will work:
redirect 301 /old-url.html http://domain.com/new-url.html redirect 301 /very-old.html http://domain.com/very-new.html
But following code will –at least in my case– failed:
redirect 301 /file.php?age=old http://domain.com/new-url.html redirect 301 /file.php?age=old&id=12 http://domain.com/very-new.html
Luckily there’s 404 directive from Apache using .htaccess. We can mix the power of custom 404 page with PHP to perform this directions stuff. Here’s how to mix them up:
Create custom 404 page using .htaccess
ErrorDocument 404 /redirect.php
Then create file redirect.php with following contents:
< ?php
$req = trim($_SERVER['REQUEST_URI']);
switch($req){
case "/file.php?age=old":
$goto = "http://domain.com/new-url.html";
break;
case "/file.php?age=old&id=12";
$goto = "http://domain.com/im-very-new.html";
break;
default:
$goto = "http://domain.com";
}
header ("HTTP/1.1 301 Moved Permanently");
header ("Location: $goto");
?>
By this method, old URLs that are no longer exist are forwarded to our custom 404 page (named redirect.php) and that redirect.php will bring visitors to new URLs.
Nice, isn’t it?
Error on Webmail, Query: SELECT “INBOX”
If you got following error message when accessing webmail using Squirrelmail or other brand:
Query: SELECT “INBOX”
Reason Given: Internal error occurred. Refer to server log for more information. [2009-11-03 15:47:40]
The cure is really easy. Check /home/user/mail/ and see its subdirectories’ permission.
In my case, I just need to perform chown command to assign the directories/files under user’s ownership and the problem is gone.
Invalid field count in csv input on line 1
When importing CSV data into my MySQL database using PHPMyAdmin, I found following error: Invalid field count in csv input on line 1.
It’s odd since I’ve manually count field numbers and compared with column on my CSV files, they’re exactly match.
Then I found something strange. PHPMyAdmin is automatically use semicolon ( ; ) as field delimiter instead of comma ( , ). Quick fix for this problem is to change the delimiter symbol manually.
In the picture above, I replaced semicolon (rounded with blue circle) with comma and everything is alright.
Youtube Downloader – Updated
After failed to work for some weeks, I finally got spare time to finish the Youtube Downloader scripts.
To get this script working, you must have readfile() function enabled. As alternative, you can modify the script and use file_get_contents() or CURL.
Have fun! ^_^
WordPress: Your hosting does not support this feature
I was moving wordpress installation from one server into another. I copy the files, import database and modify configuration file (wp-config.php) and trying to access the page. But I only get following message:
Your hosting does not support this feature.
I logged into my shell account, checked permission files and found that some files have wrong user permission. So I just change user permission using command chown -R myuser:mygroups *
.
I refresh the page, and the world become so beautiful tonight.




