White Sceen of death on Cordova iOS but not browser

Today I was getting a white screen when trying to simulate my latest Cordova App on iOS using XCode 11.
The debug messages weren’t helpful.

NSURLConnection finished with error - code -1100
2019-11-03 18:41:25.312124+0000 Plumbers Mate[9951:3513187] Finished load of: file:///Users/Andy/Library/Developer/CoreSimulator/Devices/6B89E196-7C29-4879-A5C3-1749D1063D16/data/Containers/Bundle/Application/76725DD0-4577-4BC9-8192-0E6A92394C9D/Plumbers%20Mate.app/www/index.html

I spent ages Googling “NSURLConnection finished with error – code -1100” to discover it was there in other apps and irrelevant.

Then I finally found this article https://geeklearning.io/apache-cordova-and-remote-debugging-on-ios/

So you can use Safari to do the same kind of Inspect Console that Chrome does when using the browser platform.

Open Safari and then click on Sarfari>Prefences>Advanced
Make sure “Show Develop menu in menu bar” is checked…

Debug setup for Safari

There’s some more steps in the article if you want to debug a connected device, but I’m still trying to get my app to work in the Simulator.

Then to debug what’s in the Xcode Simulator, go to Safari>Developer and pick the Simulator..

Then I found my issue immediately!

Found the error!

It turns out it was a case issue in the file name – index.html was calling customerService.js, but the file was CustomerService.js – didn’t matter on the browser platform, but sure does on iOS!

How to stop people using a weak password in WordPress

I was once with a client who changed their password for a government website to “password2016” and the website let them do it too! Thankfully,
Wordpress gives you a message to warn a user that a password is weak, but it allows users to check a box to override the warning. Noooooo!

I don’t want to allow users to create weak passwords, so what I want is that line “Confirm Password”, allowing a user to use a weak password to be disabled. Like so…

Turns out it is pretty simple to do with some CSS and javascript.

.pw-weak{display:none}

Stops the line appearing and this javascript snippet

document.getElementById("pw-checkbox").disabled = true;

ensures the checkbox is disabled.

Add this to your theme, or use this simple and lightweight plugin I created to block the creation of weak passwords on WordPress. Right click to download and upload to your website plugins and activate.

You may want to force all current users to have strong passwords at the same time, by using my emergency password reset plugin.




Restricting WordPress search

I needed to stop certain content appearing in any search on a WordPress so here’s how…

function my_no_restricted($search,$wp_query)
{
global $wpdb;
if ( empty( $search ) )
return $search;
$q = $wp_query->query_vars;
$n = ! empty( $q['exact'] ) ? '' : '%';

$searchand = ' AND ';
foreach ( (array) $q['search_terms'] as $term ) {
$term = esc_sql( $wpdb->esc_like( $term ) );
$search .= "{$searchand}($wpdb->posts.post_content NOT LIKE '%DONT SEARCH ME%')";
$searchand = ' AND ';
}
return $search;
}
add_filter( 'posts_search', 'my_no_restricted', 500, 2 );

Replace DONT SEARCH ME with whatever you want to prevent being searchable!
Just pop it in a theme/plugin function.php file

JQuery real world form clone script

I wanted to be able to clone form elements easily include checkboxes and radio buttons, which are themselves an array. My offering below appends an incremented number to the name of each field along with how many to expect on submission for easy processing..
How to use it
1) Enclose the elements you want to be able to clone in <div class=”clonearea” id=”input1″></div>
2) Give an id for each form element that is the field name without appended number…
3) Append each name with 1

and here’s the jQuery magic

Bible Books Array in PHP

Here’s an array of all the Bible books in common abbreviations…

