<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[ChildOfCode]]></title><description><![CDATA[Code, Maker, Robotic, Open Source. 
Knowledge Bases and AI]]></description><link>https://childofcode.com/</link><generator>Ghost 0.11</generator><lastBuildDate>Thu, 01 Jan 2026 01:03:12 GMT</lastBuildDate><atom:link href="https://childofcode.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Ghost CMS - Invited Users Error sending email! Solution]]></title><description><![CDATA[DigitalOcean server 1-Click Apps Droplet Ghost CMS 3.x - Invited Users Error sending email! Solution.]]></description><link>https://childofcode.com/ghost-cms-invited-users-error-sending-email-solution/</link><guid isPermaLink="false">e1abc1cb-7993-402c-823e-c0acd0f0fadd</guid><category><![CDATA[Ghost]]></category><category><![CDATA[GhostCMS]]></category><category><![CDATA[mailutils]]></category><category><![CDATA[Postfix]]></category><category><![CDATA[DigitalOcean]]></category><category><![CDATA[NodeJS]]></category><category><![CDATA[Error Send Email]]></category><category><![CDATA[InvitedUsers]]></category><category><![CDATA[Email]]></category><category><![CDATA[SPF records]]></category><category><![CDATA[Mailgun]]></category><category><![CDATA[SendingEmail]]></category><category><![CDATA[Ubuntu18.04.4LTS]]></category><category><![CDATA[GhostCMS3.36]]></category><category><![CDATA[VPS]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sun, 21 Feb 2021 06:36:47 GMT</pubDate><content:encoded><![CDATA[<p>Error sending email! Error sending email: Failed to send email.Please check your email settings and resend the invitation.</p>

<p><img src="https://childofcode.com/content/images/2021/02/email-error.jpg" alt=""></p>

<p>I set up a New Ghost Blog website for other activities on DigitalOcean VPS Hosting Droplet. After setting up and using it for a period of time, we need to add a new Staff user to help maintain the Blog, but when clicking "Invite", people always encounter the "Error sending email" problem.</p>

<p>First, I tried to set up Postfix to send invitations, but after setting up, I tried to send emails, and we received a new error.</p>

<p><em>This message does not have authentication information or fails to 550-5.7.26 pass authentication checks. To best protect our users from spam, the 550-5.7.26 message has been blocked. Please visit 550-5.7.26  <a href="https://support.google.com/mail/answer/81126#authentication">https://support.google.com/mail/answer/81126#authentication</a> for more 550 5.7.26 information.</em></p>

<p>It looks like on DigitalOcean server, use Postfix to send emails, need to set up SPF records for the target recipient, if recipient is use gmail.</p>

<p>Updating SPF records on DigitalOcean servers is easy. But this method seems to take some time to update SPF Record. <br>
<a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-spf-record-for-your-domain-with-google-apps">https://www.digitalocean.com/community/tutorials/how-to-create-a-spf-record-for-your-domain-with-google-apps</a></p>

<p>In our case, we needed a quick solution to solve, so we found a better way is to use Mailgun service, because we don't need to register many users, only need to add 2 users to maintain the blog. Mailgun free plan can accommodate up to 5 authorized recipients who have not keyed in a credit card, that is enough for our situation.</p>

<p>First, you need to go to <a href="https://www.mailgun.com">https://www.mailgun.com</a> to register an account, please remember to check your email to verify Mailgun.</p>

<p>After logging into Mailgun, you need to obtain SMTP credentials and add authorized recipients. <br>
If you are a paying user or put a credit card on Mailgun, you can skill the "authorize recipient" step, otherwise you will need to perform this step because on the Free plan without credit card information present or using your sandbox domain for testing, you're restricted to sending just to Authorized Recipients.</p>

<p><strong>1) Get SMTP credentials info</strong></p>

<p>Go to "Sending" > "Overview" > Click on "SMTP" Select button. save the SMTP credentials info. <br>
<img src="https://childofcode.com/content/images/2021/02/get-SMTP-credentials.png" alt=""></p>

<p><strong>2) Add Authorized Recipients</strong></p>

<p>On the same page, scroll down the "Authorized Recipients" section and add the destination email address. After adding the email, Mailgun will send a verification email to the email address, owner of the email needs to be verified to allow Mailgun to send the email, otherwise you will not be able to send the email to the target email address.</p>

<p><img src="https://childofcode.com/content/images/2021/02/authorized-recipients.png" alt=""></p>

<p>After completing the installation on Mailgun, now we need to configure Ghost CMS.</p>

<p>Go to your Ghost CMS folder on the server and find the file config.production.json, we need to add credentials.</p>

<p><strong>3) Add Mailgun credentials on config.production.json</strong></p>

<p>Add email credentials on config.production.json Replace the "user" and "pass" values with your Mailgun SMTP credential information.</p>

<pre><code>"mail": {
    "transport": "SMTP",
    "options": {
      "service": "Mailgun",
      "host": "smtp.mailgun.org",
      "port": 587,
      "secureConnection": false,
      "auth": {
        "user": "postmaster@sandboxe123456789abcdefg.mailgun.org",
        "pass": "123456789abcdefghi"
      }
    }
  }
</code></pre>

<p>When finished, go to the server terminal and restart Ghost CMS with the following command. <br>
<code>ghost restart</code></p>

<p>You should able to send invitation emails now. enjoy.</p>

<p><strong>Software version</strong></p>

<p>DigitalOcean VPS Hosting <br>
Ubuntu - 18.04.4 LTS <br>
NodeJS - v12.18.0 <br>
Ghost CMS - 3.36</p>

<p><strong>Signs up with below DigitalOcean referral link you will gets $100, 60-day credit now! Get a try on DigitalOcean to create your server or application.</strong>
<a href="https://m.do.co/c/6ca3326e1aa6">https://m.do.co/c/6ca3326e1aa6</a></p>]]></content:encoded></item><item><title><![CDATA[Create a Login System Using PHP and Microsoft Azure Database]]></title><description><![CDATA[Create a Login System Using PHP, Transact-SQL and Microsoft Azure Database solution.
include all the source code.]]></description><link>https://childofcode.com/create-a-login-system-using-php-and-microsoft-azure-database/</link><guid isPermaLink="false">06b13d9c-ac13-404b-8cc7-8d42db907142</guid><category><![CDATA[Azure Database]]></category><category><![CDATA[PHP]]></category><category><![CDATA[Transact-SQL]]></category><category><![CDATA[SQL]]></category><category><![CDATA[Microsoft Azure Database]]></category><category><![CDATA[Login System]]></category><category><![CDATA[Regular Expression]]></category><category><![CDATA[bootstrap]]></category><category><![CDATA[Protect Content Page]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sun, 24 Jan 2021 13:23:36 GMT</pubDate><content:encoded><![CDATA[<p>I never wrote PHP system for a while, and I asked to build a simple login system for the current system. <br>
Most of my experience is using MySQL database to build login system, and it was a long time ago.</p>

<p>Compared with MySql, Azure SQL database has some different things, especially queries.</p>

<p>Almost all tutorials are about MySQL, so I need to use MySQL knowledge and convert it to Azure SQL database version.</p>

<p>First we need to create the database structure , We need to thing what data we need to store and what we need to trace. <br>
Database is very important if on beginning we don't make it better will cause many issue on the end. </p>

<p>So Today I will share my login system create by PHP and  Azure SQL Database .</p>

<p><strong>Azure SQL Database structure</strong></p>

<p>You can easy using Azure Data Studio to create the database structure or management data, recommended get a try . </p>

<p><code>database.sql</code> </p>

<pre><code>--- Azure SQL Database login system structure by childofcode.com ---
CREATE TABLE dbo.Login  
   (UniqueID INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
    LoginUsername text NULL,
    LoginPassword text NULL,
    IPAddress text NULL,
    Permission varchar(100) NULL,
    LastLoginTime datetime2 NULL
    )  
GO  
</code></pre>

<p><strong>Microsoft Azure Database connection</strong></p>

<p><code>conn.php</code> </p>

<p>This is the Azure Database connection configuration file you can setup you own Database here.</p>

<pre><code>&lt;?php  
    // Microsoft Azure Database connection PHP script by childofcode.com
    $serverName = "tcp:servername.database.windows.net,1433";  
    $connectionOptions = array(
        "Database" =&gt; "YourDatabaseName",  
        "UID" =&gt; "YourDatabaseUserID",  
        "PWD" =&gt; "YourDatabasePassword"  
    );
    $conn = sqlsrv_connect($serverName, $connectionOptions);
?&gt;
</code></pre>

<p><strong>User Login Page</strong></p>

<p><code>login.php</code> </p>

<p>Create login page with bootstrap stylesheet. <br>
PHP script Features include record user ip address, login time and some basic user validation function and regular expression remove all unnecessary special character on username input.</p>

<p><strong>Remark:</strong> Don't return too many login errors information. Hackers can use this information to damage your system. you can check on my code all error will be show with the same error message "Login Error !".</p>

<pre><code>&lt;?php  
 /* Microsoft Azure Database PHP login page by childofcode.com */

session_start();

// SESSION check user login status 
if(isset($_SESSION["loggedin"]) &amp;&amp; $_SESSION["loggedin"] === true){  
    header("location: content.php");
    exit;
}

// require Database connection files  
require_once "conn.php";

// login error reminder
function FormatErrors( $errors )  
{
    echo "Error information: ";
    foreach ( $errors as $error )
    {
        echo "SQLSTATE: ".$error['SQLSTATE']."";
        echo "Code: ".$error['code']."";
        echo "Message: ".$error['message']."";
    }
}

// variables Declaring
$username = $password = "";
$username_err = $password_err = "";

// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){

    // Get login user current datetime
    $LoginTime = date('d-M-Y h:i:s');

    // Get login user IP address
    $UserIp = '127.0.0.1';
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ipInfo = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ipInfo = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ipInfo = $_SERVER['REMOTE_ADDR'];
    }
    $ipInfo = parse_url($ipInfo);
    $UserIp = $ipInfo['host'];

    // Check username input empty
    if(empty(trim($_POST["username"]))){
        $username_err = "Please enter username.";
    } else{
        $username = trim($_POST["username"]);
    }

    // Check password input empty
    if(empty(trim($_POST["password"]))){
        $password_err = "Please enter your password.";
    } else{
        $password = trim($_POST["password"]);
    }

    // Regular expression remove all unnecessary special character.
    $usernameInput = preg_replace('/[^A-Za-z0-9\-]/', '', (string)$username); 

    // Continue processing only when without error
    if(empty($username_err) &amp;&amp; empty($password_err))
    {
        // SQL query for check is username valid and password correct
        $tsql= "SELECT * FROM Login WHERE LoginUsername LIKE '" . $usernameInput . "' ORDER BY UniqueID";
        $getResults= sqlsrv_query($conn, $tsql);
        $checkUsername = "";
        $hashedPassword = "";
        $validateUserInfo = true;

        // SQL query error and warning information handle
        if ($getResults == FALSE)
        {
            die(FormatErrors(sqlsrv_errors()));
        }

        # Returns available row of data as an associative array
        $row = sqlsrv_fetch_array($getResults);
        $checkUsername = $row['LoginUsername'];
        $hashedPassword = $row['LoginPassword'];

        # Check if the username is registered on database
        if($checkUsername == "")
        {
            $validateUserInfo = false;
            $login_err = "Login Error !";
        }

        # Check if the password is registered on database
        if($hashedPassword == "")
        {
            $validateUserInfo = false;
            $login_err = "Login Error !";
        }

        // Continue processing only is register user
        if($validateUserInfo)
        {
             // Verifies that the given hash matches the user input password.
            if(password_verify($password, $hashedPassword))
            {
                // SQL query for updated login user latest info
                $tsqlUpdate= "UPDATE Login SET IPAddress = ?, LastLoginTime = ? WHERE LoginUsername LIKE ? "; 
                $paramsUpdate = array($UserIp, $LoginTime, $checkUsername );
                $updatedResults= sqlsrv_query($conn, $tsqlUpdate, $paramsUpdate);
                $rowsAffected = sqlsrv_rows_affected($updatedResults);

                if ($updatedResults == FALSE or $rowsAffected == FALSE)
                {
                    // SQL query error and warning information handle
                    echo "error update user info" ;
                    die(FormatErrors(sqlsrv_errors()));
                }
                else
                {
                    //create a session after sucuess login 
                    session_start();
                    $_SESSION["loggedin"] = true;
                    $_SESSION["username"] = $row['LoginUsername'];      
                    $_SESSION["userpermission"] = $row['Permission'];      
                    //Go to secure content page and and terminate the current script
                    header("location: content.php");
                    exit;
                }
            }
            else
            {
                $login_err = "Login Error !";
            }
        }
        // Frees all resources after SQL query 
        sqlsrv_free_stmt($getResults);
    }
    // Closes the connection and releases resourses.
    sqlsrv_close( $conn );
}
?&gt;

&lt;!DOCTYPE html&gt;  
&lt;html lang="en"&gt;  
&lt;head&gt;  
    &lt;meta charset="UTF-8"&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name=description content="PHP and Microsoft Azure Database Login by childofcode.com"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;PHP and Microsoft Azure Database Login by childofcode.com&lt;/title&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css"&gt;
    &lt;style type="text/css"&gt;
        body{ 
            color: #666;
            font: 14px sans-serif; 
            background-color: #fafafa;
        }
        .login-block{ 
            padding: 20px; 
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            min-height: 100vh;
        }
        .wrapper{ 
            width:300px;
            height:100%;
            padding: 20px; 
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            background-color: white;
            border: 1px solid #eaeaea;
        }
        .login-button{ 
            color: #f9f9f9;
            background-color: #00bfff;
            border-color: #eaeaea;
        }
        .login-label{ 
            color: #666;
        }
        input[type="text"]::placeholder {  
                  text-align: center; 
        } 
        input[type="password"]::placeholder {  
                  text-align: center; 
        } 
    &lt;/style&gt;
&lt;/head&gt;  
&lt;body&gt;  
    &lt;div class="login-block"&gt;
        &lt;div class="wrapper"&gt;
            &lt;h2&gt;User login page&lt;/h2&gt;
            &lt;/br&gt;
            &lt;form action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]."?page=".$_GET['page']."&amp;data=".$_GET['data']) ; ?&gt;" method="post"&gt;
                &lt;div class="form-group &lt;?php echo (!empty($username_err)) ? 'has-error' : ''; ?&gt;"&gt;
                    &lt;label  class="login-label" &gt;Username&lt;/label&gt;
                    &lt;input type="text" name="username" class="form-control" value="&lt;?php echo $username; ?&gt;" placeholder="Enter username"&gt;
                &lt;/div&gt;    
                &lt;div class="form-group &lt;?php echo (!empty($password_err)) ? 'has-error' : ''; ?&gt;"&gt;
                    &lt;label class="login-label" &gt;Password&lt;/label&gt;
                    &lt;input type="password" name="password" class="form-control" placeholder="Enter password"&gt;
                &lt;/div&gt;
                &lt;div class="form-group &lt;?php echo (!empty($username_err) || !empty($password_err) || !empty($login_err)) ? 'has-error' : ''; ?&gt;"&gt;
                    &lt;span class="help-block"&gt;&lt;?php echo $username_err; ?&gt;&lt;/span&gt;
                    &lt;span class="help-block"&gt;&lt;?php echo $password_err; ?&gt;&lt;/span&gt;
                    &lt;span class="help-block"&gt;&lt;?php echo $login_err; ?&gt;&lt;/span&gt;
                &lt;/div&gt; 
                &lt;div class="form-group"&gt;
                    &lt;input type="submit" class="btn btn-primary login-button" value="Login"&gt;
                &lt;/div&gt;
            &lt;/form&gt;
            &lt;a href="https://childofcode.com/"&gt;by childofcode.com&lt;/a&gt;
        &lt;/div&gt;    
    &lt;/div&gt;
&lt;/body&gt;  
&lt;/html&gt;  
</code></pre>

<p><strong>Protect Content Page</strong></p>

<p>This is a secure content page that we need to protect. <br>
You can simply reuse your own content by simply copying the php part at the top before you html or php code.</p>

<p><strong>Copy the following PHP script to the page you need to protect</strong></p>

<p><code>Copy the following PHP script to the page you need to protect</code></p>

<pre><code class="language- ">&lt;?php  
/* Microsoft Azure Database PHP login protected page by childofcode.com */

// Initialize the session, Check if the user is logged in, if not then redirect him to login page
session_start();  
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){  
    header("location: login.php");
    exit;
}
?&gt;
</code></pre>

<p><code>content.php</code> </p>

<p>Simple content protect page</p>

<pre><code>&lt;?php  
/* Microsoft Azure Database PHP login protected page by childofcode.com */

// Initialize the session
session_start();  
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){  
    header("location: login.php");
    exit;
}
?&gt;

&lt;!DOCTYPE html&gt;  
&lt;html lang="en"&gt;  
&lt;head&gt;  
&lt;meta charset="UTF-8"&gt;  
    &lt;meta charset="utf-8"&gt;
    &lt;meta name=description content="PHP and Microsoft Azure Database Login by childofcode.comn"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;Microsoft Azure Database PHP login page secure content page&lt;/title&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css"&gt;
    &lt;script src="https://code.jquery.com/jquery-1.12.4.js"&gt;&lt;/script&gt; 
    &lt;style type="text/css"&gt;
         body{ 
            color: #666;
            font: 14px sans-serif; 
            background-color: #fafafa;
        }
        .login-block{ 
            padding: 20px; 
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            min-height: 100vh;
        }
        .wrapper{ 
            width:100%;
            height:100%;
            padding: 20px; 
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            background-color: white;
            border: 1px solid #eaeaea;
        }
        .logout-button{ 
            color: #f9f9f9;
            background-color: #00bfff;
            border-color: #eaeaea;
        }
    &lt;/style&gt;
    &lt;script&gt;
        window.onload = function()
        {
            // logout function
            $(document).off("click", "#logout-button");
            $(document).on("click", "#logout-button", function()
            {
                window.location.href = "logout.php";
            });
        }
    &lt;/script&gt;
&lt;/head&gt;  
&lt;body&gt;  
    &lt;div class="login-block"&gt;
        &lt;div class="wrapper"&gt;
            &lt;h2&gt;secure content page&lt;/h2&gt;
            &lt;/br&gt;
            &lt;h1&gt;Hi, &lt;b&gt;&lt;?php echo htmlspecialchars($_SESSION["username"]); ?&gt;&lt;/b&gt;. Welcome to secure content page.&lt;/h1&gt;
            &lt;input type="submit" class="btn btn-primary logout-button" value="Logout"&gt;
            &lt;a href="https://childofcode.com/"&gt;by childofcode.com&lt;/a&gt;
        &lt;/div&gt;    
    &lt;/div&gt;
&lt;/body&gt;  
&lt;/html&gt;  
</code></pre>

<p><strong>Logout PHP script</strong></p>

<p>User logout php script, frees and destroys all session and redirect user to login.php .</p>

<p><code>logout.php</code> </p>

<pre><code class="language- ">&lt;?php  
/* Microsoft Azure Database PHP logout script by childofcode.com */

session_start();  
$_SESSION = array(); // Frees all session variables
session_destroy(); // destroys all session data  
header("location: login.php"); // redirect back to login page  
exit;  
?&gt;
</code></pre>

<p>Above is all the codes for login system.</p>

<p>However, if you want use for production mode, there are still some TODO parts that need to be completed. For example, the registered page, profile page (update profile or change password) and the forgotten password page. <br>
For my purposes, we don’t allow people to register themselves, so in my case, I simply use a php script to generate password hashes and create user data through Azure Data Studio.</p>

<p>Below is the PHP script and SQL query I used to create a new user,  First, I will use a PHP script to generate user password hash after that using Azure Data Studio to create user data on a Microsoft Azure database.</p>

<p><strong>A simple PHP script to Creates a password hash.</strong></p>

<p><code>hash.php</code> </p>

<pre><code>&lt;?php  
/* PHP password hash generate script by childofcode.com */

// Add plain text password on 'pw' URL parameters to Creates a password hash, Example: hash.php?pw=passs1234
$password = $_GET['pw'];
$param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
echo $param_password ;  
?&gt;
</code></pre>

