Configuring Virtual Hosts in XAMPP on Mac OS X

Configuring virtual hosts in xampp on mac is not an easy task.  It has some extra work to do as compared to windows or linux. Here is all the steps to configure it on mac.

STEP 1: open terminal and type

            vim /etc/hosts

It will open hosts file in vim editor (of course you can choose nano or others). press  i  and it will be in insert mode. Then add your host entry such as

127.0.0.1         localhost
127.0.0.1         localhost.zend.com

STEP 2:   Now you need to open

/Applications/XAMPP/xamppfiles/etc/httpd.conf 

(xampp installation path) either in vim or in normal editor via finder (file system in mac). Now you have to find this line

# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

and need to remove # from starting i.e. uncomment it. save and close this file.

STEP 3: Now you need to open file
/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf 

and need to add set up your directory and host relation but before that make sure this line

NameVirtualHost *:80

is added before you add your settings. Like this-

NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin webmaster@localhost.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
    ServerName  localhost
    ServerAlias www.localhost.com
    ErrorLog "logs/localhost-error_log"
    CustomLog "logs/localhost-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost.ci34.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/ci34"
    ServerName  localhost.ci34.com
    ServerAlias www.localhost.ci34.com
    ErrorLog "logs/localhost.ci34.com-error_log"
    CustomLog "logs/localhost.ci34.com-access_log" common
</VirtualHost>

STEP 4: You are almost done just need to restart apache from xampp panel. That's it. Your site is now ready to be used as localhost.ci34.com (whatever you added in hosts & httpd-vhosts.conf file).

Responsive File Manager Authentication

In config/config.php file write below code on top of everything-

<?php
if (session_id() == '') session_start(); error_reporting(0);
if(isset($_GET['logout'])){
    session_destroy();
    header('Location: dialog.php');
    exit();
}

if(!isset($_SESSION['authorized'])){
    if(isset($_POST['submit'])){
          $db = 'yourdbname';
            $uname = 'username';
            $pass = 'yourpass';
      

        $db = new PDO("mysql:host=localhost;dbname=".$db, $uname,$pass);
        $stmt = $db->prepare("SELECT password FROM users WHERE email=?");// AND password=?
        $stmt->bindValue(1, $_POST['username'], PDO::PARAM_STR);
        // $stmt->bindValue(2, password_hash($_POST['password'],CRYPT_BLOWFISH ), PDO::PARAM_STR);
        $stmt->execute();
        $rows = $stmt->fetch(PDO::FETCH_ASSOC);
        if (version_compare(PHP_VERSION, '5.5.9') >= 0) {
        }else{
         //include this library https://github.com/ircmaxell/password_compat
            require_once 'passwordLib.php';   
        }
       
        //echo '<pre>';print_r($rows);exit;
        if( password_verify($_POST['password'],$rows['password']) ){
            $_SESSION['authorized'] = true;
            header('Location: dialog.php');
            exit();
        }
    }
?>
<form action='' method='post' autocomplete='off'>
<p>Email: <input type="text" name="username" value=""></p>
<p>Password: <input type="password" name="password" value=""></p>
<p><input type="submit" name="submit" value="Login"></p>   
</form>
<?php exit;}?>


and enclose all of rfm code in else part.