November 22, 2017

phpBB Error: Can't connect to local MySQL server through socket Error

I was transfering phpBB forum from one hosting to another and experienced the phpBB Error:
"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") [2002]"
I was using local database on the old hosting and on the new hosting I wanted to connect to MySQL on the remote server. The problem was that config info on the new hosting was cached.

Solution
Open the /cache folder on the new server and delete all except .htaccess and index.htm. Than make sure you have a correct info in the config.php file(you can check it here: https://www.phpbb.com/support/docs/en/3.0/kb/article/rebuilding-your-configphp-file)

November 14, 2017

PostgreSQL upgrade from 9.6.5 to 10.1 on Mac OS X

I'm using Homebrew for installing and upgrading new software on Mac OS, which is quite easy to use, but sometimes I have to also upgrade something by hand. For example PostgreSQL. In PostgreSQL server log (/usr/local/var/postgres/server.log) I have found:


FATAL:  database files are incompatible with server

DETAIL:  The data directory was initialized by PostgreSQL version 9.6.5, which is not compatible with this version 10.1.

Homebrew updated it from version 9.6.5 to the last version 10.1, but I have to upgrade (initialize) data directory (upgrade my database files) also for version 10.1.

PostgreSQL is located in /usr/local/var, and homebrew data dir is located in /usr/local/Cellar/postgresql.

Run the following:


#switch to old postgres version
brew switch postgres 9.6.5    # presuming you already installed 10.1  

#backup your database data files 
pg_dumpall > outputfile

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

mv /usr/local/var/postgres /usr/local/var/postgres.old 

#switch to new postgres version
brew switch postgres 10.1

initdb -D /usr/local/var/postgres

pg_ctl -D /usr/local/var/postgres -l logfile start

#load your database data files again
psql -d postgres -f outputfile

December 5, 2016

Jasperreports - print Array or ArrayList horizontally

If you want to add any wraper to the report, just use "List" Component, but it is tricky to fill it from your Bean and print horizontally. Here is a working solution. I want to display on the "Product variant" page also "Product variant Sizes" in a horizontal List, first row are Sizes Names and the second row are available Sizes Count :
public class ProductVariant {
...
    private List selectedSizes;
...

}

public class SelectedProductVariantSize  {
...
    private int count;
    private ProductVariantSize size;
...
}

public class ProductVariantSize  {
...
 private String name;
        public String getName() {
  return name;
 }
...
}



in JRXML file, just add list, in "Appereance tab"set "Layouts" as "Vertical layout", in "List" tab set "Ignore Width" as true, and "Print Order" as Horizontal.
 



 
 
 
 
 
 
 
 
 
 
 
  
   <![CDATA[_THIS]]>
  
  
 
 
 
     
   
    
     
     
    
    
     
      <![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{selectedSizes})]]>
     
     
      
       
       
        
        
        
        
       
       
        
       
       <![CDATA[$F{size}.getSize().getName()]]>
      
      
       
       
        
        
        
        
       
       
        
       
       <![CDATA[$F{size}.getCount()]]>
      
     
    
   
  
 

The result:



 This solution is based on this answer and this answer.

November 21, 2016

Jasper Reports - Custom Font with the Font Extension

If you want to import custom font to the Jasper reports and getting for example this kind of error: (net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font:), just follow this article
http://community.jasper.oft.com/wiki/custom-font-font-extension
The important thing is NOT to fill-in "PDF Font name" when exporting JAR file. Another thing is that I was not able to use .OTF font file, just .TTF, strange thing...

October 14, 2016

Uploading image to the server via jQuery Ajax and php

I was solving a problem with uploading image to the server via jQuery Ajax. Finally I got a solution. HTML





CART


Javascript:




PHP script (just the simple solution, add some validation )

    //Custom data - Sent Via AJAX post method
    $file = $_POST['file']; //This is image sent via AJAX
    $fileName = $_POST['fileName'];    
    $brandingDesc = $_POST['brandingDesc'];
           
    $serverFile = time().$fileName;
 
    $uploads = wp_upload_dir();
    $upload_path = $uploads['basedir'];
 
    $serverFileName = $upload_path . "/" . $serverFile;
 
    //Get the base-64 string from data
    $filteredData=substr($_POST['file'], strpos($_POST['file'], ",")+1);
 
    //Decode the string
    $unencodedData=base64_decode($filteredData);
 
    //Save the image
    file_put_contents($serverFileName, $unencodedData);

October 5, 2016

New wordpress website

For one client we have created a new website based on the WordPress. Here you can find some plugins used:

Breadcrumb NavXT -
Adds a breadcrumb navigation showing the visitor's path to their current location.


Contact Form 7 -
Just another contact form plugin. Simple but flexible.

Bootstrap for Contact Form 7 - This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.


Duplicate Post -
Clone posts and pages.

Gallery -
Responsive image gallery with many views.

Loco Translate -
Translate themes and plugins directly in WordPress

Menu Image -
Provide uploading images to menu item

Newsletter -
Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business.

Projects -
project showcase plugin for WordPress. Show off your recent work using our shortcode, widget or template tag.

