↓
 

A Pipe and a Keyboard

A sort of Linux scrapbook

  • Home
  • About
  • Software
  • List of posts

Category Archives: Blogging

Post navigation

1 2 3 4 … 7 8 >>

WP phpMyAdmin Session mismatch

A Pipe and a Keyboard Posted on February 19, 2024 by RichardFebruary 19, 2024

I recently installed “WP phpMyAdmin” plugin on another WordPress site.

It’s an excellent plugin and saves the tedious business of logging into the hosting server to access the database.

On the second attempt to run the plugin however I ran into a problem –

Session mismatch.
Go back and click Enter phpMyAdmin button again. If you still experience issue, try to open a ticket at Support pages and provide some details.

After a fair bit of a search I came across a fix. Simply enter plugins/wp-phpmyadmin-extension/lib/phpMyAdmin_[followed by string of random characters] and delete the three files starting “_session_temp“

My next task is to write a small batch file to delete these without having to use FTP!

Posted in Blogging, Tech stuff | Leave a reply

Weaver Extreme Info Bar Spacing

A Pipe and a Keyboard Posted on December 16, 2018 by RichardDecember 17, 2018

I am a great fan of Weaver Extreme and its almost limitless variables and customisations.

One problem that irritated me though was the Info Bar, and in particular the Breadcrumbs.

Example 1 => Home→Books→Short Story Collections→Blackjack

To my eye, that looks cramped.  I needed a space each side of the arrows.  I tried a load of things such as trying CSS, searching forums and anywhere else I could think of.  No one else seemed to have the same problem.

Eventually I resorted to the sledgehammer approach: I changed the coding within Weaver.  I don’t like doing that as it has to be redone in the event of an update.  

The file is “themes/weaver-xtreme/includes/lib-runtime.php”.

The line to be changed ( search for ‘weaverx_breadcrumb’ ) is

$delimiter = apply_filters('weaverx_breadcrumb_delimiter', '→'); //' » ';

In fact a fix is almost in place there as there a commented alternative.  Either insert a space each side of  ‘& rarr’ or use the alternative supplied.  I chose the alternative.

Example 2 => Home » Books » Short Story Collections » Blackjack

I’m happy with that.

Posted in Blogging, Tech stuff | Leave a reply

Iframes not refreshing in WordPress pages

A Pipe and a Keyboard Posted on August 18, 2018 by RichardAugust 18, 2018

I run a couple of WordPress sites that contain IFRAMES.

The problem I had was that the content of the IFRAMES wasn’t updating when a visitor arrived at the site.  They would see content that was hours or even days out of date.

In each of my sites I was generating files which updated every ten to fifteen minutes.  This was done using a small programme that I wrote which generated small HTML files on the site itself.  The IFRAME was then used to display that HTML file.  However, caching in the site prevented that and insisted on dishing up a cached version which was out of date.

I took a two pronged approach.  

The first objective was to tell the IFRAME to load a different filename each time the page was loaded.  Obviously I couldn’t rename the origin file, so I added a parameter to the file request in the form “file.htm?t=X”.  Now X had to be different each time the page was loaded so I had to enable PHP on the page and then create a timestamp date(“U”) so that X would change every second.  

The resulting code appears as follows:

<?php
$cacheN=date('U');
echo("<iframe style='background-color: white;' src='/file.htm?cache=$cacheN' height='300'></iframe>");
?>

This will force the IFRAME to search for src=”/file.htm?cacheN=1534593560 or similar where the number changes every second.  The parameter “cacheN” will be passed to the file but as it is meaningless it will be ignored and file.htm will be loaded.

Naturally to run PHP on a WordPress page will require a plugin or a facility within the theme being used.

The second method I used (a belt and braces approach) was to add a line to the head of the page (which can either mean another plugin or manually editing your theme’s header.php file)

<link rel="preload" href="/file.htm" type="text/html">

Examples in action (on the righthand sidebars) –
https://martinscriblerus.com
https://headrambles.com/

Posted in Blogging, Tech stuff | 5 Replies

Rebuilding a WordPress site from nothing

A Pipe and a Keyboard Posted on September 19, 2017 by RichardSeptember 19, 2017

Some weeks ago I took on a project.

The project was to rebuild a major blog with next to nothing to start with.  The blog had been running for years and had an enormous following.  The author had been diagnosed with cancer some years ago but had continued her writings.  Last December she decided to discontinue the site, as her health was seriously deteriorated at that stage.  She erased the site.  Not long after, she expressed a sincere regret that the site was gone, and it was one of her dying wishes that somehow the site be restored.  Last August, she died without seeing that wish fulfilled.

I assumed there were some backups lying around and offered to restore the site to its former glory.  Unfortunately my assumption was wrong.  I contacted the company which had hosted the site.  Sorry!  We don’t keep backups that long.  So the call went out to see if anyone had miraculously got a backup of their own.

The first to respond was the blogger’s husband who was as anxious to restore the site as his wife had been. He announced that there were backups on the author’s PC.  I duly received 1,419 files (one per post) to find that they were all in MHT format.  MHT contains all the information for an individual page including HTML, JS, CSS and images.  However, MHT is not a universally recognised format so putting them on-line would only work in Internet Explorer (or in some other browsers with a specific add-on installed).  I had to find a way of extracting them, each into its component parts.

After some searching, I came across MHT2HTM which happily extracts the required contents and works on Linux.  I installed it and ran it.  It worked perfectly.

So I now had 1,419 folders, each containing everything required to reconstruct the posts.  However, files in folders – 59,337 files weighing 834Mb – are not very efficient as an archive.  They are bulky in the extreme and aren’t searchable and can’t be listed by anything other than folder name.  The answer was to extract the information from each folder, to move the image files to a central point and to populate a database with the correct information.

