WordPress plugins to remember

https://wordpress.org/plugins/duplicator/ The Duplicator gives WordPress administrators the ability to migrate, copy or clone a site from one location to another. The plugin also serves as a simple backup utility. The…

Comments Off on WordPress plugins to remember

Yii2 crib sheet (until I create some proper pages)

Creating URL Old way (Yii 1.0 maybe??) $url = Yii::$app->controller->createUrl('xx');// your own url generation logic New way (Yii 2.0 ) $url = \Yii::$app->getUrlManager()->createUrl('consignment/label'); Creating controllers Debugging (old skool) Yii::info("My message"…

Comments Off on Yii2 crib sheet (until I create some proper pages)

putting awstats live on a long hosted website

Search /home/awstats/DirData/ for any files relating to the domain you're dealing with and are newer than those for which you have logs. eg... ll /home/awstats/DirData/awstats*.www.example.com.txt ll /home/awstats/DirData/awstats*2015.www.example.com.txt and then either remove them…

Comments Off on putting awstats live on a long hosted website

WordPress harderning with apache

Installing WordFence #1 #2 gives you protection and great visibility into whats going on. It's easy to think no problems = no attacks, but after installing WordFence it was immediately obvious…

Comments Off on WordPress harderning with apache

MySQL automatically set created and lastupdated timestamps on columns

ALTER TABLE `tablename` ADD COLUMN `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD COLUMN `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; https://dev.mysql.com/doc/refman/5.6/en/timestamp-initialization.html https://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html Requires MySQL 5.6.5 or better

Comments Off on MySQL automatically set created and lastupdated timestamps on columns

SSL and Apache2.4

Generate private key openssl genrsa -out domainname.key 2048 Generate Signing Request openssl req -new -key domainname.key -out domainname.csr

Comments Off on SSL and Apache2.4

WordPress administration tips

Use WP-CLI (http://wp-cli.org/) Su to a non-privileged user # su -m www # wp core version 4.2.2 # wp core verify-checksums Success: WordPress install verifies against checksums. # wp core…

Comments Off on WordPress administration tips

How to check WordPress versions on your server are up to date

Original script at https://www.howtoforge.com/how-to-find-outdated-wordpress-versions-on-your-server-to-reduce-the-risk-of-being-hacked This script has been improved to automatically detect latest Wordpress version by sending a HTTP HEAD request to http://wordpress.org/latest and parsing the Content-Disposition: attachment; filename=wordpress-A.B.C.tar.gz result as suggested at https://wordpress.org/support/topic/programmatically-check-latest-wp-release <?php /**…

Comments Off on How to check WordPress versions on your server are up to date

Transfering MySQL database between hosts

The single command approach mysqldump -h oldhost -u oldusername -poldpassword olddbname | mysql -h newhost -u newusername -pnewpassword newdbname make sure you can ... mysql -h newhost -u newusername -pnewpassword…

Comments Off on Transfering MySQL database between hosts

FreeBSD, Fatal error: Call to undefined function geoip_country_name_by_name()

Getting Fatal error: Call to undefined function geoip_country_name_by_name() ? Install /usr/ports/net/pecl-geoip # cd /usr/ports/net/pecl-geoip && make install clean # "/usr/local/www/awstats/cgi-bin/awstats.pl" -update -config=account.ptiexpress.com -configdir="/usr/local/etc/awstats/" Error: Plugin load for plugin 'geoipfree' failed…

Comments Off on FreeBSD, Fatal error: Call to undefined function geoip_country_name_by_name()

my MySQL default configuration

my.cnf file. Try and use this before you start MySQL Server for the first time! [mysqld] log-output=TABLE expire_logs_days=1 general_log=ON general_log_file=/var/db/mysql/mysqld-queries.log slow_query_log=ON slow_query_log_file=/var/db/mysql/mysqld-slow-queries.log log_queries_not_using_indexes=ON log-error=/var/db/mysql/mysqld-error.log default-storage-engine=innodb innodb_file_per_table Run the following SQL…

Comments Off on my MySQL default configuration

MySQL function to calculate the distance between two latitude and latitude GPS pairs

CREATE DEFINER=`root`@`localhost` FUNCTION `FIND_DISTANCE`(`src_latitude` float,`src_longitude` float, `dest_latitude` float,`dest_longitude` float) RETURNS int(11) BEGIN /* This function takes four parameterss, two sets of latitude and latitude pairs and returns the distance between…

Comments Off on MySQL function to calculate the distance between two latitude and latitude GPS pairs

MySQL Logs – Selecting General Query and Slow Query Log Output Destinations

[mysqld] ... log-output=TABLE expire_logs_days=1 general_log=1 general_log_file=/var/log/mysqld-queries.log slow_query_log=1 slow_query_log_file=/var/log/mysqld-slow-queries.log ...   SET @old_log_state = @@global.general_log; SET GLOBAL general_log = 'OFF'; ALTER TABLE mysql.general_log ENGINE = MyISAM; SET GLOBAL general_log = @old_log_state;…

Comments Off on MySQL Logs – Selecting General Query and Slow Query Log Output Destinations

Add WordPress Admin user via MySQL query

// You may need to update the table names if a Wordpress table prefix has been set. INSERT INTO wp_users (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES…

Comments Off on Add WordPress Admin user via MySQL query

FreeBSD and phpList : White Screen of Death

Despite turning on errors in php.ini I wasn't getting any error messages when I went to http://ipaddress/lists/ or http://ipaddress/lists/admin/, I just received a white screen of death. After adding error_log() statements thoughout the code…

Comments Off on FreeBSD and phpList : White Screen of Death

’ characters or similar on your WordPress site

If you see random â€™ characters or similar on your Wordpress site its likely to be an encoding mismatch between your Wordpress installation and your MySQL database server. I did the…

Comments Off on ’ characters or similar on your WordPress site

degree2decimal

DROP FUNCTION IF EXISTS `degree2decimal`; CREATE DEFINER = `root`@`localhost` FUNCTION `degree2decimal`(deg_coord float) RETURNS float BEGIN #converts NMEA/GPS Lat -Long to Decimal Degrees. Code comments are self explanatory. #The code is…

Comments Off on degree2decimal

Your WordPress Metadata theme patch

<?php $meta_values = get_post_meta(get_the_ID()); $original_urls = ''; foreach ($meta_values['original_url'] as $url) { $original_urls .= "Original URL : <a href=\"$url\">$url</a><br />"; } ?>   <?php print "<small>$original_urls</small><br />"; ?>

Comments Off on Your WordPress Metadata theme patch

WordPress Security

SSL and Cookies in WordPress 2.6 HOWTO: Set up secret keys in WordPress 2.6+ Secret Key Generator

Comments Off on WordPress Security

PHP and MySQLi SELECT query

<?php $i = new mysqli('localhost', 'username', 'password', 'database'); if ($result = $i->query("SELECT * FROM tablename;") ) { printf("Select returned %d rows.\n", $result->num_rows); if ($result->num_rows > 0) { while ($row =…

Comments Off on PHP and MySQLi SELECT query

Creating PDFs from PHP

http://www.fpdf.org/ (Used on PTI and JMS) http://www.ros.co.nz/pdf/ Never used, but looks interesting.

Comments Off on Creating PDFs from PHP