<p><strong>SQL query to create new user on database</strong></p>

<p><code>insert.sql</code> </p>

<pre><code>INSERT INTO Login (LoginUsername,LoginPassword,Ip,LastLoginTime)  
VALUES ('username', 'The Password hash generate by hash.php', '127.0.0.1', '31-Aug-2020 18:39:50');  
</code></pre>

<p>You can simply use the php and query above to complete other TODO parts. It should not be difficult for you now.</p>

<p>Completed source can be found on GitHub repository <br>
<a href="https://github.com/jacklkw/PHP_AzureDatabase_LoginSystem">GitHub</a></p>

<p>Let me know if anyone really needs other parts, I will update them when I have time. If you find any security issues, errors, bugs, contact me anytime. thanks.</p>]]></content:encoded></item><item><title><![CDATA[macOS Audio switch from bluetooth headphones to internal speakers solution]]></title><description><![CDATA[macOS Audio switch from bluetooth headphones to internal speakers solution]]></description><link>https://childofcode.com/macos-audio-switch-from-bluetooth-headphones-to-internal-speakers-solution/</link><guid isPermaLink="false">f0408960-cb24-4287-8f37-eb796b872b85</guid><category><![CDATA[MacOS]]></category><category><![CDATA[Bluetooth]]></category><category><![CDATA[Catalina]]></category><category><![CDATA[Audacity]]></category><category><![CDATA[Headphones]]></category><category><![CDATA[Audio]]></category><category><![CDATA[Sound]]></category><category><![CDATA[Bug]]></category><category><![CDATA[Bluetooth 5.0]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Thu, 31 Dec 2020 14:55:02 GMT</pubDate><content:encoded><![CDATA[<p>Since these few days I need to do some audio editing, I'm using Audacity software and I found that when using Audacity, the audio will automatically switch from the Bluetooth headphones to the built-in speaker, which means there is no sound from the headphones. However, if I use Apple's built-in software- GarageBand, it is fine.</p>

<p>In fact, this is not the first time I noticed the problem. The first time I discovered this problem was when I purchased a game called "Children of Morta" from GOG, I downloaded the game and played. But I thought this may be a problem arising from the "Children of Morta", because inside the game there is no option to change the audio &amp; sound output.</p>

<p>After searching on the Internet, it seems that many people are facing the same problem.</p>

<p>I tried some solutions delete "com.apple.Bluetooth.plist", reset PRAM, reset Bluetooth module, but no luck, just like others people, none of them able to solve the problem. But, except reinstall macOS solution, and I really don't want to do it. I have been searching again on the Internet to find a better solution.</p>

<p>Suddenly, I thought that since Audacity is audio editing software, inside the software must have some audio output to set up right?</p>

<p>Great, I found an option on Audacity Preferences that allows users to set the output device. After changing the playback device to a Bluetooth headphones, I can finally listen the audio and edit the soundtrack through the Bluetooth headphones. <br>
And not only Audacity, the game "Children Of Morta" I bought and downloaded from GOG now also works well when using Bluetooth headsets!</p>

<p>Here are the steps to fix macOS audio from Bluetooth headphones to built-in speaker:</p>

<p><strong>1)Download Audacity</strong>
<a href="https://www.audacityteam.org/download/mac/">https://www.audacityteam.org/download/mac/</a></p>

<p><strong>2)Install Audacity and connect your bluetooth headphones</strong></p>

<p><img src="https://childofcode.com/content/images/2020/12/Screenshot-2020-12-31-at-10.20.41-PM.png" alt=""></p>

<p><strong>3)Open Audacity and click on top bar and go to "Preferences..."</strong></p>

<p><img src="https://childofcode.com/content/images/2020/12/Screenshot-2020-12-31-at-10.19.35-PM.png" alt=""></p>

<p><strong>4)On Preferences pages Go to Devices page > On Playback section > Device change the "Build-in Output" to you bluetooth headphones</strong></p>

<p><img src="https://childofcode.com/content/images/2020/12/Screenshot-2020-12-31-at-10.32.26-PM.png" alt=""></p>

<p><strong>5)Done, You should can listen you audio from bluetooth headphones Now !</strong></p>

<p><strong>My hardware &amp; software version</strong></p>

<p>iMac (Retina 5K, 27-inch, 2019) <br>
N8 Bluetooth 5.0 headphones <br>
macOS Catalina version 10.15.7 <br>
Audacity 2.4.2</p>]]></content:encoded></item><item><title><![CDATA[React Native 0.63 running on device by other port solution]]></title><description><![CDATA[Solution for React Native 0.63 running on latest iOS device(14.0.1) and Android 11 device using other port than 8081. ]]></description><link>https://childofcode.com/react-native-0-63-running-on-device-by-other-port-solution/</link><guid isPermaLink="false">f9520d34-728b-45f4-a924-8fe6a131431b</guid><category><![CDATA[IOS]]></category><category><![CDATA[Android]]></category><category><![CDATA[Xcode]]></category><category><![CDATA[Android 11]]></category><category><![CDATA[iOS14.0.1]]></category><category><![CDATA[React Native]]></category><category><![CDATA[react-native 0.63.3]]></category><category><![CDATA[react-native 0.63]]></category><category><![CDATA[port issue]]></category><category><![CDATA[port 8081]]></category><category><![CDATA[McAfee]]></category><category><![CDATA[npx]]></category><category><![CDATA[Xcode12.0.1]]></category><category><![CDATA[Android Studio]]></category><category><![CDATA[Android Studio 4.1]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 31 Oct 2020 07:43:15 GMT</pubDate><content:encoded><![CDATA[<p>React Native Metro bundler is runs on port 8081. And very unlucky my working machine is running a McAfee antivirus with the port 8081.</p>

<p>On React Native official sites there are provide two solution Terminating a process on port 8081 or Using a port other than 8081 .</p>

<p>Will the first solution Terminating a process is not work, even is work this is not a good solution since you will terminal you Anti virus protection on you machine. But when running McAfee antivirus the <code>kill -9 &lt;PID&gt;</code> command is not work.</p>

<p>Seconds solution using a port other than 8081 this is more better solution . But there are something unclear if you run on x-code their are still have the 8081 port on use error. And i can't find the node_modules/react-native/React/React.xcodeproj/project.pbxproj file to change the 8081.</p>

<p>After try and error finally found a solution.</p>

<h1 id="foriosdevice">For iOS Device</h1>

<p><strong>0) Start React Native Metro with port 8070</strong></p>

<p><code>npx react-native start --port=8070</code></p>

<p><img src="https://childofcode.com/content/images/2020/10/start.png" alt=""></p>

<p><strong>1) Open react<em>native</em>learning.xcworkspace on project ios folder</strong></p>

<p><img src="https://childofcode.com/content/images/2020/10/ios-project.png" alt=""></p>

<p><strong>2) Search and change 8081 on workspace replace 8081 to 8070 below is the files need to change</strong></p>

<ul>
<li>RCTBridgeDelegate.h</li>
<li>RTCDefines.h</li>
<li>RCTInspectorDevServerHelper.mm</li>
<li>RCTDevMenu.mm</li>
</ul>

<p><img src="https://childofcode.com/content/images/2020/10/project-8081.png" alt=""></p>

<p><strong>3) Go to Signing &amp; Capabilities
On project target and test target Update you own developer detail Signing on Team > xxx(company)</strong></p>

<p><img src="https://childofcode.com/content/images/2020/10/sign1.png" alt="">
<img src="https://childofcode.com/content/images/2020/10/sign2.png" alt=""></p>

<p><strong>4)Go to Build Phases
Select "Start Packager" <br>
Change the Shell script 8081 to 8070</strong></p>

<p><img src="https://childofcode.com/content/images/2020/10/shell.png" alt=""></p>

<p><strong>5) Click run on x-code and launch apps on device</strong></p>

<p>You apps should running on connected iOS device now.</p>

<p><strong>6) Open apps and shake open React Native developer menu. Click "Reload" on first launch this will enable the Fast Refresh function if not the Fast Refresh will not working.</strong></p>

<p>Command to debug on simulator <br>
<code>npx react-native run-ios --port 8070</code></p>

<p>Command to debug on Device <br>
<code>npx react-native run-ios --device "MyiPhoneDevice" --port 8070</code></p>

<h1 id="forandroiddevice">For Android Device</h1>

<p>Android is more easy than iOS, Just need change the port on command and reverse the tcp port.</p>

<p><strong>0) Start React Native Metro with port 8070</strong></p>

<p><code>npx react-native start --port=8070</code></p>

<p><strong>1) Open an Existing Project > go to react native project > android folder</strong></p>

<p><img src="https://childofcode.com/content/images/2020/10/android-studio.png" alt=""></p>

<p><img src="https://childofcode.com/content/images/2020/10/android.png" alt=""></p>

<p><strong>2) Reverse the tcp port by below command</strong></p>

<p><code>adb reverse tcp:8081 tcp:8070</code></p>

<p><strong>3) Build on Android Studio</strong></p>

<p>You apps should working good on android device with Fast Refresh.</p>

<p>Command to debug on emulator <br>
<code>npx react-native run-android --port 8070</code></p>

<p>Command to debug on specific connect device <br>
<code>npx react-native run-android --deviceId=11AA22A3C --port 8070</code></p>

<p>You can find deviceId with below command <br>
<code>adb devices</code></p>

<p><strong>Dependencies version</strong></p>

<p>react 16.13.1 <br>
react-native 0.63.3</p>

<p><strong>Developer IDE version</strong></p>

<p>Xcode 12.0.1 <br>
Android Studio Version 4.1</p>

<p><strong>Mobile device operating system</strong></p>

