<?php
        /*
        // Temporary page - version 5.017
        //
        // December 2008 / Arjan Haringa / Metalusions
        */

        // Determine the amount of free time available in the near future.

        $db = @new mysqli('127.0.0.1', 'root', 'A Fridge Too Far', 'reality');

        if(mysqli_connect_errno()){
                echo 'Unable to obtain the requested information, please try again later.';
                exit;
        } 

        // We should have a valid connection now, build and run the query.

        $stmt = $db->prepare('SELECT DATEDIFF(`deadline`, DATE_SUB(NOW(), INTERVAL -3 MONTH)) AS `freedays` FROM `project` WHERE `user` = ? AND `company` = ? ORDER BY `deadline` LIMIT 1');
        $stmt->bind_param('ss', $user, $company);

        // Define the query parameters.

        $user = 'Arjan Haringa';
        $company = 'Metalusions';

        // Perform the query.

        $stmt->execute();
        $stmt->store_result();
        $stmt->bind_result($freedays);

        // Retrieve the results.

        if($stmt->num_rows > 0){
                $stmt->fetch();
        }

        $stmt->close();

        // Close the connection to the database.

        $db->close();

        // Determine the the action to perform based on the result.

        if($freetime <= 0){

                // If no time is available, define temporary contact information.

                $contact = array();

                $contact['company'] = array();

                $contact['company']['name'] = 'Metalusions';
                $contact['company']['owner'] = 'Arjan Haringa';

                $contact['address'] = array();

                $contact['address']['street'] = 'De Berken 148';
                $contact['address']['zipcode'] = '9269 SH';
                $contact['address']['city'] = 'Veenwouden';
                $contact['address']['country'] = 'The Netherlands';

                $contact['phone'] = array();

                $contact['phone']['landline'] = '+31511473310';
                $contact['phone']['mobile'] = '+31657313675';
                
                // Debugging purpose only.

                // print_r($contact);
        
        } else {
                
                // Design a new site!

                 echo new design();
        }

?>