I set about writing a programme (in PHP).  The programme was simple enough in concept – it had to cycle through each folder, reading the HTML file and extracting al the required information to place in the database.  This meant stripping all the HTML off the file leaving just two parts – the post content and the comments.  These two were added so that the comments became part of the post.  That was moved to the database along with other information which had been extracted such as the author (there had been quite a few contributors to the site), the title, the name (slightly different to the title as far as the database is concerned) and the date of posting.

In the meantime I had taken over the domain name and had set up a server with a WordPress site.  I uploaded the database I had created and the first generation of the archive was live.

Also in the meantime I had received a few (!) more files from others who had had the foresight to backup some of the original.

One batch of 1,462 files was also in MHT format.  I ran that through MHT2HTM and I now had 1,462 folders.  Unfortunately the two archives had been saved using slightly different parameters so I couldn’t compare the two directly.  It would have to be done automatically.

I took my home-grown PHP setup and modified the code.  It now had to make sure that the record didn’t exist already from the first run.  This wasn’t quite so simple as because of the different parameters, there were some variations in post titles.  I had to generate a unique key for each post (which meant running the first batch again) and compare keys.  The key was simple enough – just strip all non-alpha-numeric characters from the title and replace spaces with dashes.

Next I had received some more copies of the site.  A couple had used WGET to download the site and a couple had used HTTrack..  These of course gave me a load of files all with different layouts and small but important differences in the HTML coding.

Once again I rewrote my PHP programme and updated the database.  I was now on a third and fourth generation of the site, each time adding a few more missing posts.

I had been dipping through the WayBack machine which had also sporadically taken copies of the site.  Then I discovered wayback-machine-downloader.  I downloaded and installed it and did a test run.  It seemed to do the job so I did a live run.  About eighteen hours later it finished.

Naturally, the downloader had dumped all its results into a series of folders with yet another layout.  This time I tried a different approach – I used “locate” to find the index files and piped the result into a file.  I discovered that if I created an array from that file using “explode” and “/” that the required files were to be found in all elements with a count of 12.  This made the job easier.  Once again, I used a modified version of the PHP programme to generate database entries.

I think I have gone as far as I can.  There are still some small tweaks to be made to the site, including a few duplicate posts that somehow crept in.  I still have to find some lost images as well, and maybe sort out additions to the various categories.

The result of all this effort can be found here:

The Anna Raccoon Archive.

 

Posted in Blogging, Linux, Tech stuff | 2 Replies

Keeping up to date

A Pipe and a Keyboard Posted on February 25, 2017 by RichardFebruary 28, 2017

This site has been somewhat quiet for a while.

Usually I post here on Linux related matters, but things have been very quiet on that front.  Instead I have been turning my attention to WordPress and hosting.

There is a major upheaval on the horizon with the arrival of PHP7.  Most sites currently run on PHP5 but a lot of coding has been depreciated and in 7 has been eliminated altogether.  So at some stage in the future, hosting companies are going to upgrade to PHP7 and sites across the board will suddenly lose a lot of functionality, or worse.

So I have been spending a considerable amount of time trawling through my sites (there's a lot of them) finding plugins that aren't PHP7 compatible.  A lot of them aren't.  Some of the latter are essential, in which case I contacted the authors and they updated their code (they were extremely grateful for the warning!).  Some plugins that were not so critical I just replaced with suitable alternatives and some I just left to chance.  The plugin I used in this part of the exercise is PHP Compatibility Checker.

Ultimately I made the switch on the majority of my sites, leaving just a few that as yet haven't got PHP7 as an option on the servers.  I hope to migrate those sites to newer servers in the coming weeks.

Another factor I have been working on is to upgrade sites to secure connections, as this another way the Internet is moving.  Google apparently intend to (or actually do) penalise non-secure sites.

The main problem with moving to SSL is the need for certificates, which are expensive and are beyond the scope of the hobbyist or even the small business.  The simple answer I found is to move all sites to CloudFlare Content Delivery Network.  As part of their free package they provide easily installable certificates.

Lastly (but by no means least) I used Weaver II as a theme builder on many of my sites.  While this was a very powerful theme creator/customiser it is now depreciated and has been replaced by Weaver Xtreme.  At first I found that the latter had a very steep learning curve and was reluctant to switch.  However I persevered and eventually found that Weaver Xtreme is immensely powerful and is far superior to the old Weaver.  It is also fully PHP7 compatible, uses more efficient coding and is therefore a lot faster.

In the course of all this work, I kept a stern eye on page speed, tweaking plugins (and replacing many) with an ultimate goal of getting every site on my books to load in under 3 seconds.  That was not easy.  One client in particular had a great fondness for sliding image galleries on his front page – six or seven of them.  On of those galleries alone contained 36 images, none of which was reduced in dimensions or compressed.  The overall size of the front page was well in excess of 50Mb.  Plugins and tweaks can do a lot, but this was the only case where I had to intervene and strongly suggest some alternative layouts!

So, as you can see, I haven't been idle! 

Posted in Blogging, Media, Tech stuff | Tagged Linux | Leave a reply

Post navigation

1 2 3 4 … 7 8 >>

Recent Posts

  • GRUB problems
  • Tab bar broken again in Firefox 133
  • WP phpMyAdmin Session mismatch
  • When Linux slows down
  • Firefox broken again

Categories

  • Blogging
  • General
  • Linux
  • Media
  • Tech stuff
  • Writing

Blogroll

  • Head Rambles
  • Kirk M's Just Thinkin'
  • Wordpress Beginner
  • Wordpress Development

Archives

©2025 - A Pipe and a Keyboard - Weaver Xtreme Theme
↑