<p>Android 11 <br>
iOS 14.0.1</p>]]></content:encoded></item><item><title><![CDATA[Update iOS 14.0.1 cause WiFi Internet Issue.]]></title><description><![CDATA[<p>After Update iPhone to latest iOS 14.0.1 Suddenly all connected WiFi network have issue. All web sites show "Safari cannot open the page because your iPhone is not connected to the internet".</p>

<p>This is weird because the URL is the internal server like 192.168.0.108. The</p>]]></description><link>https://childofcode.com/update-ios-14-0-1-cause-wifi-internet-issue-2/</link><guid isPermaLink="false">a9c8bafb-5396-486d-83b6-67e0c4bda4c7</guid><category><![CDATA[IOS]]></category><category><![CDATA[Apple]]></category><category><![CDATA[iOS14.0.1]]></category><category><![CDATA[WiFi]]></category><category><![CDATA[Updated]]></category><category><![CDATA[Internet issue]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 31 Oct 2020 05:14:10 GMT</pubDate><content:encoded><![CDATA[<p>After Update iPhone to latest iOS 14.0.1 Suddenly all connected WiFi network have issue. All web sites show "Safari cannot open the page because your iPhone is not connected to the internet".</p>

<p>This is weird because the URL is the internal server like 192.168.0.108. The target URL is a metro server running on my iMac and i can access on my android device. Metro Server is React Native development server. </p>

<p>At the times, I was start studying React Native， When debug on iOS device their are difficult to connect and debug on device i still think this is React Native issue.</p>

<p>I try to visit apple.com on browser also same issue. reconnect WiFi again but same result, Even restart the phone also same. <br>
This iPhone is one of my developer device inside device are no any other apps install. Few day ago i have update the iOS to 14.0.1 So i thing the updated may cause some issue.</p>

<p>I can find many user also have same problem on apple developer forums almost can confirm is the 14.0.1 updated cause the WiFi Internet Issue.</p>

<p>So I check if any new updated to solve the issue. But currently is no any new version to updated and solve. </p>

<p>After some try i discovery a solution. <br>
<strong>Removed WiFi profile and connect again</strong></p>

<p><code>Settings &gt; Wi-Fi &gt; Select the Wi-Fi you connected &gt; Click on Forget This Network &gt; Reconnect the Wi-Fi Again.</code></p>

<p>There are many problems with recent iOS updates.Hopefully Apple can make the updates more stable and safe before release.</p>]]></content:encoded></item><item><title><![CDATA[Docker - Create a Java development environment]]></title><description><![CDATA[<p>Yes is Docker Again 🐳. ! <br>
Well my work need to switch many different programming language and different development environment . <br>
Docker is really helpful</p>

<p>There are two way to compile and execute you java code. Compile and execute inside the Docker or compile and execute outside the Docker instance.</p>

<h1 id="compileyourappandexecuteinsidethedockercontainer">Compile your app</h1>]]></description><link>https://childofcode.com/docker-create-a-java-development-environment/</link><guid isPermaLink="false">19c5b622-627c-4641-af7d-5e8faa125ae7</guid><category><![CDATA[Docker]]></category><category><![CDATA[Java]]></category><category><![CDATA[OpenJDK]]></category><category><![CDATA[OpenJDK8]]></category><category><![CDATA[Compile Java]]></category><category><![CDATA[Execute Java]]></category><category><![CDATA[Open Java Development Kit]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Tue, 20 Oct 2020 17:53:47 GMT</pubDate><content:encoded><![CDATA[<p>Yes is Docker Again 🐳. ! <br>
Well my work need to switch many different programming language and different development environment . <br>
Docker is really helpful</p>

<p>There are two way to compile and execute you java code. Compile and execute inside the Docker or compile and execute outside the Docker instance.</p>

<h1 id="compileyourappandexecuteinsidethedockercontainer">Compile your app and execute inside the Docker container</h1>

<p><strong>1. Let Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM openjdk:8  
COPY . /usr/src/myapp  
WORKDIR /usr/src/myapp  
RUN javac Code.java  
CMD ["java", "Code"] 
</code></pre>

<p><code>FROM openjdk:8</code>
Get the openjdk 8 Images from docker hub'</p>

<p><code>COPY . /usr/src/myapp</code>
Copy myapp folder inside docker </p>

<p><code>WORKDIR /usr/src/myapp</code>
Create a place to store the source code</p>

<p><code>RUN javac Code.java</code>
Compile the java code</p>

<p><code>CMD ["java", "Code"]</code>
Execute the Java application</p>

<p><strong>2.Create a folder call myapp inside a folder create a java file</strong></p>

<p>Create java file calling Code.java with code below. </p>

<pre><code>public class Mycode {

    public static void main(String args[]){  

        System.out.println("Hello Docker");   

    }
}
</code></pre>

<p><strong>3.Build the image by Dockerfile</strong></p>

<p><code>docker build -t java_env .</code></p>

<p><strong>4. Run the Docker container Image</strong></p>

<p><code>docker run -it --rm java_env</code></p>

<p>you should see the 'Hello Docker' output on your terminal .</p>

<h2 id="compileandexecuteoutsidethedockercontainer">Compile and execute outside the Docker container</h2>

<p><strong>1. Let Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM openjdk:8  
COPY . /usr/src/myapp  
WORKDIR /usr/src/myapp
</code></pre>

<p><strong>2.Create a java file</strong></p>

<p>Create java file calling Mycode.java with code below. </p>

<pre><code>public class Mycode {

    public static void main(String args[]){  

        System.out.println("Hello Java");   

    }
}
</code></pre>

<p><strong>3.Build the image by Dockerfile</strong></p>

<p><code>docker build -t java_env .</code></p>

<p><strong>4. Compile the Java source code</strong></p>

<p><code>docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app java_env javac Mycode.java</code></p>

<p>After run the command docker will compile and create a file name Mycode.class on you folder.</p>

<p><strong>4. Execute the Java application</strong></p>

<p><code>docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app java_env java Mycode</code></p>

<p>Execute the java application outside Docker container, You will see the output message "Hello Java".</p>]]></content:encoded></item><item><title><![CDATA[Android Java - Get Eddystone Beacon Service Data and Convert]]></title><description><![CDATA[<p>On Android Eddystone beacon we can store some useful information inside Namespace and Instance to identify unique beacon.</p>

<p>Before Learn and Play CTF event. byte, ASCII text, Decimal and Hex is difficult thing for me. But after learning CTF this become very easy . since this kind of numbers is very</p>]]></description><link>https://childofcode.com/android-java-get-eddystone-beacon-service-data/</link><guid isPermaLink="false">8ccec849-9658-4955-a9c3-8167514f5ca3</guid><category><![CDATA[Android]]></category><category><![CDATA[Java]]></category><category><![CDATA[Android 11]]></category><category><![CDATA[ASCII]]></category><category><![CDATA[Decimal]]></category><category><![CDATA[Hex]]></category><category><![CDATA[Bytes]]></category><category><![CDATA[byte array]]></category><category><![CDATA[Eddystone]]></category><category><![CDATA[Beacon]]></category><category><![CDATA[Bluetooth]]></category><category><![CDATA[Service Data]]></category><category><![CDATA[Namespace]]></category><category><![CDATA[Instance]]></category><category><![CDATA[convert decimal to hex]]></category><category><![CDATA[scan record]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 17 Oct 2020 09:18:59 GMT</pubDate><content:encoded><![CDATA[<p>On Android Eddystone beacon we can store some useful information inside Namespace and Instance to identify unique beacon.</p>

<p>Before Learn and Play CTF event. byte, ASCII text, Decimal and Hex is difficult thing for me. But after learning CTF this become very easy . since this kind of numbers is very common on CTF event.</p>

<p>Android Java API <code>android.bluetooth.le.ScanRecord</code> return Service Data is Decimal (bytes) . And Hex (bytes) is Eddystone Beacon support Specification, So we need to convert the Decimal (bytes) to get the Hex (bytes).</p>

<p>Eddystone UID frame broadcasts an opaque, unique 16-byte Beacon ID composed of a 10-byte namespace and a 6-byte instance.</p>

<p>We can use ASCII text for more readable and useful. We just need to convert the ASCII text to Hex and insert on beacon Namespace or Instance. </p>

<p>But on this POST we not using ASCII text since we just need Namespace and Instance Hex (bytes) to identify the beacon. <br>
But remember we only have total 16bytes to store the text.</p>

<p>We need to Convert Byte array to Decimal string because Android Java API toString() method is not working on some older android phone with older Android OS their will alway return byte array . For compatible with older device our code will get Byte array and convert it.  </p>

<p>Example:  We can directly get ServiceData by <br>
               <code>result.getScanRecord().getServiceData().toString()</code></p>

<p>and will get the result like <br>
<code>{0000feaa-0000-1000-8000-00805f9b34fb=[0, -65, 17, 34, 51, 68, 85, 102, 119, -120, -103, 0, 49, 50, 51, 52, 53, 54]}</code></p>