array(
1=>array('Genesis','Gen','Ge','Gn'),
2=>array('Exodus','Exo','Ex','Exod'),
3=>array('Leviticus','Lev','Le','Lv'),
4=>array('Numbers','Num','Nu','Nm','Nb'),
5=>array('Deuteronomy','Deut','Dt'),
6=>array('Joshua','Josh','Jos','Jsh'),
7=>array('Judges','Judg','Jdg','Jg','Jdgs'),
8=>array('Ruth','Rth','Ru'),
9=>array('1 Samuel','1 Sam','1 Sa','1Samuel','1S','I Sa','1 Sm','1Sa','I Sam','1Sam','I Samuel','1st Samuel','First Samuel'),
10=>array('2 Samuel','2 Sam','2 Sa','2S','II Sa','2 Sm','2Sa','II Sam','2Sam','II Samuel','2Samuel','2nd Samuel','Second Samuel'),
11=>array('1 Kings','1 Kgs','1 Ki','1K','I Kgs','1Kgs','I Ki','1Ki','I Kings','1Kings','1st Kgs','1st Kings','First Kings','First Kgs','1Kin'),
12=>array('2 Kings','2 Kgs','2 Ki','2K','II Kgs','2Kgs','II Ki','2Ki','II Kings','2Kings','2nd Kgs','2nd Kings','Second Kings','Second Kgs','2Kin'),
13=>array('1 Chronicles','1 Chron','1 Ch','I Ch','1Ch','1 Chr','I Chr','1Chr','I Chron','1Chron','I Chronicles','1Chronicles','1st Chronicles','First Chronicles'),
14=>array('2 Chronicles','2 Chron','2 Ch','II Ch','2Ch','II Chr','2Chr','II Chron','2Chron','II Chronicles','2Chronicles','2nd Chronicles','Second Chronicles'),
15=>array('Ezra','Ezra','Ezr'),
16=>array('Nehemiah','Neh','Ne'),
17=>array('Esther','Esth','Es'),
18=>array('Job','Job','Job','Jb'),
19=>array('Psalm','Pslm','Ps','Psalms','Psa','Psm','Pss'),
20=>array('Proverbs','Prov','Pr','Prv'),
21=>array('Ecclesiastes','Eccles','Ec','Ecc','Qoh','Qoheleth'),
22=>array('Song of Solomon','Song','So','Canticle of Canticles','Canticles','Song of Songs','SOS'),
23=>array('Isaiah','Isa','Is'),
24=>array('Jeremiah','Jer','Je','Jr'),
25=>array('Lamentations','Lam','La'),
26=>array('Ezekiel','Ezek','Eze','Ezk'),
27=>array('Daniel','Dan','Da','Dn'),
28=>array('Hosea','Hos','Ho'),
29=>array('Joel','Joel','Joe','Jl'),
30=>array('Amos','Amos','Am'),
31=>array('Obadiah','Obad','Ob'),
32=>array('Jonah','Jnh','Jon'),
33=>array('Micah','Micah','Mic'),
34=>array('Nahum','Nah','Na'),
35=>array('Habakkuk','Hab','Hab'),
36=>array('Zephaniah','Zeph','Zep','Zp'),
37=>array('Haggai','Haggai','Hag','Hg'),
38=>array('Zechariah','Zech','Zec','Zc'),
39=>array('Malachi','Mal','Mal','Ml'),
40=>array('Matthew','Matt','Mt'),
41=>array('Mark','Mrk','Mk','Mr'),
42=>array('Luke','Luk','Lk'),
43=>array('John','John','Jn','Jhn'),
44=>array('Acts','Acts','Ac'),
45=>array('Romans','Rom','Ro','Rm'),
46=>array('1 Corinthians','1 Cor','1 Co','I Co','1Co','I Cor','1Cor','I Corinthians','1Corinthians','1st Corinthians','First Corinthians'),
47=>array('2 Corinthians','2 Cor','2 Co','II Co','2Co','II Cor','2Cor','II Corinthians','2Corinthians','2nd Corinthians','Second Corinthians'),
48=>array('Galatians','Gal','Ga'),
49=>array('Ephesians','Ephes','Eph'),
50=>array('Philippians','Phil','Php'),
51=>array('Colossians','Col','Col'),
52=>array('1 Thessalonians','1 Thess','1 Th','I Th','1Th','I Thes','1Thes','I Thess','1Thess','I Thessalonians','1Thessalonians','1st Thessalonians','First Thessalonians'),
53=>array('2 Thessalonians','2 Thess','2 Th','II Th','2Th','II Thes','2Thes','II Thess','2Thess','II Thessalonians','2Thessalonians','2nd Thessalonians','Second Thessalonians'),
54=>array('1 Timothy','1 Tim','1 Ti','I Ti','1Ti','I Tim','1Tim','I Timothy','1Timothy','1st Timothy','First Timothy'),
55=>array('2 Timothy','2 Tim','2 Ti','II Ti','2Ti','II Tim','2Tim','II Timothy','2Timothy','2nd Timothy','Second Timothy'),
56=>array('Titus','Titus','Tit'),
57=>array('Philemon','Philem','Phm'),
58=>array('Hebrews','Hebrews','Heb'),
59=>array('James','James','Jas','Jm'),
60=>array('1 Peter','1 Pet','1 Pe','I Pe','1Pe','I Pet','1Pet','I Pt','1 Pt','1Pt','I Peter','1Peter','1st Peter','First Peter'),
61=>array('2 Peter','2 Pet','2 Pe','II Pe','2Pe','II Pet','2Pet','II Pt','2 Pt','2Pt','II Peter','2Peter','2nd Peter','Second Peter'),
62=>array('1 John','1 John','1 Jn','I Jn','1Jn','I Jo','1Jo','I Joh','1Joh','I Jhn','1 Jhn','1Jhn','I John','1John','1st John','First John'),
63=>array('2 John','2 John','2 Jn','II Jn','2Jn','II Jo','2Jo','II Joh','2Joh','II Jhn','2 Jhn','2Jhn','II John','2John','2nd John','Second John'),
64=>array('3 John','3 John','3 Jn','III Jn','3Jn','III Jo','3Jo','III Joh','3Joh','III Jhn','3 Jhn','3Jhn','III John','3John','3rd John','Third John'),
65=>array('Jude','Jude','Jud'),
66=>array('Revelation','Rev','Re','The Revelation')
);

