Items filtered by date: December 2014

Wednesday, 13 December 2017 12:38

Proprietary Software Licenses and EULA

Proprietary software is computer software for which the software's publisher or another person retains intellectual property rights—usually copyright of the source code,[1] but sometimes patent rights.[2]. A Proprietry

A license for such software maintains the vendors rights tot hat software and affords the end user the use of the software under certain conditions and are usually aggreed to in a End User License Agreement (EULA).

For further information see these articles from Wikipedia

Examples of Proprietary Licenses

I have come across these examples of licenses.

  • RocketTheme Licenses - The RocketTheme Proprietary Use License (v1.3) and others. You should also look at their copyright notice for the site (link in the footer).
  • License & Terms of Service - JoomlaWorks
    • JoomlaWorks includes the following copyright notice in their code which points to this page.
      /**
       * @version     3.0.x
       * @package     Simple Image Gallery Pro
       * @author      JoomlaWorks - http://www.joomlaworks.net
       * @copyright   Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
       * @license     http://www.joomlaworks.net/license
       */
  • License | Artetics - This has really simple and easy to understand Proprietry Use License. There is also a DMCA statement.

Examples of Eula

  • RSComments - Terms and Conditions
    By checking this, you agree with the following:
    
    1. To accept full responsibility for the comment that you submit.
    2. To use this function only for lawful purposes.
    3. Not to post defamatory, abusive, offensive, racist, sexist, threatening, vulgar, obscene, hateful or otherwise inappropriate comments, or to post comments which will constitute a criminal offense or give rise to civil liability.
    4. Not to post or make available any material which is protected by copyright, trade mark or other proprietary right without the express permission of the owner of the copyright, trade mark or any other proprietary right.
    5. To evaluate for yourself the accuracy of any opinion, advice or other content.

 

Published in General

Getting Xdebug, Xampp and Netbeans to work together in Windows can be a tricky thing and I want to address that here. These instructions will get debugging working all on the same PC and IP.

A symptom of a PC that is not setup correctly is this Netbeans Socket Exception error. You get this error when Netbeans cannot communicate with Xdebug and is usually because you are running them both on the same computer and therefore IP so the traffic routing is getting mixed up. It could also because something else is running on the debug port you have selected.

Netbeans Socket Exception error

These Settings Work

These settings are what I am using now and work well.

Windows

  • You need to set a static IP on your ethernet adapter (or wifi)

php.ini

    • Use your static IP to set xdebug.remote_host. Setting a static IP seems to fix most connecion issues. xdebug does not like 127.0.0.1 it works sometimes but can be problematic.
    • Swapping xdebug.remote_port to 9001 helped when xdebug just stopped working. The default is 9000.
    • Disable output_buffering in your php.ini by altering/uncommenting the following line
      output_buffering = Off
    • Add the following code to the end of your php.ini file.
      [XDebug]
      
      zend_extension="D:\websites\php\ext\php_xdebug.dll"
      ;zend_extension="D:\websites\php\ext\php_xdebug-2.5.4-5.6-vc11.dll"
      xdebug.idekey = netbeans-xdebug
      xdebug.profiler_append = 0
      xdebug.profiler_enable = 0
      xdebug.profiler_enable_trigger = 0
      xdebug.profiler_output_dir = "d:\websites\tmp\xdebug"
      xdebug.profiler_output_name = "cachegrind.out.%t-%s"
      xdebug.remote_enable = 1
      xdebug.remote_autostart = 0
      xdebug.remote_connect_back = 0
      xdebug.remote_host = "192.168.1.160"
      xdebug.remote_port = 9001
      xdebug.remote_handler = "dbgp"
      xdebug.remote_mode = req
      xdebug.remote_log = "d:\websites\tmp\xdebug\xdebug_remote.log"
      xdebug.show_local_vars = 9
      xdebug.trace_output_dir = "d:\websites\tmp"
      
      ;xdebug.show_exception_trace = 1

      Minimum working settings

      These are the minimum settings I have found to work but are here only for reference.

      [XDebug]
      
      ;zend_extension="D:\websites\php\ext\php_xdebug.dll"
      zend_extension="D:\websites\php\ext\php_xdebug-2.5.4-5.6-vc11.dll"
      xdebug.remote_enable=1
      xdebug.remote_handler=dbgp
      xdebug.remote_mode=req
      xdebug.remote_host=192.168.1.160
      xdebug.remote_port=9001
      xdebug.idekey=netbeans-xdebug