<p>But some android device will return byte array like <code>[B@ee2583d</code></p>

<p><strong>Example:</strong></p>

<p><strong>On Eddystone Beacon hardware setting</strong></p>

<p><strong>Namespace ID</strong> : <code>6865656C6F776F726C64</code></p>

<p><strong>Instance ID</strong> : <code>313233343536</code></p>

<p>We Will Get the following result on Android</p>

<p>Android Java return Decimal (bytes) <br>
<code>104, 101, 108, 108, 111, 119, 111, 114, 108, 100, 49, 50, 51, 52, 53, 54</code></p>

<p>Convert to Hex (10 bytes) this will match what we set on beacon Namespace + Instance <br>
<code>68 65 6C 6C 6F 77 6F 72 6C 64 31 32 33 34 35 36</code></p>

<p>Convert to ASCII text <br>
<code>helloworld123456</code></p>

<pre><code> /* Android Java code - Get and convert Eddystone Beacon Service Data by childofcode.com */


private void processResult(ScanResult result) {

    String BytesArray = "";
    String RawAdvData = "";   
    String ServiceData = "";
    String Namespace = "";
    String Instance = "";

    // Process if ScanResult have result
    if (result.getScanRecord().getServiceUuids() != null) 
    {         
        // Use Android default UUID to scan beacon
        ParcelUuid EDDYSTONE_SERVICE_UUID = ParcelUuid.fromString("0000FEAA-0000-1000-8000-00805F9B34FB");
        byte[] EncodedServiceData = result.getScanRecord().getServiceData(EDDYSTONE_SERVICE_UUID);

        if (EncodedServiceData != null) 
        {
             try
             {

                // Convert Byte Array to Decimal (bytes) string
                ByteBuffer byteBuffer = ByteBuffer.wrap(EncodedServiceData);                
                BytesArray = Arrays.toString(byteBuffer.array());

                RawAdvData = BytesArray.toString();

             }
             catch (NumberFormatException nfe)
             {
                System.out.println("byteBuffer Exception ");  
             }             

            // Process if beacon advertisement have Service Data
            if (RawAdvData.length() &gt; 0)    
            {
                int counter = 1;
                ArrayList&lt;String&gt; bytes = new ArrayList&lt;String&gt;();

                String asubstring = RawAdvData.substring(1, RawAdvData.length()-1); 
                String[] dataBytes = asubstring.split(",");

                for (String abytes : dataBytes) 
                {        
                    /*       
                    Eddystone-UID frame Byte offset we only need 10-byte Namespace and 6-byte Instance
                    0 and 1 Byte is Frame Type and Ranging Data and 18 and 19 Byte is Reserved for future use.
                    */
                    if(counter &gt; 2)
                    {
                        try
                        {
                            // Convert Decimal (bytes) to Hex (bytes)
                            int theByte = Integer.parseInt(abytes.trim());  
                            String findUUID = Integer.toHexString(theByte);
                            String replacedString = findUUID.replace("ffffff", "");

                            if(replacedString.length() == 1)
                            {
                                bytes.add("0"+replacedString);
                            }
                            else
                            {
                                bytes.add(replacedString);
                            }   
                        }
                        catch (NumberFormatException nfe)
                        { 
                            System.out.println("Number Format Exception ");   
                        }
                    }
                    counter+=1;
                }

                ServiceData = bytes.toString(); 
                Namespace = ServiceData.substring(1, 35); 
                Instance = ServiceData.substring(37, ServiceData.length()-1); 
                System.out.println("ServiceData "+ServiceData);
                System.out.println("Namespace : "+Namespace);
                System.out.println("Instance : "+Instance);
            }
            else
            {
                ServiceData = ""; 
                System.out.println("ServiceData Empty "); 
            }
        }

    }

  }
</code></pre>

<p>Note: if you don't have any Beacon you can download a apps call "Beacon Simulator" on Google Play Store to simulate using android device .  </p>

<p>refer: <br>
<a href="https://github.com/google/eddystone/tree/master/eddystone-uid">https://github.com/google/eddystone/tree/master/eddystone-uid</a></p>

<p><a href="https://developer.android.com/reference/android/bluetooth/le/ScanRecord#getServiceData(">https://developer.android.com/reference/android/bluetooth/le/ScanRecord#getServiceData(</a>)</p>]]></content:encoded></item><item><title><![CDATA[PHP SQL LIKE operator wildcard cause SQL injection]]></title><description><![CDATA[<p>PHP SQL LIKE operator with percent sign wildcard cause SQL injection vulnerability.</p>

<p>One of my team member build a backend system and discovery the backend system can explore all the data by wildcard. </p>

<p>So let analysis and investigate why change UserID to percent sign can cause SQL injection and explore</p>]]></description><link>https://childofcode.com/php-sql-like-operator-wildcard-cause-sql-injection/</link><guid isPermaLink="false">a813b241-571d-465d-b892-69ecea87e136</guid><category><![CDATA[Security]]></category><category><![CDATA[SQL injection]]></category><category><![CDATA[SQL]]></category><category><![CDATA[PHP]]></category><category><![CDATA[Transact-SQL]]></category><category><![CDATA[wildcard]]></category><category><![CDATA[Azure Database]]></category><category><![CDATA[Azure App Service]]></category><category><![CDATA[PHP 5.6.40]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 19 Sep 2020 04:26:13 GMT</pubDate><content:encoded><![CDATA[<p>PHP SQL LIKE operator with percent sign wildcard cause SQL injection vulnerability.</p>

<p>One of my team member build a backend system and discovery the backend system can explore all the data by wildcard. </p>

<p>So let analysis and investigate why change UserID to percent sign can cause SQL injection and explore all data.</p>

<h2 id="part0theimpact">Part 0: The impact</h2>

<p>User or hacker can view/explore all other user data by percent sign wildcard SQL injection on the URL input.</p>

<p>SQL query percent sign on LIKE query can be use to search all results. <br>
Let’s understand how SQL Wildcards (%, _) are a threat.</p>

<p>% are special solely in the context of LIKE-matching.
% equivalent to any string of zero or more characters.</p>

<p>An application is vulnerable to this attack when it uses the LIKE operator with a user received parameter not filtering any of these wildcard.</p>

<p><br>  </p>

<h2 id="part1describethevulnerablebug">Part 1: Describe the vulnerable bug</h2>

<p>So the Main reason cause the vulnerable is the PHP never filter or checking $<em>GET['userid'] collect data on the URL , SQL query directly use the $</em>GET['userid'] data. Hacker can change the data on the URL to make SQL injection attack.</p>

<p>LIKE operator with wildcard percent sign actually is not a vulnerable because % are special solely in the context of LIKE-matching for some use case .</p>

<p><strong>The PHP code for GET userid from URL without checking escaped and validation or filter</strong> </p>

<p><br></p>

<h2 id="part2stepstoreproduce">Part 2: Steps to Reproduce</h2>

<pre><code>$UserID = (string)$_GET['userid'];
</code></pre>

<p><strong>The SQL Query</strong> </p>

<pre><code> $sqlQuery= "SELECT * FROM userTable WHERE UserID LIKE '" . $UserID . "' ORDER BY UniqueID";
</code></pre>

<p><strong>The normal userid on the URL</strong></p>

<p><a href="https://dev.domain.com/userInfo.php?action=view&amp;userid=AYqNWDcPioJSa1Y3">https://dev.domain.com/userInfo.php?action=view&amp;userid=AYqNWDcPioJSa1Y3</a></p>

<p>sql query will only return the user info when the userid is AYqNWDcPioJSa1Y3</p>

<p><strong>The SQL injection attack</strong></p>

<p><a href="https://dev.domain.com/userInfo.php?action=view&amp;userid=%">https://dev.domain.com/userInfo.php?action=view&amp;userid=%</a></p>

<p>sql query will return all user data</p>

<p><br></p>

<h2 id="part3solution">Part 3: Solution</h2>

<p>We should never trust what user input. </p>

<p>1) Use Regular expression to verify and filter malicious code in input values and parameters.</p>

<p>2) Restrict input character format and check input length.</p>

<p><strong>How to prevent SQL Injection</strong> </p>

<pre><code>    $TheUserID = preg_replace('/[^A-Za-z0-9\-]/', '', (string)$_GET['data']);

    if(strlen($TheUserID) == 16)
    {
        $TheUserID = $UserID;
    }
    else
    {
        $TheUserID = "";
    }
</code></pre>

<p>First use regular expression search and remove all the special character. <br>
And Validate userID since we know the userID characters length must be 16 character we can check the userID characters length if 16 character than process else will return empty userID since if the userID is length is more or less than 16 character length that mean must have something wrong.</p>

<p><strong>Priority</strong> <br>
P1</p>

<p><strong>Severity</strong><br>
Critical: Loss of data.</p>

<p><strong>Weakness</strong><br>
SQL Injection</p>

<p><strong>Platform/Environment</strong><br>
All browser <br>
Microsoft Azure PHP App Service (windows platform) <br>
Microsoft Azure Database <br>
Microsoft SQL Azure 12.0.2000.8</p>

<p><strong>Language/Version</strong> <br>
PHP 5.6.40 🐘 <br>
T-SQL (Transact-SQL) 12.0</p>]]></content:encoded></item><item><title><![CDATA[Python3 virtual environment]]></title><description><![CDATA[<p>After using awhile and finally discovery some limitation of Docker can't do and not suitable.</p>

<p>If you need to develop something related with GUI applications and input devices automation thing Docker is totally not suitable. </p>

<p>For Example using the PyAutoGUI to capture a screenshoot and control the input devices using</p>]]></description><link>https://childofcode.com/python3-virtual-environment/</link><guid isPermaLink="false">ca5784db-7e0c-40d3-be33-8f4ead116e56</guid><category><![CDATA[Python]]></category><category><![CDATA[Docker]]></category><category><![CDATA[Python3]]></category><category><![CDATA[VirtualEnvironment]]></category><category><![CDATA[VirtualBox]]></category><category><![CDATA[VM]]></category><category><![CDATA[Ubuntu20.04]]></category><category><![CDATA[PyAutoGUI]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 29 Aug 2020 03:00:03 GMT</pubDate><content:encoded><![CDATA[<p>After using awhile and finally discovery some limitation of Docker can't do and not suitable.</p>

<p>If you need to develop something related with GUI applications and input devices automation thing Docker is totally not suitable. </p>

<p>For Example using the PyAutoGUI to capture a screenshoot and control the input devices using a local script to control some application on host machine.</p>

<p><strong>Error when run PyAutoGUI on Docker</strong></p>

<pre><code>Traceback (most recent call last):  
  File "app/control.py", line 3, in &lt;module&gt;
    import pyautogui
  File "/usr/local/lib/python3.8/site-packages/pyautogui/__init__.py", line 241, in &lt;module&gt;
    import mouseinfo
  File "/usr/local/lib/python3.8/site-packages/mouseinfo/__init__.py", line 223, in &lt;module&gt;
    _display = Display(os.environ['DISPLAY'])
  File "/usr/local/lib/python3.8/os.py", line 675, in __getitem__
    raise KeyError(key) from None
KeyError: 'DISPLAY'  
</code></pre>

<p>Is look like the Docker can't get the correct Display for the GUI part and I can't find any solution solve this issue.</p>

<p>Maybe we can using the Ubuntu docker images but even if working also is very difficult for development since their are no GUI for fast and accurate to find the position and images information.</p>

<p>I have try using VM (VirtualBox). <br>
Yes is working without any error the script is able get the screenshoot and control the input devices but actually is quite slow performance is difficult keep coding and try and error.</p>

<p>I running the Ubuntu20.04 VM on iMac (Retina 5K, 27-inch, 2019) with 16 GB 2667 MHz DDR4 Memory and Radeon Pro 570X 4 GB Graphics machine. <br>
No idea why running Ubuntu20.04 VM on macOS Catalina is really slow, compare with running VM on my Windows 10 laptop.</p>

