<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashish</title>
    <description>The latest articles on DEV Community by Ashish (@ashishindev).</description>
    <link>https://dev.to/ashishindev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F555256%2Fa80a3fab-19b0-466b-9682-09227c27095c.jpg</url>
      <title>DEV Community: Ashish</title>
      <link>https://dev.to/ashishindev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashishindev"/>
    <language>en</language>
    <item>
      <title>Apps Allow on Firewall</title>
      <dc:creator>Ashish</dc:creator>
      <pubDate>Fri, 08 Jan 2021 13:19:44 +0000</pubDate>
      <link>https://dev.to/ashishindev/apps-allow-on-firewall-2an5</link>
      <guid>https://dev.to/ashishindev/apps-allow-on-firewall-2an5</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;GoToMeeting Domains&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;To Be on Firewall&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
logmeininc.com|getgo.com|gotomeeting.com|216.115.208.230|expertcity.com

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server Side SSL Certificate Chain Error Website List&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
slscr.update.microsoft.com

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>firewallrule</category>
      <category>appfiltering</category>
    </item>
    <item>
      <title>My First PHP Reg[Worst Starter Code]</title>
      <dc:creator>Ashish</dc:creator>
      <pubDate>Thu, 07 Jan 2021 06:56:11 +0000</pubDate>
      <link>https://dev.to/ashishindev/my-first-php-reg-worst-starter-code-2dh4</link>
      <guid>https://dev.to/ashishindev/my-first-php-reg-worst-starter-code-2dh4</guid>
      <description>&lt;p&gt;Hello All,&lt;br&gt;
I just tried a Small PHP code.&lt;br&gt;
The Point Here is not Best Practices or Clean Code.&lt;br&gt;
But To remind me when i come back to this Post that &lt;br&gt;
&lt;em&gt;&lt;code&gt;ohhh!! I did this and How different code i have written after a span of time.&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This is Just for Reference&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Anyone Who has a Better Snippet, Please add it to the comment,&lt;br&gt;
For Me as well as for Others to &lt;code&gt;Keep a Note&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Well Usually will not add this: -&amp;gt;&lt;br&gt;
&lt;code&gt;SET utf8mb4 COLLATE utf8mb4_unicode_ci&lt;/code&gt;&lt;br&gt;
But Since I Copied it From a Project, I Though Let's keep it this Way&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Table for the Below PHP MySQL Insertion&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Table

CREATE TABLE `reg_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `level` smallint(6) NOT NULL DEFAULT 1,
  `user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `full_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_address` varchar(75) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `last_login` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_name` (`user_name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Registration PHP Code:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

/*** I Have NO Clue But I will Try To Investigate on it Later: 
Well My Point was to Get the PHP Debugging Logs: 
`It does Not works`
But I will Figure it Out Soon
****/

error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");

/*** Unknown Code Ends Here ***/

// Get The Request Method
$request_method = $_SERVER["REQUEST_METHOD"];

//  Only Process if POST
if ($request_method == "POST") {

  // Collect Value of Post Body In PHP Variables
  $fullname = $_POST['fullname'];
  $username = $_POST['username'];
  $emailaddress = $_POST['emailaddress'];
  $password1 = $_POST['password1'];
  $password2 = $_POST['password2'];  

  // Validate and then Call the DB Action
  if( validate_inputs($fullname, $username, $emailaddress, $password1, $password2) ) {
        # Quick Password Hash
    $password_hashed = password_hash($password1, PASSWORD_DEFAULT);
    db_action($fullname, $username, $emailaddress, $password_hashed);
  }

} else {
    echo "In Correct Method: [{$request_method}]";
}

// Check, Confirm and Add to MySQL Database
function db_action($fullname, $username, $emailaddress, $password_hashed) {

    $db_host="localhost"; //localhost server 
    $db_user="temp"; //database username
    $db_password='temp@55hh778_0!'; //database password   
    $db_name="temp_db"; //database name

    try
    {
      $dsn = "mysql:host={$db_host};dbname={$db_name}";
      $options = [
        PDO::ATTR_EMULATE_PREPARES   =&amp;gt; false, // turn off emulation mode for "real" prepared statements
        PDO::ATTR_ERRMODE            =&amp;gt; PDO::ERRMODE_EXCEPTION, //turn on errors in the form of exceptions
        PDO::ATTR_DEFAULT_FETCH_MODE =&amp;gt; PDO::FETCH_ASSOC, //make the default fetch be an associative array
      ];
      $db=new PDO($dsn,$db_user,$db_password, $options);
      $db-&amp;gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $db-&amp;gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

      // Check First
      $check_statement = $db-&amp;gt;prepare('SELECT * FROM jam_reg_users where user_name=:user_name LIMIT 1 ');

      $check_statement-&amp;gt;execute([
        'user_name' =&amp;gt; $username
      ]);

      $is_user_exists = $check_statement-&amp;gt;fetch();

      if ($is_user_exists) {
          die("[+] User Exists, Please Use Another User");
      } else {
          //die("[-]User DOES NOT Exists");

          $insert_statement = $db-&amp;gt;prepare('INSERT INTO jam_reg_users (user_name, full_name, password_hash, email_address, timestamp) VALUES (:user_name, :full_name, :password_hash, :email_address, :timestamp)');

          $insert_statement-&amp;gt;execute([
            'user_name' =&amp;gt; $username,
            'full_name' =&amp;gt; $fullname,
            'password_hash' =&amp;gt; $password_hashed,
            'email_address' =&amp;gt; $emailaddress,
            'timestamp' =&amp;gt; date("Y-m-d H:i:s",time())
          ]);

          echo "User Added, Please Login Here &amp;lt;a href='http://login.local/'&amp;gt; Login Here &amp;lt;/a&amp;gt;";
      }

    }
    catch(PDOEXCEPTION $e)
    {
      $e-&amp;gt;getMessage();
      error_log($e-&amp;gt;getMessage());
      exit('Exception Caught Here');
    }

}

// It will Check for Fields Received in Post Body and Validate If it Empty, Blank or Not Present

function validate_inputs($fullname, $username, $emailaddress, $password1, $password2) {

  $fullname_pass = false;
  $username_pass = false;
  $emailaddress_pass = false;
  $password1_pass = false;
  $password2_pass = false;

  if ( empty($fullname) || $fullname === "" || trim($fullname," ") === "" ) {
    echo "Full Name Not Found";
  } else {
    $fullname_pass = true;
  }

  if ( empty($username) || $username === "" || trim($username," ") === "" ) {
    echo "Username Not Found";
  } else {
    $username_pass = true;
  }

  if ( empty($emailaddress) || $emailaddress === "" || trim($emailaddress," ") === "" ) {
    echo "Email Address Not Found";
  } else {
    $emailaddress_pass = true;
  }

  if ( empty($password1) || $password1 === "" || trim($password1," ") === "" ) {
    echo "Password Not Found";
  } else {
    $password1_pass = true;
  }

  if ( empty($password2) || $password2 === "" || trim($password2," ") === "" ) {
    echo "Re-Enter Password Not Found";
  } else {
    if ( $password1 === $password2 ) {
      $password2_pass = true;
    } else {
        echo "Password Did Not Match";
    }
  }

  if ($fullname_pass &amp;amp;&amp;amp; $username_pass &amp;amp;&amp;amp; $emailaddress_pass &amp;amp;&amp;amp; $password1_pass &amp;amp;&amp;amp; $password2_pass) {
      return true;
  } else {
      return false;
  }
}

?&amp;gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I saw a Better Code&lt;br&gt;
I will Add it Soon.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