Netbeans

(Tools --> Options --> PHP --> Debugging)

  • Debugger Port: 9001
  • Session ID: netbeans-xdebug
  • Maximum Data Length: 2048 - I think this is the default
  • Stop at First Line: off
  • Watches and Balloon Evaluation: All off
  • Show Requested URLs: off
  • Show Debugger Console: On

Browser

You need to send a trigger to Xdebug via your browser to trigger the debugger. You can send the trgger via GET/POST but you need a plugin for this.

Test Debugger is working

Now you have configured your system as above you need to test it before you can rely on it.

  • Set a breakpoint in Netbeans on the index.php (or a PHP file that is parsed) in your software project, preferably one before the content is displayed. (or you can enable the ‘Stop at First Line’ option in the Netbeans config
  • Start debugging in Netbeans
  • Open your project in a chrome browser with the xdebug helper plugin enabled
  • If the browser and Netbeans stop at the breakpoint, everything is working

Diagnostics

Things that Might help

If xdebug does not work straight away then trying these things might help.

  • could disabling ipv6 in the network adapter help? because xampp has issues with ipv6
  • xdebug might fail if you have multiple version of xampp running
  • Localhost is mapping to ::1 and not 127.0.0.1
  • Not all lines can act as breakpoints, these are displayed as cracked breakpoint markers in Netbeans. These breakpoints will not work because Netbeans does not like them. To fix this yoou should choose another breakpoint.
  • Run the Xdebug on another server which has another IP
  • Get the latest dll from xdebug site (i.e. php_xdebug-2.5.4-5.6-vc11.dll)
  • Comment out any zend extensions
  • Some people use port 9001 when they have issues with 9000.

Test the port is not already in use - dbgtest.php

This code is taken from 21.4.2 How to Set Up XDebug | Oracle

<?php
$address = '127.0.0.1';
$port = '9000';
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die();
socket_listen($sock);
$client = socket_accept($sock);
echo "Connection established: $client";
socket_close($client);
socket_close($sock);
?>

However I found this slightly better version from dbgtest.php · GitHub

<?php
// adapted from https://blogs.oracle.com/netbeansphp/entry/howto_check_xdebug_installation
$address = $argv[1] ?: '127.0.0.1';
$port = '9000';
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die();
echo "Listening to $address:$port\n";
socket_listen($sock);
$client = socket_accept($sock);
echo "Connection established: $client\n";
socket_close($client);
socket_close($sock);
  1. Create a php file with the code above called dbgtest.php and put it in the htdocs folder of your xampp server
  2. Change the port to 9001 if that is the port number you are using/diagnosing
  3. Enable sockets - extension=php_sockets.dll
    • only be need for the test script
    • You enable this by uncommenting the appropriate line in the php.ini
    • if you do not enable this you will get this error
      Call to undefined function socket_create()
  4. Close Netbeans if that is running.
  5. Restart Xampp
  6. Run the script

If there is something running on this socket you will get an error as shown below. This shows that some other process is using the port 9000.

Warning: socket_bind(): unable to bind address [10048]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in D:\websites\htdocs\dbgtest.php on line 5

Workarounds

These are a few workarounds I tried and might work for you. These are not designed to be a permanent fix.

Method 1

  • Make sure netbeans and xampp are not running
  • Put the basic xdebug settings in php.ini
  • Enable extension=php_sockets.dll in php.ini
  • Run xampp
  • Put a copy of the oracle script in your Webroot and run it. This causes xampp to open socket on 9000
  • Now open and run NetBeans debugging

* I am not sure if you need to do the IP fix aswell for this to work. It is all caused by routing issues on the loopback system of the PC. Or sockets might be needed.

Method 2

  • Turn of netbeans debugging (leave netbeans open)
  • Run the dbgtest.php to allow xampp/xdebug to grab the port
  • Now start netbeans debugging

Method 3 - (if working and then stops for no reason)

  • Close Netbeans, Xampp and browsers
  • Restart them all

Links

Published in xampp

This code is incredibly useful for going through an array and applying changes to the individual values without having to create a specific loop to perfom this action. In this example all apostrophes are escaped.

// Walk through the array and escape all apostophes (anonymous function)
array_walk($merged_config, function(&$value, &$key) {
    $value = str_replace("'", "\\'", $value);
});

this also works, without the &$key

// Walk through the array and escape all apostophes (anonymous function)
array_walk($merged_config, function(&$value) {
    $value = str_replace("'", "\\'", $value);
});

keep the '&' it is important. This creates a reference to the object in memory.

Published in PHP

When testing the translation system on QWcrm I needed to try different locales (languages) to see if the software actually worked how it should. The following are ways to change the HTTP_ACCEPT_LANGUAGE header that the browser sends to the webhost with its request.

FireFox

This will also fix the issue where Firefox was sending en-US instead of en-GB

Option 1 - Change the browser system settings

  • Goto (Tools menu --> Settings --> Content --> Languages)
  • Add English/United Kingdom [en-gb]
  • (optional) remove the other version of english. I do not know if this would cause issues so i have left them

Option 2 - re install

You can also just install Firefox with the correct locale.

Option 3 - Plugins

Using a plugin will allow you to easily change the settings on a temporary basis.

Chrome

Option 1 - Change the browser system settings

  • In the address bar type chrome://settings/ or click the 3 balls button-->settings
  • Open advanced section at the bottom
  • Goto languages
  • Install 'English (United Kingdom)' language
  • with 'English (United Kingdom)':
    • move to the top so it is first in the order of preference
    • set 'Display Google Chrome in this language'
    • set it as the language for spell checking
  • (optional) remove the other version of english. I do not know if this would cause issues so i have left them

Links

Published in Firefox

This is useful when you want to control the errors outputted tot he screen or is a class or some other code is not behaving as expected, such as the ADOdb error class.

The following code will preserve the current error reporting level so once your code has finished running the system's error reporting will be returned to its normal state.

// Get current PHP error reporting level
$reporting_level = error_reporting();

// Disable PHP error reporting (works globally)
error_reporting(0);

// Add you code here

// Re-Enable PHP error reporting
error_reporting($reporting_level);

 

Published in PHP
Tuesday, 12 December 2017 10:42

My Composer Notes

What is Composer?

This needs to be cleared up for us newbies. and to start with you will come across the following statements which are both true.

  • Composer is not a package manager
  • Composer is a dependency manager

Composer is not a package manager because you are not downloading complete software packages but dependencies/libraries for your own software package.

Composer is a cross-platform software package that can is used to manage libraries for your PHP software project allowing you to install, update and remove libraries/dependencies from a single point reducing the need to manually update all of the dependecies individually which reduces time and makes it easier to keep things upto date. composer calls on its own library to get the latest updates of the various depencies. A vendor of software can make their software available from this library for others to use.

It is composer of the program mentioned above to manage your dependecies and also a small library to control autoloading of classes and other things.

Composer is useful because some packages use mulitple dependancies to get them to work and composer allows you to always get the latest version of all of the packages, or specify package numbers for your project. This process also correctly sets up all the required includes up as needed. This can reduce the time needed to update all of the packages.

The Wonderful World of Composer - YouTube - This is brilliant video that will explain Composer completely.

How does it Work?

  • Installing Windows Composer  does the following
    • Installs Composer
    • Puts the Composer binary into path
    • autodetects your php.exe and allows you to choose which if you have more than one.
  • Files
    • Composer installs all of the libraries usually to a folder called /vendor/ and is controlled by a single JSON text file which is parsed by the particular version of Composer you are using.
    • Each package that is downloaded is registered with the Composer framework.
    • There is sha-1 string for both the whole 'Composer vendor library' and for the inidividual dependencies which are stored in the composer.lock file. this allows the tracking of the various assets to see if they have been updated or just to compare against packages withing the Packagist repository.
    • composer.json - Is the control files used for the composer packages used within your project. This file allows multiple packages to be downloaded and combined
    • The standard folder to use is /vendor/
    • All dependecies will be installed into the vendor folder. they all have a unique name so collisions will not be an issue.
  • Commands
    • Run the command  composer install in the folder where you want you dependencies to be installed and if the composer.json file is present it will use it for instruction.
    • I can install motranslator by navigating to where i want it and typing composer require phpmyadmin/motranslator as you can see this has the require command in the string.
    • This gets the latest stable version of the called software, in the case motranslator - composer require phpmyadmin/motranslator
    • composer require phpmyadmin/motranslator from the Windows commandline will add this dependency to your Composer library, or build a new library if there is not one already there.
  • You only need to include the autoload.php once in your software project and composer will load all dependancies. This is all you need in your PHP project to get Composer.
    require vendor/autoload.php
Published in PHP

When using mPDF to generate a PDF from a template it renders one or more tables and the fonts within them smaller than what they are in the template.

Cause

Look at the code below:

<!-- Invoice details -->
<td valign="top" align="right" width="200">
    <table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse;">
        <tr>
            <td valign="top" width="90%" align="right"></td>
            <td align="top" class="olotd5" width="200">
                <table width="180" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
                    <tr>
                        <td>
                            <b>{t}Invoice ID{/t} - </b>{$invoice_details.invoice_id}<br>
                            <b>{t}Status{/t} - </b>{$workorder_details.status}<br>
                            <b>{t}Date{/t} - </b>{$invoice_details.date|date_format:$date_format} <br>
                            <b>{t}Due Date{/t} - </b>{$invoice_details.due_date|date_format:$date_format}<br>
                            <b>{t}Work Order{/t} - </b>{$invoice_details.workorder_id}<br>
                            <b>{t}Technician{/t} - </b>{$employee_details.display_name}<br>                                        
                            <b>{t}Credit Terms{/t} - </b>{$customer_details.credit_terms}<br>                                       
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</td>

 and you can see this line.

<td valign="top" width="90%" align="right"></td>

mPDF cannot handle this empty cells with sizing statements.

Solution

I removed this line and then the template was rendered correctly.

Published in PHP
Sunday, 10 December 2017 13:04

My dhtmlxCombo Notes

These are some notes I made while integrating dhtmlxCombo into QWcrm.

  • in the package the code you want is ../codebase/
  • this codebase is prefilled with the dhxcombo_material skin
  • you don't need ../codebase/dhtmlxcombo_deprecated.js
  • you dont need ../codebase/fonts/ ? - doesnt seem to be called for what i use
  • fontawesome, dunno what this is for, again, something else
  • to add a new skin goto ../skins/ and into the folder of the skin you want. copy these files to ../codebase/ - the css will be overwritten
  • for QWcrm I use skyblue
  • only these JS and CSS are needed
    <script src="/{$theme_js_dir}dhtmlxcombo/dhtmlxcombo.js"></script>
    <link rel="stylesheet" href="/{$theme_js_dir}dhtmlxcombo/fonts/font_roboto/roboto.css"/>
    <link rel="stylesheet" href="/{$theme_js_dir}dhtmlxcombo/dhtmlxcombo.css">
  • roboto.css is for foreign characters, it might be used - cant be sure. i have not needed it yet
  • If existing select object was defined as parent - dhtmlxCombo will take all data from it (list of options, sizes, tabindex, name)

Example code I used in QWcrm

// This Call Transforms the Select Element by ID to a real Combo Box
var combo = dhtmlXComboFromSelect('description['+ iteration+']');

// This Call Transforms the Select Element by ID to a real Combo Box
 var combo = dhtmlXComboFromSelect('rate['+ iteration+']');
  • The code above auto resizes the combobox
  • var combo = can be removed unless you want to add options
var combo = dhtmlXComboFromSelect('rate['+ iteration+']');
combo.setSize(90);             // This sets the width of the combo box and drop down options width
//combo.setOptionWidth(200);    // this sets the width of the options drop down ONLY

Links

Published in Javascript
Sunday, 10 December 2017 12:50

My Keep a Changelog Notes

These are my note for Keep a Changelog

Version Number Links

The links on the version number [1.0.0] will not work unless they have the corresponding link below i.e.

[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
[0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0
Published in General
Saturday, 09 December 2017 14:47

Joomla White Screen of Death

Published in Joomla
Page 12 of 95