Category Archives: Web Development

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 Duplicator supports both serialized and base64 serialized string replacement. If you need to move WordPress or backup WordPress this plugin can help simplify the process.… Read More »

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” , ‘scsdebug’); Yii::warning(“this->consignment_date=” . $this->consignment_date , ‘scsdebug’); Yii::warning(\DateTime::createFromFormat(‘d/m/Y’, $this->consignment_date) , ‘scsdebug’);

Category: Yii

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 (if you know you can recreate them) or move them to a temp location rm /home/awstats/DirData/awstats122015.www.example.com.txt mv /home/awstats/DirData/awstats*.www.example.com.txt /tmp/awstats.tmp/ Unzip all your log files cd… Read More »

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 how much attach my little old website was under – and not because it’s a popular site (far from it – I’m pretty sure I’m… Read More »

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

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

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 check-update Success: WordPress is at the latest version. # wp core update Plugsin # wp plugin status 4 installed plugins: UI akismet 3.1.1 A force-login-except-special-ip-range… Read More »

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 /** * find outdated wordpress versions * (c) 2014 howtoforge.com (M. Cramer) <m.cramer@pixcept.de> * Appended by Steve Scotter www.stephen-scotter.net */ if(!isset($argv[1])) die(“Please start this program with… Read More »

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 newdbname … before attempting the transfer. Common issues are :- Firewall preventing access to MySQL server across the network User configured to only be able… Read More »

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 with return code: Error: Can’t locate Geo/IPfree.pm in @INC (you may need to install the Geo::IPfree module) (@INC contains: /usr/local/lib/perl5/site_perl/mach/5.18 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.18/mach /usr/local/lib/perl5/5.18 /usr/local/lib/perl5/site_perl/5.18 /usr/local/lib/perl5/site_perl/5.18/mach… Read More »

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 script to update the logs to use MyISAM (instead of CSV!). SET @old_log_state = @@global.general_log; SET GLOBAL general_log = ‘OFF’; TRUNCATE TABLE general_log; ALTER TABLE… Read More »

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 to trackdown the issues I discovered that execution was getting as far as line 198 in /lists/admin/init.php Selec All Code:1   copying this to a… Read More »

’ 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 following to fix mine, your mileage may vary. 1. Confirm wp-config.php has the encoding set as UTF8.. /** Database Charset to use in creating database… Read More »

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 />”; ?>

WordPress Security

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

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 = $result->fetch_object()) { print_r($row); } } $result->close(); } else { printf(“%d : %s\n”, $i->errno, $i->error); } ?> if (!$i->query(“INSERT INTO table VALUES(null, ‘x’,’x’,’x’);” ) ) {… Read More »

Category: PHP

Creating PDFs from PHP

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

Category: PHP