Wednesday, June 12, 2019

How to setup Reverse Proxy account on xsl.tel

Hi there,

if you would like to use reverse proxy service to hide your website IP, bypass firewall restrictions (if you have a service running on non-standard port) , cache your static images.

you can always use xsl.tel reverse proxy for this task.

I'm not getting into details on how to order as that should be common sense already I'm going into how to set it up with your domain.

First step after you complete your order you will need to use nameservers provided by xsl.tel with your domain.
Second step login to your control panel received and go to
Domain Setup -> mydomain.com
on this page just set your backend to your real http server/port to something like
http://192.168.2.3:8080

it's as simple as that .

Sunday, May 26, 2019

WHMCS sell in multiple currencies for the same client


# Hi there,
# So recently I ran into this weird scenario where I had to sell Product A in USD and Product B in EUR for same client on my website xsl.tel. (
in current WHMCS currency system the client can choose 1 currency at registration and have to create new account using new Email to use another currency)
)
# Unfortunately WHMCS don't have such feature due to its core design (database structure) and I couldn't find an addon to help with this scenario.
# I had to use my brain to figure out something so I came up with this solution .
# Basically we will use our licensed WHMCS installation to work with multiple databases based on client cookie we set through a small php script and then redirect coming client to requested WHMCS page.

# Pros
# * -> With this solution you can share your current clients with sub installations through DB Views (or you can your clients spreaded over multi databases)  .
# * -> You can run unlimited numbers of WHMCS licenses on same installation (testing, developing, etc...) .
# * -> You can have multi-currency / multi-language WHMCS installations .
# * -> You can run cron for every new system you create.

# Cons
# * -> Reply-to-answer ticket feature via pipe is lost because you can't pass parameter to pipe.php file. (however it is possible through pop3 import feature).
# * -> Paypal IPN won't work on sub installations (it send IPN to main installation only).
# * -> It may not work with a few modules .I didn't test everything.
# * -> you can login to one system per browser for both admin/client .
# * -> Enabling WHMCS auto data retention removed my clients data when I did the optional step of merging both system clients data .


# Let's get to work
# You will need to create new database with our main whmcs db in this tutorial its called eudb_name
# Below steps assumes that you already have installed WHMCS and don't have any data on it .
# Edit your configuration.php as follows (don't forget to change database name, database usernames, db user passwords) .
//======= BEGIN of configuration.php content
<?php
$license = 'YOURLICENSE';
$db_host = 'localhost';
switch($_COOKIE['clientbase']) {
    case "us":
        $db_username = 'usdb_usr';
        $db_password = 'usdb_password';
        $db_name = 'usdb_name';
        $cc_encryption_hash = 'some_random_chars_here';
        $mysql_charset = 'utf8';
        $attachments_dir = "/path/to/us/attachments";
        $downloads_dir = "/path/to/us/downloads/";
        $templates_compiledir = "/path/to/us/templates_c/";
        break;
    case "eu":
        $db_username = 'eudb_usr';
        $db_password = 'eudb_password';
        $db_name = 'eudb_name';
        $cc_encryption_hash = 'some_random_chars_here';
        $mysql_charset = 'utf8';
        $attachments_dir = "/path/to/eu/attachments";
        $downloads_dir = "/path/to/eu/downloads/";
        $templates_compiledir = "/path/to/eu/templates_c/";
        break;

    // if no cookie is set then we pass default us db to our client
    default:
        $db_username = 'usdb_usr';
        $db_password = 'usdb_password';
        $db_name = 'usdb_name';
        $cc_encryption_hash = 'some_random_chars_here';
        $mysql_charset = 'utf8';
        $attachments_dir = "/path/to/us/attachments";
        $downloads_dir = "/path/to/us/downloads/";
        $templates_compiledir = "/path/to/us/templates_c/";
        break;

}
//======= END of configuration.php content

# Then in your public html folder create a new folder and let's call it "us"
# and create .htaccess and index.php files and edit them as follows

#======= BEGIN of .htaccess content
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?uri=$1 [QSA,PT,L]

#======= END of .htaccess edit

