https://www.digitalocean.com/community/tutorials/how-to-set-up-http-authentication-with-nginx-on-ubuntu-12-10
Monday, 18 August 2014
How To Set Up HTTP Authentication With Nginx
Nginx configuration file error
When restarting nginx after a configuration file change, if you get an error message that the configuration file has an error, you can get more info about the error with:
sudo nginx -t
sudo nginx -t
Tuesday, 5 August 2014
To get a mysql formatted datetime using javascript:
I couldn't find a simpler jQuery solution to this.
If you want the time according to the user's time zone, remove the "UTC" in the second last line of the code.
**
* You first need to create a formatting function to pad numbers to two digits…
**/
function twoDigits(d) {
if(0 <= d && d < 10) return "0" + d.toString();
if(-10 < d && d < 0) return "-0" + (-1*d).toString();
return d.toString();
}
/**
* …and then create the method to output the date string as desired.
* Some people hate using prototypes this way, but if you are going
* to apply this to more than one Date object, having it as a prototype
* makes sense.
**/
Date.prototype.toMysqlFormat = function() {
return this.getUTCFullYear() + "-" + twoDigits(1 + this.getUTCMonth()) + "-" + twoDigits(this.getUTCDate()) + " " + twoDigits(this.getUTCHours()) + ":" + twoDigits(this.getUTCMinutes()) + ":" + twoDigits(this.getUTCSeconds());
};
I couldn't find a simpler jQuery solution to this.
If you want the time according to the user's time zone, remove the "UTC" in the second last line of the code.
Monday, 28 July 2014
Set Timezone
This will set the timezone for all the php functions in a page. Put this at the top of a page:
date_default_timezone_set('Asia/Calcutta');
date_default_timezone_set('Asia/Calcutta');
Solve 5 annoying moodle problems
http://www.iteachwithmoodle.com/2012/11/16/solve-5-annoying-moodle-problems-quickly/
XMPP chat
Prosody is a good XMPP chat server. It can be installed from the distro repository.
A guide: http://www.techytalk.info/install-configure-prosody-xmpp-jabber-server-on-debian-ubuntu-linux/
There are many desktop clients for XMPP. There are a few web clients too: https://conversejs.org/ and http://candy-chat.github.io/candy/
https://conversejs.org/docs/html/
However, for these web clients to connect to the XMPP server, they need to use HTTP, so the XMPP server needs a plugin to communicate using xmpp over http, called BOSH: http://xmpp.org/extensions/xep-0124.html
The BOSH plugin for Prosody is: http://prosody.im/doc/modules/mod_bosh
Once the bosh-bind plugin is installed, a redirect should be setup in the web server (Apache or Nginx). This is because, converse.js must connect to the XMPP server (through bosh) at port 5280. However, browsers prevent authentication to this port because of same-origin policies (to prevent XSS). Therefore, the javascript can be made to authenticate to a particular directory which redirects the request to the correct url and port.
http://prosody.im/doc/setting_up_bosh
For integrating prosody with Wordpress, there is a plugin:
https://github.com/llun/wordpress-authenticator
However, this plugin requires wordpress to store passwords as md5 hashes (using a plugin) instead of phpass. Md5 hashes are very insecure so wordpress-authenticator cannot be used.
There is another prosody plugin for wordpress authentication: https://code.google.com/p/prosody-modules/wiki/mod_auth_wordpress
However, the code is alpha and development seems to have halted.
To integrate converse.js with a site that already uses authentication, one needs to use PHP prebinding: http://www.techytalk.info/other-projects/xmpp-bosh-toolkit/
http://stackoverflow.com/questions/3696165/get-xmpp-sid-and-rid-from-bosh-in-php
http://stackoverflow.com/questions/23264662/java-trying-to-prebind-converse-js-using-bosh-but-not-able-to-get-the-sid-and
https://github.com/candy-chat/xmpp-prebind-php/
Prosody: creating accounts: http://prosody.im/doc/creating_accounts
A guide: http://www.techytalk.info/install-configure-prosody-xmpp-jabber-server-on-debian-ubuntu-linux/
There are many desktop clients for XMPP. There are a few web clients too: https://conversejs.org/ and http://candy-chat.github.io/candy/
https://conversejs.org/docs/html/
However, for these web clients to connect to the XMPP server, they need to use HTTP, so the XMPP server needs a plugin to communicate using xmpp over http, called BOSH: http://xmpp.org/extensions/xep-0124.html
The BOSH plugin for Prosody is: http://prosody.im/doc/modules/mod_bosh
Once the bosh-bind plugin is installed, a redirect should be setup in the web server (Apache or Nginx). This is because, converse.js must connect to the XMPP server (through bosh) at port 5280. However, browsers prevent authentication to this port because of same-origin policies (to prevent XSS). Therefore, the javascript can be made to authenticate to a particular directory which redirects the request to the correct url and port.
http://prosody.im/doc/setting_up_bosh
For integrating prosody with Wordpress, there is a plugin:
https://github.com/llun/wordpress-authenticator
However, this plugin requires wordpress to store passwords as md5 hashes (using a plugin) instead of phpass. Md5 hashes are very insecure so wordpress-authenticator cannot be used.
There is another prosody plugin for wordpress authentication: https://code.google.com/p/prosody-modules/wiki/mod_auth_wordpress
However, the code is alpha and development seems to have halted.
To integrate converse.js with a site that already uses authentication, one needs to use PHP prebinding: http://www.techytalk.info/other-projects/xmpp-bosh-toolkit/
http://stackoverflow.com/questions/3696165/get-xmpp-sid-and-rid-from-bosh-in-php
http://stackoverflow.com/questions/23264662/java-trying-to-prebind-converse-js-using-bosh-but-not-able-to-get-the-sid-and
https://github.com/candy-chat/xmpp-prebind-php/
Prosody: creating accounts: http://prosody.im/doc/creating_accounts
Wednesday, 23 July 2014
Enable error display in PHP
error_reporting(E_ALL);
ini_set('display_errors','1');
ini_set('display_errors','1');
Subscribe to:
Posts (Atom)