Setting up mail on MAMP on El Capitan

I’ve only recently switched over to Macs and have found setting up mail sending on the MAc’s MAMP as hard as Windows! So here’s how.

Firstly it all needs to be down in the “Terminal” – so click on Finder, then Applications, then Utilities to open a terminal (looks pretty similar to Windows CMD!)

Check a program called Postfix exists by typing

Postfix

That should give you the following errors – which for once is good news!
postfix: error: to submit mail, use the Postfix sendmail command
postfix: fatal: the postfix command is reserved for the superuser

Next we can start configuring for gmail – but first head over to you gmail account to set up using for less secure apps

In the terminal type or copy and paste
sudo vi /etc/postfix/main.cf

Than type your password and enter.
Scroll down and check the following lines exist…

mail_owner = _postfix
setgid_group = _postdrop

Editing took some googling for me as it is not intuitive! Here’s a cheatsheet
i) To delete – put the cursor over the character and press x
ii) To start inserting – place your cursor and press i, then start type or use copy (CTRL C) and paste (CTRL V).
To exit with out saving press key and then :q
To exit with saving press and then :wq

At the bottom of the file add the following

# Use Gmail SMTP
relayhost = smtp.gmail.com:587
smtp_sasl_mechanism_filter = plain
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
tls_random_source = dev:/dev/urandom

You can change the relayhost to whatever server you like, I’m using gmail.
We need to create a gmail username/password file. So save and exit the main.cf file – , followed by :wq

Type
sudo vim /etc/postfix/smtp_sasl_passwd

and press i to start inserting again and add the following line

smtp.gmail.com:587 your_username@gmail.com:your_password

Save the file using :wq
Now we need to get it turned into what postfix wants by typing

sudo postmap /etc/postfix/smtp_sasl_passwd

Next we need to set it up for TLS

sudo vim /etc/postfix/smtp_tls_sites
Press i to start editing and add

[smtp_gmail.com]:587 MUST_NOPEERMATCH

Save :wq

And then type

sudo postmap /etc/postfix/smtp_tls_sites

And then sudo postfix start

Now we just need to test it all!
echo "Test sending email from Postfix" | mail -s "Test Postfix" youremail@domain.com

A quick php script to test from your MAMP server



Lastly to make these changes work for starting up your mac we need to do some more worrk, changing a file called /System/Library/LaunchDaemons/org.postfix.master.plist
which is read only because it is being used!

sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist stops it!
Add the following before
RunAtLoad
KeepAlive

And then restart the daemon thingie…
sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist

Hope that helps you!

WordPress 4.5.2 produced database errors

I just updated a clients WordPress website to 4.5.2 this evening and immediately experienced database errors around the category listing.

The wp-termmeta table was missing.

Thankfully if you can get into phpmyadmin, the fix is simple. Select the database, click on “SQL” and run this

CREATE TABLE IF NOT EXISTS wp_termmeta (
meta_id bigint(20) unsigned NOT NULL,
term_id bigint(20) unsigned NOT NULL DEFAULT '0',
meta_key varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
meta_value longtext COLLATE utf8_unicode_ci
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Change the wp_ as necessary!

Urgent Update

If you are using a version of the church admin plugin older than 0.810, please update immediately!
Two security vulnerabilities to older versions have been discovered – one of which has a “proof of concept” youtube video public.
Essentially, people with more time and less godliness than they would have in Christ, could insert some Javascript code into the address field of the [church_admin_register] shortcode when they fill the form in or into the “new sermon series” input field in the sermon podcast admin area.

Potentially that could be used to steal cookies and fake your login. It’s called a “Stored XSS vulnerability”

v0.810 stops that and renders any previous attempts harmless.

There’s no evidence that anyone has used the exploit yet, but now it’s public, they may on your site if you don’t update now! Please update even if you don’t use those features as v0.810 has been thoroughly checked for that vulnerability in all it’s features.

Gazzas Clothing Store

Gazzas Clothing StoreA client wanted a simple Paypal based ecommerce site, so I built him www.gazzasclothingstore.co.uk. He had been using ebay and had some WordPress experience, so wanted a simple interface.


It features

  • a  responsive theme that looks great on all devices
  • Simple product entry, image upload and stock control.
  • Product categories
  • Paypal instant payment notification back end.

Why not take a a href=”http://www.gazzasclothingstore.co.uk”>look?