qTranslate-X -
Adds user-friendly and database-friendly multilingual content support.


Advanced Custom Fields
Customise WordPress with powerful, professional and intuitive fields
Advanced Custom Fields: qTranslate -
Provides multilingual versions of the text, text area, and wysiwyg fields.

Regenerate Thumbnails -
Allows you to regenerate all thumbnails after changing the thumbnail sizes.

Scroll Back to Top -
Adds a scroll to top button

Simple Custom CSS -
The simple, solid way to add custom CSS to your WordPress website. Simple Custom CSS allows you to add your own styles or override the default CSS of a plugin or theme.

Sitemap

Staff Directory -
Allows Wordpress to keep track of your staff directory for your website.

Superfly Menu -
Off-canvas hamburger menu for WordPress

Testimonials -
testimonials management plugin for WordPress. Show off what your customers or website users are saying about your business and how great they say you are, using our shortcode, widget or template tag.

WooCommerce -
An e-commerce toolkit that helps you sell anything.

WooCommerce & qTranslate-X -
Enables multilingual framework for plugin "WooCommerce".

WooCommerce Currency Switcher -
Currency Switcher for WooCommerce

WooCommerce Quick Donation -
Turns WooCommerce Into Online Donation

WP Add Custom CSS - Add custom css to the whole website and to specific posts, pages and custom post types.

Easy Smooth Scroll Links - Create anchors and add up to to 30 scrolling animation effects to links that link to page anchors. You can set scroll speed and offset value.

Login LockDown - Adds some extra security to WordPress by restricting the rate at which failed logins can be re-attempted from a given IP range.

wp-Typography - Improve your web typography with: hyphenation, space control, intelligent character replacement, and CSS hooks.

Clean Image Filenames - Filenames with special characters or language accent characters can sometimes be a problem. This plugin takes care of that by cleaning the filenames.

Advanced Custom Fields PRO - Advanced Custom Fields is the perfect solution for any WordPress website which needs more flexible data like other Content Management Systems.

FlowPaper - This is a PDF viewer plugin that allows you to embed your PDF catalogs, magazines and brochures as flipbooks on your web site in HTML5 format for free.

Force Strong Passwords - Forces privileged users to set a strong password.



             

June 14, 2016

Wordpress accesspress-parallax theme - add or update translation

I wanted to add a Czech translation to the wordpress theme, so there are some steps how to do it.
First of all, download PoEdit, editor for Wordpress translation.
Than go to the wp-content/themes/accesspress-parallax/languages on your FTP server.
There should be cs_CZ.po file with Czech translation, if it is missing, copy accesspress-parallax.pot (just english template) and open it in PoEdit app. For example if you want to translate button with text "Read more", than find this string and write your translation. Than save this file as cs_CZ.po file, and last but not least, export this file to "MO" file with "File->Compile to MO..." option.
Than copy both ".po" and ".mo" files back to the wp-content/themes/accesspress-parallax/languages folder.

May 23, 2016

Import of the certificate to the java Keystore

From certification authority we get three files:


Intermediate_CA_chain.cer (certificate chain)

SERVER_CERTIFICATE.cer (server certificate)

PRIVATE_KEY.key (private key)



  1. Conversion from PEM to PKCS#7
    on the page https://www.ssls.cz/converter.html is conversion PEM (.cer, .crt, .pem) to PKCS#7 (.p7b, .p7c, .p7s),
    (we will use server certificate = SERVER_CERTIFICATE.cer and Intermediate CA (Intermediate_CA_chain.cer)), so I made a .p7b file (NEW.p7b).

    Maybe the following command can be also used instead of the previous step with web form (I did not try this):

    
    
    openssl crl2pkcs7 -nocrl -certfile SERVER_CERTIFICATE.cer -out NEW.p7b -certfile Intermediate_CA_chain.cer),
    
    

    Finally I have created NEW.cer (our new certificate chain) file with following:
    
    openssl pkcs7 -print_certs -in NEW.p7b -out NEW.cer
    
    

    (maybe it could be OK to skip the step 1. and just use Intermediate_CA_chain.cer instead of the NEW.cer - I did not try this)
  2. Import of the private key (PRIVATE_KEY.key) and server certificate (SERVER_CERTIFICATE.cer) to the java keystore (game_keystore.jks)
    (https://secure.marumoto.us/motowiki/tiki-index.php?page=Import+a+private+key+and+certificate+into+a+Java+Keystore)

    
    openssl pkcs12 -export -in SERVER_CERTIFICATE.cer -inkey PRIVATE_KEY.key -out KEYSTORE.p12 -name game_key
    
    keytool -importkeystore -srckeystore KEYSTORE.p12 -srcstoretype PKCS12 -destkeystore game_keystore.jks
    
    
  3. Import of the chain of certificates to the SAME keystore (game_keystore.jks) with THE SAME ALIAS as in the previous step
    
    keytool -importcert -trustcacerts -alias game_key -file NEW.cer -keystore game_keystore.jks -storepass SECRET_PASSWORD -keypass SECRET_PASSWORD
    
    

      Finally it is possible to view the content of the final java keystore:

    
    keytool -list -v -keystore game_keystore.jks