<p>More faster and better solution is look like using Python3 virtual environment for our request. <br>
Our Principal is we need a faster, easy, safe, allow remove module files after finish and not cause any issue with current system environment .</p>

<p><strong>1. Create a Project Folder and build the virtual environment</strong> </p>

<p><code>mkdir /project-folder</code></p>

<p><code>cd /project-folder</code></p>

<p><strong>2. Create virtual environment</strong> </p>

<p><code>python3 -m venv ./venv</code></p>

<p>Installing a new virtual environment and define the env folder for the virtual environment dependent files</p>

<p><strong>2. activate virtual environment</strong> </p>

<p><code>source ./venv/bin/activate</code></p>

<p>After activate we should see the terminal will change and start with (venv)</p>

<p><strong>3. Check the binary on the venv</strong> </p>

<p><code>(venv) $ which pip</code></p>

<p><code>(venv) $ which python3</code></p>

<p>we can found all the pip and python3 is using inside the virtual environment.</p>

<p><strong>4. Install Python Module</strong> </p>

<p><code>(venv) $ pip install numpy</code></p>

<p>Is quite easy and same with we install module on main machine. <br>
Now we have a Python3 virtual environment to development and test our script.</p>

<p><strong>5. Install Python Module with requirements.txt</strong> </p>

<p><code>(venv) $ pip freeze &gt; requirements.txt</code></p>

<p>we can use pip freeze to find what module is install on current virtual environment this is very useful for source control and we send our project to other.</p>

<p><code>(venv) $ pip install -r requirements.txt</code></p>

<p>install the Module dependencies with requirements.txt</p>

<p><strong>6. Deactivate after finish work</strong> </p>

<p><code>(venv) $ deactivate</code></p>]]></content:encoded></item><item><title><![CDATA[Docker - Build a PHP with Apache HTTP Server]]></title><description><![CDATA[<p>I can't stop play with Docker 🐳. <br>
Let setup and configure PHP development environment. <br>
Can you imagine using docker build PHP and apache environment need how long ?</p>

<p><strong>1. First let Create a folder call</strong> <code>docker_dev_php</code>.</p>

<p><strong>2. Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM php:7.3.0-apache  
COPY src/</code></pre>]]></description><link>https://childofcode.com/docker-build-a-php-with-apache-http-server/</link><guid isPermaLink="false">589cbc6c-b2fd-4057-b7eb-9b521f33069d</guid><category><![CDATA[Docker]]></category><category><![CDATA[PHP]]></category><category><![CDATA[PHP 7.3.0]]></category><category><![CDATA[Apache]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sun, 23 Aug 2020 07:01:27 GMT</pubDate><content:encoded><![CDATA[<p>I can't stop play with Docker 🐳. <br>
Let setup and configure PHP development environment. <br>
Can you imagine using docker build PHP and apache environment need how long ?</p>

<p><strong>1. First let Create a folder call</strong> <code>docker_dev_php</code>.</p>

<p><strong>2. Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM php:7.3.0-apache  
COPY src/ /var/www/html  
EXPOSE 80  
</code></pre>

<p><code>FROM php:7.3.0-apache</code>
Download official php 7.3.0 version Images with Apache HTTP Server from docker hub'</p>

<p><code>COPY src/ /var/www/html</code>
Create a main working directory inside docker container '</p>

<p><code>EXPOSE 80</code>
Used to expose port 80 (HTTP) from the docker container to the host machine.</p>

<p><strong>2. Create local folder for our PHP script folder name let call it</strong> <code>src</code>.</p>

<p><strong>3. Create a PHP script</strong> </p>

<p>index.php  </p>

<pre><code>&lt;?php  
    echo 'Hello World';
?&gt;
</code></pre>

<p>Let print put the php info to verify PHP and Apache.</p>

<p><strong>4.Build the image by Dockerfile</strong></p>

<p><code>docker build -t php_env .</code></p>

<p><strong>6 Run the Docker container Image</strong></p>

<p><code>docker run -p 8080:80 php_env</code></p>

<p>Run Docker container and map a port 8080 from the host computer to container port 80.</p>

<p><strong>7 Check on Browser</strong></p>

<p>Open a browser and with URL <code>http://localhost:8080</code> , <br>
You should see the Hello World message on the browser.</p>

<p>Is cool right! Setup and configuration a PHP development environment <br>
less than 10 minutes. </p>

<p><strong>8. Create a PHP script for Mount a local directory</strong> </p>

<p>info.php  </p>

<pre><code>&lt;?php  
   phpinfo();
?&gt;
</code></pre>

<p><strong>9 Run the PHP script on local directory</strong></p>

<p><code>docker run -p 8080:80 -v /Users/jack/Desktop/code/docker/docker_dev_php/src/:/var/www/html php_env</code></p>

<p>Open a browser with URL <code>http://localhost:8080</code> ,</p>

<p>You should see the php info function print out all the PHP configuration information on the page</p>

<p>This is extreme Fast to build-up a PHP Apache environment on any platform. And less painful and happy! If you have install a PHP apache on a local machine experience. </p>

<p>Wonderful Life ~</p>]]></content:encoded></item><item><title><![CDATA[Docker - Setup a Node.js development environment]]></title><description><![CDATA[<p>Life is short, enjoy life.</p>

<p>After using Docker to build the development environment that make me feel more happy and less painful.</p>

<p>Be happy use Docker 🐳.</p>

<p>Same with Python Node.js also can running Node.js on local volume or build all the source code inside the container image. </p>

<p><strong>1.</strong></p>]]></description><link>https://childofcode.com/docker-setup-a-node-js-development-environment/</link><guid isPermaLink="false">6452fbe4-8b24-4c9d-bfdf-dd28682ae8dc</guid><category><![CDATA[Docker]]></category><category><![CDATA[NodeJS]]></category><category><![CDATA[v14]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[npm]]></category><category><![CDATA[Module]]></category><category><![CDATA[Package]]></category><category><![CDATA[axios]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sun, 23 Aug 2020 05:54:13 GMT</pubDate><content:encoded><![CDATA[<p>Life is short, enjoy life.</p>

<p>After using Docker to build the development environment that make me feel more happy and less painful.</p>

<p>Be happy use Docker 🐳.</p>

<p>Same with Python Node.js also can running Node.js on local volume or build all the source code inside the container image. </p>

<p><strong>1. Create a folder call</strong> <code>docker_dev_nodejs</code>.</p>

<p><strong>2. Create package.json</strong></p>

<pre><code>{
  "name": "docker_web_app",
  "version": "1.0.0",
  "description": "Node.js on Docker",
  "author": "childofcode &lt;docker@childofcode.com&gt;",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "axios": "^0.20.0"
  }
}
</code></pre>

<p>We can use npm command on local machine to generate the package.json. If you local machine does't install Node.js and npm you can manually create a package.json.</p>

<p><strong>3. Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM node:14

WORKDIR /node  
COPY package.json ./

RUN npm install  
WORKDIR /node/app

COPY . .

CMD ["npm", "start"]  
</code></pre>

<p><code>FROM node:14</code>
Download Node.js 14 version Images from docker hub'</p>

<p><code>WORKDIR /node</code>
Create a main working directory inside docker container '</p>

<p>If you get Module not found issue probably is module directory issue. <br>
we can either modify project structure moving every editable code inside a folder let's say src, or update your Dockerfile to move node_modules a directory upper.</p>

<p><code>COPY package.json ./</code>
Copy package.json inside docker main working directory'</p>

<p><code>RUN npm install</code>
Install npm package Module on main working directory. </p>

<p><code>WORKDIR /node/app</code>
Create a place to store the source code</p>

<p><code>COPY . .</code>
Copy the entire project to build</p>

<p><code>CMD ["npm", "start"]</code>
Execute npm command to install package module</p>

<p><strong>4.Build the image by Dockerfile</strong></p>

<p><code>docker build -t node_env .</code></p>

<p>-t is give a tag name call node_env </p>

<p><strong>.</strong> don't miss the dot is mean the current location</p>

<p><strong>5.Create a Node.js Scripts</strong></p>

<p>Create a node.js script calling app.js with code below. We will using a axios module to GET the nodejs.org page.</p>

<pre><code>const axios = require('axios');

 axios.get('https://nodejs.org/en/')
  .then(function (response) {
    // handle success
    console.log(response.status);
    console.log(response.data);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
    console.log("Done");
  }); 
</code></pre>

<p><strong>6 Run the Docker container Image</strong></p>

<p><code>docker run -it --rm node_env</code></p>

<p>you will see '200' and nodejs.org HTML return on the terminal. <br>
We can copy all our script on build Docker images and just run the images .</p>

<p><strong>7.Running Node.js Script Using Docker with Mount a local directory</strong></p>

<p>For development stage more flexible method is running our code on local directory and only using the Node.js and module on the Docker container image.</p>

<pre><code>docker run --rm -v /Users/jack/Desktop/code/docker/docker_dev_nodejs/:/node/app node_env  node app.js  
</code></pre>

<p><code>--rm</code> option will clean up your container after use.</p>

<p><code>-v</code> flag Use volumes by Docker containers.</p>

<p><code>/Users/YourWorkSpace/docker_dev_nodejs/</code> 
is the local directory  </p>

<p><code>/usr/src/app</code> is the docker container directory</p>

<p><code>node app.js</code> execute the Node.js script</p>

<p>Run the command on terminal you should see status code 200 and HTML return if success.</p>]]></content:encoded></item><item><title><![CDATA[Replacing the deprecated request module]]></title><description><![CDATA[<p>Request module is deprecated and not longer maintenance and update by Mikeal Rogers. </p>

<p>I have been using Request module very long times. Almost every NodeJS developer have use using this popular module. </p>

<p>request is also the first package on npm package and is the also first module use on my</p>]]></description><link>https://childofcode.com/replacing-the-deprecated-request-module/</link><guid isPermaLink="false">cc31bdc0-f3c0-444d-a0c3-c3b3400f6431</guid><category><![CDATA[NodeJS]]></category><category><![CDATA[Module]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[v14]]></category><category><![CDATA[npm]]></category><category><![CDATA[Package]]></category><category><![CDATA[Deprecated]]></category><category><![CDATA[request]]></category><category><![CDATA[axios]]></category><category><![CDATA[got]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sun, 23 Aug 2020 02:41:40 GMT</pubDate><content:encoded><![CDATA[<p>Request module is deprecated and not longer maintenance and update by Mikeal Rogers. </p>

