form test plugin for b2evolution to prevent spams

by prettyscripts on 2013-04-22 00:41 • 1 feedback »

freephpb2evolution

no one likes getting spams. this blog has been getting lots of spams with non-sense messages until this plugin is installed. it can't prevent comments submitted manually and intentionally, but it prevents automated submissions.

i decided to develope this plugin since there isn't one available. well... there was one but it was for older versions of b2evo. i couldn't get it to work and now the link is broken. while i love b2evolution, its plugin directory is very outdated and it's frustrating you can't find anything up-to-dated.

please note that i haven't added this plugin to official plugin directory. it's not thoroughly tested and i need to tidy up codes.

this plugin simply adds a simple verification field to comment form. there are 2 types of verifications - alphanumeric text or simple 1-digit arithmetic calculation. comment will only be submitted if the correct random text is entered or the math calculation is answered correctly. both the text and math questions are generated randomly.

current version only adds the field to comment form. ideally it should applies to all forms. i will work on the other forms later.

logged in users will not see this field. 

this plugin is developed in b2evo V4 but has also been tested in V5-alpha. however captcha / turing feature has been added in V5 so you have the option to use the built-in feature or this for V5.

license

not sure which one to use. basically it's free. you can do whatever you want with it.

it's greatly appreciated if you could link back to this post and contribute a small donation (tip jar at top right section of the site).

releases

0.1 - initial beta release.

0.2 - simplify the random text and allows numeric answer to math question.

installation

  • download the plugin. untar.
  • upload the folder to plugins directory.
  • activate the plugin via plugins menu.
  • in plugin settings, choose verification type. verification prefix is simply for a hidden field in the form for verification purpose.

support

please report any issues to the project page so i can easily keep track of any problems.

if you have used this plugin on your site, i'd love to see it! please leave your links and let me know what you think in the comments.

ubuntu: setup apache2, php5 and mysql

by prettyscripts on 2013-04-12 01:56 • Send feedback »

unix

packages to install to run php:

Code:

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo service apache2 restart

some optional / useful php libraries to install:

Code:

sudo apt-get install php5-gd
sudo apt-get install php5-curl
sudo apt-get install php5-mysql
sudo service apache2 restart

to install mysql:

Code:

sudo apt-get install mysql-server
sudo service mysql start
sudo apt-get install php5-mysql
sudo service apache2 restart

yii: css file order with registerCssFile

by prettyscripts on 2012-08-30 11:02 • 1 feedback »

phpcssyii

in yii there are different ways to include stylesheets. it can be done by inserting html code into header page, as shown in default layout files (eg 'yii/protected/views/layouts/main.php). it can also be done by calling registerCssFile().

i've been using the html code method because that's the default when setting up a yii project.

recently i wanted to develop a new theme using foundation framework. i used the foundation 3 extension which does the hardwork and cuts down development time.

i ran into problem with presentation of the site when some pages has its own stylesheets.

the intended order of stylesheets should be foundation, theme and page. however it becomes foundation, page, theme. certain classes defined for the page becomes reset or overwritten by the theme specific stylesheet.

this is not the problem with extension but with how the files are included to the page with registerCssFile(). the method doesn't have option to specify the order. the foundation stylesheets and page specific stylesheets were included with this method, yet the theme specific stylesheet was included as html code in the main theme layout. even if the theme specific stylesheet was included with the method, the order was still wrong.

to ensure the page specific stylesheets comes after the default theme stylesheet, call registerCssFile() method in the controller.

ie, in <path to project>/yii/protected/components/Controller.php, add the code to init():

PHP:

public function init() {
    parent::init();
    Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl .'/css/main.css');
    // if you use theme, this includes theme specific stylesheet
    Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl .'/css/main.css');
}

the stylesheet orders now looks correct. at least on the current project i'm working on.

i came up with this solution while researching about the problem and ended up in this forum post. yii experts, let me know if this is not the correct way to do it.

css3: detecting devices with media queries

by prettyscripts on 2012-08-10 11:25 • Send feedback »

css

css3 has media queries that enables conditions to check device properties such as width, height and orientation and applies different stylesheets based on these conditions.

this is useful since we're able to browse via different devices with different sizes and we want to ensure the site is displayed optimally. ie, more legible.

very often i leave a site immediately if the website is not responsive when browsing from my mobile device. it's too much pain to zoom in, scroll left and right etc.

css3 markup template

here's a template for responsive websites, which detects screen different resolutions for desktops, and major mobile device and tablets:

CSS:

/* desktops */
@media screen and (max-width : 1024px) {
    ....
}
@media screen and (max-width : 800px) {
    ....
}
@media screen and (max-width : 640px) {
    ....
}
 
/* smartphones and iPhones */
@media screen and (min-width: 320px) and (max-width: 480px) {
    ....
}
/* iPad with landscape */
@media screen and (max-width: 1024px) and (orientation: landscape) {
    ....
}
/* iPad with portrait */
@media screen and (max-width: 768px) and (orientation: portrait) {
    ....
}

for further reading about css3 media queries and more variety of properties to use, read the w3c document.