# make sure to change domain in cookie you set and the url of your whmcs installation
//======= BEGIN of index.php content
<?php<?php
setcookie("clientbase", "us",NULL, "/", "xsl.tel", 1, 1);
$args = $_REQUEST;
unset($args['uri']);
$newArgs= array();
foreach($args as $key => $value) {
    $newArgs[] = "{$key}={$value}";
}
$queryargs = implode('&',$newArgs);
header("Location: https://my.
xsl.tel/{$_GET['uri']}?{$queryargs}");
//======= END of index.php content

# now create another folder and let's call it "eu" for our EUR currency create same files except changing index.php as follows (just change cookie value from us to eu so our configuration.php serve eudb_name)
//======= BEGIN of index.php content
<?php
setcookie("clientbase", "eu",NULL, "/", "
xsl.tel", 1, 1);
$args = $_REQUEST;
unset($args['uri']);
$newArgs= array();
foreach($args as $key => $value) {
    $newArgs[] = "{$key}={$value}";
}
$queryargs = implode('&',$newArgs);
header("Location: https://my.
xsl.tel/{$_GET['uri']}?{$queryargs}");//======= END of index.php content

# MySQL work
# now you have to mysqldump/export your current whmcs database (usdb_name) in this tutorial and import it on our (eudb_name) or whatever your new db_name

# now if you navigate to your whmcs.domain/eu/ (change name to something different to see if it differs from whmcs.domain/us/) .
# If everything works as expected let's continue to setting up cron jobs for new systems.

# Looks like we can't pass cookie through command line so we will run cron through wget using this command  (don't forget to change domain)
#======= BEGIN of cron job
*/5     *     *     *     *     wget -O /dev/null https://my.xsl.tel/us/crons/cron.php
> /dev/null 2>&1
*/5     *     *     *     *     wget -O /dev/null https://my.xsl.tel/eu/crons/cron.php
> /dev/null 2>&1
 #======= END of cron job

# Only use if you want to use pop3 import feature to import tickets to your sub-systems
#======= BEGIN of cron job
*/5     *     *     *     *     wget -O /dev/null https://my.xsl.tel/us/crons/pop.php > /dev/null 2>&1
*/5     *     *     *     *     wget -O /dev/null https://my.xsl.tel/eu/crons/pop.php
> /dev/null 2>&1
 #======= END of cron job

# For security reasons you may want to restrict accessing /crons/ folder from your server IP only to avoid bots bombing your cron.php with requests so create .htaccess file with following directives
#======= BEGIN of .htaccess content
Order Allow,Deny
Allow from IP-OF-SERVER 127.0.0.1

#======= END of .htaccess content

# Login to our new /eu/ whmcs admin panel and change currency to EUR and WHMCS system url to corresponding folders we created above and you are done.

# Optional Step merging clients & contacts of main usdb_name and eudb_name RUN this query in mysql as root/permitted user for both databases
#======= BEGIN of MySQL Clients merge
DROP TABLE eudb_name.tblclients;
CREATE VIEW eudb_name.tblclients AS SELECT * FROM usdb_name.tblclients;


 DROP TABLE eudb_name.tblcontacts;
CREATE VIEW eudb_name.tblcontacts AS SELECT * FROM usdb_name.tblcontacts;

#======= END of MySQL Clients merge


Friday, February 1, 2019

Google Analytics Console not working for new accounts

UPDATE : Issue has been fixed by google on 02/02/2019.

Today I tried to setup Google analytics for this blog using a newly created account. however looks like Analytics Console is encountering some weird bug with AngularJS Service Dependency Injection .

to reproduce this issue try to login to an account with no Analytics enabled through this URL :
https://analytics.google.com/analytics/web/provision/

it will hang at this page
Figure 1
In console you can see this url pointing to angularjs docs with 404 error .
http://errors.angularjs.org/1.6.4-local+sha.617b36117/$injector/unpr?p0=firebaseProjectQuotaProvider%20%3C-%20firebaseProjectQuota

apparently google is using internal AngularJS version and that's why we are getting 404.

if we change the angluarjs version to publicly available one 1.6.4 :
https://code.angularjs.org/1.6.4/docs/error/$injector/unpr?p0=firebaseProjectQuotaProvider%20%3C-%20firebaseProjectQuota

we will be introduced with nice looking docs page explaining what AngularJS is encountering : 
Unknown provider: firebaseProjectQuotaProvider <- firebaseProjectQuota

 I couldn't find firebaseProjectQuotaProvider in js source code but I found firebaseProjectQuotaService registered as Dependency Inject in this URL : 
https://ssl.gstatic.com/analytics/20190131-00/app/js/js.js

I guess google analytics web app is asking for wrong service name (firebaseProjectQuotaProvider) instead of (firebaseProjectQuotaService) .

I already reported this to google via feedback from that page but not sure if it was sent.

I also tried that url from account with analytics already provisioned and the console loads just fine.

Wednesday, January 30, 2019

How to install lets encrypt SSL on Windows server ?


One of my clients asked me about SSL for his website which is hosted on Windows Server 2012 IIS. I advised him to go with either Lets Encrypt or Cloudflare Reverse Proxy.

My reasons are simple both options are free to use and offer same level of encryption even better than some paid solutions (Looking at you SHA1 SSL providers) , Cloudflare is easier to setup though as you don't have to install any software on your server just use  Cloudflare's provided nameservers and you are ready to go.

So if you wonder how to install Lets Encrypt SSL on Windows Server.
First download and install this handy tool CertifyTheWeb.

Once done you will be introduced with this screen :
Figure 1
A. Click on (New Certificate).
B. Choose your IIS domain from this select menu.
C. (Optional) If B is not showing any domain. you can type your domain manually and you will need to verify it manually (locating www root, etc...).

Once you Select your domain from B or add domain in C you will be introduced with Figure 2.

Figure 2
A. just a checkbox to include/exclude your domain in certificate request . (you can include multiple domains in 1 request).
B. I don't use it. some kind of test before actual request I will assume .
C. Click this once you are ready to get your free SSL Certificate .

Once you click on C you will be introduced with another screen showing the progress of your request and whether it succeeded or failed.

What I like  about CertifyTheWeb is the auto renewal feature it has. I rarely login to my clients servers to find their SSL expired and not renewed .





How to setup Reverse Proxy account on xsl.tel

Hi there, if you would like to use reverse proxy service to hide your website IP, bypass firewall restrictions (if you have a service runn...