<p>I have been using Request module very long times. Almost every NodeJS developer have use using this popular module. </p>

<p>request is also the first package on npm package and is the also first module use on my NodeJS production module.</p>

<p>The main reason Request module is deprecated because the request module code structure is older many latest javascript feature is not supported For example, async/await feature and the main reason is the vulnerability threats will cause many security .</p>

<p>Update the whole new structure of module will take a longer times and on npm have many other module can replace request module so the module author is not longer maintenance the module.</p>

<p>First let take a long how the request module working.</p>

<p><strong>request module</strong></p>

<pre><code>var request = require('request');

function requestModule()  
{
    request('https://nodejs.org/en/', function (error, response, body) {
      console.log('statusCode:', response &amp;&amp; response.statusCode);
      console.log('error:', error );
      console.log('body:', body );
    });
}

requestModule();
</code></pre>

<p>Let try the most popular HTTP module axios</p>

<p><strong>axios module</strong></p>

<pre><code>const axios = require('axios');

function axiosModule()  
{
  axios.get('https://nodejs.org/en/')
  .then(function (response) {
    // handle success
    console.log(response.status);
    console.log(response.data);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
    console.log("Done");
  }); 
}

axiosModule(); 
</code></pre>

<p>Also let have a look the Human-friendly and powerful HTTP request library for Node.js</p>

<p><strong>got module</strong></p>

<pre><code>const got = require('got');

function gotModule()  
{
  (async () =&gt; {
      try {
          const response = await got('https://nodejs.org/en/');
          console.log(response.body);
          console.log(response.statusCode)
      } catch (error) {
          console.log(error.response.body);
      }
  })();
}

gotModule();
</code></pre>

<p>After some test axios Module is more suitable for my current project. <br>
axios module not only available on NodeJS also available on frontend Browser support. <br>
On new project maybe will try to use got module regarding got module have more feature support compare with axios.</p>]]></content:encoded></item><item><title><![CDATA[Docker - Setup a Python development environment]]></title><description><![CDATA[<p>Docker really is a good tools for Dev-ops , learning and R&amp;D .</p>

<p>Want to try and learning Docker but alway drag until now.</p>

<p>After get back my new iMac need to re-setup all my development environment but I don't want too install too many package and module on the</p>]]></description><link>https://childofcode.com/docker-setup-a-python-development-environment/</link><guid isPermaLink="false">fc2c288a-848b-4efe-9d79-f8456ef37abb</guid><category><![CDATA[Docker]]></category><category><![CDATA[Python]]></category><category><![CDATA[Development]]></category><category><![CDATA[Container]]></category><category><![CDATA[Images]]></category><category><![CDATA[Environment]]></category><category><![CDATA[Python3.8.5]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 22 Aug 2020 10:21:29 GMT</pubDate><content:encoded><![CDATA[<p>Docker really is a good tools for Dev-ops , learning and R&amp;D .</p>

<p>Want to try and learning Docker but alway drag until now.</p>

<p>After get back my new iMac need to re-setup all my development environment but I don't want too install too many package and module on the iMac system since is difficult to clean and this is not a good practice and this will cause the current MacOS system also.</p>

<p>Node.JS is more simple we can control the project Module inside a folder but Python is more different and many thing need to link with the system.</p>

<p>of course we can use the Python virtual environment but this also will cause the system and storage messy .</p>

<p>I want a Clean and Clear and consistent same system enviroment for my R&amp;D and project so is time's to learn Docker.</p>

<p>Compare with Virtual Machine, Docker is more Light, Fast and easy way. <br>
I try Virtual Machine with Ubuntu 20.04-desktop-amd64 on the latest macOS Catalina their have a-lot a issue when installing and I feel is slow when using the VirtualBox to development code.</p>

<p><strong>Their are two way to using a Docker</strong></p>

<p>1) Mount a local directory as a volume execute a script on local directory without rebuild. <br>
2) Copy the script into the Docker container and rebuild the container image.</p>

<p>First method is more suitable for me since on development alway need to code and run. <br>
Seconds method is more suitable for production.</p>

<h3 id="method1mountalocaldirectoryasavolume">Method 1 : Mount a local directory as a volume</h3>

<p><strong>1. Create a folder call "docker_dev"</strong></p>

<p><strong>2. Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM python:3.8.5-slim  
WORKDIR /usr/src/app  
RUN python -m pip install \  
         parse \
         requests
</code></pre>

<p><code>FROM python:3.8.5-slim</code></p>

<p>Download the Python 3.8.5 slim version Images from docker hub</p>

<p><code>WORKDIR /usr/src/app</code></p>

<p>Set a working directory inside docker container</p>

<p><code>RUN python -m pip install \</code>
<code>parse \</code>
<code>requests</code></p>

<p>Install python module we need.</p>

<p><strong>3.Build the image by Dockerfile</strong></p>

<p><code>docker build -t python_env .</code></p>

<p>-t is give a tag name call python_env </p>

<p><strong>.</strong> don't miss the dot is mean the current location</p>

<p><strong>4.Create a source directory</strong></p>

<p>create a folder calling app </p>

<p><strong>5.Create a Python Scripts</strong></p>

<p>create a python script call dev.py with the code</p>

<pre><code>import requests

x = requests.get('https://www.python.org')  
print(x.status_code)
</code></pre>

<p><strong>6 Confirm that parse module has been installed in the container</strong></p>

<p><code>docker run -it --rm python_env</code></p>

<p><code>&gt;&gt;&gt; import parse</code></p>

<p><code>&gt;&gt;&gt; parse.__version__</code></p>

<p>you will see version like '1.16.0' return on the terminal.</p>

<p><strong>7.Running Python Script Using Docker with Mount a local directory</strong></p>

<p>Execute below command</p>

<pre><code>docker run --rm -v /Users/YourWorkSpace/docker_dev/:/usr/src/app python_env python app/dev.py  
</code></pre>

<p><code>--rm</code> option will clean up your container after use.</p>

<p><code>/Users/YourWorkSpace/docker_dev/</code> 
is the local directory  </p>

<p><code>/usr/src/app</code> is the docker container directory</p>

<p><code>python app/dev.py</code> execute the python script</p>

<p>Run the command on terminal you should see status code 200 return if work.</p>

<h3 id="method2buildeverythinginsidedockercontainerimage">Method 2 : Build everything inside Docker container image</h3>

<p><strong>1. Create a folder call "docker_dev"</strong></p>

<p><strong>2. Create a Dockerfile with below configuration</strong></p>

<pre><code>FROM python:3.8.5-slim  
WORKDIR /usr/src/app  
RUN python -m pip install \  
         parse \
         requests
COPY app/dev.py .  
CMD ["python", "dev.py"]
</code></pre>

<p><code>COPY app/dev.py .</code></p>

<p>Copy the dev.py to that working directory inside the container</p>

<p><code>CMD ["python", "dev.py"]</code></p>

<p>Download the Python 3.7.5 slim version Images from docker hub</p>

<p><strong>3.Build the image by Dockerfile</strong></p>

<p><code>docker build -t python_env .</code></p>

<p><em>*3.Running the Docker Images *</em></p>

<p><code>docker run --rm python_env</code></p>

<p>You should see status code 200 return on terminal when success.</p>

<h5 id="dockercommand">Docker command</h5>

<p><code>docker images</code>
Check all Docker images</p>

<p><code>docker images -a</code>
Check all Docker images <br>
 -a flag will show all images including intermediate image layers</p>

<p><code>docker build -t ImageName .</code>
Docker Build Images container</p>

<p><code>docker run --rm ImageName</code>
Run DockerImages container</p>

<p><code>docker run -it --rm ImageName</code>
Run Docker Images container with commands</p>

<p><code>docker rmi ImageName</code>
 Delete a docker images</p>

<p><code>docker system prune</code>
Purging All Unused or Dangling Images, Containers, Volumes, and Networks</p>

<p><code>docker system prune -a</code>
To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command: (Delete everything)</p>

<p><code>docker ps -a</code>
Show both running and stopped containers</p>

<p>refer: <br>
<a href="https://realpython.com/python-versions-docker/">https://realpython.com/python-versions-docker/</a></p>

<p><a href="https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes">https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes</a></p>

<p><a href="https://docs.docker.com/engine/reference/commandline/container_ls/">https://docs.docker.com/engine/reference/commandline/container_ls/</a></p>

<p><a href="https://hub.docker.com/">https://hub.docker.com/</a></p>]]></content:encoded></item><item><title><![CDATA[Migrate Wordpress to New server]]></title><description><![CDATA[<p><strong>Migrate Wordpress to New server Host on DigitalOcean</strong></p>

<p>Regarding <strong>certbot</strong> is not longer support on <strong>ubuntu 14.04 LTS</strong> this will cause we can't renew the <strong>Let's Encrypt</strong> Certificates on our wordpress server this will cause our domain become unsecure mark on all browser.</p>

<p>The current server host is almost</p>]]></description><link>https://childofcode.com/migrate-wordpress-to-new-server/</link><guid isPermaLink="false">263abb00-dd71-4f40-82b0-f0df210de72e</guid><category><![CDATA[DigitalOcean]]></category><category><![CDATA[Wordpress]]></category><category><![CDATA[MySQL]]></category><category><![CDATA[phpMyAdmin]]></category><category><![CDATA[CMS]]></category><category><![CDATA[PHP]]></category><category><![CDATA[PHP7]]></category><category><![CDATA[certbot]]></category><category><![CDATA[Let's Encrypt]]></category><category><![CDATA[Migrate]]></category><category><![CDATA[SQL]]></category><category><![CDATA[DNS records]]></category><category><![CDATA[Security]]></category><category><![CDATA[Database]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sun, 19 Jul 2020 11:25:37 GMT</pubDate><content:encoded><![CDATA[<p><strong>Migrate Wordpress to New server Host on DigitalOcean</strong></p>

<p>Regarding <strong>certbot</strong> is not longer support on <strong>ubuntu 14.04 LTS</strong> this will cause we can't renew the <strong>Let's Encrypt</strong> Certificates on our wordpress server this will cause our domain become unsecure mark on all browser.</p>

<p>The current server host is almost running 6 years and more . Is time to update due the security issue . <br>
I try to Upgrade to current server from <strong>Ubuntu 14.04 LTS</strong> to <strong>Ubuntu 16.04 LTS</strong> because the <strong>certbot</strong> software tool minimum support version is <strong>Ubuntu is 16.04 LTS</strong> . But i have no luck since update the current running server is difficult and painful.</p>

<p>So the better solution is Migrate <strong>Wordpress</strong> to New server.</p>

<p>Any Migrate action first step always is backup all the related files, content and the most important thing The database.</p>

<p><strong>1) Export Wordpress MySQL database</strong></p>

<p>Export Wordpress MYSQL database by phpMyAdmin <br>
<img src="https://childofcode.com/content/images/2020/07/phpMyAdmin1.png" alt=""></p>

<p>Go to Wordpress Tables > Export Section > Choose the Export Format <code>SQL</code> and click the Go button. <br>
<img src="https://childofcode.com/content/images/2020/07/phpMyAdmin2.png" alt=""></p>

<p>You should download a files like YouWordpressTablesName.sql </p>

<p>This sql file is all data not include Media files (images, video, audio) on Wordpress MySql database is only store the Media files URL path only. <br>
After download please make sure this files is secure.</p>

<p>We can Migrate our Wordpress to any New server using this sql file.</p>

<p><strong>2) Backup Whole Wordpress CMS or Backup Content Files only</strong></p>

<p>To backup server files we need Connect server host with <strong>FileZilla</strong> software. <strong>FileZilla</strong> software is most quick and easy way and it support all OS platform.</p>

<p><strong>2a) You can only backup wp-content and replace this on latest version Wordpress</strong></p>

<p><img src="https://childofcode.com/content/images/2020/07/ftp2.png" alt=""></p>

<p>You can do this when you new server or host already include or build-in with Wordpress . Example like <strong>Digital Ocean</strong> One-Click <strong>Droplet</strong> </p>

<p>Login You Server host on <strong>FileZilla</strong> and go to Wordpress location find the wp-content folder and backup it <br>
default location is <em>/var/www/html/wp-content</em> </p>

<p><strong>2b) Backup Whole Wordpress CMS files</strong></p>

<p><img src="https://childofcode.com/content/images/2020/07/ftp1.png" alt=""></p>

<p>Login You Server host on <strong>FileZilla</strong> and go to the Wordpress main location and backup all the files <br>
default location is <em>/var/www/html/</em> </p>

<p><strong>3)Change phpMyAdmin PHP Import Max file size</strong></p>

<p>By Default phpMyAdmin Import Max file size is set to 2MB if you sql file size is more than 2MB you will need to modified the php.ini for increase Import Max file size.</p>

<p>Method to find correct PHP.ini files location is create a php files with phpinfo function and check on it.</p>

<p><strong>3a)Find PHP.ini files location</strong></p>

<p>PHP Code for check the PHP.ini, Upload this to you new server.</p>

<pre><code>&lt;?php

phpinfo();

?&gt;
</code></pre>

<p><img src="https://childofcode.com/content/images/2020/07/PHP-1.png" alt=""></p>

<p>check on the <code>Loaded Configuration File</code> you will get the PHP.ini location. Digital Ocean Server Default location is <br>
/etc/php/7.2/apache2/php.ini</p>

<p><mark>After find php.ini file location, Delete the phpinfo php file immediately on you server due the Security issue.</mark> </p>

<p><strong>3b)Modify PHP.ini files to increase upload size</strong></p>

<p>Open the php.ini with nano  </p>

<pre><code>nano /etc/php/7.2/apache2/php.ini  
</code></pre>

<p>search for <code>post_max_size</code> and <code>upload_max_filesize</code> increase the size.save the change .</p>

<p><img src="https://childofcode.com/content/images/2020/07/post_max_size.png" alt="">
<img src="https://childofcode.com/content/images/2020/07/max_file_uploads.png" alt=""></p>

<p>Restart Apache Server  </p>

<pre><code>sudo systemctl restart apache2  
</code></pre>

<p><strong>4) Import Wordpress MySQL database on new Server Host</strong></p>

<p>You will new create a database before import data.</p>

<p><strong>4a) Create databas</strong></p>

<p>Go to Databases > Create database </p>

<p>Database Name is the Export sql file name </p>

<p><img src="https://childofcode.com/content/images/2020/07/create_database.png" alt=""></p>

<p>Collation need to match with Export sql files collation you can open the sql file and check or use <code>utf8_general_ci</code> for most general case.</p>

<p><strong>4b) Import database</strong></p>

<p>Import Wordpress MYSQL database by phpMyAdmin</p>

<p>Go to Wordpress Tables > Import Section > Choose the sql file we download just now and click the Go button.</p>

<p><img src="https://childofcode.com/content/images/2020/07/import.png" alt=""></p>

<p><strong>4) Update Wordpress and Plug-in</strong></p>

<p>Update the Wordpress and Plug-in to the latest version on you new server host.</p>

<p>Normally you can update this on Wordpress Dashboard but i will strongly recommend don't use this FTP method to download , <br>
The better way is download the files and upload by <strong>FileZilla</strong> .</p>

<p><strong>for Wordpress you can download latest version on here</strong></p>

<p><a href="https://wordpress.org/download/">https://wordpress.org/download/</a> <br>
download unzip and replace all the files on except wp-content folder <br>
<mark><strong>Beware don't replace your wp-content folder</strong></mark></p>

<p><strong>for Wordpress plugin</strong></p>

<p><a href="https://wordpress.org/plugins/jetpack/">https://wordpress.org/plugins/jetpack/</a> <br>
you can replace on wp-content > plugins folder</p>

<p><strong>5) Upload The WordPress Files Or wp-content To Your New Server Host</strong></p>

<p>for wp-content <br>
Copy the wp-content and replace it on <br>
<em>/var/www/html/wp-content</em> </p>

<p>for Backup whole WordPress site just copy and replace all the files on public html folder <br>
<em>/var/www/html/</em> </p>

<p><strong>6) Update Domain DNS records</strong></p>

<p>Update you Domain name with the New Server Host IP address , for Digital Ocean you just need go to Networking > Domain  > select you domain name > More > Manage domain <br>
Edit A record  directs to new IP address</p>

<p><strong>Done the Migrate.</strong></p>

<p>For New user you can use my referral link to register Digital Ocean and get Free credit active: Get started on DigitalOcean with a $100, 60-day credit for new users.</p>

<p>my DigitalOcean referral link <br>
<a href="https://m.do.co/c/6ca3326e1aa6">https://m.do.co/c/6ca3326e1aa6</a></p>]]></content:encoded></item><item><title><![CDATA[Ghost CMS - Forgot password send mail Error]]></title><description><![CDATA[<p><strong>Ghost CMS Forgot Password send mail Error: Failed to send email.</strong></p>

<p><img src="https://childofcode.com/content/images/2020/07/Failed-to-send-email.png" alt=""></p>

<p>Long time never login COC to write any POST until forget my login password. </p>

<p>Normally i will just click forget password and reset the password but unfortunately my server can't send email. oh No how to I reset my</p>]]></description><link>https://childofcode.com/ghost-cms-error-failed-to-send-email/</link><guid isPermaLink="false">ac449243-23f4-40ba-88dc-29362227a310</guid><category><![CDATA[NodeJS]]></category><category><![CDATA[Ghost]]></category><category><![CDATA[CMS]]></category><category><![CDATA[Postfix]]></category><category><![CDATA[mail]]></category><category><![CDATA[mailutils]]></category><category><![CDATA[Error]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[JackLee]]></dc:creator><pubDate>Sat, 18 Jul 2020 15:52:47 GMT</pubDate><content:encoded><![CDATA[<p><strong>Ghost CMS Forgot Password send mail Error: Failed to send email.</strong></p>

<p><img src="https://childofcode.com/content/images/2020/07/Failed-to-send-email.png" alt=""></p>

<p>Long time never login COC to write any POST until forget my login password. </p>

<p>Normally i will just click forget password and reset the password but unfortunately my server can't send email. oh No how to I reset my password?</p>

<p>At first i will think about maybe i can view the database for the password but on latest CMS system will not store plain text so this is not work.</p>

<p>Ok than the only solution is fixed the send email issue.start to figure up what issue cause this problem i guess is because last time i update the OS system and setup the SSL cause something wrong since i have reset password before .</p>

<p>After investigate is look like the Mail software missing ok than we just need to reinstall the mail software on Linux Ubuntu send Mail software must is <strong>Postfix</strong> , Is a free and open-source mail transfer agent that routes and delivers electronic mail.</p>

<p>The most efficient and easy way to install <strong>Postfix</strong> and <strong>mail</strong> programs needed for testing email is</p>

<p><strong>1)Install mailutils</strong></p>

<pre><code>sudo apt-get install mailutils
</code></pre>

<p>we need to setup some configuration on install <br>
General type of email configuration is "<em>Internet Site.</em>" <br>
and the System mail name: <em>YourSiteDomainName.com</em></p>

<p><strong>2)Configure Postfix</strong></p>

<pre><code>sudo nano /etc/postfix/main.cf
</code></pre>

<p>Change the line that reads inet<em>interfaces = all to inet</em>interfaces = loopback-only</p>

<pre><code>inet_interfaces = loopback-only  
</code></pre>

<p>restart Postfix :  </p>

<pre><code>sudo service postfix restart  
</code></pre>

<p><strong>3) Test SMTP Server Send Emails funtion</strong></p>

<p>Testing send a email using the mail command.</p>

<pre><code>echo "This is the  SMTP Server email testing content " | mail -s "SMTP Server send mail test" YouEmail@mail.com  
</code></pre>

<p>Now you should send and receive you email.</p>

<p>But please check you email on the spam or junk if the mail is not receive on mailbox possibility when using Gmail the mail will be send to junk mail or spam.</p>

<p>refer: <br>
<a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04">https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04</a></p>]]></content:encoded></item></channel></rss>