HOME


Mini Shell 1.0
DIR: /home/islapiiu/sites/forbes/contact-form/img/
Upload File :
Current File : /home/islapiiu/sites/forbes/contact-form/img/class.tar
Product.php000064400000010015150755024470006703 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Product
 *
 * @author Nipuni
 */
class Product {

    public $id;
    public $type; 
    public $name;
    public $image_name;
    public $short_description;
    public $description;
    public $price;
    public $url;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`type`,`name`,`image_name`,`short_description`,`description`,`price`,`url`,`queue` FROM `product` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->type = $result['type'];
            $this->name = $result['name'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->price = $result['price'];
            $this->url = $result['url'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `product` (`type`,`name`,`image_name`,`short_description`,`description`,`price`,`url`,`queue`) VALUES  ('"
                . $this->type . "','"
                . $this->name . "', '"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->price . "', '"
                . $this->url . "', '"
                . $this->queue . "')";
         

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `product` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `product` SET "
                . "`type` ='" . $this->type . "', "
                . "`name` ='" . $this->name . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`price` ='" . $this->price . "', "
                . "`url` ='" . $this->url . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {


        $query = 'DELETE FROM `product` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getProductsById($product) {

        $query = 'SELECT * FROM `product` WHERE type="' . $product . '"   ORDER BY queue ASC';

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `product` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Service.php000064400000007354150755024470006677 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of service

 *

 * @author Suharshana DsW

 */
class Service {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`queue` FROM `service` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `service` (`title`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `service` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `service` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

  
    
    public function delete() {



        $this->deletePhotos();



        unlink(Helper::getSitePath() . "upload/service/" . $this->image_name);



        $query = 'DELETE FROM `service` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $SERVICE_PHOTO = new ServicePhoto(NULL);



        $allPhotos = $SERVICE_PHOTO->getServicePhotosById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $SERVICE_PHOTO->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/service/gallery/" . $IMG);

            unlink(Helper::getSitePath() . "upload/service/gallery/thumb/" . $IMG);



            $SERVICE_PHOTO->id = $photo["id"];

            $SERVICE_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `service` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Room.php000064400000010175150755024470006206 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Room
 *
 * @author Suharshana DsW
 */
class Room {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $no_of_rooms;
    public $price;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`no_of_rooms`,`price`,`queue` FROM `room` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->no_of_rooms = $result['no_of_rooms'];
            $this->price = $result['price'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `room` (`title`,`image_name`,`short_description`,`description`,`no_of_rooms`,`price`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->no_of_rooms . "', '"
                . $this->price . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `room` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `room` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`no_of_rooms` ='" . $this->no_of_rooms . "', "
                . "`price` ='" . $this->price . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $this->deletePhotos();

        unlink(Helper::getSitePath() . "upload/room/" . $this->image_name);

        $query = 'DELETE FROM `room` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deletePhotos() {

        $ROOM_PHOTOS = new RoomPhoto(NULL);

        $allPhotos = $ROOM_PHOTOS->getRoomPhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $ROOM_PHOTOS->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/room/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/room/gallery/thumb/" . $IMG);

            $ROOM_PHOTOS->id = $photo["id"];
            $ROOM_PHOTOS->delete();
        }
    }

    public function arrange($key, $img) {
        $query = "UPDATE `room` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Validator.php000064400000007002150755024470007212 0ustar00<?php

/**

 * Description of Validator

 *

 * @author official

 */
class Validator {

    private $_passed = false,
            $_errors = array();

    public function check($source, $items = array()) {





        foreach ($items as $item => $rules) {



            foreach ($rules as $rule => $rule_value) {





                $value = trim($source->$item);



                if ($rule === "required" && empty($value)) {



                    $message = "{$item} is required";

                    $status = "danger";

                    $this->addError($message, $status);
                } else if (!empty($value)) {

                    switch ($rule) {

                        case 'min':

                            if (strlen($value) < $rule_value) {

                                $message = "{$item} must be a minimum of {$rule_value} characters.";

                                $status = "danger";

                                $this->addError($message, $status);
                            }

                            break;

                        case 'max':

                            if (strlen($value) > $rule_value) {

                                $message = "{$item} must be a maximum of {$rule_value} characters.";

                                $status = "danger";

                                $this->addError($message, $status);
                            }

                            break;

                        case 'matches':

                            if ($value != $source[$rule_value]) {

                                $message = "{$rule_value} must match {$item}";

                                $status = "danger";

                                $this->addError($message, $status);
                            }

                            break;

                        case 'email':

                            if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {

                                $message = "{$rule_value} invalid email format {$item}";

                                $status = "danger";

                                $this->addError($message, $status);
                            }

                            break;

                        case 'numeric':

                            if (!is_numeric($value)) {

                                $message = "{$item} must be numeric ";

                                $status = "danger";

                                $this->addError($message, $status);
                            }

                            break;
                    }
                }
            }
        }

        if (empty($this->_errors)) {

            $this->_passed = TRUE;
        }

        return $this;
    }

    public function addError($message, $status) {

        $this->_errors[] = ['message' => $message, 'status' => $status];
    }

    public function errors() {

        return $this->_errors;
    }

    public function passed() {

        return $this->_passed;
    }

    public function show_message() {



        if (!isset($_SESSION)) {

            session_start();
        }



        if (isset($_SESSION['ERRORS'])) {

            foreach ($_SESSION['ERRORS'] as $error) {
                ?>

                <div class="alert alert-<?php echo $error["status"]; ?>">

                    <strong><?php echo ucfirst($error["status"]); ?> : </strong> <?php echo ucfirst($error["message"]); ?>!.

                </div>

                <?php
            }

            unset($_SESSION['ERRORS']);
        }
    }

}
Banner.php000064400000004367150755024470006505 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of banner

 *

 * @author Suharshana DsW

 */
class Banner {

    public $id;
    public $title;
    public $image_name;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name` FROM `banner` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];





            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `banner` (`title`,`image_name`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "')";





        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `banner`";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `banner` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `banner` WHERE id="' . $this->id . '"';



        unlink(Helper::getSitePath() . "upload/banner/" . $this->image_name);



        $db = new Database();



        return $db->readQuery($query);
    }

}
TourDate.php000064400000010044150755024470007014 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of tour_dates
 *
 * @author Suharshana DsW
 */
class TourDate {

    public $id;
    public $tour;
    public $title;
    public $image_name;
    public $description;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`tour`,`title`,`image_name`,`description`,`queue` FROM `tour_date` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->tour = $result['tour'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `tour_date` (`tour`,`title`,`image_name`,`description`,`queue`) VALUES  ('"
                . $this->tour . "','"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->description . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `tour_date` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `tour_date` SET "
                . "`tour` ='" . $this->tour . "', "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $this->deleteDatesPhotos();

        $query = 'DELETE FROM `tour_date` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deleteDatesPhotos() {

        $TOUR_DATE_PHOTOS = new TourDatePhoto(NULL);

        $allPhotos = $TOUR_DATE_PHOTOS->getTourDatePhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $TOUR_DATE_PHOTOS->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/tour-package/date/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/tour-package/date/gallery/thumb/" . $IMG);

            $TOUR_DATE_PHOTOS->id = $photo["id"];
            $TOUR_DATE_PHOTOS->delete();
        }
    }

    public function getTourDatesById($tour) {

        $query = "SELECT * FROM `tour_date` WHERE `tour`= $tour ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `tour_date` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Setting.php000064400000003756150755024470006716 0ustar00<?php

/**

 * Description of User

 *

 * @author sublime holdings

 * @web www.sublime.lk

 */
class Setting {

    public $domain = 'xxx';

    public function sendSecurityAlert($domain) {



        date_default_timezone_set('Asia/Colombo');

        $subject = 'Security Alert - ' . $domain;



        $headers = "From: mail@" . $this->domain . "\r\n";

        $headers .= "Reply-To: mail@" . $this->domain . "\r\n";

        $headers .= "MIME-Version: 1.0\r\n";

        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";



        $html = '<h3>Security Alert - ' . $domain . '</h3>';

        $html .= '<table>';

        $html .= '<tr>';

        $html .= '<td>Client IP Address: </td>';

        $html .= '<td>' . getUserIP() . '</td>';

        $html .= '</tr>';

        $html .= '<tr>';

        $html .= '<td>Date: </td>';

        $html .= '<td>' . date("l, F j, Y") . '</td>';

        $html .= '</tr>';

        $html .= '<tr>';

        $html .= '<td>Time: </td>';

        $html .= '<td>' . date("g:i a") . '</td>';

        $html .= '</tr>';

        $html .= '<td>Referer Url: </td>';

        $html .= '<td>' . parse_url($_SERVER['HTTP_REFERER'])["host"] . '</td>';

        $html .= '</tr>';

        $html .= '</table>';



        mail('[email protected]', $subject, $html, $headers);



        echo '<script>alert("Invalid security token!..."); window.location.replace("http://www.sublime.lk");</script>';

        exit();
    }

    public function getUserIP() {

        $client = @$_SERVER['HTTP_CLIENT_IP'];

        $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];

        $remote = $_SERVER['REMOTE_ADDR'];



        if (filter_var($client, FILTER_VALIDATE_IP)) {

            $ip = $client;
        } elseif (filter_var($forward, FILTER_VALIDATE_IP)) {

            $ip = $forward;
        } else {

            $ip = $remote;
        }

        return $ip;
    }

    public function url() {

        return "http://" . parse_url($_SERVER['HTTP_REFERER'])['host'] . "/";
    }

}
include.php000064400000004234150755024470006714 0ustar00<?php

error_reporting(0);
ini_set('display_errors', 0);



include_once(dirname(__FILE__) . '/Setting.php');
include_once(dirname(__FILE__) . '/Helper.php');
include_once(dirname(__FILE__) . '/Upload.php');
include_once(dirname(__FILE__) . '/Database.php');
include_once(dirname(__FILE__) . '/User.php');
include_once(dirname(__FILE__) . '/Message.php');
include_once(dirname(__FILE__) . '/Validator.php');
include_once(dirname(__FILE__) . '/Service.php');
include_once(dirname(__FILE__) . '/ServicePhoto.php');
include_once(dirname(__FILE__) . '/TourPackage.php');
include_once(dirname(__FILE__) . '/TourDate.php');
include_once(dirname(__FILE__) . '/TourDatePhoto.php');
include_once(dirname(__FILE__) . '/Portfolio.php');
include_once(dirname(__FILE__) . '/PortfolioPhoto.php');
include_once(dirname(__FILE__) . '/Activities.php');
include_once(dirname(__FILE__) . '/ActivitiesPhoto.php');
include_once(dirname(__FILE__) . '/Attraction.php');
include_once(dirname(__FILE__) . '/AttractionPhoto.php');
include_once(dirname(__FILE__) . '/Offer.php');
include_once(dirname(__FILE__) . '/OfferPhoto.php');
include_once(dirname(__FILE__) . '/PhotoAlbum.php');
include_once(dirname(__FILE__) . '/AlbumPhoto.php');
include_once(dirname(__FILE__) . '/Comments.php');
include_once(dirname(__FILE__) . '/Slider.php');
include_once(dirname(__FILE__) . '/Page.php');
include_once(dirname(__FILE__) . '/Banner.php');
include_once(dirname(__FILE__) . '/Product.php');
include_once(dirname(__FILE__) . '/ProductType.php');
include_once(dirname(__FILE__) . '/ProductPhoto.php');
include_once(dirname(__FILE__) . '/TourPackagePhotosNormal.php');
include_once(dirname(__FILE__) . '/TourType.php');
include_once(dirname(__FILE__) . '/Ingredients.php');
include_once(dirname(__FILE__) . '/Room.php');
include_once(dirname(__FILE__) . '/RoomPhoto.php');
include_once(dirname(__FILE__) . '/Booking.php');

function dd($data) {

    var_dump($data);

    exit();
}

function redirect($url) {

    $string = '<script type="text/javascript">';

    $string .= 'window.location = "' . $url . '"';

    $string .= '</script>';



    echo $string;

    exit();
}
ServicePhoto.php000064400000006343150755024470007706 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Service_photo

 *

 * @author Suharshana DsW

 */
class ServicePhoto {

    public $id;
    public $service;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`service`,`image_name`,`caption`,`queue` FROM `service_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->service = $result['service'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `service_photo` (`service`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->service . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `service_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `service_photo` SET "
                . "`service` ='" . $this->service . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `service_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getServicePhotosById($service) {



        $query = 'SELECT * FROM `service_photo` WHERE service ="' . $service . '"';



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `service_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
User.php000064400000020104150755024470006201 0ustar00<?php

/**

 * Description of User

 *

 * @author sublime holdings

 * @web www.sublime.lk

 */
class User {

    public $id;
    public $name;
    public $email;
    public $createdAt;
    public $isActive;
    public $authToken;
    public $lastLogin;
    public $username;
    public $resetCode;
    private $password;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`name`,`email`,`createdAt`,`isActive`,`authToken`,`lastLogin`,`username`,`resetcode` FROM `user` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->name = $result['name'];

            $this->email = $result['email'];

            $this->createdAt = $result['createdAt'];

            $this->isActive = $result['isActive'];

            $this->lastLogin = $result['lastLogin'];

            $this->username = $result['username'];

            $this->authToken = $result['authToken'];

            $this->resetCode = $result['resetcode'];



            return $result;
        }
    }

    public function create($name, $email, $username, $passwor) {



        $enPass = md5($passwor);



        date_default_timezone_set('Asia/Colombo');



        $createdAt = date('Y-m-d H:i:s');



        $query = "INSERT INTO `user` (name, email, createdAt, isActive, username, password) VALUES  ('" . $name . "', '" . $email . "', '" . $createdAt . "', '" . 1 . "', '" . $username . "', '" . $enPass . "')";



        $db = new Database();



        $result = $db->readQuery($query);

        if ($result) {

            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function login($username, $password) {



        $enPass = md5($password);

        $query = "SELECT `id`,`name`,`email`,`createdAt`,`isActive`,`lastLogin`,`username` FROM `user` WHERE `username`= '" . $username . "' AND `password`= '" . $enPass . "'";



        $db = new Database();



        $result = mysql_fetch_array($db->readQuery($query));





        if (!$result) {

            return FALSE;
        } else {

            $this->id = $result['id'];

            $this->setAuthToken($result['id']);

            $this->setLastLogin($this->id);



            $user = $this->__construct($this->id);



            $this->setUserSession($user);



            return $user;
        }
    }

    public function checkOldPass($id, $password) {



        $enPass = md5($password);



        $query = "SELECT `id` FROM `user` WHERE `id`= '" . $id . "' AND `password`= '" . $enPass . "'";



        $db = new Database();



        $result = mysql_fetch_array($db->readQuery($query));



        if (!$result) {

            return FALSE;
        } else {

            return TRUE;
        }
    }

    public function changePassword($id, $password) {



        $enPass = md5($password);



        $query = "UPDATE  `user` SET "
                . "`password` ='" . $enPass . "' "
                . "WHERE `id` = '" . $id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return TRUE;
        } else {

            return FALSE;
        }
    }

    public function authenticate() {



        if (!isset($_SESSION)) {

            session_start();
        }



        $id = NULL;

        $authToken = NULL;



        if (isset($_SESSION["id"])) {

            $id = $_SESSION["id"];
        }



        if (isset($_SESSION["authToken"])) {

            $authToken = $_SESSION["authToken"];
        }



        $query = "SELECT `id` FROM `user` WHERE `id`= '" . $id . "' AND `authToken`= '" . $authToken . "'";



        $db = new Database();



        $result = mysql_fetch_array($db->readQuery($query));



        if (!$result) {

            return FALSE;
        } else {



            return TRUE;
        }
    }

    public function logOut() {



        if (!isset($_SESSION)) {

            session_start();
        }



        unset($_SESSION["id"]);

        unset($_SESSION["name"]);

        unset($_SESSION["email"]);

        unset($_SESSION["isActive"]);

        unset($_SESSION["authToken"]);

        unset($_SESSION["lastLogin"]);

        unset($_SESSION["username"]);



        return TRUE;
    }

    public function update() {



        $query = "UPDATE  `user` SET "
                . "`name` ='" . $this->name . "', "
                . "`username` ='" . $this->username . "', "
                . "`email` ='" . $this->email . "', "
                . "`isActive` ='" . $this->isActive . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    private function setUserSession($user) {



        if (!isset($_SESSION)) {

            session_start();
        }



        $_SESSION["id"] = $user['id'];

        $_SESSION["name"] = $user['name'];

        $_SESSION["email"] = $user['email'];

        $_SESSION["isActive"] = $user['isActive'];

        $_SESSION["authToken"] = $user['authToken'];

        $_SESSION["lastLogin"] = $user['lastLogin'];

        $_SESSION["username"] = $user['username'];
    }

    private function setAuthToken($id) {



        $authToken = md5(uniqid(rand(), true));



        $query = "UPDATE `user` SET `authToken` ='" . $authToken . "' WHERE `id`='" . $id . "'";



        $db = new Database();



        if ($db->readQuery($query)) {



            return $authToken;
        } else {

            return FALSE;
        }
    }

    private function setLastLogin($id) {



        date_default_timezone_set('Asia/Colombo');



        $now = date('Y-m-d H:i:s');



        $query = "UPDATE `user` SET `lastLogin` ='" . $now . "' WHERE `id`='" . $id . "'";



        $db = new Database();



        if ($db->readQuery($query)) {

            return TRUE;
        } else {

            return FALSE;
        }
    }

    public function checkEmail($email) {



        $query = "SELECT `email`,`username` FROM `user` WHERE `email`= '" . $email . "'";



        $db = new Database();



        $result = mysql_fetch_array($db->readQuery($query));



        if (!$result) {

            return FALSE;
        } else {

            return $result;
        }
    }

    public function GenarateCode($email) {



        $rand = rand(10000, 99999);



        $query = "UPDATE  `user` SET "
                . "`resetcode` ='" . $rand . "' "
                . "WHERE `email` = '" . $email . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return TRUE;
        } else {

            return FALSE;
        }
    }

    public function SelectForgetUser($email) {



        if ($email) {



            $query = "SELECT `email`,`username`,`resetcode` FROM `user` WHERE `email`= '" . $email . "'";



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->username = $result['username'];

            $this->email = $result['email'];

            $this->restCode = $result['resetcode'];



            return $result;
        }
    }

    public function SelectResetCode($code) {



        $query = "SELECT `id` FROM `user` WHERE `resetcode`= '" . $code . "'";



        $db = new Database();



        $result = mysql_fetch_array($db->readQuery($query));



        if (!$result) {

            return FALSE;
        } else {



            return TRUE;
        }
    }

    public function updatePassword($password, $code) {



        $enPass = md5($password);



        $query = "UPDATE  `user` SET "
                . "`password` ='" . $enPass . "' "
                . "WHERE `resetcode` = '" . $code . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return TRUE;
        } else {

            return FALSE;
        }
    }

}
TourDatePhoto.php000064400000006430150755024470010032 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Tour_dates_photos

 *

 * @author Suharshana DsW

 */
class TourDatePhoto {

    public $id;
    public $tour_date;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`tour_date`,`image_name`,`caption`,`queue` FROM `tour_date_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->tour_date = $result['tour_date'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `tour_date_photo` (`tour_date`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->tour_date . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `tour_date_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `tour_date_photo` SET "
                . "`tour_date` ='" . $this->tour_date . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `tour_date_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getTourDatePhotosById($tour_date) {



        $query = "SELECT * FROM `tour_date_photo` WHERE `tour_date`= $tour_date ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `tour_date_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Offer.php000064400000010073150755024470006330 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Offer

 *

 * @author Suharshana DsW

 */
class Offer {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $price;
    public $discount;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`price`,`discount`,`queue` FROM `offer` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->price = $result['price'];

            $this->discount = $result['discount'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `offer` (`title`,`image_name`,`short_description`,`description`,`price`,`discount`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->price . "', '"
                . $this->discount . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `offer` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `offer` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`price` ='" . $this->price . "', "
                . "`discount` ='" . $this->discount . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $this->deletePhotos();



        unlink(Helper::getSitePath() . "upload/offer/" . $this->image_name);



        $query = 'DELETE FROM `offer` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $OFFER_PHOTOS = new OfferPhoto(NULL);



        $allPhotos = $OFFER_PHOTOS->getOfferPhotosById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $OFFER_PHOTOS->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/offer/gallery/" . $IMG);

            unlink(Helper::getSitePath() . "upload/offer/gallery/thumb/" . $IMG);



            $OFFER_PHOTOS->id = $photo["id"];

            $OFFER_PHOTOS->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `offer` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Page.php000064400000004762150755024470006153 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Page
 *
 * @author Suharshana DsW
 */
class Page {

    public $id;
    public $title;
    public $description;
    public $image_name;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`description`,`image_name` FROM `pages` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->description = $result['description'];
            $this->image_name = $result['image_name'];


            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `pages` (`title`,`description`,`image_name`) VALUES  ('"
                . $this->title . "','"
                . $this->description . "', '"
                . $this->image_name . "')";


        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `pages`";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `pages` SET "
                . "`title` ='" . $this->title . "', "
                . "`description` ='" . $this->description . "', "
                . "`image_name` ='" . $this->image_name . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `pages` WHERE id="' . $this->id . '"';
        unlink(Helper::getSitePath() . "upload/page/" . $this->image_name);

        $db = new Database();

        return $db->readQuery($query);
    }

}
RoomPhoto.php000064400000006357150755024470007227 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Room_photo
 *
 * @author Suharshana DsW
 */
class RoomPhoto {
    
    public $id;
    public $room;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`room`,`image_name`,`caption`,`queue` FROM `room_photo` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->room = $result['room'];
            $this->image_name = $result['image_name'];
            $this->caption = $result['caption'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `room_photo` (`room`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->room . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `room_photo` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `room_photo` SET "
                . "`room` ='" . $this->room . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `room_photo` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

     public function getRoomPhotosById($room) {

        $query = "SELECT * FROM `room_photo` WHERE `room`= $room ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    
        public function arrange($key, $img) {
        $query = "UPDATE `room_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Slider.php000064400000006114150755024470006512 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of slider
 *
 * @author Nipuni
 */
class Slider {

    public $id;
    public $title;
    public $image_name;
    public $description;
    public $url;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`description`,`url`,`queue` FROM `slider` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->description = $result['description'];
            $this->url = $result['url'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `slider` (`title`,`image_name`,`description`,`url`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->description . "', '"
                . $this->url . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `slider` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `slider` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`description` ='" . $this->description . "', "
                . "`url` ='" . $this->url . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `slider` WHERE id="' . $this->id . '"';
        unlink(Helper::getSitePath() . "upload/slider/" . $this->image_name);

        $db = new Database();

        return $db->readQuery($query);
    }

    public function arrange($key, $img) {
        $query = "UPDATE `slider` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Upload.php000064400000751702150755024470006526 0ustar00<?php

// +------------------------------------------------------------------------+
// | class.upload.php                                                       |
// +------------------------------------------------------------------------+
// | Copyright (c) Colin Verot 2003-2014. All rights reserved.              |
// | Email         [email protected]                                          |
// | Web           http://www.verot.net                                     |
// +------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify   |
// | it under the terms of the GNU General Public License version 2 as      |
// | published by the Free Software Foundation.                             |
// |                                                                        |
// | This program is distributed in the hope that it will be useful,        |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of         |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          |
// | GNU General Public License for more details.                           |
// |                                                                        |
// | You should have received a copy of the GNU General Public License      |
// | along with this program; if not, write to the                          |
// |   Free Software Foundation, Inc., 59 Temple Place, Suite 330,          |
// |   Boston, MA 02111-1307 USA                                            |
// |                                                                        |
// | Please give credit on sites that use class.upload and submit changes   |
// | of the script so other people can use them as well.                    |
// | This script is free to use, don't abuse.                               |
// +------------------------------------------------------------------------+

/**

 * Class upload

 *

 * @author    Colin Verot <[email protected]>

 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License

 * @copyright Colin Verot

 */
class upload {

    /**

     * Class version

     *

     * @access public

     * @var string

     */
    var $version;

    /**

     * Uploaded file name

     *

     * @access public

     * @var string

     */
    var $file_src_name;

    /**

     * Uploaded file name body (i.e. without extension)

     *

     * @access public

     * @var string

     */
    var $file_src_name_body;

    /**

     * Uploaded file name extension

     *

     * @access public

     * @var string

     */
    var $file_src_name_ext;

    /**

     * Uploaded file MIME type

     *

     * @access public

     * @var string

     */
    var $file_src_mime;

    /**

     * Uploaded file size, in bytes

     *

     * @access public

     * @var double

     */
    var $file_src_size;

    /**

     * Holds eventual PHP error code from $_FILES

     *

     * @access public

     * @var string

     */
    var $file_src_error;

    /**

     * Uloaded file name, including server path

     *

     * @access public

     * @var string

     */
    var $file_src_pathname;

    /**

     * Uloaded file name temporary copy

     *

     * @access private

     * @var string

     */
    var $file_src_temp;

    /**

     * Destination file name

     *

     * @access public

     * @var string

     */
    var $file_dst_path;

    /**

     * Destination file name

     *

     * @access public

     * @var string

     */
    var $file_dst_name;

    /**

     * Destination file name body (i.e. without extension)

     *

     * @access public

     * @var string

     */
    var $file_dst_name_body;

    /**

     * Destination file extension

     *

     * @access public

     * @var string

     */
    var $file_dst_name_ext;

    /**

     * Destination file name, including path

     *

     * @access public

     * @var string

     */
    var $file_dst_pathname;

    /**

     * Source image width

     *

     * @access public

     * @var integer

     */
    var $image_src_x;

    /**

     * Source image height

     *

     * @access public

     * @var integer

     */
    var $image_src_y;

    /**

     * Source image color depth

     *

     * @access public

     * @var integer

     */
    var $image_src_bits;

    /**

     * Number of pixels

     *

     * @access public

     * @var long

     */
    var $image_src_pixels;

    /**

     * Type of image (png, gif, jpg or bmp)

     *

     * @access public

     * @var string

     */
    var $image_src_type;

    /**

     * Destination image width

     *

     * @access public

     * @var integer

     */
    var $image_dst_x;

    /**

     * Destination image height

     *

     * @access public

     * @var integer

     */
    var $image_dst_y;

    /**

     * Destination image type (png, gif, jpg or bmp)

     *

     * @access public

     * @var integer

     */
    var $image_dst_type;

    /**

     * Supported image formats

     *

     * @access private

     * @var array

     */
    var $image_supported;

    /**

     * Flag to determine if the source file is an image

     *

     * @access public

     * @var boolean

     */
    var $file_is_image;

    /**

     * Flag set after instanciating the class

     *

     * Indicates if the file has been uploaded properly

     *

     * @access public

     * @var bool

     */
    var $uploaded;

    /**

     * Flag stopping PHP upload checks

     *

     * Indicates whether we instanciated the class with a filename, in which case

     * we will not check on the validity of the PHP *upload*

     *

     * This flag is automatically set to true when working on a local file

     *

     * Warning: for uploads, this flag MUST be set to false for security reason

     *

     * @access public

     * @var bool

     */
    var $no_upload_check;

    /**

     * Flag set after calling a process

     *

     * Indicates if the processing, and copy of the resulting file went OK

     *

     * @access public

     * @var bool

     */
    var $processed;

    /**

     * Holds eventual error message in plain english

     *

     * @access public

     * @var string

     */
    var $error;

    /**

     * Holds an HTML formatted log

     *

     * @access public

     * @var string

     */
    var $log;





    // overiddable processing variables

    /**

     * Set this variable to replace the name body (i.e. without extension)

     *

     * @access public

     * @var string

     */
    var $file_new_name_body;

    /**

     * Set this variable to append a string to the file name body

     *

     * @access public

     * @var string

     */
    var $file_name_body_add;

    /**

     * Set this variable to prepend a string to the file name body

     *

     * @access public

     * @var string

     */
    var $file_name_body_pre;

    /**

     * Set this variable to change the file extension

     *

     * @access public

     * @var string

     */
    var $file_new_name_ext;

    /**

     * Set this variable to format the filename (spaces changed to _)

     *

     * @access public

     * @var boolean

     */
    var $file_safe_name;

    /**

     * Forces an extension if the source file doesn't have one

     *

     * If the file is an image, then the correct extension will be added

     * Otherwise, a .txt extension will be chosen

     *

     * @access public

     * @var boolean

     */
    var $file_force_extension;

    /**

     * Set this variable to false if you don't want to check the MIME against the allowed list

     *

     * This variable is set to true by default for security reason

     *

     * @access public

     * @var boolean

     */
    var $mime_check;

    /**

     * Set this variable to false in the init() function if you don't want to check the MIME

     * with Fileinfo PECL extension. On some systems, Fileinfo is known to be buggy, and you

     * may want to deactivate it in the class code directly.

     *

     * You can also set it with the path of the magic database file.

     * If set to true, the class will try to read the MAGIC environment variable

     *   and if it is empty, will default to the system's default

     * If set to an empty string, it will call finfo_open without the path argument

     *

     * This variable is set to true by default for security reason

     *

     * @access public

     * @var boolean

     */
    var $mime_fileinfo;

    /**

     * Set this variable to false in the init() function if you don't want to check the MIME

     * with UNIX file() command

     *

     * This variable is set to true by default for security reason

     *

     * @access public

     * @var boolean

     */
    var $mime_file;

    /**

     * Set this variable to false in the init() function if you don't want to check the MIME

     * with the magic.mime file

     *

     * The function mime_content_type() will be deprecated,

     * and this variable will be set to false in a future release

     *

     * This variable is set to true by default for security reason

     *

     * @access public

     * @var boolean

     */
    var $mime_magic;

    /**

     * Set this variable to false in the init() function if you don't want to check the MIME

     * with getimagesize()

     *

     * The class tries to get a MIME type from getimagesize()

     * If no MIME is returned, it tries to guess the MIME type from the file type

     *

     * This variable is set to true by default for security reason

     *

     * @access public

     * @var boolean

     */
    var $mime_getimagesize;

    /**

     * Set this variable to false if you don't want to turn dangerous scripts into simple text files

     *

     * @access public

     * @var boolean

     */
    var $no_script;

    /**

     * Set this variable to true to allow automatic renaming of the file

     * if the file already exists

     *

     * Default value is true

     *

     * For instance, on uploading foo.ext,<br>

     * if foo.ext already exists, upload will be renamed foo_1.ext<br>

     * and if foo_1.ext already exists, upload will be renamed foo_2.ext<br>

     *

     * Note that this option doesn't have any effect if {@link file_overwrite} is true

     *

     * @access public

     * @var bool

     */
    var $file_auto_rename;

    /**

     * Set this variable to true to allow automatic creation of the destination

     * directory if it is missing (works recursively)

     *

     * Default value is true

     *

     * @access public

     * @var bool

     */
    var $dir_auto_create;

    /**

     * Set this variable to true to allow automatic chmod of the destination

     * directory if it is not writeable

     *

     * Default value is true

     *

     * @access public

     * @var bool

     */
    var $dir_auto_chmod;

    /**

     * Set this variable to the default chmod you want the class to use

     * when creating directories, or attempting to write in a directory

     *

     * Default value is 0777 (without quotes)

     *

     * @access public

     * @var bool

     */
    var $dir_chmod;

    /**

     * Set this variable tu true to allow overwriting of an existing file

     *

     * Default value is false, so no files will be overwritten

     *

     * @access public

     * @var bool

     */
    var $file_overwrite;

    /**

     * Set this variable to change the maximum size in bytes for an uploaded file

     *

     * Default value is the value <i>upload_max_filesize</i> from php.ini

     *

     * Value in bytes (integer) or shorthand byte values (string) is allowed.

     * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes)

     *

     * @access public

     * @var double

     */
    var $file_max_size;

    /**

     * Set this variable to true to resize the file if it is an image

     *

     * You will probably want to set {@link image_x} and {@link image_y}, and maybe one of the ratio variables

     *

     * Default value is false (no resizing)

     *

     * @access public

     * @var bool

     */
    var $image_resize;

    /**

     * Set this variable to convert the file if it is an image

     *

     * Possibles values are : ''; 'png'; 'jpeg'; 'gif'; 'bmp'

     *

     * Default value is '' (no conversion)<br>

     * If {@link resize} is true, {@link convert} will be set to the source file extension

     *

     * @access public

     * @var string

     */
    var $image_convert;

    /**

     * Set this variable to the wanted (or maximum/minimum) width for the processed image, in pixels

     *

     * Default value is 150

     *

     * @access public

     * @var integer

     */
    var $image_x;

    /**

     * Set this variable to the wanted (or maximum/minimum) height for the processed image, in pixels

     *

     * Default value is 150

     *

     * @access public

     * @var integer

     */
    var $image_y;

    /**

     * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}

     *

     * Default value is false

     *

     * @access public

     * @var bool

     */
    var $image_ratio;

    /**

     * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}

     *

     * The image will be resized as to fill the whole space, and excedent will be cropped

     *

     * Value can also be a string, one or more character from 'TBLR' (top, bottom, left and right)

     * If set as a string, it determines which side of the image is kept while cropping.

     * By default, the part of the image kept is in the center, i.e. it crops equally on both sides

     *

     * Default value is false

     *

     * @access public

     * @var mixed

     */
    var $image_ratio_crop;

    /**

     * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}

     *

     * The image will be resized to fit entirely in the space, and the rest will be colored.

     * The default color is white, but can be set with {@link image_default_color}

     *

     * Value can also be a string, one or more character from 'TBLR' (top, bottom, left and right)

     * If set as a string, it determines in which side of the space the image is displayed.

     * By default, the image is displayed in the center, i.e. it fills the remaining space equally on both sides

     *

     * Default value is false

     *

     * @access public

     * @var mixed

     */
    var $image_ratio_fill;

    /**

     * Set this variable to a number of pixels so that {@link image_x} and {@link image_y} are the best match possible

     *

     * The image will be resized to have approximatively the number of pixels

     * The aspect ratio wil be conserved

     *

     * Default value is false

     *

     * @access public

     * @var mixed

     */
    var $image_ratio_pixels;

    /**

     * Set this variable to calculate {@link image_x} automatically , using {@link image_y} and conserving ratio

     *

     * Default value is false

     *

     * @access public

     * @var bool

     */
    var $image_ratio_x;

    /**

     * Set this variable to calculate {@link image_y} automatically , using {@link image_x} and conserving ratio

     *

     * Default value is false

     *

     * @access public

     * @var bool

     */
    var $image_ratio_y;

    /**

     * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y},

     * but only if original image is bigger

     *

     * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_enlarging}

     *

     * Default value is false

     *

     * @access public

     * @var bool

     */
    var $image_ratio_no_zoom_in;

    /**

     * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y},

     * but only if original image is smaller

     *

     * Default value is false

     *

     * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_shrinking}

     *

     * @access public

     * @var bool

     */
    var $image_ratio_no_zoom_out;

    /**

     * Cancel resizing if the resized image is bigger than the original image, to prevent enlarging

     *

     * Default value is false

     *

     * @access public

     * @var bool

     */
    var $image_no_enlarging;

    /**

     * Cancel resizing if the resized image is smaller than the original image, to prevent shrinking

     *

     * Default value is false

     *

     * @access public

     * @var bool

     */
    var $image_no_shrinking;

    /**

     * Set this variable to set a maximum image width, above which the upload will be invalid

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_max_width;

    /**

     * Set this variable to set a maximum image height, above which the upload will be invalid

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_max_height;

    /**

     * Set this variable to set a maximum number of pixels for an image, above which the upload will be invalid

     *

     * Default value is null

     *

     * @access public

     * @var long

     */
    var $image_max_pixels;

    /**

     * Set this variable to set a maximum image aspect ratio, above which the upload will be invalid

     *

     * Note that ratio = width / height

     *

     * Default value is null

     *

     * @access public

     * @var float

     */
    var $image_max_ratio;

    /**

     * Set this variable to set a minimum image width, below which the upload will be invalid

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_min_width;

    /**

     * Set this variable to set a minimum image height, below which the upload will be invalid

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_min_height;

    /**

     * Set this variable to set a minimum number of pixels for an image, below which the upload will be invalid

     *

     * Default value is null

     *

     * @access public

     * @var long

     */
    var $image_min_pixels;

    /**

     * Set this variable to set a minimum image aspect ratio, below which the upload will be invalid

     *

     * Note that ratio = width / height

     *

     * Default value is null

     *

     * @access public

     * @var float

     */
    var $image_min_ratio;

    /**

     * Compression level for PNG images

     *

     * Between 1 (fast but large files) and 9 (slow but smaller files)

     *

     * Default value is null (Zlib default)

     *

     * @access public

     * @var integer

     */
    var $png_compression;

    /**

     * Quality of JPEG created/converted destination image

     *

     * Default value is 85

     *

     * @access public

     * @var integer

     */
    var $jpeg_quality;

    /**

     * Determines the quality of the JPG image to fit a desired file size

     *

     * The JPG quality will be set between 1 and 100%

     * The calculations are approximations.

     *

     * Value in bytes (integer) or shorthand byte values (string) is allowed.

     * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes)

     *

     * Default value is null (no calculations)

     *

     * @access public

     * @var integer

     */
    var $jpeg_size;

    /**

     * Turns the interlace bit on

     *

     * This is actually used only for JPEG images, and defaults to false

     *

     * @access public

     * @var boolean

     */
    var $image_interlace;

    /**

     * Flag set to true when the image is transparent

     *

     * This is actually used only for transparent GIFs

     *

     * @access public

     * @var boolean

     */
    var $image_is_transparent;

    /**

     * Transparent color in a palette

     *

     * This is actually used only for transparent GIFs

     *

     * @access public

     * @var boolean

     */
    var $image_transparent_color;

    /**

     * Background color, used to paint transparent areas with

     *

     * If set, it will forcibly remove transparency by painting transparent areas with the color

     * This setting will fill in all transparent areas in PNG and GIF, as opposed to {@link image_default_color}

     * which will do so only in BMP, JPEG, and alpha transparent areas in transparent GIFs

     * This setting overrides {@link image_default_color}

     *

     * Default value is null

     *

     * @access public

     * @var string

     */
    var $image_background_color;

    /**

     * Default color for non alpha-transparent images

     *

     * This setting is to be used to define a background color for semi transparent areas

     * of an alpha transparent when the output format doesn't support alpha transparency

     * This is useful when, from an alpha transparent PNG image, or an image with alpha transparent features

     * if you want to output it as a transparent GIFs for instance, you can set a blending color for transparent areas

     * If you output in JPEG or BMP, this color will be used to fill in the previously transparent areas

     *

     * The default color white

     *

     * @access public

     * @var boolean

     */
    var $image_default_color;

    /**

     * Flag set to true when the image is not true color

     *

     * @access public

     * @var boolean

     */
    var $image_is_palette;

    /**

     * Corrects the image brightness

     *

     * Value can range between -127 and 127

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_brightness;

    /**

     * Corrects the image contrast

     *

     * Value can range between -127 and 127

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_contrast;

    /**

     * Changes the image opacity

     *

     * Value can range between 0 and 100

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_opacity;

    /**

     * Applies threshold filter

     *

     * Value can range between -127 and 127

     *

     * Default value is null

     *

     * @access public

     * @var integer

     */
    var $image_threshold;

    /**

     * Applies a tint on the image

     *

     * Value is an hexadecimal color, such as #FFFFFF

     *

     * Default value is null

     *

     * @access public

     * @var string;

     */
    var $image_tint_color;

    /**

     * Applies a colored overlay on the image

     *

     * Value is an hexadecimal color, such as #FFFFFF

     *

     * To use with {@link image_overlay_opacity}

     *

     * Default value is null

     *

     * @access public

     * @var string;

     */
    var $image_overlay_color;

    /**

     * Sets the opacity for the colored overlay

     *

     * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)

     *

     * Unless used with {@link image_overlay_color}, this setting has no effect

     *

     * Default value is 50

     *

     * @access public

     * @var integer

     */
    var $image_overlay_opacity;

    /**

     * Inverts the color of an image

     *

     * Default value is FALSE

     *

     * @access public

     * @var boolean;

     */
    var $image_negative;

    /**

     * Turns the image into greyscale

     *

     * Default value is FALSE

     *

     * @access public

     * @var boolean;

     */
    var $image_greyscale;

    /**

     * Pixelate an image

     *

     * Value is integer, represents the block size

     *

     * Default value is null

     *

     * @access public

     * @var integer;

     */
    var $image_pixelate;

    /**

     * Applies an unsharp mask, with alpha transparency support

     *

     * Beware that this unsharp mask is quite resource-intensive

     *

     * Default value is FALSE

     *

     * @access public

     * @var boolean;

     */
    var $image_unsharp;

    /**

     * Sets the unsharp mask amount

     *

     * Value is an integer between 0 and 500, typically between 50 and 200

     *

     * Unless used with {@link image_unsharp}, this setting has no effect

     *

     * Default value is 80

     *

     * @access public

     * @var integer

     */
    var $image_unsharp_amount;

    /**

     * Sets the unsharp mask radius

     *

     * Value is an integer between 0 and 50, typically between 0.5 and 1

     * It is not recommended to change it, the default works best

     *

     * Unless used with {@link image_unsharp}, this setting has no effect

     *

     * From PHP 5.1, imageconvolution is used, and this setting has no effect

     *

     * Default value is 0.5

     *

     * @access public

     * @var integer

     */
    var $image_unsharp_radius;

    /**

     * Sets the unsharp mask threshold

     *

     * Value is an integer between 0 and 255, typically between 0 and 5

     *

     * Unless used with {@link image_unsharp}, this setting has no effect

     *

     * Default value is 1

     *

     * @access public

     * @var integer

     */
    var $image_unsharp_threshold;

    /**

     * Adds a text label on the image

     *

     * Value is a string, any text. Text will not word-wrap, although you can use breaklines in your text "\n"

     *

     * If set, this setting allow the use of all other settings starting with image_text_

     *

     * Replacement tokens can be used in the string:

     * <pre>

     * gd_version    src_name       src_name_body src_name_ext

     * src_pathname  src_mime       src_x         src_y

     * src_type      src_bits       src_pixels

     * src_size      src_size_kb    src_size_mb   src_size_human

     * dst_path      dst_name_body  dst_pathname

     * dst_name      dst_name_ext   dst_x         dst_y

     * date          time           host          server        ip

     * </pre>

     * The tokens must be enclosed in square brackets: [dst_x] will be replaced by the width of the picture

     *

     * Default value is null

     *

     * @access public

     * @var string;

     */
    var $image_text;

    /**

     * Sets the text direction for the text label

     *

     * Value is either 'h' or 'v', as in horizontal and vertical

     *

     * Note that if you use a TrueType font, you can use {@link image_text_angle} instead

     *

     * Default value is h (horizontal)

     *

     * @access public

     * @var string;

     */
    var $image_text_direction;

    /**

     * Sets the text color for the text label

     *

     * Value is an hexadecimal color, such as #FFFFFF

     *

     * Default value is #FFFFFF (white)

     *

     * @access public

     * @var string;

     */
    var $image_text_color;

    /**

     * Sets the text opacity in the text label

     *

     * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)

     *

     * Default value is 100

     *

     * @access public

     * @var integer

     */
    var $image_text_opacity;

    /**

     * Sets the text background color for the text label

     *

     * Value is an hexadecimal color, such as #FFFFFF

     *

     * Default value is null (no background)

     *

     * @access public

     * @var string;

     */
    var $image_text_background;

    /**

     * Sets the text background opacity in the text label

     *

     * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)

     *

     * Default value is 100

     *

     * @access public

     * @var integer

     */
    var $image_text_background_opacity;

    /**

     * Sets the text font in the text label

     *

     * Value is a an integer between 1 and 5 for GD built-in fonts. 1 is the smallest font, 5 the biggest

     * Value can also be a string, which represents the path to a GDF or TTF font (TrueType).

     *

     * Default value is 5

     *

     * @access public

     * @var mixed;

     */
    var $image_text_font;

    /**

     * Sets the text font size for TrueType fonts

     *

     * Value is a an integer, and represents the font size in pixels (GD1) or points (GD1)

     *

     * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts

     *

     * Default value is 16

     *

     * @access public

     * @var integer;

     */
    var $image_text_size;

    /**

     * Sets the text angle for TrueType fonts

     *

     * Value is a an integer between 0 and 360, in degrees, with 0 degrees being left-to-right reading text.

     *

     * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts

     * For GD fonts, you can use {@link image_text_direction} instead

     *

     * Default value is null (so it is determined by the value of {@link image_text_direction})

     *

     * @access public

     * @var integer;

     */
    var $image_text_angle;

    /**

     * Sets the text label position within the image

     *

     * Value is one or two out of 'TBLR' (top, bottom, left, right)

     *

     * The positions are as following:

     * <pre>

     *                        TL  T  TR

     *                        L       R

     *                        BL  B  BR

     * </pre>

     *

     * Default value is null (centered, horizontal and vertical)

     *

     * Note that is {@link image_text_x} and {@link image_text_y} are used, this setting has no effect

     *

     * @access public

     * @var string;

     */
    var $image_text_position;

    /**

     * Sets the text label absolute X position within the image

     *

     * Value is in pixels, representing the distance between the left of the image and the label

     * If a negative value is used, it will represent the distance between the right of the image and the label

     *

     * Default value is null (so {@link image_text_position} is used)

     *

     * @access public

     * @var integer

     */
    var $image_text_x;

    /**

     * Sets the text label absolute Y position within the image

     *

     * Value is in pixels, representing the distance between the top of the image and the label

     * If a negative value is used, it will represent the distance between the bottom of the image and the label

     *

     * Default value is null (so {@link image_text_position} is used)

     *

     * @access public

     * @var integer

     */
    var $image_text_y;

    /**

     * Sets the text label padding

     *

     * Value is in pixels, representing the distance between the text and the label background border

     *

     * Default value is 0

     *

     * This setting can be overriden by {@link image_text_padding_x} and {@link image_text_padding_y}

     *

     * @access public

     * @var integer

     */
    var $image_text_padding;

    /**

     * Sets the text label horizontal padding

     *

     * Value is in pixels, representing the distance between the text and the left and right label background borders

     *

     * Default value is null

     *

     * If set, this setting overrides the horizontal part of {@link image_text_padding}

     *

     * @access public

     * @var integer

     */
    var $image_text_padding_x;

    /**

     * Sets the text label vertical padding

     *

     * Value is in pixels, representing the distance between the text and the top and bottom label background borders

     *

     * Default value is null

     *

     * If set, his setting overrides the vertical part of {@link image_text_padding}

     *

     * @access public

     * @var integer

     */
    var $image_text_padding_y;

    /**

     * Sets the text alignment

     *

     * Value is a string, which can be either 'L', 'C' or 'R'

     *

     * Default value is 'C'

     *

     * This setting is relevant only if the text has several lines.

     *

     * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts

     *

     * @access public

     * @var string;

     */
    var $image_text_alignment;

    /**

     * Sets the text line spacing

     *

     * Value is an integer, in pixels

     *

     * Default value is 0

     *

     * This setting is relevant only if the text has several lines.

     *

     * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts

     *

     * @access public

     * @var integer

     */
    var $image_text_line_spacing;

    /**

     * Sets the height of the reflection

     *

     * Value is an integer in pixels, or a string which format can be in pixels or percentage.

     * For instance, values can be : 40, '40', '40px' or '40%'

     *

     * Default value is null, no reflection

     *

     * @access public

     * @var mixed;

     */
    var $image_reflection_height;

    /**

     * Sets the space between the source image and its relection

     *

     * Value is an integer in pixels, which can be negative

     *

     * Default value is 2

     *

     * This setting is relevant only if {@link image_reflection_height} is set

     *

     * @access public

     * @var integer

     */
    var $image_reflection_space;

    /**

     * Sets the initial opacity of the reflection

     *

     * Value is an integer between 0 (no opacity) and 100 (full opacity).

     * The reflection will start from {@link image_reflection_opacity} and end up at 0

     *

     * Default value is 60

     *

     * This setting is relevant only if {@link image_reflection_height} is set

     *

     * @access public

     * @var integer

     */
    var $image_reflection_opacity;

    /**

     * Automatically rotates the image according to EXIF data (JPEG only)

     *

     * Default value is true

     *

     * @access public

     * @var boolean;

     */
    var $image_auto_rotate;

    /**

     * Flips the image vertically or horizontally

     *

     * Value is either 'h' or 'v', as in horizontal and vertical

     *

     * Default value is null (no flip)

     *

     * @access public

     * @var string;

     */
    var $image_flip;

    /**

     * Rotates the image by increments of 45 degrees

     *

     * Value is either 90, 180 or 270

     *

     * Default value is null (no rotation)

     *

     * @access public

     * @var string;

     */
    var $image_rotate;

    /**

     * Crops an image

     *

     * Values are four dimensions, or two, or one (CSS style)

     * They represent the amount cropped top, right, bottom and left.

     * These values can either be in an array, or a space separated string.

     * Each value can be in pixels (with or without 'px'), or percentage (of the source image)

     *

     * For instance, are valid:

     * <pre>

     * $foo->image_crop = 20                  OR array(20);

     * $foo->image_crop = '20px'              OR array('20px');

     * $foo->image_crop = '20 40'             OR array('20', 40);

     * $foo->image_crop = '-20 25%'           OR array(-20, '25%');

     * $foo->image_crop = '20px 25%'          OR array('20px', '25%');

     * $foo->image_crop = '20% 25%'           OR array('20%', '25%');

     * $foo->image_crop = '20% 25% 10% 30%'   OR array('20%', '25%', '10%', '30%');

     * $foo->image_crop = '20px 25px 2px 2px' OR array('20px', '25%px', '2px', '2px');

     * $foo->image_crop = '20 25% 40px 10%'   OR array(20, '25%', '40px', '10%');

     * </pre>

     *

     * If a value is negative, the image will be expanded, and the extra parts will be filled with black

     *

     * Default value is null (no cropping)

     *

     * @access public

     * @var string OR array;

     */
    var $image_crop;

    /**

     * Crops an image, before an eventual resizing

     *

     * See {@link image_crop} for valid formats

     *

     * Default value is null (no cropping)

     *

     * @access public

     * @var string OR array;

     */
    var $image_precrop;

    /**

     * Adds a bevel border on the image

     *

     * Value is a positive integer, representing the thickness of the bevel

     *

     * If the bevel colors are the same as the background, it makes a fade out effect

     *

     * Default value is null (no bevel)

     *

     * @access public

     * @var integer

     */
    var $image_bevel;

    /**

     * Top and left bevel color

     *

     * Value is a color, in hexadecimal format

     * This setting is used only if {@link image_bevel} is set

     *

     * Default value is #FFFFFF

     *

     * @access public

     * @var string;

     */
    var $image_bevel_color1;

    /**

     * Right and bottom bevel color

     *

     * Value is a color, in hexadecimal format

     * This setting is used only if {@link image_bevel} is set

     *

     * Default value is #000000

     *

     * @access public

     * @var string;

     */
    var $image_bevel_color2;

    /**

     * Adds a single-color border on the outer of the image

     *

     * Values are four dimensions, or two, or one (CSS style)

     * They represent the border thickness top, right, bottom and left.

     * These values can either be in an array, or a space separated string.

     * Each value can be in pixels (with or without 'px'), or percentage (of the source image)

     *

     * See {@link image_crop} for valid formats

     *

     * If a value is negative, the image will be cropped.

     * Note that the dimensions of the picture will be increased by the borders' thickness

     *

     * Default value is null (no border)

     *

     * @access public

     * @var integer

     */
    var $image_border;

    /**

     * Border color

     *

     * Value is a color, in hexadecimal format.

     * This setting is used only if {@link image_border} is set

     *

     * Default value is #FFFFFF

     *

     * @access public

     * @var string;

     */
    var $image_border_color;

    /**

     * Sets the opacity for the borders

     *

     * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)

     *

     * Unless used with {@link image_border}, this setting has no effect

     *

     * Default value is 100

     *

     * @access public

     * @var integer

     */
    var $image_border_opacity;

    /**

     * Adds a fading-to-transparent border on the image

     *

     * Values are four dimensions, or two, or one (CSS style)

     * They represent the border thickness top, right, bottom and left.

     * These values can either be in an array, or a space separated string.

     * Each value can be in pixels (with or without 'px'), or percentage (of the source image)

     *

     * See {@link image_crop} for valid formats

     *

     * Note that the dimensions of the picture will not be increased by the borders' thickness

     *

     * Default value is null (no border)

     *

     * @access public

     * @var integer

     */
    var $image_border_transparent;

    /**

     * Adds a multi-color frame on the outer of the image

     *

     * Value is an integer. Two values are possible for now:

     * 1 for flat border, meaning that the frame is mirrored horizontally and vertically

     * 2 for crossed border, meaning that the frame will be inversed, as in a bevel effect

     *

     * The frame will be composed of colored lines set in {@link image_frame_colors}

     *

     * Note that the dimensions of the picture will be increased by the borders' thickness

     *

     * Default value is null (no frame)

     *

     * @access public

     * @var integer

     */
    var $image_frame;

    /**

     * Sets the colors used to draw a frame

     *

     * Values is a list of n colors in hexadecimal format.

     * These values can either be in an array, or a space separated string.

     *

     * The colors are listed in the following order: from the outset of the image to its center

     *

     * For instance, are valid:

     * <pre>

     * $foo->image_frame_colors = '#FFFFFF #999999 #666666 #000000';

     * $foo->image_frame_colors = array('#FFFFFF', '#999999', '#666666', '#000000');

     * </pre>

     *

     * This setting is used only if {@link image_frame} is set

     *

     * Default value is '#FFFFFF #999999 #666666 #000000'

     *

     * @access public

     * @var string OR array;

     */
    var $image_frame_colors;

    /**

     * Sets the opacity for the frame

     *

     * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)

     *

     * Unless used with {@link image_frame}, this setting has no effect

     *

     * Default value is 100

     *

     * @access public

     * @var integer

     */
    var $image_frame_opacity;

    /**

     * Adds a watermark on the image

     *

     * Value is a local image filename, relative or absolute. GIF, JPG, BMP and PNG are supported, as well as PNG alpha.

     *

     * If set, this setting allow the use of all other settings starting with image_watermark_

     *

     * Default value is null

     *

     * @access public

     * @var string;

     */
    var $image_watermark;

    /**

     * Sets the watermarkposition within the image

     *

     * Value is one or two out of 'TBLR' (top, bottom, left, right)

     *

     * The positions are as following:   TL  T  TR

     *                                   L       R

     *                                   BL  B  BR

     *

     * Default value is null (centered, horizontal and vertical)

     *

     * Note that is {@link image_watermark_x} and {@link image_watermark_y} are used, this setting has no effect

     *

     * @access public

     * @var string;

     */
    var $image_watermark_position;

    /**

     * Sets the watermark absolute X position within the image

     *

     * Value is in pixels, representing the distance between the top of the image and the watermark

     * If a negative value is used, it will represent the distance between the bottom of the image and the watermark

     *

     * Default value is null (so {@link image_watermark_position} is used)

     *

     * @access public

     * @var integer

     */
    var $image_watermark_x;

    /**

     * Sets the twatermark absolute Y position within the image

     *

     * Value is in pixels, representing the distance between the left of the image and the watermark

     * If a negative value is used, it will represent the distance between the right of the image and the watermark

     *

     * Default value is null (so {@link image_watermark_position} is used)

     *

     * @access public

     * @var integer

     */
    var $image_watermark_y;

    /**

     * Prevents the watermark to be resized up if it is smaller than the image

     *

     * If the watermark if smaller than the destination image, taking in account the desired watermark position

     * then it will be resized up to fill in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values)

     *

     * If you don't want your watermark to be resized in any way, then

     * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true

     * If you want your watermark to be resized up or doan to fill in the image better, then

     * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false

     *

     * Default value is true (so the watermark will not be resized up, which is the behaviour most people expect)

     *

     * @access public

     * @var integer

     */
    var $image_watermark_no_zoom_in;

    /**

     * Prevents the watermark to be resized down if it is bigger than the image

     *

     * If the watermark if bigger than the destination image, taking in account the desired watermark position

     * then it will be resized down to fit in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values)

     *

     * If you don't want your watermark to be resized in any way, then

     * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true

     * If you want your watermark to be resized up or doan to fill in the image better, then

     * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false

     *

     * Default value is false (so the watermark may be shrinked to fit in the image)

     *

     * @access public

     * @var integer

     */
    var $image_watermark_no_zoom_out;

    /**

     * List of MIME types per extension

     *

     * @access private

     * @var array

     */
    var $mime_types;

    /**

     * Allowed MIME types

     *

     * Default is a selection of safe mime-types, but you might want to change it

     *

     * Simple wildcards are allowed, such as image/* or application/*

     * If there is only one MIME type allowed, then it can be a string instead of an array

     *

     * @access public

     * @var array OR string

     */
    var $allowed;

    /**

     * Forbidden MIME types

     *

     * Default is a selection of safe mime-types, but you might want to change it

     * To only check for forbidden MIME types, and allow everything else, set {@link allowed} to array('* / *') without the spaces

     *

     * Simple wildcards are allowed, such as image/* or application/*

     * If there is only one MIME type forbidden, then it can be a string instead of an array

     *

     * @access public

     * @var array OR string

     */
    var $forbidden;

    /**

     * Array of translated error messages

     *

     * By default, the language is english (en_GB)

     * Translations can be in separate files, in a lang/ subdirectory

     *

     * @access public

     * @var array

     */
    var $translation;

    /**

     * Language selected for the translations

     *

     * By default, the language is english ("en_GB")

     *

     * @access public

     * @var array

     */
    var $lang;

    /**

     * Init or re-init all the processing variables to their default values

     *

     * This function is called in the constructor, and after each call of {@link process}

     *

     * @access private

     */
    function init() {



        // overiddable variables

        $this->file_new_name_body = null;     // replace the name body

        $this->file_name_body_add = null;     // append to the name body

        $this->file_name_body_pre = null;     // prepend to the name body

        $this->file_new_name_ext = null;     // replace the file extension

        $this->file_safe_name = true;     // format safely the filename

        $this->file_force_extension = true;     // forces extension if there isn't one

        $this->file_overwrite = false;    // allows overwritting if the file already exists

        $this->file_auto_rename = true;     // auto-rename if the file already exists

        $this->dir_auto_create = true;     // auto-creates directory if missing

        $this->dir_auto_chmod = true;     // auto-chmod directory if not writeable

        $this->dir_chmod = 0777;     // default chmod to use



        $this->no_script = true;     // turns scripts into test files

        $this->mime_check = true;     // checks the mime type against the allowed list
        // these are the different MIME detection methods. if one of these method doesn't work on your
        // system, you can deactivate it here; just set it to false

        $this->mime_fileinfo = true;     // MIME detection with Fileinfo PECL extension

        $this->mime_file = true;     // MIME detection with UNIX file() command

        $this->mime_magic = true;     // MIME detection with mime_magic (mime_content_type())

        $this->mime_getimagesize = true;     // MIME detection with getimagesize()
        // get the default max size from php.ini

        $this->file_max_size_raw = trim(ini_get('upload_max_filesize'));

        $this->file_max_size = $this->getsize($this->file_max_size_raw);



        $this->image_resize = false;    // resize the image

        $this->image_convert = '';       // convert. values :''; 'png'; 'jpeg'; 'gif'; 'bmp'



        $this->image_x = 150;

        $this->image_y = 150;

        $this->image_ratio = false;    // keeps aspect ratio with x and y dimensions

        $this->image_ratio_crop = false;    // keeps aspect ratio with x and y dimensions, filling the space

        $this->image_ratio_fill = false;    // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest

        $this->image_ratio_pixels = false;    // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels

        $this->image_ratio_x = false;    // calculate the $image_x if true

        $this->image_ratio_y = false;    // calculate the $image_y if true

        $this->image_ratio_no_zoom_in = false;

        $this->image_ratio_no_zoom_out = false;

        $this->image_no_enlarging = false;

        $this->image_no_shrinking = false;



        $this->png_compression = null;

        $this->jpeg_quality = 85;

        $this->jpeg_size = null;

        $this->image_interlace = false;

        $this->image_is_transparent = false;

        $this->image_transparent_color = null;

        $this->image_background_color = null;

        $this->image_default_color = '#ffffff';

        $this->image_is_palette = false;



        $this->image_max_width = null;

        $this->image_max_height = null;

        $this->image_max_pixels = null;

        $this->image_max_ratio = null;

        $this->image_min_width = null;

        $this->image_min_height = null;

        $this->image_min_pixels = null;

        $this->image_min_ratio = null;



        $this->image_brightness = null;

        $this->image_contrast = null;

        $this->image_opacity = null;

        $this->image_threshold = null;

        $this->image_tint_color = null;

        $this->image_overlay_color = null;

        $this->image_overlay_opacity = null;

        $this->image_negative = false;

        $this->image_greyscale = false;

        $this->image_pixelate = null;

        $this->image_unsharp = false;

        $this->image_unsharp_amount = 80;

        $this->image_unsharp_radius = 0.5;

        $this->image_unsharp_threshold = 1;



        $this->image_text = null;

        $this->image_text_direction = null;

        $this->image_text_color = '#FFFFFF';

        $this->image_text_opacity = 100;

        $this->image_text_background = null;

        $this->image_text_background_opacity = 100;

        $this->image_text_font = 5;

        $this->image_text_size = 16;

        $this->image_text_angle = null;

        $this->image_text_x = null;

        $this->image_text_y = null;

        $this->image_text_position = null;

        $this->image_text_padding = 0;

        $this->image_text_padding_x = null;

        $this->image_text_padding_y = null;

        $this->image_text_alignment = 'C';

        $this->image_text_line_spacing = 0;



        $this->image_reflection_height = null;

        $this->image_reflection_space = 2;

        $this->image_reflection_opacity = 60;



        $this->image_watermark = null;

        $this->image_watermark_x = null;

        $this->image_watermark_y = null;

        $this->image_watermark_position = null;

        $this->image_watermark_no_zoom_in = true;

        $this->image_watermark_no_zoom_out = false;



        $this->image_flip = null;

        $this->image_auto_rotate = true;

        $this->image_rotate = null;

        $this->image_crop = null;

        $this->image_precrop = null;



        $this->image_bevel = null;

        $this->image_bevel_color1 = '#FFFFFF';

        $this->image_bevel_color2 = '#000000';

        $this->image_border = null;

        $this->image_border_color = '#FFFFFF';

        $this->image_border_opacity = 100;

        $this->image_border_transparent = null;

        $this->image_frame = null;

        $this->image_frame_colors = '#FFFFFF #999999 #666666 #000000';

        $this->image_frame_opacity = 100;



        $this->forbidden = array();

        $this->allowed = array(
            'application/arj',
            'application/excel',
            'application/gnutar',
            'application/mspowerpoint',
            'application/msword',
            'application/octet-stream',
            'application/onenote',
            'application/pdf',
            'application/plain',
            'application/postscript',
            'application/powerpoint',
            'application/rar',
            'application/rtf',
            'application/vnd.ms-excel',
            'application/vnd.ms-excel.addin.macroEnabled.12',
            'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
            'application/vnd.ms-excel.sheet.macroEnabled.12',
            'application/vnd.ms-excel.template.macroEnabled.12',
            'application/vnd.ms-office',
            'application/vnd.ms-officetheme',
            'application/vnd.ms-powerpoint',
            'application/vnd.ms-powerpoint.addin.macroEnabled.12',
            'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
            'application/vnd.ms-powerpoint.slide.macroEnabled.12',
            'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
            'application/vnd.ms-powerpoint.template.macroEnabled.12',
            'application/vnd.ms-word',
            'application/vnd.ms-word.document.macroEnabled.12',
            'application/vnd.ms-word.template.macroEnabled.12',
            'application/vnd.oasis.opendocument.chart',
            'application/vnd.oasis.opendocument.database',
            'application/vnd.oasis.opendocument.formula',
            'application/vnd.oasis.opendocument.graphics',
            'application/vnd.oasis.opendocument.graphics-template',
            'application/vnd.oasis.opendocument.image',
            'application/vnd.oasis.opendocument.presentation',
            'application/vnd.oasis.opendocument.presentation-template',
            'application/vnd.oasis.opendocument.spreadsheet',
            'application/vnd.oasis.opendocument.spreadsheet-template',
            'application/vnd.oasis.opendocument.text',
            'application/vnd.oasis.opendocument.text-master',
            'application/vnd.oasis.opendocument.text-template',
            'application/vnd.oasis.opendocument.text-web',
            'application/vnd.openofficeorg.extension',
            'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            'application/vnd.openxmlformats-officedocument.presentationml.slide',
            'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
            'application/vnd.openxmlformats-officedocument.presentationml.template',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
            'application/vocaltec-media-file',
            'application/wordperfect',
            'application/x-bittorrent',
            'application/x-bzip',
            'application/x-bzip2',
            'application/x-compressed',
            'application/x-excel',
            'application/x-gzip',
            'application/x-latex',
            'application/x-midi',
            'application/xml',
            'application/x-msexcel',
            'application/x-rar',
            'application/x-rar-compressed',
            'application/x-rtf',
            'application/x-shockwave-flash',
            'application/x-sit',
            'application/x-stuffit',
            'application/x-troff-msvideo',
            'application/x-zip',
            'application/x-zip-compressed',
            'application/zip',
            'audio/*',
            'image/*',
            'multipart/x-gzip',
            'multipart/x-zip',
            'text/plain',
            'text/rtf',
            'text/richtext',
            'text/xml',
            'video/*',
            'text/csv'
        );



        $this->mime_types = array(
            'jpg' => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpe' => 'image/jpeg',
            'gif' => 'image/gif',
            'png' => 'image/png',
            'bmp' => 'image/bmp',
            'flif' => 'image/flif',
            'flv' => 'video/x-flv',
            'js' => 'application/x-javascript',
            'json' => 'application/json',
            'tiff' => 'image/tiff',
            'css' => 'text/css',
            'xml' => 'application/xml',
            'doc' => 'application/msword',
            'xls' => 'application/vnd.ms-excel',
            'xlt' => 'application/vnd.ms-excel',
            'xlm' => 'application/vnd.ms-excel',
            'xld' => 'application/vnd.ms-excel',
            'xla' => 'application/vnd.ms-excel',
            'xlc' => 'application/vnd.ms-excel',
            'xlw' => 'application/vnd.ms-excel',
            'xll' => 'application/vnd.ms-excel',
            'ppt' => 'application/vnd.ms-powerpoint',
            'pps' => 'application/vnd.ms-powerpoint',
            'rtf' => 'application/rtf',
            'pdf' => 'application/pdf',
            'html' => 'text/html',
            'htm' => 'text/html',
            'php' => 'text/html',
            'txt' => 'text/plain',
            'mpeg' => 'video/mpeg',
            'mpg' => 'video/mpeg',
            'mpe' => 'video/mpeg',
            'mp3' => 'audio/mpeg3',
            'wav' => 'audio/wav',
            'aiff' => 'audio/aiff',
            'aif' => 'audio/aiff',
            'avi' => 'video/msvideo',
            'wmv' => 'video/x-ms-wmv',
            'mov' => 'video/quicktime',
            'zip' => 'application/zip',
            'tar' => 'application/x-tar',
            'swf' => 'application/x-shockwave-flash',
            'odt' => 'application/vnd.oasis.opendocument.text',
            'ott' => 'application/vnd.oasis.opendocument.text-template',
            'oth' => 'application/vnd.oasis.opendocument.text-web',
            'odm' => 'application/vnd.oasis.opendocument.text-master',
            'odg' => 'application/vnd.oasis.opendocument.graphics',
            'otg' => 'application/vnd.oasis.opendocument.graphics-template',
            'odp' => 'application/vnd.oasis.opendocument.presentation',
            'otp' => 'application/vnd.oasis.opendocument.presentation-template',
            'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
            'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
            'odc' => 'application/vnd.oasis.opendocument.chart',
            'odf' => 'application/vnd.oasis.opendocument.formula',
            'odb' => 'application/vnd.oasis.opendocument.database',
            'odi' => 'application/vnd.oasis.opendocument.image',
            'oxt' => 'application/vnd.openofficeorg.extension',
            'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
            'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
            'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
            'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
            'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
            'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
            'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
            'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
            'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
            'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
            'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
            'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
            'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
            'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
            'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
            'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12',
            'thmx' => 'application/vnd.ms-officetheme',
            'onetoc' => 'application/onenote',
            'onetoc2' => 'application/onenote',
            'onetmp' => 'application/onenote',
            'onepkg' => 'application/onenote',
            'csv' => 'text/csv',
        );
    }

    /**

     * Constructor, for PHP5+

     */
    function __construct($file, $lang = 'en_GB') {

        $this->upload($file, $lang);
    }

    /**

     * Constructor, for PHP4. Checks if the file has been uploaded

     *

     * The constructor takes $_FILES['form_field'] array as argument

     * where form_field is the form field name

     *

     * The constructor will check if the file has been uploaded in its temporary location, and

     * accordingly will set {@link uploaded} (and {@link error} is an error occurred)

     *

     * If the file has been uploaded, the constructor will populate all the variables holding the upload

     * information (none of the processing class variables are used here).

     * You can have access to information about the file (name, size, MIME type...).

     *

     *

     * Alternatively, you can set the first argument to be a local filename (string)

     * This allows processing of a local file, as if the file was uploaded

     *

     * The optional second argument allows you to set the language for the error messages

     *

     * @access private

     * @param  array  $file $_FILES['form_field']

     *    or   string $file Local filename

     * @param  string $lang Optional language code

     */
    function upload($file, $lang = 'en_GB') {



        $this->version = '0.34dev';



        $this->file_src_name = '';

        $this->file_src_name_body = '';

        $this->file_src_name_ext = '';

        $this->file_src_mime = '';

        $this->file_src_size = '';

        $this->file_src_error = '';

        $this->file_src_pathname = '';

        $this->file_src_temp = '';



        $this->file_dst_path = '';

        $this->file_dst_name = '';

        $this->file_dst_name_body = '';

        $this->file_dst_name_ext = '';

        $this->file_dst_pathname = '';



        $this->image_src_x = null;

        $this->image_src_y = null;

        $this->image_src_bits = null;

        $this->image_src_type = null;

        $this->image_src_pixels = null;

        $this->image_dst_x = 0;

        $this->image_dst_y = 0;

        $this->image_dst_type = '';



        $this->uploaded = true;

        $this->no_upload_check = false;

        $this->processed = false;

        $this->error = '';

        $this->log = '';

        $this->allowed = array();

        $this->forbidden = array();

        $this->file_is_image = false;

        $this->init();

        $info = null;

        $mime_from_browser = null;



        // sets default language

        $this->translation = array();

        $this->translation['file_error'] = 'File error. Please try again.';

        $this->translation['local_file_missing'] = 'Local file doesn\'t exist.';

        $this->translation['local_file_not_readable'] = 'Local file is not readable.';

        $this->translation['uploaded_too_big_ini'] = 'File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini).';

        $this->translation['uploaded_too_big_html'] = 'File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form).';

        $this->translation['uploaded_partial'] = 'File upload error (the uploaded file was only partially uploaded).';

        $this->translation['uploaded_missing'] = 'File upload error (no file was uploaded).';

        $this->translation['uploaded_no_tmp_dir'] = 'File upload error (missing a temporary folder).';

        $this->translation['uploaded_cant_write'] = 'File upload error (failed to write file to disk).';

        $this->translation['uploaded_err_extension'] = 'File upload error (file upload stopped by extension).';

        $this->translation['uploaded_unknown'] = 'File upload error (unknown error code).';

        $this->translation['try_again'] = 'File upload error. Please try again.';

        $this->translation['file_too_big'] = 'File too big.';

        $this->translation['no_mime'] = 'MIME type can\'t be detected.';

        $this->translation['incorrect_file'] = 'Incorrect type of file.';

        $this->translation['image_too_wide'] = 'Image too wide.';

        $this->translation['image_too_narrow'] = 'Image too narrow.';

        $this->translation['image_too_high'] = 'Image too tall.';

        $this->translation['image_too_short'] = 'Image too short.';

        $this->translation['ratio_too_high'] = 'Image ratio too high (image too wide).';

        $this->translation['ratio_too_low'] = 'Image ratio too low (image too high).';

        $this->translation['too_many_pixels'] = 'Image has too many pixels.';

        $this->translation['not_enough_pixels'] = 'Image has not enough pixels.';

        $this->translation['file_not_uploaded'] = 'File not uploaded. Can\'t carry on a process.';

        $this->translation['already_exists'] = '%s already exists. Please change the file name.';

        $this->translation['temp_file_missing'] = 'No correct temp source file. Can\'t carry on a process.';

        $this->translation['source_missing'] = 'No correct uploaded source file. Can\'t carry on a process.';

        $this->translation['destination_dir'] = 'Destination directory can\'t be created. Can\'t carry on a process.';

        $this->translation['destination_dir_missing'] = 'Destination directory doesn\'t exist. Can\'t carry on a process.';

        $this->translation['destination_path_not_dir'] = 'Destination path is not a directory. Can\'t carry on a process.';

        $this->translation['destination_dir_write'] = 'Destination directory can\'t be made writeable. Can\'t carry on a process.';

        $this->translation['destination_path_write'] = 'Destination path is not a writeable. Can\'t carry on a process.';

        $this->translation['temp_file'] = 'Can\'t create the temporary file. Can\'t carry on a process.';

        $this->translation['source_not_readable'] = 'Source file is not readable. Can\'t carry on a process.';

        $this->translation['no_create_support'] = 'No create from %s support.';

        $this->translation['create_error'] = 'Error in creating %s image from source.';

        $this->translation['source_invalid'] = 'Can\'t read image source. Not an image?.';

        $this->translation['gd_missing'] = 'GD doesn\'t seem to be present.';

        $this->translation['watermark_no_create_support'] = 'No create from %s support, can\'t read watermark.';

        $this->translation['watermark_create_error'] = 'No %s read support, can\'t create watermark.';

        $this->translation['watermark_invalid'] = 'Unknown image format, can\'t read watermark.';

        $this->translation['file_create'] = 'No %s create support.';

        $this->translation['no_conversion_type'] = 'No conversion type defined.';

        $this->translation['copy_failed'] = 'Error copying file on the server. copy() failed.';

        $this->translation['reading_failed'] = 'Error reading the file.';



        // determines the language

        $this->lang = $lang;

        if ($this->lang != 'en_GB' && file_exists(dirname(__FILE__) . '/lang') && file_exists(dirname(__FILE__) . '/lang/class.upload.' . $lang . '.php')) {

            $translation = null;

            include(dirname(__FILE__) . '/lang/class.upload.' . $lang . '.php');

            if (is_array($translation)) {

                $this->translation = array_merge($this->translation, $translation);
            } else {

                $this->lang = 'en_GB';
            }
        }





        // determines the supported MIME types, and matching image format

        $this->image_supported = array();

        if ($this->gdversion()) {

            if (imagetypes() & IMG_GIF) {

                $this->image_supported['image/gif'] = 'gif';
            }

            if (imagetypes() & IMG_JPG) {

                $this->image_supported['image/jpg'] = 'jpg';

                $this->image_supported['image/jpeg'] = 'jpg';

                $this->image_supported['image/pjpeg'] = 'jpg';
            }

            if (imagetypes() & IMG_PNG) {

                $this->image_supported['image/png'] = 'png';

                $this->image_supported['image/x-png'] = 'png';
            }

            if (imagetypes() & IMG_WBMP) {

                $this->image_supported['image/bmp'] = 'bmp';

                $this->image_supported['image/x-ms-bmp'] = 'bmp';

                $this->image_supported['image/x-windows-bmp'] = 'bmp';
            }
        }



        // display some system information

        if (empty($this->log)) {

            $this->log .= '<b>system information</b><br />';

            if ($this->function_enabled('ini_get_all')) {

                $inis = ini_get_all();

                $open_basedir = (array_key_exists('open_basedir', $inis) && array_key_exists('local_value', $inis['open_basedir']) && !empty($inis['open_basedir']['local_value'])) ? $inis['open_basedir']['local_value'] : false;
            } else {

                $open_basedir = false;
            }

            $gd = $this->gdversion() ? $this->gdversion(true) : 'GD not present';

            $supported = trim((in_array('png', $this->image_supported) ? 'png' : '') . ' ' . (in_array('jpg', $this->image_supported) ? 'jpg' : '') . ' ' . (in_array('gif', $this->image_supported) ? 'gif' : '') . ' ' . (in_array('bmp', $this->image_supported) ? 'bmp' : ''));

            $this->log .= '-&nbsp;class version           : ' . $this->version . '<br />';

            $this->log .= '-&nbsp;operating system        : ' . PHP_OS . '<br />';

            $this->log .= '-&nbsp;PHP version             : ' . PHP_VERSION . '<br />';

            $this->log .= '-&nbsp;GD version              : ' . $gd . '<br />';

            $this->log .= '-&nbsp;supported image types   : ' . (!empty($supported) ? $supported : 'none') . '<br />';

            $this->log .= '-&nbsp;open_basedir            : ' . (!empty($open_basedir) ? $open_basedir : 'no restriction') . '<br />';

            $this->log .= '-&nbsp;upload_max_filesize     : ' . $this->file_max_size_raw . ' (' . $this->file_max_size . ' bytes)<br />';

            $this->log .= '-&nbsp;language                : ' . $this->lang . '<br />';
        }



        if (!$file) {

            $this->uploaded = false;

            $this->error = $this->translate('file_error');
        }



        // check if we sent a local filename or a PHP stream rather than a $_FILE element

        if (!is_array($file)) {

            if (empty($file)) {

                $this->uploaded = false;

                $this->error = $this->translate('file_error');
            } else {

                if (substr($file, 0, 4) == 'php:' || substr($file, 0, 5) == 'data:' || substr($file, 0, 7) == 'base64:') {

                    $data = null;



                    // this is a PHP stream, i.e.not uploaded

                    if (substr($file, 0, 4) == 'php:') {

                        $file = preg_replace('/^php:(.*)/i', '$1', $file);

                        if (!$file)
                            $file = $_SERVER['HTTP_X_FILE_NAME'];

                        if (!$file)
                            $file = 'unknown';

                        $data = file_get_contents('php://input');

                        $this->log .= '<b>source is a PHP stream ' . $file . ' of length ' . strlen($data) . '</b><br />';



                        // this is the raw file data, i.e.not uploaded
                    } else if (substr($file, 0, 5) == 'data:') {

                        $data = preg_replace('/^data:(.*)/i', '$1', $file);

                        $file = 'data';

                        $this->log .= '<b>source is a data string of length ' . strlen($data) . '</b><br />';



                        // this is the raw file data, base64-encoded, i.e.not uploaded
                    } else if (substr($file, 0, 7) == 'base64:') {

                        $data = base64_decode(preg_replace('/^base64:(?:.*base64,)?(.*)/i', '$1', $file));

                        $file = 'base64';

                        $this->log .= '<b>source is a base64 data string of length ' . strlen($data) . '</b><br />';
                    }



                    if (!$data) {

                        $this->log .= '- source is empty!<br />';

                        $this->uploaded = false;

                        $this->error = $this->translate('source_invalid');
                    }



                    $this->no_upload_check = TRUE;



                    if ($this->uploaded) {

                        $this->log .= '- requires a temp file ... ';

                        $hash = $this->temp_dir() . md5($file . rand(1, 1000));

                        if ($data && file_put_contents($hash, $data)) {

                            $this->file_src_pathname = $hash;

                            $this->log .= ' file created<br />';

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;temp file is: ' . $this->file_src_pathname . '<br />';
                        } else {

                            $this->log .= ' failed<br />';

                            $this->uploaded = false;

                            $this->error = $this->translate('temp_file');
                        }
                    }



                    if ($this->uploaded) {

                        $this->file_src_name = $file;

                        $this->log .= '- local file OK<br />';

                        preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

                        if (is_array($extension) && sizeof($extension) > 0) {

                            $this->file_src_name_ext = strtolower($extension[1]);

                            $this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext))) - 1);
                        } else {

                            $this->file_src_name_ext = '';

                            $this->file_src_name_body = $this->file_src_name;
                        }

                        $this->file_src_size = (file_exists($this->file_src_pathname) ? filesize($this->file_src_pathname) : 0);
                    }

                    $this->file_src_error = 0;
                } else {

                    // this is a local filename, i.e.not uploaded

                    $this->log .= '<b>source is a local file ' . $file . '</b><br />';

                    $this->no_upload_check = TRUE;



                    if ($this->uploaded && !file_exists($file)) {

                        $this->uploaded = false;

                        $this->error = $this->translate('local_file_missing');
                    }



                    if ($this->uploaded && !is_readable($file)) {

                        $this->uploaded = false;

                        $this->error = $this->translate('local_file_not_readable');
                    }



                    if ($this->uploaded) {

                        $this->file_src_pathname = $file;

                        $this->file_src_name = basename($file);

                        $this->log .= '- local file OK<br />';

                        preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

                        if (is_array($extension) && sizeof($extension) > 0) {

                            $this->file_src_name_ext = strtolower($extension[1]);

                            $this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext))) - 1);
                        } else {

                            $this->file_src_name_ext = '';

                            $this->file_src_name_body = $this->file_src_name;
                        }

                        $this->file_src_size = (file_exists($this->file_src_pathname) ? filesize($this->file_src_pathname) : 0);
                    }

                    $this->file_src_error = 0;
                }
            }
        } else {

            // this is an element from $_FILE, i.e. an uploaded file

            $this->log .= '<b>source is an uploaded file</b><br />';

            if ($this->uploaded) {

                $this->file_src_error = trim($file['error']);

                switch ($this->file_src_error) {

                    case UPLOAD_ERR_OK:

                        // all is OK

                        $this->log .= '- upload OK<br />';

                        break;

                    case UPLOAD_ERR_INI_SIZE:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_too_big_ini');

                        break;

                    case UPLOAD_ERR_FORM_SIZE:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_too_big_html');

                        break;

                    case UPLOAD_ERR_PARTIAL:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_partial');

                        break;

                    case UPLOAD_ERR_NO_FILE:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_missing');

                        break;

                    case @UPLOAD_ERR_NO_TMP_DIR:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_no_tmp_dir');

                        break;

                    case @UPLOAD_ERR_CANT_WRITE:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_cant_write');

                        break;

                    case @UPLOAD_ERR_EXTENSION:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_err_extension');

                        break;

                    default:

                        $this->uploaded = false;

                        $this->error = $this->translate('uploaded_unknown') . ' (' . $this->file_src_error . ')';
                }
            }



            if ($this->uploaded) {

                $this->file_src_pathname = $file['tmp_name'];

                $this->file_src_name = $file['name'];

                if ($this->file_src_name == '') {

                    $this->uploaded = false;

                    $this->error = $this->translate('try_again');
                }
            }



            if ($this->uploaded) {

                $this->log .= '- file name OK<br />';

                preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

                if (is_array($extension) && sizeof($extension) > 0) {

                    $this->file_src_name_ext = strtolower($extension[1]);

                    $this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext))) - 1);
                } else {

                    $this->file_src_name_ext = '';

                    $this->file_src_name_body = $this->file_src_name;
                }

                $this->file_src_size = $file['size'];

                $mime_from_browser = $file['type'];
            }
        }



        if ($this->uploaded) {

            $this->log .= '<b>determining MIME type</b><br />';

            $this->file_src_mime = null;



            // checks MIME type with Fileinfo PECL extension

            if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) {

                if ($this->mime_fileinfo) {

                    $this->log .= '- Checking MIME type with Fileinfo PECL extension<br />';

                    if ($this->function_enabled('finfo_open')) {

                        $path = null;

                        if ($this->mime_fileinfo !== '') {

                            if ($this->mime_fileinfo === true) {

                                if (getenv('MAGIC') === FALSE) {

                                    if (substr(PHP_OS, 0, 3) == 'WIN') {

                                        $path = realpath(ini_get('extension_dir') . '/../') . '/extras/magic';

                                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MAGIC path defaults to ' . $path . '<br />';
                                    }
                                } else {

                                    $path = getenv('MAGIC');

                                    $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MAGIC path is set to ' . $path . ' from MAGIC variable<br />';
                                }
                            } else {

                                $path = $this->mime_fileinfo;

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MAGIC path is set to ' . $path . '<br />';
                            }
                        }

                        if ($path) {

                            $f = @finfo_open(FILEINFO_MIME, $path);
                        } else {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MAGIC path will not be used<br />';

                            $f = @finfo_open(FILEINFO_MIME);
                        }

                        if (is_resource($f)) {

                            $mime = finfo_file($f, realpath($this->file_src_pathname));

                            finfo_close($f);

                            $this->file_src_mime = $mime;

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension<br />';

                            if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {

                                $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);

                                $this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
                            } else {

                                $this->file_src_mime = null;
                            }
                        } else {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;Fileinfo PECL extension failed (finfo_open)<br />';
                        }
                    } elseif (@class_exists('finfo')) {

                        $f = new finfo(FILEINFO_MIME);

                        if ($f) {

                            $this->file_src_mime = $f->file(realpath($this->file_src_pathname));

                            $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension<br />';

                            if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {

                                $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);

                                $this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
                            } else {

                                $this->file_src_mime = null;
                            }
                        } else {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;Fileinfo PECL extension failed (finfo)<br />';
                        }
                    } else {

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;Fileinfo PECL extension not available<br />';
                    }
                } else {

                    $this->log .= '- Fileinfo PECL extension deactivated<br />';
                }
            }



            // checks MIME type with shell if unix access is authorized

            if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) {

                if ($this->mime_file) {

                    $this->log .= '- Checking MIME type with UNIX file() command<br />';

                    if (substr(PHP_OS, 0, 3) != 'WIN') {

                        if ($this->function_enabled('exec') && $this->function_enabled('escapeshellarg')) {

                            if (strlen($mime = @exec("file -bi " . escapeshellarg($this->file_src_pathname))) != 0) {

                                $this->file_src_mime = trim($mime);

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by UNIX file() command<br />';

                                if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {

                                    $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);

                                    $this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
                                } else {

                                    $this->file_src_mime = null;
                                }
                            } else {

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;UNIX file() command failed<br />';
                            }
                        } else {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;PHP exec() function is disabled<br />';
                        }
                    } else {

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;UNIX file() command not availabled<br />';
                    }
                } else {

                    $this->log .= '- UNIX file() command is deactivated<br />';
                }
            }



            // checks MIME type with mime_magic

            if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) {

                if ($this->mime_magic) {

                    $this->log .= '- Checking MIME type with mime.magic file (mime_content_type())<br />';

                    if ($this->function_enabled('mime_content_type')) {

                        $this->file_src_mime = mime_content_type($this->file_src_pathname);

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by mime_content_type()<br />';

                        if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {

                            $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);

                            $this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
                        } else {

                            $this->file_src_mime = null;
                        }
                    } else {

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;mime_content_type() is not available<br />';
                    }
                } else {

                    $this->log .= '- mime.magic file (mime_content_type()) is deactivated<br />';
                }
            }



            // checks MIME type with getimagesize()

            if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) {

                if ($this->mime_getimagesize) {

                    $this->log .= '- Checking MIME type with getimagesize()<br />';

                    $info = getimagesize($this->file_src_pathname);

                    if (is_array($info) && array_key_exists('mime', $info)) {

                        $this->file_src_mime = trim($info['mime']);

                        if (empty($this->file_src_mime)) {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME empty, guessing from type<br />';

                            $mime = (is_array($info) && array_key_exists(2, $info) ? $info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG

                            $this->file_src_mime = ($mime == IMAGETYPE_GIF ? 'image/gif' : ($mime == IMAGETYPE_JPEG ? 'image/jpeg' : ($mime == IMAGETYPE_PNG ? 'image/png' : ($mime == IMAGETYPE_BMP ? 'image/bmp' : null))));
                        }

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;MIME type detected as ' . $this->file_src_mime . ' by PHP getimagesize() function<br />';

                        if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {

                            $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);

                            $this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
                        } else {

                            $this->file_src_mime = null;
                        }
                    } else {

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;getimagesize() failed<br />';
                    }
                } else {

                    $this->log .= '- getimagesize() is deactivated<br />';
                }
            }



            // default to MIME from browser (or Flash)

            if (!empty($mime_from_browser) && !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime)) {

                $this->file_src_mime = $mime_from_browser;

                $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by browser<br />';

                if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) {

                    $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime);

                    $this->log .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
                } else {

                    $this->file_src_mime = null;
                }
            }



            // we need to work some magic if we upload via Flash

            if ($this->file_src_mime == 'application/octet-stream' || !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) {

                if ($this->file_src_mime == 'application/octet-stream')
                    $this->log .= '- Flash may be rewriting MIME as application/octet-stream<br />';

                $this->log .= '- Try to guess MIME type from file extension (' . $this->file_src_name_ext . '): ';

                if (array_key_exists($this->file_src_name_ext, $this->mime_types))
                    $this->file_src_mime = $this->mime_types[$this->file_src_name_ext];

                if ($this->file_src_mime == 'application/octet-stream') {

                    $this->log .= 'doesn\'t look like anything known<br />';
                } else {

                    $this->log .= 'MIME type set to ' . $this->file_src_mime . '<br />';
                }
            }



            if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) {

                $this->log .= '- MIME type couldn\'t be detected! (' . (string) $this->file_src_mime . ')<br />';
            }



            // determine whether the file is an image

            if ($this->file_src_mime && is_string($this->file_src_mime) && !empty($this->file_src_mime) && array_key_exists($this->file_src_mime, $this->image_supported)) {

                $this->file_is_image = true;

                $this->image_src_type = $this->image_supported[$this->file_src_mime];
            }



            // if the file is an image, we gather some useful data

            if ($this->file_is_image) {

                if ($h = fopen($this->file_src_pathname, 'r')) {

                    fclose($h);

                    $info = getimagesize($this->file_src_pathname);

                    if (is_array($info)) {

                        $this->image_src_x = $info[0];

                        $this->image_src_y = $info[1];

                        $this->image_dst_x = $this->image_src_x;

                        $this->image_dst_y = $this->image_src_y;

                        $this->image_src_pixels = $this->image_src_x * $this->image_src_y;

                        $this->image_src_bits = array_key_exists('bits', $info) ? $info['bits'] : null;
                    } else {

                        $this->file_is_image = false;

                        $this->uploaded = false;

                        $this->log .= '- can\'t retrieve image information, image may have been tampered with<br />';

                        $this->error = $this->translate('source_invalid');
                    }
                } else {

                    $this->log .= '- can\'t read source file directly. open_basedir restriction in place?<br />';
                }
            }



            $this->log .= '<b>source variables</b><br />';

            $this->log .= '- You can use all these before calling process()<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_name         : ' . $this->file_src_name . '<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_name_body    : ' . $this->file_src_name_body . '<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_name_ext     : ' . $this->file_src_name_ext . '<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_pathname     : ' . $this->file_src_pathname . '<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_mime         : ' . $this->file_src_mime . '<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_size         : ' . $this->file_src_size . ' (max= ' . $this->file_max_size . ')<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_src_error        : ' . $this->file_src_error . '<br />';



            if ($this->file_is_image) {

                $this->log .= '- source file is an image<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_src_x           : ' . $this->image_src_x . '<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_src_y           : ' . $this->image_src_y . '<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_src_pixels      : ' . $this->image_src_pixels . '<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_src_type        : ' . $this->image_src_type . '<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_src_bits        : ' . $this->image_src_bits . '<br />';
            }
        }
    }

    /**

     * Returns the version of GD

     *

     * @access public

     * @param  boolean  $full Optional flag to get precise version

     * @return float GD version

     */
    function gdversion($full = false) {

        static $gd_version = null;

        static $gd_full_version = null;

        if ($gd_version === null) {

            if ($this->function_enabled('gd_info')) {

                $gd = gd_info();

                $gd = $gd["GD Version"];

                $regex = "/([\d\.]+)/i";
            } else {

                ob_start();

                phpinfo(8);

                $gd = ob_get_contents();

                ob_end_clean();

                $regex = "/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i";
            }

            if (preg_match($regex, $gd, $m)) {

                $gd_full_version = (string) $m[1];

                $gd_version = (float) $m[1];
            } else {

                $gd_full_version = 'none';

                $gd_version = 0;
            }
        }

        if ($full) {

            return $gd_full_version;
        } else {

            return $gd_version;
        }
    }

    /**

     * Checks if a function is available

     *

     * @access private

     * @param  string  $func Function name

     * @return boolean Success

     */
    function function_enabled($func) {

        // cache the list of disabled functions

        static $disabled = null;

        if ($disabled === null)
            $disabled = array_map('trim', array_map('strtolower', explode(',', ini_get('disable_functions'))));

        // cache the list of functions blacklisted by suhosin

        static $blacklist = null;

        if ($blacklist === null)
            $blacklist = extension_loaded('suhosin') ? array_map('trim', array_map('strtolower', explode(',', ini_get('  suhosin.executor.func.blacklist')))) : array();

        // checks if the function is really enabled

        return (function_exists($func) && !in_array($func, $disabled) && !in_array($func, $blacklist));
    }

    /**

     * Creates directories recursively

     *

     * @access private

     * @param  string  $path Path to create

     * @param  integer $mode Optional permissions

     * @return boolean Success

     */
    function rmkdir($path, $mode = 0777) {

        return is_dir($path) || ( $this->rmkdir(dirname($path), $mode) && $this->_mkdir($path, $mode) );
    }

    /**

     * Creates directory

     *

     * @access private

     * @param  string  $path Path to create

     * @param  integer $mode Optional permissions

     * @return boolean Success

     */
    function _mkdir($path, $mode = 0777) {

        $old = umask(0);

        $res = @mkdir($path, $mode);

        umask($old);

        return $res;
    }

    /**

     * Translate error messages

     *

     * @access private

     * @param  string  $str    Message to translate

     * @param  array   $tokens Optional token values

     * @return string Translated string

     */
    function translate($str, $tokens = array()) {

        if (array_key_exists($str, $this->translation))
            $str = $this->translation[$str];

        if (is_array($tokens) && sizeof($tokens) > 0)
            $str = vsprintf($str, $tokens);

        return $str;
    }

    /**

     * Returns the temp directory

     *

     * @access private

     * @return string Temp directory string

     */
    function temp_dir() {

        $dir = '';

        if ($this->function_enabled('sys_get_temp_dir'))
            $dir = sys_get_temp_dir();

        if (!$dir && $tmp = getenv('TMP'))
            $dir = $tmp;

        if (!$dir && $tmp = getenv('TEMP'))
            $dir = $tmp;

        if (!$dir && $tmp = getenv('TMPDIR'))
            $dir = $tmp;

        if (!$dir) {

            $tmp = tempnam(__FILE__, '');

            if (file_exists($tmp)) {

                unlink($tmp);

                $dir = dirname($tmp);
            }
        }

        if (!$dir)
            return '';

        $slash = (strtolower(substr(PHP_OS, 0, 3)) === 'win' ? '\\' : '/');

        if (substr($dir, -1) != $slash)
            $dir = $dir . $slash;

        return $dir;
    }

    /**

     * Decodes colors

     *

     * @access private

     * @param  string  $color  Color string

     * @return array RGB colors

     */
    function getcolors($color) {

        $color = str_replace('#', '', $color);

        if (strlen($color) == 3)
            $color = str_repeat(substr($color, 0, 1), 2) . str_repeat(substr($color, 1, 1), 2) . str_repeat(substr($color, 2, 1), 2);

        $r = sscanf($color, "%2x%2x%2x");

        $red = (is_array($r) && array_key_exists(0, $r) && is_numeric($r[0]) ? $r[0] : 0);

        $green = (is_array($r) && array_key_exists(1, $r) && is_numeric($r[1]) ? $r[1] : 0);

        $blue = (is_array($r) && array_key_exists(2, $r) && is_numeric($r[2]) ? $r[2] : 0);

        return array($red, $green, $blue);
    }

    /**

     * Decodes sizes

     *

     * @access private

     * @param  string  $size  Size in bytes, or shorthand byte options

     * @return integer Size in bytes

     */
    function getsize($size) {

        if ($size === null)
            return null;

        $last = strtolower($size{strlen($size) - 1});

        $size = (int) $size;

        switch ($last) {

            case 'g':

                $size *= 1024;

            case 'm':

                $size *= 1024;

            case 'k':

                $size *= 1024;
        }

        return $size;
    }

    /**

     * Decodes offsets

     *

     * @access private

     * @param  misc    $offsets  Offsets, as an integer, a string or an array

     * @param  integer $x        Reference picture width

     * @param  integer $y        Reference picture height

     * @param  boolean $round    Round offsets before returning them

     * @param  boolean $negative Allow negative offsets to be returned

     * @return array Array of four offsets (TRBL)

     */
    function getoffsets($offsets, $x, $y, $round = true, $negative = true) {

        if (!is_array($offsets))
            $offsets = explode(' ', $offsets);

        if (sizeof($offsets) == 4) {

            $ct = $offsets[0];

            $cr = $offsets[1];

            $cb = $offsets[2];

            $cl = $offsets[3];
        } else if (sizeof($offsets) == 2) {

            $ct = $offsets[0];

            $cr = $offsets[1];

            $cb = $offsets[0];

            $cl = $offsets[1];
        } else {

            $ct = $offsets[0];

            $cr = $offsets[0];

            $cb = $offsets[0];

            $cl = $offsets[0];
        }

        if (strpos($ct, '%') > 0)
            $ct = $y * (str_replace('%', '', $ct) / 100);

        if (strpos($cr, '%') > 0)
            $cr = $x * (str_replace('%', '', $cr) / 100);

        if (strpos($cb, '%') > 0)
            $cb = $y * (str_replace('%', '', $cb) / 100);

        if (strpos($cl, '%') > 0)
            $cl = $x * (str_replace('%', '', $cl) / 100);

        if (strpos($ct, 'px') > 0)
            $ct = str_replace('px', '', $ct);

        if (strpos($cr, 'px') > 0)
            $cr = str_replace('px', '', $cr);

        if (strpos($cb, 'px') > 0)
            $cb = str_replace('px', '', $cb);

        if (strpos($cl, 'px') > 0)
            $cl = str_replace('px', '', $cl);

        $ct = (int) $ct;

        $cr = (int) $cr;

        $cb = (int) $cb;

        $cl = (int) $cl;

        if ($round) {

            $ct = round($ct);

            $cr = round($cr);

            $cb = round($cb);

            $cl = round($cl);
        }

        if (!$negative) {

            if ($ct < 0)
                $ct = 0;

            if ($cr < 0)
                $cr = 0;

            if ($cb < 0)
                $cb = 0;

            if ($cl < 0)
                $cl = 0;
        }

        return array($ct, $cr, $cb, $cl);
    }

    /**

     * Creates a container image

     *

     * @access private

     * @param  integer  $x    Width

     * @param  integer  $y    Height

     * @param  boolean  $fill Optional flag to draw the background color or not

     * @param  boolean  $trsp Optional flag to set the background to be transparent

     * @return resource Container image

     */
    function imagecreatenew($x, $y, $fill = true, $trsp = false) {

        if ($x < 1)
            $x = 1;

        if ($y < 1)
            $y = 1;

        if ($this->gdversion() >= 2 && !$this->image_is_palette) {

            // create a true color image

            $dst_im = imagecreatetruecolor($x, $y);

            // this preserves transparency in PNGs, in true color

            if (empty($this->image_background_color) || $trsp) {

                imagealphablending($dst_im, false);

                imagefilledrectangle($dst_im, 0, 0, $x, $y, imagecolorallocatealpha($dst_im, 0, 0, 0, 127));
            }
        } else {

            // creates a palette image

            $dst_im = imagecreate($x, $y);

            // preserves transparency for palette images, if the original image has transparency

            if (($fill && $this->image_is_transparent && empty($this->image_background_color)) || $trsp) {

                imagefilledrectangle($dst_im, 0, 0, $x, $y, $this->image_transparent_color);

                imagecolortransparent($dst_im, $this->image_transparent_color);
            }
        }

        // fills with background color if any is set

        if ($fill && !empty($this->image_background_color) && !$trsp) {

            list($red, $green, $blue) = $this->getcolors($this->image_background_color);

            $background_color = imagecolorallocate($dst_im, $red, $green, $blue);

            imagefilledrectangle($dst_im, 0, 0, $x, $y, $background_color);
        }

        return $dst_im;
    }

    /**

     * Transfers an image from the container to the destination image

     *

     * @access private

     * @param  resource $src_im Container image

     * @param  resource $dst_im Destination image

     * @return resource Destination image

     */
    function imagetransfer($src_im, $dst_im) {

        if (is_resource($dst_im))
            imagedestroy($dst_im);

        $dst_im = & $src_im;

        return $dst_im;
    }

    /**

     * Merges two images

     *

     * If the output format is PNG, then we do it pixel per pixel to retain the alpha channel

     *

     * @access private

     * @param  resource $dst_img Destination image

     * @param  resource $src_img Overlay image

     * @param  int      $dst_x   x-coordinate of destination point

     * @param  int      $dst_y   y-coordinate of destination point

     * @param  int      $src_x   x-coordinate of source point

     * @param  int      $src_y   y-coordinate of source point

     * @param  int      $src_w   Source width

     * @param  int      $src_h   Source height

     * @param  int      $pct     Optional percentage of the overlay, between 0 and 100 (default: 100)

     * @return resource Destination image

     */
    function imagecopymergealpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct = 0) {

        $dst_x = (int) $dst_x;

        $dst_y = (int) $dst_y;

        $src_x = (int) $src_x;

        $src_y = (int) $src_y;

        $src_w = (int) $src_w;

        $src_h = (int) $src_h;

        $pct = (int) $pct;

        $dst_w = imagesx($dst_im);

        $dst_h = imagesy($dst_im);



        for ($y = $src_y; $y < $src_h; $y++) {

            for ($x = $src_x; $x < $src_w; $x++) {



                if ($x + $dst_x >= 0 && $x + $dst_x < $dst_w && $x + $src_x >= 0 && $x + $src_x < $src_w && $y + $dst_y >= 0 && $y + $dst_y < $dst_h && $y + $src_y >= 0 && $y + $src_y < $src_h) {



                    $dst_pixel = imagecolorsforindex($dst_im, imagecolorat($dst_im, $x + $dst_x, $y + $dst_y));

                    $src_pixel = imagecolorsforindex($src_im, imagecolorat($src_im, $x + $src_x, $y + $src_y));



                    $src_alpha = 1 - ($src_pixel['alpha'] / 127);

                    $dst_alpha = 1 - ($dst_pixel['alpha'] / 127);

                    $opacity = $src_alpha * $pct / 100;

                    if ($dst_alpha >= $opacity)
                        $alpha = $dst_alpha;

                    if ($dst_alpha < $opacity)
                        $alpha = $opacity;

                    if ($alpha > 1)
                        $alpha = 1;



                    if ($opacity > 0) {

                        $dst_red = round(( ($dst_pixel['red'] * $dst_alpha * (1 - $opacity))));

                        $dst_green = round(( ($dst_pixel['green'] * $dst_alpha * (1 - $opacity))));

                        $dst_blue = round(( ($dst_pixel['blue'] * $dst_alpha * (1 - $opacity))));

                        $src_red = round((($src_pixel['red'] * $opacity)));

                        $src_green = round((($src_pixel['green'] * $opacity)));

                        $src_blue = round((($src_pixel['blue'] * $opacity)));

                        $red = round(($dst_red + $src_red ) / ($dst_alpha * (1 - $opacity) + $opacity));

                        $green = round(($dst_green + $src_green) / ($dst_alpha * (1 - $opacity) + $opacity));

                        $blue = round(($dst_blue + $src_blue ) / ($dst_alpha * (1 - $opacity) + $opacity));

                        if ($red > 255)
                            $red = 255;

                        if ($green > 255)
                            $green = 255;

                        if ($blue > 255)
                            $blue = 255;

                        $alpha = round((1 - $alpha) * 127);

                        $color = imagecolorallocatealpha($dst_im, $red, $green, $blue, $alpha);

                        imagesetpixel($dst_im, $x + $dst_x, $y + $dst_y, $color);
                    }
                }
            }
        }

        return true;
    }

    /**

     * Actually uploads the file, and act on it according to the set processing class variables

     *

     * This function copies the uploaded file to the given location, eventually performing actions on it.

     * Typically, you can call {@link process} several times for the same file,

     * for instance to create a resized image and a thumbnail of the same file.

     * The original uploaded file remains intact in its temporary location, so you can use {@link process} several times.

     * You will be able to delete the uploaded file with {@link clean} when you have finished all your {@link process} calls.

     *

     * According to the processing class variables set in the calling file, the file can be renamed,

     * and if it is an image, can be resized or converted.

     *

     * When the processing is completed, and the file copied to its new location, the

     * processing class variables will be reset to their default value.

     * This allows you to set new properties, and perform another {@link process} on the same uploaded file

     *

     * If the function is called with a null or empty argument, then it will return the content of the picture

     *

     * It will set {@link processed} (and {@link error} is an error occurred)

     *

     * @access public

     * @param  string $server_path Optional path location of the uploaded file, with an ending slash

     * @return string Optional content of the image

     */
    function process($server_path = null) {

        $this->error = '';

        $this->processed = true;

        $return_mode = false;

        $return_content = null;



        // clean up dst variables

        $this->file_dst_path = '';

        $this->file_dst_pathname = '';

        $this->file_dst_name = '';

        $this->file_dst_name_body = '';

        $this->file_dst_name_ext = '';



        // clean up some parameters

        $this->file_max_size = $this->getsize($this->file_max_size);

        $this->jpeg_size = $this->getsize($this->jpeg_size);



        // copy some variables as we need to keep them clean

        $file_src_name = $this->file_src_name;

        $file_src_name_body = $this->file_src_name_body;

        $file_src_name_ext = $this->file_src_name_ext;



        if (!$this->uploaded) {

            $this->error = $this->translate('file_not_uploaded');

            $this->processed = false;
        }



        if ($this->processed) {

            if (empty($server_path) || is_null($server_path)) {

                $this->log .= '<b>process file and return the content</b><br />';

                $return_mode = true;
            } else {

                if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {

                    if (substr($server_path, -1, 1) != '\\')
                        $server_path = $server_path . '\\';
                } else {

                    if (substr($server_path, -1, 1) != '/')
                        $server_path = $server_path . '/';
                }

                $this->log .= '<b>process file to ' . $server_path . '</b><br />';
            }
        }



        if ($this->processed) {

            // checks file max size

            if ($this->file_src_size > $this->file_max_size) {

                $this->processed = false;

                $this->error = $this->translate('file_too_big') . ' : ' . $this->file_src_size . ' > ' . $this->file_max_size;
            } else {

                $this->log .= '- file size OK<br />';
            }
        }



        if ($this->processed) {

            // if we have an image without extension, set it

            if ($this->file_force_extension && $this->file_is_image && !$this->file_src_name_ext)
                $file_src_name_ext = $this->image_src_type;

            // turn dangerous scripts into text files

            if ($this->no_script) {

                // if the file has no extension, we try to guess it from the MIME type

                if ($this->file_force_extension && empty($file_src_name_ext)) {

                    if ($key = array_search($this->file_src_mime, $this->mime_types)) {

                        $file_src_name_ext = $key;

                        $file_src_name = $file_src_name_body . '.' . $file_src_name_ext;

                        $this->log .= '- file renamed as ' . $file_src_name_body . '.' . $file_src_name_ext . '!<br />';
                    }
                }

                // if the file is text based, or has a dangerous extension, we rename it as .txt

                if ((((substr($this->file_src_mime, 0, 5) == 'text/' && $this->file_src_mime != 'text/rtf') || strpos($this->file_src_mime, 'javascript') !== false) && (substr($file_src_name, -4) != '.txt')) || preg_match('/\.(php|php5|php4|php3|phtml|pl|py|cgi|asp|js)$/i', $this->file_src_name) || $this->file_force_extension && empty($file_src_name_ext)) {

                    $this->file_src_mime = 'text/plain';

                    if ($this->file_src_name_ext)
                        $file_src_name_body = $file_src_name_body . '.' . $this->file_src_name_ext;

                    $file_src_name_ext = 'txt';

                    $file_src_name = $file_src_name_body . '.' . $file_src_name_ext;

                    $this->log .= '- script renamed as ' . $file_src_name_body . '.' . $file_src_name_ext . '!<br />';
                }
            }



            if ($this->mime_check && empty($this->file_src_mime)) {

                $this->processed = false;

                $this->error = $this->translate('no_mime');
            } else if ($this->mime_check && !empty($this->file_src_mime) && strpos($this->file_src_mime, '/') !== false) {

                list($m1, $m2) = explode('/', $this->file_src_mime);

                $allowed = false;

                // check wether the mime type is allowed

                if (!is_array($this->allowed))
                    $this->allowed = array($this->allowed);

                foreach ($this->allowed as $k => $v) {

                    list($v1, $v2) = explode('/', $v);

                    if (($v1 == '*' && $v2 == '*') || ($v1 == $m1 && ($v2 == $m2 || $v2 == '*'))) {

                        $allowed = true;

                        break;
                    }
                }

                // check wether the mime type is forbidden

                if (!is_array($this->forbidden))
                    $this->forbidden = array($this->forbidden);

                foreach ($this->forbidden as $k => $v) {

                    list($v1, $v2) = explode('/', $v);

                    if (($v1 == '*' && $v2 == '*') || ($v1 == $m1 && ($v2 == $m2 || $v2 == '*'))) {

                        $allowed = false;

                        break;
                    }
                }

                if (!$allowed) {

                    $this->processed = false;

                    $this->error = $this->translate('incorrect_file');
                } else {

                    $this->log .= '- file mime OK : ' . $this->file_src_mime . '<br />';
                }
            } else {

                $this->log .= '- file mime (not checked) : ' . $this->file_src_mime . '<br />';
            }



            // if the file is an image, we can check on its dimensions
            // these checks are not available if open_basedir restrictions are in place

            if ($this->file_is_image) {

                if (is_numeric($this->image_src_x) && is_numeric($this->image_src_y)) {

                    $ratio = $this->image_src_x / $this->image_src_y;

                    if (!is_null($this->image_max_width) && $this->image_src_x > $this->image_max_width) {

                        $this->processed = false;

                        $this->error = $this->translate('image_too_wide');
                    }

                    if (!is_null($this->image_min_width) && $this->image_src_x < $this->image_min_width) {

                        $this->processed = false;

                        $this->error = $this->translate('image_too_narrow');
                    }

                    if (!is_null($this->image_max_height) && $this->image_src_y > $this->image_max_height) {

                        $this->processed = false;

                        $this->error = $this->translate('image_too_high');
                    }

                    if (!is_null($this->image_min_height) && $this->image_src_y < $this->image_min_height) {

                        $this->processed = false;

                        $this->error = $this->translate('image_too_short');
                    }

                    if (!is_null($this->image_max_ratio) && $ratio > $this->image_max_ratio) {

                        $this->processed = false;

                        $this->error = $this->translate('ratio_too_high');
                    }

                    if (!is_null($this->image_min_ratio) && $ratio < $this->image_min_ratio) {

                        $this->processed = false;

                        $this->error = $this->translate('ratio_too_low');
                    }

                    if (!is_null($this->image_max_pixels) && $this->image_src_pixels > $this->image_max_pixels) {

                        $this->processed = false;

                        $this->error = $this->translate('too_many_pixels');
                    }

                    if (!is_null($this->image_min_pixels) && $this->image_src_pixels < $this->image_min_pixels) {

                        $this->processed = false;

                        $this->error = $this->translate('not_enough_pixels');
                    }
                } else {

                    $this->log .= '- no image properties available, can\'t enforce dimension checks : ' . $this->file_src_mime . '<br />';
                }
            }
        }



        if ($this->processed) {

            $this->file_dst_path = $server_path;



            // repopulate dst variables from src

            $this->file_dst_name = $file_src_name;

            $this->file_dst_name_body = $file_src_name_body;

            $this->file_dst_name_ext = $file_src_name_ext;

            if ($this->file_overwrite)
                $this->file_auto_rename = false;



            if ($this->image_convert && $this->file_is_image) { // if we convert as an image
                if ($this->file_src_name_ext)
                    $this->file_dst_name_ext = $this->image_convert;

                $this->log .= '- new file name ext : ' . $this->image_convert . '<br />';
            }

            if (!is_null($this->file_new_name_body)) { // rename file body
                $this->file_dst_name_body = $this->file_new_name_body;

                $this->log .= '- new file name body : ' . $this->file_new_name_body . '<br />';
            }

            if (!is_null($this->file_new_name_ext)) { // rename file ext
                $this->file_dst_name_ext = $this->file_new_name_ext;

                $this->log .= '- new file name ext : ' . $this->file_new_name_ext . '<br />';
            }

            if (!is_null($this->file_name_body_add)) { // append a string to the name
                $this->file_dst_name_body = $this->file_dst_name_body . $this->file_name_body_add;

                $this->log .= '- file name body append : ' . $this->file_name_body_add . '<br />';
            }

            if (!is_null($this->file_name_body_pre)) { // prepend a string to the name
                $this->file_dst_name_body = $this->file_name_body_pre . $this->file_dst_name_body;

                $this->log .= '- file name body prepend : ' . $this->file_name_body_pre . '<br />';
            }

            if ($this->file_safe_name) { // formats the name
                $this->file_dst_name_body = utf8_encode(strtr(utf8_decode($this->file_dst_name_body), utf8_decode('ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ'), 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'));

                $this->file_dst_name_body = strtr($this->file_dst_name_body, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u'));

                $this->file_dst_name_body = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $this->file_dst_name_body);

                $this->log .= '- file name safe format<br />';
            }



            $this->log .= '- destination variables<br />';

            if (empty($this->file_dst_path) || is_null($this->file_dst_path)) {

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_dst_path         : n/a<br />';
            } else {

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_dst_path         : ' . $this->file_dst_path . '<br />';
            }

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_dst_name_body    : ' . $this->file_dst_name_body . '<br />';

            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_dst_name_ext     : ' . $this->file_dst_name_ext . '<br />';



            // set the destination file name

            $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : '');



            if (!$return_mode) {

                if (!$this->file_auto_rename) {

                    $this->log .= '- no auto_rename if same filename exists<br />';

                    $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name;
                } else {

                    $this->log .= '- checking for auto_rename<br />';

                    $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name;

                    $body = $this->file_dst_name_body;

                    $ext = '';

                    // if we have changed the extension, then we add our increment before

                    if ($file_src_name_ext != $this->file_src_name_ext) {

                        if (substr($this->file_dst_name_body, -1 - strlen($this->file_src_name_ext)) == '.' . $this->file_src_name_ext) {

                            $body = substr($this->file_dst_name_body, 0, strlen($this->file_dst_name_body) - 1 - strlen($this->file_src_name_ext));

                            $ext = '.' . $this->file_src_name_ext;
                        }
                    }

                    $cpt = 1;

                    while (@file_exists($this->file_dst_pathname)) {

                        $this->file_dst_name_body = $body . '_' . $cpt . $ext;

                        $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : '');

                        $cpt++;

                        $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name;
                    }

                    if ($cpt > 1)
                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;auto_rename to ' . $this->file_dst_name . '<br />';
                }



                $this->log .= '- destination file details<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_dst_name         : ' . $this->file_dst_name . '<br />';

                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;file_dst_pathname     : ' . $this->file_dst_pathname . '<br />';



                if ($this->file_overwrite) {

                    $this->log .= '- no overwrite checking<br />';
                } else {

                    if (@file_exists($this->file_dst_pathname)) {

                        $this->processed = false;

                        $this->error = $this->translate('already_exists', array($this->file_dst_name));
                    } else {

                        $this->log .= '- ' . $this->file_dst_name . ' doesn\'t exist already<br />';
                    }
                }
            }
        }



        if ($this->processed) {

            // if we have already moved the uploaded file, we use the temporary copy as source file, and check if it exists

            if (!empty($this->file_src_temp)) {

                $this->log .= '- use the temp file instead of the original file since it is a second process<br />';

                $this->file_src_pathname = $this->file_src_temp;

                if (!file_exists($this->file_src_pathname)) {

                    $this->processed = false;

                    $this->error = $this->translate('temp_file_missing');
                }

                // if we haven't a temp file, and that we do check on uploads, we use is_uploaded_file()
            } else if (!$this->no_upload_check) {

                if (!is_uploaded_file($this->file_src_pathname)) {

                    $this->processed = false;

                    $this->error = $this->translate('source_missing');
                }

                // otherwise, if we don't check on uploaded files (local file for instance), we use file_exists()
            } else {

                if (!file_exists($this->file_src_pathname)) {

                    $this->processed = false;

                    $this->error = $this->translate('source_missing');
                }
            }



            // checks if the destination directory exists, and attempt to create it

            if (!$return_mode) {

                if ($this->processed && !file_exists($this->file_dst_path)) {

                    if ($this->dir_auto_create) {

                        $this->log .= '- ' . $this->file_dst_path . ' doesn\'t exist. Attempting creation:';

                        if (!$this->rmkdir($this->file_dst_path, $this->dir_chmod)) {

                            $this->log .= ' failed<br />';

                            $this->processed = false;

                            $this->error = $this->translate('destination_dir');
                        } else {

                            $this->log .= ' success<br />';
                        }
                    } else {

                        $this->error = $this->translate('destination_dir_missing');
                    }
                }



                if ($this->processed && !is_dir($this->file_dst_path)) {

                    $this->processed = false;

                    $this->error = $this->translate('destination_path_not_dir');
                }



                // checks if the destination directory is writeable, and attempt to make it writeable

                $hash = md5($this->file_dst_name_body . rand(1, 1000));

                if ($this->processed && !($f = @fopen($this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''), 'a+'))) {

                    if ($this->dir_auto_chmod) {

                        $this->log .= '- ' . $this->file_dst_path . ' is not writeable. Attempting chmod:';

                        if (!@chmod($this->file_dst_path, $this->dir_chmod)) {

                            $this->log .= ' failed<br />';

                            $this->processed = false;

                            $this->error = $this->translate('destination_dir_write');
                        } else {

                            $this->log .= ' success<br />';

                            if (!($f = @fopen($this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''), 'a+'))) { // we re-check
                                $this->processed = false;

                                $this->error = $this->translate('destination_dir_write');
                            } else {

                                @fclose($f);
                            }
                        }
                    } else {

                        $this->processed = false;

                        $this->error = $this->translate('destination_path_write');
                    }
                } else {

                    if ($this->processed)
                        @fclose($f);

                    @unlink($this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''));
                }





                // if we have an uploaded file, and if it is the first process, and if we can't access the file directly (open_basedir restriction)
                // then we create a temp file that will be used as the source file in subsequent processes
                // the third condition is there to check if the file is not accessible *directly* (it already has positively gone through is_uploaded_file(), so it exists)

                if (!$this->no_upload_check && empty($this->file_src_temp) && !@file_exists($this->file_src_pathname)) {

                    $this->log .= '- attempting to use a temp file:';

                    $hash = md5($this->file_dst_name_body . rand(1, 1000));

                    if (move_uploaded_file($this->file_src_pathname, $this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''))) {

                        $this->file_src_pathname = $this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : '');

                        $this->file_src_temp = $this->file_src_pathname;

                        $this->log .= ' file created<br />';

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;temp file is: ' . $this->file_src_temp . '<br />';
                    } else {

                        $this->log .= ' failed<br />';

                        $this->processed = false;

                        $this->error = $this->translate('temp_file');
                    }
                }
            }
        }



        if ($this->processed) {



            // check if we need to autorotate, to automatically pre-rotates the image according to EXIF data (JPEG only)

            $auto_flip = false;

            $auto_rotate = 0;

            if ($this->file_is_image && $this->image_auto_rotate && $this->image_src_type == 'jpg' && $this->function_enabled('exif_read_data')) {

                $exif = @exif_read_data($this->file_src_pathname);

                if (is_array($exif) && isset($exif['Orientation'])) {

                    $orientation = $exif['Orientation'];

                    switch ($orientation) {

                        case 1:

                            $this->log .= '- EXIF orientation = 1 : default<br />';

                            break;

                        case 2:

                            $auto_flip = 'v';

                            $this->log .= '- EXIF orientation = 2 : vertical flip<br />';

                            break;

                        case 3:

                            $auto_rotate = 180;

                            $this->log .= '- EXIF orientation = 3 : 180 rotate left<br />';

                            break;

                        case 4:

                            $auto_flip = 'h';

                            $this->log .= '- EXIF orientation = 4 : horizontal flip<br />';

                            break;

                        case 5:

                            $auto_flip = 'h';

                            $auto_rotate = 90;

                            $this->log .= '- EXIF orientation = 5 : horizontal flip + 90 rotate right<br />';

                            break;

                        case 6:

                            $auto_rotate = 90;

                            $this->log .= '- EXIF orientation = 6 : 90 rotate right<br />';

                            break;

                        case 7:

                            $auto_flip = 'v';

                            $auto_rotate = 90;

                            $this->log .= '- EXIF orientation = 7 : vertical flip + 90 rotate right<br />';

                            break;

                        case 8:

                            $auto_rotate = 270;

                            $this->log .= '- EXIF orientation = 8 : 90 rotate left<br />';

                            break;

                        default:

                            $this->log .= '- EXIF orientation = ' . $orientation . ' : unknown<br />';

                            break;
                    }
                } else {

                    $this->log .= '- EXIF data is invalid or missing<br />';
                }
            } else {

                if (!$this->image_auto_rotate) {

                    $this->log .= '- auto-rotate deactivated<br />';
                } else if (!$this->image_src_type == 'jpg') {

                    $this->log .= '- auto-rotate applies only to JPEG images<br />';
                } else if (!$this->function_enabled('exif_read_data')) {

                    $this->log .= '- auto-rotate requires function exif_read_data to be enabled<br />';
                }
            }



            // do we do some image manipulation?

            $image_manipulation = ($this->file_is_image && (

                    $this->image_resize || $this->image_convert != '' || is_numeric($this->image_brightness) || is_numeric($this->image_contrast) || is_numeric($this->image_opacity) || is_numeric($this->image_threshold) || !empty($this->image_tint_color) || !empty($this->image_overlay_color) || $this->image_pixelate || $this->image_unsharp || !empty($this->image_text) || $this->image_greyscale || $this->image_negative || !empty($this->image_watermark) || $auto_rotate || $auto_flip || is_numeric($this->image_rotate) || is_numeric($this->jpeg_size) || !empty($this->image_flip) || !empty($this->image_crop) || !empty($this->image_precrop) || !empty($this->image_border) || !empty($this->image_border_transparent) || $this->image_frame > 0 || $this->image_bevel > 0 || $this->image_reflection_height));



            // we do a quick check to ensure the file is really an image
            // we can do this only now, as it would have failed before in case of open_basedir

            if ($image_manipulation && !@getimagesize($this->file_src_pathname)) {

                $this->log .= '- the file is not an image!<br />';

                $image_manipulation = false;
            }



            if ($image_manipulation) {



                // make sure GD doesn't complain too much

                @ini_set("gd.jpeg_ignore_warning", 1);



                // checks if the source file is readable

                if ($this->processed && !($f = @fopen($this->file_src_pathname, 'r'))) {

                    $this->processed = false;

                    $this->error = $this->translate('source_not_readable');
                } else {

                    @fclose($f);
                }



                // we now do all the image manipulations

                $this->log .= '- image resizing or conversion wanted<br />';

                if ($this->gdversion()) {

                    switch ($this->image_src_type) {

                        case 'jpg':

                            if (!$this->function_enabled('imagecreatefromjpeg')) {

                                $this->processed = false;

                                $this->error = $this->translate('no_create_support', array('JPEG'));
                            } else {

                                $image_src = @imagecreatefromjpeg($this->file_src_pathname);

                                if (!$image_src) {

                                    $this->processed = false;

                                    $this->error = $this->translate('create_error', array('JPEG'));
                                } else {

                                    $this->log .= '- source image is JPEG<br />';
                                }
                            }

                            break;

                        case 'png':

                            if (!$this->function_enabled('imagecreatefrompng')) {

                                $this->processed = false;

                                $this->error = $this->translate('no_create_support', array('PNG'));
                            } else {

                                $image_src = @imagecreatefrompng($this->file_src_pathname);

                                if (!$image_src) {

                                    $this->processed = false;

                                    $this->error = $this->translate('create_error', array('PNG'));
                                } else {

                                    $this->log .= '- source image is PNG<br />';
                                }
                            }

                            break;

                        case 'gif':

                            if (!$this->function_enabled('imagecreatefromgif')) {

                                $this->processed = false;

                                $this->error = $this->translate('no_create_support', array('GIF'));
                            } else {

                                $image_src = @imagecreatefromgif($this->file_src_pathname);

                                if (!$image_src) {

                                    $this->processed = false;

                                    $this->error = $this->translate('create_error', array('GIF'));
                                } else {

                                    $this->log .= '- source image is GIF<br />';
                                }
                            }

                            break;

                        case 'bmp':

                            if (!method_exists($this, 'imagecreatefrombmp')) {

                                $this->processed = false;

                                $this->error = $this->translate('no_create_support', array('BMP'));
                            } else {

                                $image_src = @$this->imagecreatefrombmp($this->file_src_pathname);

                                if (!$image_src) {

                                    $this->processed = false;

                                    $this->error = $this->translate('create_error', array('BMP'));
                                } else {

                                    $this->log .= '- source image is BMP<br />';
                                }
                            }

                            break;

                        default:

                            $this->processed = false;

                            $this->error = $this->translate('source_invalid');
                    }
                } else {

                    $this->processed = false;

                    $this->error = $this->translate('gd_missing');
                }



                if ($this->processed && $image_src) {



                    // we have to set image_convert if it is not already

                    if (empty($this->image_convert)) {

                        $this->log .= '- setting destination file type to ' . $this->image_src_type . '<br />';

                        $this->image_convert = $this->image_src_type;
                    }



                    if (!in_array($this->image_convert, $this->image_supported)) {

                        $this->image_convert = 'jpg';
                    }



                    // we set the default color to be the background color if we don't output in a transparent format

                    if ($this->image_convert != 'png' && $this->image_convert != 'gif' && !empty($this->image_default_color) && empty($this->image_background_color))
                        $this->image_background_color = $this->image_default_color;

                    if (!empty($this->image_background_color))
                        $this->image_default_color = $this->image_background_color;

                    if (empty($this->image_default_color))
                        $this->image_default_color = '#FFFFFF';



                    $this->image_src_x = imagesx($image_src);

                    $this->image_src_y = imagesy($image_src);

                    $gd_version = $this->gdversion();

                    $ratio_crop = null;



                    if (!imageistruecolor($image_src)) {  // $this->image_src_type == 'gif'
                        $this->log .= '- image is detected as having a palette<br />';

                        $this->image_is_palette = true;

                        $this->image_transparent_color = imagecolortransparent($image_src);

                        if ($this->image_transparent_color >= 0 && imagecolorstotal($image_src) > $this->image_transparent_color) {

                            $this->image_is_transparent = true;

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;palette image is detected as transparent<br />';
                        }

                        // if the image has a palette (GIF), we convert it to true color, preserving transparency

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;convert palette image to true color<br />';

                        $true_color = imagecreatetruecolor($this->image_src_x, $this->image_src_y);

                        imagealphablending($true_color, false);

                        imagesavealpha($true_color, true);

                        for ($x = 0; $x < $this->image_src_x; $x++) {

                            for ($y = 0; $y < $this->image_src_y; $y++) {

                                if ($this->image_transparent_color >= 0 && imagecolorat($image_src, $x, $y) == $this->image_transparent_color) {

                                    imagesetpixel($true_color, $x, $y, 127 << 24);
                                } else {

                                    $rgb = imagecolorsforindex($image_src, imagecolorat($image_src, $x, $y));

                                    imagesetpixel($true_color, $x, $y, ($rgb['alpha'] << 24) | ($rgb['red'] << 16) | ($rgb['green'] << 8) | $rgb['blue']);
                                }
                            }
                        }

                        $image_src = $this->imagetransfer($true_color, $image_src);

                        imagealphablending($image_src, false);

                        imagesavealpha($image_src, true);

                        $this->image_is_palette = false;
                    }



                    $image_dst = & $image_src;



                    // auto-flip image, according to EXIF data (JPEG only)

                    if ($gd_version >= 2 && !empty($auto_flip)) {

                        $this->log .= '- auto-flip image : ' . ($auto_flip == 'v' ? 'vertical' : 'horizontal') . '<br />';

                        $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y);

                        for ($x = 0; $x < $this->image_src_x; $x++) {

                            for ($y = 0; $y < $this->image_src_y; $y++) {

                                if (strpos($auto_flip, 'v') !== false) {

                                    imagecopy($tmp, $image_dst, $this->image_src_x - $x - 1, $y, $x, $y, 1, 1);
                                } else {

                                    imagecopy($tmp, $image_dst, $x, $this->image_src_y - $y - 1, $x, $y, 1, 1);
                                }
                            }
                        }

                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // auto-rotate image, according to EXIF data (JPEG only)

                    if ($gd_version >= 2 && is_numeric($auto_rotate)) {

                        if (!in_array($auto_rotate, array(0, 90, 180, 270)))
                            $auto_rotate = 0;

                        if ($auto_rotate != 0) {

                            if ($auto_rotate == 90 || $auto_rotate == 270) {

                                $tmp = $this->imagecreatenew($this->image_src_y, $this->image_src_x);
                            } else {

                                $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y);
                            }

                            $this->log .= '- auto-rotate image : ' . $auto_rotate . '<br />';

                            for ($x = 0; $x < $this->image_src_x; $x++) {

                                for ($y = 0; $y < $this->image_src_y; $y++) {

                                    if ($auto_rotate == 90) {

                                        imagecopy($tmp, $image_dst, $y, $x, $x, $this->image_src_y - $y - 1, 1, 1);
                                    } else if ($auto_rotate == 180) {

                                        imagecopy($tmp, $image_dst, $x, $y, $this->image_src_x - $x - 1, $this->image_src_y - $y - 1, 1, 1);
                                    } else if ($auto_rotate == 270) {

                                        imagecopy($tmp, $image_dst, $y, $x, $this->image_src_x - $x - 1, $y, 1, 1);
                                    } else {

                                        imagecopy($tmp, $image_dst, $x, $y, $x, $y, 1, 1);
                                    }
                                }
                            }

                            if ($auto_rotate == 90 || $auto_rotate == 270) {

                                $t = $this->image_src_y;

                                $this->image_src_y = $this->image_src_x;

                                $this->image_src_x = $t;
                            }

                            // we transfert tmp into image_dst

                            $image_dst = $this->imagetransfer($tmp, $image_dst);
                        }
                    }



                    // pre-crop image, before resizing

                    if ((!empty($this->image_precrop))) {

                        list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_precrop, $this->image_src_x, $this->image_src_y, true, true);

                        $this->log .= '- pre-crop image : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . ' <br />';

                        $this->image_src_x = $this->image_src_x - $cl - $cr;

                        $this->image_src_y = $this->image_src_y - $ct - $cb;

                        if ($this->image_src_x < 1)
                            $this->image_src_x = 1;

                        if ($this->image_src_y < 1)
                            $this->image_src_y = 1;

                        $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y);



                        // we copy the image into the recieving image

                        imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_src_x, $this->image_src_y);



                        // if we crop with negative margins, we have to make sure the extra bits are the right color, or transparent

                        if ($ct < 0 || $cr < 0 || $cb < 0 || $cl < 0) {

                            // use the background color if present

                            if (!empty($this->image_background_color)) {

                                list($red, $green, $blue) = $this->getcolors($this->image_background_color);

                                $fill = imagecolorallocate($tmp, $red, $green, $blue);
                            } else {

                                $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
                            }

                            // fills eventual negative margins

                            if ($ct < 0)
                                imagefilledrectangle($tmp, 0, 0, $this->image_src_x, -$ct, $fill);

                            if ($cr < 0)
                                imagefilledrectangle($tmp, $this->image_src_x + $cr, 0, $this->image_src_x, $this->image_src_y, $fill);

                            if ($cb < 0)
                                imagefilledrectangle($tmp, 0, $this->image_src_y + $cb, $this->image_src_x, $this->image_src_y, $fill);

                            if ($cl < 0)
                                imagefilledrectangle($tmp, 0, 0, -$cl, $this->image_src_y, $fill);
                        }



                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // resize image (and move image_src_x, image_src_y dimensions into image_dst_x, image_dst_y)

                    if ($this->image_resize) {

                        $this->log .= '- resizing...<br />';

                        $this->image_dst_x = $this->image_x;

                        $this->image_dst_y = $this->image_y;



                        // backward compatibility for soon to be deprecated settings

                        if ($this->image_ratio_no_zoom_in) {

                            $this->image_ratio = true;

                            $this->image_no_enlarging = true;
                        } else if ($this->image_ratio_no_zoom_out) {

                            $this->image_ratio = true;

                            $this->image_no_shrinking = true;
                        }



                        // keeps aspect ratio with x calculated from y

                        if ($this->image_ratio_x) {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;calculate x size<br />';

                            $this->image_dst_x = round(($this->image_src_x * $this->image_y) / $this->image_src_y);

                            $this->image_dst_y = $this->image_y;



                            // keeps aspect ratio with y calculated from x
                        } else if ($this->image_ratio_y) {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;calculate y size<br />';

                            $this->image_dst_x = $this->image_x;

                            $this->image_dst_y = round(($this->image_src_y * $this->image_x) / $this->image_src_x);



                            // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels
                        } else if (is_numeric($this->image_ratio_pixels)) {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;calculate x/y size to match a number of pixels<br />';

                            $pixels = $this->image_src_y * $this->image_src_x;

                            $diff = sqrt($this->image_ratio_pixels / $pixels);

                            $this->image_dst_x = round($this->image_src_x * $diff);

                            $this->image_dst_y = round($this->image_src_y * $diff);



                            // keeps aspect ratio with x and y dimensions, filling the space
                        } else if ($this->image_ratio_crop) {

                            if (!is_string($this->image_ratio_crop))
                                $this->image_ratio_crop = '';

                            $this->image_ratio_crop = strtolower($this->image_ratio_crop);

                            if (($this->image_src_x / $this->image_x) > ($this->image_src_y / $this->image_y)) {

                                $this->image_dst_y = $this->image_y;

                                $this->image_dst_x = intval($this->image_src_x * ($this->image_y / $this->image_src_y));

                                $ratio_crop = array();

                                $ratio_crop['x'] = $this->image_dst_x - $this->image_x;

                                if (strpos($this->image_ratio_crop, 'l') !== false) {

                                    $ratio_crop['l'] = 0;

                                    $ratio_crop['r'] = $ratio_crop['x'];
                                } else if (strpos($this->image_ratio_crop, 'r') !== false) {

                                    $ratio_crop['l'] = $ratio_crop['x'];

                                    $ratio_crop['r'] = 0;
                                } else {

                                    $ratio_crop['l'] = round($ratio_crop['x'] / 2);

                                    $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l'];
                                }

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;ratio_crop_x         : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')<br />';

                                if (is_null($this->image_crop))
                                    $this->image_crop = array(0, 0, 0, 0);
                            } else {

                                $this->image_dst_x = $this->image_x;

                                $this->image_dst_y = intval($this->image_src_y * ($this->image_x / $this->image_src_x));

                                $ratio_crop = array();

                                $ratio_crop['y'] = $this->image_dst_y - $this->image_y;

                                if (strpos($this->image_ratio_crop, 't') !== false) {

                                    $ratio_crop['t'] = 0;

                                    $ratio_crop['b'] = $ratio_crop['y'];
                                } else if (strpos($this->image_ratio_crop, 'b') !== false) {

                                    $ratio_crop['t'] = $ratio_crop['y'];

                                    $ratio_crop['b'] = 0;
                                } else {

                                    $ratio_crop['t'] = round($ratio_crop['y'] / 2);

                                    $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t'];
                                }

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;ratio_crop_y         : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')<br />';

                                if (is_null($this->image_crop))
                                    $this->image_crop = array(0, 0, 0, 0);
                            }



                            // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest
                        } else if ($this->image_ratio_fill) {

                            if (!is_string($this->image_ratio_fill))
                                $this->image_ratio_fill = '';

                            $this->image_ratio_fill = strtolower($this->image_ratio_fill);

                            if (($this->image_src_x / $this->image_x) < ($this->image_src_y / $this->image_y)) {

                                $this->image_dst_y = $this->image_y;

                                $this->image_dst_x = intval($this->image_src_x * ($this->image_y / $this->image_src_y));

                                $ratio_crop = array();

                                $ratio_crop['x'] = $this->image_dst_x - $this->image_x;

                                if (strpos($this->image_ratio_fill, 'l') !== false) {

                                    $ratio_crop['l'] = 0;

                                    $ratio_crop['r'] = $ratio_crop['x'];
                                } else if (strpos($this->image_ratio_fill, 'r') !== false) {

                                    $ratio_crop['l'] = $ratio_crop['x'];

                                    $ratio_crop['r'] = 0;
                                } else {

                                    $ratio_crop['l'] = round($ratio_crop['x'] / 2);

                                    $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l'];
                                }

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;ratio_fill_x         : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')<br />';

                                if (is_null($this->image_crop))
                                    $this->image_crop = array(0, 0, 0, 0);
                            } else {

                                $this->image_dst_x = $this->image_x;

                                $this->image_dst_y = intval($this->image_src_y * ($this->image_x / $this->image_src_x));

                                $ratio_crop = array();

                                $ratio_crop['y'] = $this->image_dst_y - $this->image_y;

                                if (strpos($this->image_ratio_fill, 't') !== false) {

                                    $ratio_crop['t'] = 0;

                                    $ratio_crop['b'] = $ratio_crop['y'];
                                } else if (strpos($this->image_ratio_fill, 'b') !== false) {

                                    $ratio_crop['t'] = $ratio_crop['y'];

                                    $ratio_crop['b'] = 0;
                                } else {

                                    $ratio_crop['t'] = round($ratio_crop['y'] / 2);

                                    $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t'];
                                }

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;ratio_fill_y         : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')<br />';

                                if (is_null($this->image_crop))
                                    $this->image_crop = array(0, 0, 0, 0);
                            }



                            // keeps aspect ratio with x and y dimensions
                        } else if ($this->image_ratio) {

                            if (($this->image_src_x / $this->image_x) > ($this->image_src_y / $this->image_y)) {

                                $this->image_dst_x = $this->image_x;

                                $this->image_dst_y = intval($this->image_src_y * ($this->image_x / $this->image_src_x));
                            } else {

                                $this->image_dst_y = $this->image_y;

                                $this->image_dst_x = intval($this->image_src_x * ($this->image_y / $this->image_src_y));
                            }



                            // resize to provided exact dimensions
                        } else {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;use plain sizes<br />';

                            $this->image_dst_x = $this->image_x;

                            $this->image_dst_y = $this->image_y;
                        }



                        if ($this->image_dst_x < 1)
                            $this->image_dst_x = 1;

                        if ($this->image_dst_y < 1)
                            $this->image_dst_y = 1;

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_src_x y        : ' . $this->image_src_x . ' x ' . $this->image_src_y . '<br />';

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image_dst_x y        : ' . $this->image_dst_x . ' x ' . $this->image_dst_y . '<br />';



                        // make sure we don't enlarge the image if we don't want to

                        if ($this->image_no_enlarging && ($this->image_src_x < $this->image_dst_x || $this->image_src_y < $this->image_dst_y)) {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;cancel resizing, as it would enlarge the image!<br />';

                            $this->image_dst_x = $this->image_src_x;

                            $this->image_dst_y = $this->image_src_y;
                        }



                        // make sure we don't shrink the image if we don't want to

                        if ($this->image_no_shrinking && ($this->image_src_x > $this->image_dst_x || $this->image_src_y > $this->image_dst_y)) {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;cancel resizing, as it would shrink the image!<br />';

                            $this->image_dst_x = $this->image_src_x;

                            $this->image_dst_y = $this->image_src_y;
                        }



                        // resize the image

                        if ($this->image_dst_x != $this->image_src_x && $this->image_dst_y != $this->image_src_y) {

                            $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);



                            if ($gd_version >= 2) {

                                $res = imagecopyresampled($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y);
                            } else {

                                $res = imagecopyresized($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y);
                            }



                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;resized image object created<br />';

                            // we transfert tmp into image_dst

                            $image_dst = $this->imagetransfer($tmp, $image_dst);
                        }
                    } else {

                        $this->image_dst_x = $this->image_src_x;

                        $this->image_dst_y = $this->image_src_y;
                    }



                    // crop image (and also crops if image_ratio_crop is used)

                    if ((!empty($this->image_crop) || !is_null($ratio_crop))) {

                        list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_crop, $this->image_dst_x, $this->image_dst_y, true, true);

                        // we adjust the cropping if we use image_ratio_crop

                        if (!is_null($ratio_crop)) {

                            if (array_key_exists('t', $ratio_crop))
                                $ct += $ratio_crop['t'];

                            if (array_key_exists('r', $ratio_crop))
                                $cr += $ratio_crop['r'];

                            if (array_key_exists('b', $ratio_crop))
                                $cb += $ratio_crop['b'];

                            if (array_key_exists('l', $ratio_crop))
                                $cl += $ratio_crop['l'];
                        }

                        $this->log .= '- crop image : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . ' <br />';

                        $this->image_dst_x = $this->image_dst_x - $cl - $cr;

                        $this->image_dst_y = $this->image_dst_y - $ct - $cb;

                        if ($this->image_dst_x < 1)
                            $this->image_dst_x = 1;

                        if ($this->image_dst_y < 1)
                            $this->image_dst_y = 1;

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);



                        // we copy the image into the recieving image

                        imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_dst_x, $this->image_dst_y);



                        // if we crop with negative margins, we have to make sure the extra bits are the right color, or transparent

                        if ($ct < 0 || $cr < 0 || $cb < 0 || $cl < 0) {

                            // use the background color if present

                            if (!empty($this->image_background_color)) {

                                list($red, $green, $blue) = $this->getcolors($this->image_background_color);

                                $fill = imagecolorallocate($tmp, $red, $green, $blue);
                            } else {

                                $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
                            }

                            // fills eventual negative margins

                            if ($ct < 0)
                                imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, -$ct - 1, $fill);

                            if ($cr < 0)
                                imagefilledrectangle($tmp, $this->image_dst_x + $cr, 0, $this->image_dst_x, $this->image_dst_y, $fill);

                            if ($cb < 0)
                                imagefilledrectangle($tmp, 0, $this->image_dst_y + $cb, $this->image_dst_x, $this->image_dst_y, $fill);

                            if ($cl < 0)
                                imagefilledrectangle($tmp, 0, 0, -$cl - 1, $this->image_dst_y, $fill);
                        }



                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // flip image

                    if ($gd_version >= 2 && !empty($this->image_flip)) {

                        $this->image_flip = strtolower($this->image_flip);

                        $this->log .= '- flip image : ' . $this->image_flip . '<br />';

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);

                        for ($x = 0; $x < $this->image_dst_x; $x++) {

                            for ($y = 0; $y < $this->image_dst_y; $y++) {

                                if (strpos($this->image_flip, 'v') !== false) {

                                    imagecopy($tmp, $image_dst, $this->image_dst_x - $x - 1, $y, $x, $y, 1, 1);
                                } else {

                                    imagecopy($tmp, $image_dst, $x, $this->image_dst_y - $y - 1, $x, $y, 1, 1);
                                }
                            }
                        }

                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // rotate image

                    if ($gd_version >= 2 && is_numeric($this->image_rotate)) {

                        if (!in_array($this->image_rotate, array(0, 90, 180, 270)))
                            $this->image_rotate = 0;

                        if ($this->image_rotate != 0) {

                            if ($this->image_rotate == 90 || $this->image_rotate == 270) {

                                $tmp = $this->imagecreatenew($this->image_dst_y, $this->image_dst_x);
                            } else {

                                $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);
                            }

                            $this->log .= '- rotate image : ' . $this->image_rotate . '<br />';

                            for ($x = 0; $x < $this->image_dst_x; $x++) {

                                for ($y = 0; $y < $this->image_dst_y; $y++) {

                                    if ($this->image_rotate == 90) {

                                        imagecopy($tmp, $image_dst, $y, $x, $x, $this->image_dst_y - $y - 1, 1, 1);
                                    } else if ($this->image_rotate == 180) {

                                        imagecopy($tmp, $image_dst, $x, $y, $this->image_dst_x - $x - 1, $this->image_dst_y - $y - 1, 1, 1);
                                    } else if ($this->image_rotate == 270) {

                                        imagecopy($tmp, $image_dst, $y, $x, $this->image_dst_x - $x - 1, $y, 1, 1);
                                    } else {

                                        imagecopy($tmp, $image_dst, $x, $y, $x, $y, 1, 1);
                                    }
                                }
                            }

                            if ($this->image_rotate == 90 || $this->image_rotate == 270) {

                                $t = $this->image_dst_y;

                                $this->image_dst_y = $this->image_dst_x;

                                $this->image_dst_x = $t;
                            }

                            // we transfert tmp into image_dst

                            $image_dst = $this->imagetransfer($tmp, $image_dst);
                        }
                    }



                    // pixelate image

                    if ((is_numeric($this->image_pixelate) && $this->image_pixelate > 0)) {

                        $this->log .= '- pixelate image (' . $this->image_pixelate . 'px)<br />';

                        $filter = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);

                        if ($gd_version >= 2) {

                            imagecopyresampled($filter, $image_dst, 0, 0, 0, 0, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate), $this->image_dst_x, $this->image_dst_y);

                            imagecopyresampled($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate));
                        } else {

                            imagecopyresized($filter, $image_dst, 0, 0, 0, 0, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate), $this->image_dst_x, $this->image_dst_y);

                            imagecopyresized($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate));
                        }

                        imagedestroy($filter);
                    }



                    // unsharp mask

                    if ($gd_version >= 2 && $this->image_unsharp && is_numeric($this->image_unsharp_amount) && is_numeric($this->image_unsharp_radius) && is_numeric($this->image_unsharp_threshold)) {

                        // Unsharp Mask for PHP - version 2.1.1
                        // Unsharp mask algorithm by Torstein Hønsi 2003-07.
                        // Used with permission
                        // Modified to support alpha transparency

                        if ($this->image_unsharp_amount > 500)
                            $this->image_unsharp_amount = 500;

                        $this->image_unsharp_amount = $this->image_unsharp_amount * 0.016;

                        if ($this->image_unsharp_radius > 50)
                            $this->image_unsharp_radius = 50;

                        $this->image_unsharp_radius = $this->image_unsharp_radius * 2;

                        if ($this->image_unsharp_threshold > 255)
                            $this->image_unsharp_threshold = 255;

                        $this->image_unsharp_radius = abs(round($this->image_unsharp_radius));

                        if ($this->image_unsharp_radius != 0) {

                            $this->image_dst_x = imagesx($image_dst);

                            $this->image_dst_y = imagesy($image_dst);

                            $canvas = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true);

                            $blur = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true);

                            if ($this->function_enabled('imageconvolution')) { // PHP >= 5.1
                                $matrix = array(array(1, 2, 1), array(2, 4, 2), array(1, 2, 1));

                                imagecopy($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y);

                                imageconvolution($blur, $matrix, 16, 0);
                            } else {

                                for ($i = 0; $i < $this->image_unsharp_radius; $i++) {

                                    imagecopy($blur, $image_dst, 0, 0, 1, 0, $this->image_dst_x - 1, $this->image_dst_y); // left

                                    $this->imagecopymergealpha($blur, $image_dst, 1, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // right

                                    $this->imagecopymergealpha($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // center

                                    imagecopy($canvas, $blur, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y);

                                    $this->imagecopymergealpha($blur, $canvas, 0, 0, 0, 1, $this->image_dst_x, $this->image_dst_y - 1, 33.33333); // up

                                    $this->imagecopymergealpha($blur, $canvas, 0, 1, 0, 0, $this->image_dst_x, $this->image_dst_y, 25); // down
                                }
                            }

                            $p_new = array();

                            if ($this->image_unsharp_threshold > 0) {

                                for ($x = 0; $x < $this->image_dst_x - 1; $x++) {

                                    for ($y = 0; $y < $this->image_dst_y; $y++) {

                                        $p_orig = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                        $p_blur = imagecolorsforindex($blur, imagecolorat($blur, $x, $y));

                                        $p_new['red'] = (abs($p_orig['red'] - $p_blur['red']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red'])) : $p_orig['red'];

                                        $p_new['green'] = (abs($p_orig['green'] - $p_blur['green']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green'])) : $p_orig['green'];

                                        $p_new['blue'] = (abs($p_orig['blue'] - $p_blur['blue']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'])) : $p_orig['blue'];

                                        if (($p_orig['red'] != $p_new['red']) || ($p_orig['green'] != $p_new['green']) || ($p_orig['blue'] != $p_new['blue'])) {

                                            $color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']);

                                            imagesetpixel($image_dst, $x, $y, $color);
                                        }
                                    }
                                }
                            } else {

                                for ($x = 0; $x < $this->image_dst_x; $x++) {

                                    for ($y = 0; $y < $this->image_dst_y; $y++) {

                                        $p_orig = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                        $p_blur = imagecolorsforindex($blur, imagecolorat($blur, $x, $y));

                                        $p_new['red'] = ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red'];

                                        if ($p_new['red'] > 255) {

                                            $p_new['red'] = 255;
                                        } elseif ($p_new['red'] < 0) {

                                            $p_new['red'] = 0;
                                        }

                                        $p_new['green'] = ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green'];

                                        if ($p_new['green'] > 255) {

                                            $p_new['green'] = 255;
                                        } elseif ($p_new['green'] < 0) {

                                            $p_new['green'] = 0;
                                        }

                                        $p_new['blue'] = ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'];

                                        if ($p_new['blue'] > 255) {

                                            $p_new['blue'] = 255;
                                        } elseif ($p_new['blue'] < 0) {

                                            $p_new['blue'] = 0;
                                        }

                                        $color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']);

                                        imagesetpixel($image_dst, $x, $y, $color);
                                    }
                                }
                            }

                            imagedestroy($canvas);

                            imagedestroy($blur);
                        }
                    }



                    // add color overlay

                    if ($gd_version >= 2 && (is_numeric($this->image_overlay_opacity) && $this->image_overlay_opacity > 0 && !empty($this->image_overlay_color))) {

                        $this->log .= '- apply color overlay<br />';

                        list($red, $green, $blue) = $this->getcolors($this->image_overlay_color);

                        $filter = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y);

                        $color = imagecolorallocate($filter, $red, $green, $blue);

                        imagefilledrectangle($filter, 0, 0, $this->image_dst_x, $this->image_dst_y, $color);

                        $this->imagecopymergealpha($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_overlay_opacity);

                        imagedestroy($filter);
                    }



                    // add brightness, contrast and tint, turns to greyscale and inverts colors

                    if ($gd_version >= 2 && ($this->image_negative || $this->image_greyscale || is_numeric($this->image_threshold) || is_numeric($this->image_brightness) || is_numeric($this->image_contrast) || !empty($this->image_tint_color))) {

                        $this->log .= '- apply tint, light, contrast correction, negative, greyscale and threshold<br />';

                        if (!empty($this->image_tint_color))
                            list($tint_red, $tint_green, $tint_blue) = $this->getcolors($this->image_tint_color);

                        //imagealphablending($image_dst, true);

                        for ($y = 0; $y < $this->image_dst_y; $y++) {

                            for ($x = 0; $x < $this->image_dst_x; $x++) {

                                if ($this->image_greyscale) {

                                    $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                    $r = $g = $b = round((0.2125 * $pixel['red']) + (0.7154 * $pixel['green']) + (0.0721 * $pixel['blue']));

                                    $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);

                                    imagesetpixel($image_dst, $x, $y, $color);

                                    unset($color);

                                    unset($pixel);
                                }

                                if (is_numeric($this->image_threshold)) {

                                    $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                    $c = (round($pixel['red'] + $pixel['green'] + $pixel['blue']) / 3) - 127;

                                    $r = $g = $b = ($c > $this->image_threshold ? 255 : 0);

                                    $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);

                                    imagesetpixel($image_dst, $x, $y, $color);

                                    unset($color);

                                    unset($pixel);
                                }

                                if (is_numeric($this->image_brightness)) {

                                    $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                    $r = max(min(round($pixel['red'] + (($this->image_brightness * 2))), 255), 0);

                                    $g = max(min(round($pixel['green'] + (($this->image_brightness * 2))), 255), 0);

                                    $b = max(min(round($pixel['blue'] + (($this->image_brightness * 2))), 255), 0);

                                    $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);

                                    imagesetpixel($image_dst, $x, $y, $color);

                                    unset($color);

                                    unset($pixel);
                                }

                                if (is_numeric($this->image_contrast)) {

                                    $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                    $r = max(min(round(($this->image_contrast + 128) * $pixel['red'] / 128), 255), 0);

                                    $g = max(min(round(($this->image_contrast + 128) * $pixel['green'] / 128), 255), 0);

                                    $b = max(min(round(($this->image_contrast + 128) * $pixel['blue'] / 128), 255), 0);

                                    $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);

                                    imagesetpixel($image_dst, $x, $y, $color);

                                    unset($color);

                                    unset($pixel);
                                }

                                if (!empty($this->image_tint_color)) {

                                    $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                    $r = min(round($tint_red * $pixel['red'] / 169), 255);

                                    $g = min(round($tint_green * $pixel['green'] / 169), 255);

                                    $b = min(round($tint_blue * $pixel['blue'] / 169), 255);

                                    $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);

                                    imagesetpixel($image_dst, $x, $y, $color);

                                    unset($color);

                                    unset($pixel);
                                }

                                if (!empty($this->image_negative)) {

                                    $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                    $r = round(255 - $pixel['red']);

                                    $g = round(255 - $pixel['green']);

                                    $b = round(255 - $pixel['blue']);

                                    $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']);

                                    imagesetpixel($image_dst, $x, $y, $color);

                                    unset($color);

                                    unset($pixel);
                                }
                            }
                        }
                    }



                    // adds a border

                    if ($gd_version >= 2 && !empty($this->image_border)) {

                        list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_border, $this->image_dst_x, $this->image_dst_y, true, false);

                        $this->log .= '- add border : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '<br />';

                        $this->image_dst_x = $this->image_dst_x + $cl + $cr;

                        $this->image_dst_y = $this->image_dst_y + $ct + $cb;

                        if (!empty($this->image_border_color))
                            list($red, $green, $blue) = $this->getcolors($this->image_border_color);

                        $opacity = (is_numeric($this->image_border_opacity) ? (int) (127 - $this->image_border_opacity / 100 * 127) : 0);

                        // we now create an image, that we fill with the border color

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);

                        $background = imagecolorallocatealpha($tmp, $red, $green, $blue, $opacity);

                        imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, $this->image_dst_y, $background);

                        // we then copy the source image into the new image, without merging so that only the border is actually kept

                        imagecopy($tmp, $image_dst, $cl, $ct, 0, 0, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct);

                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // adds a fading-to-transparent border

                    if ($gd_version >= 2 && !empty($this->image_border_transparent)) {

                        list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_border_transparent, $this->image_dst_x, $this->image_dst_y, true, false);

                        $this->log .= '- add transparent border : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '<br />';

                        // we now create an image, that we fill with the border color

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);

                        // we then copy the source image into the new image, without the borders

                        imagecopy($tmp, $image_dst, $cl, $ct, $cl, $ct, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct);

                        // we now add the top border

                        $opacity = 100;

                        for ($y = $ct - 1; $y >= 0; $y--) {

                            $il = (int) ($ct > 0 ? ($cl * ($y / $ct)) : 0);

                            $ir = (int) ($ct > 0 ? ($cr * ($y / $ct)) : 0);

                            for ($x = $il; $x < $this->image_dst_x - $ir; $x++) {

                                $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100;

                                if ($alpha > 0) {

                                    if ($alpha > 1)
                                        $alpha = 1;

                                    $color = imagecolorallocatealpha($tmp, $pixel['red'], $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127));

                                    imagesetpixel($tmp, $x, $y, $color);
                                }
                            }

                            if ($opacity > 0)
                                $opacity = $opacity - (100 / $ct);
                        }

                        // we now add the right border

                        $opacity = 100;

                        for ($x = $this->image_dst_x - $cr; $x < $this->image_dst_x; $x++) {

                            $it = (int) ($cr > 0 ? ($ct * (($this->image_dst_x - $x - 1) / $cr)) : 0);

                            $ib = (int) ($cr > 0 ? ($cb * (($this->image_dst_x - $x - 1) / $cr)) : 0);

                            for ($y = $it; $y < $this->image_dst_y - $ib; $y++) {

                                $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100;

                                if ($alpha > 0) {

                                    if ($alpha > 1)
                                        $alpha = 1;

                                    $color = imagecolorallocatealpha($tmp, $pixel['red'], $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127));

                                    imagesetpixel($tmp, $x, $y, $color);
                                }
                            }

                            if ($opacity > 0)
                                $opacity = $opacity - (100 / $cr);
                        }

                        // we now add the bottom border

                        $opacity = 100;

                        for ($y = $this->image_dst_y - $cb; $y < $this->image_dst_y; $y++) {

                            $il = (int) ($cb > 0 ? ($cl * (($this->image_dst_y - $y - 1) / $cb)) : 0);

                            $ir = (int) ($cb > 0 ? ($cr * (($this->image_dst_y - $y - 1) / $cb)) : 0);

                            for ($x = $il; $x < $this->image_dst_x - $ir; $x++) {

                                $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100;

                                if ($alpha > 0) {

                                    if ($alpha > 1)
                                        $alpha = 1;

                                    $color = imagecolorallocatealpha($tmp, $pixel['red'], $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127));

                                    imagesetpixel($tmp, $x, $y, $color);
                                }
                            }

                            if ($opacity > 0)
                                $opacity = $opacity - (100 / $cb);
                        }

                        // we now add the left border

                        $opacity = 100;

                        for ($x = $cl - 1; $x >= 0; $x--) {

                            $it = (int) ($cl > 0 ? ($ct * ($x / $cl)) : 0);

                            $ib = (int) ($cl > 0 ? ($cb * ($x / $cl)) : 0);

                            for ($y = $it; $y < $this->image_dst_y - $ib; $y++) {

                                $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100;

                                if ($alpha > 0) {

                                    if ($alpha > 1)
                                        $alpha = 1;

                                    $color = imagecolorallocatealpha($tmp, $pixel['red'], $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127));

                                    imagesetpixel($tmp, $x, $y, $color);
                                }
                            }

                            if ($opacity > 0)
                                $opacity = $opacity - (100 / $cl);
                        }

                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // add frame border

                    if ($gd_version >= 2 && is_numeric($this->image_frame)) {

                        if (is_array($this->image_frame_colors)) {

                            $vars = $this->image_frame_colors;

                            $this->log .= '- add frame : ' . implode(' ', $this->image_frame_colors) . '<br />';
                        } else {

                            $this->log .= '- add frame : ' . $this->image_frame_colors . '<br />';

                            $vars = explode(' ', $this->image_frame_colors);
                        }

                        $nb = sizeof($vars);

                        $this->image_dst_x = $this->image_dst_x + ($nb * 2);

                        $this->image_dst_y = $this->image_dst_y + ($nb * 2);

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);

                        imagecopy($tmp, $image_dst, $nb, $nb, 0, 0, $this->image_dst_x - ($nb * 2), $this->image_dst_y - ($nb * 2));

                        $opacity = (is_numeric($this->image_frame_opacity) ? (int) (127 - $this->image_frame_opacity / 100 * 127) : 0);

                        for ($i = 0; $i < $nb; $i++) {

                            list($red, $green, $blue) = $this->getcolors($vars[$i]);

                            $c = imagecolorallocatealpha($tmp, $red, $green, $blue, $opacity);

                            if ($this->image_frame == 1) {

                                imageline($tmp, $i, $i, $this->image_dst_x - $i - 1, $i, $c);

                                imageline($tmp, $this->image_dst_x - $i - 1, $this->image_dst_y - $i - 1, $this->image_dst_x - $i - 1, $i, $c);

                                imageline($tmp, $this->image_dst_x - $i - 1, $this->image_dst_y - $i - 1, $i, $this->image_dst_y - $i - 1, $c);

                                imageline($tmp, $i, $i, $i, $this->image_dst_y - $i - 1, $c);
                            } else {

                                imageline($tmp, $i, $i, $this->image_dst_x - $i - 1, $i, $c);

                                imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $this->image_dst_x - $nb + $i, $nb - $i, $c);

                                imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $nb - $i, $this->image_dst_y - $nb + $i, $c);

                                imageline($tmp, $i, $i, $i, $this->image_dst_y - $i - 1, $c);
                            }
                        }

                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // add bevel border

                    if ($gd_version >= 2 && $this->image_bevel > 0) {

                        if (empty($this->image_bevel_color1))
                            $this->image_bevel_color1 = '#FFFFFF';

                        if (empty($this->image_bevel_color2))
                            $this->image_bevel_color2 = '#000000';

                        list($red1, $green1, $blue1) = $this->getcolors($this->image_bevel_color1);

                        list($red2, $green2, $blue2) = $this->getcolors($this->image_bevel_color2);

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y);

                        imagecopy($tmp, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y);

                        imagealphablending($tmp, true);

                        for ($i = 0; $i < $this->image_bevel; $i++) {

                            $alpha = round(($i / $this->image_bevel) * 127);

                            $c1 = imagecolorallocatealpha($tmp, $red1, $green1, $blue1, $alpha);

                            $c2 = imagecolorallocatealpha($tmp, $red2, $green2, $blue2, $alpha);

                            imageline($tmp, $i, $i, $this->image_dst_x - $i - 1, $i, $c1);

                            imageline($tmp, $this->image_dst_x - $i - 1, $this->image_dst_y - $i, $this->image_dst_x - $i - 1, $i, $c2);

                            imageline($tmp, $this->image_dst_x - $i - 1, $this->image_dst_y - $i - 1, $i, $this->image_dst_y - $i - 1, $c2);

                            imageline($tmp, $i, $i, $i, $this->image_dst_y - $i - 1, $c1);
                        }

                        // we transfert tmp into image_dst

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // add watermark image

                    if ($this->image_watermark != '' && file_exists($this->image_watermark)) {

                        $this->log .= '- add watermark<br />';

                        $this->image_watermark_position = strtolower($this->image_watermark_position);

                        $watermark_info = getimagesize($this->image_watermark);

                        $watermark_type = (array_key_exists(2, $watermark_info) ? $watermark_info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG

                        $watermark_checked = false;

                        if ($watermark_type == IMAGETYPE_GIF) {

                            if (!$this->function_enabled('imagecreatefromgif')) {

                                $this->error = $this->translate('watermark_no_create_support', array('GIF'));
                            } else {

                                $filter = @imagecreatefromgif($this->image_watermark);

                                if (!$filter) {

                                    $this->error = $this->translate('watermark_create_error', array('GIF'));
                                } else {

                                    $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;watermark source image is GIF<br />';

                                    $watermark_checked = true;
                                }
                            }
                        } else if ($watermark_type == IMAGETYPE_JPEG) {

                            if (!$this->function_enabled('imagecreatefromjpeg')) {

                                $this->error = $this->translate('watermark_no_create_support', array('JPEG'));
                            } else {

                                $filter = @imagecreatefromjpeg($this->image_watermark);

                                if (!$filter) {

                                    $this->error = $this->translate('watermark_create_error', array('JPEG'));
                                } else {

                                    $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;watermark source image is JPEG<br />';

                                    $watermark_checked = true;
                                }
                            }
                        } else if ($watermark_type == IMAGETYPE_PNG) {

                            if (!$this->function_enabled('imagecreatefrompng')) {

                                $this->error = $this->translate('watermark_no_create_support', array('PNG'));
                            } else {

                                $filter = @imagecreatefrompng($this->image_watermark);

                                if (!$filter) {

                                    $this->error = $this->translate('watermark_create_error', array('PNG'));
                                } else {

                                    $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;watermark source image is PNG<br />';

                                    $watermark_checked = true;
                                }
                            }
                        } else if ($watermark_type == IMAGETYPE_BMP) {

                            if (!method_exists($this, 'imagecreatefrombmp')) {

                                $this->error = $this->translate('watermark_no_create_support', array('BMP'));
                            } else {

                                $filter = @$this->imagecreatefrombmp($this->image_watermark);

                                if (!$filter) {

                                    $this->error = $this->translate('watermark_create_error', array('BMP'));
                                } else {

                                    $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;watermark source image is BMP<br />';

                                    $watermark_checked = true;
                                }
                            }
                        } else {

                            $this->error = $this->translate('watermark_invalid');
                        }

                        if ($watermark_checked) {

                            $watermark_dst_width = $watermark_src_width = imagesx($filter);

                            $watermark_dst_height = $watermark_src_height = imagesy($filter);



                            // if watermark is too large/tall, resize it first

                            if ((!$this->image_watermark_no_zoom_out && ($watermark_dst_width > $this->image_dst_x || $watermark_dst_height > $this->image_dst_y)) || (!$this->image_watermark_no_zoom_in && $watermark_dst_width < $this->image_dst_x && $watermark_dst_height < $this->image_dst_y)) {

                                $canvas_width = $this->image_dst_x - abs($this->image_watermark_x);

                                $canvas_height = $this->image_dst_y - abs($this->image_watermark_y);

                                if (($watermark_src_width / $canvas_width) > ($watermark_src_height / $canvas_height)) {

                                    $watermark_dst_width = $canvas_width;

                                    $watermark_dst_height = intval($watermark_src_height * ($canvas_width / $watermark_src_width));
                                } else {

                                    $watermark_dst_height = $canvas_height;

                                    $watermark_dst_width = intval($watermark_src_width * ($canvas_height / $watermark_src_height));
                                }

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;watermark resized from ' . $watermark_src_width . 'x' . $watermark_src_height . ' to ' . $watermark_dst_width . 'x' . $watermark_dst_height . '<br />';
                            }

                            // determine watermark position

                            $watermark_x = 0;

                            $watermark_y = 0;

                            if (is_numeric($this->image_watermark_x)) {

                                if ($this->image_watermark_x < 0) {

                                    $watermark_x = $this->image_dst_x - $watermark_dst_width + $this->image_watermark_x;
                                } else {

                                    $watermark_x = $this->image_watermark_x;
                                }
                            } else {

                                if (strpos($this->image_watermark_position, 'r') !== false) {

                                    $watermark_x = $this->image_dst_x - $watermark_dst_width;
                                } else if (strpos($this->image_watermark_position, 'l') !== false) {

                                    $watermark_x = 0;
                                } else {

                                    $watermark_x = ($this->image_dst_x - $watermark_dst_width) / 2;
                                }
                            }

                            if (is_numeric($this->image_watermark_y)) {

                                if ($this->image_watermark_y < 0) {

                                    $watermark_y = $this->image_dst_y - $watermark_dst_height + $this->image_watermark_y;
                                } else {

                                    $watermark_y = $this->image_watermark_y;
                                }
                            } else {

                                if (strpos($this->image_watermark_position, 'b') !== false) {

                                    $watermark_y = $this->image_dst_y - $watermark_dst_height;
                                } else if (strpos($this->image_watermark_position, 't') !== false) {

                                    $watermark_y = 0;
                                } else {

                                    $watermark_y = ($this->image_dst_y - $watermark_dst_height) / 2;
                                }
                            }

                            imagealphablending($image_dst, true);

                            imagecopyresampled($image_dst, $filter, $watermark_x, $watermark_y, 0, 0, $watermark_dst_width, $watermark_dst_height, $watermark_src_width, $watermark_src_height);
                        } else {

                            $this->error = $this->translate('watermark_invalid');
                        }
                    }



                    // add text

                    if (!empty($this->image_text)) {

                        $this->log .= '- add text<br />';



                        // calculate sizes in human readable format

                        $src_size = $this->file_src_size / 1024;

                        $src_size_mb = number_format($src_size / 1024, 1, ".", " ");

                        $src_size_kb = number_format($src_size, 1, ".", " ");

                        $src_size_human = ($src_size > 1024 ? $src_size_mb . " MB" : $src_size_kb . " kb");



                        $this->image_text = str_replace(
                                array('[src_name]',
                            '[src_name_body]',
                            '[src_name_ext]',
                            '[src_pathname]',
                            '[src_mime]',
                            '[src_size]',
                            '[src_size_kb]',
                            '[src_size_mb]',
                            '[src_size_human]',
                            '[src_x]',
                            '[src_y]',
                            '[src_pixels]',
                            '[src_type]',
                            '[src_bits]',
                            '[dst_path]',
                            '[dst_name_body]',
                            '[dst_name_ext]',
                            '[dst_name]',
                            '[dst_pathname]',
                            '[dst_x]',
                            '[dst_y]',
                            '[date]',
                            '[time]',
                            '[host]',
                            '[server]',
                            '[ip]',
                            '[gd_version]'), array($this->file_src_name,
                            $this->file_src_name_body,
                            $this->file_src_name_ext,
                            $this->file_src_pathname,
                            $this->file_src_mime,
                            $this->file_src_size,
                            $src_size_kb,
                            $src_size_mb,
                            $src_size_human,
                            $this->image_src_x,
                            $this->image_src_y,
                            $this->image_src_pixels,
                            $this->image_src_type,
                            $this->image_src_bits,
                            $this->file_dst_path,
                            $this->file_dst_name_body,
                            $this->file_dst_name_ext,
                            $this->file_dst_name,
                            $this->file_dst_pathname,
                            $this->image_dst_x,
                            $this->image_dst_y,
                            date('Y-m-d'),
                            date('H:i:s'),
                            (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'n/a'),
                            (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'n/a'),
                            (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'n/a'),
                            $this->gdversion(true)), $this->image_text);



                        if (!is_numeric($this->image_text_padding))
                            $this->image_text_padding = 0;

                        if (!is_numeric($this->image_text_line_spacing))
                            $this->image_text_line_spacing = 0;

                        if (!is_numeric($this->image_text_padding_x))
                            $this->image_text_padding_x = $this->image_text_padding;

                        if (!is_numeric($this->image_text_padding_y))
                            $this->image_text_padding_y = $this->image_text_padding;

                        $this->image_text_position = strtolower($this->image_text_position);

                        $this->image_text_direction = strtolower($this->image_text_direction);

                        $this->image_text_alignment = strtolower($this->image_text_alignment);



                        $font_type = 'gd';



                        // if the font is a string with a GDF font path, we assume that we might want to load a font

                        if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.gdf') {

                            if (strpos($this->image_text_font, '/') === false)
                                $this->image_text_font = "./" . $this->image_text_font;

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;try to load font ' . $this->image_text_font . '... ';

                            if ($this->image_text_font = @imageloadfont($this->image_text_font)) {

                                $this->log .= 'success<br />';
                            } else {

                                $this->log .= 'error<br />';

                                $this->image_text_font = 5;
                            }
                        }



                        // if the font is a string with a TTF font path, we check if we can access the font file

                        if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.ttf') {

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;try to load font ' . $this->image_text_font . '... ';

                            if (strpos($this->image_text_font, '/') === false)
                                $this->image_text_font = "./" . $this->image_text_font;

                            if (file_exists($this->image_text_font) && is_readable($this->image_text_font)) {

                                $this->log .= 'success<br />';

                                $font_type = 'tt';
                            } else {

                                $this->log .= 'error<br />';

                                $this->image_text_font = 5;
                            }
                        }



                        // get the text bounding box (GD fonts)

                        if ($font_type == 'gd') {

                            $text = explode("\n", $this->image_text);

                            $char_width = imagefontwidth($this->image_text_font);

                            $char_height = imagefontheight($this->image_text_font);

                            $text_height = 0;

                            $text_width = 0;

                            $line_height = 0;

                            $line_width = 0;

                            foreach ($text as $k => $v) {

                                if ($this->image_text_direction == 'v') {

                                    $h = ($char_width * strlen($v));

                                    if ($h > $text_height)
                                        $text_height = $h;

                                    $line_width = $char_height;

                                    $text_width += $line_width + ($k < (sizeof($text) - 1) ? $this->image_text_line_spacing : 0);
                                } else {

                                    $w = ($char_width * strlen($v));

                                    if ($w > $text_width)
                                        $text_width = $w;

                                    $line_height = $char_height;

                                    $text_height += $line_height + ($k < (sizeof($text) - 1) ? $this->image_text_line_spacing : 0);
                                }
                            }

                            $text_width += (2 * $this->image_text_padding_x);

                            $text_height += (2 * $this->image_text_padding_y);



                            // get the text bounding box (TrueType fonts)
                        } else if ($font_type == 'tt') {

                            $text = $this->image_text;

                            if (!$this->image_text_angle)
                                $this->image_text_angle = $this->image_text_direction == 'v' ? 90 : 0;

                            $text_height = 0;

                            $text_width = 0;

                            $text_offset_x = 0;

                            $text_offset_y = 0;

                            $rect = imagettfbbox($this->image_text_size, $this->image_text_angle, $this->image_text_font, $text);

                            if ($rect) {

                                $minX = min(array($rect[0], $rect[2], $rect[4], $rect[6]));

                                $maxX = max(array($rect[0], $rect[2], $rect[4], $rect[6]));

                                $minY = min(array($rect[1], $rect[3], $rect[5], $rect[7]));

                                $maxY = max(array($rect[1], $rect[3], $rect[5], $rect[7]));

                                $text_offset_x = abs($minX) - 1;

                                $text_offset_y = abs($minY) - 1;

                                $text_width = $maxX - $minX + (2 * $this->image_text_padding_x);

                                $text_height = $maxY - $minY + (2 * $this->image_text_padding_y);
                            }
                        }



                        // position the text block

                        $text_x = 0;

                        $text_y = 0;

                        if (is_numeric($this->image_text_x)) {

                            if ($this->image_text_x < 0) {

                                $text_x = $this->image_dst_x - $text_width + $this->image_text_x;
                            } else {

                                $text_x = $this->image_text_x;
                            }
                        } else {

                            if (strpos($this->image_text_position, 'r') !== false) {

                                $text_x = $this->image_dst_x - $text_width;
                            } else if (strpos($this->image_text_position, 'l') !== false) {

                                $text_x = 0;
                            } else {

                                $text_x = ($this->image_dst_x - $text_width) / 2;
                            }
                        }

                        if (is_numeric($this->image_text_y)) {

                            if ($this->image_text_y < 0) {

                                $text_y = $this->image_dst_y - $text_height + $this->image_text_y;
                            } else {

                                $text_y = $this->image_text_y;
                            }
                        } else {

                            if (strpos($this->image_text_position, 'b') !== false) {

                                $text_y = $this->image_dst_y - $text_height;
                            } else if (strpos($this->image_text_position, 't') !== false) {

                                $text_y = 0;
                            } else {

                                $text_y = ($this->image_dst_y - $text_height) / 2;
                            }
                        }



                        // add a background, maybe transparent

                        if (!empty($this->image_text_background)) {

                            list($red, $green, $blue) = $this->getcolors($this->image_text_background);

                            if ($gd_version >= 2 && (is_numeric($this->image_text_background_opacity)) && $this->image_text_background_opacity >= 0 && $this->image_text_background_opacity <= 100) {

                                $filter = imagecreatetruecolor($text_width, $text_height);

                                $background_color = imagecolorallocate($filter, $red, $green, $blue);

                                imagefilledrectangle($filter, 0, 0, $text_width, $text_height, $background_color);

                                $this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $text_width, $text_height, $this->image_text_background_opacity);

                                imagedestroy($filter);
                            } else {

                                $background_color = imagecolorallocate($image_dst, $red, $green, $blue);

                                imagefilledrectangle($image_dst, $text_x, $text_y, $text_x + $text_width, $text_y + $text_height, $background_color);
                            }
                        }



                        $text_x += $this->image_text_padding_x;

                        $text_y += $this->image_text_padding_y;

                        $t_width = $text_width - (2 * $this->image_text_padding_x);

                        $t_height = $text_height - (2 * $this->image_text_padding_y);

                        list($red, $green, $blue) = $this->getcolors($this->image_text_color);



                        // add the text, maybe transparent

                        if ($gd_version >= 2 && (is_numeric($this->image_text_opacity)) && $this->image_text_opacity >= 0 && $this->image_text_opacity <= 100) {

                            if ($t_width < 0)
                                $t_width = 0;

                            if ($t_height < 0)
                                $t_height = 0;

                            $filter = $this->imagecreatenew($t_width, $t_height, false, true);

                            $text_color = imagecolorallocate($filter, $red, $green, $blue);



                            if ($font_type == 'gd') {

                                foreach ($text as $k => $v) {

                                    if ($this->image_text_direction == 'v') {

                                        imagestringup($filter, $this->image_text_font, $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), $v, $text_color);
                                    } else {

                                        imagestring($filter, $this->image_text_font, ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), $v, $text_color);
                                    }
                                }
                            } else if ($font_type == 'tt') {

                                imagettftext($filter, $this->image_text_size, $this->image_text_angle, $text_offset_x, $text_offset_y, $text_color, $this->image_text_font, $text);
                            }

                            $this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $t_width, $t_height, $this->image_text_opacity);

                            imagedestroy($filter);
                        } else {

                            $text_color = imagecolorallocate($image_dst, $red, $green, $blue);

                            if ($font_type == 'gd') {

                                foreach ($text as $k => $v) {

                                    if ($this->image_text_direction == 'v') {

                                        imagestringup($image_dst, $this->image_text_font, $text_x + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), $text_y + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), $v, $text_color);
                                    } else {

                                        imagestring($image_dst, $this->image_text_font, $text_x + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), $text_y + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), $v, $text_color);
                                    }
                                }
                            } else if ($font_type == 'tt') {

                                imagettftext($image_dst, $this->image_text_size, $this->image_text_angle, $text_offset_x + ($this->image_dst_x / 2) - ($text_width / 2) + $this->image_text_padding_x, $text_offset_y + ($this->image_dst_y / 2) - ($text_height / 2) + $this->image_text_padding_y, $text_color, $this->image_text_font, $text);
                            }
                        }
                    }



                    // add a reflection

                    if ($this->image_reflection_height) {

                        $this->log .= '- add reflection : ' . $this->image_reflection_height . '<br />';

                        // we decode image_reflection_height, which can be a integer, a string in pixels or percentage

                        $image_reflection_height = $this->image_reflection_height;

                        if (strpos($image_reflection_height, '%') > 0)
                            $image_reflection_height = $this->image_dst_y * (str_replace('%', '', $image_reflection_height / 100));

                        if (strpos($image_reflection_height, 'px') > 0)
                            $image_reflection_height = str_replace('px', '', $image_reflection_height);

                        $image_reflection_height = (int) $image_reflection_height;

                        if ($image_reflection_height > $this->image_dst_y)
                            $image_reflection_height = $this->image_dst_y;

                        if (empty($this->image_reflection_opacity))
                            $this->image_reflection_opacity = 60;

                        // create the new destination image

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y + $image_reflection_height + $this->image_reflection_space, true);

                        $transparency = $this->image_reflection_opacity;



                        // copy the original image

                        imagecopy($tmp, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y + ($this->image_reflection_space < 0 ? $this->image_reflection_space : 0));



                        // we have to make sure the extra bit is the right color, or transparent

                        if ($image_reflection_height + $this->image_reflection_space > 0) {

                            // use the background color if present

                            if (!empty($this->image_background_color)) {

                                list($red, $green, $blue) = $this->getcolors($this->image_background_color);

                                $fill = imagecolorallocate($tmp, $red, $green, $blue);
                            } else {

                                $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127);
                            }

                            // fill in from the edge of the extra bit

                            imagefill($tmp, round($this->image_dst_x / 2), $this->image_dst_y + $image_reflection_height + $this->image_reflection_space - 1, $fill);
                        }



                        // copy the reflection

                        for ($y = 0; $y < $image_reflection_height; $y++) {

                            for ($x = 0; $x < $this->image_dst_x; $x++) {

                                $pixel_b = imagecolorsforindex($tmp, imagecolorat($tmp, $x, $y + $this->image_dst_y + $this->image_reflection_space));

                                $pixel_o = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $this->image_dst_y - $y - 1 + ($this->image_reflection_space < 0 ? $this->image_reflection_space : 0)));

                                $alpha_o = 1 - ($pixel_o['alpha'] / 127);

                                $alpha_b = 1 - ($pixel_b['alpha'] / 127);

                                $opacity = $alpha_o * $transparency / 100;

                                if ($opacity > 0) {

                                    $red = round((($pixel_o['red'] * $opacity) + ($pixel_b['red'] ) * $alpha_b) / ($alpha_b + $opacity));

                                    $green = round((($pixel_o['green'] * $opacity) + ($pixel_b['green']) * $alpha_b) / ($alpha_b + $opacity));

                                    $blue = round((($pixel_o['blue'] * $opacity) + ($pixel_b['blue'] ) * $alpha_b) / ($alpha_b + $opacity));

                                    $alpha = ($opacity + $alpha_b);

                                    if ($alpha > 1)
                                        $alpha = 1;

                                    $alpha = round((1 - $alpha) * 127);

                                    $color = imagecolorallocatealpha($tmp, $red, $green, $blue, $alpha);

                                    imagesetpixel($tmp, $x, $y + $this->image_dst_y + $this->image_reflection_space, $color);
                                }
                            }

                            if ($transparency > 0)
                                $transparency = $transparency - ($this->image_reflection_opacity / $image_reflection_height);
                        }



                        // copy the resulting image into the destination image

                        $this->image_dst_y = $this->image_dst_y + $image_reflection_height + $this->image_reflection_space;

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // change opacity

                    if ($gd_version >= 2 && is_numeric($this->image_opacity) && $this->image_opacity < 100) {

                        $this->log .= '- change opacity<br />';

                        // create the new destination image

                        $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, true);

                        for ($y = 0; $y < $this->image_dst_y; $y++) {

                            for ($x = 0; $x < $this->image_dst_x; $x++) {

                                $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                $alpha = $pixel['alpha'] + round((127 - $pixel['alpha']) * (100 - $this->image_opacity) / 100);

                                if ($alpha > 127)
                                    $alpha = 127;

                                if ($alpha > 0) {

                                    $color = imagecolorallocatealpha($tmp, $pixel['red'], $pixel['green'], $pixel['blue'], $alpha);

                                    imagesetpixel($tmp, $x, $y, $color);
                                }
                            }
                        }

                        // copy the resulting image into the destination image

                        $image_dst = $this->imagetransfer($tmp, $image_dst);
                    }



                    // reduce the JPEG image to a set desired size

                    if (is_numeric($this->jpeg_size) && $this->jpeg_size > 0 && ($this->image_convert == 'jpeg' || $this->image_convert == 'jpg')) {

                        // inspired by: JPEGReducer class version 1, 25 November 2004, Author: Huda M ElMatsani, justhuda at netscape dot net

                        $this->log .= '- JPEG desired file size : ' . $this->jpeg_size . '<br />';

                        // calculate size of each image. 75%, 50%, and 25% quality

                        ob_start();

                        imagejpeg($image_dst, null, 75);

                        $buffer = ob_get_contents();

                        ob_end_clean();

                        $size75 = strlen($buffer);

                        ob_start();

                        imagejpeg($image_dst, null, 50);

                        $buffer = ob_get_contents();

                        ob_end_clean();

                        $size50 = strlen($buffer);

                        ob_start();

                        imagejpeg($image_dst, null, 25);

                        $buffer = ob_get_contents();

                        ob_end_clean();

                        $size25 = strlen($buffer);



                        // make sure we won't divide by 0

                        if ($size50 == $size25)
                            $size50++;

                        if ($size75 == $size50 || $size75 == $size25)
                            $size75++;



                        // calculate gradient of size reduction by quality

                        $mgrad1 = 25 / ($size50 - $size25);

                        $mgrad2 = 25 / ($size75 - $size50);

                        $mgrad3 = 50 / ($size75 - $size25);

                        $mgrad = ($mgrad1 + $mgrad2 + $mgrad3) / 3;

                        // result of approx. quality factor for expected size

                        $q_factor = round($mgrad * ($this->jpeg_size - $size50) + 50);



                        if ($q_factor < 1) {

                            $this->jpeg_quality = 1;
                        } elseif ($q_factor > 100) {

                            $this->jpeg_quality = 100;
                        } else {

                            $this->jpeg_quality = $q_factor;
                        }

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;JPEG quality factor set to ' . $this->jpeg_quality . '<br />';
                    }



                    // converts image from true color, and fix transparency if needed

                    $this->log .= '- converting...<br />';

                    $this->image_dst_type = $this->image_convert;

                    switch ($this->image_convert) {

                        case 'gif':

                            // if the image is true color, we convert it to a palette

                            if (imageistruecolor($image_dst)) {

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;true color to palette<br />';

                                // creates a black and white mask

                                $mask = array(array());

                                for ($x = 0; $x < $this->image_dst_x; $x++) {

                                    for ($y = 0; $y < $this->image_dst_y; $y++) {

                                        $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                        $mask[$x][$y] = $pixel['alpha'];
                                    }
                                }

                                list($red, $green, $blue) = $this->getcolors($this->image_default_color);

                                // first, we merge the image with the background color, so we know which colors we will have

                                for ($x = 0; $x < $this->image_dst_x; $x++) {

                                    for ($y = 0; $y < $this->image_dst_y; $y++) {

                                        if ($mask[$x][$y] > 0) {

                                            // we have some transparency. we combine the color with the default color

                                            $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));

                                            $alpha = ($mask[$x][$y] / 127);

                                            $pixel['red'] = round(($pixel['red'] * (1 - $alpha) + $red * ($alpha)));

                                            $pixel['green'] = round(($pixel['green'] * (1 - $alpha) + $green * ($alpha)));

                                            $pixel['blue'] = round(($pixel['blue'] * (1 - $alpha) + $blue * ($alpha)));

                                            $color = imagecolorallocate($image_dst, $pixel['red'], $pixel['green'], $pixel['blue']);

                                            imagesetpixel($image_dst, $x, $y, $color);
                                        }
                                    }
                                }

                                // transforms the true color image into palette, with its merged default color

                                if (empty($this->image_background_color)) {

                                    imagetruecolortopalette($image_dst, true, 255);

                                    $transparency = imagecolorallocate($image_dst, 254, 1, 253);

                                    imagecolortransparent($image_dst, $transparency);

                                    // make the transparent areas transparent

                                    for ($x = 0; $x < $this->image_dst_x; $x++) {

                                        for ($y = 0; $y < $this->image_dst_y; $y++) {

                                            // we test wether we have enough opacity to justify keeping the color

                                            if ($mask[$x][$y] > 120)
                                                imagesetpixel($image_dst, $x, $y, $transparency);
                                        }
                                    }
                                }

                                unset($mask);
                            }

                            break;

                        case 'jpg':

                        case 'bmp':

                            // if the image doesn't support any transparency, then we merge it with the default color

                            $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;fills in transparency with default color<br />';

                            list($red, $green, $blue) = $this->getcolors($this->image_default_color);

                            $transparency = imagecolorallocate($image_dst, $red, $green, $blue);

                            // make the transaparent areas transparent

                            for ($x = 0; $x < $this->image_dst_x; $x++) {

                                for ($y = 0; $y < $this->image_dst_y; $y++) {

                                    // we test wether we have some transparency, in which case we will merge the colors

                                    if (imageistruecolor($image_dst)) {

                                        $rgba = imagecolorat($image_dst, $x, $y);

                                        $pixel = array('red' => ($rgba >> 16) & 0xFF,
                                            'green' => ($rgba >> 8) & 0xFF,
                                            'blue' => $rgba & 0xFF,
                                            'alpha' => ($rgba & 0x7F000000) >> 24);
                                    } else {

                                        $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y));
                                    }

                                    if ($pixel['alpha'] == 127) {

                                        // we have full transparency. we make the pixel transparent

                                        imagesetpixel($image_dst, $x, $y, $transparency);
                                    } else if ($pixel['alpha'] > 0) {

                                        // we have some transparency. we combine the color with the default color

                                        $alpha = ($pixel['alpha'] / 127);

                                        $pixel['red'] = round(($pixel['red'] * (1 - $alpha) + $red * ($alpha)));

                                        $pixel['green'] = round(($pixel['green'] * (1 - $alpha) + $green * ($alpha)));

                                        $pixel['blue'] = round(($pixel['blue'] * (1 - $alpha) + $blue * ($alpha)));

                                        $color = imagecolorclosest($image_dst, $pixel['red'], $pixel['green'], $pixel['blue']);

                                        imagesetpixel($image_dst, $x, $y, $color);
                                    }
                                }
                            }



                            break;

                        default:

                            break;
                    }



                    // interlace options

                    if ($this->image_interlace)
                        imageinterlace($image_dst, true);



                    // outputs image

                    $this->log .= '- saving image...<br />';

                    switch ($this->image_convert) {

                        case 'jpeg':

                        case 'jpg':

                            if (!$return_mode) {

                                $result = @imagejpeg($image_dst, $this->file_dst_pathname, $this->jpeg_quality);
                            } else {

                                ob_start();

                                $result = @imagejpeg($image_dst, null, $this->jpeg_quality);

                                $return_content = ob_get_contents();

                                ob_end_clean();
                            }

                            if (!$result) {

                                $this->processed = false;

                                $this->error = $this->translate('file_create', array('JPEG'));
                            } else {

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;JPEG image created<br />';
                            }

                            break;

                        case 'png':

                            imagealphablending($image_dst, false);

                            imagesavealpha($image_dst, true);

                            if (!$return_mode) {

                                if (is_numeric($this->png_compression) && version_compare(PHP_VERSION, '5.1.2') >= 0) {

                                    $result = @imagepng($image_dst, $this->file_dst_pathname, $this->png_compression);
                                } else {

                                    $result = @imagepng($image_dst, $this->file_dst_pathname);
                                }
                            } else {

                                ob_start();

                                if (is_numeric($this->png_compression) && version_compare(PHP_VERSION, '5.1.2') >= 0) {

                                    $result = @imagepng($image_dst, null, $this->png_compression);
                                } else {

                                    $result = @imagepng($image_dst);
                                }

                                $return_content = ob_get_contents();

                                ob_end_clean();
                            }

                            if (!$result) {

                                $this->processed = false;

                                $this->error = $this->translate('file_create', array('PNG'));
                            } else {

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;PNG image created<br />';
                            }

                            break;

                        case 'gif':

                            if (!$return_mode) {

                                $result = @imagegif($image_dst, $this->file_dst_pathname);
                            } else {

                                ob_start();

                                $result = @imagegif($image_dst);

                                $return_content = ob_get_contents();

                                ob_end_clean();
                            }

                            if (!$result) {

                                $this->processed = false;

                                $this->error = $this->translate('file_create', array('GIF'));
                            } else {

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;GIF image created<br />';
                            }

                            break;

                        case 'bmp':

                            if (!$return_mode) {

                                $result = $this->imagebmp($image_dst, $this->file_dst_pathname);
                            } else {

                                ob_start();

                                $result = $this->imagebmp($image_dst);

                                $return_content = ob_get_contents();

                                ob_end_clean();
                            }

                            if (!$result) {

                                $this->processed = false;

                                $this->error = $this->translate('file_create', array('BMP'));
                            } else {

                                $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;BMP image created<br />';
                            }

                            break;



                        default:

                            $this->processed = false;

                            $this->error = $this->translate('no_conversion_type');
                    }

                    if ($this->processed) {

                        if (is_resource($image_src))
                            imagedestroy($image_src);

                        if (is_resource($image_dst))
                            imagedestroy($image_dst);

                        $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;image objects destroyed<br />';
                    }
                }
            } else {

                $this->log .= '- no image processing wanted<br />';



                if (!$return_mode) {

                    // copy the file to its final destination. we don't use move_uploaded_file here
                    // if we happen to have open_basedir restrictions, it is a temp file that we copy, not the original uploaded file

                    if (!copy($this->file_src_pathname, $this->file_dst_pathname)) {

                        $this->processed = false;

                        $this->error = $this->translate('copy_failed');
                    }
                } else {

                    // returns the file, so that its content can be received by the caller

                    $return_content = @file_get_contents($this->file_src_pathname);

                    if ($return_content === FALSE) {

                        $this->processed = false;

                        $this->error = $this->translate('reading_failed');
                    }
                }
            }
        }



        if ($this->processed) {

            $this->log .= '- <b>process OK</b><br />';
        } else {

            $this->log .= '- <b>error</b>: ' . $this->error . '<br />';
        }



        // we reinit all the vars

        $this->init();



        // we may return the image content

        if ($return_mode)
            return $return_content;
    }

    /**

     * Deletes the uploaded file from its temporary location

     *

     * When PHP uploads a file, it stores it in a temporary location.

     * When you {@link process} the file, you actually copy the resulting file to the given location, it doesn't alter the original file.

     * Once you have processed the file as many times as you wanted, you can delete the uploaded file.

     * If there is open_basedir restrictions, the uploaded file is in fact a temporary file

     *

     * You might want not to use this function if you work on local files, as it will delete the source file

     *

     * @access public

     */
    function clean() {

        $this->log .= '<b>cleanup</b><br />';

        $this->log .= '- delete temp file ' . $this->file_src_pathname . '<br />';

        @unlink($this->file_src_pathname);
    }

    /**

     * Opens a BMP image

     *

     * This function has been written by DHKold, and is used with permission of the author

     *

     * @access public

     */
    function imagecreatefrombmp($filename) {

        if (!$f1 = fopen($filename, "rb"))
            return false;



        $file = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1, 14));

        if ($file['file_type'] != 19778)
            return false;



        $bmp = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' .
                '/Vcompression/Vsize_bitmap/Vhoriz_resolution' .
                '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1, 40));

        $bmp['colors'] = pow(2, $bmp['bits_per_pixel']);

        if ($bmp['size_bitmap'] == 0)
            $bmp['size_bitmap'] = $file['file_size'] - $file['bitmap_offset'];

        $bmp['bytes_per_pixel'] = $bmp['bits_per_pixel'] / 8;

        $bmp['bytes_per_pixel2'] = ceil($bmp['bytes_per_pixel']);

        $bmp['decal'] = ($bmp['width'] * $bmp['bytes_per_pixel'] / 4);

        $bmp['decal'] -= floor($bmp['width'] * $bmp['bytes_per_pixel'] / 4);

        $bmp['decal'] = 4 - (4 * $bmp['decal']);

        if ($bmp['decal'] == 4)
            $bmp['decal'] = 0;



        $palette = array();

        if ($bmp['colors'] < 16777216) {

            $palette = unpack('V' . $bmp['colors'], fread($f1, $bmp['colors'] * 4));
        }



        $im = fread($f1, $bmp['size_bitmap']);

        $vide = chr(0);



        $res = imagecreatetruecolor($bmp['width'], $bmp['height']);

        $P = 0;

        $Y = $bmp['height'] - 1;

        while ($Y >= 0) {

            $X = 0;

            while ($X < $bmp['width']) {

                if ($bmp['bits_per_pixel'] == 24)
                    $color = unpack("V", substr($im, $P, 3) . $vide);

                elseif ($bmp['bits_per_pixel'] == 16) {

                    $color = unpack("n", substr($im, $P, 2));

                    $color[1] = $palette[$color[1] + 1];
                } elseif ($bmp['bits_per_pixel'] == 8) {

                    $color = unpack("n", $vide . substr($im, $P, 1));

                    $color[1] = $palette[$color[1] + 1];
                } elseif ($bmp['bits_per_pixel'] == 4) {

                    $color = unpack("n", $vide . substr($im, floor($P), 1));

                    if (($P * 2) % 2 == 0)
                        $color[1] = ($color[1] >> 4);
                    else
                        $color[1] = ($color[1] & 0x0F);

                    $color[1] = $palette[$color[1] + 1];
                } elseif ($bmp['bits_per_pixel'] == 1) {

                    $color = unpack("n", $vide . substr($im, floor($P), 1));

                    if (($P * 8) % 8 == 0)
                        $color[1] = $color[1] >> 7;

                    elseif (($P * 8) % 8 == 1)
                        $color[1] = ($color[1] & 0x40) >> 6;

                    elseif (($P * 8) % 8 == 2)
                        $color[1] = ($color[1] & 0x20) >> 5;

                    elseif (($P * 8) % 8 == 3)
                        $color[1] = ($color[1] & 0x10) >> 4;

                    elseif (($P * 8) % 8 == 4)
                        $color[1] = ($color[1] & 0x8) >> 3;

                    elseif (($P * 8) % 8 == 5)
                        $color[1] = ($color[1] & 0x4) >> 2;

                    elseif (($P * 8) % 8 == 6)
                        $color[1] = ($color[1] & 0x2) >> 1;

                    elseif (($P * 8) % 8 == 7)
                        $color[1] = ($color[1] & 0x1);

                    $color[1] = $palette[$color[1] + 1];
                } else
                    return FALSE;

                imagesetpixel($res, $X, $Y, $color[1]);

                $X++;

                $P += $bmp['bytes_per_pixel'];
            }

            $Y--;

            $P += $bmp['decal'];
        }

        fclose($f1);

        return $res;
    }

    /**

     * Saves a BMP image

     *

     * This function has been published on the PHP website, and can be used freely

     *

     * @access public

     */
    function imagebmp(&$im, $filename = "") {



        if (!$im)
            return false;

        $w = imagesx($im);

        $h = imagesy($im);

        $result = '';



        // if the image is not true color, we convert it first

        if (!imageistruecolor($im)) {

            $tmp = imagecreatetruecolor($w, $h);

            imagecopy($tmp, $im, 0, 0, 0, 0, $w, $h);

            imagedestroy($im);

            $im = & $tmp;
        }



        $biBPLine = $w * 3;

        $biStride = ($biBPLine + 3) & ~3;

        $biSizeImage = $biStride * $h;

        $bfOffBits = 54;

        $bfSize = $bfOffBits + $biSizeImage;



        $result .= substr('BM', 0, 2);

        $result .= pack('VvvV', $bfSize, 0, 0, $bfOffBits);

        $result .= pack('VVVvvVVVVVV', 40, $w, $h, 1, 24, 0, $biSizeImage, 0, 0, 0, 0);



        $numpad = $biStride - $biBPLine;

        for ($y = $h - 1; $y >= 0; --$y) {

            for ($x = 0; $x < $w; ++$x) {

                $col = imagecolorat($im, $x, $y);

                $result .= substr(pack('V', $col), 0, 3);
            }

            for ($i = 0; $i < $numpad; ++$i)
                $result .= pack('C', 0);
        }



        if ($filename == "") {

            echo $result;
        } else {

            $file = fopen($filename, "wb");

            fwrite($file, $result);

            fclose($file);
        }

        return true;
    }

}
Message.php000064400000001134150755024470006651 0ustar00<?php

/**

 * Description of Message

 *

 * @author official

 */
class Message {

    public $id;
    public $status;
    public $description;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`status`,`description` FROM `message` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->status = $result['status'];

            $this->description = $result['description'];



            return $result;
        }
    }

}
Activities.php000064400000007412150755024470007376 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of activities

 *

 * @author Suharshana DsW

 */
class Activities {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`queue` FROM `activities` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `activities` (`title`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `activities` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `activities` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $this->deletePhotos();



        unlink(Helper::getSitePath() . "upload/activity/" . $this->image_name);



        $query = 'DELETE FROM `activities` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $ACTIVITY_PHOTO = new ActivitiesPhoto(NULL);



        $allPhotos = $ACTIVITY_PHOTO->getActivitiesPhotosById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $ACTIVITY_PHOTO->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/activity/gallery/" . $IMG);

            unlink(Helper::getSitePath() . "upload/activity/gallery/thumb/" . $IMG);



            $ACTIVITY_PHOTO->id = $photo["id"];

            $ACTIVITY_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `activities` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Helper.php000064400000001405150755024470006505 0ustar00<?php

class Helper {

    public function randamId() {



        $today = time();

        $startDate = date('YmdHi', strtotime('1912-03-14 09:06:00'));

        $range = $today - $startDate;

        $rand = rand(0, $range);

        $randam = $rand . "_" . ($startDate + $rand) . '_' . $today . "_n";

        return $randam;
    }

    public function calImgResize($newHeight, $width, $height) {



        $percent = $newHeight / $height;

        $result1 = $percent * 100;



        $result2 = $width * $result1 / 100;



        return array($result2, $newHeight);
    }

    public function getSitePath() {

//        return substr_replace(dirname(__FILE__), '', 26);

        $path = str_replace('class', '', dirname(__FILE__));

        return $path;
    }

}
PhotoAlbum.php000064400000007030150755024470007340 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PhotoAlbum
 *
 * @author Suharshana DsW
 */
class PhotoAlbum {

    public $id;
    public $title;
    public $image_name;
    public $description;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`description`,`queue` FROM `photo_album` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `photo_album` (`title`,`image_name`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->description . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `photo_album`  ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `photo_album` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $this->deletePhotos();

        unlink(Helper::getSitePath() . "upload/photo-album/" . $this->image_name);

        $query = 'DELETE FROM `photo_album` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deletePhotos() {

        $ALBUM_PHOTOS = new AlbumPhoto(NULL);

        $allPhotos = $ALBUM_PHOTOS->getAlbumPhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $ALBUM_PHOTOS->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/photo-album/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/photo-album/gallery/thumb/" . $IMG);

            $ALBUM_PHOTOS->id = $photo["id"];
            $ALBUM_PHOTOS->delete();
        }
    }

    public function arrange($key, $img) {
        $query = "UPDATE `photo_album` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Database.php000064400000003170150755024470006773 0ustar00<?php

/**

 * Description of User

 *

 * @author sublime holdings

 * @web www.sublime.lk

 * */
class Database {


    private $host = 'localhost';
    private $name = 'islapiiu_taxigalle';
    private $user = 'islapiiu_main';
    private $password = 'Ue.t;FNgC?BG,Paf8V';


// private $host = 'localhost';
// private $name = 'synoteca_hbs_taxi';
// private $user = 'synoteca_main';
// private $password = '3rTI#)-vDmAKczXQ-J';

    public function __construct() {

        mysql_connect($this->host, $this->user, $this->password) or die("Invalid host  or user details");

        mysql_select_db($this->name) or die("Unable to select database");
    }

    public function readQuery($query) {



        $result = mysql_query($query) or die(mysql_error());

        return $result;



//        $qu1 = explode(" ", $query)[0];
//
//        if ($qu1 === 'SELECT' || $qu1 === 'select') {
//            $result = mysql_query($query) or die(mysql_error());
//            return $result;
//        } else {
//            if (!isset($_SESSION)) {
//                session_start();
//            }
//
//            if (
//                    $_SESSION["LOGIN"] === true &&
//                    parse_url($_SERVER['HTTP_REFERER'])["host"] == $this->domain &&
//                    $_SESSION['TOKEN'] == 'Vr-EFV!Fn6qCCUHYF2&cFzLw_thehorizonvilla-H5Dx'
//            ) {
//
//                $result = mysql_query($query) or die(mysql_error());
//                return $result;
//            } else {
//                sendSecurityAlert($this->domain);
//            }
//        }
    }

}
TourPackagePhotosNormal.php000064400000006456150755024470012054 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of TourPackagePhotosNormal

 *

 * @author HP

 */
class TourPackagePhotosNormal {

    public $id;
    public $tourpackage;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`tourpackage`,`image_name`,`caption`,`queue` FROM `tour_photo_normal` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->tourpackage = $result['tourpackage'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `tour_photo_normal` (`tourpackage`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->tourpackage . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `tour_photo_normal` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `tour_photo_normal` SET "
                . "`tourpackage` ='" . $this->tourpackage . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `tour_photo_normal` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getTourPhotosById($tour) {



        $query = "SELECT * FROM `tour_photo_normal` WHERE `tourpackage`= $tour ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `tour_photo_normal` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
TourPackage.php000064400000012532150755024470007476 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Tour_package

 *

 * @author Suharshana DsW

 */
class TourPackage {

    public $id;
    public $title;
    public $dates;
    public $image_name;
    public $price;
    public $short_description;
    public $description;
    public $queue;
    public $map;

    public function __construct($id) {

        if ($id) {

            $query = "SELECT *  FROM `tour_package` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->dates = $result['dates'];
            $this->image_name = $result['image_name'];
            $this->price = $result['price'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];
            $this->map = $result['map'];

            return $this;
        }
    }

    public function create() {
       
        $query = "INSERT INTO `tour_package` (`title`,`tour_type`,`dates`,`image_name`,`price`,`short_description`,`description`,`map`,`queue`) VALUES  ('"
                . $this->title . "', '"
                . $this->tour_type . "', '"
                . $this->dates . "', '"
                . $this->image_name . "', '"
                . $this->price . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->map . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `tour_package` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function allToursByType($type) {

        $query = "SELECT * FROM `tour_package` WHERE `tour_type`= $type ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `tour_package` SET "
                . "`title` ='" . $this->title . "', "
                . "`dates` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`price` ='" . $this->price . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);
        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {
        $this->deleteTourDates();
        unlink(Helper::getSitePath() . "upload/tour-package/" . $this->image_name);
        $query = 'DELETE FROM `tour_package` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deleteTourDates() {

        $TOUR_DATE = new TourDate(NULL);
        $alldates = $TOUR_DATE->getTourDatesById($this->id);

        foreach ($alldates as $date) {

            $IMG = $TOUR_DATE->image_name = $date["image_name"];
            unlink(Helper::getSitePath() . "upload/tour-package/date/" . $IMG);
            unlink(Helper::getSitePath() . "upload/tour-package/date/thumb/" . $IMG);

            $TOUR_DATE->id = $date["id"];

            $TOUR_DATE->delete();
        }
    }

    public function deleteNormal() {

        $this->deleteNormalPhotos();
        unlink(Helper::getSitePath() . "upload/tour-package/" . $this->image_name);
        $query = 'DELETE FROM `tour_package` WHERE id="' . $this->id . '"';
        $db = new Database();

        return $db->readQuery($query);
    }

    public function deleteNormalPhotos() {

        $TOUR_PACKAGE_PHOTO = new TourPackagePhotosNormal(NULL);

        $allPhotos = $TOUR_PACKAGE_PHOTO->getTourPhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $TOUR_PACKAGE_PHOTO->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/tour-package/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/tour-package/gallery/thumb/" . $IMG);

            $TOUR_PACKAGE_PHOTO->id = $photo["id"];

            $TOUR_PACKAGE_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `tour_package` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
OfferPhoto.php000064400000006303150755024470007343 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of OfferPhoto

 *

 * @author Suharshana DsW

 */
class OfferPhoto {

    public $id;
    public $offer;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`offer`,`image_name`,`caption`,`queue` FROM `offer_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->offer = $result['offer'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `offer_photo` (`offer`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->offer . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `offer_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `offer_photo` SET "
                . "`offer` ='" . $this->offer . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `offer_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getOfferPhotosById($offer) {



        $query = "SELECT * FROM `offer_photo` WHERE `offer`= $offer ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `offer_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Attraction.php000064400000007435150755024470007407 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Attractions

 *

 * @author Suharshana DsW

 */
class Attraction {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,   `queue` FROM `attraction` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `attraction` (`title`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `attraction` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `attraction` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $this->deletePhotos();



       unlink(Helper::getSitePath() . "upload/attraction/" . $this->image_name);



        $query = 'DELETE FROM `attraction` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $ATTRACTION_PHOTO = new AttractionPhoto(NULL);



        $allPhotos = $ATTRACTION_PHOTO->getAttractionPhotosById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $ATTRACTION_PHOTO->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/attraction/gallery/" . $IMG);

            unlink(Helper::getSitePath() . "upload/attraction/gallery/thumb/" . $IMG);



            $ATTRACTION_PHOTO->id = $photo["id"];

            $ATTRACTION_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `attraction` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
ProductType.php000064400000007206150755024470007555 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of ProductType

 *

 * @author Nipuni

 */
class ProductType {

    public $id;
    public $name;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`name`,`image_name`,`short_description`,`description`,`queue` FROM `product_type` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->name = $result['name'];

            $this->image_name = $result['image_name'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `product_type` (`name`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->name . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `product_type` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `product_type` SET "
                . "`name` ='" . $this->name . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {





        $this->deletePhotos();



        unlink(Helper::getSitePath() . "upload/product-type/" . $this->image_name);



        $query = 'DELETE FROM `product_type` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $PRODUCT = new Product(NULL);



        $allPhotos = $PRODUCT->getProductsById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $PRODUCT->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/product-type/product/" . $IMG);



            $PRODUCT->id = $photo["id"];

            $PRODUCT->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `product_type` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
AttractionPhoto.php000064400000006435150755024470010420 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Attraction_photo

 *

 * @author Suharshana DsW

 */
class AttractionPhoto {

    public $id;
    public $attraction;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`attraction`,`image_name`,`caption`,`queue` FROM `attraction_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->attraction = $result['attraction'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `attraction_photo` (`attraction`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->attraction . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `attraction_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `attraction_photo` SET "
                . "`attraction` ='" . $this->attraction . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `attraction_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getAttractionPhotosById($id) {



        $query = "SELECT * FROM `attraction_photo` WHERE `attraction`= $id ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `attraction_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Comments.php000064400000007623150755024470007063 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Comments

 *

 * @author Suharshana DsW

 */
class Comments {

    public $id;
    public $name;
    public $title;
    public $country;
    public $image_name;
    public $comment;
    public $is_active;
    public $queue;

    public function __construct($id) {

        if ($id) {

            $query = "SELECT * FROM `comments` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->title = $result['title'];
            $this->country = $result['country'];
            $this->image_name = $result['image_name'];
            $this->comment = $result['comment'];
            $this->is_active = $result['is_active'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `comments` (`name`,`title`,`country`,`image_name`,`comment`,`is_active`,`queue`) VALUES  ('"
                . $this->name . "','"
                . $this->title . "','"
                . $this->country . "','"
                . $this->image_name . "', '"
                . $this->comment . "', '"
                . $this->is_active . "', '"
                . $this->queue . "')";

        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `comments` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `comments` SET "
                . "`name` ='" . $this->name . "', "
                . "`title` ='" . $this->title . "', "
                . "`country` ='" . $this->country . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`comment` ='" . $this->comment . "', "
                . "`is_active` ='" . $this->is_active . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";


        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `comments` WHERE id="' . $this->id . '"';
        $db = new Database();

        return $db->readQuery($query);
    }

    public function activeComments() {

        $query = "SELECT * FROM `comments` WHERE is_active = '1'";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function pendingComments() {

        $query = "SELECT * FROM `comments` WHERE is_active = '0'";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `comments` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
ActivitiesPhoto.php000064400000006455150755024470010416 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Activities_photo

 *

 * @author Suharshana DsW

 */
class ActivitiesPhoto {

    public $id;
    public $activities;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`activities`,`image_name`,`caption`,`queue` FROM `activities_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->activities = $result['activities'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `activities_photo` (`activities`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->activities . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `activities_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `activities_photo` SET "
                . "`activities` ='" . $this->activities . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `activities_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getActivitiesPhotosById($activities) {



        $query = "SELECT * FROM `activities_photo` WHERE `activities`= $activities ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `activities_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
AlbumPhoto.php000064400000006366150755024470007353 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AlbumPhoto
 *
 * @author Suharshana DsW
 */
class AlbumPhoto {

    public $id;
    public $album;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`album`,`image_name`,`caption`,`queue` FROM `album_photo` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->album = $result['album'];
            $this->image_name = $result['image_name'];
            $this->caption = $result['caption'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `album_photo` (`album`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->album . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `album_photo` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `album_photo` SET "
                . "`album` ='" . $this->album . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `album_photo` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getAlbumPhotosById($album) {

        $query = "SELECT * FROM `album_photo` WHERE `album`= $album ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `album_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Facilities.php000064400000007267150765320710007353 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of facilities
 *
 * @author Suharshana DsW
 */
class Facilities {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`queue` FROM `facilities` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `facilities` (`title`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `facilities` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `facilities` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $this->deletePhotos();

        unlink(Helper::getSitePath() . "upload/facilities/" . $this->image_name);

        $query = 'DELETE FROM `facilities` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deletePhotos() {

        $SERVICE_PHOTO = new FacilitiesPhoto(NULL);

        $allPhotos = $SERVICE_PHOTO->getFacilitiesPhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $SERVICE_PHOTO->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/facilities/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/facilities/gallery/thumb/" . $IMG);

            $SERVICE_PHOTO->id = $photo["id"];
            $SERVICE_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {
        $query = "UPDATE `facilities` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}ThingsToDoPhoto.php000064400000006404150765320710010323 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ThingsToDo_photo
 *
 * @author Suharshana DsW
 */
class ThingsToDoPhoto {

    public $id;
    public $things_to_do;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`things_to_do`,`image_name`,`caption`,`queue` FROM `things_to_do_photo` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->things_to_do = $result['things_to_do'];
            $this->image_name = $result['image_name'];
            $this->caption = $result['caption'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `things_to_do_photo` (`things_to_do`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->things_to_do . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `things_to_do_photo` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `things_to_do_photo` SET "
                . "`things_to_do` ='" . $this->things_to_do . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `things-to-do_photo` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getThingsToDoPhotosById($things_to_do) {

        $query = "SELECT * FROM `things_to_do_photo` WHERE `things_to_do`= $things_to_do ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `things_to_do_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}RoomFeatures.php000064400000002611150765320710007676 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Room Features
 *
 * @author Suharshana DsW
 */
class RoomFeatures {

    public $id;
    public $title;
    public $icon;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`icon`,`queue` FROM `room_features` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->icon = $result['icon'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function all() {

        $query = "SELECT * FROM `room_features` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `room_features` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}ThingsToDo.php000064400000007052150765320710007311 0ustar00<?php

/**
 * Description of things-to-do
 *
 * @author Suharshana DsW
 */
class ThingsToDo {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`queue` FROM `things_to_do` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `things_to_do` (`title`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `things_to_do` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `things_to_do` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $this->deletePhotos();

        unlink(Helper::getSitePath() . "upload/things-to-do/" . $this->image_name);

        $query = 'DELETE FROM `things_to_do` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deletePhotos() {

        $THINGS_TO_DO_PHOTO = new ThingsToDoPhoto(NULL);

        $allPhotos = $THINGS_TO_DO_PHOTO->getThingsToDoPhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $THINGS_TO_DO_PHOTO->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/things-to-do/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/things-to-do/gallery/thumb/" . $IMG);

            $THINGS_TO_DO_PHOTO->id = $photo["id"];
            $THINGS_TO_DO_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {
        $query = "UPDATE `things_to_do` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}ProductPhotos.php000064400000007425150765646200010115 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Product
 *
 * @author Nipuni
 */
class ProductPhotos {

    public $id;
    public $product_id;
    public $name;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`product_id`,`name`,`image_name`,`short_description`,`description`,`queue` FROM `product_photos` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->product_id = $result['product_id'];
            $this->name = $result['name'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `product_photos` (`product_id`,`name`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->product_id . "','"
                . $this->name . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `product_photos` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `product_photos` SET "
                . "`product_id` ='" . $this->product_id . "', "
                . "`name` ='" . $this->name . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {


        $query = 'DELETE FROM `product_photos` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getProductsPhotosById($product) {

        $query = "SELECT * FROM `product_photos` WHERE `product_id`= $product  ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `product_photos` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
ProductPhoto.php000064400000006666150766067670007751 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Room_photo

 *

 * @author Suharshana DsW

 */
class ProductPhoto {

    public $id;
    public $product;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`product`,`image_name`,`caption`,`queue` FROM `product_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->product = $result['product'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `product_photo` (`product`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->product . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `product_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `product_photo` SET "
                . "`product` ='" . $this->product . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `product_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getProductPhotosById($product) {



        $query = "SELECT * FROM `product_photo` WHERE `product`= $product ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `product_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
TourType.php000064400000006534150766067670007104 0ustar00<?php

/**
 * Description of TourTypes
 *
 * @author U s E r ¨
 */
class TourType {

    public $id;
    public $name;
    public $short_description;
    public $description;
    public $image_name;
    public $sort;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT * FROM `tour_type` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->short_description= $result['short_description'];
            $this->description= $result['description'];
            $this->image_name = $result['image_name'];
            $this->sort = $result['sort'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `tour_type` (`name`,`short_description`,`image_name`,`description`,`sort`) VALUES  ('"
                . $this->name . "', '"
                . $this->short_description . "', '"
                . $this->image_name . "', '"
                . $this->description . "', '"
                . $this->sort . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `tour_type` ORDER BY sort ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `tour_type` SET "
                . "`name` ='" . $this->name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`description` ='" . $this->description . "', "
                . "`sort` ='" . $this->sort . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        unlink(Helper::getSitePath() . "upload/tour_type/" . $this->image_name);
      
        $query = 'DELETE FROM `tour_type` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function GetTourTypeById($id) {

        $query = "SELECT * FROM `tour_type` WHERE `id` = '" . $id . "' ORDER BY `sort` ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `tour_type` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Ingredients.php000064400000006644150766067670007566 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Room_photo

 *

 * @author Suharshana DsW

 */
class Ingredients {

    public $id;
    public $product;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`product`,`image_name`,`caption`,`queue` FROM `ingredients` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->product = $result['product'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `ingredients` (`product`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->product . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";

      

        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `ingredients` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `ingredients` SET "
                . "`product` ='" . $this->product . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `ingredients` WHERE id="' . $this->id . '"';

        $db = new Database();
        return $db->readQuery($query);
    }

    public function getIngredientsByProductId($product) {



        $query = "SELECT * FROM `ingredients` WHERE `product`= $product ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `ingredients` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Booking.php000064400000007106150766067670006675 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of dealer

 *

 * @author imasha

 */
class Booking {

    public $id;
    public $vehicle;
    public $start_destination;
    public $end_destination;
    public $phone;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT * FROM `booking` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->vehicle = $result['vehicle'];

            $this->start_destination = $result['start_destination'];

            $this->end_destination = $result['end_destination'];

            $this->phone = $result['phone'];





            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `booking` (`vehicle`,`start_destination`,`end_destination`,`phone`) VALUES  ('"
                . $this->vehicle . "','"
                . $this->start_destination . "', '"
                . $this->end_destination . "', '"
                . $this->phone . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `booking` ";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `booking` SET "
                . "`vehicle` ='" . $this->vehicle . "', "
                . "`start_destination` ='" . $this->start_destination . "', "
                . "`end_destination` ='" . $this->end_destination . "', "
                . "`phone` ='" . $this->phone . "', "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



//        $this->deletePhotos();
//        unlink(Helper::getSitePath() . "upload/jobsearch/" . $this->image_name);



        $query = 'DELETE FROM `booking` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

//    public function deletePhotos() {
//
//
//
//        $ACTIVITY_PHOTO = new ActivitiesPhoto(NULL);
//
//
//
//        $allPhotos = $ACTIVITY_PHOTO->getActivitiesPhotosById($this->id);
//
//
//
//        foreach ($allPhotos as $photo) {
//
//
//
//            $IMG = $ACTIVITY_PHOTO->image_name = $photo["image_name"];
//
//            unlink(Helper::getSitePath() . "upload/activity/gallery/" . $IMG);
//
//            unlink(Helper::getSitePath() . "upload/activity/gallery/thumb/" . $IMG);
//
//
//
//            $ACTIVITY_PHOTO->id = $photo["id"];
//
//            $ACTIVITY_PHOTO->delete();
//        }
//    }
//    public function arrange($key, $img) {
//
//        $query = "UPDATE `jobsearch` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
//
//        $db = new Database();
//
//        $result = $db->readQuery($query);
//
//        return $result;
//    }
}
Portfolio.php000064400000007342150766067670007264 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Room
 *
 * @author Suharshana DsW
 */
class Portfolio {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $price;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`price`,`queue` FROM `portfolio` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->price = $result['price'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `portfolio` (`title`,`image_name`,`short_description`,`description`,`price`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->price . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `portfolio` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `portfolio` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`price` ='" . $this->price . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

  public function delete() {


        $query = 'DELETE FROM `portfolio` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }
    
     public function getPortfolioById($portfolio) {

        $query = 'SELECT * FROM `portfolio` WHERE type="' . $portfolio . '"   ORDER BY queue ASC';

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    
    
    public function arrange($key, $img) {
        $query = "UPDATE `portfolio` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
PortfolioPhoto.php000064400000006423150766067670010275 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Room_photo

 *

 * @author Suharshana DsW

 */
class PortfolioPhoto {

    public $id;
    public $portfolio;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`portfolio`,`image_name`,`caption`,`queue` FROM `portfolio_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->portfolio = $result['portfolio'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `portfolio_photo` (`portfolio`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->portfolio . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `portfolio_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `portfolio_photo` SET "
                . "`portfolio` ='" . $this->portfolio . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `portfolio_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getPortfolioPhotosById($portfolio) {



        $query = "SELECT * FROM `portfolio_photo` WHERE `portfolio`= $portfolio ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `portfolio_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
ProductCategories.php000064400000007263150766203050010717 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Product
 *
 * @author Nipuni
 */
class ProductCategories {

    public $id;
    public $name;
    public $icon;
    public $banner;
    public $sort;
    public $title;
    public $price;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT * FROM `product_categories` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->icon = $result['icon'];
            $this->title = $result['title'];
            $this->price = $result['price'];
            $this->banner = $result['banner'];
            $this->sort = $result['sort'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `product_categories` (`name`,`icon`,`title`,`price`,`banner`,`sort`) VALUES  ('"
                . $this->name . "', '"
                . $this->icon . "', '"
                . $this->title . "', '"
                . $this->price . "', '"
                . $this->banner . "', '"
                . $this->sort . "')";


        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `product_categories` ORDER BY sort ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `product_categories` SET "
                . "`name` ='" . $this->name . "', "
                . "`icon` ='" . $this->icon . "', "
                . "`title` ='" . $this->title . "', "
                . "`price` ='" . $this->price . "', "
                . "`banner` ='" . $this->banner . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        unlink(Helper::getSitePath() . "upload/product-categories/icon/" . $this->icon);
        unlink(Helper::getSitePath() . "upload/product-categories/banner/" . $this->banner);
        $query = 'DELETE FROM `product_categories` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getProductsById($product_categories) {

        $query = 'SELECT * FROM `product_categories` WHERE type="' . $product_categories . '"   ORDER BY queue ASC';

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `product_categories` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Package.php000064400000006775150766203050006633 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Attractions

 *

 * @author Suharshana DsW

 */
class Package {

    public $id;
    public $category;
    public $sub_category;
    public $name;
    public $description;
    public $image_name;
    public $discount;
    public $product_list;
    public $price;
    public $sort;

    public function __construct($id) {

        if ($id) {

            $query = "SELECT * FROM `package` WHERE `id`=" . $id;
            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->category = $result['category'];
            $this->sub_category = $result['sub_category'];
            $this->name = $result['name'];
            $this->description = $result['description'];
            $this->image_name = $result['image_name'];
            $this->discount = $result['discount'];
            $this->product_list = $result['product_list'];
            $this->price = $result['price'];
            $this->sort = $result['sort'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `package` (`category`,`sub_category`,`name`,`description`,`image_name`,`discount`,`product_list`,`price`,`sort`) VALUES  ('"
                . $this->category . "','"
                . $this->sub_category . "', '"
                . $this->name . "', '"
                . $this->description . "', '"
                . $this->image_name . "', '"
                . $this->discount . "', '"
                . $this->product_list . "', '"
                . $this->price . "', '"
                . $this->sort . "')";

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `package` ORDER BY sort ASC";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
            }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `package` SET "
                . "`category` ='" . $this->category . "', "
                . "`sub_category` ='" . $this->sub_category . "', "
                . "`name` ='" . $this->name . "', "
                . "`price` ='" . $this->price . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`discount` ='" . $this->discount . "', "
                . "`product_list` ='" . $this->product_list . "', "
                . "`description` ='" . $this->description . "', "
                . "`sort` ='" . $this->sort . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {

        unlink(Helper::getSitePath() . "upload/package/" . $this->image_name);

        $query = 'DELETE FROM `package` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }


}
ProductReview.php000064400000007045150766203050010071 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of ProductReview

 *

 * @author Suharshana DsW

 */
class ProductReview {

    public $id;
    public $product;
    public $stars;
    public $title;
    public $description;
    public $customer;
    public $date_time;
    public $is_active;

    public function __construct($id) {

        if ($id) {
            $query = "SELECT  * FROM `product_review` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->product = $result['product'];
            $this->stars = $result['stars'];
            $this->title = $result['title'];
            $this->description = $result['description'];
            $this->customer = $result['customer'];
            $this->date_time = $result['date_time'];
            $this->is_active = $result['is_active'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `product_review` (`product`,`stars`,`title`,`description`,`customer`,`date_time`) VALUES  ('"
                . $this->product . "','"
                . $this->stars . "','"
                . $this->title . "','"
                . $this->description . "', '"
                . $this->customer . "', '"
                . $this->date_time . "')";

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `product_review` ORDER BY date_time ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `product_review` SET "
                . "`product` ='" . $this->product . "', "
                . "`title` ='" . $this->title . "', "
                . "`stars` ='" . $this->stars . "', "
                . "`description` ='" . $this->description . "', "
                . "`is_active` ='" . $this->is_active . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `product_review` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getReviwsByProduct($product) {

        $query = "SELECT * FROM `product_review` WHERE `product`= $product && `is_active` = 1 ORDER BY stars DESC";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `product_review` SET `date_time` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}
Dealer.php000064400000022301150766203050006453 0ustar00<?php

/**
 * Description of Product
 *
 * @author synotec holdings
 * @web www.synotec.lk
 */
class Dealer {

    public $id;
    public $name;
    public $phone;
    public $email;
    public $nic;
    public $address;
    public $district;
    public $city;
    public $picture;
    public $nic_fr_photo;
    public $nic_bk_photo;
    private $password;
    private $authToken; 
    public $resetcode;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT  * FROM `dealer` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->phone = $result['phone'];
            $this->email = $result['email'];
            $this->nic = $result['nic'];
            $this->address = $result['address'];
            $this->city = $result['city'];
            $this->district = $result['district'];
            $this->picture = $result['picture'];
            $this->nic_fr_photo = $result['nic_fr_photo'];
            $this->nic_bk_photo = $result['nic_bk_photo'];
            $this->password = null;
            $this->authToken = $result['authToken'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `dealer` ("
                . "`name`, "
                . "`phone`, "
                . "`email`,"
                . "`nic`,"
                . "`address`,"
                . "`district`,"
                . "`city`,"
                . "`picture`,"
                . "`nic_fr_photo`,"
                . "`nic_bk_photo`"
                . ") VALUES  ('"
                . $this->name . "','"
                . $this->phone . "', '"
                . $this->email . "', '"
                . $this->nic . "', '"
                . $this->address . "', '"
                . $this->district . "', '"
                . $this->city . "', '"
                . $this->picture . "', '"
                . $this->nic_fr_photo . "', '"
                . $this->nic_bk_photo . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `dealer` ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function login($email, $password) {


        $query = "SELECT  * FROM `dealer` WHERE `email`= '" . $email . "' AND `password`= '" . $password . "'";
        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {

            return FALSE;
        } else {

            $this->id = $result['id'];
            $this->setAuthToken($result['id']);
            $this->setUserSession($this->id);
            $dealer = $this->__construct($this->id);
            return $dealer;
        }
    }

    public function logOut() {

        if (!isset($_SESSION)) {
            session_start();
        }

        unset($_SESSION["id"]);
        unset($_SESSION["name"]);
        unset($_SESSION["email"]);

        return TRUE;
    }

    private function setUserSession($dealer) {

        if (!isset($_SESSION)) {
            session_start();
        }
        $dealer = $this->__construct($dealer);

        $_SESSION["id"] = $dealer->id;
        $_SESSION["name"] = $dealer->name;
        $_SESSION["email"] = $dealer->email;
        $_SESSION["phone"] = $dealer->phone;
        $_SESSION["authToken"] = $dealer->authToken;
        $_SESSION["picture"] = $dealer->picture;
    }

    private function setAuthToken($id) {

        $authToken = md5(uniqid(rand(), true));

        $query = "UPDATE `dealer` SET `authToken` ='" . $authToken . "' WHERE `id`='" . $id . "'";

        $db = new Database();

        if ($db->readQuery($query)) {
            return $authToken;
        } else {

            return FALSE;
        }
    }

    public function authenticate() {

        if (!isset($_SESSION)) {

            session_start();
        }

        $id = NULL;
        $authToken = NULL;

        if (isset($_SESSION["id"])) {
            $id = $_SESSION["id"];
        }

        if (isset($_SESSION["authToken"])) {
            $authToken = $_SESSION["authToken"];
        }

        $query = "SELECT `id` FROM `dealer` WHERE `id`= '" . $id . "' AND `authToken`= '" . $authToken . "'";

        $db = new Database();
        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {

            return FALSE;
        } else {
            return TRUE;
        }
    }

    public function checkEmail($email) {

        $query = "SELECT `email`,`name` FROM `dealer` WHERE `email`= '" . $email . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {

            return FALSE;
        } else {

            return $result;
        }
    }

    public function genarateCode($email) {

        $rand = rand(10000, 99999);

        $query = "UPDATE  `dealer` SET "
                . "`resetcode` ='" . $rand . "' "
                . "WHERE `email` = '" . $email . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    public function selectForgetDealer($email) {

        if ($email) {

            $query = "SELECT `email`,`name`,`resetcode` FROM `dealer` WHERE `email`= '" . $email . "'";

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->name = $result['name'];
            $this->email = $result['email'];
            $this->restCode = $result['resetcode'];

            return $result;
        }
    }

    public function selectResetCode($code) {

        $query = "SELECT `id` FROM `dealer` WHERE `resetcode`= '" . $code . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));
        if (!$result) {

            return FALSE;
        } else {
            return TRUE;
        }
    }

    public function updatePassword($password, $code) {
        $enPass = md5($password);

        $query = "UPDATE  `dealer` SET "
                . "`password` ='" . $enPass . "' "
                . "WHERE `resetcode` = '" . $code . "'";

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {

            return TRUE;
        } else {

            return FALSE;
        }
    }

    public function update() {

        $query = "UPDATE  `resetcode` SET "
                . "`name` ='" . $this->name . "', "
                . "`email` ='" . $this->email . "', "
                . "`password` ='" . $this->password . "', "
                . "`phone` ='" . $this->phone . "', "
                . "`district` ='" . $this->district . "', "
                . "`city` ='" . $this->city . "', "
                . "`address` ='" . $this->address . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `dealer` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function GetCitiesByDistrict($district) {

        $query = "SELECT * FROM `dealer` WHERE `district` = '" . $district . "'";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function getDistrictByCityId($dealer) {

        $query = "SELECT * FROM `dealer` WHERE `id` = '" . $dealer . "'";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function deleteCitiesByDistrict($district) {

        $query = "DELETE FROM `dealer` WHERE `district`= '" . $district . "'";

        $db = new Database();
        $result = $db->readQuery($query);

        return $result;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `dealer` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
District.php000064400000005056150766203050007054 0ustar00<?php

/**
 * Description of Product
 *
 * @author sublime holdings
 * @web www.sublime.lk
 */
class District {

    public $id;
    public $name;
    public $sort = 100;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`name`,`sort` FROM `district` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->sort = $result['sort'];

            return $this;
        }
    }
    public function getDistrictByName($name) {

            $query = "SELECT `id` FROM `district` WHERE `name` LIKE '" . $name . "'";
            $db = new Database();
            $result = mysql_fetch_array($db->readQuery($query));
            return $result;
    }

    public function create() {

        $query = "INSERT INTO `district` (`name`, `sort`) VALUES  ('" . $this->name . "', '" . $this->sort . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `district` ORDER BY `name` ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = 'UPDATE `district` SET `name`= "' . $this->name . '" WHERE id="' . $this->id . '"';

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function arrange($key, $img) {
        $query = "UPDATE `district` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

    public function delete() {

        $CITY = new City(NULL);

        $result = $CITY->deleteCitiesByDistrict($this->id);

        if ($result) {
            $query = 'DELETE FROM `district` WHERE id="' . $this->id . '"';
        }

        $db = new Database();

        return $db->readQuery($query);
//        dd($query);
    }

}AddToCart.php000064400000004533150766203060007074 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of add_to_product

 *

 * @author Suharshana DsW

 */
class AddToCart {

    public $id;
    public $product;
    public $customer;
    public $status;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT * FROM `add_to_cart` WHERE `id`=" . $id;
            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->product = $result['product'];
            $this->customer = $result['customer'];
            $this->status = $result['status'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `add_to_cart` (`product`,`customer`,`status`) VALUES  ('"
                . $this->product . "','"
                . $this->customer . "','"
                . $this->status . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `add_to_cart`  ";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function getProductById($id) {

        $query = "SELECT * FROM `add_to_cart` WHERE `id` = ' $id  '";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `add_to_cart` SET "
                . "`status` ='" . $this->status . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

}
test.php000064400000027646150766203060006260 0ustar00
application/x-httpd-php Visitor.php ( PHP script text )

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Visitor
 *
 * @author User
 */
class Visitor {

    public $id;
    public $name;
    public $email;
    public $address;
    public $contact_number;
    public $profile_picture;
    public $createdAt;
    public $isActive;
    public $facebookID;
    public $authToken;
    public $lastLogin;
    public $resetCode;
    public $password;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`name`,`email`,`address`,`contact_number`,`profile_picture`,`createdAt`,`isActive`,`facebookID`,`authToken`,`lastLogin`,`resetCode` FROM `visitor` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->email = $result['email'];
            $this->address = $result['address'];
            $this->contact_number = $result['contact_number'];
            $this->profile_picture = $result['profile_picture'];
            $this->createdAt = $result['createdAt'];
            $this->isActive = $result['isActive'];
            $this->facebookID = $result['facebookID'];
            $this->lastLogin = $result['lastLogin'];
            $this->authToken = $result['authToken'];
            $this->resetCode = $result['resetCode'];

            return $result;
        }
    }

    public function create() {

        date_default_timezone_set('Asia/Colombo');

        $createdAt = date('Y-m-d H:i:s');

        $query = "INSERT INTO `visitor` (`createdAt`,`name`,`email`,`password`) VALUES  ('"
                . $createdAt . "', '"
                . $this->name . "', '"
                . $this->email . "', '"
                . $this->password . "')";

        $db = new Database();

        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }
    
    public function all() {

        $query = "SELECT * FROM `visitor` ORDER BY id ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    
    public function delete() {
        
        unlink(Helper::getSitePath() . "upload/visitor/" . $this->profile_picture);

        $query = 'DELETE FROM `visitor` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function login($email, $password) {

        
        $query = "SELECT `id`,`name`,`email`,`address`,`contact_number`,`profile_picture`,`createdAt`,`isActive`,`lastLogin` FROM `visitor` WHERE `email`= '" . $email . "' AND `password`= '" . $password . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));


        if (!$result) {
            return FALSE;
        } else {
            $this->id = $result['id'];
            $this->setAuthToken($result['id']);
//            $this->setLastLogin($this->id);

            $visitor = $this->__construct($this->id);
            
            $this->setUserSession($visitor);

            return $visitor;
        }
    }

    public function checkOldPass($id, $password) {

        $enPass = md5($password);

        $query = "SELECT `id` FROM `visitor` WHERE `id`= '" . $id . "' AND `password`= '" . $enPass . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    public function changePassword($id, $password) {

        $enPass = md5($password);

        $query = "UPDATE  `visitor` SET "
                . "`password` ='" . $enPass . "' "
                . "WHERE `id` = '" . $id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    public function authenticate() {

        if (!isset($_SESSION)) {
            session_start();
        }

        $id = NULL;
        $authToken = NULL;

        if (isset($_SESSION["id"])) {
            $id = $_SESSION["id"];
        }

        if (isset($_SESSION["authToken"])) {
            $authToken = $_SESSION["authToken"];
        }

        $query = "SELECT `id` FROM `visitor` WHERE `id`= '" . $id . "' AND `authToken`= '" . $authToken . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {
            return FALSE;
        } else {

            return TRUE;
        }
        
    }

    public function logOut() {

        if (!isset($_SESSION)) {
            session_start();
        }

        unset($_SESSION["id"]);
        unset($_SESSION["name"]);
        unset($_SESSION["email"]);
        unset($_SESSION["isActive"]);
        unset($_SESSION["authToken"]);
        unset($_SESSION["lastLogin"]);
        unset($_SESSION["position"]);
     
        return TRUE;
    }

    public function update() {

        $query = "UPDATE  `visitor` SET "
                . "`name` ='" . $this->name . "', "
                . "`email` ='" . $this->email . "', "
                . "`address` ='" . $this->address . "', "
                . "`contact_number` ='" . $this->contact_number . "', "
                . "`profile_picture` ='" . $this->profile_picture . "' "
                . "WHERE `id` = '" . $this->id . "'";
        
        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    private function setUserSession($visitor) {

        if (!isset($_SESSION)) {
            session_start();
        }

        $_SESSION["id"] = $visitor["id"];
        $_SESSION["name"] = $visitor['name'];
        $_SESSION["email"] = $visitor['email'];
        $_SESSION["address"] = $visitor['address'];
        $_SESSION["contact_number"] = $visitor['contact_number'];
        $_SESSION["profile_picture"] = $visitor['profile_picture'];
        $_SESSION["isActive"] = $visitor['isActive'];
        $_SESSION["authToken"] = $visitor['authToken'];
        $_SESSION["position"] = 'visitor';
        
    }

    private function setAuthToken($id) {

        $authToken = md5(uniqid(rand(), true));

        $query = "UPDATE `visitor` SET `authToken` ='" . $authToken . "' WHERE `id`='" . $id . "'";

        $db = new Database();

        if ($db->readQuery($query)) {

            return $authToken;
        } else {
            return FALSE;
        }
    }

    private function setLastLogin($id) {

        date_default_timezone_set('Asia/Colombo');

        $now = date('Y-m-d H:i:s');

        $query = "UPDATE `visitor` SET `lastLogin` ='" . $now . "' WHERE `id`='" . $id . "'";

        $db = new Database();

        if ($db->readQuery($query)) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    public function checkEmail($email) {

        $query = "SELECT `email` FROM `visitor` WHERE `email`= '" . $email . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {
            return FALSE;
        } else {
            return $result;
        }
    }
    
    public function checkUserName($username) {

        $query = "SELECT `email`,`username` FROM `visitor` WHERE `username`= '" . $username . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {
            return FALSE;
        } else {
            return $result;
        }
    }

    public function GenarateCode($email) {

        $rand = rand(10000, 99999);

        $query = "UPDATE  `visitor` SET "
                . "`resetCode` ='" . $rand . "' "
                . "WHERE `email` = '" . $email . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $rand;
        } else {
            return FALSE;
        }
    }

    public function SelectForgetVisitor($email) {

        if ($email) {

            $query = "SELECT `email`,`resetCode` FROM `visitor` WHERE `email`= '" . $email . "'";

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->username = $result['username'];
            $this->email = $result['email'];
            $this->restCode = $result['resetCode'];

            return $result;
        }
    }

    public function SelectResetCode($code) {

        $query = "SELECT `id` FROM `visitor` WHERE `resetCode`= '" . $code . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {
            return FALSE;
        } else {

            return TRUE;
        }
    }

    public function updatePassword($password, $code) {

        $enPass = md5($password);

        $query = "UPDATE  `visitor` SET "
                . "`password` ='" . $enPass . "' "
                . "WHERE `resetCode` = '" . $code . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    
    public function isFbIdIsEx($visitorID) {

        $query = "SELECT * FROM `visitor` WHERE `facebookID` = '" . $visitorID . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if ($result === false) {
            return false;
        } else {
            return true;
        }
    }

    public function createByFB($name, $email, $picture, $visitorID, $password) {
        date_default_timezone_set('Asia/Colombo');

        $createdAt = date('Y-m-d H:i:s');

        $query = "INSERT INTO `visitor` (`createdAt`,`name`,`email`,`profile_picture`,`facebookID`,`password`) VALUES  ('" . $createdAt . "','" . $name . "', '" . $email . "', '" . $picture . "', '" . $visitorID . "', '" . $password . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        $last_id = mysql_insert_id();

        if ($result) {

            $this->loginByFB($visitorID, $password);

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function loginByFB($visitorID, $password) {
        

        $query = "SELECT * FROM `visitor` WHERE `facebookID`= '" . $visitorID . "' AND `password`= '" . $password . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {
            return FALSE;
        } else {
            $this->id = $result['id'];
            $visitor = $this->__construct($this->id);

            if (!isset($_SESSION)) {
                session_start();
                session_unset($_SESSION);
            }
            
            $authtocken = $this->setAuthToken($visitor['id']);
            $_SESSION["login"] = TRUE;
            $_SESSION["id"] = $visitor['id'];
            $_SESSION["authToken"] = $authtocken;
            $_SESSION["position"] = 'visitor';

            return TRUE;
        }
    }

}

PHPMailer/SECURITY.md000064400000012136150766203060010126 0ustar00# Security notices relating to PHPMailer

Please disclose any vulnerabilities found responsibly - report any security problems found to the maintainers privately.

PHPMailer versions 6.1.5 and earlier contain an output escaping bug that occurs in `Content-Type` and `Content-Disposition` when filenames passed into `addAttachment` and other methods that accept attachment names contain double quote characters, in contravention of RFC822 3.4.1. No specific vulnerability has been found relating to this, but it could allow file attachments to bypass attachment filters that are based on matching filename extensions. Recorded as [CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security.

PHPMailer versions prior to 6.0.6 and 5.2.27 are vulnerable to an object injection attack by passing `phar://` paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. Recorded as [CVE-2018-19296](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2018-19296). See [this article](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info on this type of vulnerability. Mitigated by blocking the use of paths containing URL-protocol style prefixes such as `phar://`. Reported by Sehun Oh of cyberone.kr.

PHPMailer versions prior to 5.2.24 (released July 26th 2017) have an XSS vulnerability in one of the code examples, [CVE-2017-11503](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-11503). The `code_generator.phps` example did not filter user input prior to output. This file is distributed with a `.phps` extension, so it it not normally executable unless it is explicitly renamed, and the file is not included when PHPMailer is loaded through composer, so it is safe by default. There was also an undisclosed potential XSS vulnerability in the default exception handler (unused by default). Patches for both issues kindly provided by Patrick Monnerat of the Fedora Project.

PHPMailer versions prior to 5.2.22 (released January 9th 2017) have a local file disclosure vulnerability, [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity.

PHPMailer versions prior to 5.2.20 (released December 28th 2016) are vulnerable to [CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer).

PHPMailer versions prior to 5.2.18 (released December 2016) are vulnerable to [CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html).

PHPMailer versions prior to 5.2.14 (released November 2015) are vulnerable to [CVE-2015-8476](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-8476) an SMTP CRLF injection bug permitting arbitrary message sending.

PHPMailer versions prior to 5.2.10 (released May 2015) are vulnerable to [CVE-2008-5619](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-5619), a remote code execution vulnerability in the bundled html2text library. This file was removed in 5.2.10, so if you are using a version prior to that and make use of the html2text function, it's vitally important that you upgrade and remove this file.

PHPMailer versions prior to 2.0.7 and 2.2.1 are vulnerable to [CVE-2012-0796](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0796), an email header injection attack.

Joomla 1.6.0 uses PHPMailer in an unsafe way, allowing it to reveal local file paths, reported in [CVE-2011-3747](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-3747).

PHPMailer didn't sanitise the `$lang_path` parameter in `SetLanguage`. This wasn't a problem in itself, but some apps (PHPClassifieds, ATutor) also failed to sanitise user-provided parameters passed to it, permitting semi-arbitrary local file inclusion, reported in [CVE-2010-4914](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2010-4914), [CVE-2007-2021](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-2021) and [CVE-2006-5734](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-5734).

PHPMailer 1.7.2 and earlier contained a possible DDoS vulnerability reported in [CVE-2005-1807](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-1807).

PHPMailer 1.7 and earlier (June 2003) have a possible vulnerability in the `SendmailSend` method where shell commands may not be sanitised. Reported in [CVE-2007-3215](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-3215).

PHPMailer/VERSION000064400000000005150766203060007375 0ustar006.1.7PHPMailer/COMMITMENT000064400000004054150766203060007734 0ustar00GPL Cooperation Commitment
Version 1.0

Before filing or continuing to prosecute any legal proceeding or claim
(other than a Defensive Action) arising from termination of a Covered
License, we commit to extend to the person or entity ('you') accused
of violating the Covered License the following provisions regarding
cure and reinstatement, taken from GPL version 3. As used here, the
term 'this License' refers to the specific Covered License being
enforced.

    However, if you cease all violation of this License, then your
    license from a particular copyright holder is reinstated (a)
    provisionally, unless and until the copyright holder explicitly
    and finally terminates your license, and (b) permanently, if the
    copyright holder fails to notify you of the violation by some
    reasonable means prior to 60 days after the cessation.

    Moreover, your license from a particular copyright holder is
    reinstated permanently if the copyright holder notifies you of the
    violation by some reasonable means, this is the first time you
    have received notice of violation of this License (for any work)
    from that copyright holder, and you cure the violation prior to 30
    days after your receipt of the notice.

We intend this Commitment to be irrevocable, and binding and
enforceable against us and assignees of or successors to our
copyrights.

Definitions

'Covered License' means the GNU General Public License, version 2
(GPLv2), the GNU Lesser General Public License, version 2.1
(LGPLv2.1), or the GNU Library General Public License, version 2
(LGPLv2), all as published by the Free Software Foundation.

'Defensive Action' means a legal proceeding or claim that We bring
against you in response to a prior proceeding or claim initiated by
you or your affiliate.

'We' means each contributor to this repository as of the date of
inclusion of this file, including subsidiaries of a corporate
contributor.

This work is available under a Creative Commons Attribution-ShareAlike
4.0 International license (https://creativecommons.org/licenses/by-sa/4.0/).
PHPMailer/src/OAuth.php000064400000007240150766203060010655 0ustar00<?php
/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5.5.
 *
 * @see       https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 *
 * @author    Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author    Jim Jagielski (jimjag) <[email protected]>
 * @author    Andy Prevost (codeworxtech) <[email protected]>
 * @author    Brent R. Matzelle (original founder)
 * @copyright 2012 - 2020 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license   http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note      This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */

namespace PHPMailer\PHPMailer;

use League\OAuth2\Client\Grant\RefreshToken;
use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Token\AccessToken;

/**
 * OAuth - OAuth2 authentication wrapper class.
 * Uses the oauth2-client package from the League of Extraordinary Packages.
 *
 * @see     http://oauth2-client.thephpleague.com
 *
 * @author  Marcus Bointon (Synchro/coolbru) <[email protected]>
 */
class OAuth
{
    /**
     * An instance of the League OAuth Client Provider.
     *
     * @var AbstractProvider
     */
    protected $provider;

    /**
     * The current OAuth access token.
     *
     * @var AccessToken
     */
    protected $oauthToken;

    /**
     * The user's email address, usually used as the login ID
     * and also the from address when sending email.
     *
     * @var string
     */
    protected $oauthUserEmail = '';

    /**
     * The client secret, generated in the app definition of the service you're connecting to.
     *
     * @var string
     */
    protected $oauthClientSecret = '';

    /**
     * The client ID, generated in the app definition of the service you're connecting to.
     *
     * @var string
     */
    protected $oauthClientId = '';

    /**
     * The refresh token, used to obtain new AccessTokens.
     *
     * @var string
     */
    protected $oauthRefreshToken = '';

    /**
     * OAuth constructor.
     *
     * @param array $options Associative array containing
     *                       `provider`, `userName`, `clientSecret`, `clientId` and `refreshToken` elements
     */
    public function __construct($options)
    {
        $this->provider = $options['provider'];
        $this->oauthUserEmail = $options['userName'];
        $this->oauthClientSecret = $options['clientSecret'];
        $this->oauthClientId = $options['clientId'];
        $this->oauthRefreshToken = $options['refreshToken'];
    }

    /**
     * Get a new RefreshToken.
     *
     * @return RefreshToken
     */
    protected function getGrant()
    {
        return new RefreshToken();
    }

    /**
     * Get a new AccessToken.
     *
     * @return AccessToken
     */
    protected function getToken()
    {
        return $this->provider->getAccessToken(
            $this->getGrant(),
            ['refresh_token' => $this->oauthRefreshToken]
        );
    }

    /**
     * Generate a base64-encoded OAuth token.
     *
     * @return string
     */
    public function getOauth64()
    {
        // Get a new token if it's not available or has expired
        if (null === $this->oauthToken || $this->oauthToken->hasExpired()) {
            $this->oauthToken = $this->getToken();
        }

        return base64_encode(
            'user=' .
            $this->oauthUserEmail .
            "\001auth=Bearer " .
            $this->oauthToken .
            "\001\001"
        );
    }
}
PHPMailer/src/SMTP.php000064400000131763150766203060010430 0ustar00<?php
/**
 * PHPMailer RFC821 SMTP email transport class.
 * PHP Version 5.5.
 *
 * @see       https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 *
 * @author    Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author    Jim Jagielski (jimjag) <[email protected]>
 * @author    Andy Prevost (codeworxtech) <[email protected]>
 * @author    Brent R. Matzelle (original founder)
 * @copyright 2012 - 2020 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license   http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note      This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */

namespace PHPMailer\PHPMailer;

/**
 * PHPMailer RFC821 SMTP email transport class.
 * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
 *
 * @author Chris Ryan
 * @author Marcus Bointon <[email protected]>
 */
class SMTP
{
    /**
     * The PHPMailer SMTP version number.
     *
     * @var string
     */
    const VERSION = '6.1.7';

    /**
     * SMTP line break constant.
     *
     * @var string
     */
    const LE = "\r\n";

    /**
     * The SMTP port to use if one is not specified.
     *
     * @var int
     */
    const DEFAULT_PORT = 25;

    /**
     * The maximum line length allowed by RFC 5321 section 4.5.3.1.6,
     * *excluding* a trailing CRLF break.
     *
     * @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.6
     *
     * @var int
     */
    const MAX_LINE_LENGTH = 998;

    /**
     * The maximum line length allowed for replies in RFC 5321 section 4.5.3.1.5,
     * *including* a trailing CRLF line break.
     *
     * @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.5
     *
     * @var int
     */
    const MAX_REPLY_LENGTH = 512;

    /**
     * Debug level for no output.
     *
     * @var int
     */
    const DEBUG_OFF = 0;

    /**
     * Debug level to show client -> server messages.
     *
     * @var int
     */
    const DEBUG_CLIENT = 1;

    /**
     * Debug level to show client -> server and server -> client messages.
     *
     * @var int
     */
    const DEBUG_SERVER = 2;

    /**
     * Debug level to show connection status, client -> server and server -> client messages.
     *
     * @var int
     */
    const DEBUG_CONNECTION = 3;

    /**
     * Debug level to show all messages.
     *
     * @var int
     */
    const DEBUG_LOWLEVEL = 4;

    /**
     * Debug output level.
     * Options:
     * * self::DEBUG_OFF (`0`) No debug output, default
     * * self::DEBUG_CLIENT (`1`) Client commands
     * * self::DEBUG_SERVER (`2`) Client commands and server responses
     * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
     * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages.
     *
     * @var int
     */
    public $do_debug = self::DEBUG_OFF;

    /**
     * How to handle debug output.
     * Options:
     * * `echo` Output plain-text as-is, appropriate for CLI
     * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
     * * `error_log` Output to error log as configured in php.ini
     * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
     *
     * ```php
     * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
     * ```
     *
     * Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug`
     * level output is used:
     *
     * ```php
     * $mail->Debugoutput = new myPsr3Logger;
     * ```
     *
     * @var string|callable|\Psr\Log\LoggerInterface
     */
    public $Debugoutput = 'echo';

    /**
     * Whether to use VERP.
     *
     * @see http://en.wikipedia.org/wiki/Variable_envelope_return_path
     * @see http://www.postfix.org/VERP_README.html Info on VERP
     *
     * @var bool
     */
    public $do_verp = false;

    /**
     * The timeout value for connection, in seconds.
     * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
     * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
     *
     * @see http://tools.ietf.org/html/rfc2821#section-4.5.3.2
     *
     * @var int
     */
    public $Timeout = 300;

    /**
     * How long to wait for commands to complete, in seconds.
     * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
     *
     * @var int
     */
    public $Timelimit = 300;

    /**
     * Patterns to extract an SMTP transaction id from reply to a DATA command.
     * The first capture group in each regex will be used as the ID.
     * MS ESMTP returns the message ID, which may not be correct for internal tracking.
     *
     * @var string[]
     */
    protected $smtp_transaction_id_patterns = [
        'exim' => '/[\d]{3} OK id=(.*)/',
        'sendmail' => '/[\d]{3} 2.0.0 (.*) Message/',
        'postfix' => '/[\d]{3} 2.0.0 Ok: queued as (.*)/',
        'Microsoft_ESMTP' => '/[0-9]{3} 2.[\d].0 (.*)@(?:.*) Queued mail for delivery/',
        'Amazon_SES' => '/[\d]{3} Ok (.*)/',
        'SendGrid' => '/[\d]{3} Ok: queued as (.*)/',
        'CampaignMonitor' => '/[\d]{3} 2.0.0 OK:([a-zA-Z\d]{48})/',
    ];

    /**
     * The last transaction ID issued in response to a DATA command,
     * if one was detected.
     *
     * @var string|bool|null
     */
    protected $last_smtp_transaction_id;

    /**
     * The socket for the server connection.
     *
     * @var ?resource
     */
    protected $smtp_conn;

    /**
     * Error information, if any, for the last SMTP command.
     *
     * @var array
     */
    protected $error = [
        'error' => '',
        'detail' => '',
        'smtp_code' => '',
        'smtp_code_ex' => '',
    ];

    /**
     * The reply the server sent to us for HELO.
     * If null, no HELO string has yet been received.
     *
     * @var string|null
     */
    protected $helo_rply;

    /**
     * The set of SMTP extensions sent in reply to EHLO command.
     * Indexes of the array are extension names.
     * Value at index 'HELO' or 'EHLO' (according to command that was sent)
     * represents the server name. In case of HELO it is the only element of the array.
     * Other values can be boolean TRUE or an array containing extension options.
     * If null, no HELO/EHLO string has yet been received.
     *
     * @var array|null
     */
    protected $server_caps;

    /**
     * The most recent reply received from the server.
     *
     * @var string
     */
    protected $last_reply = '';

    /**
     * Output debugging info via a user-selected method.
     *
     * @param string $str   Debug string to output
     * @param int    $level The debug level of this message; see DEBUG_* constants
     *
     * @see SMTP::$Debugoutput
     * @see SMTP::$do_debug
     */
    protected function edebug($str, $level = 0)
    {
        if ($level > $this->do_debug) {
            return;
        }
        //Is this a PSR-3 logger?
        if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
            $this->Debugoutput->debug($str);

            return;
        }
        //Avoid clash with built-in function names
        if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) {
            call_user_func($this->Debugoutput, $str, $level);

            return;
        }
        switch ($this->Debugoutput) {
            case 'error_log':
                //Don't output, just log
                error_log($str);
                break;
            case 'html':
                //Cleans up output a bit for a better looking, HTML-safe output
                echo gmdate('Y-m-d H:i:s'), ' ', htmlentities(
                    preg_replace('/[\r\n]+/', '', $str),
                    ENT_QUOTES,
                    'UTF-8'
                ), "<br>\n";
                break;
            case 'echo':
            default:
                //Normalize line breaks
                $str = preg_replace('/\r\n|\r/m', "\n", $str);
                echo gmdate('Y-m-d H:i:s'),
                "\t",
                    //Trim trailing space
                trim(
                    //Indent for readability, except for trailing break
                    str_replace(
                        "\n",
                        "\n                   \t                  ",
                        trim($str)
                    )
                ),
                "\n";
        }
    }

    /**
     * Connect to an SMTP server.
     *
     * @param string $host    SMTP server IP or host name
     * @param int    $port    The port number to connect to
     * @param int    $timeout How long to wait for the connection to open
     * @param array  $options An array of options for stream_context_create()
     *
     * @return bool
     */
    public function connect($host, $port = null, $timeout = 30, $options = [])
    {
        // Clear errors to avoid confusion
        $this->setError('');
        // Make sure we are __not__ connected
        if ($this->connected()) {
            // Already connected, generate error
            $this->setError('Already connected to a server');

            return false;
        }
        if (empty($port)) {
            $port = self::DEFAULT_PORT;
        }
        // Connect to the SMTP server
        $this->edebug(
            "Connection: opening to $host:$port, timeout=$timeout, options=" .
            (count($options) > 0 ? var_export($options, true) : 'array()'),
            self::DEBUG_CONNECTION
        );

        $this->smtp_conn = $this->getSMTPConnection($host, $port, $timeout, $options);

        if ($this->smtp_conn === false) {
            //Error info already set inside `getSMTPConnection()`
            return false;
        }

        $this->edebug('Connection: opened', self::DEBUG_CONNECTION);

        // Get any announcement
        $this->last_reply = $this->get_lines();
        $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);

        return true;
    }

    /**
     * Create connection to the SMTP server.
     *
     * @param string $host    SMTP server IP or host name
     * @param int    $port    The port number to connect to
     * @param int    $timeout How long to wait for the connection to open
     * @param array  $options An array of options for stream_context_create()
     *
     * @return false|resource
     */
    protected function getSMTPConnection($host, $port = null, $timeout = 30, $options = [])
    {
        static $streamok;
        //This is enabled by default since 5.0.0 but some providers disable it
        //Check this once and cache the result
        if (null === $streamok) {
            $streamok = function_exists('stream_socket_client');
        }

        $errno = 0;
        $errstr = '';
        if ($streamok) {
            $socket_context = stream_context_create($options);
            set_error_handler([$this, 'errorHandler']);
            $connection = stream_socket_client(
                $host . ':' . $port,
                $errno,
                $errstr,
                $timeout,
                STREAM_CLIENT_CONNECT,
                $socket_context
            );
            restore_error_handler();
        } else {
            //Fall back to fsockopen which should work in more places, but is missing some features
            $this->edebug(
                'Connection: stream_socket_client not available, falling back to fsockopen',
                self::DEBUG_CONNECTION
            );
            set_error_handler([$this, 'errorHandler']);
            $connection = fsockopen(
                $host,
                $port,
                $errno,
                $errstr,
                $timeout
            );
            restore_error_handler();
        }

        // Verify we connected properly
        if (!is_resource($connection)) {
            $this->setError(
                'Failed to connect to server',
                '',
                (string) $errno,
                $errstr
            );
            $this->edebug(
                'SMTP ERROR: ' . $this->error['error']
                . ": $errstr ($errno)",
                self::DEBUG_CLIENT
            );

            return false;
        }

        // SMTP server can take longer to respond, give longer timeout for first read
        // Windows does not have support for this timeout function
        if (strpos(PHP_OS, 'WIN') !== 0) {
            $max = (int)ini_get('max_execution_time');
            // Don't bother if unlimited, or if set_time_limit is disabled
            if (0 !== $max && $timeout > $max && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
                @set_time_limit($timeout);
            }
            stream_set_timeout($connection, $timeout, 0);
        }

        return $connection;
    }

    /**
     * Initiate a TLS (encrypted) session.
     *
     * @return bool
     */
    public function startTLS()
    {
        if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
            return false;
        }

        //Allow the best TLS version(s) we can
        $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;

        //PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
        //so add them back in manually if we can
        if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
            $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
            $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
        }

        // Begin encrypted connection
        set_error_handler([$this, 'errorHandler']);
        $crypto_ok = stream_socket_enable_crypto(
            $this->smtp_conn,
            true,
            $crypto_method
        );
        restore_error_handler();

        return (bool) $crypto_ok;
    }

    /**
     * Perform SMTP authentication.
     * Must be run after hello().
     *
     * @see    hello()
     *
     * @param string $username The user name
     * @param string $password The password
     * @param string $authtype The auth type (CRAM-MD5, PLAIN, LOGIN, XOAUTH2)
     * @param OAuth  $OAuth    An optional OAuth instance for XOAUTH2 authentication
     *
     * @return bool True if successfully authenticated
     */
    public function authenticate(
        $username,
        $password,
        $authtype = null,
        $OAuth = null
    ) {
        if (!$this->server_caps) {
            $this->setError('Authentication is not allowed before HELO/EHLO');

            return false;
        }

        if (array_key_exists('EHLO', $this->server_caps)) {
            // SMTP extensions are available; try to find a proper authentication method
            if (!array_key_exists('AUTH', $this->server_caps)) {
                $this->setError('Authentication is not allowed at this stage');
                // 'at this stage' means that auth may be allowed after the stage changes
                // e.g. after STARTTLS

                return false;
            }

            $this->edebug('Auth method requested: ' . ($authtype ?: 'UNSPECIFIED'), self::DEBUG_LOWLEVEL);
            $this->edebug(
                'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
                self::DEBUG_LOWLEVEL
            );

            //If we have requested a specific auth type, check the server supports it before trying others
            if (null !== $authtype && !in_array($authtype, $this->server_caps['AUTH'], true)) {
                $this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL);
                $authtype = null;
            }

            if (empty($authtype)) {
                //If no auth mechanism is specified, attempt to use these, in this order
                //Try CRAM-MD5 first as it's more secure than the others
                foreach (['CRAM-MD5', 'LOGIN', 'PLAIN', 'XOAUTH2'] as $method) {
                    if (in_array($method, $this->server_caps['AUTH'], true)) {
                        $authtype = $method;
                        break;
                    }
                }
                if (empty($authtype)) {
                    $this->setError('No supported authentication methods found');

                    return false;
                }
                $this->edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
            }

            if (!in_array($authtype, $this->server_caps['AUTH'], true)) {
                $this->setError("The requested authentication method \"$authtype\" is not supported by the server");

                return false;
            }
        } elseif (empty($authtype)) {
            $authtype = 'LOGIN';
        }
        switch ($authtype) {
            case 'PLAIN':
                // Start authentication
                if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) {
                    return false;
                }
                // Send encoded username and password
                if (!$this->sendCommand(
                    'User & Password',
                    base64_encode("\0" . $username . "\0" . $password),
                    235
                )
                ) {
                    return false;
                }
                break;
            case 'LOGIN':
                // Start authentication
                if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) {
                    return false;
                }
                if (!$this->sendCommand('Username', base64_encode($username), 334)) {
                    return false;
                }
                if (!$this->sendCommand('Password', base64_encode($password), 235)) {
                    return false;
                }
                break;
            case 'CRAM-MD5':
                // Start authentication
                if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
                    return false;
                }
                // Get the challenge
                $challenge = base64_decode(substr($this->last_reply, 4));

                // Build the response
                $response = $username . ' ' . $this->hmac($challenge, $password);

                // send encoded credentials
                return $this->sendCommand('Username', base64_encode($response), 235);
            case 'XOAUTH2':
                //The OAuth instance must be set up prior to requesting auth.
                if (null === $OAuth) {
                    return false;
                }
                $oauth = $OAuth->getOauth64();

                // Start authentication
                if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
                    return false;
                }
                break;
            default:
                $this->setError("Authentication method \"$authtype\" is not supported");

                return false;
        }

        return true;
    }

    /**
     * Calculate an MD5 HMAC hash.
     * Works like hash_hmac('md5', $data, $key)
     * in case that function is not available.
     *
     * @param string $data The data to hash
     * @param string $key  The key to hash with
     *
     * @return string
     */
    protected function hmac($data, $key)
    {
        if (function_exists('hash_hmac')) {
            return hash_hmac('md5', $data, $key);
        }

        // The following borrowed from
        // http://php.net/manual/en/function.mhash.php#27225

        // RFC 2104 HMAC implementation for php.
        // Creates an md5 HMAC.
        // Eliminates the need to install mhash to compute a HMAC
        // by Lance Rushing

        $bytelen = 64; // byte length for md5
        if (strlen($key) > $bytelen) {
            $key = pack('H*', md5($key));
        }
        $key = str_pad($key, $bytelen, chr(0x00));
        $ipad = str_pad('', $bytelen, chr(0x36));
        $opad = str_pad('', $bytelen, chr(0x5c));
        $k_ipad = $key ^ $ipad;
        $k_opad = $key ^ $opad;

        return md5($k_opad . pack('H*', md5($k_ipad . $data)));
    }

    /**
     * Check connection state.
     *
     * @return bool True if connected
     */
    public function connected()
    {
        if (is_resource($this->smtp_conn)) {
            $sock_status = stream_get_meta_data($this->smtp_conn);
            if ($sock_status['eof']) {
                // The socket is valid but we are not connected
                $this->edebug(
                    'SMTP NOTICE: EOF caught while checking if connected',
                    self::DEBUG_CLIENT
                );
                $this->close();

                return false;
            }

            return true; // everything looks good
        }

        return false;
    }

    /**
     * Close the socket and clean up the state of the class.
     * Don't use this function without first trying to use QUIT.
     *
     * @see quit()
     */
    public function close()
    {
        $this->setError('');
        $this->server_caps = null;
        $this->helo_rply = null;
        if (is_resource($this->smtp_conn)) {
            // close the connection and cleanup
            fclose($this->smtp_conn);
            $this->smtp_conn = null; //Makes for cleaner serialization
            $this->edebug('Connection: closed', self::DEBUG_CONNECTION);
        }
    }

    /**
     * Send an SMTP DATA command.
     * Issues a data command and sends the msg_data to the server,
     * finializing the mail transaction. $msg_data is the message
     * that is to be send with the headers. Each header needs to be
     * on a single line followed by a <CRLF> with the message headers
     * and the message body being separated by an additional <CRLF>.
     * Implements RFC 821: DATA <CRLF>.
     *
     * @param string $msg_data Message data to send
     *
     * @return bool
     */
    public function data($msg_data)
    {
        //This will use the standard timelimit
        if (!$this->sendCommand('DATA', 'DATA', 354)) {
            return false;
        }

        /* The server is ready to accept data!
         * According to rfc821 we should not send more than 1000 characters on a single line (including the LE)
         * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
         * smaller lines to fit within the limit.
         * We will also look for lines that start with a '.' and prepend an additional '.'.
         * NOTE: this does not count towards line-length limit.
         */

        // Normalize line breaks before exploding
        $lines = explode("\n", str_replace(["\r\n", "\r"], "\n", $msg_data));

        /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
         * of the first line (':' separated) does not contain a space then it _should_ be a header and we will
         * process all lines before a blank line as headers.
         */

        $field = substr($lines[0], 0, strpos($lines[0], ':'));
        $in_headers = false;
        if (!empty($field) && strpos($field, ' ') === false) {
            $in_headers = true;
        }

        foreach ($lines as $line) {
            $lines_out = [];
            if ($in_headers && $line === '') {
                $in_headers = false;
            }
            //Break this line up into several smaller lines if it's too long
            //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len),
            while (isset($line[self::MAX_LINE_LENGTH])) {
                //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
                //so as to avoid breaking in the middle of a word
                $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' ');
                //Deliberately matches both false and 0
                if (!$pos) {
                    //No nice break found, add a hard break
                    $pos = self::MAX_LINE_LENGTH - 1;
                    $lines_out[] = substr($line, 0, $pos);
                    $line = substr($line, $pos);
                } else {
                    //Break at the found point
                    $lines_out[] = substr($line, 0, $pos);
                    //Move along by the amount we dealt with
                    $line = substr($line, $pos + 1);
                }
                //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
                if ($in_headers) {
                    $line = "\t" . $line;
                }
            }
            $lines_out[] = $line;

            //Send the lines to the server
            foreach ($lines_out as $line_out) {
                //RFC2821 section 4.5.2
                if (!empty($line_out) && $line_out[0] === '.') {
                    $line_out = '.' . $line_out;
                }
                $this->client_send($line_out . static::LE, 'DATA');
            }
        }

        //Message data has been sent, complete the command
        //Increase timelimit for end of DATA command
        $savetimelimit = $this->Timelimit;
        $this->Timelimit *= 2;
        $result = $this->sendCommand('DATA END', '.', 250);
        $this->recordLastTransactionID();
        //Restore timelimit
        $this->Timelimit = $savetimelimit;

        return $result;
    }

    /**
     * Send an SMTP HELO or EHLO command.
     * Used to identify the sending server to the receiving server.
     * This makes sure that client and server are in a known state.
     * Implements RFC 821: HELO <SP> <domain> <CRLF>
     * and RFC 2821 EHLO.
     *
     * @param string $host The host name or IP to connect to
     *
     * @return bool
     */
    public function hello($host = '')
    {
        //Try extended hello first (RFC 2821)
        return $this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host);
    }

    /**
     * Send an SMTP HELO or EHLO command.
     * Low-level implementation used by hello().
     *
     * @param string $hello The HELO string
     * @param string $host  The hostname to say we are
     *
     * @return bool
     *
     * @see hello()
     */
    protected function sendHello($hello, $host)
    {
        $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250);
        $this->helo_rply = $this->last_reply;
        if ($noerror) {
            $this->parseHelloFields($hello);
        } else {
            $this->server_caps = null;
        }

        return $noerror;
    }

    /**
     * Parse a reply to HELO/EHLO command to discover server extensions.
     * In case of HELO, the only parameter that can be discovered is a server name.
     *
     * @param string $type `HELO` or `EHLO`
     */
    protected function parseHelloFields($type)
    {
        $this->server_caps = [];
        $lines = explode("\n", $this->helo_rply);

        foreach ($lines as $n => $s) {
            //First 4 chars contain response code followed by - or space
            $s = trim(substr($s, 4));
            if (empty($s)) {
                continue;
            }
            $fields = explode(' ', $s);
            if (!empty($fields)) {
                if (!$n) {
                    $name = $type;
                    $fields = $fields[0];
                } else {
                    $name = array_shift($fields);
                    switch ($name) {
                        case 'SIZE':
                            $fields = ($fields ? $fields[0] : 0);
                            break;
                        case 'AUTH':
                            if (!is_array($fields)) {
                                $fields = [];
                            }
                            break;
                        default:
                            $fields = true;
                    }
                }
                $this->server_caps[$name] = $fields;
            }
        }
    }

    /**
     * Send an SMTP MAIL command.
     * Starts a mail transaction from the email address specified in
     * $from. Returns true if successful or false otherwise. If True
     * the mail transaction is started and then one or more recipient
     * commands may be called followed by a data command.
     * Implements RFC 821: MAIL <SP> FROM:<reverse-path> <CRLF>.
     *
     * @param string $from Source address of this message
     *
     * @return bool
     */
    public function mail($from)
    {
        $useVerp = ($this->do_verp ? ' XVERP' : '');

        return $this->sendCommand(
            'MAIL FROM',
            'MAIL FROM:<' . $from . '>' . $useVerp,
            250
        );
    }

    /**
     * Send an SMTP QUIT command.
     * Closes the socket if there is no error or the $close_on_error argument is true.
     * Implements from RFC 821: QUIT <CRLF>.
     *
     * @param bool $close_on_error Should the connection close if an error occurs?
     *
     * @return bool
     */
    public function quit($close_on_error = true)
    {
        $noerror = $this->sendCommand('QUIT', 'QUIT', 221);
        $err = $this->error; //Save any error
        if ($noerror || $close_on_error) {
            $this->close();
            $this->error = $err; //Restore any error from the quit command
        }

        return $noerror;
    }

    /**
     * Send an SMTP RCPT command.
     * Sets the TO argument to $toaddr.
     * Returns true if the recipient was accepted false if it was rejected.
     * Implements from RFC 821: RCPT <SP> TO:<forward-path> <CRLF>.
     *
     * @param string $address The address the message is being sent to
     * @param string $dsn     Comma separated list of DSN notifications. NEVER, SUCCESS, FAILURE
     *                        or DELAY. If you specify NEVER all other notifications are ignored.
     *
     * @return bool
     */
    public function recipient($address, $dsn = '')
    {
        if (empty($dsn)) {
            $rcpt = 'RCPT TO:<' . $address . '>';
        } else {
            $dsn = strtoupper($dsn);
            $notify = [];

            if (strpos($dsn, 'NEVER') !== false) {
                $notify[] = 'NEVER';
            } else {
                foreach (['SUCCESS', 'FAILURE', 'DELAY'] as $value) {
                    if (strpos($dsn, $value) !== false) {
                        $notify[] = $value;
                    }
                }
            }

            $rcpt = 'RCPT TO:<' . $address . '> NOTIFY=' . implode(',', $notify);
        }

        return $this->sendCommand(
            'RCPT TO',
            $rcpt,
            [250, 251]
        );
    }

    /**
     * Send an SMTP RSET command.
     * Abort any transaction that is currently in progress.
     * Implements RFC 821: RSET <CRLF>.
     *
     * @return bool True on success
     */
    public function reset()
    {
        return $this->sendCommand('RSET', 'RSET', 250);
    }

    /**
     * Send a command to an SMTP server and check its return code.
     *
     * @param string    $command       The command name - not sent to the server
     * @param string    $commandstring The actual command to send
     * @param int|array $expect        One or more expected integer success codes
     *
     * @return bool True on success
     */
    protected function sendCommand($command, $commandstring, $expect)
    {
        if (!$this->connected()) {
            $this->setError("Called $command without being connected");

            return false;
        }
        //Reject line breaks in all commands
        if ((strpos($commandstring, "\n") !== false) || (strpos($commandstring, "\r") !== false)) {
            $this->setError("Command '$command' contained line breaks");

            return false;
        }
        $this->client_send($commandstring . static::LE, $command);

        $this->last_reply = $this->get_lines();
        // Fetch SMTP code and possible error code explanation
        $matches = [];
        if (preg_match('/^([\d]{3})[ -](?:([\d]\\.[\d]\\.[\d]{1,2}) )?/', $this->last_reply, $matches)) {
            $code = (int) $matches[1];
            $code_ex = (count($matches) > 2 ? $matches[2] : null);
            // Cut off error code from each response line
            $detail = preg_replace(
                "/{$code}[ -]" .
                ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . '/m',
                '',
                $this->last_reply
            );
        } else {
            // Fall back to simple parsing if regex fails
            $code = (int) substr($this->last_reply, 0, 3);
            $code_ex = null;
            $detail = substr($this->last_reply, 4);
        }

        $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);

        if (!in_array($code, (array) $expect, true)) {
            $this->setError(
                "$command command failed",
                $detail,
                $code,
                $code_ex
            );
            $this->edebug(
                'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
                self::DEBUG_CLIENT
            );

            return false;
        }

        $this->setError('');

        return true;
    }

    /**
     * Send an SMTP SAML command.
     * Starts a mail transaction from the email address specified in $from.
     * Returns true if successful or false otherwise. If True
     * the mail transaction is started and then one or more recipient
     * commands may be called followed by a data command. This command
     * will send the message to the users terminal if they are logged
     * in and send them an email.
     * Implements RFC 821: SAML <SP> FROM:<reverse-path> <CRLF>.
     *
     * @param string $from The address the message is from
     *
     * @return bool
     */
    public function sendAndMail($from)
    {
        return $this->sendCommand('SAML', "SAML FROM:$from", 250);
    }

    /**
     * Send an SMTP VRFY command.
     *
     * @param string $name The name to verify
     *
     * @return bool
     */
    public function verify($name)
    {
        return $this->sendCommand('VRFY', "VRFY $name", [250, 251]);
    }

    /**
     * Send an SMTP NOOP command.
     * Used to keep keep-alives alive, doesn't actually do anything.
     *
     * @return bool
     */
    public function noop()
    {
        return $this->sendCommand('NOOP', 'NOOP', 250);
    }

    /**
     * Send an SMTP TURN command.
     * This is an optional command for SMTP that this class does not support.
     * This method is here to make the RFC821 Definition complete for this class
     * and _may_ be implemented in future.
     * Implements from RFC 821: TURN <CRLF>.
     *
     * @return bool
     */
    public function turn()
    {
        $this->setError('The SMTP TURN command is not implemented');
        $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);

        return false;
    }

    /**
     * Send raw data to the server.
     *
     * @param string $data    The data to send
     * @param string $command Optionally, the command this is part of, used only for controlling debug output
     *
     * @return int|bool The number of bytes sent to the server or false on error
     */
    public function client_send($data, $command = '')
    {
        //If SMTP transcripts are left enabled, or debug output is posted online
        //it can leak credentials, so hide credentials in all but lowest level
        if (self::DEBUG_LOWLEVEL > $this->do_debug &&
            in_array($command, ['User & Password', 'Username', 'Password'], true)) {
            $this->edebug('CLIENT -> SERVER: [credentials hidden]', self::DEBUG_CLIENT);
        } else {
            $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT);
        }
        set_error_handler([$this, 'errorHandler']);
        $result = fwrite($this->smtp_conn, $data);
        restore_error_handler();

        return $result;
    }

    /**
     * Get the latest error.
     *
     * @return array
     */
    public function getError()
    {
        return $this->error;
    }

    /**
     * Get SMTP extensions available on the server.
     *
     * @return array|null
     */
    public function getServerExtList()
    {
        return $this->server_caps;
    }

    /**
     * Get metadata about the SMTP server from its HELO/EHLO response.
     * The method works in three ways, dependent on argument value and current state:
     *   1. HELO/EHLO has not been sent - returns null and populates $this->error.
     *   2. HELO has been sent -
     *     $name == 'HELO': returns server name
     *     $name == 'EHLO': returns boolean false
     *     $name == any other string: returns null and populates $this->error
     *   3. EHLO has been sent -
     *     $name == 'HELO'|'EHLO': returns the server name
     *     $name == any other string: if extension $name exists, returns True
     *       or its options (e.g. AUTH mechanisms supported). Otherwise returns False.
     *
     * @param string $name Name of SMTP extension or 'HELO'|'EHLO'
     *
     * @return string|bool|null
     */
    public function getServerExt($name)
    {
        if (!$this->server_caps) {
            $this->setError('No HELO/EHLO was sent');

            return;
        }

        if (!array_key_exists($name, $this->server_caps)) {
            if ('HELO' === $name) {
                return $this->server_caps['EHLO'];
            }
            if ('EHLO' === $name || array_key_exists('EHLO', $this->server_caps)) {
                return false;
            }
            $this->setError('HELO handshake was used; No information about server extensions available');

            return;
        }

        return $this->server_caps[$name];
    }

    /**
     * Get the last reply from the server.
     *
     * @return string
     */
    public function getLastReply()
    {
        return $this->last_reply;
    }

    /**
     * Read the SMTP server's response.
     * Either before eof or socket timeout occurs on the operation.
     * With SMTP we can tell if we have more lines to read if the
     * 4th character is '-' symbol. If it is a space then we don't
     * need to read anything else.
     *
     * @return string
     */
    protected function get_lines()
    {
        // If the connection is bad, give up straight away
        if (!is_resource($this->smtp_conn)) {
            return '';
        }
        $data = '';
        $endtime = 0;
        stream_set_timeout($this->smtp_conn, $this->Timeout);
        if ($this->Timelimit > 0) {
            $endtime = time() + $this->Timelimit;
        }
        $selR = [$this->smtp_conn];
        $selW = null;
        while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
            //Must pass vars in here as params are by reference
            //solution for signals inspired by https://github.com/symfony/symfony/pull/6540
            set_error_handler([$this, 'errorHandler']);
            $n = stream_select($selR, $selW, $selW, $this->Timelimit);
            restore_error_handler();

            if ($n === false) {
                $message = $this->getError()['detail'];

                $this->edebug(
                    'SMTP -> get_lines(): select failed (' . $message . ')',
                    self::DEBUG_LOWLEVEL
                );

                //stream_select returns false when the `select` system call is interrupted by an incoming signal, try the select again
                if (stripos($message, 'interrupted system call') !== false) {
                    $this->edebug(
                        'SMTP -> get_lines(): retrying stream_select',
                        self::DEBUG_LOWLEVEL
                    );
                    $this->setError('');
                    continue;
                }

                break;
            }

            if (!$n) {
                $this->edebug(
                    'SMTP -> get_lines(): select timed-out in (' . $this->Timelimit . ' sec)',
                    self::DEBUG_LOWLEVEL
                );
                break;
            }

            //Deliberate noise suppression - errors are handled afterwards
            $str = @fgets($this->smtp_conn, self::MAX_REPLY_LENGTH);
            $this->edebug('SMTP INBOUND: "' . trim($str) . '"', self::DEBUG_LOWLEVEL);
            $data .= $str;
            // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
            // or 4th character is a space or a line break char, we are done reading, break the loop.
            // String array access is a significant micro-optimisation over strlen
            if (!isset($str[3]) || $str[3] === ' ' || $str[3] === "\r" || $str[3] === "\n") {
                break;
            }
            // Timed-out? Log and break
            $info = stream_get_meta_data($this->smtp_conn);
            if ($info['timed_out']) {
                $this->edebug(
                    'SMTP -> get_lines(): stream timed-out (' . $this->Timeout . ' sec)',
                    self::DEBUG_LOWLEVEL
                );
                break;
            }
            // Now check if reads took too long
            if ($endtime && time() > $endtime) {
                $this->edebug(
                    'SMTP -> get_lines(): timelimit reached (' .
                    $this->Timelimit . ' sec)',
                    self::DEBUG_LOWLEVEL
                );
                break;
            }
        }

        return $data;
    }

    /**
     * Enable or disable VERP address generation.
     *
     * @param bool $enabled
     */
    public function setVerp($enabled = false)
    {
        $this->do_verp = $enabled;
    }

    /**
     * Get VERP address generation mode.
     *
     * @return bool
     */
    public function getVerp()
    {
        return $this->do_verp;
    }

    /**
     * Set error messages and codes.
     *
     * @param string $message      The error message
     * @param string $detail       Further detail on the error
     * @param string $smtp_code    An associated SMTP error code
     * @param string $smtp_code_ex Extended SMTP code
     */
    protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '')
    {
        $this->error = [
            'error' => $message,
            'detail' => $detail,
            'smtp_code' => $smtp_code,
            'smtp_code_ex' => $smtp_code_ex,
        ];
    }

    /**
     * Set debug output method.
     *
     * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it
     */
    public function setDebugOutput($method = 'echo')
    {
        $this->Debugoutput = $method;
    }

    /**
     * Get debug output method.
     *
     * @return string
     */
    public function getDebugOutput()
    {
        return $this->Debugoutput;
    }

    /**
     * Set debug output level.
     *
     * @param int $level
     */
    public function setDebugLevel($level = 0)
    {
        $this->do_debug = $level;
    }

    /**
     * Get debug output level.
     *
     * @return int
     */
    public function getDebugLevel()
    {
        return $this->do_debug;
    }

    /**
     * Set SMTP timeout.
     *
     * @param int $timeout The timeout duration in seconds
     */
    public function setTimeout($timeout = 0)
    {
        $this->Timeout = $timeout;
    }

    /**
     * Get SMTP timeout.
     *
     * @return int
     */
    public function getTimeout()
    {
        return $this->Timeout;
    }

    /**
     * Reports an error number and string.
     *
     * @param int    $errno   The error number returned by PHP
     * @param string $errmsg  The error message returned by PHP
     * @param string $errfile The file the error occurred in
     * @param int    $errline The line number the error occurred on
     */
    protected function errorHandler($errno, $errmsg, $errfile = '', $errline = 0)
    {
        $notice = 'Connection failed.';
        $this->setError(
            $notice,
            $errmsg,
            (string) $errno
        );
        $this->edebug(
            "$notice Error #$errno: $errmsg [$errfile line $errline]",
            self::DEBUG_CONNECTION
        );
    }

    /**
     * Extract and return the ID of the last SMTP transaction based on
     * a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
     * Relies on the host providing the ID in response to a DATA command.
     * If no reply has been received yet, it will return null.
     * If no pattern was matched, it will return false.
     *
     * @return bool|string|null
     */
    protected function recordLastTransactionID()
    {
        $reply = $this->getLastReply();

        if (empty($reply)) {
            $this->last_smtp_transaction_id = null;
        } else {
            $this->last_smtp_transaction_id = false;
            foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
                $matches = [];
                if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
                    $this->last_smtp_transaction_id = trim($matches[1]);
                    break;
                }
            }
        }

        return $this->last_smtp_transaction_id;
    }

    /**
     * Get the queue/transaction ID of the last SMTP transaction
     * If no reply has been received yet, it will return null.
     * If no pattern was matched, it will return false.
     *
     * @return bool|string|null
     *
     * @see recordLastTransactionID()
     */
    public function getLastTransactionID()
    {
        return $this->last_smtp_transaction_id;
    }
}
PHPMailer/src/POP3.php000064400000025462150766203070010365 0ustar00<?php
/**
 * PHPMailer POP-Before-SMTP Authentication Class.
 * PHP Version 5.5.
 *
 * @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 *
 * @author    Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author    Jim Jagielski (jimjag) <[email protected]>
 * @author    Andy Prevost (codeworxtech) <[email protected]>
 * @author    Brent R. Matzelle (original founder)
 * @copyright 2012 - 2020 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license   http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note      This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */

namespace PHPMailer\PHPMailer;

/**
 * PHPMailer POP-Before-SMTP Authentication Class.
 * Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
 * 1) This class does not support APOP authentication.
 * 2) Opening and closing lots of POP3 connections can be quite slow. If you need
 *   to send a batch of emails then just perform the authentication once at the start,
 *   and then loop through your mail sending script. Providing this process doesn't
 *   take longer than the verification period lasts on your POP3 server, you should be fine.
 * 3) This is really ancient technology; you should only need to use it to talk to very old systems.
 * 4) This POP3 class is deliberately lightweight and incomplete, implementing just
 *   enough to do authentication.
 *   If you want a more complete class there are other POP3 classes for PHP available.
 *
 * @author Richard Davey (original author) <[email protected]>
 * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author Jim Jagielski (jimjag) <[email protected]>
 * @author Andy Prevost (codeworxtech) <[email protected]>
 */
class POP3
{
    /**
     * The POP3 PHPMailer Version number.
     *
     * @var string
     */
    const VERSION = '6.1.7';

    /**
     * Default POP3 port number.
     *
     * @var int
     */
    const DEFAULT_PORT = 110;

    /**
     * Default timeout in seconds.
     *
     * @var int
     */
    const DEFAULT_TIMEOUT = 30;

    /**
     * Debug display level.
     * Options: 0 = no, 1+ = yes.
     *
     * @var int
     */
    public $do_debug = 0;

    /**
     * POP3 mail server hostname.
     *
     * @var string
     */
    public $host;

    /**
     * POP3 port number.
     *
     * @var int
     */
    public $port;

    /**
     * POP3 Timeout Value in seconds.
     *
     * @var int
     */
    public $tval;

    /**
     * POP3 username.
     *
     * @var string
     */
    public $username;

    /**
     * POP3 password.
     *
     * @var string
     */
    public $password;

    /**
     * Resource handle for the POP3 connection socket.
     *
     * @var resource
     */
    protected $pop_conn;

    /**
     * Are we connected?
     *
     * @var bool
     */
    protected $connected = false;

    /**
     * Error container.
     *
     * @var array
     */
    protected $errors = [];

    /**
     * Line break constant.
     */
    const LE = "\r\n";

    /**
     * Simple static wrapper for all-in-one POP before SMTP.
     *
     * @param string   $host        The hostname to connect to
     * @param int|bool $port        The port number to connect to
     * @param int|bool $timeout     The timeout value
     * @param string   $username
     * @param string   $password
     * @param int      $debug_level
     *
     * @return bool
     */
    public static function popBeforeSmtp(
        $host,
        $port = false,
        $timeout = false,
        $username = '',
        $password = '',
        $debug_level = 0
    ) {
        $pop = new self();

        return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level);
    }

    /**
     * Authenticate with a POP3 server.
     * A connect, login, disconnect sequence
     * appropriate for POP-before SMTP authorisation.
     *
     * @param string   $host        The hostname to connect to
     * @param int|bool $port        The port number to connect to
     * @param int|bool $timeout     The timeout value
     * @param string   $username
     * @param string   $password
     * @param int      $debug_level
     *
     * @return bool
     */
    public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
    {
        $this->host = $host;
        // If no port value provided, use default
        if (false === $port) {
            $this->port = static::DEFAULT_PORT;
        } else {
            $this->port = (int) $port;
        }
        // If no timeout value provided, use default
        if (false === $timeout) {
            $this->tval = static::DEFAULT_TIMEOUT;
        } else {
            $this->tval = (int) $timeout;
        }
        $this->do_debug = $debug_level;
        $this->username = $username;
        $this->password = $password;
        //  Reset the error log
        $this->errors = [];
        //  connect
        $result = $this->connect($this->host, $this->port, $this->tval);
        if ($result) {
            $login_result = $this->login($this->username, $this->password);
            if ($login_result) {
                $this->disconnect();

                return true;
            }
        }
        // We need to disconnect regardless of whether the login succeeded
        $this->disconnect();

        return false;
    }

    /**
     * Connect to a POP3 server.
     *
     * @param string   $host
     * @param int|bool $port
     * @param int      $tval
     *
     * @return bool
     */
    public function connect($host, $port = false, $tval = 30)
    {
        //  Are we already connected?
        if ($this->connected) {
            return true;
        }

        //On Windows this will raise a PHP Warning error if the hostname doesn't exist.
        //Rather than suppress it with @fsockopen, capture it cleanly instead
        set_error_handler([$this, 'catchWarning']);

        if (false === $port) {
            $port = static::DEFAULT_PORT;
        }

        //  connect to the POP3 server
        $errno = 0;
        $errstr = '';
        $this->pop_conn = fsockopen(
            $host, //  POP3 Host
            $port, //  Port #
            $errno, //  Error Number
            $errstr, //  Error Message
            $tval
        ); //  Timeout (seconds)
        //  Restore the error handler
        restore_error_handler();

        //  Did we connect?
        if (false === $this->pop_conn) {
            //  It would appear not...
            $this->setError(
                "Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr"
            );

            return false;
        }

        //  Increase the stream time-out
        stream_set_timeout($this->pop_conn, $tval, 0);

        //  Get the POP3 server response
        $pop3_response = $this->getResponse();
        //  Check for the +OK
        if ($this->checkResponse($pop3_response)) {
            //  The connection is established and the POP3 server is talking
            $this->connected = true;

            return true;
        }

        return false;
    }

    /**
     * Log in to the POP3 server.
     * Does not support APOP (RFC 2828, 4949).
     *
     * @param string $username
     * @param string $password
     *
     * @return bool
     */
    public function login($username = '', $password = '')
    {
        if (!$this->connected) {
            $this->setError('Not connected to POP3 server');
        }
        if (empty($username)) {
            $username = $this->username;
        }
        if (empty($password)) {
            $password = $this->password;
        }

        // Send the Username
        $this->sendString("USER $username" . static::LE);
        $pop3_response = $this->getResponse();
        if ($this->checkResponse($pop3_response)) {
            // Send the Password
            $this->sendString("PASS $password" . static::LE);
            $pop3_response = $this->getResponse();
            if ($this->checkResponse($pop3_response)) {
                return true;
            }
        }

        return false;
    }

    /**
     * Disconnect from the POP3 server.
     */
    public function disconnect()
    {
        $this->sendString('QUIT');
        //The QUIT command may cause the daemon to exit, which will kill our connection
        //So ignore errors here
        try {
            @fclose($this->pop_conn);
        } catch (Exception $e) {
            //Do nothing
        }
    }

    /**
     * Get a response from the POP3 server.
     *
     * @param int $size The maximum number of bytes to retrieve
     *
     * @return string
     */
    protected function getResponse($size = 128)
    {
        $response = fgets($this->pop_conn, $size);
        if ($this->do_debug >= 1) {
            echo 'Server -> Client: ', $response;
        }

        return $response;
    }

    /**
     * Send raw data to the POP3 server.
     *
     * @param string $string
     *
     * @return int
     */
    protected function sendString($string)
    {
        if ($this->pop_conn) {
            if ($this->do_debug >= 2) { //Show client messages when debug >= 2
                echo 'Client -> Server: ', $string;
            }

            return fwrite($this->pop_conn, $string, strlen($string));
        }

        return 0;
    }

    /**
     * Checks the POP3 server response.
     * Looks for for +OK or -ERR.
     *
     * @param string $string
     *
     * @return bool
     */
    protected function checkResponse($string)
    {
        if (strpos($string, '+OK') !== 0) {
            $this->setError("Server reported an error: $string");

            return false;
        }

        return true;
    }

    /**
     * Add an error to the internal error store.
     * Also display debug output if it's enabled.
     *
     * @param string $error
     */
    protected function setError($error)
    {
        $this->errors[] = $error;
        if ($this->do_debug >= 1) {
            echo '<pre>';
            foreach ($this->errors as $e) {
                print_r($e);
            }
            echo '</pre>';
        }
    }

    /**
     * Get an array of error messages, if any.
     *
     * @return array
     */
    public function getErrors()
    {
        return $this->errors;
    }

    /**
     * POP3 connection error handler.
     *
     * @param int    $errno
     * @param string $errstr
     * @param string $errfile
     * @param int    $errline
     */
    protected function catchWarning($errno, $errstr, $errfile, $errline)
    {
        $this->setError(
            'Connecting to the POP3 server raised a PHP warning:' .
            "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline"
        );
    }
}
PHPMailer/src/Exception.php000064400000002275150766203070011577 0ustar00<?php
/**
 * PHPMailer Exception class.
 * PHP Version 5.5.
 *
 * @see       https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 *
 * @author    Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author    Jim Jagielski (jimjag) <[email protected]>
 * @author    Andy Prevost (codeworxtech) <[email protected]>
 * @author    Brent R. Matzelle (original founder)
 * @copyright 2012 - 2020 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license   http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note      This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */

namespace PHPMailer\PHPMailer;

/**
 * PHPMailer exception handler.
 *
 * @author Marcus Bointon <[email protected]>
 */
class Exception extends \Exception
{
    /**
     * Prettify error message output.
     *
     * @return string
     */
    public function errorMessage()
    {
        return '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n";
    }
}
PHPMailer/src/PHPMailer.php000064400000504556150766203070011433 0ustar00<?php
/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5.5.
 *
 * @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 *
 * @author    Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author    Jim Jagielski (jimjag) <[email protected]>
 * @author    Andy Prevost (codeworxtech) <[email protected]>
 * @author    Brent R. Matzelle (original founder)
 * @copyright 2012 - 2020 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license   http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note      This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */

namespace PHPMailer\PHPMailer;

/**
 * PHPMailer - PHP email creation and transport class.
 *
 * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author Jim Jagielski (jimjag) <[email protected]>
 * @author Andy Prevost (codeworxtech) <[email protected]>
 * @author Brent R. Matzelle (original founder)
 */
class PHPMailer
{
    const CHARSET_ASCII = 'us-ascii';
    const CHARSET_ISO88591 = 'iso-8859-1';
    const CHARSET_UTF8 = 'utf-8';

    const CONTENT_TYPE_PLAINTEXT = 'text/plain';
    const CONTENT_TYPE_TEXT_CALENDAR = 'text/calendar';
    const CONTENT_TYPE_TEXT_HTML = 'text/html';
    const CONTENT_TYPE_MULTIPART_ALTERNATIVE = 'multipart/alternative';
    const CONTENT_TYPE_MULTIPART_MIXED = 'multipart/mixed';
    const CONTENT_TYPE_MULTIPART_RELATED = 'multipart/related';

    const ENCODING_7BIT = '7bit';
    const ENCODING_8BIT = '8bit';
    const ENCODING_BASE64 = 'base64';
    const ENCODING_BINARY = 'binary';
    const ENCODING_QUOTED_PRINTABLE = 'quoted-printable';

    const ENCRYPTION_STARTTLS = 'tls';
    const ENCRYPTION_SMTPS = 'ssl';

    const ICAL_METHOD_REQUEST = 'REQUEST';
    const ICAL_METHOD_PUBLISH = 'PUBLISH';
    const ICAL_METHOD_REPLY = 'REPLY';
    const ICAL_METHOD_ADD = 'ADD';
    const ICAL_METHOD_CANCEL = 'CANCEL';
    const ICAL_METHOD_REFRESH = 'REFRESH';
    const ICAL_METHOD_COUNTER = 'COUNTER';
    const ICAL_METHOD_DECLINECOUNTER = 'DECLINECOUNTER';

    /**
     * Email priority.
     * Options: null (default), 1 = High, 3 = Normal, 5 = low.
     * When null, the header is not set at all.
     *
     * @var int|null
     */
    public $Priority;

    /**
     * The character set of the message.
     *
     * @var string
     */
    public $CharSet = self::CHARSET_ISO88591;

    /**
     * The MIME Content-type of the message.
     *
     * @var string
     */
    public $ContentType = self::CONTENT_TYPE_PLAINTEXT;

    /**
     * The message encoding.
     * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
     *
     * @var string
     */
    public $Encoding = self::ENCODING_8BIT;

    /**
     * Holds the most recent mailer error message.
     *
     * @var string
     */
    public $ErrorInfo = '';

    /**
     * The From email address for the message.
     *
     * @var string
     */
    public $From = 'root@localhost';

    /**
     * The From name of the message.
     *
     * @var string
     */
    public $FromName = 'Root User';

    /**
     * The envelope sender of the message.
     * This will usually be turned into a Return-Path header by the receiver,
     * and is the address that bounces will be sent to.
     * If not empty, will be passed via `-f` to sendmail or as the 'MAIL FROM' value over SMTP.
     *
     * @var string
     */
    public $Sender = '';

    /**
     * The Subject of the message.
     *
     * @var string
     */
    public $Subject = '';

    /**
     * An HTML or plain text message body.
     * If HTML then call isHTML(true).
     *
     * @var string
     */
    public $Body = '';

    /**
     * The plain-text message body.
     * This body can be read by mail clients that do not have HTML email
     * capability such as mutt & Eudora.
     * Clients that can read HTML will view the normal Body.
     *
     * @var string
     */
    public $AltBody = '';

    /**
     * An iCal message part body.
     * Only supported in simple alt or alt_inline message types
     * To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator.
     *
     * @see http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
     * @see http://kigkonsult.se/iCalcreator/
     *
     * @var string
     */
    public $Ical = '';

    /**
     * Value-array of "method" in Contenttype header "text/calendar"
     *
     * @var string[]
     */
    protected static $IcalMethods = [
        self::ICAL_METHOD_REQUEST,
        self::ICAL_METHOD_PUBLISH,
        self::ICAL_METHOD_REPLY,
        self::ICAL_METHOD_ADD,
        self::ICAL_METHOD_CANCEL,
        self::ICAL_METHOD_REFRESH,
        self::ICAL_METHOD_COUNTER,
        self::ICAL_METHOD_DECLINECOUNTER,
    ];

    /**
     * The complete compiled MIME message body.
     *
     * @var string
     */
    protected $MIMEBody = '';

    /**
     * The complete compiled MIME message headers.
     *
     * @var string
     */
    protected $MIMEHeader = '';

    /**
     * Extra headers that createHeader() doesn't fold in.
     *
     * @var string
     */
    protected $mailHeader = '';

    /**
     * Word-wrap the message body to this number of chars.
     * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
     *
     * @see static::STD_LINE_LENGTH
     *
     * @var int
     */
    public $WordWrap = 0;

    /**
     * Which method to use to send mail.
     * Options: "mail", "sendmail", or "smtp".
     *
     * @var string
     */
    public $Mailer = 'mail';

    /**
     * The path to the sendmail program.
     *
     * @var string
     */
    public $Sendmail = '/usr/sbin/sendmail';

    /**
     * Whether mail() uses a fully sendmail-compatible MTA.
     * One which supports sendmail's "-oi -f" options.
     *
     * @var bool
     */
    public $UseSendmailOptions = true;

    /**
     * The email address that a reading confirmation should be sent to, also known as read receipt.
     *
     * @var string
     */
    public $ConfirmReadingTo = '';

    /**
     * The hostname to use in the Message-ID header and as default HELO string.
     * If empty, PHPMailer attempts to find one with, in order,
     * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value
     * 'localhost.localdomain'.
     *
     * @see PHPMailer::$Helo
     *
     * @var string
     */
    public $Hostname = '';

    /**
     * An ID to be used in the Message-ID header.
     * If empty, a unique id will be generated.
     * You can set your own, but it must be in the format "<id@domain>",
     * as defined in RFC5322 section 3.6.4 or it will be ignored.
     *
     * @see https://tools.ietf.org/html/rfc5322#section-3.6.4
     *
     * @var string
     */
    public $MessageID = '';

    /**
     * The message Date to be used in the Date header.
     * If empty, the current date will be added.
     *
     * @var string
     */
    public $MessageDate = '';

    /**
     * SMTP hosts.
     * Either a single hostname or multiple semicolon-delimited hostnames.
     * You can also specify a different port
     * for each host by using this format: [hostname:port]
     * (e.g. "smtp1.example.com:25;smtp2.example.com").
     * You can also specify encryption type, for example:
     * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
     * Hosts will be tried in order.
     *
     * @var string
     */
    public $Host = 'localhost';

    /**
     * The default SMTP server port.
     *
     * @var int
     */
    public $Port = 25;

    /**
     * The SMTP HELO/EHLO name used for the SMTP connection.
     * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find
     * one with the same method described above for $Hostname.
     *
     * @see PHPMailer::$Hostname
     *
     * @var string
     */
    public $Helo = '';

    /**
     * What kind of encryption to use on the SMTP connection.
     * Options: '', static::ENCRYPTION_STARTTLS, or static::ENCRYPTION_SMTPS.
     *
     * @var string
     */
    public $SMTPSecure = '';

    /**
     * Whether to enable TLS encryption automatically if a server supports it,
     * even if `SMTPSecure` is not set to 'tls'.
     * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
     *
     * @var bool
     */
    public $SMTPAutoTLS = true;

    /**
     * Whether to use SMTP authentication.
     * Uses the Username and Password properties.
     *
     * @see PHPMailer::$Username
     * @see PHPMailer::$Password
     *
     * @var bool
     */
    public $SMTPAuth = false;

    /**
     * Options array passed to stream_context_create when connecting via SMTP.
     *
     * @var array
     */
    public $SMTPOptions = [];

    /**
     * SMTP username.
     *
     * @var string
     */
    public $Username = '';

    /**
     * SMTP password.
     *
     * @var string
     */
    public $Password = '';

    /**
     * SMTP auth type.
     * Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2, attempted in that order if not specified.
     *
     * @var string
     */
    public $AuthType = '';

    /**
     * An instance of the PHPMailer OAuth class.
     *
     * @var OAuth
     */
    protected $oauth;

    /**
     * The SMTP server timeout in seconds.
     * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
     *
     * @var int
     */
    public $Timeout = 300;

    /**
     * Comma separated list of DSN notifications
     * 'NEVER' under no circumstances a DSN must be returned to the sender.
     *         If you use NEVER all other notifications will be ignored.
     * 'SUCCESS' will notify you when your mail has arrived at its destination.
     * 'FAILURE' will arrive if an error occurred during delivery.
     * 'DELAY'   will notify you if there is an unusual delay in delivery, but the actual
     *           delivery's outcome (success or failure) is not yet decided.
     *
     * @see https://tools.ietf.org/html/rfc3461 See section 4.1 for more information about NOTIFY
     */
    public $dsn = '';

    /**
     * SMTP class debug output mode.
     * Debug output level.
     * Options:
     * * SMTP::DEBUG_OFF: No output
     * * SMTP::DEBUG_CLIENT: Client messages
     * * SMTP::DEBUG_SERVER: Client and server messages
     * * SMTP::DEBUG_CONNECTION: As SERVER plus connection status
     * * SMTP::DEBUG_LOWLEVEL: Noisy, low-level data output, rarely needed
     *
     * @see SMTP::$do_debug
     *
     * @var int
     */
    public $SMTPDebug = 0;

    /**
     * How to handle debug output.
     * Options:
     * * `echo` Output plain-text as-is, appropriate for CLI
     * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
     * * `error_log` Output to error log as configured in php.ini
     * By default PHPMailer will use `echo` if run from a `cli` or `cli-server` SAPI, `html` otherwise.
     * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
     *
     * ```php
     * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
     * ```
     *
     * Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug`
     * level output is used:
     *
     * ```php
     * $mail->Debugoutput = new myPsr3Logger;
     * ```
     *
     * @see SMTP::$Debugoutput
     *
     * @var string|callable|\Psr\Log\LoggerInterface
     */
    public $Debugoutput = 'echo';

    /**
     * Whether to keep SMTP connection open after each message.
     * If this is set to true then to close the connection
     * requires an explicit call to smtpClose().
     *
     * @var bool
     */
    public $SMTPKeepAlive = false;

    /**
     * Whether to split multiple to addresses into multiple messages
     * or send them all in one message.
     * Only supported in `mail` and `sendmail` transports, not in SMTP.
     *
     * @var bool
     *
     * @deprecated 6.0.0 PHPMailer isn't a mailing list manager!
     */
    public $SingleTo = false;

    /**
     * Storage for addresses when SingleTo is enabled.
     *
     * @var array
     */
    protected $SingleToArray = [];

    /**
     * Whether to generate VERP addresses on send.
     * Only applicable when sending via SMTP.
     *
     * @see https://en.wikipedia.org/wiki/Variable_envelope_return_path
     * @see http://www.postfix.org/VERP_README.html Postfix VERP info
     *
     * @var bool
     */
    public $do_verp = false;

    /**
     * Whether to allow sending messages with an empty body.
     *
     * @var bool
     */
    public $AllowEmpty = false;

    /**
     * DKIM selector.
     *
     * @var string
     */
    public $DKIM_selector = '';

    /**
     * DKIM Identity.
     * Usually the email address used as the source of the email.
     *
     * @var string
     */
    public $DKIM_identity = '';

    /**
     * DKIM passphrase.
     * Used if your key is encrypted.
     *
     * @var string
     */
    public $DKIM_passphrase = '';

    /**
     * DKIM signing domain name.
     *
     * @example 'example.com'
     *
     * @var string
     */
    public $DKIM_domain = '';

    /**
     * DKIM Copy header field values for diagnostic use.
     *
     * @var bool
     */
    public $DKIM_copyHeaderFields = true;

    /**
     * DKIM Extra signing headers.
     *
     * @example ['List-Unsubscribe', 'List-Help']
     *
     * @var array
     */
    public $DKIM_extraHeaders = [];

    /**
     * DKIM private key file path.
     *
     * @var string
     */
    public $DKIM_private = '';

    /**
     * DKIM private key string.
     *
     * If set, takes precedence over `$DKIM_private`.
     *
     * @var string
     */
    public $DKIM_private_string = '';

    /**
     * Callback Action function name.
     *
     * The function that handles the result of the send email action.
     * It is called out by send() for each email sent.
     *
     * Value can be any php callable: http://www.php.net/is_callable
     *
     * Parameters:
     *   bool $result        result of the send action
     *   array   $to            email addresses of the recipients
     *   array   $cc            cc email addresses
     *   array   $bcc           bcc email addresses
     *   string  $subject       the subject
     *   string  $body          the email body
     *   string  $from          email address of sender
     *   string  $extra         extra information of possible use
     *                          "smtp_transaction_id' => last smtp transaction id
     *
     * @var string
     */
    public $action_function = '';

    /**
     * What to put in the X-Mailer header.
     * Options: An empty string for PHPMailer default, whitespace/null for none, or a string to use.
     *
     * @var string|null
     */
    public $XMailer = '';

    /**
     * Which validator to use by default when validating email addresses.
     * May be a callable to inject your own validator, but there are several built-in validators.
     * The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option.
     *
     * @see PHPMailer::validateAddress()
     *
     * @var string|callable
     */
    public static $validator = 'php';

    /**
     * An instance of the SMTP sender class.
     *
     * @var SMTP
     */
    protected $smtp;

    /**
     * The array of 'to' names and addresses.
     *
     * @var array
     */
    protected $to = [];

    /**
     * The array of 'cc' names and addresses.
     *
     * @var array
     */
    protected $cc = [];

    /**
     * The array of 'bcc' names and addresses.
     *
     * @var array
     */
    protected $bcc = [];

    /**
     * The array of reply-to names and addresses.
     *
     * @var array
     */
    protected $ReplyTo = [];

    /**
     * An array of all kinds of addresses.
     * Includes all of $to, $cc, $bcc.
     *
     * @see PHPMailer::$to
     * @see PHPMailer::$cc
     * @see PHPMailer::$bcc
     *
     * @var array
     */
    protected $all_recipients = [];

    /**
     * An array of names and addresses queued for validation.
     * In send(), valid and non duplicate entries are moved to $all_recipients
     * and one of $to, $cc, or $bcc.
     * This array is used only for addresses with IDN.
     *
     * @see PHPMailer::$to
     * @see PHPMailer::$cc
     * @see PHPMailer::$bcc
     * @see PHPMailer::$all_recipients
     *
     * @var array
     */
    protected $RecipientsQueue = [];

    /**
     * An array of reply-to names and addresses queued for validation.
     * In send(), valid and non duplicate entries are moved to $ReplyTo.
     * This array is used only for addresses with IDN.
     *
     * @see PHPMailer::$ReplyTo
     *
     * @var array
     */
    protected $ReplyToQueue = [];

    /**
     * The array of attachments.
     *
     * @var array
     */
    protected $attachment = [];

    /**
     * The array of custom headers.
     *
     * @var array
     */
    protected $CustomHeader = [];

    /**
     * The most recent Message-ID (including angular brackets).
     *
     * @var string
     */
    protected $lastMessageID = '';

    /**
     * The message's MIME type.
     *
     * @var string
     */
    protected $message_type = '';

    /**
     * The array of MIME boundary strings.
     *
     * @var array
     */
    protected $boundary = [];

    /**
     * The array of available languages.
     *
     * @var array
     */
    protected $language = [];

    /**
     * The number of errors encountered.
     *
     * @var int
     */
    protected $error_count = 0;

    /**
     * The S/MIME certificate file path.
     *
     * @var string
     */
    protected $sign_cert_file = '';

    /**
     * The S/MIME key file path.
     *
     * @var string
     */
    protected $sign_key_file = '';

    /**
     * The optional S/MIME extra certificates ("CA Chain") file path.
     *
     * @var string
     */
    protected $sign_extracerts_file = '';

    /**
     * The S/MIME password for the key.
     * Used only if the key is encrypted.
     *
     * @var string
     */
    protected $sign_key_pass = '';

    /**
     * Whether to throw exceptions for errors.
     *
     * @var bool
     */
    protected $exceptions = false;

    /**
     * Unique ID used for message ID and boundaries.
     *
     * @var string
     */
    protected $uniqueid = '';

    /**
     * The PHPMailer Version number.
     *
     * @var string
     */
    const VERSION = '6.1.7';

    /**
     * Error severity: message only, continue processing.
     *
     * @var int
     */
    const STOP_MESSAGE = 0;

    /**
     * Error severity: message, likely ok to continue processing.
     *
     * @var int
     */
    const STOP_CONTINUE = 1;

    /**
     * Error severity: message, plus full stop, critical error reached.
     *
     * @var int
     */
    const STOP_CRITICAL = 2;

    /**
     * The SMTP standard CRLF line break.
     * If you want to change line break format, change static::$LE, not this.
     */
    const CRLF = "\r\n";

    /**
     * "Folding White Space" a white space string used for line folding.
     */
    const FWS = ' ';

    /**
     * SMTP RFC standard line ending; Carriage Return, Line Feed.
     *
     * @var string
     */
    protected static $LE = self::CRLF;

    /**
     * The maximum line length supported by mail().
     *
     * Background: mail() will sometimes corrupt messages
     * with headers headers longer than 65 chars, see #818.
     *
     * @var int
     */
    const MAIL_MAX_LINE_LENGTH = 63;

    /**
     * The maximum line length allowed by RFC 2822 section 2.1.1.
     *
     * @var int
     */
    const MAX_LINE_LENGTH = 998;

    /**
     * The lower maximum line length allowed by RFC 2822 section 2.1.1.
     * This length does NOT include the line break
     * 76 means that lines will be 77 or 78 chars depending on whether
     * the line break format is LF or CRLF; both are valid.
     *
     * @var int
     */
    const STD_LINE_LENGTH = 76;

    /**
     * Constructor.
     *
     * @param bool $exceptions Should we throw external exceptions?
     */
    public function __construct($exceptions = null)
    {
        if (null !== $exceptions) {
            $this->exceptions = (bool) $exceptions;
        }
        //Pick an appropriate debug output format automatically
        $this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html');
    }

    /**
     * Destructor.
     */
    public function __destruct()
    {
        //Close any open SMTP connection nicely
        $this->smtpClose();
    }

    /**
     * Call mail() in a safe_mode-aware fashion.
     * Also, unless sendmail_path points to sendmail (or something that
     * claims to be sendmail), don't pass params (not a perfect fix,
     * but it will do).
     *
     * @param string      $to      To
     * @param string      $subject Subject
     * @param string      $body    Message Body
     * @param string      $header  Additional Header(s)
     * @param string|null $params  Params
     *
     * @return bool
     */
    private function mailPassthru($to, $subject, $body, $header, $params)
    {
        //Check overloading of mail function to avoid double-encoding
        if (ini_get('mbstring.func_overload') & 1) {
            $subject = $this->secureHeader($subject);
        } else {
            $subject = $this->encodeHeader($this->secureHeader($subject));
        }
        //Calling mail() with null params breaks
        if (!$this->UseSendmailOptions || null === $params) {
            $result = @mail($to, $subject, $body, $header);
        } else {
            $result = @mail($to, $subject, $body, $header, $params);
        }

        return $result;
    }

    /**
     * Output debugging info via user-defined method.
     * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
     *
     * @see PHPMailer::$Debugoutput
     * @see PHPMailer::$SMTPDebug
     *
     * @param string $str
     */
    protected function edebug($str)
    {
        if ($this->SMTPDebug <= 0) {
            return;
        }
        //Is this a PSR-3 logger?
        if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
            $this->Debugoutput->debug($str);

            return;
        }
        //Avoid clash with built-in function names
        if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) {
            call_user_func($this->Debugoutput, $str, $this->SMTPDebug);

            return;
        }
        switch ($this->Debugoutput) {
            case 'error_log':
                //Don't output, just log
                /** @noinspection ForgottenDebugOutputInspection */
                error_log($str);
                break;
            case 'html':
                //Cleans up output a bit for a better looking, HTML-safe output
                echo htmlentities(
                    preg_replace('/[\r\n]+/', '', $str),
                    ENT_QUOTES,
                    'UTF-8'
                ), "<br>\n";
                break;
            case 'echo':
            default:
                //Normalize line breaks
                $str = preg_replace('/\r\n|\r/m', "\n", $str);
                echo gmdate('Y-m-d H:i:s'),
                "\t",
                    //Trim trailing space
                trim(
                    //Indent for readability, except for trailing break
                    str_replace(
                        "\n",
                        "\n                   \t                  ",
                        trim($str)
                    )
                ),
                "\n";
        }
    }

    /**
     * Sets message type to HTML or plain.
     *
     * @param bool $isHtml True for HTML mode
     */
    public function isHTML($isHtml = true)
    {
        if ($isHtml) {
            $this->ContentType = static::CONTENT_TYPE_TEXT_HTML;
        } else {
            $this->ContentType = static::CONTENT_TYPE_PLAINTEXT;
        }
    }

    /**
     * Send messages using SMTP.
     */
    public function isSMTP()
    {
        $this->Mailer = 'smtp';
    }

    /**
     * Send messages using PHP's mail() function.
     */
    public function isMail()
    {
        $this->Mailer = 'mail';
    }

    /**
     * Send messages using $Sendmail.
     */
    public function isSendmail()
    {
        $ini_sendmail_path = ini_get('sendmail_path');

        if (false === stripos($ini_sendmail_path, 'sendmail')) {
            $this->Sendmail = '/usr/sbin/sendmail';
        } else {
            $this->Sendmail = $ini_sendmail_path;
        }
        $this->Mailer = 'sendmail';
    }

    /**
     * Send messages using qmail.
     */
    public function isQmail()
    {
        $ini_sendmail_path = ini_get('sendmail_path');

        if (false === stripos($ini_sendmail_path, 'qmail')) {
            $this->Sendmail = '/var/qmail/bin/qmail-inject';
        } else {
            $this->Sendmail = $ini_sendmail_path;
        }
        $this->Mailer = 'qmail';
    }

    /**
     * Add a "To" address.
     *
     * @param string $address The email address to send to
     * @param string $name
     *
     * @throws Exception
     *
     * @return bool true on success, false if address already used or invalid in some way
     */
    public function addAddress($address, $name = '')
    {
        return $this->addOrEnqueueAnAddress('to', $address, $name);
    }

    /**
     * Add a "CC" address.
     *
     * @param string $address The email address to send to
     * @param string $name
     *
     * @throws Exception
     *
     * @return bool true on success, false if address already used or invalid in some way
     */
    public function addCC($address, $name = '')
    {
        return $this->addOrEnqueueAnAddress('cc', $address, $name);
    }

    /**
     * Add a "BCC" address.
     *
     * @param string $address The email address to send to
     * @param string $name
     *
     * @throws Exception
     *
     * @return bool true on success, false if address already used or invalid in some way
     */
    public function addBCC($address, $name = '')
    {
        return $this->addOrEnqueueAnAddress('bcc', $address, $name);
    }

    /**
     * Add a "Reply-To" address.
     *
     * @param string $address The email address to reply to
     * @param string $name
     *
     * @throws Exception
     *
     * @return bool true on success, false if address already used or invalid in some way
     */
    public function addReplyTo($address, $name = '')
    {
        return $this->addOrEnqueueAnAddress('Reply-To', $address, $name);
    }

    /**
     * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer
     * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still
     * be modified after calling this function), addition of such addresses is delayed until send().
     * Addresses that have been added already return false, but do not throw exceptions.
     *
     * @param string $kind    One of 'to', 'cc', 'bcc', or 'ReplyTo'
     * @param string $address The email address to send, resp. to reply to
     * @param string $name
     *
     * @throws Exception
     *
     * @return bool true on success, false if address already used or invalid in some way
     */
    protected function addOrEnqueueAnAddress($kind, $address, $name)
    {
        $address = trim($address);
        $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
        $pos = strrpos($address, '@');
        if (false === $pos) {
            // At-sign is missing.
            $error_message = sprintf(
                '%s (%s): %s',
                $this->lang('invalid_address'),
                $kind,
                $address
            );
            $this->setError($error_message);
            $this->edebug($error_message);
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

            return false;
        }
        $params = [$kind, $address, $name];
        // Enqueue addresses with IDN until we know the PHPMailer::$CharSet.
        if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) {
            if ('Reply-To' !== $kind) {
                if (!array_key_exists($address, $this->RecipientsQueue)) {
                    $this->RecipientsQueue[$address] = $params;

                    return true;
                }
            } elseif (!array_key_exists($address, $this->ReplyToQueue)) {
                $this->ReplyToQueue[$address] = $params;

                return true;
            }

            return false;
        }

        // Immediately add standard addresses without IDN.
        return call_user_func_array([$this, 'addAnAddress'], $params);
    }

    /**
     * Add an address to one of the recipient arrays or to the ReplyTo array.
     * Addresses that have been added already return false, but do not throw exceptions.
     *
     * @param string $kind    One of 'to', 'cc', 'bcc', or 'ReplyTo'
     * @param string $address The email address to send, resp. to reply to
     * @param string $name
     *
     * @throws Exception
     *
     * @return bool true on success, false if address already used or invalid in some way
     */
    protected function addAnAddress($kind, $address, $name = '')
    {
        if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) {
            $error_message = sprintf(
                '%s: %s',
                $this->lang('Invalid recipient kind'),
                $kind
            );
            $this->setError($error_message);
            $this->edebug($error_message);
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

            return false;
        }
        if (!static::validateAddress($address)) {
            $error_message = sprintf(
                '%s (%s): %s',
                $this->lang('invalid_address'),
                $kind,
                $address
            );
            $this->setError($error_message);
            $this->edebug($error_message);
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

            return false;
        }
        if ('Reply-To' !== $kind) {
            if (!array_key_exists(strtolower($address), $this->all_recipients)) {
                $this->{$kind}[] = [$address, $name];
                $this->all_recipients[strtolower($address)] = true;

                return true;
            }
        } elseif (!array_key_exists(strtolower($address), $this->ReplyTo)) {
            $this->ReplyTo[strtolower($address)] = [$address, $name];

            return true;
        }

        return false;
    }

    /**
     * Parse and validate a string containing one or more RFC822-style comma-separated email addresses
     * of the form "display name <address>" into an array of name/address pairs.
     * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available.
     * Note that quotes in the name part are removed.
     *
     * @see http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation
     *
     * @param string $addrstr The address list string
     * @param bool   $useimap Whether to use the IMAP extension to parse the list
     *
     * @return array
     */
    public static function parseAddresses($addrstr, $useimap = true)
    {
        $addresses = [];
        if ($useimap && function_exists('imap_rfc822_parse_adrlist')) {
            //Use this built-in parser if it's available
            $list = imap_rfc822_parse_adrlist($addrstr, '');
            foreach ($list as $address) {
                if (('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress(
                    $address->mailbox . '@' . $address->host
                )) {
                    $addresses[] = [
                        'name' => (property_exists($address, 'personal') ? $address->personal : ''),
                        'address' => $address->mailbox . '@' . $address->host,
                    ];
                }
            }
        } else {
            //Use this simpler parser
            $list = explode(',', $addrstr);
            foreach ($list as $address) {
                $address = trim($address);
                //Is there a separate name part?
                if (strpos($address, '<') === false) {
                    //No separate name, just use the whole thing
                    if (static::validateAddress($address)) {
                        $addresses[] = [
                            'name' => '',
                            'address' => $address,
                        ];
                    }
                } else {
                    list($name, $email) = explode('<', $address);
                    $email = trim(str_replace('>', '', $email));
                    if (static::validateAddress($email)) {
                        $addresses[] = [
                            'name' => trim(str_replace(['"', "'"], '', $name)),
                            'address' => $email,
                        ];
                    }
                }
            }
        }

        return $addresses;
    }

    /**
     * Set the From and FromName properties.
     *
     * @param string $address
     * @param string $name
     * @param bool   $auto    Whether to also set the Sender address, defaults to true
     *
     * @throws Exception
     *
     * @return bool
     */
    public function setFrom($address, $name = '', $auto = true)
    {
        $address = trim($address);
        $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
        // Don't validate now addresses with IDN. Will be done in send().
        $pos = strrpos($address, '@');
        if ((false === $pos)
            || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported())
            && !static::validateAddress($address))
        ) {
            $error_message = sprintf(
                '%s (From): %s',
                $this->lang('invalid_address'),
                $address
            );
            $this->setError($error_message);
            $this->edebug($error_message);
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

            return false;
        }
        $this->From = $address;
        $this->FromName = $name;
        if ($auto && empty($this->Sender)) {
            $this->Sender = $address;
        }

        return true;
    }

    /**
     * Return the Message-ID header of the last email.
     * Technically this is the value from the last time the headers were created,
     * but it's also the message ID of the last sent message except in
     * pathological cases.
     *
     * @return string
     */
    public function getLastMessageID()
    {
        return $this->lastMessageID;
    }

    /**
     * Check that a string looks like an email address.
     * Validation patterns supported:
     * * `auto` Pick best pattern automatically;
     * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0;
     * * `pcre` Use old PCRE implementation;
     * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL;
     * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
     * * `noregex` Don't use a regex: super fast, really dumb.
     * Alternatively you may pass in a callable to inject your own validator, for example:
     *
     * ```php
     * PHPMailer::validateAddress('[email protected]', function($address) {
     *     return (strpos($address, '@') !== false);
     * });
     * ```
     *
     * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator.
     *
     * @param string          $address       The email address to check
     * @param string|callable $patternselect Which pattern to use
     *
     * @return bool
     */
    public static function validateAddress($address, $patternselect = null)
    {
        if (null === $patternselect) {
            $patternselect = static::$validator;
        }
        if (is_callable($patternselect)) {
            return call_user_func($patternselect, $address);
        }
        //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
        if (strpos($address, "\n") !== false || strpos($address, "\r") !== false) {
            return false;
        }
        switch ($patternselect) {
            case 'pcre': //Kept for BC
            case 'pcre8':
                /*
                 * A more complex and more permissive version of the RFC5322 regex on which FILTER_VALIDATE_EMAIL
                 * is based.
                 * In addition to the addresses allowed by filter_var, also permits:
                 *  * dotless domains: `a@b`
                 *  * comments: `1234 @ local(blah) .machine .example`
                 *  * quoted elements: `'"test blah"@example.org'`
                 *  * numeric TLDs: `[email protected]`
                 *  * unbracketed IPv4 literals: `[email protected]`
                 *  * IPv6 literals: 'first.last@[IPv6:a1::]'
                 * Not all of these will necessarily work for sending!
                 *
                 * @see       http://squiloople.com/2009/12/20/email-address-validation/
                 * @copyright 2009-2010 Michael Rushton
                 * Feel free to use and redistribute this code. But please keep this copyright notice.
                 */
                return (bool) preg_match(
                    '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
                    '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
                    '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
                    '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
                    '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
                    '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
                    '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
                    '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
                    '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
                    $address
                );
            case 'html5':
                /*
                 * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
                 *
                 * @see https://html.spec.whatwg.org/#e-mail-state-(type=email)
                 */
                return (bool) preg_match(
                    '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
                    '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
                    $address
                );
            case 'php':
            default:
                return filter_var($address, FILTER_VALIDATE_EMAIL) !== false;
        }
    }

    /**
     * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the
     * `intl` and `mbstring` PHP extensions.
     *
     * @return bool `true` if required functions for IDN support are present
     */
    public static function idnSupported()
    {
        return function_exists('idn_to_ascii') && function_exists('mb_convert_encoding');
    }

    /**
     * Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
     * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet.
     * This function silently returns unmodified address if:
     * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form)
     * - Conversion to punycode is impossible (e.g. required PHP functions are not available)
     *   or fails for any reason (e.g. domain contains characters not allowed in an IDN).
     *
     * @see PHPMailer::$CharSet
     *
     * @param string $address The email address to convert
     *
     * @return string The encoded address in ASCII form
     */
    public function punyencodeAddress($address)
    {
        // Verify we have required functions, CharSet, and at-sign.
        $pos = strrpos($address, '@');
        if (!empty($this->CharSet) &&
            false !== $pos &&
            static::idnSupported()
        ) {
            $domain = substr($address, ++$pos);
            // Verify CharSet string is a valid one, and domain properly encoded in this CharSet.
            if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) {
                $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet);
                //Ignore IDE complaints about this line - method signature changed in PHP 5.4
                $errorcode = 0;
                if (defined('INTL_IDNA_VARIANT_UTS46')) {
                    $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46);
                } elseif (defined('INTL_IDNA_VARIANT_2003')) {
                    $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_2003);
                } else {
                    $punycode = idn_to_ascii($domain, $errorcode);
                }
                if (false !== $punycode) {
                    return substr($address, 0, $pos) . $punycode;
                }
            }
        }

        return $address;
    }

    /**
     * Create a message and send it.
     * Uses the sending method specified by $Mailer.
     *
     * @throws Exception
     *
     * @return bool false on error - See the ErrorInfo property for details of the error
     */
    public function send()
    {
        try {
            if (!$this->preSend()) {
                return false;
            }

            return $this->postSend();
        } catch (Exception $exc) {
            $this->mailHeader = '';
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return false;
        }
    }

    /**
     * Prepare a message for sending.
     *
     * @throws Exception
     *
     * @return bool
     */
    public function preSend()
    {
        if ('smtp' === $this->Mailer
            || ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0)
        ) {
            //SMTP mandates RFC-compliant line endings
            //and it's also used with mail() on Windows
            static::setLE(self::CRLF);
        } else {
            //Maintain backward compatibility with legacy Linux command line mailers
            static::setLE(PHP_EOL);
        }
        //Check for buggy PHP versions that add a header with an incorrect line break
        if ('mail' === $this->Mailer
            && ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017)
                || (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103))
            && ini_get('mail.add_x_header') === '1'
            && stripos(PHP_OS, 'WIN') === 0
        ) {
            trigger_error(
                'Your version of PHP is affected by a bug that may result in corrupted messages.' .
                ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' .
                ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.',
                E_USER_WARNING
            );
        }

        try {
            $this->error_count = 0; // Reset errors
            $this->mailHeader = '';

            // Dequeue recipient and Reply-To addresses with IDN
            foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) {
                $params[1] = $this->punyencodeAddress($params[1]);
                call_user_func_array([$this, 'addAnAddress'], $params);
            }
            if (count($this->to) + count($this->cc) + count($this->bcc) < 1) {
                throw new Exception($this->lang('provide_address'), self::STOP_CRITICAL);
            }

            // Validate From, Sender, and ConfirmReadingTo addresses
            foreach (['From', 'Sender', 'ConfirmReadingTo'] as $address_kind) {
                $this->$address_kind = trim($this->$address_kind);
                if (empty($this->$address_kind)) {
                    continue;
                }
                $this->$address_kind = $this->punyencodeAddress($this->$address_kind);
                if (!static::validateAddress($this->$address_kind)) {
                    $error_message = sprintf(
                        '%s (%s): %s',
                        $this->lang('invalid_address'),
                        $address_kind,
                        $this->$address_kind
                    );
                    $this->setError($error_message);
                    $this->edebug($error_message);
                    if ($this->exceptions) {
                        throw new Exception($error_message);
                    }

                    return false;
                }
            }

            // Set whether the message is multipart/alternative
            if ($this->alternativeExists()) {
                $this->ContentType = static::CONTENT_TYPE_MULTIPART_ALTERNATIVE;
            }

            $this->setMessageType();
            // Refuse to send an empty message unless we are specifically allowing it
            if (!$this->AllowEmpty && empty($this->Body)) {
                throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
            }

            //Trim subject consistently
            $this->Subject = trim($this->Subject);
            // Create body before headers in case body makes changes to headers (e.g. altering transfer encoding)
            $this->MIMEHeader = '';
            $this->MIMEBody = $this->createBody();
            // createBody may have added some headers, so retain them
            $tempheaders = $this->MIMEHeader;
            $this->MIMEHeader = $this->createHeader();
            $this->MIMEHeader .= $tempheaders;

            // To capture the complete message when using mail(), create
            // an extra header list which createHeader() doesn't fold in
            if ('mail' === $this->Mailer) {
                if (count($this->to) > 0) {
                    $this->mailHeader .= $this->addrAppend('To', $this->to);
                } else {
                    $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
                }
                $this->mailHeader .= $this->headerLine(
                    'Subject',
                    $this->encodeHeader($this->secureHeader($this->Subject))
                );
            }

            // Sign with DKIM if enabled
            if (!empty($this->DKIM_domain)
                && !empty($this->DKIM_selector)
                && (!empty($this->DKIM_private_string)
                    || (!empty($this->DKIM_private)
                        && static::isPermittedPath($this->DKIM_private)
                        && file_exists($this->DKIM_private)
                    )
                )
            ) {
                $header_dkim = $this->DKIM_Add(
                    $this->MIMEHeader . $this->mailHeader,
                    $this->encodeHeader($this->secureHeader($this->Subject)),
                    $this->MIMEBody
                );
                $this->MIMEHeader = static::stripTrailingWSP($this->MIMEHeader) . static::$LE .
                    static::normalizeBreaks($header_dkim) . static::$LE;
            }

            return true;
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return false;
        }
    }

    /**
     * Actually send a message via the selected mechanism.
     *
     * @throws Exception
     *
     * @return bool
     */
    public function postSend()
    {
        try {
            // Choose the mailer and send through it
            switch ($this->Mailer) {
                case 'sendmail':
                case 'qmail':
                    return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
                case 'smtp':
                    return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
                case 'mail':
                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
                default:
                    $sendMethod = $this->Mailer . 'Send';
                    if (method_exists($this, $sendMethod)) {
                        return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
                    }

                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
            }
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            $this->edebug($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }
        }

        return false;
    }

    /**
     * Send mail using the $Sendmail program.
     *
     * @see PHPMailer::$Sendmail
     *
     * @param string $header The message headers
     * @param string $body   The message body
     *
     * @throws Exception
     *
     * @return bool
     */
    protected function sendmailSend($header, $body)
    {
        $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;

        // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
        if (!empty($this->Sender) && self::isShellSafe($this->Sender)) {
            if ('qmail' === $this->Mailer) {
                $sendmailFmt = '%s -f%s';
            } else {
                $sendmailFmt = '%s -oi -f%s -t';
            }
        } elseif ('qmail' === $this->Mailer) {
            $sendmailFmt = '%s';
        } else {
            $sendmailFmt = '%s -oi -t';
        }

        $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender);

        if ($this->SingleTo) {
            foreach ($this->SingleToArray as $toAddr) {
                $mail = @popen($sendmail, 'w');
                if (!$mail) {
                    throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
                }
                fwrite($mail, 'To: ' . $toAddr . "\n");
                fwrite($mail, $header);
                fwrite($mail, $body);
                $result = pclose($mail);
                $this->doCallback(
                    ($result === 0),
                    [$toAddr],
                    $this->cc,
                    $this->bcc,
                    $this->Subject,
                    $body,
                    $this->From,
                    []
                );
                if (0 !== $result) {
                    throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
                }
            }
        } else {
            $mail = @popen($sendmail, 'w');
            if (!$mail) {
                throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
            }
            fwrite($mail, $header);
            fwrite($mail, $body);
            $result = pclose($mail);
            $this->doCallback(
                ($result === 0),
                $this->to,
                $this->cc,
                $this->bcc,
                $this->Subject,
                $body,
                $this->From,
                []
            );
            if (0 !== $result) {
                throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
            }
        }

        return true;
    }

    /**
     * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
     * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.
     *
     * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report
     *
     * @param string $string The string to be validated
     *
     * @return bool
     */
    protected static function isShellSafe($string)
    {
        // Future-proof
        if (escapeshellcmd($string) !== $string
            || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""])
        ) {
            return false;
        }

        $length = strlen($string);

        for ($i = 0; $i < $length; ++$i) {
            $c = $string[$i];

            // All other characters have a special meaning in at least one common shell, including = and +.
            // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.
            // Note that this does permit non-Latin alphanumeric characters based on the current locale.
            if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
                return false;
            }
        }

        return true;
    }

    /**
     * Check whether a file path is of a permitted type.
     * Used to reject URLs and phar files from functions that access local file paths,
     * such as addAttachment.
     *
     * @param string $path A relative or absolute path to a file
     *
     * @return bool
     */
    protected static function isPermittedPath($path)
    {
        return !preg_match('#^[a-z]+://#i', $path);
    }

    /**
     * Send mail using the PHP mail() function.
     *
     * @see http://www.php.net/manual/en/book.mail.php
     *
     * @param string $header The message headers
     * @param string $body   The message body
     *
     * @throws Exception
     *
     * @return bool
     */
    protected function mailSend($header, $body)
    {
        $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;

        $toArr = [];
        foreach ($this->to as $toaddr) {
            $toArr[] = $this->addrFormat($toaddr);
        }
        $to = implode(', ', $toArr);

        $params = null;
        //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
        //A space after `-f` is optional, but there is a long history of its presence
        //causing problems, so we don't use one
        //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
        //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html
        //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
        //Example problem: https://www.drupal.org/node/1057954
        // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
        if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) {
            $params = sprintf('-f%s', $this->Sender);
        }
        if (!empty($this->Sender) && static::validateAddress($this->Sender)) {
            $old_from = ini_get('sendmail_from');
            ini_set('sendmail_from', $this->Sender);
        }
        $result = false;
        if ($this->SingleTo && count($toArr) > 1) {
            foreach ($toArr as $toAddr) {
                $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
                $this->doCallback($result, [$toAddr], $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
            }
        } else {
            $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
            $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
        }
        if (isset($old_from)) {
            ini_set('sendmail_from', $old_from);
        }
        if (!$result) {
            throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL);
        }

        return true;
    }

    /**
     * Get an instance to use for SMTP operations.
     * Override this function to load your own SMTP implementation,
     * or set one with setSMTPInstance.
     *
     * @return SMTP
     */
    public function getSMTPInstance()
    {
        if (!is_object($this->smtp)) {
            $this->smtp = new SMTP();
        }

        return $this->smtp;
    }

    /**
     * Provide an instance to use for SMTP operations.
     *
     * @return SMTP
     */
    public function setSMTPInstance(SMTP $smtp)
    {
        $this->smtp = $smtp;

        return $this->smtp;
    }

    /**
     * Send mail via SMTP.
     * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
     *
     * @see PHPMailer::setSMTPInstance() to use a different class.
     *
     * @uses \PHPMailer\PHPMailer\SMTP
     *
     * @param string $header The message headers
     * @param string $body   The message body
     *
     * @throws Exception
     *
     * @return bool
     */
    protected function smtpSend($header, $body)
    {
        $header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
        $bad_rcpt = [];
        if (!$this->smtpConnect($this->SMTPOptions)) {
            throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
        }
        //Sender already validated in preSend()
        if ('' === $this->Sender) {
            $smtp_from = $this->From;
        } else {
            $smtp_from = $this->Sender;
        }
        if (!$this->smtp->mail($smtp_from)) {
            $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
            throw new Exception($this->ErrorInfo, self::STOP_CRITICAL);
        }

        $callbacks = [];
        // Attempt to send to all recipients
        foreach ([$this->to, $this->cc, $this->bcc] as $togroup) {
            foreach ($togroup as $to) {
                if (!$this->smtp->recipient($to[0], $this->dsn)) {
                    $error = $this->smtp->getError();
                    $bad_rcpt[] = ['to' => $to[0], 'error' => $error['detail']];
                    $isSent = false;
                } else {
                    $isSent = true;
                }

                $callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]];
            }
        }

        // Only send the DATA command if we have viable recipients
        if ((count($this->all_recipients) > count($bad_rcpt)) && !$this->smtp->data($header . $body)) {
            throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL);
        }

        $smtp_transaction_id = $this->smtp->getLastTransactionID();

        if ($this->SMTPKeepAlive) {
            $this->smtp->reset();
        } else {
            $this->smtp->quit();
            $this->smtp->close();
        }

        foreach ($callbacks as $cb) {
            $this->doCallback(
                $cb['issent'],
                [$cb['to']],
                [],
                [],
                $this->Subject,
                $body,
                $this->From,
                ['smtp_transaction_id' => $smtp_transaction_id]
            );
        }

        //Create error message for any bad addresses
        if (count($bad_rcpt) > 0) {
            $errstr = '';
            foreach ($bad_rcpt as $bad) {
                $errstr .= $bad['to'] . ': ' . $bad['error'];
            }
            throw new Exception($this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE);
        }

        return true;
    }

    /**
     * Initiate a connection to an SMTP server.
     * Returns false if the operation failed.
     *
     * @param array $options An array of options compatible with stream_context_create()
     *
     * @throws Exception
     *
     * @uses \PHPMailer\PHPMailer\SMTP
     *
     * @return bool
     */
    public function smtpConnect($options = null)
    {
        if (null === $this->smtp) {
            $this->smtp = $this->getSMTPInstance();
        }

        //If no options are provided, use whatever is set in the instance
        if (null === $options) {
            $options = $this->SMTPOptions;
        }

        // Already connected?
        if ($this->smtp->connected()) {
            return true;
        }

        $this->smtp->setTimeout($this->Timeout);
        $this->smtp->setDebugLevel($this->SMTPDebug);
        $this->smtp->setDebugOutput($this->Debugoutput);
        $this->smtp->setVerp($this->do_verp);
        $hosts = explode(';', $this->Host);
        $lastexception = null;

        foreach ($hosts as $hostentry) {
            $hostinfo = [];
            if (!preg_match(
                '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/',
                trim($hostentry),
                $hostinfo
            )) {
                $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry));
                // Not a valid host entry
                continue;
            }
            // $hostinfo[1]: optional ssl or tls prefix
            // $hostinfo[2]: the hostname
            // $hostinfo[3]: optional port number
            // The host string prefix can temporarily override the current setting for SMTPSecure
            // If it's not specified, the default value is used

            //Check the host name is a valid name or IP address before trying to use it
            if (!static::isValidHost($hostinfo[2])) {
                $this->edebug($this->lang('invalid_host') . ' ' . $hostinfo[2]);
                continue;
            }
            $prefix = '';
            $secure = $this->SMTPSecure;
            $tls = (static::ENCRYPTION_STARTTLS === $this->SMTPSecure);
            if ('ssl' === $hostinfo[1] || ('' === $hostinfo[1] && static::ENCRYPTION_SMTPS === $this->SMTPSecure)) {
                $prefix = 'ssl://';
                $tls = false; // Can't have SSL and TLS at the same time
                $secure = static::ENCRYPTION_SMTPS;
            } elseif ('tls' === $hostinfo[1]) {
                $tls = true;
                // tls doesn't use a prefix
                $secure = static::ENCRYPTION_STARTTLS;
            }
            //Do we need the OpenSSL extension?
            $sslext = defined('OPENSSL_ALGO_SHA256');
            if (static::ENCRYPTION_STARTTLS === $secure || static::ENCRYPTION_SMTPS === $secure) {
                //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
                if (!$sslext) {
                    throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL);
                }
            }
            $host = $hostinfo[2];
            $port = $this->Port;
            if (
                array_key_exists(3, $hostinfo) &&
                is_numeric($hostinfo[3]) &&
                $hostinfo[3] > 0 &&
                $hostinfo[3] < 65536
            ) {
                $port = (int) $hostinfo[3];
            }
            if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
                try {
                    if ($this->Helo) {
                        $hello = $this->Helo;
                    } else {
                        $hello = $this->serverHostname();
                    }
                    $this->smtp->hello($hello);
                    //Automatically enable TLS encryption if:
                    // * it's not disabled
                    // * we have openssl extension
                    // * we are not already using SSL
                    // * the server offers STARTTLS
                    if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) {
                        $tls = true;
                    }
                    if ($tls) {
                        if (!$this->smtp->startTLS()) {
                            throw new Exception($this->lang('connect_host'));
                        }
                        // We must resend EHLO after TLS negotiation
                        $this->smtp->hello($hello);
                    }
                    if ($this->SMTPAuth && !$this->smtp->authenticate(
                        $this->Username,
                        $this->Password,
                        $this->AuthType,
                        $this->oauth
                    )) {
                        throw new Exception($this->lang('authenticate'));
                    }

                    return true;
                } catch (Exception $exc) {
                    $lastexception = $exc;
                    $this->edebug($exc->getMessage());
                    // We must have connected, but then failed TLS or Auth, so close connection nicely
                    $this->smtp->quit();
                }
            }
        }
        // If we get here, all connection attempts have failed, so close connection hard
        $this->smtp->close();
        // As we've caught all exceptions, just report whatever the last one was
        if ($this->exceptions && null !== $lastexception) {
            throw $lastexception;
        }

        return false;
    }

    /**
     * Close the active SMTP session if one exists.
     */
    public function smtpClose()
    {
        if ((null !== $this->smtp) && $this->smtp->connected()) {
            $this->smtp->quit();
            $this->smtp->close();
        }
    }

    /**
     * Set the language for error messages.
     * Returns false if it cannot load the language file.
     * The default language is English.
     *
     * @param string $langcode  ISO 639-1 2-character language code (e.g. French is "fr")
     * @param string $lang_path Path to the language file directory, with trailing separator (slash)
     *
     * @return bool
     */
    public function setLanguage($langcode = 'en', $lang_path = '')
    {
        // Backwards compatibility for renamed language codes
        $renamed_langcodes = [
            'br' => 'pt_br',
            'cz' => 'cs',
            'dk' => 'da',
            'no' => 'nb',
            'se' => 'sv',
            'rs' => 'sr',
            'tg' => 'tl',
            'am' => 'hy',
        ];

        if (isset($renamed_langcodes[$langcode])) {
            $langcode = $renamed_langcodes[$langcode];
        }

        // Define full set of translatable strings in English
        $PHPMAILER_LANG = [
            'authenticate' => 'SMTP Error: Could not authenticate.',
            'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
            'data_not_accepted' => 'SMTP Error: data not accepted.',
            'empty_message' => 'Message body empty',
            'encoding' => 'Unknown encoding: ',
            'execute' => 'Could not execute: ',
            'file_access' => 'Could not access file: ',
            'file_open' => 'File Error: Could not open file: ',
            'from_failed' => 'The following From address failed: ',
            'instantiate' => 'Could not instantiate mail function.',
            'invalid_address' => 'Invalid address: ',
            'invalid_hostentry' => 'Invalid hostentry: ',
            'invalid_host' => 'Invalid host: ',
            'mailer_not_supported' => ' mailer is not supported.',
            'provide_address' => 'You must provide at least one recipient email address.',
            'recipients_failed' => 'SMTP Error: The following recipients failed: ',
            'signing' => 'Signing Error: ',
            'smtp_connect_failed' => 'SMTP connect() failed.',
            'smtp_error' => 'SMTP server error: ',
            'variable_set' => 'Cannot set or reset variable: ',
            'extension_missing' => 'Extension missing: ',
        ];
        if (empty($lang_path)) {
            // Calculate an absolute path so it can work if CWD is not here
            $lang_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR;
        }
        //Validate $langcode
        if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) {
            $langcode = 'en';
        }
        $foundlang = true;
        $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
        // There is no English translation file
        if ('en' !== $langcode) {
            // Make sure language file path is readable
            if (!static::isPermittedPath($lang_file) || !file_exists($lang_file)) {
                $foundlang = false;
            } else {
                // Overwrite language-specific strings.
                // This way we'll never have missing translation keys.
                $foundlang = include $lang_file;
            }
        }
        $this->language = $PHPMAILER_LANG;

        return (bool) $foundlang; // Returns false if language not found
    }

    /**
     * Get the array of strings for the current language.
     *
     * @return array
     */
    public function getTranslations()
    {
        return $this->language;
    }

    /**
     * Create recipient headers.
     *
     * @param string $type
     * @param array  $addr An array of recipients,
     *                     where each recipient is a 2-element indexed array with element 0 containing an address
     *                     and element 1 containing a name, like:
     *                     [['[email protected]', 'Joe User'], ['[email protected]', 'Zoe User']]
     *
     * @return string
     */
    public function addrAppend($type, $addr)
    {
        $addresses = [];
        foreach ($addr as $address) {
            $addresses[] = $this->addrFormat($address);
        }

        return $type . ': ' . implode(', ', $addresses) . static::$LE;
    }

    /**
     * Format an address for use in a message header.
     *
     * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name like
     *                    ['[email protected]', 'Joe User']
     *
     * @return string
     */
    public function addrFormat($addr)
    {
        if (empty($addr[1])) { // No name provided
            return $this->secureHeader($addr[0]);
        }

        return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') .
            ' <' . $this->secureHeader($addr[0]) . '>';
    }

    /**
     * Word-wrap message.
     * For use with mailers that do not automatically perform wrapping
     * and for quoted-printable encoded messages.
     * Original written by philippe.
     *
     * @param string $message The message to wrap
     * @param int    $length  The line length to wrap to
     * @param bool   $qp_mode Whether to run in Quoted-Printable mode
     *
     * @return string
     */
    public function wrapText($message, $length, $qp_mode = false)
    {
        if ($qp_mode) {
            $soft_break = sprintf(' =%s', static::$LE);
        } else {
            $soft_break = static::$LE;
        }
        // If utf-8 encoding is used, we will need to make sure we don't
        // split multibyte characters when we wrap
        $is_utf8 = static::CHARSET_UTF8 === strtolower($this->CharSet);
        $lelen = strlen(static::$LE);
        $crlflen = strlen(static::$LE);

        $message = static::normalizeBreaks($message);
        //Remove a trailing line break
        if (substr($message, -$lelen) === static::$LE) {
            $message = substr($message, 0, -$lelen);
        }

        //Split message into lines
        $lines = explode(static::$LE, $message);
        //Message will be rebuilt in here
        $message = '';
        foreach ($lines as $line) {
            $words = explode(' ', $line);
            $buf = '';
            $firstword = true;
            foreach ($words as $word) {
                if ($qp_mode && (strlen($word) > $length)) {
                    $space_left = $length - strlen($buf) - $crlflen;
                    if (!$firstword) {
                        if ($space_left > 20) {
                            $len = $space_left;
                            if ($is_utf8) {
                                $len = $this->utf8CharBoundary($word, $len);
                            } elseif ('=' === substr($word, $len - 1, 1)) {
                                --$len;
                            } elseif ('=' === substr($word, $len - 2, 1)) {
                                $len -= 2;
                            }
                            $part = substr($word, 0, $len);
                            $word = substr($word, $len);
                            $buf .= ' ' . $part;
                            $message .= $buf . sprintf('=%s', static::$LE);
                        } else {
                            $message .= $buf . $soft_break;
                        }
                        $buf = '';
                    }
                    while ($word !== '') {
                        if ($length <= 0) {
                            break;
                        }
                        $len = $length;
                        if ($is_utf8) {
                            $len = $this->utf8CharBoundary($word, $len);
                        } elseif ('=' === substr($word, $len - 1, 1)) {
                            --$len;
                        } elseif ('=' === substr($word, $len - 2, 1)) {
                            $len -= 2;
                        }
                        $part = substr($word, 0, $len);
                        $word = (string) substr($word, $len);

                        if ($word !== '') {
                            $message .= $part . sprintf('=%s', static::$LE);
                        } else {
                            $buf = $part;
                        }
                    }
                } else {
                    $buf_o = $buf;
                    if (!$firstword) {
                        $buf .= ' ';
                    }
                    $buf .= $word;

                    if ('' !== $buf_o && strlen($buf) > $length) {
                        $message .= $buf_o . $soft_break;
                        $buf = $word;
                    }
                }
                $firstword = false;
            }
            $message .= $buf . static::$LE;
        }

        return $message;
    }

    /**
     * Find the last character boundary prior to $maxLength in a utf-8
     * quoted-printable encoded string.
     * Original written by Colin Brown.
     *
     * @param string $encodedText utf-8 QP text
     * @param int    $maxLength   Find the last character boundary prior to this length
     *
     * @return int
     */
    public function utf8CharBoundary($encodedText, $maxLength)
    {
        $foundSplitPos = false;
        $lookBack = 3;
        while (!$foundSplitPos) {
            $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
            $encodedCharPos = strpos($lastChunk, '=');
            if (false !== $encodedCharPos) {
                // Found start of encoded character byte within $lookBack block.
                // Check the encoded byte value (the 2 chars after the '=')
                $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
                $dec = hexdec($hex);
                if ($dec < 128) {
                    // Single byte character.
                    // If the encoded char was found at pos 0, it will fit
                    // otherwise reduce maxLength to start of the encoded char
                    if ($encodedCharPos > 0) {
                        $maxLength -= $lookBack - $encodedCharPos;
                    }
                    $foundSplitPos = true;
                } elseif ($dec >= 192) {
                    // First byte of a multi byte character
                    // Reduce maxLength to split at start of character
                    $maxLength -= $lookBack - $encodedCharPos;
                    $foundSplitPos = true;
                } elseif ($dec < 192) {
                    // Middle byte of a multi byte character, look further back
                    $lookBack += 3;
                }
            } else {
                // No encoded character found
                $foundSplitPos = true;
            }
        }

        return $maxLength;
    }

    /**
     * Apply word wrapping to the message body.
     * Wraps the message body to the number of chars set in the WordWrap property.
     * You should only do this to plain-text bodies as wrapping HTML tags may break them.
     * This is called automatically by createBody(), so you don't need to call it yourself.
     */
    public function setWordWrap()
    {
        if ($this->WordWrap < 1) {
            return;
        }

        switch ($this->message_type) {
            case 'alt':
            case 'alt_inline':
            case 'alt_attach':
            case 'alt_inline_attach':
                $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap);
                break;
            default:
                $this->Body = $this->wrapText($this->Body, $this->WordWrap);
                break;
        }
    }

    /**
     * Assemble message headers.
     *
     * @return string The assembled headers
     */
    public function createHeader()
    {
        $result = '';

        $result .= $this->headerLine('Date', '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate);

        // The To header is created automatically by mail(), so needs to be omitted here
        if ('mail' !== $this->Mailer) {
            if ($this->SingleTo) {
                foreach ($this->to as $toaddr) {
                    $this->SingleToArray[] = $this->addrFormat($toaddr);
                }
            } elseif (count($this->to) > 0) {
                $result .= $this->addrAppend('To', $this->to);
            } elseif (count($this->cc) === 0) {
                $result .= $this->headerLine('To', 'undisclosed-recipients:;');
            }
        }
        $result .= $this->addrAppend('From', [[trim($this->From), $this->FromName]]);

        // sendmail and mail() extract Cc from the header before sending
        if (count($this->cc) > 0) {
            $result .= $this->addrAppend('Cc', $this->cc);
        }

        // sendmail and mail() extract Bcc from the header before sending
        if ((
                'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer
            )
            && count($this->bcc) > 0
        ) {
            $result .= $this->addrAppend('Bcc', $this->bcc);
        }

        if (count($this->ReplyTo) > 0) {
            $result .= $this->addrAppend('Reply-To', $this->ReplyTo);
        }

        // mail() sets the subject itself
        if ('mail' !== $this->Mailer) {
            $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
        }

        // Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4
        // https://tools.ietf.org/html/rfc5322#section-3.6.4
        if ('' !== $this->MessageID && preg_match('/^<.*@.*>$/', $this->MessageID)) {
            $this->lastMessageID = $this->MessageID;
        } else {
            $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname());
        }
        $result .= $this->headerLine('Message-ID', $this->lastMessageID);
        if (null !== $this->Priority) {
            $result .= $this->headerLine('X-Priority', $this->Priority);
        }
        if ('' === $this->XMailer) {
            $result .= $this->headerLine(
                'X-Mailer',
                'PHPMailer ' . self::VERSION . ' (https://github.com/PHPMailer/PHPMailer)'
            );
        } else {
            $myXmailer = trim($this->XMailer);
            if ($myXmailer) {
                $result .= $this->headerLine('X-Mailer', $myXmailer);
            }
        }

        if ('' !== $this->ConfirmReadingTo) {
            $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>');
        }

        // Add custom headers
        foreach ($this->CustomHeader as $header) {
            $result .= $this->headerLine(
                trim($header[0]),
                $this->encodeHeader(trim($header[1]))
            );
        }
        if (!$this->sign_key_file) {
            $result .= $this->headerLine('MIME-Version', '1.0');
            $result .= $this->getMailMIME();
        }

        return $result;
    }

    /**
     * Get the message MIME type headers.
     *
     * @return string
     */
    public function getMailMIME()
    {
        $result = '';
        $ismultipart = true;
        switch ($this->message_type) {
            case 'inline':
                $result .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $result .= $this->textLine(' boundary="' . $this->boundary[1] . '"');
                break;
            case 'attach':
            case 'inline_attach':
            case 'alt_attach':
            case 'alt_inline_attach':
                $result .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_MIXED . ';');
                $result .= $this->textLine(' boundary="' . $this->boundary[1] . '"');
                break;
            case 'alt':
            case 'alt_inline':
                $result .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
                $result .= $this->textLine(' boundary="' . $this->boundary[1] . '"');
                break;
            default:
                // Catches case 'plain': and case '':
                $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
                $ismultipart = false;
                break;
        }
        // RFC1341 part 5 says 7bit is assumed if not specified
        if (static::ENCODING_7BIT !== $this->Encoding) {
            // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE
            if ($ismultipart) {
                if (static::ENCODING_8BIT === $this->Encoding) {
                    $result .= $this->headerLine('Content-Transfer-Encoding', static::ENCODING_8BIT);
                }
                // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible
            } else {
                $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
            }
        }

        if ('mail' !== $this->Mailer) {
//            $result .= static::$LE;
        }

        return $result;
    }

    /**
     * Returns the whole MIME message.
     * Includes complete headers and body.
     * Only valid post preSend().
     *
     * @see PHPMailer::preSend()
     *
     * @return string
     */
    public function getSentMIMEMessage()
    {
        return static::stripTrailingWSP($this->MIMEHeader . $this->mailHeader) .
            static::$LE . static::$LE . $this->MIMEBody;
    }

    /**
     * Create a unique ID to use for boundaries.
     *
     * @return string
     */
    protected function generateId()
    {
        $len = 32; //32 bytes = 256 bits
        $bytes = '';
        if (function_exists('random_bytes')) {
            try {
                $bytes = random_bytes($len);
            } catch (\Exception $e) {
                //Do nothing
            }
        } elseif (function_exists('openssl_random_pseudo_bytes')) {
            /** @noinspection CryptographicallySecureRandomnessInspection */
            $bytes = openssl_random_pseudo_bytes($len);
        }
        if ($bytes === '') {
            //We failed to produce a proper random string, so make do.
            //Use a hash to force the length to the same as the other methods
            $bytes = hash('sha256', uniqid((string) mt_rand(), true), true);
        }

        //We don't care about messing up base64 format here, just want a random string
        return str_replace(['=', '+', '/'], '', base64_encode(hash('sha256', $bytes, true)));
    }

    /**
     * Assemble the message body.
     * Returns an empty string on failure.
     *
     * @throws Exception
     *
     * @return string The assembled message body
     */
    public function createBody()
    {
        $body = '';
        //Create unique IDs and preset boundaries
        $this->uniqueid = $this->generateId();
        $this->boundary[1] = 'b1_' . $this->uniqueid;
        $this->boundary[2] = 'b2_' . $this->uniqueid;
        $this->boundary[3] = 'b3_' . $this->uniqueid;

        if ($this->sign_key_file) {
            $body .= $this->getMailMIME() . static::$LE;
        }

        $this->setWordWrap();

        $bodyEncoding = $this->Encoding;
        $bodyCharSet = $this->CharSet;
        //Can we do a 7-bit downgrade?
        if (static::ENCODING_8BIT === $bodyEncoding && !$this->has8bitChars($this->Body)) {
            $bodyEncoding = static::ENCODING_7BIT;
            //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
            $bodyCharSet = static::CHARSET_ASCII;
        }
        //If lines are too long, and we're not already using an encoding that will shorten them,
        //change to quoted-printable transfer encoding for the body part only
        if (static::ENCODING_BASE64 !== $this->Encoding && static::hasLineLongerThanMax($this->Body)) {
            $bodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
        }

        $altBodyEncoding = $this->Encoding;
        $altBodyCharSet = $this->CharSet;
        //Can we do a 7-bit downgrade?
        if (static::ENCODING_8BIT === $altBodyEncoding && !$this->has8bitChars($this->AltBody)) {
            $altBodyEncoding = static::ENCODING_7BIT;
            //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
            $altBodyCharSet = static::CHARSET_ASCII;
        }
        //If lines are too long, and we're not already using an encoding that will shorten them,
        //change to quoted-printable transfer encoding for the alt body part only
        if (static::ENCODING_BASE64 !== $altBodyEncoding && static::hasLineLongerThanMax($this->AltBody)) {
            $altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
        }
        //Use this as a preamble in all multipart message types
        $mimepre = 'This is a multi-part message in MIME format.' . static::$LE . static::$LE;
        switch ($this->message_type) {
            case 'inline':
                $body .= $mimepre;
                $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[1]);
                break;
            case 'attach':
                $body .= $mimepre;
                $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            case 'inline_attach':
                $body .= $mimepre;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
                $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            case 'alt':
                $body .= $mimepre;
                $body .= $this->getBoundary(
                    $this->boundary[1],
                    $altBodyCharSet,
                    static::CONTENT_TYPE_PLAINTEXT,
                    $altBodyEncoding
                );
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->getBoundary(
                    $this->boundary[1],
                    $bodyCharSet,
                    static::CONTENT_TYPE_TEXT_HTML,
                    $bodyEncoding
                );
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                if (!empty($this->Ical)) {
                    $method = static::ICAL_METHOD_REQUEST;
                    foreach (static::$IcalMethods as $imethod) {
                        if (stripos($this->Ical, 'METHOD:' . $imethod) !== false) {
                            $method = $imethod;
                            break;
                        }
                    }
                    $body .= $this->getBoundary(
                        $this->boundary[1],
                        '',
                        static::CONTENT_TYPE_TEXT_CALENDAR . '; method=' . $method,
                        ''
                    );
                    $body .= $this->encodeString($this->Ical, $this->Encoding);
                    $body .= static::$LE;
                }
                $body .= $this->endBoundary($this->boundary[1]);
                break;
            case 'alt_inline':
                $body .= $mimepre;
                $body .= $this->getBoundary(
                    $this->boundary[1],
                    $altBodyCharSet,
                    static::CONTENT_TYPE_PLAINTEXT,
                    $altBodyEncoding
                );
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
                $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary(
                    $this->boundary[2],
                    $bodyCharSet,
                    static::CONTENT_TYPE_TEXT_HTML,
                    $bodyEncoding
                );
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->endBoundary($this->boundary[1]);
                break;
            case 'alt_attach':
                $body .= $mimepre;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary(
                    $this->boundary[2],
                    $altBodyCharSet,
                    static::CONTENT_TYPE_PLAINTEXT,
                    $altBodyEncoding
                );
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->getBoundary(
                    $this->boundary[2],
                    $bodyCharSet,
                    static::CONTENT_TYPE_TEXT_HTML,
                    $bodyEncoding
                );
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                if (!empty($this->Ical)) {
                    $method = static::ICAL_METHOD_REQUEST;
                    foreach (static::$IcalMethods as $imethod) {
                        if (stripos($this->Ical, 'METHOD:' . $imethod) !== false) {
                            $method = $imethod;
                            break;
                        }
                    }
                    $body .= $this->getBoundary(
                        $this->boundary[2],
                        '',
                        static::CONTENT_TYPE_TEXT_CALENDAR . '; method=' . $method,
                        ''
                    );
                    $body .= $this->encodeString($this->Ical, $this->Encoding);
                }
                $body .= $this->endBoundary($this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            case 'alt_inline_attach':
                $body .= $mimepre;
                $body .= $this->textLine('--' . $this->boundary[1]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary(
                    $this->boundary[2],
                    $altBodyCharSet,
                    static::CONTENT_TYPE_PLAINTEXT,
                    $altBodyEncoding
                );
                $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
                $body .= static::$LE;
                $body .= $this->textLine('--' . $this->boundary[2]);
                $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
                $body .= $this->textLine(' boundary="' . $this->boundary[3] . '";');
                $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
                $body .= static::$LE;
                $body .= $this->getBoundary(
                    $this->boundary[3],
                    $bodyCharSet,
                    static::CONTENT_TYPE_TEXT_HTML,
                    $bodyEncoding
                );
                $body .= $this->encodeString($this->Body, $bodyEncoding);
                $body .= static::$LE;
                $body .= $this->attachAll('inline', $this->boundary[3]);
                $body .= static::$LE;
                $body .= $this->endBoundary($this->boundary[2]);
                $body .= static::$LE;
                $body .= $this->attachAll('attachment', $this->boundary[1]);
                break;
            default:
                // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types
                //Reset the `Encoding` property in case we changed it for line length reasons
                $this->Encoding = $bodyEncoding;
                $body .= $this->encodeString($this->Body, $this->Encoding);
                break;
        }

        if ($this->isError()) {
            $body = '';
            if ($this->exceptions) {
                throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
            }
        } elseif ($this->sign_key_file) {
            try {
                if (!defined('PKCS7_TEXT')) {
                    throw new Exception($this->lang('extension_missing') . 'openssl');
                }

                $file = tempnam(sys_get_temp_dir(), 'srcsign');
                $signed = tempnam(sys_get_temp_dir(), 'mailsign');
                file_put_contents($file, $body);

                //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
                if (empty($this->sign_extracerts_file)) {
                    $sign = @openssl_pkcs7_sign(
                        $file,
                        $signed,
                        'file://' . realpath($this->sign_cert_file),
                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
                        []
                    );
                } else {
                    $sign = @openssl_pkcs7_sign(
                        $file,
                        $signed,
                        'file://' . realpath($this->sign_cert_file),
                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
                        [],
                        PKCS7_DETACHED,
                        $this->sign_extracerts_file
                    );
                }

                @unlink($file);
                if ($sign) {
                    $body = file_get_contents($signed);
                    @unlink($signed);
                    //The message returned by openssl contains both headers and body, so need to split them up
                    $parts = explode("\n\n", $body, 2);
                    $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
                    $body = $parts[1];
                } else {
                    @unlink($signed);
                    throw new Exception($this->lang('signing') . openssl_error_string());
                }
            } catch (Exception $exc) {
                $body = '';
                if ($this->exceptions) {
                    throw $exc;
                }
            }
        }

        return $body;
    }

    /**
     * Return the start of a message boundary.
     *
     * @param string $boundary
     * @param string $charSet
     * @param string $contentType
     * @param string $encoding
     *
     * @return string
     */
    protected function getBoundary($boundary, $charSet, $contentType, $encoding)
    {
        $result = '';
        if ('' === $charSet) {
            $charSet = $this->CharSet;
        }
        if ('' === $contentType) {
            $contentType = $this->ContentType;
        }
        if ('' === $encoding) {
            $encoding = $this->Encoding;
        }
        $result .= $this->textLine('--' . $boundary);
        $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
        $result .= static::$LE;
        // RFC1341 part 5 says 7bit is assumed if not specified
        if (static::ENCODING_7BIT !== $encoding) {
            $result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
        }
        $result .= static::$LE;

        return $result;
    }

    /**
     * Return the end of a message boundary.
     *
     * @param string $boundary
     *
     * @return string
     */
    protected function endBoundary($boundary)
    {
        return static::$LE . '--' . $boundary . '--' . static::$LE;
    }

    /**
     * Set the message type.
     * PHPMailer only supports some preset message types, not arbitrary MIME structures.
     */
    protected function setMessageType()
    {
        $type = [];
        if ($this->alternativeExists()) {
            $type[] = 'alt';
        }
        if ($this->inlineImageExists()) {
            $type[] = 'inline';
        }
        if ($this->attachmentExists()) {
            $type[] = 'attach';
        }
        $this->message_type = implode('_', $type);
        if ('' === $this->message_type) {
            //The 'plain' message_type refers to the message having a single body element, not that it is plain-text
            $this->message_type = 'plain';
        }
    }

    /**
     * Format a header line.
     *
     * @param string     $name
     * @param string|int $value
     *
     * @return string
     */
    public function headerLine($name, $value)
    {
        return $name . ': ' . $value . static::$LE;
    }

    /**
     * Return a formatted mail line.
     *
     * @param string $value
     *
     * @return string
     */
    public function textLine($value)
    {
        return $value . static::$LE;
    }

    /**
     * Add an attachment from a path on the filesystem.
     * Never use a user-supplied path to a file!
     * Returns false if the file could not be found or read.
     * Explicitly *does not* support passing URLs; PHPMailer is not an HTTP client.
     * If you need to do that, fetch the resource yourself and pass it in via a local file or string.
     *
     * @param string $path        Path to the attachment
     * @param string $name        Overrides the attachment name
     * @param string $encoding    File encoding (see $Encoding)
     * @param string $type        File extension (MIME) type
     * @param string $disposition Disposition to use
     *
     * @throws Exception
     *
     * @return bool
     */
    public function addAttachment(
        $path,
        $name = '',
        $encoding = self::ENCODING_BASE64,
        $type = '',
        $disposition = 'attachment'
    ) {
        try {
            if (!static::isPermittedPath($path) || !@is_file($path) || !is_readable($path)) {
                throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE);
            }

            // If a MIME type is not specified, try to work it out from the file name
            if ('' === $type) {
                $type = static::filenameToType($path);
            }

            $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME);
            if ('' === $name) {
                $name = $filename;
            }
            if (!$this->validateEncoding($encoding)) {
                throw new Exception($this->lang('encoding') . $encoding);
            }

            $this->attachment[] = [
                0 => $path,
                1 => $filename,
                2 => $name,
                3 => $encoding,
                4 => $type,
                5 => false, // isStringAttachment
                6 => $disposition,
                7 => $name,
            ];
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            $this->edebug($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return false;
        }

        return true;
    }

    /**
     * Return the array of attachments.
     *
     * @return array
     */
    public function getAttachments()
    {
        return $this->attachment;
    }

    /**
     * Attach all file, string, and binary attachments to the message.
     * Returns an empty string on failure.
     *
     * @param string $disposition_type
     * @param string $boundary
     *
     * @throws Exception
     *
     * @return string
     */
    protected function attachAll($disposition_type, $boundary)
    {
        // Return text of body
        $mime = [];
        $cidUniq = [];
        $incl = [];

        // Add all attachments
        foreach ($this->attachment as $attachment) {
            // Check if it is a valid disposition_filter
            if ($attachment[6] === $disposition_type) {
                // Check for string attachment
                $string = '';
                $path = '';
                $bString = $attachment[5];
                if ($bString) {
                    $string = $attachment[0];
                } else {
                    $path = $attachment[0];
                }

                $inclhash = hash('sha256', serialize($attachment));
                if (in_array($inclhash, $incl, true)) {
                    continue;
                }
                $incl[] = $inclhash;
                $name = $attachment[2];
                $encoding = $attachment[3];
                $type = $attachment[4];
                $disposition = $attachment[6];
                $cid = $attachment[7];
                if ('inline' === $disposition && array_key_exists($cid, $cidUniq)) {
                    continue;
                }
                $cidUniq[$cid] = true;

                $mime[] = sprintf('--%s%s', $boundary, static::$LE);
                //Only include a filename property if we have one
                if (!empty($name)) {
                    $mime[] = sprintf(
                        'Content-Type: %s; name=%s%s',
                        $type,
                        static::quotedString($this->encodeHeader($this->secureHeader($name))),
                        static::$LE
                    );
                } else {
                    $mime[] = sprintf(
                        'Content-Type: %s%s',
                        $type,
                        static::$LE
                    );
                }
                // RFC1341 part 5 says 7bit is assumed if not specified
                if (static::ENCODING_7BIT !== $encoding) {
                    $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, static::$LE);
                }

                //Only set Content-IDs on inline attachments
                if ((string) $cid !== '' && $disposition === 'inline') {
                    $mime[] = 'Content-ID: <' . $this->encodeHeader($this->secureHeader($cid)) . '>' . static::$LE;
                }

                // Allow for bypassing the Content-Disposition header
                if (!empty($disposition)) {
                    $encoded_name = $this->encodeHeader($this->secureHeader($name));
                    if (!empty($encoded_name)) {
                        $mime[] = sprintf(
                            'Content-Disposition: %s; filename=%s%s',
                            $disposition,
                            static::quotedString($encoded_name),
                            static::$LE . static::$LE
                        );
                    } else {
                        $mime[] = sprintf(
                            'Content-Disposition: %s%s',
                            $disposition,
                            static::$LE . static::$LE
                        );
                    }
                } else {
                    $mime[] = static::$LE;
                }

                // Encode as string attachment
                if ($bString) {
                    $mime[] = $this->encodeString($string, $encoding);
                } else {
                    $mime[] = $this->encodeFile($path, $encoding);
                }
                if ($this->isError()) {
                    return '';
                }
                $mime[] = static::$LE;
            }
        }

        $mime[] = sprintf('--%s--%s', $boundary, static::$LE);

        return implode('', $mime);
    }

    /**
     * Encode a file attachment in requested format.
     * Returns an empty string on failure.
     *
     * @param string $path     The full path to the file
     * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
     *
     * @return string
     */
    protected function encodeFile($path, $encoding = self::ENCODING_BASE64)
    {
        try {
            if (!static::isPermittedPath($path) || !file_exists($path) || !is_readable($path)) {
                throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE);
            }
            $file_buffer = file_get_contents($path);
            if (false === $file_buffer) {
                throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE);
            }
            $file_buffer = $this->encodeString($file_buffer, $encoding);

            return $file_buffer;
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            $this->edebug($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return '';
        }
    }

    /**
     * Encode a string in requested format.
     * Returns an empty string on failure.
     *
     * @param string $str      The text to encode
     * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
     *
     * @throws Exception
     *
     * @return string
     */
    public function encodeString($str, $encoding = self::ENCODING_BASE64)
    {
        $encoded = '';
        switch (strtolower($encoding)) {
            case static::ENCODING_BASE64:
                $encoded = chunk_split(
                    base64_encode($str),
                    static::STD_LINE_LENGTH,
                    static::$LE
                );
                break;
            case static::ENCODING_7BIT:
            case static::ENCODING_8BIT:
                $encoded = static::normalizeBreaks($str);
                // Make sure it ends with a line break
                if (substr($encoded, -(strlen(static::$LE))) !== static::$LE) {
                    $encoded .= static::$LE;
                }
                break;
            case static::ENCODING_BINARY:
                $encoded = $str;
                break;
            case static::ENCODING_QUOTED_PRINTABLE:
                $encoded = $this->encodeQP($str);
                break;
            default:
                $this->setError($this->lang('encoding') . $encoding);
                if ($this->exceptions) {
                    throw new Exception($this->lang('encoding') . $encoding);
                }
                break;
        }

        return $encoded;
    }

    /**
     * Encode a header value (not including its label) optimally.
     * Picks shortest of Q, B, or none. Result includes folding if needed.
     * See RFC822 definitions for phrase, comment and text positions.
     *
     * @param string $str      The header value to encode
     * @param string $position What context the string will be used in
     *
     * @return string
     */
    public function encodeHeader($str, $position = 'text')
    {
        $matchcount = 0;
        switch (strtolower($position)) {
            case 'phrase':
                if (!preg_match('/[\200-\377]/', $str)) {
                    // Can't use addslashes as we don't know the value of magic_quotes_sybase
                    $encoded = addcslashes($str, "\0..\37\177\\\"");
                    if (($str === $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
                        return $encoded;
                    }

                    return "\"$encoded\"";
                }
                $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
                break;
            /* @noinspection PhpMissingBreakStatementInspection */
            case 'comment':
                $matchcount = preg_match_all('/[()"]/', $str, $matches);
            //fallthrough
            case 'text':
            default:
                $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
                break;
        }

        if ($this->has8bitChars($str)) {
            $charset = $this->CharSet;
        } else {
            $charset = static::CHARSET_ASCII;
        }

        // Q/B encoding adds 8 chars and the charset ("` =?<charset>?[QB]?<content>?=`").
        $overhead = 8 + strlen($charset);

        if ('mail' === $this->Mailer) {
            $maxlen = static::MAIL_MAX_LINE_LENGTH - $overhead;
        } else {
            $maxlen = static::MAX_LINE_LENGTH - $overhead;
        }

        // Select the encoding that produces the shortest output and/or prevents corruption.
        if ($matchcount > strlen($str) / 3) {
            // More than 1/3 of the content needs encoding, use B-encode.
            $encoding = 'B';
        } elseif ($matchcount > 0) {
            // Less than 1/3 of the content needs encoding, use Q-encode.
            $encoding = 'Q';
        } elseif (strlen($str) > $maxlen) {
            // No encoding needed, but value exceeds max line length, use Q-encode to prevent corruption.
            $encoding = 'Q';
        } else {
            // No reformatting needed
            $encoding = false;
        }

        switch ($encoding) {
            case 'B':
                if ($this->hasMultiBytes($str)) {
                    // Use a custom function which correctly encodes and wraps long
                    // multibyte strings without breaking lines within a character
                    $encoded = $this->base64EncodeWrapMB($str, "\n");
                } else {
                    $encoded = base64_encode($str);
                    $maxlen -= $maxlen % 4;
                    $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
                }
                $encoded = preg_replace('/^(.*)$/m', ' =?' . $charset . "?$encoding?\\1?=", $encoded);
                break;
            case 'Q':
                $encoded = $this->encodeQ($str, $position);
                $encoded = $this->wrapText($encoded, $maxlen, true);
                $encoded = str_replace('=' . static::$LE, "\n", trim($encoded));
                $encoded = preg_replace('/^(.*)$/m', ' =?' . $charset . "?$encoding?\\1?=", $encoded);
                break;
            default:
                return $str;
        }

        return trim(static::normalizeBreaks($encoded));
    }

    /**
     * Check if a string contains multi-byte characters.
     *
     * @param string $str multi-byte text to wrap encode
     *
     * @return bool
     */
    public function hasMultiBytes($str)
    {
        if (function_exists('mb_strlen')) {
            return strlen($str) > mb_strlen($str, $this->CharSet);
        }

        // Assume no multibytes (we can't handle without mbstring functions anyway)
        return false;
    }

    /**
     * Does a string contain any 8-bit chars (in any charset)?
     *
     * @param string $text
     *
     * @return bool
     */
    public function has8bitChars($text)
    {
        return (bool) preg_match('/[\x80-\xFF]/', $text);
    }

    /**
     * Encode and wrap long multibyte strings for mail headers
     * without breaking lines within a character.
     * Adapted from a function by paravoid.
     *
     * @see http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
     *
     * @param string $str       multi-byte text to wrap encode
     * @param string $linebreak string to use as linefeed/end-of-line
     *
     * @return string
     */
    public function base64EncodeWrapMB($str, $linebreak = null)
    {
        $start = '=?' . $this->CharSet . '?B?';
        $end = '?=';
        $encoded = '';
        if (null === $linebreak) {
            $linebreak = static::$LE;
        }

        $mb_length = mb_strlen($str, $this->CharSet);
        // Each line must have length <= 75, including $start and $end
        $length = 75 - strlen($start) - strlen($end);
        // Average multi-byte ratio
        $ratio = $mb_length / strlen($str);
        // Base64 has a 4:3 ratio
        $avgLength = floor($length * $ratio * .75);

        $offset = 0;
        for ($i = 0; $i < $mb_length; $i += $offset) {
            $lookBack = 0;
            do {
                $offset = $avgLength - $lookBack;
                $chunk = mb_substr($str, $i, $offset, $this->CharSet);
                $chunk = base64_encode($chunk);
                ++$lookBack;
            } while (strlen($chunk) > $length);
            $encoded .= $chunk . $linebreak;
        }

        // Chomp the last linefeed
        return substr($encoded, 0, -strlen($linebreak));
    }

    /**
     * Encode a string in quoted-printable format.
     * According to RFC2045 section 6.7.
     *
     * @param string $string The text to encode
     *
     * @return string
     */
    public function encodeQP($string)
    {
        return static::normalizeBreaks(quoted_printable_encode($string));
    }

    /**
     * Encode a string using Q encoding.
     *
     * @see http://tools.ietf.org/html/rfc2047#section-4.2
     *
     * @param string $str      the text to encode
     * @param string $position Where the text is going to be used, see the RFC for what that means
     *
     * @return string
     */
    public function encodeQ($str, $position = 'text')
    {
        // There should not be any EOL in the string
        $pattern = '';
        $encoded = str_replace(["\r", "\n"], '', $str);
        switch (strtolower($position)) {
            case 'phrase':
                // RFC 2047 section 5.3
                $pattern = '^A-Za-z0-9!*+\/ -';
                break;
            /*
             * RFC 2047 section 5.2.
             * Build $pattern without including delimiters and []
             */
            /* @noinspection PhpMissingBreakStatementInspection */
            case 'comment':
                $pattern = '\(\)"';
            /* Intentional fall through */
            case 'text':
            default:
                // RFC 2047 section 5.1
                // Replace every high ascii, control, =, ? and _ characters
                $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
                break;
        }
        $matches = [];
        if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
            // If the string contains an '=', make sure it's the first thing we replace
            // so as to avoid double-encoding
            $eqkey = array_search('=', $matches[0], true);
            if (false !== $eqkey) {
                unset($matches[0][$eqkey]);
                array_unshift($matches[0], '=');
            }
            foreach (array_unique($matches[0]) as $char) {
                $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
            }
        }
        // Replace spaces with _ (more readable than =20)
        // RFC 2047 section 4.2(2)
        return str_replace(' ', '_', $encoded);
    }

    /**
     * Add a string or binary attachment (non-filesystem).
     * This method can be used to attach ascii or binary data,
     * such as a BLOB record from a database.
     *
     * @param string $string      String attachment data
     * @param string $filename    Name of the attachment
     * @param string $encoding    File encoding (see $Encoding)
     * @param string $type        File extension (MIME) type
     * @param string $disposition Disposition to use
     *
     * @throws Exception
     *
     * @return bool True on successfully adding an attachment
     */
    public function addStringAttachment(
        $string,
        $filename,
        $encoding = self::ENCODING_BASE64,
        $type = '',
        $disposition = 'attachment'
    ) {
        try {
            // If a MIME type is not specified, try to work it out from the file name
            if ('' === $type) {
                $type = static::filenameToType($filename);
            }

            if (!$this->validateEncoding($encoding)) {
                throw new Exception($this->lang('encoding') . $encoding);
            }

            // Append to $attachment array
            $this->attachment[] = [
                0 => $string,
                1 => $filename,
                2 => static::mb_pathinfo($filename, PATHINFO_BASENAME),
                3 => $encoding,
                4 => $type,
                5 => true, // isStringAttachment
                6 => $disposition,
                7 => 0,
            ];
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            $this->edebug($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return false;
        }

        return true;
    }

    /**
     * Add an embedded (inline) attachment from a file.
     * This can include images, sounds, and just about any other document type.
     * These differ from 'regular' attachments in that they are intended to be
     * displayed inline with the message, not just attached for download.
     * This is used in HTML messages that embed the images
     * the HTML refers to using the $cid value.
     * Never use a user-supplied path to a file!
     *
     * @param string $path        Path to the attachment
     * @param string $cid         Content ID of the attachment; Use this to reference
     *                            the content when using an embedded image in HTML
     * @param string $name        Overrides the attachment name
     * @param string $encoding    File encoding (see $Encoding)
     * @param string $type        File MIME type
     * @param string $disposition Disposition to use
     *
     * @throws Exception
     *
     * @return bool True on successfully adding an attachment
     */
    public function addEmbeddedImage(
        $path,
        $cid,
        $name = '',
        $encoding = self::ENCODING_BASE64,
        $type = '',
        $disposition = 'inline'
    ) {
        try {
            if (!static::isPermittedPath($path) || !@is_file($path) || !is_readable($path)) {
                throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE);
            }

            // If a MIME type is not specified, try to work it out from the file name
            if ('' === $type) {
                $type = static::filenameToType($path);
            }

            if (!$this->validateEncoding($encoding)) {
                throw new Exception($this->lang('encoding') . $encoding);
            }

            $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME);
            if ('' === $name) {
                $name = $filename;
            }

            // Append to $attachment array
            $this->attachment[] = [
                0 => $path,
                1 => $filename,
                2 => $name,
                3 => $encoding,
                4 => $type,
                5 => false, // isStringAttachment
                6 => $disposition,
                7 => $cid,
            ];
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            $this->edebug($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return false;
        }

        return true;
    }

    /**
     * Add an embedded stringified attachment.
     * This can include images, sounds, and just about any other document type.
     * If your filename doesn't contain an extension, be sure to set the $type to an appropriate MIME type.
     *
     * @param string $string      The attachment binary data
     * @param string $cid         Content ID of the attachment; Use this to reference
     *                            the content when using an embedded image in HTML
     * @param string $name        A filename for the attachment. If this contains an extension,
     *                            PHPMailer will attempt to set a MIME type for the attachment.
     *                            For example 'file.jpg' would get an 'image/jpeg' MIME type.
     * @param string $encoding    File encoding (see $Encoding), defaults to 'base64'
     * @param string $type        MIME type - will be used in preference to any automatically derived type
     * @param string $disposition Disposition to use
     *
     * @throws Exception
     *
     * @return bool True on successfully adding an attachment
     */
    public function addStringEmbeddedImage(
        $string,
        $cid,
        $name = '',
        $encoding = self::ENCODING_BASE64,
        $type = '',
        $disposition = 'inline'
    ) {
        try {
            // If a MIME type is not specified, try to work it out from the name
            if ('' === $type && !empty($name)) {
                $type = static::filenameToType($name);
            }

            if (!$this->validateEncoding($encoding)) {
                throw new Exception($this->lang('encoding') . $encoding);
            }

            // Append to $attachment array
            $this->attachment[] = [
                0 => $string,
                1 => $name,
                2 => $name,
                3 => $encoding,
                4 => $type,
                5 => true, // isStringAttachment
                6 => $disposition,
                7 => $cid,
            ];
        } catch (Exception $exc) {
            $this->setError($exc->getMessage());
            $this->edebug($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }

            return false;
        }

        return true;
    }

    /**
     * Validate encodings.
     *
     * @param string $encoding
     *
     * @return bool
     */
    protected function validateEncoding($encoding)
    {
        return in_array(
            $encoding,
            [
                self::ENCODING_7BIT,
                self::ENCODING_QUOTED_PRINTABLE,
                self::ENCODING_BASE64,
                self::ENCODING_8BIT,
                self::ENCODING_BINARY,
            ],
            true
        );
    }

    /**
     * Check if an embedded attachment is present with this cid.
     *
     * @param string $cid
     *
     * @return bool
     */
    protected function cidExists($cid)
    {
        foreach ($this->attachment as $attachment) {
            if ('inline' === $attachment[6] && $cid === $attachment[7]) {
                return true;
            }
        }

        return false;
    }

    /**
     * Check if an inline attachment is present.
     *
     * @return bool
     */
    public function inlineImageExists()
    {
        foreach ($this->attachment as $attachment) {
            if ('inline' === $attachment[6]) {
                return true;
            }
        }

        return false;
    }

    /**
     * Check if an attachment (non-inline) is present.
     *
     * @return bool
     */
    public function attachmentExists()
    {
        foreach ($this->attachment as $attachment) {
            if ('attachment' === $attachment[6]) {
                return true;
            }
        }

        return false;
    }

    /**
     * Check if this message has an alternative body set.
     *
     * @return bool
     */
    public function alternativeExists()
    {
        return !empty($this->AltBody);
    }

    /**
     * Clear queued addresses of given kind.
     *
     * @param string $kind 'to', 'cc', or 'bcc'
     */
    public function clearQueuedAddresses($kind)
    {
        $this->RecipientsQueue = array_filter(
            $this->RecipientsQueue,
            static function ($params) use ($kind) {
                return $params[0] !== $kind;
            }
        );
    }

    /**
     * Clear all To recipients.
     */
    public function clearAddresses()
    {
        foreach ($this->to as $to) {
            unset($this->all_recipients[strtolower($to[0])]);
        }
        $this->to = [];
        $this->clearQueuedAddresses('to');
    }

    /**
     * Clear all CC recipients.
     */
    public function clearCCs()
    {
        foreach ($this->cc as $cc) {
            unset($this->all_recipients[strtolower($cc[0])]);
        }
        $this->cc = [];
        $this->clearQueuedAddresses('cc');
    }

    /**
     * Clear all BCC recipients.
     */
    public function clearBCCs()
    {
        foreach ($this->bcc as $bcc) {
            unset($this->all_recipients[strtolower($bcc[0])]);
        }
        $this->bcc = [];
        $this->clearQueuedAddresses('bcc');
    }

    /**
     * Clear all ReplyTo recipients.
     */
    public function clearReplyTos()
    {
        $this->ReplyTo = [];
        $this->ReplyToQueue = [];
    }

    /**
     * Clear all recipient types.
     */
    public function clearAllRecipients()
    {
        $this->to = [];
        $this->cc = [];
        $this->bcc = [];
        $this->all_recipients = [];
        $this->RecipientsQueue = [];
    }

    /**
     * Clear all filesystem, string, and binary attachments.
     */
    public function clearAttachments()
    {
        $this->attachment = [];
    }

    /**
     * Clear all custom headers.
     */
    public function clearCustomHeaders()
    {
        $this->CustomHeader = [];
    }

    /**
     * Add an error message to the error container.
     *
     * @param string $msg
     */
    protected function setError($msg)
    {
        ++$this->error_count;
        if ('smtp' === $this->Mailer && null !== $this->smtp) {
            $lasterror = $this->smtp->getError();
            if (!empty($lasterror['error'])) {
                $msg .= $this->lang('smtp_error') . $lasterror['error'];
                if (!empty($lasterror['detail'])) {
                    $msg .= ' Detail: ' . $lasterror['detail'];
                }
                if (!empty($lasterror['smtp_code'])) {
                    $msg .= ' SMTP code: ' . $lasterror['smtp_code'];
                }
                if (!empty($lasterror['smtp_code_ex'])) {
                    $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex'];
                }
            }
        }
        $this->ErrorInfo = $msg;
    }

    /**
     * Return an RFC 822 formatted date.
     *
     * @return string
     */
    public static function rfcDate()
    {
        // Set the time zone to whatever the default is to avoid 500 errors
        // Will default to UTC if it's not set properly in php.ini
        date_default_timezone_set(@date_default_timezone_get());

        return date('D, j M Y H:i:s O');
    }

    /**
     * Get the server hostname.
     * Returns 'localhost.localdomain' if unknown.
     *
     * @return string
     */
    protected function serverHostname()
    {
        $result = '';
        if (!empty($this->Hostname)) {
            $result = $this->Hostname;
        } elseif (isset($_SERVER) && array_key_exists('SERVER_NAME', $_SERVER)) {
            $result = $_SERVER['SERVER_NAME'];
        } elseif (function_exists('gethostname') && gethostname() !== false) {
            $result = gethostname();
        } elseif (php_uname('n') !== false) {
            $result = php_uname('n');
        }
        if (!static::isValidHost($result)) {
            return 'localhost.localdomain';
        }

        return $result;
    }

    /**
     * Validate whether a string contains a valid value to use as a hostname or IP address.
     * IPv6 addresses must include [], e.g. `[::1]`, not just `::1`.
     *
     * @param string $host The host name or IP address to check
     *
     * @return bool
     */
    public static function isValidHost($host)
    {
        //Simple syntax limits
        if (empty($host)
            || !is_string($host)
            || strlen($host) > 256
            || !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host)
        ) {
            return false;
        }
        //Looks like a bracketed IPv6 address
        if (strlen($host) > 2 && substr($host, 0, 1) === '[' && substr($host, -1, 1) === ']') {
            return filter_var(substr($host, 1, -1), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
        }
        //If removing all the dots results in a numeric string, it must be an IPv4 address.
        //Need to check this first because otherwise things like `999.0.0.0` are considered valid host names
        if (is_numeric(str_replace('.', '', $host))) {
            //Is it a valid IPv4 address?
            return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
        }
        if (filter_var('http://' . $host, FILTER_VALIDATE_URL) !== false) {
            //Is it a syntactically valid hostname?
            return true;
        }

        return false;
    }

    /**
     * Get an error message in the current language.
     *
     * @param string $key
     *
     * @return string
     */
    protected function lang($key)
    {
        if (count($this->language) < 1) {
            $this->setLanguage(); // set the default language
        }

        if (array_key_exists($key, $this->language)) {
            if ('smtp_connect_failed' === $key) {
                //Include a link to troubleshooting docs on SMTP connection failure
                //this is by far the biggest cause of support questions
                //but it's usually not PHPMailer's fault.
                return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
            }

            return $this->language[$key];
        }

        //Return the key as a fallback
        return $key;
    }

    /**
     * Check if an error occurred.
     *
     * @return bool True if an error did occur
     */
    public function isError()
    {
        return $this->error_count > 0;
    }

    /**
     * Add a custom header.
     * $name value can be overloaded to contain
     * both header name and value (name:value).
     *
     * @param string      $name  Custom header name
     * @param string|null $value Header value
     *
     * @throws Exception
     */
    public function addCustomHeader($name, $value = null)
    {
        if (null === $value && strpos($name, ':') !== false) {
            // Value passed in as name:value
            list($name, $value) = explode(':', $name, 2);
        }
        $name = trim($name);
        $value = trim($value);
        //Ensure name is not empty, and that neither name nor value contain line breaks
        if (empty($name) || strpbrk($name . $value, "\r\n") !== false) {
            if ($this->exceptions) {
                throw new Exception('Invalid header name or value');
            }

            return false;
        }
        $this->CustomHeader[] = [$name, $value];

        return true;
    }

    /**
     * Returns all custom headers.
     *
     * @return array
     */
    public function getCustomHeaders()
    {
        return $this->CustomHeader;
    }

    /**
     * Create a message body from an HTML string.
     * Automatically inlines images and creates a plain-text version by converting the HTML,
     * overwriting any existing values in Body and AltBody.
     * Do not source $message content from user input!
     * $basedir is prepended when handling relative URLs, e.g. <img src="/images/a.png"> and must not be empty
     * will look for an image file in $basedir/images/a.png and convert it to inline.
     * If you don't provide a $basedir, relative paths will be left untouched (and thus probably break in email)
     * Converts data-uri images into embedded attachments.
     * If you don't want to apply these transformations to your HTML, just set Body and AltBody directly.
     *
     * @param string        $message  HTML message string
     * @param string        $basedir  Absolute path to a base directory to prepend to relative paths to images
     * @param bool|callable $advanced Whether to use the internal HTML to text converter
     *                                or your own custom converter
     * @return string The transformed message body
     *
     * @throws Exception
     *
     * @see PHPMailer::html2text()
     */
    public function msgHTML($message, $basedir = '', $advanced = false)
    {
        preg_match_all('/(?<!-)(src|background)=["\'](.*)["\']/Ui', $message, $images);
        if (array_key_exists(2, $images)) {
            if (strlen($basedir) > 1 && '/' !== substr($basedir, -1)) {
                // Ensure $basedir has a trailing /
                $basedir .= '/';
            }
            foreach ($images[2] as $imgindex => $url) {
                // Convert data URIs into embedded images
                //e.g. "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
                $match = [];
                if (preg_match('#^data:(image/(?:jpe?g|gif|png));?(base64)?,(.+)#', $url, $match)) {
                    if (count($match) === 4 && static::ENCODING_BASE64 === $match[2]) {
                        $data = base64_decode($match[3]);
                    } elseif ('' === $match[2]) {
                        $data = rawurldecode($match[3]);
                    } else {
                        //Not recognised so leave it alone
                        continue;
                    }
                    //Hash the decoded data, not the URL, so that the same data-URI image used in multiple places
                    //will only be embedded once, even if it used a different encoding
                    $cid = substr(hash('sha256', $data), 0, 32) . '@phpmailer.0'; // RFC2392 S 2

                    if (!$this->cidExists($cid)) {
                        $this->addStringEmbeddedImage(
                            $data,
                            $cid,
                            'embed' . $imgindex,
                            static::ENCODING_BASE64,
                            $match[1]
                        );
                    }
                    $message = str_replace(
                        $images[0][$imgindex],
                        $images[1][$imgindex] . '="cid:' . $cid . '"',
                        $message
                    );
                    continue;
                }
                if (// Only process relative URLs if a basedir is provided (i.e. no absolute local paths)
                    !empty($basedir)
                    // Ignore URLs containing parent dir traversal (..)
                    && (strpos($url, '..') === false)
                    // Do not change urls that are already inline images
                    && 0 !== strpos($url, 'cid:')
                    // Do not change absolute URLs, including anonymous protocol
                    && !preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url)
                ) {
                    $filename = static::mb_pathinfo($url, PATHINFO_BASENAME);
                    $directory = dirname($url);
                    if ('.' === $directory) {
                        $directory = '';
                    }
                    // RFC2392 S 2
                    $cid = substr(hash('sha256', $url), 0, 32) . '@phpmailer.0';
                    if (strlen($basedir) > 1 && '/' !== substr($basedir, -1)) {
                        $basedir .= '/';
                    }
                    if (strlen($directory) > 1 && '/' !== substr($directory, -1)) {
                        $directory .= '/';
                    }
                    if ($this->addEmbeddedImage(
                        $basedir . $directory . $filename,
                        $cid,
                        $filename,
                        static::ENCODING_BASE64,
                        static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION))
                    )
                    ) {
                        $message = preg_replace(
                            '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
                            $images[1][$imgindex] . '="cid:' . $cid . '"',
                            $message
                        );
                    }
                }
            }
        }
        $this->isHTML();
        // Convert all message body line breaks to LE, makes quoted-printable encoding work much better
        $this->Body = static::normalizeBreaks($message);
        $this->AltBody = static::normalizeBreaks($this->html2text($message, $advanced));
        if (!$this->alternativeExists()) {
            $this->AltBody = 'This is an HTML-only message. To view it, activate HTML in your email application.'
                . static::$LE;
        }

        return $this->Body;
    }

    /**
     * Convert an HTML string into plain text.
     * This is used by msgHTML().
     * Note - older versions of this function used a bundled advanced converter
     * which was removed for license reasons in #232.
     * Example usage:
     *
     * ```php
     * // Use default conversion
     * $plain = $mail->html2text($html);
     * // Use your own custom converter
     * $plain = $mail->html2text($html, function($html) {
     *     $converter = new MyHtml2text($html);
     *     return $converter->get_text();
     * });
     * ```
     *
     * @param string        $html     The HTML text to convert
     * @param bool|callable $advanced Any boolean value to use the internal converter,
     *                                or provide your own callable for custom conversion
     *
     * @return string
     */
    public function html2text($html, $advanced = false)
    {
        if (is_callable($advanced)) {
            return call_user_func($advanced, $html);
        }

        return html_entity_decode(
            trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
            ENT_QUOTES,
            $this->CharSet
        );
    }

    /**
     * Get the MIME type for a file extension.
     *
     * @param string $ext File extension
     *
     * @return string MIME type of file
     */
    public static function _mime_types($ext = '')
    {
        $mimes = [
            'xl' => 'application/excel',
            'js' => 'application/javascript',
            'hqx' => 'application/mac-binhex40',
            'cpt' => 'application/mac-compactpro',
            'bin' => 'application/macbinary',
            'doc' => 'application/msword',
            'word' => 'application/msword',
            'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
            'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
            'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
            'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
            'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
            'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
            'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
            'class' => 'application/octet-stream',
            'dll' => 'application/octet-stream',
            'dms' => 'application/octet-stream',
            'exe' => 'application/octet-stream',
            'lha' => 'application/octet-stream',
            'lzh' => 'application/octet-stream',
            'psd' => 'application/octet-stream',
            'sea' => 'application/octet-stream',
            'so' => 'application/octet-stream',
            'oda' => 'application/oda',
            'pdf' => 'application/pdf',
            'ai' => 'application/postscript',
            'eps' => 'application/postscript',
            'ps' => 'application/postscript',
            'smi' => 'application/smil',
            'smil' => 'application/smil',
            'mif' => 'application/vnd.mif',
            'xls' => 'application/vnd.ms-excel',
            'ppt' => 'application/vnd.ms-powerpoint',
            'wbxml' => 'application/vnd.wap.wbxml',
            'wmlc' => 'application/vnd.wap.wmlc',
            'dcr' => 'application/x-director',
            'dir' => 'application/x-director',
            'dxr' => 'application/x-director',
            'dvi' => 'application/x-dvi',
            'gtar' => 'application/x-gtar',
            'php3' => 'application/x-httpd-php',
            'php4' => 'application/x-httpd-php',
            'php' => 'application/x-httpd-php',
            'phtml' => 'application/x-httpd-php',
            'phps' => 'application/x-httpd-php-source',
            'swf' => 'application/x-shockwave-flash',
            'sit' => 'application/x-stuffit',
            'tar' => 'application/x-tar',
            'tgz' => 'application/x-tar',
            'xht' => 'application/xhtml+xml',
            'xhtml' => 'application/xhtml+xml',
            'zip' => 'application/zip',
            'mid' => 'audio/midi',
            'midi' => 'audio/midi',
            'mp2' => 'audio/mpeg',
            'mp3' => 'audio/mpeg',
            'm4a' => 'audio/mp4',
            'mpga' => 'audio/mpeg',
            'aif' => 'audio/x-aiff',
            'aifc' => 'audio/x-aiff',
            'aiff' => 'audio/x-aiff',
            'ram' => 'audio/x-pn-realaudio',
            'rm' => 'audio/x-pn-realaudio',
            'rpm' => 'audio/x-pn-realaudio-plugin',
            'ra' => 'audio/x-realaudio',
            'wav' => 'audio/x-wav',
            'mka' => 'audio/x-matroska',
            'bmp' => 'image/bmp',
            'gif' => 'image/gif',
            'jpeg' => 'image/jpeg',
            'jpe' => 'image/jpeg',
            'jpg' => 'image/jpeg',
            'png' => 'image/png',
            'tiff' => 'image/tiff',
            'tif' => 'image/tiff',
            'webp' => 'image/webp',
            'avif' => 'image/avif',
            'heif' => 'image/heif',
            'heifs' => 'image/heif-sequence',
            'heic' => 'image/heic',
            'heics' => 'image/heic-sequence',
            'eml' => 'message/rfc822',
            'css' => 'text/css',
            'html' => 'text/html',
            'htm' => 'text/html',
            'shtml' => 'text/html',
            'log' => 'text/plain',
            'text' => 'text/plain',
            'txt' => 'text/plain',
            'rtx' => 'text/richtext',
            'rtf' => 'text/rtf',
            'vcf' => 'text/vcard',
            'vcard' => 'text/vcard',
            'ics' => 'text/calendar',
            'xml' => 'text/xml',
            'xsl' => 'text/xml',
            'wmv' => 'video/x-ms-wmv',
            'mpeg' => 'video/mpeg',
            'mpe' => 'video/mpeg',
            'mpg' => 'video/mpeg',
            'mp4' => 'video/mp4',
            'm4v' => 'video/mp4',
            'mov' => 'video/quicktime',
            'qt' => 'video/quicktime',
            'rv' => 'video/vnd.rn-realvideo',
            'avi' => 'video/x-msvideo',
            'movie' => 'video/x-sgi-movie',
            'webm' => 'video/webm',
            'mkv' => 'video/x-matroska',
        ];
        $ext = strtolower($ext);
        if (array_key_exists($ext, $mimes)) {
            return $mimes[$ext];
        }

        return 'application/octet-stream';
    }

    /**
     * Map a file name to a MIME type.
     * Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
     *
     * @param string $filename A file name or full path, does not need to exist as a file
     *
     * @return string
     */
    public static function filenameToType($filename)
    {
        // In case the path is a URL, strip any query string before getting extension
        $qpos = strpos($filename, '?');
        if (false !== $qpos) {
            $filename = substr($filename, 0, $qpos);
        }
        $ext = static::mb_pathinfo($filename, PATHINFO_EXTENSION);

        return static::_mime_types($ext);
    }

    /**
     * Multi-byte-safe pathinfo replacement.
     * Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe.
     *
     * @see http://www.php.net/manual/en/function.pathinfo.php#107461
     *
     * @param string     $path    A filename or path, does not need to exist as a file
     * @param int|string $options Either a PATHINFO_* constant,
     *                            or a string name to return only the specified piece
     *
     * @return string|array
     */
    public static function mb_pathinfo($path, $options = null)
    {
        $ret = ['dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''];
        $pathinfo = [];
        if (preg_match('#^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^.\\\\/]+?)|))[\\\\/.]*$#m', $path, $pathinfo)) {
            if (array_key_exists(1, $pathinfo)) {
                $ret['dirname'] = $pathinfo[1];
            }
            if (array_key_exists(2, $pathinfo)) {
                $ret['basename'] = $pathinfo[2];
            }
            if (array_key_exists(5, $pathinfo)) {
                $ret['extension'] = $pathinfo[5];
            }
            if (array_key_exists(3, $pathinfo)) {
                $ret['filename'] = $pathinfo[3];
            }
        }
        switch ($options) {
            case PATHINFO_DIRNAME:
            case 'dirname':
                return $ret['dirname'];
            case PATHINFO_BASENAME:
            case 'basename':
                return $ret['basename'];
            case PATHINFO_EXTENSION:
            case 'extension':
                return $ret['extension'];
            case PATHINFO_FILENAME:
            case 'filename':
                return $ret['filename'];
            default:
                return $ret;
        }
    }

    /**
     * Set or reset instance properties.
     * You should avoid this function - it's more verbose, less efficient, more error-prone and
     * harder to debug than setting properties directly.
     * Usage Example:
     * `$mail->set('SMTPSecure', static::ENCRYPTION_STARTTLS);`
     *   is the same as:
     * `$mail->SMTPSecure = static::ENCRYPTION_STARTTLS;`.
     *
     * @param string $name  The property name to set
     * @param mixed  $value The value to set the property to
     *
     * @return bool
     */
    public function set($name, $value = '')
    {
        if (property_exists($this, $name)) {
            $this->$name = $value;

            return true;
        }
        $this->setError($this->lang('variable_set') . $name);

        return false;
    }

    /**
     * Strip newlines to prevent header injection.
     *
     * @param string $str
     *
     * @return string
     */
    public function secureHeader($str)
    {
        return trim(str_replace(["\r", "\n"], '', $str));
    }

    /**
     * Normalize line breaks in a string.
     * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format.
     * Defaults to CRLF (for message bodies) and preserves consecutive breaks.
     *
     * @param string $text
     * @param string $breaktype What kind of line break to use; defaults to static::$LE
     *
     * @return string
     */
    public static function normalizeBreaks($text, $breaktype = null)
    {
        if (null === $breaktype) {
            $breaktype = static::$LE;
        }
        // Normalise to \n
        $text = str_replace([self::CRLF, "\r"], "\n", $text);
        // Now convert LE as needed
        if ("\n" !== $breaktype) {
            $text = str_replace("\n", $breaktype, $text);
        }

        return $text;
    }

    /**
     * Remove trailing breaks from a string.
     *
     * @param string $text
     *
     * @return string The text to remove breaks from
     */
    public static function stripTrailingWSP($text)
    {
        return rtrim($text, " \r\n\t");
    }

    /**
     * Return the current line break format string.
     *
     * @return string
     */
    public static function getLE()
    {
        return static::$LE;
    }

    /**
     * Set the line break format string, e.g. "\r\n".
     *
     * @param string $le
     */
    protected static function setLE($le)
    {
        static::$LE = $le;
    }

    /**
     * Set the public and private key files and password for S/MIME signing.
     *
     * @param string $cert_filename
     * @param string $key_filename
     * @param string $key_pass            Password for private key
     * @param string $extracerts_filename Optional path to chain certificate
     */
    public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '')
    {
        $this->sign_cert_file = $cert_filename;
        $this->sign_key_file = $key_filename;
        $this->sign_key_pass = $key_pass;
        $this->sign_extracerts_file = $extracerts_filename;
    }

    /**
     * Quoted-Printable-encode a DKIM header.
     *
     * @param string $txt
     *
     * @return string
     */
    public function DKIM_QP($txt)
    {
        $line = '';
        $len = strlen($txt);
        for ($i = 0; $i < $len; ++$i) {
            $ord = ord($txt[$i]);
            if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord === 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
                $line .= $txt[$i];
            } else {
                $line .= '=' . sprintf('%02X', $ord);
            }
        }

        return $line;
    }

    /**
     * Generate a DKIM signature.
     *
     * @param string $signHeader
     *
     * @throws Exception
     *
     * @return string The DKIM signature value
     */
    public function DKIM_Sign($signHeader)
    {
        if (!defined('PKCS7_TEXT')) {
            if ($this->exceptions) {
                throw new Exception($this->lang('extension_missing') . 'openssl');
            }

            return '';
        }
        $privKeyStr = !empty($this->DKIM_private_string) ?
            $this->DKIM_private_string :
            file_get_contents($this->DKIM_private);
        if ('' !== $this->DKIM_passphrase) {
            $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
        } else {
            $privKey = openssl_pkey_get_private($privKeyStr);
        }
        if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
            openssl_pkey_free($privKey);

            return base64_encode($signature);
        }
        openssl_pkey_free($privKey);

        return '';
    }

    /**
     * Generate a DKIM canonicalization header.
     * Uses the 'relaxed' algorithm from RFC6376 section 3.4.2.
     * Canonicalized headers should *always* use CRLF, regardless of mailer setting.
     *
     * @see https://tools.ietf.org/html/rfc6376#section-3.4.2
     *
     * @param string $signHeader Header
     *
     * @return string
     */
    public function DKIM_HeaderC($signHeader)
    {
        //Normalize breaks to CRLF (regardless of the mailer)
        $signHeader = static::normalizeBreaks($signHeader, self::CRLF);
        //Unfold header lines
        //Note PCRE \s is too broad a definition of whitespace; RFC5322 defines it as `[ \t]`
        //@see https://tools.ietf.org/html/rfc5322#section-2.2
        //That means this may break if you do something daft like put vertical tabs in your headers.
        $signHeader = preg_replace('/\r\n[ \t]+/', ' ', $signHeader);
        //Break headers out into an array
        $lines = explode(self::CRLF, $signHeader);
        foreach ($lines as $key => $line) {
            //If the header is missing a :, skip it as it's invalid
            //This is likely to happen because the explode() above will also split
            //on the trailing LE, leaving an empty line
            if (strpos($line, ':') === false) {
                continue;
            }
            list($heading, $value) = explode(':', $line, 2);
            //Lower-case header name
            $heading = strtolower($heading);
            //Collapse white space within the value, also convert WSP to space
            $value = preg_replace('/[ \t]+/', ' ', $value);
            //RFC6376 is slightly unclear here - it says to delete space at the *end* of each value
            //But then says to delete space before and after the colon.
            //Net result is the same as trimming both ends of the value.
            //By elimination, the same applies to the field name
            $lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t");
        }

        return implode(self::CRLF, $lines);
    }

    /**
     * Generate a DKIM canonicalization body.
     * Uses the 'simple' algorithm from RFC6376 section 3.4.3.
     * Canonicalized bodies should *always* use CRLF, regardless of mailer setting.
     *
     * @see https://tools.ietf.org/html/rfc6376#section-3.4.3
     *
     * @param string $body Message Body
     *
     * @return string
     */
    public function DKIM_BodyC($body)
    {
        if (empty($body)) {
            return self::CRLF;
        }
        // Normalize line endings to CRLF
        $body = static::normalizeBreaks($body, self::CRLF);

        //Reduce multiple trailing line breaks to a single one
        return static::stripTrailingWSP($body) . self::CRLF;
    }

    /**
     * Create the DKIM header and body in a new message header.
     *
     * @param string $headers_line Header lines
     * @param string $subject      Subject
     * @param string $body         Body
     *
     * @throws Exception
     *
     * @return string
     */
    public function DKIM_Add($headers_line, $subject, $body)
    {
        $DKIMsignatureType = 'rsa-sha256'; // Signature & hash algorithms
        $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization methods of header & body
        $DKIMquery = 'dns/txt'; // Query method
        $DKIMtime = time();
        //Always sign these headers without being asked
        //Recommended list from https://tools.ietf.org/html/rfc6376#section-5.4.1
        $autoSignHeaders = [
            'from',
            'to',
            'cc',
            'date',
            'subject',
            'reply-to',
            'message-id',
            'content-type',
            'mime-version',
            'x-mailer',
        ];
        if (stripos($headers_line, 'Subject') === false) {
            $headers_line .= 'Subject: ' . $subject . static::$LE;
        }
        $headerLines = explode(static::$LE, $headers_line);
        $currentHeaderLabel = '';
        $currentHeaderValue = '';
        $parsedHeaders = [];
        $headerLineIndex = 0;
        $headerLineCount = count($headerLines);
        foreach ($headerLines as $headerLine) {
            $matches = [];
            if (preg_match('/^([^ \t]*?)(?::[ \t]*)(.*)$/', $headerLine, $matches)) {
                if ($currentHeaderLabel !== '') {
                    //We were previously in another header; This is the start of a new header, so save the previous one
                    $parsedHeaders[] = ['label' => $currentHeaderLabel, 'value' => $currentHeaderValue];
                }
                $currentHeaderLabel = $matches[1];
                $currentHeaderValue = $matches[2];
            } elseif (preg_match('/^[ \t]+(.*)$/', $headerLine, $matches)) {
                //This is a folded continuation of the current header, so unfold it
                $currentHeaderValue .= ' ' . $matches[1];
            }
            ++$headerLineIndex;
            if ($headerLineIndex >= $headerLineCount) {
                //This was the last line, so finish off this header
                $parsedHeaders[] = ['label' => $currentHeaderLabel, 'value' => $currentHeaderValue];
            }
        }
        $copiedHeaders = [];
        $headersToSignKeys = [];
        $headersToSign = [];
        foreach ($parsedHeaders as $header) {
            //Is this header one that must be included in the DKIM signature?
            if (in_array(strtolower($header['label']), $autoSignHeaders, true)) {
                $headersToSignKeys[] = $header['label'];
                $headersToSign[] = $header['label'] . ': ' . $header['value'];
                if ($this->DKIM_copyHeaderFields) {
                    $copiedHeaders[] = $header['label'] . ':' . //Note no space after this, as per RFC
                        str_replace('|', '=7C', $this->DKIM_QP($header['value']));
                }
                continue;
            }
            //Is this an extra custom header we've been asked to sign?
            if (in_array($header['label'], $this->DKIM_extraHeaders, true)) {
                //Find its value in custom headers
                foreach ($this->CustomHeader as $customHeader) {
                    if ($customHeader[0] === $header['label']) {
                        $headersToSignKeys[] = $header['label'];
                        $headersToSign[] = $header['label'] . ': ' . $header['value'];
                        if ($this->DKIM_copyHeaderFields) {
                            $copiedHeaders[] = $header['label'] . ':' . //Note no space after this, as per RFC
                                str_replace('|', '=7C', $this->DKIM_QP($header['value']));
                        }
                        //Skip straight to the next header
                        continue 2;
                    }
                }
            }
        }
        $copiedHeaderFields = '';
        if ($this->DKIM_copyHeaderFields && count($copiedHeaders) > 0) {
            //Assemble a DKIM 'z' tag
            $copiedHeaderFields = ' z=';
            $first = true;
            foreach ($copiedHeaders as $copiedHeader) {
                if (!$first) {
                    $copiedHeaderFields .= static::$LE . ' |';
                }
                //Fold long values
                if (strlen($copiedHeader) > self::STD_LINE_LENGTH - 3) {
                    $copiedHeaderFields .= substr(
                        chunk_split($copiedHeader, self::STD_LINE_LENGTH - 3, static::$LE . self::FWS),
                        0,
                        -strlen(static::$LE . self::FWS)
                    );
                } else {
                    $copiedHeaderFields .= $copiedHeader;
                }
                $first = false;
            }
            $copiedHeaderFields .= ';' . static::$LE;
        }
        $headerKeys = ' h=' . implode(':', $headersToSignKeys) . ';' . static::$LE;
        $headerValues = implode(static::$LE, $headersToSign);
        $body = $this->DKIM_BodyC($body);
        $DKIMb64 = base64_encode(pack('H*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body
        $ident = '';
        if ('' !== $this->DKIM_identity) {
            $ident = ' i=' . $this->DKIM_identity . ';' . static::$LE;
        }
        //The DKIM-Signature header is included in the signature *except for* the value of the `b` tag
        //which is appended after calculating the signature
        //https://tools.ietf.org/html/rfc6376#section-3.5
        $dkimSignatureHeader = 'DKIM-Signature: v=1;' .
            ' d=' . $this->DKIM_domain . ';' .
            ' s=' . $this->DKIM_selector . ';' . static::$LE .
            ' a=' . $DKIMsignatureType . ';' .
            ' q=' . $DKIMquery . ';' .
            ' t=' . $DKIMtime . ';' .
            ' c=' . $DKIMcanonicalization . ';' . static::$LE .
            $headerKeys .
            $ident .
            $copiedHeaderFields .
            ' bh=' . $DKIMb64 . ';' . static::$LE .
            ' b=';
        //Canonicalize the set of headers
        $canonicalizedHeaders = $this->DKIM_HeaderC(
            $headerValues . static::$LE . $dkimSignatureHeader
        );
        $signature = $this->DKIM_Sign($canonicalizedHeaders);
        $signature = trim(chunk_split($signature, self::STD_LINE_LENGTH - 3, static::$LE . self::FWS));

        return static::normalizeBreaks($dkimSignatureHeader . $signature);
    }

    /**
     * Detect if a string contains a line longer than the maximum line length
     * allowed by RFC 2822 section 2.1.1.
     *
     * @param string $str
     *
     * @return bool
     */
    public static function hasLineLongerThanMax($str)
    {
        return (bool) preg_match('/^(.{' . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . ',})/m', $str);
    }

    /**
     * If a string contains any "special" characters, double-quote the name,
     * and escape any double quotes with a backslash.
     *
     * @param string $str
     *
     * @return string
     *
     * @see RFC822 3.4.1
     */
    public static function quotedString($str)
    {
        if (preg_match('/[ ()<>@,;:"\/\[\]?=]/', $str)) {
            //If the string contains any of these chars, it must be double-quoted
            //and any double quotes must be escaped with a backslash
            return '"' . str_replace('"', '\\"', $str) . '"';
        }

        //Return the string untouched, it doesn't need quoting
        return $str;
    }

    /**
     * Allows for public read access to 'to' property.
     * Before the send() call, queued addresses (i.e. with IDN) are not yet included.
     *
     * @return array
     */
    public function getToAddresses()
    {
        return $this->to;
    }

    /**
     * Allows for public read access to 'cc' property.
     * Before the send() call, queued addresses (i.e. with IDN) are not yet included.
     *
     * @return array
     */
    public function getCcAddresses()
    {
        return $this->cc;
    }

    /**
     * Allows for public read access to 'bcc' property.
     * Before the send() call, queued addresses (i.e. with IDN) are not yet included.
     *
     * @return array
     */
    public function getBccAddresses()
    {
        return $this->bcc;
    }

    /**
     * Allows for public read access to 'ReplyTo' property.
     * Before the send() call, queued addresses (i.e. with IDN) are not yet included.
     *
     * @return array
     */
    public function getReplyToAddresses()
    {
        return $this->ReplyTo;
    }

    /**
     * Allows for public read access to 'all_recipients' property.
     * Before the send() call, queued addresses (i.e. with IDN) are not yet included.
     *
     * @return array
     */
    public function getAllRecipientAddresses()
    {
        return $this->all_recipients;
    }

    /**
     * Perform a callback.
     *
     * @param bool   $isSent
     * @param array  $to
     * @param array  $cc
     * @param array  $bcc
     * @param string $subject
     * @param string $body
     * @param string $from
     * @param array  $extra
     */
    protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra)
    {
        if (!empty($this->action_function) && is_callable($this->action_function)) {
            call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra);
        }
    }

    /**
     * Get the OAuth instance.
     *
     * @return OAuth
     */
    public function getOAuth()
    {
        return $this->oauth;
    }

    /**
     * Set an OAuth instance.
     */
    public function setOAuth(OAuth $oauth)
    {
        $this->oauth = $oauth;
    }
}
PHPMailer/get_oauth_token.php000064400000011402150766203070012221 0ustar00<?php
/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5.5
 * @package PHPMailer
 * @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
 * @author Jim Jagielski (jimjag) <[email protected]>
 * @author Andy Prevost (codeworxtech) <[email protected]>
 * @author Brent R. Matzelle (original founder)
 * @copyright 2012 - 2020 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */
/**
 * Get an OAuth2 token from an OAuth2 provider.
 * * Install this script on your server so that it's accessible
 * as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
 * e.g.: http://localhost/phpmailer/get_oauth_token.php
 * * Ensure dependencies are installed with 'composer install'
 * * Set up an app in your Google/Yahoo/Microsoft account
 * * Set the script address as the app's redirect URL
 * If no refresh token is obtained when running this file,
 * revoke access to your app and run the script again.
 */

namespace PHPMailer\PHPMailer;

/**
 * Aliases for League Provider Classes
 * Make sure you have added these to your composer.json and run `composer install`
 * Plenty to choose from here:
 * @see http://oauth2-client.thephpleague.com/providers/thirdparty/
 */
// @see https://github.com/thephpleague/oauth2-google
use League\OAuth2\Client\Provider\Google;
// @see https://packagist.org/packages/hayageek/oauth2-yahoo
use Hayageek\OAuth2\Client\Provider\Yahoo;
// @see https://github.com/stevenmaguire/oauth2-microsoft
use Stevenmaguire\OAuth2\Client\Provider\Microsoft;

if (!isset($_GET['code']) && !isset($_GET['provider'])) {
?>
<html>
<body>Select Provider:<br/>
<a href='?provider=Google'>Google</a><br/>
<a href='?provider=Yahoo'>Yahoo</a><br/>
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br/>
</body>
</html>
<?php
exit;
}

require 'vendor/autoload.php';

session_start();

$providerName = '';

if (array_key_exists('provider', $_GET)) {
    $providerName = $_GET['provider'];
    $_SESSION['provider'] = $providerName;
} elseif (array_key_exists('provider', $_SESSION)) {
    $providerName = $_SESSION['provider'];
}
if (!in_array($providerName, ['Google', 'Microsoft', 'Yahoo'])) {
    exit('Only Google, Microsoft and Yahoo OAuth2 providers are currently supported in this script.');
}

//These details are obtained by setting up an app in the Google developer console,
//or whichever provider you're using.
$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';

//If this automatic URL doesn't work, set it yourself manually to the URL of this script
$redirectUri = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
//$redirectUri = 'http://localhost/PHPMailer/redirect';

$params = [
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
    'redirectUri' => $redirectUri,
    'accessType' => 'offline'
];

$options = [];
$provider = null;

switch ($providerName) {
    case 'Google':
        $provider = new Google($params);
        $options = [
            'scope' => [
                'https://mail.google.com/'
            ]
        ];
        break;
    case 'Yahoo':
        $provider = new Yahoo($params);
        break;
    case 'Microsoft':
        $provider = new Microsoft($params);
        $options = [
            'scope' => [
                'wl.imap',
                'wl.offline_access'
            ]
        ];
        break;
}

if (null === $provider) {
    exit('Provider missing');
}

if (!isset($_GET['code'])) {
    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl($options);
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: ' . $authUrl);
    exit;
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
    unset($_SESSION['oauth2state']);
    unset($_SESSION['provider']);
    exit('Invalid state');
} else {
    unset($_SESSION['provider']);
    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken(
        'authorization_code',
        [
            'code' => $_GET['code']
        ]
    );
    // Use this to interact with an API on the users behalf
    // Use this to get a new access token if the old one expires
    echo 'Refresh Token: ', $token->getRefreshToken();
}
PHPMailer/mail_template.php000064400000004467150766203070011674 0ustar00<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer's autoloader
// require 'vendor/autoload.php';

require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
require '../DefaultData.php';

// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
     //Server settings
     $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
     $mail->isSMTP();                                            // Send using SMTP
     $mail->Host       = DefaultData::Host;                    // Set the SMTP server to send through
     $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
     $mail->Username   = DefaultData::Username;                     // SMTP username
     $mail->Password   = DefaultData::Password;                               // SMTP password
     $mail->SMTPSecure = "ssl";         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
     $mail->Port       = DefaultData::Port;                                      // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail->setFrom('[email protected]', 'Mailer');
    $mail->addAddress('[email protected]', 'Hansajith');     // Add a recipient
    // $mail->addAddress('[email protected]');               // Name is optional
    // $mail->addReplyTo('[email protected]', 'Information');
    // $mail->addCC('[email protected]');
    // $mail->addBCC('[email protected]');

    // Attachments
    // $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    // $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    // Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the test HTML message body <b>in bold!</b>';
    // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}PHPMailer/language/phpmailer.lang-ja.php000064400000003604150766203070014123 0ustar00<?php
/**
 * Japanese PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Mitsuhiro Yoshida <http://mitstek.com/>
 * @author Yoshi Sakai <http://bluemooninc.jp/>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTPエラー: 認証できませんでした。';
$PHPMAILER_LANG['connect_host']         = 'SMTPエラー: SMTPホストに接続できませんでした。';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTPエラー: データが受け付けられませんでした。';
//$PHPMAILER_LANG['empty_message']        = 'Message body empty';
$PHPMAILER_LANG['encoding']             = '不明なエンコーディング: ';
$PHPMAILER_LANG['execute']              = '実行できませんでした: ';
$PHPMAILER_LANG['file_access']          = 'ファイルにアクセスできません: ';
$PHPMAILER_LANG['file_open']            = 'ファイルエラー: ファイルを開けません: ';
$PHPMAILER_LANG['from_failed']          = 'Fromアドレスを登録する際にエラーが発生しました: ';
$PHPMAILER_LANG['instantiate']          = 'メール関数が正常に動作しませんでした。';
//$PHPMAILER_LANG['invalid_address']      = 'Invalid address: ';
$PHPMAILER_LANG['provide_address']      = '少なくとも1つメールアドレスを 指定する必要があります。';
$PHPMAILER_LANG['mailer_not_supported'] = ' メーラーがサポートされていません。';
$PHPMAILER_LANG['recipients_failed']    = 'SMTPエラー: 次の受信者アドレスに 間違いがあります: ';
//$PHPMAILER_LANG['signing']              = 'Signing Error: ';
//$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() failed.';
//$PHPMAILER_LANG['smtp_error']           = 'SMTP server error: ';
//$PHPMAILER_LANG['variable_set']         = 'Cannot set or reset variable: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-nb.php000064400000003022150766203070014122 0ustar00<?php
/**
 * Norwegian Bokmål PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Feil: Kunne ikke autentisere.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Feil: Kunne ikke koble til SMTP tjener.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Feil: Datainnhold ikke akseptert.';
$PHPMAILER_LANG['empty_message']        = 'Meldingsinnhold mangler';
$PHPMAILER_LANG['encoding']             = 'Ukjent koding: ';
$PHPMAILER_LANG['execute']              = 'Kunne ikke utføre: ';
$PHPMAILER_LANG['file_access']          = 'Får ikke tilgang til filen: ';
$PHPMAILER_LANG['file_open']            = 'Fil Feil: Kunne ikke åpne filen: ';
$PHPMAILER_LANG['from_failed']          = 'Følgende Frå adresse feilet: ';
$PHPMAILER_LANG['instantiate']          = 'Kunne ikke initialisere post funksjon.';
$PHPMAILER_LANG['invalid_address']      = 'Ugyldig adresse: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' sender er ikke støttet.';
$PHPMAILER_LANG['provide_address']      = 'Du må opppgi minst en mottakeradresse.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Feil: Følgende mottakeradresse feilet: ';
$PHPMAILER_LANG['signing']              = 'Signering Feil: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP connect() feilet.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP server feil: ';
$PHPMAILER_LANG['variable_set']         = 'Kan ikke skrive eller omskrive variabel: ';
$PHPMAILER_LANG['extension_missing']    = 'Utvidelse mangler: ';
PHPMailer/language/phpmailer.lang-fr.php000064400000003724150766203070014143 0ustar00<?php
/**
 * French PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * Some French punctuation requires a thin non-breaking space (U+202F) character before it,
 * for example before a colon or exclamation mark.
 * There is one of these characters between these quotes: " "
 * @see http://unicode.org/udhr/n/notes_fra.html
 */

$PHPMAILER_LANG['authenticate']         = 'Erreur SMTP : échec de l\'authentification.';
$PHPMAILER_LANG['connect_host']         = 'Erreur SMTP : impossible de se connecter au serveur SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Erreur SMTP : données incorrectes.';
$PHPMAILER_LANG['empty_message']        = 'Corps du message vide.';
$PHPMAILER_LANG['encoding']             = 'Encodage inconnu : ';
$PHPMAILER_LANG['execute']              = 'Impossible de lancer l\'exécution : ';
$PHPMAILER_LANG['file_access']          = 'Impossible d\'accéder au fichier : ';
$PHPMAILER_LANG['file_open']            = 'Ouverture du fichier impossible : ';
$PHPMAILER_LANG['from_failed']          = 'L\'adresse d\'expéditeur suivante a échoué : ';
$PHPMAILER_LANG['instantiate']          = 'Impossible d\'instancier la fonction mail.';
$PHPMAILER_LANG['invalid_address']      = 'L\'adresse courriel n\'est pas valide : ';
$PHPMAILER_LANG['mailer_not_supported'] = ' client de messagerie non supporté.';
$PHPMAILER_LANG['provide_address']      = 'Vous devez fournir au moins une adresse de destinataire.';
$PHPMAILER_LANG['recipients_failed']    = 'Erreur SMTP : les destinataires suivants sont en erreur : ';
$PHPMAILER_LANG['signing']              = 'Erreur de signature : ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Échec de la connexion SMTP.';
$PHPMAILER_LANG['smtp_error']           = 'Erreur du serveur SMTP : ';
$PHPMAILER_LANG['variable_set']         = 'Impossible d\'initialiser ou de réinitialiser une variable : ';
$PHPMAILER_LANG['extension_missing']    = 'Extension manquante : ';
PHPMailer/language/phpmailer.lang-hi.php000064400000005037150766203070014133 0ustar00<?php
/**
 * Hindi PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Yash Karanke <[email protected]>
 */
 
$PHPMAILER_LANG['authenticate']         = 'SMTP त्रुटि: प्रामाणिकता की जांच नहीं हो सका। ';
$PHPMAILER_LANG['connect_host']         = 'SMTP त्रुटि: SMTP सर्वर से कनेक्ट नहीं हो सका। ';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP त्रुटि: डेटा स्वीकार नहीं किया जाता है। ';
$PHPMAILER_LANG['empty_message']        = 'संदेश खाली है। ';
$PHPMAILER_LANG['encoding']             = 'अज्ञात एन्कोडिंग प्रकार। ';
$PHPMAILER_LANG['execute']              = 'आदेश को निष्पादित करने में विफल। ';
$PHPMAILER_LANG['file_access']          = 'फ़ाइल उपलब्ध नहीं है। ';
$PHPMAILER_LANG['file_open']            = 'फ़ाइल त्रुटि: फाइल को खोला नहीं जा सका। ';
$PHPMAILER_LANG['from_failed']          = 'प्रेषक का पता गलत है। ';
$PHPMAILER_LANG['instantiate']          = 'मेल फ़ंक्शन कॉल नहीं कर सकता है।';
$PHPMAILER_LANG['invalid_address']      = 'पता गलत है। ';
$PHPMAILER_LANG['mailer_not_supported'] = 'मेल सर्वर के साथ काम नहीं करता है। ';
$PHPMAILER_LANG['provide_address']      = 'आपको कम से कम एक प्राप्तकर्ता का ई-मेल पता प्रदान करना होगा।';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP त्रुटि: निम्न प्राप्तकर्ताओं को पते भेजने में विफल। ';
$PHPMAILER_LANG['signing']              = 'साइनअप त्रुटि:। ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP का connect () फ़ंक्शन विफल हुआ। ';
$PHPMAILER_LANG['smtp_error']           = 'SMTP सर्वर त्रुटि। ';
$PHPMAILER_LANG['variable_set']         = 'चर को बना या संशोधित नहीं किया जा सकता। ';
$PHPMAILER_LANG['extension_missing']    = 'एक्सटेन्षन गायब है: ';
PHPMailer/language/phpmailer.lang-ca.php000064400000003301150766203070014106 0ustar00<?php
/**
 * Catalan PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Ivan <web AT microstudi DOT com>
 */

$PHPMAILER_LANG['authenticate']         = 'Error SMTP: No s’ha pogut autenticar.';
$PHPMAILER_LANG['connect_host']         = 'Error SMTP: No es pot connectar al servidor SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Error SMTP: Dades no acceptades.';
$PHPMAILER_LANG['empty_message']        = 'El cos del missatge està buit.';
$PHPMAILER_LANG['encoding']             = 'Codificació desconeguda: ';
$PHPMAILER_LANG['execute']              = 'No es pot executar: ';
$PHPMAILER_LANG['file_access']          = 'No es pot accedir a l’arxiu: ';
$PHPMAILER_LANG['file_open']            = 'Error d’Arxiu: No es pot obrir l’arxiu: ';
$PHPMAILER_LANG['from_failed']          = 'La(s) següent(s) adreces de remitent han fallat: ';
$PHPMAILER_LANG['instantiate']          = 'No s’ha pogut crear una instància de la funció Mail.';
$PHPMAILER_LANG['invalid_address']      = 'Adreça d’email invalida: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no està suportat';
$PHPMAILER_LANG['provide_address']      = 'S’ha de proveir almenys una adreça d’email com a destinatari.';
$PHPMAILER_LANG['recipients_failed']    = 'Error SMTP: Els següents destinataris han fallat: ';
$PHPMAILER_LANG['signing']              = 'Error al signar: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Ha fallat el SMTP Connect().';
$PHPMAILER_LANG['smtp_error']           = 'Error del servidor SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'No s’ha pogut establir o restablir la variable: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-cs.php000064400000003156150766203070014140 0ustar00<?php
/**
 * Czech PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'Chyba SMTP: Autentizace selhala.';
$PHPMAILER_LANG['connect_host']         = 'Chyba SMTP: Nelze navázat spojení se SMTP serverem.';
$PHPMAILER_LANG['data_not_accepted']    = 'Chyba SMTP: Data nebyla přijata.';
$PHPMAILER_LANG['empty_message']        = 'Prázdné tělo zprávy';
$PHPMAILER_LANG['encoding']             = 'Neznámé kódování: ';
$PHPMAILER_LANG['execute']              = 'Nelze provést: ';
$PHPMAILER_LANG['file_access']          = 'Nelze získat přístup k souboru: ';
$PHPMAILER_LANG['file_open']            = 'Chyba souboru: Nelze otevřít soubor pro čtení: ';
$PHPMAILER_LANG['from_failed']          = 'Následující adresa odesílatele je nesprávná: ';
$PHPMAILER_LANG['instantiate']          = 'Nelze vytvořit instanci emailové funkce.';
$PHPMAILER_LANG['invalid_address']      = 'Neplatná adresa: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer není podporován.';
$PHPMAILER_LANG['provide_address']      = 'Musíte zadat alespoň jednu emailovou adresu příjemce.';
$PHPMAILER_LANG['recipients_failed']    = 'Chyba SMTP: Následující adresy příjemců nejsou správně: ';
$PHPMAILER_LANG['signing']              = 'Chyba přihlašování: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() selhal.';
$PHPMAILER_LANG['smtp_error']           = 'Chyba SMTP serveru: ';
$PHPMAILER_LANG['variable_set']         = 'Nelze nastavit nebo změnit proměnnou: ';
$PHPMAILER_LANG['extension_missing']    = 'Chybí rozšíření: ';
PHPMailer/language/phpmailer.lang-be.php000064400000004201150766203070014111 0ustar00<?php
/**
 * Belarusian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Aleksander Maksymiuk <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Памылка SMTP: памылка ідэнтыфікацыі.';
$PHPMAILER_LANG['connect_host']         = 'Памылка SMTP: нельга ўстанавіць сувязь з SMTP-серверам.';
$PHPMAILER_LANG['data_not_accepted']    = 'Памылка SMTP: звесткі непрынятыя.';
$PHPMAILER_LANG['empty_message']        = 'Пустое паведамленне.';
$PHPMAILER_LANG['encoding']             = 'Невядомая кадыроўка тэксту: ';
$PHPMAILER_LANG['execute']              = 'Нельга выканаць каманду: ';
$PHPMAILER_LANG['file_access']          = 'Няма доступу да файла: ';
$PHPMAILER_LANG['file_open']            = 'Нельга адкрыць файл: ';
$PHPMAILER_LANG['from_failed']          = 'Няправільны адрас адпраўніка: ';
$PHPMAILER_LANG['instantiate']          = 'Нельга прымяніць функцыю mail().';
$PHPMAILER_LANG['invalid_address']      = 'Нельга даслаць паведамленне, няправільны email атрымальніка: ';
$PHPMAILER_LANG['provide_address']      = 'Запоўніце, калі ласка, правільны email атрымальніка.';
$PHPMAILER_LANG['mailer_not_supported'] = ' - паштовы сервер не падтрымліваецца.';
$PHPMAILER_LANG['recipients_failed']    = 'Памылка SMTP: няправільныя атрымальнікі: ';
$PHPMAILER_LANG['signing']              = 'Памылка подпісу паведамлення: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Памылка сувязі з SMTP-серверам.';
$PHPMAILER_LANG['smtp_error']           = 'Памылка SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Нельга ўстанавіць або перамяніць значэнне пераменнай: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-et.php000064400000003317150766203070014142 0ustar00<?php
/**
 * Estonian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Indrek Päri
 * @author Elan Ruusamäe <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Viga: Autoriseerimise viga.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Viga: Ei õnnestunud luua ühendust SMTP serveriga.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Viga: Vigased andmed.';
$PHPMAILER_LANG['empty_message']        = 'Tühi kirja sisu';
$PHPMAILER_LANG["encoding"]             = 'Tundmatu kodeering: ';
$PHPMAILER_LANG['execute']              = 'Tegevus ebaõnnestus: ';
$PHPMAILER_LANG['file_access']          = 'Pole piisavalt õiguseid järgneva faili avamiseks: ';
$PHPMAILER_LANG['file_open']            = 'Faili Viga: Faili avamine ebaõnnestus: ';
$PHPMAILER_LANG['from_failed']          = 'Järgnev saatja e-posti aadress on vigane: ';
$PHPMAILER_LANG['instantiate']          = 'mail funktiooni käivitamine ebaõnnestus.';
$PHPMAILER_LANG['invalid_address']      = 'Saatmine peatatud, e-posti address vigane: ';
$PHPMAILER_LANG['provide_address']      = 'Te peate määrama vähemalt ühe saaja e-posti aadressi.';
$PHPMAILER_LANG['mailer_not_supported'] = ' maileri tugi puudub.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Viga: Järgnevate saajate e-posti aadressid on vigased: ';
$PHPMAILER_LANG["signing"]              = 'Viga allkirjastamisel: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() ebaõnnestus.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP serveri viga: ';
$PHPMAILER_LANG['variable_set']         = 'Ei õnnestunud määrata või lähtestada muutujat: ';
$PHPMAILER_LANG['extension_missing']    = 'Nõutud laiendus on puudu: ';
PHPMailer/language/phpmailer.lang-tl.php000064400000003244150766203070014150 0ustar00<?php
/**
 * Tagalog PHPMailer language file: refer to English translation for definitive list
 *
 *   @package PHPMailer
 *   @author Adriane Justine Tan <[email protected]>
 */
 
$PHPMAILER_LANG['authenticate']         = 'SMTP Error: Hindi mapatotohanan.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Error: Hindi makakonekta sa SMTP host.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Error: Ang datos ay hindi maaaring matatanggap.';
$PHPMAILER_LANG['empty_message']        = 'Walang laman ang mensahe';
$PHPMAILER_LANG['encoding']             = 'Hindi alam ang encoding: ';
$PHPMAILER_LANG['execute']              = 'Hindi maisasagawa: ';
$PHPMAILER_LANG['file_access']          = 'Hindi ma-access ang file: ';
$PHPMAILER_LANG['file_open']            = 'Hindi mabuksan ang file: ';
$PHPMAILER_LANG['from_failed']          = 'Ang sumusunod na address ay nabigo: ';
$PHPMAILER_LANG['instantiate']          = 'Hindi maaaring magbigay ng institusyon ang mail';
$PHPMAILER_LANG['invalid_address']      = 'Hindi wasto ang address na naibigay: ';
$PHPMAILER_LANG['mailer_not_supported'] = 'Ang mailer ay hindi suportado';
$PHPMAILER_LANG['provide_address']      = 'Kailangan mong magbigay ng kahit isang email address na tatanggap';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Error: Ang mga sumusunod na tatanggap ay nabigo: ';
$PHPMAILER_LANG['signing']              = 'Hindi ma-sign';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Ang SMTP connect() ay nabigo';
$PHPMAILER_LANG['smtp_error']           = 'Ang server ng SMTP ay nabigo';
$PHPMAILER_LANG['variable_set']         = 'Hindi matatakda ang mga variables: ';
$PHPMAILER_LANG['extension_missing']    = 'Nawawala ang extension';
PHPMailer/language/phpmailer.lang-zh_cn.php000064400000003167150766203070014636 0ustar00<?php
/**
 * Simplified Chinese PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author liqwei <[email protected]>
 * @author young <[email protected]>
 * @author Teddysun <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP 错误:登录失败。';
$PHPMAILER_LANG['connect_host']         = 'SMTP 错误:无法连接到 SMTP 主机。';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP 错误:数据不被接受。';
$PHPMAILER_LANG['empty_message']        = '邮件正文为空。';
$PHPMAILER_LANG['encoding']             = '未知编码:';
$PHPMAILER_LANG['execute']              = '无法执行:';
$PHPMAILER_LANG['file_access']          = '无法访问文件:';
$PHPMAILER_LANG['file_open']            = '文件错误:无法打开文件:';
$PHPMAILER_LANG['from_failed']          = '发送地址错误:';
$PHPMAILER_LANG['instantiate']          = '未知函数调用。';
$PHPMAILER_LANG['invalid_address']      = '发送失败,电子邮箱地址是无效的:';
$PHPMAILER_LANG['mailer_not_supported'] = '发信客户端不被支持。';
$PHPMAILER_LANG['provide_address']      = '必须提供至少一个收件人地址。';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP 错误:收件人地址错误:';
$PHPMAILER_LANG['signing']              = '登录失败:';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP服务器连接失败。';
$PHPMAILER_LANG['smtp_error']           = 'SMTP服务器出错:';
$PHPMAILER_LANG['variable_set']         = '无法设置或重置变量:';
$PHPMAILER_LANG['extension_missing']    = '丢失模块 Extension:';
PHPMailer/language/phpmailer.lang-az.php000064400000003324150766203070014142 0ustar00<?php
/**
 * Azerbaijani PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author @mirjalal
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP xətası: Giriş uğursuz oldu.';
$PHPMAILER_LANG['connect_host']         = 'SMTP xətası: SMTP serverinə qoşulma uğursuz oldu.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP xətası: Verilənlər qəbul edilməyib.';
$PHPMAILER_LANG['empty_message']        = 'Boş mesaj göndərilə bilməz.';
$PHPMAILER_LANG['encoding']             = 'Qeyri-müəyyən kodlaşdırma: ';
$PHPMAILER_LANG['execute']              = 'Əmr yerinə yetirilmədi: ';
$PHPMAILER_LANG['file_access']          = 'Fayla giriş yoxdur: ';
$PHPMAILER_LANG['file_open']            = 'Fayl xətası: Fayl açıla bilmədi: ';
$PHPMAILER_LANG['from_failed']          = 'Göstərilən poçtlara göndərmə uğursuz oldu: ';
$PHPMAILER_LANG['instantiate']          = 'Mail funksiyası işə salına bilmədi.';
$PHPMAILER_LANG['invalid_address']      = 'Düzgün olmayan e-mail adresi: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' - e-mail kitabxanası dəstəklənmir.';
$PHPMAILER_LANG['provide_address']      = 'Ən azı bir e-mail adresi daxil edilməlidir.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP xətası: Aşağıdakı ünvanlar üzrə alıcılara göndərmə uğursuzdur: ';
$PHPMAILER_LANG['signing']              = 'İmzalama xətası: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP serverinə qoşulma uğursuz oldu.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP serveri xətası: ';
$PHPMAILER_LANG['variable_set']         = 'Dəyişənin quraşdırılması uğursuz oldu: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-de.php000064400000003326150766203070014122 0ustar00<?php
/**
 * German PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP-Fehler: Authentifizierung fehlgeschlagen.';
$PHPMAILER_LANG['connect_host']         = 'SMTP-Fehler: Konnte keine Verbindung zum SMTP-Host herstellen.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP-Fehler: Daten werden nicht akzeptiert.';
$PHPMAILER_LANG['empty_message']        = 'E-Mail-Inhalt ist leer.';
$PHPMAILER_LANG['encoding']             = 'Unbekannte Kodierung: ';
$PHPMAILER_LANG['execute']              = 'Konnte folgenden Befehl nicht ausführen: ';
$PHPMAILER_LANG['file_access']          = 'Zugriff auf folgende Datei fehlgeschlagen: ';
$PHPMAILER_LANG['file_open']            = 'Dateifehler: Konnte folgende Datei nicht öffnen: ';
$PHPMAILER_LANG['from_failed']          = 'Die folgende Absenderadresse ist nicht korrekt: ';
$PHPMAILER_LANG['instantiate']          = 'Mail-Funktion konnte nicht initialisiert werden.';
$PHPMAILER_LANG['invalid_address']      = 'Die Adresse ist ungültig: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wird nicht unterstützt.';
$PHPMAILER_LANG['provide_address']      = 'Bitte geben Sie mindestens eine Empfängeradresse an.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP-Fehler: Die folgenden Empfänger sind nicht korrekt: ';
$PHPMAILER_LANG['signing']              = 'Fehler beim Signieren: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Verbindung zum SMTP-Server fehlgeschlagen.';
$PHPMAILER_LANG['smtp_error']           = 'Fehler vom SMTP-Server: ';
$PHPMAILER_LANG['variable_set']         = 'Kann Variable nicht setzen oder zurücksetzen: ';
$PHPMAILER_LANG['extension_missing']    = 'Fehlende Erweiterung: ';
PHPMailer/language/phpmailer.lang-pt.php000064400000003540150766203070014153 0ustar00<?php
/**
 * Portuguese (European) PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Jonadabe <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Erro do SMTP: Não foi possível realizar a autenticação.';
$PHPMAILER_LANG['connect_host']         = 'Erro do SMTP: Não foi possível realizar ligação com o servidor SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Erro do SMTP: Os dados foram rejeitados.';
$PHPMAILER_LANG['empty_message']        = 'A mensagem no e-mail está vazia.';
$PHPMAILER_LANG['encoding']             = 'Codificação desconhecida: ';
$PHPMAILER_LANG['execute']              = 'Não foi possível executar: ';
$PHPMAILER_LANG['file_access']          = 'Não foi possível aceder o ficheiro: ';
$PHPMAILER_LANG['file_open']            = 'Abertura do ficheiro: Não foi possível abrir o ficheiro: ';
$PHPMAILER_LANG['from_failed']          = 'Ocorreram falhas nos endereços dos seguintes remententes: ';
$PHPMAILER_LANG['instantiate']          = 'Não foi possível iniciar uma instância da função mail.';
$PHPMAILER_LANG['invalid_address']      = 'Não foi enviado nenhum e-mail para o endereço de e-mail inválido: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.';
$PHPMAILER_LANG['provide_address']      = 'Tem de fornecer pelo menos um endereço como destinatário do e-mail.';
$PHPMAILER_LANG['recipients_failed']    = 'Erro do SMTP: O endereço do seguinte destinatário falhou: ';
$PHPMAILER_LANG['signing']              = 'Erro ao assinar: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() falhou.';
$PHPMAILER_LANG['smtp_error']           = 'Erro de servidor SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Não foi possível definir ou redefinir a variável: ';
$PHPMAILER_LANG['extension_missing']    = 'Extensão em falta: ';
PHPMailer/language/phpmailer.lang-sr.php000064400000004374150766203100014154 0ustar00<?php
/**
 * Serbian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Александар Јевремовић <[email protected]>
 * @author Miloš Milanović <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP грешка: аутентификација није успела.';
$PHPMAILER_LANG['connect_host']         = 'SMTP грешка: повезивање са SMTP сервером није успело.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP грешка: подаци нису прихваћени.';
$PHPMAILER_LANG['empty_message']        = 'Садржај поруке је празан.';
$PHPMAILER_LANG['encoding']             = 'Непознато кодирање: ';
$PHPMAILER_LANG['execute']              = 'Није могуће извршити наредбу: ';
$PHPMAILER_LANG['file_access']          = 'Није могуће приступити датотеци: ';
$PHPMAILER_LANG['file_open']            = 'Није могуће отворити датотеку: ';
$PHPMAILER_LANG['from_failed']          = 'SMTP грешка: слање са следећих адреса није успело: ';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP грешка: слање на следеће адресе није успело: ';
$PHPMAILER_LANG['instantiate']          = 'Није могуће покренути mail функцију.';
$PHPMAILER_LANG['invalid_address']      = 'Порука није послата. Неисправна адреса: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' мејлер није подржан.';
$PHPMAILER_LANG['provide_address']      = 'Дефинишите бар једну адресу примаоца.';
$PHPMAILER_LANG['signing']              = 'Грешка приликом пријаве: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Повезивање са SMTP сервером није успело.';
$PHPMAILER_LANG['smtp_error']           = 'Грешка SMTP сервера: ';
$PHPMAILER_LANG['variable_set']         = 'Није могуће задати нити ресетовати променљиву: ';
$PHPMAILER_LANG['extension_missing']    = 'Недостаје проширење: ';
PHPMailer/language/phpmailer.lang-id.php000064400000003356150766203100014123 0ustar00<?php
/**
 * Indonesian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Cecep Prawiro <[email protected]>
 * @author @januridp
 */

$PHPMAILER_LANG['authenticate']         = 'Kesalahan SMTP: Tidak dapat mengotentikasi.';
$PHPMAILER_LANG['connect_host']         = 'Kesalahan SMTP: Tidak dapat terhubung ke host SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Kesalahan SMTP: Data tidak diterima.';
$PHPMAILER_LANG['empty_message']        = 'Isi pesan kosong';
$PHPMAILER_LANG['encoding']             = 'Pengkodean karakter tidak dikenali: ';
$PHPMAILER_LANG['execute']              = 'Tidak dapat menjalankan proses : ';
$PHPMAILER_LANG['file_access']          = 'Tidak dapat mengakses berkas : ';
$PHPMAILER_LANG['file_open']            = 'Kesalahan File: Berkas tidak dapat dibuka : ';
$PHPMAILER_LANG['from_failed']          = 'Alamat pengirim berikut mengakibatkan kesalahan : ';
$PHPMAILER_LANG['instantiate']          = 'Tidak dapat menginisialisasi fungsi surel';
$PHPMAILER_LANG['invalid_address']      = 'Gagal terkirim, alamat surel tidak benar : ';
$PHPMAILER_LANG['provide_address']      = 'Harus disediakan minimal satu alamat tujuan';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer tidak didukung';
$PHPMAILER_LANG['recipients_failed']    = 'Kesalahan SMTP: Alamat tujuan berikut menghasilkan kesalahan : ';
$PHPMAILER_LANG['signing']              = 'Kesalahan dalam tanda tangan : ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() gagal.';
$PHPMAILER_LANG['smtp_error']           = 'Kesalahan pada pelayan SMTP : ';
$PHPMAILER_LANG['variable_set']         = 'Tidak dapat mengatur atau mengatur ulang variable : ';
$PHPMAILER_LANG['extension_missing']    = 'Ekstensi hilang: ';
PHPMailer/language/phpmailer.lang-sk.php000064400000003335150766203100014141 0ustar00<?php
/**
 * Slovak PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Michal Tinka <[email protected]>
 * @author Peter Orlický <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Error: Chyba autentifikácie.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Error: Nebolo možné nadviazať spojenie so SMTP serverom.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Error: Dáta neboli prijaté';
$PHPMAILER_LANG['empty_message']        = 'Prázdne telo správy.';
$PHPMAILER_LANG['encoding']             = 'Neznáme kódovanie: ';
$PHPMAILER_LANG['execute']              = 'Nedá sa vykonať: ';
$PHPMAILER_LANG['file_access']          = 'Súbor nebol nájdený: ';
$PHPMAILER_LANG['file_open']            = 'File Error: Súbor sa otvoriť pre čítanie: ';
$PHPMAILER_LANG['from_failed']          = 'Následujúca adresa From je nesprávna: ';
$PHPMAILER_LANG['instantiate']          = 'Nedá sa vytvoriť inštancia emailovej funkcie.';
$PHPMAILER_LANG['invalid_address']      = 'Neodoslané, emailová adresa je nesprávna: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' emailový klient nieje podporovaný.';
$PHPMAILER_LANG['provide_address']      = 'Musíte zadať aspoň jednu emailovú adresu príjemcu.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Error: Adresy príjemcov niesu správne ';
$PHPMAILER_LANG['signing']              = 'Chyba prihlasovania: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() zlyhalo.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP chyba serveru: ';
$PHPMAILER_LANG['variable_set']         = 'Nemožno nastaviť alebo resetovať premennú: ';
$PHPMAILER_LANG['extension_missing']    = 'Chýba rozšírenie: ';
PHPMailer/language/phpmailer.lang-hy.php000064400000004211150766203100014136 0ustar00<?php
/**
 * Armenian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Hrayr Grigoryan <[email protected]>
 */
 
$PHPMAILER_LANG['authenticate']         = 'SMTP -ի սխալ: չհաջողվեց ստուգել իսկությունը.';
$PHPMAILER_LANG['connect_host']         = 'SMTP -ի սխալ: չհաջողվեց կապ հաստատել SMTP սերվերի հետ.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP -ի սխալ: տվյալները ընդունված չեն.';
$PHPMAILER_LANG['empty_message']        = 'Հաղորդագրությունը դատարկ է';
$PHPMAILER_LANG['encoding']             = 'Կոդավորման անհայտ տեսակ: ';
$PHPMAILER_LANG['execute']              = 'Չհաջողվեց իրականացնել հրամանը: ';
$PHPMAILER_LANG['file_access']          = 'Ֆայլը հասանելի չէ: ';
$PHPMAILER_LANG['file_open']            = 'Ֆայլի սխալ: ֆայլը չհաջողվեց բացել: ';
$PHPMAILER_LANG['from_failed']          = 'Ուղարկողի հետևյալ հասցեն սխալ է: ';
$PHPMAILER_LANG['instantiate']          = 'Հնարավոր չէ կանչել mail ֆունկցիան.';
$PHPMAILER_LANG['invalid_address']      = 'Հասցեն սխալ է: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' փոստային սերվերի հետ չի աշխատում.';
$PHPMAILER_LANG['provide_address']      = 'Անհրաժեշտ է տրամադրել գոնե մեկ ստացողի e-mail հասցե.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP -ի սխալ: չի հաջողվել ուղարկել հետևյալ ստացողների հասցեներին: ';
$PHPMAILER_LANG['signing']              = 'Ստորագրման սխալ: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP -ի connect() ֆունկցիան չի հաջողվել';
$PHPMAILER_LANG['smtp_error']           = 'SMTP սերվերի սխալ: ';
$PHPMAILER_LANG['variable_set']         = 'Չի հաջողվում ստեղծել կամ վերափոխել փոփոխականը: ';
$PHPMAILER_LANG['extension_missing']    = 'Հավելվածը բացակայում է: ';
PHPMailer/language/phpmailer.lang-fo.php000064400000003144150766203100014126 0ustar00<?php
/**
 * Faroese PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Dávur Sørensen <http://www.profo-webdesign.dk>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP feilur: Kundi ikki góðkenna.';
$PHPMAILER_LANG['connect_host']         = 'SMTP feilur: Kundi ikki knýta samband við SMTP vert.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP feilur: Data ikki góðkent.';
//$PHPMAILER_LANG['empty_message']        = 'Message body empty';
$PHPMAILER_LANG['encoding']             = 'Ókend encoding: ';
$PHPMAILER_LANG['execute']              = 'Kundi ikki útføra: ';
$PHPMAILER_LANG['file_access']          = 'Kundi ikki tilganga fílu: ';
$PHPMAILER_LANG['file_open']            = 'Fílu feilur: Kundi ikki opna fílu: ';
$PHPMAILER_LANG['from_failed']          = 'fylgjandi Frá/From adressa miseydnaðist: ';
$PHPMAILER_LANG['instantiate']          = 'Kuni ikki instantiera mail funktión.';
//$PHPMAILER_LANG['invalid_address']      = 'Invalid address: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' er ikki supporterað.';
$PHPMAILER_LANG['provide_address']      = 'Tú skal uppgeva minst móttakara-emailadressu(r).';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Feilur: Fylgjandi móttakarar miseydnaðust: ';
//$PHPMAILER_LANG['signing']              = 'Signing Error: ';
//$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() failed.';
//$PHPMAILER_LANG['smtp_error']           = 'SMTP server error: ';
//$PHPMAILER_LANG['variable_set']         = 'Cannot set or reset variable: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-ru.php000064400000004306150766203100014151 0ustar00<?php
/**
 * Russian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Alexey Chumakov <[email protected]>
 * @author Foster Snowhill <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Ошибка SMTP: ошибка авторизации.';
$PHPMAILER_LANG['connect_host']         = 'Ошибка SMTP: не удается подключиться к SMTP-серверу.';
$PHPMAILER_LANG['data_not_accepted']    = 'Ошибка SMTP: данные не приняты.';
$PHPMAILER_LANG['encoding']             = 'Неизвестная кодировка: ';
$PHPMAILER_LANG['execute']              = 'Невозможно выполнить команду: ';
$PHPMAILER_LANG['file_access']          = 'Нет доступа к файлу: ';
$PHPMAILER_LANG['file_open']            = 'Файловая ошибка: не удаётся открыть файл: ';
$PHPMAILER_LANG['from_failed']          = 'Неверный адрес отправителя: ';
$PHPMAILER_LANG['instantiate']          = 'Невозможно запустить функцию mail().';
$PHPMAILER_LANG['provide_address']      = 'Пожалуйста, введите хотя бы один email-адрес получателя.';
$PHPMAILER_LANG['mailer_not_supported'] = ' — почтовый сервер не поддерживается.';
$PHPMAILER_LANG['recipients_failed']    = 'Ошибка SMTP: не удалась отправка таким адресатам: ';
$PHPMAILER_LANG['empty_message']        = 'Пустое сообщение';
$PHPMAILER_LANG['invalid_address']      = 'Не отправлено из-за неправильного формата email-адреса: ';
$PHPMAILER_LANG['signing']              = 'Ошибка подписи: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Ошибка соединения с SMTP-сервером';
$PHPMAILER_LANG['smtp_error']           = 'Ошибка SMTP-сервера: ';
$PHPMAILER_LANG['variable_set']         = 'Невозможно установить или сбросить переменную: ';
$PHPMAILER_LANG['extension_missing']    = 'Расширение отсутствует: ';
PHPMailer/language/phpmailer.lang-hr.php000064400000003331150766203100014131 0ustar00<?php
/**
 * Croatian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Hrvoj3e <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Greška: Neuspjela autentikacija.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Greška: Ne mogu se spojiti na SMTP poslužitelj.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Greška: Podatci nisu prihvaćeni.';
$PHPMAILER_LANG['empty_message']        = 'Sadržaj poruke je prazan.';
$PHPMAILER_LANG['encoding']             = 'Nepoznati encoding: ';
$PHPMAILER_LANG['execute']              = 'Nije moguće izvršiti naredbu: ';
$PHPMAILER_LANG['file_access']          = 'Nije moguće pristupiti datoteci: ';
$PHPMAILER_LANG['file_open']            = 'Nije moguće otvoriti datoteku: ';
$PHPMAILER_LANG['from_failed']          = 'SMTP Greška: Slanje s navedenih e-mail adresa nije uspjelo: ';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Greška: Slanje na navedenih e-mail adresa nije uspjelo: ';
$PHPMAILER_LANG['instantiate']          = 'Ne mogu pokrenuti mail funkcionalnost.';
$PHPMAILER_LANG['invalid_address']      = 'E-mail nije poslan. Neispravna e-mail adresa: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nije podržan.';
$PHPMAILER_LANG['provide_address']      = 'Definirajte barem jednu adresu primatelja.';
$PHPMAILER_LANG['signing']              = 'Greška prilikom prijave: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Spajanje na SMTP poslužitelj nije uspjelo.';
$PHPMAILER_LANG['smtp_error']           = 'Greška SMTP poslužitelja: ';
$PHPMAILER_LANG['variable_set']         = 'Ne mogu postaviti varijablu niti ju vratiti nazad: ';
$PHPMAILER_LANG['extension_missing']    = 'Nedostaje proširenje: ';
PHPMailer/language/phpmailer.lang-it.php000064400000003432150766203100014136 0ustar00<?php
/**
 * Italian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Ilias Bartolini <[email protected]>
 * @author Stefano Sabatini <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Error: Impossibile autenticarsi.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Error: Impossibile connettersi all\'host SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Error: Dati non accettati dal server.';
$PHPMAILER_LANG['empty_message']        = 'Il corpo del messaggio è vuoto';
$PHPMAILER_LANG['encoding']             = 'Codifica dei caratteri sconosciuta: ';
$PHPMAILER_LANG['execute']              = 'Impossibile eseguire l\'operazione: ';
$PHPMAILER_LANG['file_access']          = 'Impossibile accedere al file: ';
$PHPMAILER_LANG['file_open']            = 'File Error: Impossibile aprire il file: ';
$PHPMAILER_LANG['from_failed']          = 'I seguenti indirizzi mittenti hanno generato errore: ';
$PHPMAILER_LANG['instantiate']          = 'Impossibile istanziare la funzione mail';
$PHPMAILER_LANG['invalid_address']      = 'Impossibile inviare, l\'indirizzo email non è valido: ';
$PHPMAILER_LANG['provide_address']      = 'Deve essere fornito almeno un indirizzo ricevente';
$PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Error: I seguenti indirizzi destinatari hanno generato un errore: ';
$PHPMAILER_LANG['signing']              = 'Errore nella firma: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() fallita.';
$PHPMAILER_LANG['smtp_error']           = 'Errore del server SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Impossibile impostare o resettare la variabile: ';
$PHPMAILER_LANG['extension_missing']    = 'Estensione mancante: ';
PHPMailer/language/phpmailer.lang-uk.php000064400000004341150766203100014141 0ustar00<?php
/**
 * Ukrainian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Yuriy Rudyy <[email protected]>
 * @fixed by Boris Yurchenko <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Помилка SMTP: помилка авторизації.';
$PHPMAILER_LANG['connect_host']         = 'Помилка SMTP: не вдається під\'єднатися до SMTP-серверу.';
$PHPMAILER_LANG['data_not_accepted']    = 'Помилка SMTP: дані не прийнято.';
$PHPMAILER_LANG['encoding']             = 'Невідоме кодування: ';
$PHPMAILER_LANG['execute']              = 'Неможливо виконати команду: ';
$PHPMAILER_LANG['file_access']          = 'Немає доступу до файлу: ';
$PHPMAILER_LANG['file_open']            = 'Помилка файлової системи: не вдається відкрити файл: ';
$PHPMAILER_LANG['from_failed']          = 'Невірна адреса відправника: ';
$PHPMAILER_LANG['instantiate']          = 'Неможливо запустити функцію mail().';
$PHPMAILER_LANG['provide_address']      = 'Будь-ласка, введіть хоча б одну email-адресу отримувача.';
$PHPMAILER_LANG['mailer_not_supported'] = ' - поштовий сервер не підтримується.';
$PHPMAILER_LANG['recipients_failed']    = 'Помилка SMTP: не вдалося відправлення для таких отримувачів: ';
$PHPMAILER_LANG['empty_message']        = 'Пусте повідомлення';
$PHPMAILER_LANG['invalid_address']      = 'Не відправлено через невірний формат email-адреси: ';
$PHPMAILER_LANG['signing']              = 'Помилка підпису: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Помилка з\'єднання з SMTP-сервером';
$PHPMAILER_LANG['smtp_error']           = 'Помилка SMTP-сервера: ';
$PHPMAILER_LANG['variable_set']         = 'Неможливо встановити або скинути змінну: ';
$PHPMAILER_LANG['extension_missing']    = 'Розширення відсутнє: ';
PHPMailer/language/phpmailer.lang-eo.php000064400000003200150766203100014116 0ustar00<?php
/**
 * Esperanto PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'Eraro de servilo SMTP : aŭtentigo malsukcesis.';
$PHPMAILER_LANG['connect_host']         = 'Eraro de servilo SMTP : konektado al servilo malsukcesis.';
$PHPMAILER_LANG['data_not_accepted']    = 'Eraro de servilo SMTP : neĝustaj datumoj.';
$PHPMAILER_LANG['empty_message']        = 'Teksto de mesaĝo mankas.';
$PHPMAILER_LANG['encoding']             = 'Nekonata kodoprezento: ';
$PHPMAILER_LANG['execute']              = 'Lanĉi rulumadon ne eblis: ';
$PHPMAILER_LANG['file_access']          = 'Aliro al dosiero ne sukcesis: ';
$PHPMAILER_LANG['file_open']            = 'Eraro de dosiero: malfermo neeblas: ';
$PHPMAILER_LANG['from_failed']          = 'Jena adreso de sendinto malsukcesis: ';
$PHPMAILER_LANG['instantiate']          = 'Genero de retmesaĝa funkcio neeblis.';
$PHPMAILER_LANG['invalid_address']      = 'Retadreso ne validas: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mesaĝilo ne subtenata.';
$PHPMAILER_LANG['provide_address']      = 'Vi devas tajpi almenaŭ unu recevontan retadreson.';
$PHPMAILER_LANG['recipients_failed']    = 'Eraro de servilo SMTP : la jenaj poŝtrecivuloj kaŭzis eraron: ';
$PHPMAILER_LANG['signing']              = 'Eraro de subskribo: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP konektado malsukcesis.';
$PHPMAILER_LANG['smtp_error']           = 'Eraro de servilo SMTP : ';
$PHPMAILER_LANG['variable_set']         = 'Variablo ne pravalorizeblas aŭ ne repravalorizeblas: ';
$PHPMAILER_LANG['extension_missing']    = 'Mankas etendo: ';
PHPMailer/language/phpmailer.lang-ar.php000064400000004026150766203110014125 0ustar00<?php
/**
 * Arabic PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author bahjat al mostafa <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'خطأ SMTP : لا يمكن تأكيد الهوية.';
$PHPMAILER_LANG['connect_host']         = 'خطأ SMTP: لا يمكن الاتصال بالخادم SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'خطأ SMTP: لم يتم قبول المعلومات .';
$PHPMAILER_LANG['empty_message']        = 'نص الرسالة فارغ';
$PHPMAILER_LANG['encoding']             = 'ترميز غير معروف: ';
$PHPMAILER_LANG['execute']              = 'لا يمكن تنفيذ : ';
$PHPMAILER_LANG['file_access']          = 'لا يمكن الوصول للملف: ';
$PHPMAILER_LANG['file_open']            = 'خطأ في الملف: لا يمكن فتحه: ';
$PHPMAILER_LANG['from_failed']          = 'خطأ على مستوى عنوان المرسل : ';
$PHPMAILER_LANG['instantiate']          = 'لا يمكن توفير خدمة البريد.';
$PHPMAILER_LANG['invalid_address']      = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.';
$PHPMAILER_LANG['provide_address']      = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.';
$PHPMAILER_LANG['recipients_failed']    = 'خطأ SMTP: الأخطاء التالية ' .
                                          'فشل في الارسال لكل من : ';
$PHPMAILER_LANG['signing']              = 'خطأ في التوقيع: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() غير ممكن.';
$PHPMAILER_LANG['smtp_error']           = 'خطأ على مستوى الخادم SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'لا يمكن تعيين أو إعادة تعيين متغير: ';
$PHPMAILER_LANG['extension_missing']    = 'الإضافة غير موجودة: ';
PHPMailer/language/phpmailer.lang-he.php000064400000003423150766203110014117 0ustar00<?php
/**
 * Hebrew PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Ronny Sherer <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'שגיאת SMTP: פעולת האימות נכשלה.';
$PHPMAILER_LANG['connect_host']         = 'שגיאת SMTP: לא הצלחתי להתחבר לשרת SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'שגיאת SMTP: מידע לא התקבל.';
$PHPMAILER_LANG['empty_message']        = 'גוף ההודעה ריק';
$PHPMAILER_LANG['invalid_address']      = 'כתובת שגויה: ';
$PHPMAILER_LANG['encoding']             = 'קידוד לא מוכר: ';
$PHPMAILER_LANG['execute']              = 'לא הצלחתי להפעיל את: ';
$PHPMAILER_LANG['file_access']          = 'לא ניתן לגשת לקובץ: ';
$PHPMAILER_LANG['file_open']            = 'שגיאת קובץ: לא ניתן לגשת לקובץ: ';
$PHPMAILER_LANG['from_failed']          = 'כתובות הנמענים הבאות נכשלו: ';
$PHPMAILER_LANG['instantiate']          = 'לא הצלחתי להפעיל את פונקציית המייל.';
$PHPMAILER_LANG['mailer_not_supported'] = ' אינה נתמכת.';
$PHPMAILER_LANG['provide_address']      = 'חובה לספק לפחות כתובת אחת של מקבל המייל.';
$PHPMAILER_LANG['recipients_failed']    = 'שגיאת SMTP: הנמענים הבאים נכשלו: ';
$PHPMAILER_LANG['signing']              = 'שגיאת חתימה: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() failed.';
$PHPMAILER_LANG['smtp_error']           = 'שגיאת שרת SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'לא ניתן לקבוע או לשנות את המשתנה: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-ko.php000064400000003352150766203110014135 0ustar00<?php
/**
 * Korean PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author ChalkPE <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP 오류: 인증할 수 없습니다.';
$PHPMAILER_LANG['connect_host']         = 'SMTP 오류: SMTP 호스트에 접속할 수 없습니다.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP 오류: 데이터가 받아들여지지 않았습니다.';
$PHPMAILER_LANG['empty_message']        = '메세지 내용이 없습니다';
$PHPMAILER_LANG['encoding']             = '알 수 없는 인코딩: ';
$PHPMAILER_LANG['execute']              = '실행 불가: ';
$PHPMAILER_LANG['file_access']          = '파일 접근 불가: ';
$PHPMAILER_LANG['file_open']            = '파일 오류: 파일을 열 수 없습니다: ';
$PHPMAILER_LANG['from_failed']          = '다음 From 주소에서 오류가 발생했습니다: ';
$PHPMAILER_LANG['instantiate']          = 'mail 함수를 인스턴스화할 수 없습니다';
$PHPMAILER_LANG['invalid_address']      = '잘못된 주소: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' 메일러는 지원되지 않습니다.';
$PHPMAILER_LANG['provide_address']      = '적어도 한 개 이상의 수신자 메일 주소를 제공해야 합니다.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP 오류: 다음 수신자에서 오류가 발생했습니다: ';
$PHPMAILER_LANG['signing']              = '서명 오류: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP 연결을 실패하였습니다.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP 서버 오류: ';
$PHPMAILER_LANG['variable_set']         = '변수 설정 및 초기화 불가: ';
$PHPMAILER_LANG['extension_missing']    = '확장자 없음: ';
PHPMailer/language/phpmailer.lang-pl.php000064400000003430150766203110014134 0ustar00<?php
/**
 * Polish PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'Błąd SMTP: Nie można przeprowadzić uwierzytelnienia.';
$PHPMAILER_LANG['connect_host']         = 'Błąd SMTP: Nie można połączyć się z wybranym hostem.';
$PHPMAILER_LANG['data_not_accepted']    = 'Błąd SMTP: Dane nie zostały przyjęte.';
$PHPMAILER_LANG['empty_message']        = 'Wiadomość jest pusta.';
$PHPMAILER_LANG['encoding']             = 'Nieznany sposób kodowania znaków: ';
$PHPMAILER_LANG['execute']              = 'Nie można uruchomić: ';
$PHPMAILER_LANG['file_access']          = 'Brak dostępu do pliku: ';
$PHPMAILER_LANG['file_open']            = 'Nie można otworzyć pliku: ';
$PHPMAILER_LANG['from_failed']          = 'Następujący adres Nadawcy jest nieprawidłowy: ';
$PHPMAILER_LANG['instantiate']          = 'Nie można wywołać funkcji mail(). Sprawdź konfigurację serwera.';
$PHPMAILER_LANG['invalid_address']      = 'Nie można wysłać wiadomości, '.
    'następujący adres Odbiorcy jest nieprawidłowy: ';
$PHPMAILER_LANG['provide_address']      = 'Należy podać prawidłowy adres email Odbiorcy.';
$PHPMAILER_LANG['mailer_not_supported'] = 'Wybrana metoda wysyłki wiadomości nie jest obsługiwana.';
$PHPMAILER_LANG['recipients_failed']    = 'Błąd SMTP: Następujący odbiorcy są nieprawidłowi: ';
$PHPMAILER_LANG['signing']              = 'Błąd podpisywania wiadomości: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() zakończone niepowodzeniem.';
$PHPMAILER_LANG['smtp_error']           = 'Błąd SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Nie można ustawić lub zmodyfikować zmiennej: ';
$PHPMAILER_LANG['extension_missing']    = 'Brakujące rozszerzenie: ';
PHPMailer/language/phpmailer.lang-pt_br.php000064400000003567150766203110014642 0ustar00<?php
/**
 * Brazilian Portuguese PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Paulo Henrique Garcia <[email protected]>
 * @author Lucas Guimarães <[email protected]>
 * @author Phelipe Alves <[email protected]>
 * @author Fabio Beneditto <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Erro de SMTP: Não foi possível autenticar.';
$PHPMAILER_LANG['connect_host']         = 'Erro de SMTP: Não foi possível conectar ao servidor SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Erro de SMTP: Dados rejeitados.';
$PHPMAILER_LANG['empty_message']        = 'Mensagem vazia';
$PHPMAILER_LANG['encoding']             = 'Codificação desconhecida: ';
$PHPMAILER_LANG['execute']              = 'Não foi possível executar: ';
$PHPMAILER_LANG['file_access']          = 'Não foi possível acessar o arquivo: ';
$PHPMAILER_LANG['file_open']            = 'Erro de Arquivo: Não foi possível abrir o arquivo: ';
$PHPMAILER_LANG['from_failed']          = 'Os seguintes remetentes falharam: ';
$PHPMAILER_LANG['instantiate']          = 'Não foi possível instanciar a função mail.';
$PHPMAILER_LANG['invalid_address']      = 'Endereço de e-mail inválido: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.';
$PHPMAILER_LANG['provide_address']      = 'Você deve informar pelo menos um destinatário.';
$PHPMAILER_LANG['recipients_failed']    = 'Erro de SMTP: Os seguintes destinatários falharam: ';
$PHPMAILER_LANG['signing']              = 'Erro de Assinatura: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() falhou.';
$PHPMAILER_LANG['smtp_error']           = 'Erro de servidor SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Não foi possível definir ou redefinir a variável: ';
$PHPMAILER_LANG['extension_missing']    = 'Extensão não existe: ';
PHPMailer/language/phpmailer.lang-zh.php000064400000003204150766203110014141 0ustar00<?php
/**
 * Traditional Chinese PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author liqwei <[email protected]>
 * @author Peter Dave Hello <@PeterDaveHello/>
 * @author Jason Chiang <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP 錯誤:登入失敗。';
$PHPMAILER_LANG['connect_host']         = 'SMTP 錯誤:無法連線到 SMTP 主機。';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP 錯誤:無法接受的資料。';
$PHPMAILER_LANG['empty_message']        = '郵件內容為空';
$PHPMAILER_LANG['encoding']             = '未知編碼: ';
$PHPMAILER_LANG['execute']              = '無法執行:';
$PHPMAILER_LANG['file_access']          = '無法存取檔案:';
$PHPMAILER_LANG['file_open']            = '檔案錯誤:無法開啟檔案:';
$PHPMAILER_LANG['from_failed']          = '發送地址錯誤:';
$PHPMAILER_LANG['instantiate']          = '未知函數呼叫。';
$PHPMAILER_LANG['invalid_address']      = '因為電子郵件地址無效,無法傳送: ';
$PHPMAILER_LANG['mailer_not_supported'] = '不支援的發信客戶端。';
$PHPMAILER_LANG['provide_address']      = '必須提供至少一個收件人地址。';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP 錯誤:以下收件人地址錯誤:';
$PHPMAILER_LANG['signing']              = '電子簽章錯誤: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP 連線失敗';
$PHPMAILER_LANG['smtp_error']           = 'SMTP 伺服器錯誤: ';
$PHPMAILER_LANG['variable_set']         = '無法設定或重設變數: ';
$PHPMAILER_LANG['extension_missing']    = '遺失模組 Extension: ';
PHPMailer/language/phpmailer.lang-sl.php000064400000003352150766203110014142 0ustar00<?php
/**
 * Slovene PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Klemen Tušar <[email protected]>
 * @author Filip Š <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP napaka: Avtentikacija ni uspela.';
$PHPMAILER_LANG['connect_host']         = 'SMTP napaka: Vzpostavljanje povezave s SMTP gostiteljem ni uspelo.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP napaka: Strežnik zavrača podatke.';
$PHPMAILER_LANG['empty_message']        = 'E-poštno sporočilo nima vsebine.';
$PHPMAILER_LANG['encoding']             = 'Nepoznan tip kodiranja: ';
$PHPMAILER_LANG['execute']              = 'Operacija ni uspela: ';
$PHPMAILER_LANG['file_access']          = 'Nimam dostopa do datoteke: ';
$PHPMAILER_LANG['file_open']            = 'Ne morem odpreti datoteke: ';
$PHPMAILER_LANG['from_failed']          = 'Neveljaven e-naslov pošiljatelja: ';
$PHPMAILER_LANG['instantiate']          = 'Ne morem inicializirati mail funkcije.';
$PHPMAILER_LANG['invalid_address']      = 'E-poštno sporočilo ni bilo poslano. E-naslov je neveljaven: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer ni podprt.';
$PHPMAILER_LANG['provide_address']      = 'Prosim vnesite vsaj enega naslovnika.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP napaka: Sledeči naslovniki so neveljavni: ';
$PHPMAILER_LANG['signing']              = 'Napaka pri podpisovanju: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Ne morem vzpostaviti povezave s SMTP strežnikom.';
$PHPMAILER_LANG['smtp_error']           = 'Napaka SMTP strežnika: ';
$PHPMAILER_LANG['variable_set']         = 'Ne morem nastaviti oz. ponastaviti spremenljivke: ';
$PHPMAILER_LANG['extension_missing']    = 'Manjkajoča razširitev: ';
PHPMailer/language/phpmailer.lang-da.php000064400000003252150766203110014107 0ustar00<?php
/**
 * Danish PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author John Sebastian <[email protected]>
 * Rewrite and extension of the work by Mikael Stokkebro <[email protected]> 
 *  
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP fejl: Login mislykkedes.';
$PHPMAILER_LANG['connect_host']         = 'SMTP fejl: Forbindelse til SMTP serveren kunne ikke oprettes.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP fejl: Data blev ikke accepteret.';
$PHPMAILER_LANG['empty_message']        = 'Meddelelsen er uden indhold';
$PHPMAILER_LANG['encoding']             = 'Ukendt encode-format: ';
$PHPMAILER_LANG['execute']              = 'Kunne ikke afvikle: ';
$PHPMAILER_LANG['file_access']          = 'Kunne ikke tilgå filen: ';
$PHPMAILER_LANG['file_open']            = 'Fil fejl: Kunne ikke åbne filen: ';
$PHPMAILER_LANG['from_failed']          = 'Følgende afsenderadresse er forkert: ';
$PHPMAILER_LANG['instantiate']          = 'Email funktionen kunne ikke initialiseres.';
$PHPMAILER_LANG['invalid_address']      = 'Udgyldig adresse: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.';
$PHPMAILER_LANG['provide_address']      = 'Indtast mindst en modtagers email adresse.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP fejl: Følgende modtagere er forkerte: ';
$PHPMAILER_LANG['signing']              = 'Signeringsfejl: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() fejlede.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP server fejl: ';
$PHPMAILER_LANG['variable_set']         = 'Kunne ikke definere eller nulstille variablen: ';
$PHPMAILER_LANG['extension_missing']    = 'Udvidelse mangler: ';
PHPMailer/language/phpmailer.lang-ro.php000064400000003330150766203110014140 0ustar00<?php
/**
 * Romanian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Alex Florea <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Eroare SMTP: Autentificarea a eșuat.';
$PHPMAILER_LANG['connect_host']         = 'Eroare SMTP: Conectarea la serverul SMTP a eșuat.';
$PHPMAILER_LANG['data_not_accepted']    = 'Eroare SMTP: Datele nu au fost acceptate.';
$PHPMAILER_LANG['empty_message']        = 'Mesajul este gol.';
$PHPMAILER_LANG['encoding']             = 'Encodare necunoscută: ';
$PHPMAILER_LANG['execute']              = 'Nu se poate executa următoarea comandă:  ';
$PHPMAILER_LANG['file_access']          = 'Nu se poate accesa următorul fișier: ';
$PHPMAILER_LANG['file_open']            = 'Eroare fișier: Nu se poate deschide următorul fișier: ';
$PHPMAILER_LANG['from_failed']          = 'Următoarele adrese From au dat eroare: ';
$PHPMAILER_LANG['instantiate']          = 'Funcția mail nu a putut fi inițializată.';
$PHPMAILER_LANG['invalid_address']      = 'Adresa de email nu este validă: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nu este suportat.';
$PHPMAILER_LANG['provide_address']      = 'Trebuie să adăugați cel puțin o adresă de email.';
$PHPMAILER_LANG['recipients_failed']    = 'Eroare SMTP: Următoarele adrese de email au eșuat: ';
$PHPMAILER_LANG['signing']              = 'A aparut o problemă la semnarea emailului. ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Conectarea la serverul SMTP a eșuat.';
$PHPMAILER_LANG['smtp_error']           = 'Eroare server SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Nu se poate seta/reseta variabila. ';
$PHPMAILER_LANG['extension_missing']    = 'Lipsește extensia: ';
PHPMailer/language/phpmailer.lang-fi.php000064400000003302150766203110014115 0ustar00<?php
/**
 * Finnish PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Jyry Kuukanen
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP-virhe: käyttäjätunnistus epäonnistui.';
$PHPMAILER_LANG['connect_host']         = 'SMTP-virhe: yhteys palvelimeen ei onnistu.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP-virhe: data on virheellinen.';
//$PHPMAILER_LANG['empty_message']        = 'Message body empty';
$PHPMAILER_LANG['encoding']             = 'Tuntematon koodaustyyppi: ';
$PHPMAILER_LANG['execute']              = 'Suoritus epäonnistui: ';
$PHPMAILER_LANG['file_access']          = 'Seuraavaan tiedostoon ei ole oikeuksia: ';
$PHPMAILER_LANG['file_open']            = 'Tiedostovirhe: Ei voida avata tiedostoa: ';
$PHPMAILER_LANG['from_failed']          = 'Seuraava lähettäjän osoite on virheellinen: ';
$PHPMAILER_LANG['instantiate']          = 'mail-funktion luonti epäonnistui.';
//$PHPMAILER_LANG['invalid_address']      = 'Invalid address: ';
$PHPMAILER_LANG['mailer_not_supported'] = 'postivälitintyyppiä ei tueta.';
$PHPMAILER_LANG['provide_address']      = 'Aseta vähintään yksi vastaanottajan sähk&ouml;postiosoite.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP-virhe: seuraava vastaanottaja osoite on virheellinen.';
$PHPMAILER_LANG['encoding']             = 'Tuntematon koodaustyyppi: ';
//$PHPMAILER_LANG['signing']              = 'Signing Error: ';
//$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() failed.';
//$PHPMAILER_LANG['smtp_error']           = 'SMTP server error: ';
//$PHPMAILER_LANG['variable_set']         = 'Cannot set or reset variable: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-ms.php000064400000003305150766203120014142 0ustar00<?php
/**
 * Malaysian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Nawawi Jamili <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Ralat SMTP: Tidak dapat pengesahan.';
$PHPMAILER_LANG['connect_host']         = 'Ralat SMTP: Tidak dapat menghubungi hos pelayan SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Ralat SMTP: Data tidak diterima oleh pelayan.';
$PHPMAILER_LANG['empty_message']        = 'Tiada isi untuk mesej';
$PHPMAILER_LANG['encoding']             = 'Pengekodan tidak diketahui: ';
$PHPMAILER_LANG['execute']              = 'Tidak dapat melaksanakan: ';
$PHPMAILER_LANG['file_access']          = 'Tidak dapat mengakses fail: ';
$PHPMAILER_LANG['file_open']            = 'Ralat Fail: Tidak dapat membuka fail: ';
$PHPMAILER_LANG['from_failed']          = 'Berikut merupakan ralat dari alamat e-mel: ';
$PHPMAILER_LANG['instantiate']          = 'Tidak dapat memberi contoh fungsi e-mel.';
$PHPMAILER_LANG['invalid_address']      = 'Alamat emel tidak sah: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' jenis penghantar emel tidak disokong.';
$PHPMAILER_LANG['provide_address']      = 'Anda perlu menyediakan sekurang-kurangnya satu alamat e-mel penerima.';
$PHPMAILER_LANG['recipients_failed']    = 'Ralat SMTP: Penerima e-mel berikut telah gagal: ';
$PHPMAILER_LANG['signing']              = 'Ralat pada tanda tangan: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() telah gagal.';
$PHPMAILER_LANG['smtp_error']           = 'Ralat pada pelayan SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Tidak boleh menetapkan atau menetapkan semula pembolehubah: ';
$PHPMAILER_LANG['extension_missing']    = 'Sambungan hilang: ';
PHPMailer/language/phpmailer.lang-fa.php000064400000004036150766203120014113 0ustar00<?php
/**
 * Persian/Farsi PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Ali Jazayeri <[email protected]>
 * @author Mohammad Hossein Mojtahedi <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'خطای SMTP: احراز هویت با شکست مواجه شد.';
$PHPMAILER_LANG['connect_host']         = 'خطای SMTP: اتصال به سرور SMTP برقرار نشد.';
$PHPMAILER_LANG['data_not_accepted']    = 'خطای SMTP: داده‌ها نا‌درست هستند.';
$PHPMAILER_LANG['empty_message']        = 'بخش متن پیام خالی است.';
$PHPMAILER_LANG['encoding']             = 'کد‌گذاری نا‌شناخته: ';
$PHPMAILER_LANG['execute']              = 'امکان اجرا وجود ندارد: ';
$PHPMAILER_LANG['file_access']          = 'امکان دسترسی به فایل وجود ندارد: ';
$PHPMAILER_LANG['file_open']            = 'خطای File: امکان بازکردن فایل وجود ندارد: ';
$PHPMAILER_LANG['from_failed']          = 'آدرس فرستنده اشتباه است: ';
$PHPMAILER_LANG['instantiate']          = 'امکان معرفی تابع ایمیل وجود ندارد.';
$PHPMAILER_LANG['invalid_address']      = 'آدرس ایمیل معتبر نیست: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer پشتیبانی نمی‌شود.';
$PHPMAILER_LANG['provide_address']      = 'باید حداقل یک آدرس گیرنده وارد کنید.';
$PHPMAILER_LANG['recipients_failed']    = 'خطای SMTP: ارسال به آدرس گیرنده با خطا مواجه شد: ';
$PHPMAILER_LANG['signing']              = 'خطا در امضا: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'خطا در اتصال به SMTP.';
$PHPMAILER_LANG['smtp_error']           = 'خطا در SMTP Server: ';
$PHPMAILER_LANG['variable_set']         = 'امکان ارسال یا ارسال مجدد متغیر‌ها وجود ندارد: ';
$PHPMAILER_LANG['extension_missing']    = 'افزونه موجود نیست: ';
PHPMailer/language/phpmailer.lang-ka.php000064400000005503150766203120014120 0ustar00<?php
/**
 * Georgian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Avtandil Kikabidze aka LONGMAN <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP შეცდომა: ავტორიზაცია შეუძლებელია.';
$PHPMAILER_LANG['connect_host']         = 'SMTP შეცდომა: SMTP სერვერთან დაკავშირება შეუძლებელია.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP შეცდომა: მონაცემები არ იქნა მიღებული.';
$PHPMAILER_LANG['encoding']             = 'კოდირების უცნობი ტიპი: ';
$PHPMAILER_LANG['execute']              = 'შეუძლებელია შემდეგი ბრძანების შესრულება: ';
$PHPMAILER_LANG['file_access']          = 'შეუძლებელია წვდომა ფაილთან: ';
$PHPMAILER_LANG['file_open']            = 'ფაილური სისტემის შეცდომა: არ იხსნება ფაილი: ';
$PHPMAILER_LANG['from_failed']          = 'გამგზავნის არასწორი მისამართი: ';
$PHPMAILER_LANG['instantiate']          = 'mail ფუნქციის გაშვება ვერ ხერხდება.';
$PHPMAILER_LANG['provide_address']      = 'გთხოვთ მიუთითოთ ერთი ადრესატის e-mail მისამართი მაინც.';
$PHPMAILER_LANG['mailer_not_supported'] = ' - საფოსტო სერვერის მხარდაჭერა არ არის.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP შეცდომა: შემდეგ მისამართებზე გაგზავნა ვერ მოხერხდა: ';
$PHPMAILER_LANG['empty_message']        = 'შეტყობინება ცარიელია';
$PHPMAILER_LANG['invalid_address']      = 'არ გაიგზავნა, e-mail მისამართის არასწორი ფორმატი: ';
$PHPMAILER_LANG['signing']              = 'ხელმოწერის შეცდომა: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'შეცდომა SMTP სერვერთან დაკავშირებისას';
$PHPMAILER_LANG['smtp_error']           = 'SMTP სერვერის შეცდომა: ';
$PHPMAILER_LANG['variable_set']         = 'შეუძლებელია შემდეგი ცვლადის შექმნა ან შეცვლა: ';
$PHPMAILER_LANG['extension_missing']    = 'ბიბლიოთეკა არ არსებობს: ';
PHPMailer/language/phpmailer.lang-bg.php000064400000004223150766203120014113 0ustar00<?php
/**
 * Bulgarian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Mikhail Kyosev <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP грешка: Не може да се удостовери пред сървъра.';
$PHPMAILER_LANG['connect_host']         = 'SMTP грешка: Не може да се свърже с SMTP хоста.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP грешка: данните не са приети.';
$PHPMAILER_LANG['empty_message']        = 'Съдържанието на съобщението е празно';
$PHPMAILER_LANG['encoding']             = 'Неизвестно кодиране: ';
$PHPMAILER_LANG['execute']              = 'Не може да се изпълни: ';
$PHPMAILER_LANG['file_access']          = 'Няма достъп до файл: ';
$PHPMAILER_LANG['file_open']            = 'Файлова грешка: Не може да се отвори файл: ';
$PHPMAILER_LANG['from_failed']          = 'Следните адреси за подател са невалидни: ';
$PHPMAILER_LANG['instantiate']          = 'Не може да се инстанцира функцията mail.';
$PHPMAILER_LANG['invalid_address']      = 'Невалиден адрес: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' - пощенски сървър не се поддържа.';
$PHPMAILER_LANG['provide_address']      = 'Трябва да предоставите поне един email адрес за получател.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP грешка: Следните адреси за Получател са невалидни: ';
$PHPMAILER_LANG['signing']              = 'Грешка при подписване: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP провален connect().';
$PHPMAILER_LANG['smtp_error']           = 'SMTP сървърна грешка: ';
$PHPMAILER_LANG['variable_set']         = 'Не може да се установи или възстанови променлива: ';
$PHPMAILER_LANG['extension_missing']    = 'Липсва разширение: ';
PHPMailer/language/phpmailer.lang-lv.php000064400000003152150766203120014144 0ustar00<?php
/**
 * Latvian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Eduards M. <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP kļūda: Autorizācija neizdevās.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Kļūda: Nevar izveidot savienojumu ar SMTP serveri.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Kļūda: Nepieņem informāciju.';
$PHPMAILER_LANG['empty_message']        = 'Ziņojuma teksts ir tukšs';
$PHPMAILER_LANG['encoding']             = 'Neatpazīts kodējums: ';
$PHPMAILER_LANG['execute']              = 'Neizdevās izpildīt komandu: ';
$PHPMAILER_LANG['file_access']          = 'Fails nav pieejams: ';
$PHPMAILER_LANG['file_open']            = 'Faila kļūda: Nevar atvērt failu: ';
$PHPMAILER_LANG['from_failed']          = 'Nepareiza sūtītāja adrese: ';
$PHPMAILER_LANG['instantiate']          = 'Nevar palaist sūtīšanas funkciju.';
$PHPMAILER_LANG['invalid_address']      = 'Nepareiza adrese: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' sūtītājs netiek atbalstīts.';
$PHPMAILER_LANG['provide_address']      = 'Lūdzu, norādiet vismaz vienu adresātu.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP kļūda: neizdevās nosūtīt šādiem saņēmējiem: ';
$PHPMAILER_LANG['signing']              = 'Autorizācijas kļūda: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP savienojuma kļūda';
$PHPMAILER_LANG['smtp_error']           = 'SMTP servera kļūda: ';
$PHPMAILER_LANG['variable_set']         = 'Nevar piešķirt mainīgā vērtību: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-vi.php000064400000003400150766203120014135 0ustar00<?php
/**
 * Vietnamese (Tiếng Việt) PHPMailer language file: refer to English translation for definitive list.
 * @package PHPMailer
 * @author VINADES.,JSC <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Lỗi SMTP: Không thể xác thực.';
$PHPMAILER_LANG['connect_host']         = 'Lỗi SMTP: Không thể kết nối máy chủ SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Lỗi SMTP: Dữ liệu không được chấp nhận.';
$PHPMAILER_LANG['empty_message']        = 'Không có nội dung';
$PHPMAILER_LANG['encoding']             = 'Mã hóa không xác định: ';
$PHPMAILER_LANG['execute']              = 'Không thực hiện được: ';
$PHPMAILER_LANG['file_access']          = 'Không thể truy cập tệp tin ';
$PHPMAILER_LANG['file_open']            = 'Lỗi Tập tin: Không thể mở tệp tin: ';
$PHPMAILER_LANG['from_failed']          = 'Lỗi địa chỉ gửi đi: ';
$PHPMAILER_LANG['instantiate']          = 'Không dùng được các hàm gửi thư.';
$PHPMAILER_LANG['invalid_address']      = 'Đại chỉ emai không đúng: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' trình gửi thư không được hỗ trợ.';
$PHPMAILER_LANG['provide_address']      = 'Bạn phải cung cấp ít nhất một địa chỉ người nhận.';
$PHPMAILER_LANG['recipients_failed']    = 'Lỗi SMTP: lỗi địa chỉ người nhận: ';
$PHPMAILER_LANG['signing']              = 'Lỗi đăng nhập: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Lỗi kết nối với SMTP';
$PHPMAILER_LANG['smtp_error']           = 'Lỗi máy chủ smtp ';
$PHPMAILER_LANG['variable_set']         = 'Không thể thiết lập hoặc thiết lập lại biến: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-el.php000064400000004366150766203120014133 0ustar00<?php
/**
 * Greek PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Σφάλμα: Αδυναμία πιστοποίησης (authentication).';
$PHPMAILER_LANG['connect_host']         = 'SMTP Σφάλμα: Αδυναμία σύνδεσης στον SMTP-Host.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Σφάλμα: Τα δεδομένα δεν έγιναν αποδεκτά.';
$PHPMAILER_LANG['empty_message']        = 'Το E-Mail δεν έχει περιεχόμενο .';
$PHPMAILER_LANG['encoding']             = 'Αγνωστο Encoding-Format: ';
$PHPMAILER_LANG['execute']              = 'Αδυναμία εκτέλεσης ακόλουθης εντολής: ';
$PHPMAILER_LANG['file_access']          = 'Αδυναμία προσπέλασης του αρχείου: ';
$PHPMAILER_LANG['file_open']            = 'Σφάλμα Αρχείου: Δεν είναι δυνατό το άνοιγμα του ακόλουθου αρχείου: ';
$PHPMAILER_LANG['from_failed']          = 'Η παρακάτω διεύθυνση αποστολέα δεν είναι σωστή: ';
$PHPMAILER_LANG['instantiate']          = 'Αδυναμία εκκίνησης Mail function.';
$PHPMAILER_LANG['invalid_address']      = 'Το μήνυμα δεν εστάλη, η διεύθυνση δεν είναι έγκυρη: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer δεν υποστηρίζεται.';
$PHPMAILER_LANG['provide_address']      = 'Παρακαλούμε δώστε τουλάχιστον μια e-mail διεύθυνση παραλήπτη.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Σφάλμα: Οι παρακάτω διευθύνσεις παραλήπτη δεν είναι έγκυρες: ';
$PHPMAILER_LANG['signing']              = 'Σφάλμα υπογραφής: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Αποτυχία σύνδεσης στον SMTP Server.';
$PHPMAILER_LANG['smtp_error']           = 'Σφάλμα από τον SMTP Server: ';
$PHPMAILER_LANG['variable_set']         = 'Αδυναμία ορισμού ή αρχικοποίησης μεταβλητής: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-es.php000064400000003273150766203120014136 0ustar00<?php
/**
 * Spanish PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Matt Sturdy <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Error SMTP: Imposible autentificar.';
$PHPMAILER_LANG['connect_host']         = 'Error SMTP: Imposible conectar al servidor SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Error SMTP: Datos no aceptados.';
$PHPMAILER_LANG['empty_message']        = 'El cuerpo del mensaje está vacío.';
$PHPMAILER_LANG['encoding']             = 'Codificación desconocida: ';
$PHPMAILER_LANG['execute']              = 'Imposible ejecutar: ';
$PHPMAILER_LANG['file_access']          = 'Imposible acceder al archivo: ';
$PHPMAILER_LANG['file_open']            = 'Error de Archivo: Imposible abrir el archivo: ';
$PHPMAILER_LANG['from_failed']          = 'La(s) siguiente(s) direcciones de remitente fallaron: ';
$PHPMAILER_LANG['instantiate']          = 'Imposible crear una instancia de la función Mail.';
$PHPMAILER_LANG['invalid_address']      = 'Imposible enviar: dirección de email inválido: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no está soportado.';
$PHPMAILER_LANG['provide_address']      = 'Debe proporcionar al menos una dirección de email de destino.';
$PHPMAILER_LANG['recipients_failed']    = 'Error SMTP: Los siguientes destinos fallaron: ';
$PHPMAILER_LANG['signing']              = 'Error al firmar: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() falló.';
$PHPMAILER_LANG['smtp_error']           = 'Error del servidor SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'No se pudo configurar la variable: ';
$PHPMAILER_LANG['extension_missing']    = 'Extensión faltante: ';
PHPMailer/language/phpmailer.lang-ba.php000064400000003317150766203120014110 0ustar00<?php
/**
 * Bosnian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Ermin Islamagić <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Greška: Neuspjela prijava.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Greška: Nije moguće spojiti se sa SMTP serverom.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Greška: Podatci nisu prihvaćeni.';
$PHPMAILER_LANG['empty_message']        = 'Sadržaj poruke je prazan.';
$PHPMAILER_LANG['encoding']             = 'Nepoznata kriptografija: ';
$PHPMAILER_LANG['execute']              = 'Nije moguće izvršiti naredbu: ';
$PHPMAILER_LANG['file_access']          = 'Nije moguće pristupiti datoteci: ';
$PHPMAILER_LANG['file_open']            = 'Nije moguće otvoriti datoteku: ';
$PHPMAILER_LANG['from_failed']          = 'SMTP Greška: Slanje sa navedenih e-mail adresa nije uspjelo: ';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Greška: Slanje na navedene e-mail adrese nije uspjelo: ';
$PHPMAILER_LANG['instantiate']          = 'Ne mogu pokrenuti mail funkcionalnost.';
$PHPMAILER_LANG['invalid_address']      = 'E-mail nije poslan. Neispravna e-mail adresa: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nije podržan.';
$PHPMAILER_LANG['provide_address']      = 'Definišite barem jednu adresu primaoca.';
$PHPMAILER_LANG['signing']              = 'Greška prilikom prijave: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Spajanje na SMTP server nije uspjelo.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP greška: ';
$PHPMAILER_LANG['variable_set']         = 'Nije moguće postaviti varijablu ili je vratiti nazad: ';
$PHPMAILER_LANG['extension_missing']    = 'Nedostaje ekstenzija: ';PHPMailer/language/phpmailer.lang-lt.php000064400000003132150766203120014140 0ustar00<?php
/**
 * Lithuanian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Dainius Kaupaitis <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP klaida: autentifikacija nepavyko.';
$PHPMAILER_LANG['connect_host']         = 'SMTP klaida: nepavyksta prisijungti prie SMTP stoties.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP klaida: duomenys nepriimti.';
$PHPMAILER_LANG['empty_message']        = 'Laiško turinys tuščias';
$PHPMAILER_LANG['encoding']             = 'Neatpažinta koduotė: ';
$PHPMAILER_LANG['execute']              = 'Nepavyko įvykdyti komandos: ';
$PHPMAILER_LANG['file_access']          = 'Byla nepasiekiama: ';
$PHPMAILER_LANG['file_open']            = 'Bylos klaida: Nepavyksta atidaryti: ';
$PHPMAILER_LANG['from_failed']          = 'Neteisingas siuntėjo adresas: ';
$PHPMAILER_LANG['instantiate']          = 'Nepavyko paleisti mail funkcijos.';
$PHPMAILER_LANG['invalid_address']      = 'Neteisingas adresas: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' pašto stotis nepalaikoma.';
$PHPMAILER_LANG['provide_address']      = 'Nurodykite bent vieną gavėjo adresą.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP klaida: nepavyko išsiųsti šiems gavėjams: ';
$PHPMAILER_LANG['signing']              = 'Prisijungimo klaida: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP susijungimo klaida';
$PHPMAILER_LANG['smtp_error']           = 'SMTP stoties klaida: ';
$PHPMAILER_LANG['variable_set']         = 'Nepavyko priskirti reikšmės kintamajam: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-tr.php000064400000003353150766203120014153 0ustar00<?php
/**
 * Turkish PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Elçin Özel
 * @author Can Yılmaz
 * @author Mehmet Benlioğlu
 * @author @yasinaydin
 * @author Ogün Karakuş
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP Hatası: Oturum açılamadı.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Hatası: SMTP sunucusuna bağlanılamadı.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP Hatası: Veri kabul edilmedi.';
$PHPMAILER_LANG['empty_message']        = 'Mesajın içeriği boş';
$PHPMAILER_LANG['encoding']             = 'Bilinmeyen karakter kodlama: ';
$PHPMAILER_LANG['execute']              = 'Çalıştırılamadı: ';
$PHPMAILER_LANG['file_access']          = 'Dosyaya erişilemedi: ';
$PHPMAILER_LANG['file_open']            = 'Dosya Hatası: Dosya açılamadı: ';
$PHPMAILER_LANG['from_failed']          = 'Belirtilen adreslere gönderme başarısız: ';
$PHPMAILER_LANG['instantiate']          = 'Örnek e-posta fonksiyonu oluşturulamadı.';
$PHPMAILER_LANG['invalid_address']      = 'Geçersiz e-posta adresi: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' e-posta kütüphanesi desteklenmiyor.';
$PHPMAILER_LANG['provide_address']      = 'En az bir alıcı e-posta adresi belirtmelisiniz.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Hatası: Belirtilen alıcılara ulaşılamadı: ';
$PHPMAILER_LANG['signing']              = 'İmzalama hatası: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP connect() fonksiyonu başarısız.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP sunucu hatası: ';
$PHPMAILER_LANG['variable_set']         = 'Değişken ayarlanamadı ya da sıfırlanamadı: ';
$PHPMAILER_LANG['extension_missing']    = 'Eklenti bulunamadı: ';
PHPMailer/language/phpmailer.lang-sv.php000064400000003111150766203130014147 0ustar00<?php
/**
 * Swedish PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Johan Linnér <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP fel: Kunde inte autentisera.';
$PHPMAILER_LANG['connect_host']         = 'SMTP fel: Kunde inte ansluta till SMTP-server.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP fel: Data accepterades inte.';
//$PHPMAILER_LANG['empty_message']        = 'Message body empty';
$PHPMAILER_LANG['encoding']             = 'Okänt encode-format: ';
$PHPMAILER_LANG['execute']              = 'Kunde inte köra: ';
$PHPMAILER_LANG['file_access']          = 'Ingen åtkomst till fil: ';
$PHPMAILER_LANG['file_open']            = 'Fil fel: Kunde inte öppna fil: ';
$PHPMAILER_LANG['from_failed']          = 'Följande avsändaradress är felaktig: ';
$PHPMAILER_LANG['instantiate']          = 'Kunde inte initiera e-postfunktion.';
$PHPMAILER_LANG['invalid_address']      = 'Felaktig adress: ';
$PHPMAILER_LANG['provide_address']      = 'Du måste ange minst en mottagares e-postadress.';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP fel: Följande mottagare är felaktig: ';
$PHPMAILER_LANG['signing']              = 'Signeringsfel: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() misslyckades.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP serverfel: ';
$PHPMAILER_LANG['variable_set']         = 'Kunde inte definiera eller återställa variabel: ';
$PHPMAILER_LANG['extension_missing']    = 'Tillägg ej tillgängligt: ';
PHPMailer/language/phpmailer.lang-hu.php000064400000003264150766203130014144 0ustar00<?php
/**
 * Hungarian PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author @dominicus-75
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP hiba: az azonosítás sikertelen.';
$PHPMAILER_LANG['connect_host']         = 'SMTP hiba: nem lehet kapcsolódni az SMTP-szerverhez.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP hiba: adatok visszautasítva.';
$PHPMAILER_LANG['empty_message']        = 'Üres az üzenettörzs.';
$PHPMAILER_LANG['encoding']             = 'Ismeretlen kódolás: ';
$PHPMAILER_LANG['execute']              = 'Nem lehet végrehajtani: ';
$PHPMAILER_LANG['file_access']          = 'A következő fájl nem elérhető: ';
$PHPMAILER_LANG['file_open']            = 'Fájl hiba: a következő fájlt nem lehet megnyitni: ';
$PHPMAILER_LANG['from_failed']          = 'A feladóként megadott következő cím hibás: ';
$PHPMAILER_LANG['instantiate']          = 'A PHP mail() függvényt nem sikerült végrehajtani.';
$PHPMAILER_LANG['invalid_address']      = 'Érvénytelen cím: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' a mailer-osztály nem támogatott.';
$PHPMAILER_LANG['provide_address']      = 'Legalább egy címzettet fel kell tüntetni.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP hiba: a címzettként megadott következő címek hibásak: ';
$PHPMAILER_LANG['signing']              = 'Hibás aláírás: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Hiba az SMTP-kapcsolatban.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP-szerver hiba: ';
$PHPMAILER_LANG['variable_set']         = 'A következő változók beállítása nem sikerült: ';
$PHPMAILER_LANG['extension_missing']    = 'Bővítmény hiányzik: ';
PHPMailer/language/phpmailer.lang-nl.php000064400000003315150766203130014136 0ustar00<?php
/**
 * Dutch PHPMailer language file: refer to PHPMailer.php for definitive list.
 * @package PHPMailer
 * @author Tuxion <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP-fout: authenticatie mislukt.';
$PHPMAILER_LANG['connect_host']         = 'SMTP-fout: kon niet verbinden met SMTP-host.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP-fout: data niet geaccepteerd.';
$PHPMAILER_LANG['empty_message']        = 'Berichttekst is leeg';
$PHPMAILER_LANG['encoding']             = 'Onbekende codering: ';
$PHPMAILER_LANG['execute']              = 'Kon niet uitvoeren: ';
$PHPMAILER_LANG['file_access']          = 'Kreeg geen toegang tot bestand: ';
$PHPMAILER_LANG['file_open']            = 'Bestandsfout: kon bestand niet openen: ';
$PHPMAILER_LANG['from_failed']          = 'Het volgende afzendersadres is mislukt: ';
$PHPMAILER_LANG['instantiate']          = 'Kon mailfunctie niet initialiseren.';
$PHPMAILER_LANG['invalid_address']      = 'Ongeldig adres: ';
$PHPMAILER_LANG['invalid_hostentry']    = 'Ongeldige hostentry: ';
$PHPMAILER_LANG['invalid_host']         = 'Ongeldige host: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wordt niet ondersteund.';
$PHPMAILER_LANG['provide_address']      = 'Er moet minstens één ontvanger worden opgegeven.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP-fout: de volgende ontvangers zijn mislukt: ';
$PHPMAILER_LANG['signing']              = 'Signeerfout: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Verbinding mislukt.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP-serverfout: ';
$PHPMAILER_LANG['variable_set']         = 'Kan de volgende variabele niet instellen of resetten: ';
$PHPMAILER_LANG['extension_missing']    = 'Extensie afwezig: ';
PHPMailer/language/phpmailer.lang-mg.php000064400000003364150766203130014134 0ustar00<?php
/**
 * Malagasy PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author Hackinet <[email protected]>
 */
$PHPMAILER_LANG['authenticate']         = 'Hadisoana SMTP: Tsy nahomby ny fanamarinana.';
$PHPMAILER_LANG['connect_host']         = 'SMTP Error: Tsy afaka mampifandray amin\'ny mpampiantrano SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP diso: tsy voarakitra ny angona.';
$PHPMAILER_LANG['empty_message']        = 'Tsy misy ny votoaty mailaka.';
$PHPMAILER_LANG['encoding']             = 'Tsy fantatra encoding: ';
$PHPMAILER_LANG['execute']              = 'Tsy afaka manatanteraka ity baiko manaraka ity: ';
$PHPMAILER_LANG['file_access']          = 'Tsy nahomby ny fidirana amin\'ity rakitra ity: ';
$PHPMAILER_LANG['file_open']            = 'Hadisoana diso: Tsy afaka nanokatra ity file manaraka ity: ';
$PHPMAILER_LANG['from_failed']          = 'Ny adiresy iraka manaraka dia diso: ';
$PHPMAILER_LANG['instantiate']          = 'Tsy afaka nanomboka ny hetsika mail.';
$PHPMAILER_LANG['invalid_address']      = 'Tsy mety ny adiresy: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer tsy manohana.';
$PHPMAILER_LANG['provide_address']      = 'Alefaso azafady iray adiresy iray farafahakeliny.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP Error: Tsy mety ireo mpanaraka ireto: ';
$PHPMAILER_LANG['signing']              = 'Error nandritra ny sonia:';
$PHPMAILER_LANG['smtp_connect_failed']  = 'Tsy nahomby ny fifandraisana tamin\'ny server SMTP.';
$PHPMAILER_LANG['smtp_error']           = 'Fahadisoana tamin\'ny server SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Tsy azo atao ny mametraka na mamerina ny variable: ';
$PHPMAILER_LANG['extension_missing']    = 'Tsy hita ny ampahany: ';
PHPMailer/language/phpmailer.lang-ch.php000064400000003115150766203130014115 0ustar00<?php
/**
 * Chinese PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author LiuXin <http://www.80x86.cn/blog/>
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP 错误:身份验证失败。';
$PHPMAILER_LANG['connect_host']         = 'SMTP 错误: 不能连接SMTP主机。';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP 错误: 数据不可接受。';
//$PHPMAILER_LANG['empty_message']        = 'Message body empty';
$PHPMAILER_LANG['encoding']             = '未知编码:';
$PHPMAILER_LANG['execute']              = '不能执行: ';
$PHPMAILER_LANG['file_access']          = '不能访问文件:';
$PHPMAILER_LANG['file_open']            = '文件错误:不能打开文件:';
$PHPMAILER_LANG['from_failed']          = '下面的发送地址邮件发送失败了: ';
$PHPMAILER_LANG['instantiate']          = '不能实现mail方法。';
//$PHPMAILER_LANG['invalid_address']      = 'Invalid address: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' 您所选择的发送邮件的方法并不支持。';
$PHPMAILER_LANG['provide_address']      = '您必须提供至少一个 收信人的email地址。';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP 错误: 下面的 收件人失败了: ';
//$PHPMAILER_LANG['signing']              = 'Signing Error: ';
//$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() failed.';
//$PHPMAILER_LANG['smtp_error']           = 'SMTP server error: ';
//$PHPMAILER_LANG['variable_set']         = 'Cannot set or reset variable: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/language/phpmailer.lang-af.php000064400000003057150766203130014116 0ustar00<?php
/**
 * Afrikaans PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 */

$PHPMAILER_LANG['authenticate']         = 'SMTP-fout: kon nie geverifieer word nie.';
$PHPMAILER_LANG['connect_host']         = 'SMTP-fout: kon nie aan SMTP-verbind nie.';
$PHPMAILER_LANG['data_not_accepted']    = 'SMTP-fout: data nie aanvaar nie.';
$PHPMAILER_LANG['empty_message']        = 'Boodskapliggaam leeg.';
$PHPMAILER_LANG['encoding']             = 'Onbekende kodering: ';
$PHPMAILER_LANG['execute']              = 'Kon nie uitvoer nie: ';
$PHPMAILER_LANG['file_access']          = 'Kon nie lêer oopmaak nie: ';
$PHPMAILER_LANG['file_open']            = 'Lêerfout: Kon nie lêer oopmaak nie: ';
$PHPMAILER_LANG['from_failed']          = 'Die volgende Van adres misluk: ';
$PHPMAILER_LANG['instantiate']          = 'Kon nie posfunksie instansieer nie.';
$PHPMAILER_LANG['invalid_address']      = 'Ongeldige adres: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer word nie ondersteun nie.';
$PHPMAILER_LANG['provide_address']      = 'U moet ten minste een ontvanger e-pos adres verskaf.';
$PHPMAILER_LANG['recipients_failed']    = 'SMTP-fout: Die volgende ontvangers het misluk: ';
$PHPMAILER_LANG['signing']              = 'Ondertekening Fout: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP-verbinding () misluk.';
$PHPMAILER_LANG['smtp_error']           = 'SMTP-bediener fout: ';
$PHPMAILER_LANG['variable_set']         = 'Kan nie veranderlike instel of herstel nie: ';
$PHPMAILER_LANG['extension_missing']    = 'Uitbreiding ontbreek: ';
PHPMailer/language/phpmailer.lang-gl.php000064400000003315150766203130014127 0ustar00<?php
/**
 * Galician PHPMailer language file: refer to English translation for definitive list
 * @package PHPMailer
 * @author by Donato Rouco <[email protected]>
 */

$PHPMAILER_LANG['authenticate']         = 'Erro SMTP: Non puido ser autentificado.';
$PHPMAILER_LANG['connect_host']         = 'Erro SMTP: Non puido conectar co servidor SMTP.';
$PHPMAILER_LANG['data_not_accepted']    = 'Erro SMTP: Datos non aceptados.';
$PHPMAILER_LANG['empty_message']        = 'Corpo da mensaxe vacía';
$PHPMAILER_LANG['encoding']             = 'Codificación descoñecida: ';
$PHPMAILER_LANG['execute']              = 'Non puido ser executado: ';
$PHPMAILER_LANG['file_access']          = 'Nob puido acceder ó arquivo: ';
$PHPMAILER_LANG['file_open']            = 'Erro de Arquivo: No puido abrir o arquivo: ';
$PHPMAILER_LANG['from_failed']          = 'A(s) seguinte(s) dirección(s) de remitente(s) deron erro: ';
$PHPMAILER_LANG['instantiate']          = 'Non puido crear unha instancia da función Mail.';
$PHPMAILER_LANG['invalid_address']      = 'Non puido envia-lo correo: dirección de email inválida: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer non está soportado.';
$PHPMAILER_LANG['provide_address']      = 'Debe engadir polo menos unha dirección de email coma destino.';
$PHPMAILER_LANG['recipients_failed']    = 'Erro SMTP: Os seguintes destinos fallaron: ';
$PHPMAILER_LANG['signing']              = 'Erro ó firmar: ';
$PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() fallou.';
$PHPMAILER_LANG['smtp_error']           = 'Erro do servidor SMTP: ';
$PHPMAILER_LANG['variable_set']         = 'Non puidemos axustar ou reaxustar a variábel: ';
//$PHPMAILER_LANG['extension_missing']    = 'Extension missing: ';
PHPMailer/composer.json000064400000003340150766203130011052 0ustar00{
    "name": "phpmailer/phpmailer",
    "type": "library",
    "description": "PHPMailer is a full-featured email creation and transfer class for PHP",
    "authors": [
        {
            "name": "Marcus Bointon",
            "email": "[email protected]"
        },
        {
            "name": "Jim Jagielski",
            "email": "[email protected]"
        },
        {
            "name": "Andy Prevost",
            "email": "[email protected]"
        },
        {
            "name": "Brent R. Matzelle"
        }
    ],
    "funding": [
        {
            "url": "https://github.com/synchro",
            "type": "github"
        }
    ],
    "require": {
        "php": ">=5.5.0",
        "ext-ctype": "*",
        "ext-filter": "*",
        "ext-hash": "*"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "^2.2",
        "phpunit/phpunit": "^4.8 || ^5.7",
        "doctrine/annotations": "^1.2"
    },
    "suggest": {
        "psr/log": "For optional PSR-3 debug logging",
        "league/oauth2-google": "Needed for Google XOAUTH2 authentication",
        "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
        "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication",
        "ext-mbstring": "Needed to send email in multibyte encoding charset",
        "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)"
    },
    "autoload": {
        "psr-4": {
            "PHPMailer\\PHPMailer\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "PHPMailer\\Test\\": "test/"
        }
    },
    "license": "LGPL-2.1-only"
}
PHPMailer/README.md000064400000040334150766203130007613 0ustar00![PHPMailer](https://raw.github.com/PHPMailer/PHPMailer/master/examples/images/phpmailer.png)

# PHPMailer - A full-featured email creation and transfer class for PHP

Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/quality-score.png?s=3758e21d279becdf847a557a56a3ed16dfec9d5d)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
[![Code Coverage](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/coverage.png?s=3fe6ca5fe8cd2cdf96285756e42932f7ca256962)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)

[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) [![Latest Unstable Version](https://poser.pugx.org/phpmailer/phpmailer/v/unstable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![API Docs](https://github.com/phpmailer/phpmailer/workflows/Docs/badge.svg)](http://phpmailer.github.io/PHPMailer/)

## Class Features
- Probably the world's most popular code for sending email from PHP!
- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more
- Integrated SMTP support - send without a local mail server
- Send emails with multiple To, CC, BCC and Reply-to addresses
- Multipart/alternative emails for mail clients that do not read HTML email
- Add attachments, including inline
- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
- SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SSL and SMTP+STARTTLS transports
- Validates email addresses automatically
- Protect against header injection attacks
- Error messages in over 50 languages!
- DKIM and S/MIME signing support
- Compatible with PHP 5.5 and later
- Namespaced to prevent name clashes
- Much more!

## Why you might need it
Many PHP developers need to send email from their code. The only PHP function that supports this is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments.

Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong!
*Please* don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own. Try [SwiftMailer](https://swiftmailer.symfony.com/), [Zend/Mail](https://zendframework.github.io/zend-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail) etc.

The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.

## License
This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read LICENSE for information on the software availability and distribution.

## Installation & loading
PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file:

```json
"phpmailer/phpmailer": "~6.1"
```

or run

```sh
composer require phpmailer/phpmailer
```

Note that the `vendor` folder and the `vendor/autoload.php` script are generated by Composer; they are not part of PHPMailer.

If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the `league/oauth2-client` package in your `composer.json`.

Alternatively, if you're not using Composer, copy the contents of the PHPMailer folder into one of the `include_path` directories specified in your PHP configuration and load each class file manually:

```php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'path/to/PHPMailer/src/Exception.php';
require 'path/to/PHPMailer/src/PHPMailer.php';
require 'path/to/PHPMailer/src/SMTP.php';
```

If you're not using the `SMTP` class explicitly (you're probably not), you don't need a `use` line for the SMTP class.

If you don't speak git or just want a tarball, click the 'zip' button on the right of the project page in GitHub, though note that docs and examples are not included in the tarball.

## Legacy versions
PHPMailer 5.2 (which is compatible with PHP 5.0 - 7.0) is no longer being supported, even for security updates. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable). If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases.

### Upgrading from 5.2
The biggest changes are that source files are now in the `src/` folder, and PHPMailer now declares the namespace `PHPMailer\PHPMailer`. This has several important effects – [read the upgrade guide](https://github.com/PHPMailer/PHPMailer/tree/master/UPGRADING.md) for more details.

### Minimal installation
While installing the entire package manually or with Composer is simple, convenient, and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer!

## A Simple Example

```php
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer's autoloader
require 'vendor/autoload.php';

// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
    //Server settings
    $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
    $mail->isSMTP();                                            // Send using SMTP
    $mail->Host       = 'smtp1.example.com';                    // Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->Username   = '[email protected]';                     // SMTP username
    $mail->Password   = 'secret';                               // SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail->setFrom('[email protected]', 'Mailer');
    $mail->addAddress('[email protected]', 'Joe User');     // Add a recipient
    $mail->addAddress('[email protected]');               // Name is optional
    $mail->addReplyTo('[email protected]', 'Information');
    $mail->addCC('[email protected]');
    $mail->addBCC('[email protected]');

    // Attachments
    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    // Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
```

You'll find plenty more to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder.

If you are re-using the instance (e.g. when sending to a mailing list), you may need to clear the recipient list to avoid sending duplicate messages. See [the mailing list example](https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps) for further guidance.

That's it. You should now be ready to use PHPMailer!

## Localization
PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder you'll find many translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:

```php
// To load the French version
$mail->setLanguage('fr', '/optional/path/to/language/directory/');
```

We welcome corrections and new languages - if you're looking for corrections to do, run the [PHPMailerLangTest.php](https://github.com/PHPMailer/PHPMailer/tree/master/test/PHPMailerLangTest.php) script in the tests folder and it will show any missing translations.

## Documentation
Start reading at the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, this should be the first place you look as it's the most frequently updated.

Examples of how to use PHPMailer for common scenarios can be found in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder. If you're looking for a good starting point, we recommend you start with [the Gmail example](https://github.com/PHPMailer/PHPMailer/tree/master/examples/gmail.phps).

Note that in order to reduce PHPMailer's deployed code footprint, the examples are no longer included if you load PHPMailer via Composer or via [GitHub's zip file download](https://github.com/PHPMailer/PHPMailer/archive/master.zip), so you'll need to either clone the git repository or use the above links to get to the examples directly.

Complete generated API documentation is [available online](http://phpmailer.github.io/PHPMailer/).

You can generate complete API-level documentation by running `phpdoc` in the top-level folder, and documentation will appear in the `docs` folder, though you'll need to have [PHPDocumentor](http://www.phpdoc.org) installed. You may find [the unit tests](https://github.com/PHPMailer/PHPMailer/blob/master/test/PHPMailerTest.php) a good source of how to do various operations such as encryption.

If the documentation doesn't cover what you need, search the [many questions on Stack Overflow](http://stackoverflow.com/questions/tagged/phpmailer), and before you ask a question about "SMTP Error: Could not connect to SMTP host.", [read the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting).

## Tests
There is a PHPUnit test script in the [test](https://github.com/PHPMailer/PHPMailer/tree/master/test/) folder. PHPMailer uses PHPUnit 4.8 - we would use 5.x but we need to run on PHP 5.5.

Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)

If this isn't passing, is there something you can do to help?

## Security
Please disclose any vulnerabilities found responsibly - report any security problems found to the maintainers privately.

PHPMailer versions prior to 5.2.22 (released January 9th 2017) have a local file disclosure vulnerability, [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity.

PHPMailer versions prior to 5.2.20 (released December 28th 2016) are vulnerable to [CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer).

PHPMailer versions prior to 5.2.18 (released December 2016) are vulnerable to [CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a critical remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html).

See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) for more detail on security issues.

## Contributing
Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues).

We're particularly interested in fixing edge-cases, expanding test coverage and updating translations.

If you found a mistake in the docs, or want to add something, go ahead and amend the wiki - anyone can edit it.

If you have git clones from prior to the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone:

```sh
git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git
```

Please *don't* use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained.

## Sponsorship
Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), a powerful email marketing system.

<a href="https://info.smartmessages.net/"><img src="https://www.smartmessages.net/img/smartmessages-logo.svg" width="250" height="28" alt="Smartmessages email marketing"></a>

Other contributions are gladly received, whether in beer 🍺, T-shirts 👕, Amazon wishlist raids, or cold, hard cash 💰. If you'd like to donate to say "thank you" to maintainers or contributors, please contact them through individual profile pages via [the contributors page](https://github.com/PHPMailer/PHPMailer/graphs/contributors).

## Changelog
See [changelog](changelog.md).

## History
- PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/).
- Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
- Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski.
- Marcus created his fork on [GitHub](https://github.com/Synchro/PHPMailer) in 2008.
- Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer in 2013.
- PHPMailer moves to the [PHPMailer organisation](https://github.com/PHPMailer) on GitHub in 2013.

### What's changed since moving from SourceForge?
- Official successor to the SourceForge and Google Code projects.
- Test suite.
- Continuous integration with Travis-CI.
- Composer support.
- Public development.
- Additional languages and language strings.
- CRAM-MD5 authentication support.
- Preserves full repo history of authors, commits and branches from the original SourceForge project.
PHPMailer/LICENSE000064400000063641150766203130007347 0ustar00                  GNU LESSER GENERAL PUBLIC LICENSE
                       Version 2.1, February 1999

 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

[This is the first released version of the Lesser GPL.  It also counts
 as the successor of the GNU Library Public License, version 2, hence
 the version number 2.1.]

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.

  This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it.  You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.

  When we speak of free software, we are referring to freedom of use,
not price.  Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.

  To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights.  These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.

  For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you.  You must make sure that they, too, receive or can get the source
code.  If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it.  And you must show them these terms so they know their rights.

  We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.

  To protect each distributor, we want to make it very clear that
there is no warranty for the free library.  Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.

  Finally, software patents pose a constant threat to the existence of
any free program.  We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder.  Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.

  Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License.  This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License.  We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.

  When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library.  The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom.  The Lesser General
Public License permits more lax criteria for linking other code with
the library.

  We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License.  It also provides other free software developers Less
of an advantage over competing non-free programs.  These disadvantages
are the reason we use the ordinary General Public License for many
libraries.  However, the Lesser license provides advantages in certain
special circumstances.

  For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard.  To achieve this, non-free programs must be
allowed to use the library.  A more frequent case is that a free
library does the same job as widely used non-free libraries.  In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.

  In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software.  For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.

  Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.

  The precise terms and conditions for copying, distribution and
modification follow.  Pay close attention to the difference between a
"work based on the library" and a "work that uses the library".  The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

                  GNU LESSER GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".

  A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.

  The "Library", below, refers to any such software library or work
which has been distributed under these terms.  A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language.  (Hereinafter, translation is
included without limitation in the term "modification".)

  "Source code" for a work means the preferred form of the work for
making modifications to it.  For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.

  Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it).  Whether that is true depends on what the Library does
and what the program that uses the Library does.

  1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.

  You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.

  2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) The modified work must itself be a software library.

    b) You must cause the files modified to carry prominent notices
    stating that you changed the files and the date of any change.

    c) You must cause the whole of the work to be licensed at no
    charge to all third parties under the terms of this License.

    d) If a facility in the modified Library refers to a function or a
    table of data to be supplied by an application program that uses
    the facility, other than as an argument passed when the facility
    is invoked, then you must make a good faith effort to ensure that,
    in the event an application does not supply such function or
    table, the facility still operates, and performs whatever part of
    its purpose remains meaningful.

    (For example, a function in a library to compute square roots has
    a purpose that is entirely well-defined independent of the
    application.  Therefore, Subsection 2d requires that any
    application-supplied function or table used by this function must
    be optional: if the application does not supply it, the square
    root function must still compute square roots.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.

In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library.  To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License.  (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.)  Do not make any other change in
these notices.

  Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.

  This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.

  4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.

  If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.

  5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library".  Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.

  However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library".  The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.

  When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library.  The
threshold for this to be true is not precisely defined by law.

  If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work.  (Executables containing this object code plus portions of the
Library will still fall under Section 6.)

  Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.

  6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.

  You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License.  You must supply a copy of this License.  If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License.  Also, you must do one
of these things:

    a) Accompany the work with the complete corresponding
    machine-readable source code for the Library including whatever
    changes were used in the work (which must be distributed under
    Sections 1 and 2 above); and, if the work is an executable linked
    with the Library, with the complete machine-readable "work that
    uses the Library", as object code and/or source code, so that the
    user can modify the Library and then relink to produce a modified
    executable containing the modified Library.  (It is understood
    that the user who changes the contents of definitions files in the
    Library will not necessarily be able to recompile the application
    to use the modified definitions.)

    b) Use a suitable shared library mechanism for linking with the
    Library.  A suitable mechanism is one that (1) uses at run time a
    copy of the library already present on the user's computer system,
    rather than copying library functions into the executable, and (2)
    will operate properly with a modified version of the library, if
    the user installs one, as long as the modified version is
    interface-compatible with the version that the work was made with.

    c) Accompany the work with a written offer, valid for at
    least three years, to give the same user the materials
    specified in Subsection 6a, above, for a charge no more
    than the cost of performing this distribution.

    d) If distribution of the work is made by offering access to copy
    from a designated place, offer equivalent access to copy the above
    specified materials from the same place.

    e) Verify that the user has already received a copy of these
    materials or that you have already sent this user a copy.

  For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it.  However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.

  It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system.  Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.

  7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:

    a) Accompany the combined library with a copy of the same work
    based on the Library, uncombined with any other library
    facilities.  This must be distributed under the terms of the
    Sections above.

    b) Give prominent notice with the combined library of the fact
    that part of it is a work based on the Library, and explaining
    where to find the accompanying uncombined form of the same work.

  8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License.  Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License.  However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.

  9. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Library or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.

  10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.

  11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all.  For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.

If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded.  In such case, this License incorporates the limitation as if
written in the body of this License.

  13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number.  If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation.  If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.

  14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission.  For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this.  Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.

                            NO WARRANTY

  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

                     END OF TERMS AND CONDITIONS

           How to Apply These Terms to Your New Libraries

  If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change.  You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).

  To apply these terms, attach the following notices to the library.  It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the library's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Also add information on how to contact you by electronic and paper mail.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  library `Frob' (a library for tweaking knobs) written by James Random Hacker.

  <signature of Ty Coon>, 1 April 1990
  Ty Coon, President of Vice

That's all there is to it!SubCategory.php000064400000012234150766203130007511 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Product
 *
 * @author Nipuni
 */
class SubCategory {

    public $id;
    public $category;
    public $name;
    public $image_name;
    public $sort;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT * FROM `sub_category` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->category = $result['category'];
            $this->name = $result['name'];
            $this->image_name = $result['image_name'];
            $this->sort = $result['sort'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `sub_category` (`category`,`name`,`image_name`,`sort`) VALUES  ('"
                . $this->category . "','"
                . $this->name . "', '"
                . $this->image_name . "', '"
                . $this->sort . "')";


        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `sub_category` ORDER BY sort ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `sub_category` SET "
                . "`name` ='" . $this->name . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`sort` ='" . $this->sort . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {
        $this->deletePhotos();

        unlink(Helper::getSitePath() . "upload/product-categories/sub-category/" . $this->image_name);

        $query = 'DELETE FROM `sub_category` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deletePhotos() {

        $PRODUCT = new Product(NULL);

        $allPhotos = $PRODUCT->getProductsBySubProduct($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $PRODUCT->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/product-categories/sub-category/product/photos/" . $IMG);


            $PRODUCT_PHOTO = new ProductPhoto(NULL);
            foreach ($PRODUCT_PHOTO->getProductPhotosById($photo["id"]) as $product_photo) {
                $IMG_2 = $photo["image_name"] = $product_photo["image_name"];

                unlink(Helper::getSitePath() . "upload/product-categories/sub-category/product/photos/gallery/" . $IMG_2);
                unlink(Helper::getSitePath() . "upload/product-categories/sub-category/product/photos/gallery/thumb/" . $IMG_2);

                $PRODUCT_PHOTO->id = $product_photo['id'];
                $PRODUCT_PHOTO->delete();
            }

            $PRODUCT->id = $photo["id"];

            $PRODUCT->delete();
        }
    }

    public function getProductsByCategory($category) {

        $query = 'SELECT * FROM `sub_category` WHERE category="' . $category . '" ORDER BY sort ASC';
        
        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getSubCategoriesByCategory($category) {

        $query = 'SELECT * FROM `sub_category` WHERE category="' . $category . '"   ORDER BY sort ASC';

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function getProductsByBrand($brand) {

        $query = 'SELECT * FROM `sub_category` WHERE brand="' . $brand . '"   ORDER BY sort ASC';

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `sub_category` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
include_1.php000064400000002653150766203130007131 0ustar00<?php
var_dump(11);
include_once(dirname(__FILE__) . '/Setting.php');
include_once(dirname(__FILE__) . '/Helper.php');
include_once(dirname(__FILE__) . '/Upload.php');
include_once(dirname(__FILE__) . '/Database.php');
include_once(dirname(__FILE__) . '/User.php');
include_once(dirname(__FILE__) . '/Message.php');
include_once(dirname(__FILE__) . '/Validator.php');
include_once(dirname(__FILE__) . '/ProductCategories.php');
include_once(dirname(__FILE__) . '/Product.php');
include_once(dirname(__FILE__) . '/ProductPhoto.php');
include_once(dirname(__FILE__) . '/Brand.php');
include_once(dirname(__FILE__) . '/District.php');
include_once(dirname(__FILE__) . '/City.php');
include_once(dirname(__FILE__) . '/Customer.php');
include_once(dirname(__FILE__) . '/SubCategory.php');
include_once(dirname(__FILE__) . '/Offer.php');
include_once(dirname(__FILE__) . '/OfferPhoto.php');
include_once(dirname(__FILE__) . '/Comments.php');
include_once(dirname(__FILE__) . '/ProductReview.php');
include_once(dirname(__FILE__) . '/Package.php');
include_once(dirname(__FILE__) . '/AddToCart.php');
//include_once(dirname(__FILE__) . '/Order.php');
//include_once(dirname(__FILE__) . '/OrderProduct.php');

function dd($data) {

    var_dump($data);

    exit();
}

function redirect($url) {

    $string = '<script type="text/javascript">';

    $string .= 'window.location = "' . $url . '"';

    $string .= '</script>';
    echo $string;

    exit();
}
Order.php000064400000306077150766203140006351 0ustar00<?php

/**
 * Description of Order
 *
 * @author U s E r ¨
 */
class Order
{
    public $id;
    public $orderedAt;
    public $member;
    public $address;
    public $city;
    public $contactNo1;
    public $contactNo2;
    public $district;
    public $amount;
    public $delivery_charges;
    public $orderNote;
    public $status;
    public $paymentStatusCode;
    public $statusCode;
    public $txnid;
    public $deliveryStatus;
    public $deliveredAt;
    public $completedAt;
    public $canceledAt;
    public function __construct($id)
    {
        if ($id) {
            $query = "SELECT *  FROM `orders` WHERE `id`='" . $id . "'";
            $db = new Database();
            $result = mysql_fetch_assoc($db->readQuery($query));

            $this->id = $result['id'];
            $this->orderedAt = $result['ordered_at'];
            $this->member = $result['member'];
            $this->address = $result['address'];
            $this->city = $result['city'];
            $this->contactNo1 = $result['contact_no_1'];
            $this->contactNo2 = $result['contact_no_2'];
            $this->district = $result['district'];
            $this->amount = $result['amount'];
            $this->delivery_charges = $result['delivery_charges'];
            $this->orderNote = $result['order_note'];
            $this->status = $result['status'];
            $this->paymentStatusCode = $result['payment_status_code'];
            $this->statusCode = $result['status_code'];
            $this->txnid = $result['txnid'];
            $this->deliveryStatus = $result['delivery_status'];
            $this->deliveredAt = $result['delivered_at'];
            $this->completedAt = $result['completed_at'];
            $this->canceledAt = $result['canceled_at'];
            return $result;
        }
    }
    public function create()
    {
        $db = new Database();
        $query = "INSERT INTO `orders` ("
            . "`ordered_at`,"
            . "`member`,"
            . "`address`,"
            . "`city`,"
            . "`contact_no_1`,"
            . "`contact_no_2`,"
            . "`district`,"
            . "`amount`,"
            . "`delivery_charges`,"
            . "`order_note`,"
            . "`status`,"
            . "`payment_status_code`,"
            . "`delivery_status`,"
            . "`delivered_at`,"
            . "`completed_at`,"
            . "`canceled_at`) VALUES  ("
            . "'" . $this->orderedAt . "', "
            . "'" . $this->member . "', "
            . "'" . mysql_real_escape_string($this->address) . "', "
            . "'" . $this->city . "', "
            . "'" . $this->contactNo1 . "', "
            . "'" . $this->contactNo2 . "', "
            . "'" . $this->district . "', "
            . "'" . $this->amount . "', "
            . "'" . $this->delivery_charges . "', "
            . "'" . mysql_real_escape_string($this->orderNote) . "', "
            . "'" . 0 . "', "
            . "'" . $this->paymentStatusCode . "', "
            . "'" . $this->deliveryStatus . "', "
            . "'" . $this->deliveredAt . "', "
            . "'" . $this->completedAt . "', "
            . "'" . $this->canceledAt . "')";
        // dd($query);
        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $last_id;
        } else {
            return FALSE;
        }
    }
    public function all()
    {
        $query = "SELECT * FROM `orders` ORDER BY `id` DESC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getOrdersByDateRange($from, $to, $status)
    {
        $query = "SELECT * FROM `orders` WHERE `delivery_status`='" . $status . "' AND `status`='1' AND (`ordered_at` BETWEEN '" . $from . "' AND '" . $to . "' OR `ordered_at` LIKE '%" . $to . "%')";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getOrdersByCustomer($customer)
    {
        $query = "SELECT * FROM `orders` WHERE `member`='" . $customer . "' ORDER BY `id` DESC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getUnpaidOrdersByDateRange($from, $to)
    {
        $query = "SELECT * FROM `orders` WHERE `status`='0' AND (`ordered_at` BETWEEN '" . $from . "' AND '" . $to . "' OR `ordered_at` LIKE '%" . $to . "%') ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getPaidOrders()
    {
        $query = "SELECT * FROM `orders` WHERE `status`='1' ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function updateResponse($id, $status)
    {
        $query = "UPDATE `orders` SET "
            . "`status` ='" . $status . "' "
            . " WHERE `id` = '" . $id . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    public function delete()
    {
        $this->deleteOrderProducts();
        $query = 'DELETE FROM `orders` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }
    public function deleteOrderProducts()
    {
        $ORDER_PRODUCT = new OrderProduct(NULL);
        $allOrderProducts = $ORDER_PRODUCT->getOrdersById($this->id);
        foreach ($allOrderProducts as $order_products) {
            $ORDER_PRODUCT_OBJ = new OrderProduct($order_products["id"]);
            $ORDER_PRODUCT_OBJ->delete();
        }
    }
    public function getLastID()
    {
        $query = "SELECT `id` FROM `orders` ORDER BY `id` DESC LIMIT 1";
        $db = new Database();
        $result = mysql_fetch_assoc($db->readQuery($query));
        return $result['id'];
    }
    function updatePaymentStatusCodeAndStatus()
    {
        
        $query = "UPDATE  `orders` SET "
            . "`payment_status_code` ='" . $this->paymentStatusCode . "', "
            . "`status_code` ='" . $this->statusCode . "', "
            . "`txnid` ='" . $this->txnid . "' "
            // . "`status` ='" . $this->status . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function updatePaymentStatusCode()
    {
        $query = "UPDATE  `orders` SET "
            . "`payment_status_code` ='" . $this->paymentStatusCode . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function markAsDelivered()
    {
        date_default_timezone_set('Asia/Colombo');
        $deliveredAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`delivery_status` ='1', "
            . "`delivered_at` ='" . $deliveredAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function markAsCompleted()
    {
        date_default_timezone_set('Asia/Colombo');
        $completedAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`delivery_status` ='2', "
            . "`completed_at` ='" . $completedAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function confirmOrder()
    {
        date_default_timezone_set('Asia/Colombo');
        $confirmedAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`status` ='1', "
            . "`delivered_at` ='" . $confirmedAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function completeOrder()
    {
        date_default_timezone_set('Asia/Colombo');
        $completedAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`status` ='2', "
            . "`completed_at` ='" . $completedAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function cancelOrder()
    {
        date_default_timezone_set('Asia/Colombo');
        $canceledAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`status` ='3', "
            . "`canceled_at` ='" . $canceledAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    public function deleteOrder()
    {
        $query = 'DELETE FROM `orders` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }
    public function getPaymentStatusCode($order)
    {
        $query = "SELECT `payment_status_code` FROM `orders` WHERE `id` = $order";
        $db = new Database();
        $result = mysql_fetch_array($db->readQuery($query));
        return $result["payment_status_code"];
    }
    public function getOrdersByDeliveryStatusDescending($status)
    {
        $query = "SELECT * FROM `orders` WHERE `delivery_status`='" . $status . "' AND `payment_status_code` != 4 AND `status`='1' ORDER BY `id` DESC ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getOrdersByDeliveryStatus($status)
    {
        $query = "SELECT * FROM `orders` WHERE `status`='" . $status . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getCanceledOrders()
    {
        $query = "SELECT * FROM `orders` WHERE `status`='3'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getRefundOrders()
    {
        $query = "SELECT * FROM `orders` WHERE `payment_status_code`='4'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    function sendOrderMail()
    {
        $products = OrderProduct::getProductsByOrder($this->id);

        $CUSTOMER = new Customer($this->member);
        $DISTRICT = new District($this->district);

        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "http://" . $_SERVER['HTTP_HOST'];

        //----------------------- DISPLAY STRINGS ---------------------
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $customer_msg = 'Hello, and thank you for your interest in ' . $comany_name . '. We have received your enquiry, and we will get back to you as soon as possible.';


        $visitor_name = $CUSTOMER->name;
        $visitor_email = $CUSTOMER->email;
        //    $visitor_phone = $CUSTOMER->phone_number;
        //    $message = $_POST['message'];


        //------------------------ MAIL ESSENTIALS --------------------------------

        $webmail = "[email protected]";
        $visitorSubject = "Order Enquiry - #" . $this->id;
        $companySubject = "Order Enquiry - #" . $this->id;

        $delivery_charge = $this->delivery_charges;

        $tr = '';
        $tot = 0;
        $id = 0;
        foreach ($products as $key => $product) {

            $PRODUCT = new Product($product['product']);

            // if ($PRODUCT->parent  != 0) {
            //     $PARANT = new Product($PRODUCT->parent);
            //     $name = $PARANT->name . ' - ' . $product["product_name"];
            // } else {
            $name =  $PRODUCT->name;
            // }

            $tot += $product['amount'];
            $id++;
            $tr .= '<tr>';
            $tr .= '<td>' . $id . '</td>';
            $tr .= '<td>' . $name . '</td>';
            $tr .= '<td>' . $product['qty'] . '</td>';
            $tr .= '<td style="text-align: right;">' . number_format($product['amount'], 2) . ' LKR</td>';
            $tr .= '</tr>';
        }

        $grand_total = $tot + $delivery_charge;
        if ($this->paymentStatusCode == 2 && $this->statusCode == 'Completed') {
            $paymentstatus = "Success";
        } elseif ($this->paymentStatusCode == 2 && $this->statusCode == 'Pending') {
            $paymentstatus = "Pending";
        } else {
            $paymentstatus = "Failed";
        }
        if ($this->status == 0) {
            $status = "Pending";
        } elseif ($this->status == 1) {
            $status = "Confirmed";
        }
        if (empty($this->contactNo2)) {
            $conNo2 = '-';
        } else {
            $conNo2 = $this->contactNo2;
        }

        $visitor_message = '<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Synotec Email</title>
        </head>
        <body>
            <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                <tbody>
                    <tr> 
                        <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                            <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                <tbody>
                                    <tr> 
                                        <td bgcolor=""> 
                                            <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                                <tbody> 
                                                    <tr> 
                                                        <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody>
                                                                    <tr><td>
                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                <tbody>
                                                                                    <tr>
                                                                                        <td width="100%">
                                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                                <tbody>
                                                                                                    <tr>
                                                                                                        <td valign="middle" height="46" align="right">
                                                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                                <tbody>
                                                                                                                    <tr>
                                                                                                                        <td width="100%" align="center">
                                                                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                                <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.gallecabsandtours.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                    <h4>' . $website_name . '</h4>
                                                                                                                                </a>
                                                                                                                            </font>
                                                                                                                        </td>
                                                                                                                    </tr>
                                                                                                                </tbody>
                                                                                                            </table>
                                                                                                        </td>
                                                                                                    </tr>
                                                                                                </tbody>
                                                                                            </table>
                                                                                        </td>
                                                                                    </tr>
                                                                                </tbody>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $this->full_name . ' </td> 
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                            <p>Thank you for purchasing with us and find the attached details of the purchase below. Do not be hesitate to contact us via hotline for any enquiries.</p></td> 
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <ul>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                    Full Name : ' . $visitor_name . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                    Email : ' . $visitor_email . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                    Contact No : ' . $this->contactNo1 . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                   Additional Contact No : ' . $conNo2 . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Address : ' . $this->address . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    District : ' . $DISTRICT->name . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Ordered At : ' . $this->orderedAt . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Order Status : ' . $status . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Payment Status : ' . $paymentstatus . '
                                                                                </font>
                                                                            </li>
                                                                                
                                                                                <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                    <thead>
                                                                                        <tr>
                                                                                            <th>ID</th>
                                                                                            <th>Product</th>
                                                                                            <th>Qty</th>
                                                                                            <th>Amount</th>
                                                                                        </tr>
    
                                                                                    </thead>
                                                                                    <tbody>
                                                                                        ' . $tr . '
                                                                                    </tbody>
                                                                                    <tfoot>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($tot, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($delivery_charge, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($grand_total, 2) . ' </th>
                                                                                        </tr>
                                                                                    </tfoot>
                                                                                </table>
                                                                        </ul>
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:10px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px 10px" align="left"> <p> Cheers, </p>
                                                                            <p> ' . $comOwner . ' </p>
                                                                        </td> 
                                                                    </tr>
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                            <p>* Special Note - Do not delete this e-mail, instead keep it as the invoice to submit the delivery person.</p></td> 
                                                                    </tr> 
                                                                        
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#fff" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff"> 
                                                                
                                                                <tbody>
                                                                    <tr> 
                                                                        <td style="padding:10px 20px 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0"> 
                                                                            </p><p style="line-height:24px;margin:0;padding:0">' . $comany_name . '</p>
                                                                            <p style="line-height:24px;margin:0;padding:0">Email : ' . $comEmail . ' </p> 
                                                                            <p style="line-height:24px;margin:0;padding:0">Tel: ' . $comConNumber . '</p> </td> 
                                                                    </tr> 
                                                                </tbody>
                                                            </table> 
                                                        </td> 
                                                    </tr> 
                                                </tbody> 
                                            </table>
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td id="m_-1040695829873221998footer_content"> 
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                                <tbody>
                                                    <tr> 
                                                        <td> 
                                                            <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                    </tr> 
                                                                    <tr></tr> 
                                                                </tbody> 
                                                            </table>
                                                        </td> 
                                                    </tr> 
                                                </tbody>
                                            </table> 
                                        </td> 
                                    </tr> 
                                </tbody>
                            </table>
                        </td> 
                    </tr> 
                </tbody>
            </table>
        </body>
    </html>';

        $company_message = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr><td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="100%" align="center">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.gallecabsandtours.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $comany_name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p> You have a new order enquiry from your website on ' . $todayis . ' as follows. Please pay your attention as soon as possible.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                    <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                        Full Name : ' . $visitor_name . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                        Email : ' . $visitor_email . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                        Contact No : ' . $this->contactNo1 . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                       Additional Contact No : ' . $conNo2 . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Address : ' . $this->address . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        District : ' . $DISTRICT->name . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Ordered At : ' . $this->orderedAt . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Order Status : ' . $status . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Payment Status : ' . $paymentstatus . '
                                                                    </font>
                                                                </li>
                                                                        <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <th>ID</th>
                                                                                        <th>Product</th>
                                                                                        <th>Qty</th>
                                                                                        <th>Amount</th>
                                                                                    </tr>

                                                                                </thead>
                                                                                <tbody>
                                                                                    ' . $tr . '
                                                                                </tbody>
                                                                                <tfoot>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($tot, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($delivery_charge, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($grand_total, 2) . ' </th>
                                                                                        </tr>
                                                                                    </tfoot>
                                                                            </table>
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table> 
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';

        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $comany_name, $visitor_email, $visitor_name, $visitorSubject, $visitor_message);
        $companyMail = $HELPER->PHPMailer($webmail, $visitor_name, $visitor_email, $visitor_name, $comEmail, $comany_name, $companySubject, $company_message);

        if ($visitorMail && $companyMail) {
            $arr['status'] = "Your message has been sent successfully";
        } else {
            $arr['status'] = "Could not be sent your message";
        }

        return $arr;
    }


    function sendOrderMail1($products)
    {
        $CUSTOMER = new Customer($this->member);
        $DISTRICT = new District($this->district);
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $visitor_email = $CUSTOMER->email;
        $visitor_name = $CUSTOMER->name;
        $webmail = "[email protected]";
        $visitorSubject = "Order Enquiry - #" . $this->id;
        $tr = '';
        $tot = 0;
        $id = 0;
        foreach ($products as $key => $product) {
            $PRODUCT = new Product($product['product']);
            $tot += $product['amount'];
            $id++;
            $tr .= '<tr>';
            $tr .= '<td>' . $id . '</td>';
            $tr .= '<td>' . $PRODUCT->name . '</td>';
            $tr .= '<td>' . $product['qty'] . ' ' . $PRODUCT->unit . '</td>';
            $tr .= '<td style="text-align: right;">US $' . number_format($product['amount'], 2) . '</td>';
            $tr .= '</tr>';
        }
        // $processing_fee = ($tot + 150) * 3 / 100;
        $grand_total = $tot + 0;
        $html = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr><td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="100%" align="center">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.pramudigems.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $CUSTOMER->name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p>Thank you for purchasing with us and find the attached details of the purchase below. Do not be hesitate to contact us via hotline for any enquiries.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Full Name : ' . $CUSTOMER->name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Email : ' . $CUSTOMER->email . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Contact No : ' . $this->contactNo1 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                               Additional Contact No : ' . $this->contactNo2 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Address : ' . $this->address . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                State : ' . $DISTRICT->name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Ordered At : ' . $this->orderedAt . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Status : Pending
                                                                            </font>
                                                                        </li>
                                                                            
                                                                            <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <th>ID</th>
                                                                                        <th>Product</th>
                                                                                        <th>Qty</th>
                                                                                        <th>Amount</th>
                                                                                    </tr>
                                                                                </thead>
                                                                                <tbody>
                                                                                    ' . $tr . '
                                                                                </tbody>
                                                                                <tfoot>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($tot, 2) . '</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                        <th style="text-align: right;">US $0.00</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($grand_total, 2) . '</th>
                                                                                    </tr>
                                                                                </tfoot>
                                                                            </table>
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:10px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px 10px" align="left"> <p> Cheers, </p>
                                                                        <p> ' . $comOwner . ' </p>
                                                                    </td> 
                                                                </tr>
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p>* Special Note - Do not delete this e-mail, instead keep it as the invoice to submit the delivery person.</p></td> 
                                                                </tr> 
                                                                    
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#fff" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff"> 
                                                            
                                                            <tbody>
                                                                <tr> 
                                                                    <td style="padding:10px 20px 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0"> 
                                                                        </p><p style="line-height:24px;margin:0;padding:0">' . $comany_name . '</p>
                                                                        <p style="line-height:24px;margin:0;padding:0">Email : ' . $comEmail . ' </p> 
                                                                        <p style="line-height:24px;margin:0;padding:0">Tel: ' . $comConNumber . '</p> </td> 
                                                                </tr> 
                                                            </tbody>
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table> 
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';
        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $reply_email_name, $visitor_email, $visitor_name, $visitorSubject, $html);
        if ($visitorMail) {
            $arr['status'] = "Your message has been sent successfully";
        } else {
            $arr['status'] = "Could not be sent your message";
        }
        return $arr;
    }
    function sendOrderMailToAdmin($products)
    {
        $CUSTOMER = new Customer($this->member);
        $DISTRICT = new District($this->district);
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $visitor_email = $CUSTOMER->email;
        $visitor_name = $CUSTOMER->name;
        $webmail = "[email protected]";
        $visitorSubject = "Order Enquiry - #" . $this->id;
        $tr = '';
        $tot = 0;
        $id = 0;
        foreach ($products as $key => $product) {
            $PRODUCT = new Product($product['product']);
            $tot += $product['amount'];
            $id++;
            $tr .= '<tr>';
            $tr .= '<td>' . $id . '</td>';
            $tr .= '<td>' . $PRODUCT->name . '</td>';
            $tr .= '<td>' . $product['qty'] . ' ' . $PRODUCT->unit . '</td>';
            $tr .= '<td style="text-align: right;">US $' . number_format($product['amount'], 2) . '</td>';
            $tr .= '</tr>';
        }
        // $processing_fee = ($tot + 150) * 3 / 100;
        $grand_total = $tot + 0;
        $status = "Pending";
        $html = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr><td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="100%" align="center">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.pramudigems.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $comany_name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p> You have a new order enquiry from your website on ' . $todayis . ' as follows. Please pay your attention as soon as possible.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Full Name : ' . $CUSTOMER->name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Email : ' . $CUSTOMER->email . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Contact No : ' . $this->contactNo1 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                               Additional Contact No : ' . $this->contactNo2 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Address : ' . $this->address . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                State : ' . $DISTRICT->name . '
                                                                            </font>
                                                                        </li>
                                                                            
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Ordered At : ' . $this->orderedAt . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Status : ' . $status . '
                                                                            </font>
                                                                        </li>
                                                                        <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <th>ID</th>
                                                                                        <th>Product</th>
                                                                                        <th>Qty</th>
                                                                                        <th>Amount</th>
                                                                                    </tr>
                                                                                </thead>
                                                                                <tbody>
                                                                                    ' . $tr . '
                                                                                </tbody>
                                                                                <tfoot style="border: 1px solid #000">
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($tot, 2) . '</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                        <th style="text-align: right;">US $0.00</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($grand_total, 2) . '</th>
                                                                                    </tr>
                                                                                </tfoot>
                                                                            </table>
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table> 
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';
        $HELPER = new Helper();
        $companyMail = $HELPER->PHPMailer($webmail, $visitor_name, $visitor_email, $visitor_name, $comEmail, $comany_name, $visitorSubject, $html);
        if ($companyMail) {
            $arr['status'] = "Your message has been sent successfully";
        } else {
            $arr['status'] = "Could not be sent your message";
        }
        return $arr;
    }
    public function sendOrderConfirmedEmail()
    {
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $CUSTOMER = new Customer($this->member);
        $visitor_email = $CUSTOMER->email;
        $visitor_name = $CUSTOMER->name;
        $webmail = "[email protected]";
        $visitorSubject = "Order Confirmation - (#" . $this->id . ")";
        // Compose a simple HTML email message
        $message = '<html>';
        $message .= '<body>';
        $message .= '<div  style="padding: 10px; max-width: 650px; background-color: #f2f1ff; border: 1px solid #d4d4d4;">';
        $message .= '<h4>Order Confirmation - (#' . $this->id . ')</h4>';
        $message .= '<p>Dear sir/madam, <br/>Your order (#' . $this->id . ') has been confiremd successfully.</p>';
        $message .= '<hr/>';
        $message .= '<p>Please click <a href="' . $site_link . '/member/view-order.php?id=' . $this->id . '" target="_blank">here</a> to check your order details.</p>';
        $message .= '<hr/>';
        $message .= '<p>Thanks & Best Regards!.. <br/> ' . $website_name . '<p/>';
        $message .= '<small>*Please do not reply to this email. This is an automated email & you will not receive a response.</small><br/>';
        $message .= '<span>Hotline: ' . $comConNumber . ' </span><br/>';
        $message .= '<span>' . $comEmail . '</span>';
        $message .= '</div>';
        $message .= '</body>';
        $message .= '</html>';
        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $reply_email_name, $visitor_email, $visitor_name, $visitorSubject, $message);
        if ($visitorMail) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function checkTxnid($txnid)
    {

        $query = "SELECT * FROM `orders` WHERE `txnid` = '" . mysql_real_escape_string($txnid) . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return FALSE;
        } else {
            return TRUE;
        }
    }
}
Brand.php000064400000005607150766203140006317 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Product
 *
 * @author Nipuni
 */
class Brand {

    public $id;
    public $name; 
    public $logo; 
    public $sort;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT * FROM `brands` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->logo = $result['logo']; 
            $this->sort = $result['sort'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `brands` (`name`,`logo`,`sort`) VALUES  ('"
                . $this->name . "', '"
                . $this->logo . "', '" 
                . $this->sort . "')";


        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `brands` ORDER BY sort ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `brands` SET " 
                . "`name` ='" . $this->name . "', "
                . "`logo` ='" . $this->logo . "' "  
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {


        $query = 'DELETE FROM `brands` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getProductsById($brands) {

        $query = 'SELECT * FROM `brands` WHERE type="' . $brands . '"   ORDER BY queue ASC';

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `brands` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
OrderProduct.php000064400000010743150766203140007702 0ustar00<?php

/**
 * Description of OrderProduct
 *
 * @author U s E r ¨
 */
class OrderProduct {

    public $id;
    public $order;
    public $product;
    public $qty;
    public $amount;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT *  FROM `order_product` WHERE `id`='" . $id . "'";

            $db = new Database();

            $result = mysql_fetch_assoc($db->readQuery($query));

            $this->id = $result['id'];
            $this->order = $result['order'];
            $this->product = $result['product'];
            $this->qty = $result['qty'];
            $this->amount = $result['amount'];

            return $result;
        }
    }

    public function create() {

        $query = "INSERT INTO `order_product` ("
                . "`order`,"
                . "`product`,"
                . "`qty`,"
                . "`amount`) VALUES  ("
                . "'" . $this->order . "', "
                . "'" . $this->product . "', "
                . "'" . $this->qty . "', "
                . "'" . $this->amount . "')";
// dd($query);
        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $last_id;
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `order_product`";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    
    public function getProductsByOrder($order) {

        $query = "SELECT * FROM `order_product` WHERE `order`='" . $order . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    public function delete() {

        $query = 'DELETE FROM `order_product` WHERE id="' . $this->id . '"';

        $db = new Database();
        return $db->readQuery($query);
    }    
    
    public function createOrderProduct() {
        
        $query = "INSERT INTO `order_product` ("
                . "`order`,"
                . "`product`,"
                . "`qty`,"
                . "`amount`) VALUES  ("
                . "'" . $this->order . "', "
                . "'" . $this->product . "', "
                . "'" . $this->qty . "', "
                . "'" . $this->amount . "')";

        $db = new Database();
        $result = $db->readQuery1($query);
        
        if ($result) {
            return $result;
        } else {
            return FALSE;
        }
    }
    
    public function getOrdersById($order) {

        $query = "SELECT * FROM `order_product` WHERE `order` = $order";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    public function getOrderProductsById($order) {

        $query = "SELECT * FROM `order_product` WHERE `order` = $order";

        $db = new Database();
        $result = $db->readQuery1($query);
        $array_res = array();

        while ($row = mysqli_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    public function getPendingOrdersProducts() {

        $query = "SELECT `product`, sum(`qty`) AS `qty` FROM `order_product` WHERE `order` IN (SELECT `id` FROM `orders` WHERE `payment_status_code` = 2 AND `delivery_status` = 0 AND `status` = 1) GROUP BY `product`";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    public function getConfirmedOrdersProducts() {

        $query = "SELECT `product`, sum(`qty`) AS `qty` FROM `order_product` WHERE `order` IN (SELECT `id` FROM `orders` WHERE `payment_status_code` = 2 AND `delivery_status` = 1 AND `status` = 1) GROUP BY `product`";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

}DefaultData.php000064400000000756150766203150007450 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of DefaultData
 *
 * @author W j K n``
 */
class DefaultData {

    const Host = 'sg1-ls7.a2hosting.com';
    const Username = '[email protected]';
    const Password = '~y]cu9v;~WYy';
    const Port = 465;

    public function getDeliveryCharges()
    {
        return 0;
    }

}City.php000064400000007054150766203150006200 0ustar00<?php

/**
 * Description of Product
 *
 * @author sublime holdings
 * @web www.sublime.lk
 */
class City {

    //put your code here
    public $id;
    public $district;
    public $name;
    public $sort;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`district`,`name`,`sort` FROM `city` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->district = $result['district'];
            $this->name = $result['name'];
            $this->sort = $result['sort'];

            return $this;
        }
    }
    
    public function getCityByName($name) {

            $query = "SELECT `id` FROM `city` WHERE `name` LIKE '" . $name . "'";
            
            $db = new Database();
            $result = mysql_fetch_array($db->readQuery($query));
            return $result;
    }

    public function create() {

        $query = "INSERT INTO `city` (`district`, `name`, `sort`) VALUES  ('" . $this->district . "','" . $this->name . "', '" . $this->sort . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `city` ORDER BY `sort` ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = 'UPDATE `city` SET `name`= "' . $this->name . '" WHERE id="' . $this->id . '"';

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `city` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function GetCitiesByDistrict($district) {

        $query = "SELECT * FROM `city` WHERE `district` = '" . $district . "' ORDER BY `name` ASC";
       
        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }
    
    public function getDistrictByCityId($city) {

        $query = "SELECT * FROM `city` WHERE `id` = '" . $city . "'";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function deleteCitiesByDistrict($district) {

        $query = "DELETE FROM `city` WHERE `district`= '" . $district . "'";

        $db = new Database();
        $result = $db->readQuery($query);

        return $result;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `city` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}Customer.php000064400000024640150766203160007072 0ustar00<?php

/**
 * Description of Product
 *
 * @author sublime holdings
 * @web www.sublime.lk
 */
class Customer
{

    //put your code here
    public $id;
    public $name;
    public $email;
    public $password;
    public $phone_number;
    public $district;
    public $city;
    public $address;
    public $resetcode;
    public $authToken;
    public $image_name;

    public function __construct($id)
    {
        if ($id) {

            $query = "SELECT  * FROM `customer` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->email = $result['email'];
            $this->password = $result['password'];
            $this->phone_number = $result['phone_number'];
            $this->district = $result['district'];
            $this->address = $result['address'];
            $this->resetcode = $result['resetcode'];
            $this->authToken = $result['authToken'];
            $this->image_name = $result['image_name'];

            return $this;
        }
    }

    public function create()
    {

        $query = "INSERT INTO `customer` (`name`, `email`, `password`,`phone_number`,`district`,`address`,`image_name`) VALUES  ('"
            . $this->name . "','"
            . $this->email . "', '"
            . $this->password . "', '"
            . $this->phone_number . "', '"
            . $this->district . "', '"
            . $this->address . "', '"
            . $this->image_name . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all()
    {

        $query = "SELECT * FROM `customer` ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function login($email, $password)
    {


        $query = "SELECT  * FROM `customer` WHERE `email`= '" . $email . "' AND `password`= '" . $password . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {

            return FALSE;
        } else {

            $this->id = $result['id'];
            $this->setAuthToken($result['id']);
            $this->setUserSession($this->id);
            $customer = $this->__construct($this->id);
            return $customer;
        }
    }

    public function logOut()
    {

        if (!isset($_SESSION)) {
            session_start();
        }

        unset($_SESSION["id"]);
        unset($_SESSION["name"]);
        unset($_SESSION["email"]);

        return TRUE;
    }

    private function setUserSession($customer)
    {

        if (!isset($_SESSION)) {
            session_start();
        }
        $customer = $this->__construct($customer);

        $_SESSION["id"] = $customer->id;
        $_SESSION["name"] = $customer->name;
        $_SESSION["email"] = $customer->email;
        $_SESSION["phone_number"] = $customer->phone_number;
        $_SESSION["authToken"] = $customer->authToken;
        $_SESSION["image_name"] = $customer->image_name;
    }

    private function setAuthToken($id)
    {

        $authToken = md5(uniqid(rand(), true));

        $query = "UPDATE `customer` SET `authToken` ='" . $authToken . "' WHERE `id`='" . $id . "'";

        $db = new Database();

        if ($db->readQuery($query)) {
            return $authToken;
        } else {

            return FALSE;
        }
    }

    public function authenticate()
    {

        if (!isset($_SESSION)) {

            session_start();
        }

        $id = NULL;
        $authToken = NULL;

        if (isset($_SESSION["id"])) {
            $id = $_SESSION["id"];
        }

        if (isset($_SESSION["authToken"])) {
            $authToken = $_SESSION["authToken"];
        }

        $query = "SELECT `id` FROM `customer` WHERE `id`= '" . $id . "' AND `authToken`= '" . $authToken . "'";

        $db = new Database();
        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {

            return FALSE;
        } else {
            return TRUE;
        }
    }

    public function checkEmail($email)
    {

        $query = "SELECT `id`,`email`,`name` FROM `customer` WHERE `email`= '" . $email . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));

        if (!$result) {

            return FALSE;
        } else {

            return $result;
        }
    }

    public function GenarateCode($email)
    {

        $rand = rand(10000, 99999);

        $query = "UPDATE  `customer` SET "
            . "`resetcode` ='" . $rand . "' "
            . "WHERE `email` = '" . $email . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    public function SelectForgetCustomer($email)
    {

        if ($email) {

            $query = "SELECT `email`,`name`,`resetcode` FROM `customer` WHERE `email`= '" . $email . "'";

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->name = $result['name'];
            $this->email = $result['email'];
            $this->restCode = $result['resetcode'];

            return $result;
        }
    }

    public function SelectResetCode($code)
    {

        $query = "SELECT `id` FROM `customer` WHERE `resetcode`= '" . $code . "'";

        $db = new Database();

        $result = mysql_fetch_array($db->readQuery($query));
        if (!$result) {

            return FALSE;
        } else {
            return TRUE;
        }
    }

    public function updatePassword($password, $code)
    {
        $enPass = md5($password);

        $query = "UPDATE  `customer` SET "
            . "`password` ='" . $enPass . "' "
            . "WHERE `resetcode` = '" . $code . "'";

        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {

            return TRUE;
        } else {

            return FALSE;
        }
    }

    public function update()
    {

        $query = "UPDATE  `customer` SET "
            . "`name` ='" . $this->name . "', "
            . "`email` ='" . $this->email . "', "
            . "`password` ='" . $this->password . "', "
            . "`phone_number` ='" . $this->phone_number . "', "
            . "`district` ='" . $this->district . "', "
            . "`address` ='" . $this->address . "' "
            . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete()
    {

        $query = 'DELETE FROM `customer` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function GetCitiesByDistrict($district)
    {

        $query = "SELECT * FROM `customer` WHERE `district` = '" . $district . "'";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function getDistrictByCityId($customer)
    {

        $query = "SELECT * FROM `customer` WHERE `id` = '" . $customer . "'";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function deleteCitiesByDistrict($district)
    {

        $query = "DELETE FROM `customer` WHERE `district`= '" . $district . "'";

        $db = new Database();
        $result = $db->readQuery($query);

        return $result;
    }

    public function arrange($key, $img)
    {
        $query = "UPDATE `customer` SET `sort` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

    public function sendRegistrationEmail()
    {


        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];

        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";

        $visitor_email = $this->email;
        $visitor_name = $this->name;
        $webmail = "[email protected]";
        $visitorSubject = "Your Registration is Successful!. -" . $comany_name;



        // Compose a simple HTML email message
        $message = '<html>';
        $message .= '<body>';
        $message .= '<div  style="padding: 10px; max-width: 650px; background-color: #f2f1ff; border: 1px solid #d4d4d4;">';
        $message .= '<h4>Welcome to the ' . $comany_name . '!.</h4>';
        $message .= '<p>Dear sir/madam, Thank you for registering on ' . $website_name . '. Please use your email when you log in to the website with the password, which you gave when creating your account...</p>';
        $message .= '<hr/>';
        $message .= '<h3>Your Email :' . $this->email . '</h3>';
        $message .= '<hr/>';
        $message .= '<p>Thanks & Best Regards!.. <br/> ' . $website_name . '<p/>';
        $message .= '<small>*Please do not reply to this email. This is an automated email & you will not receive a response.</small><br/>';
        $message .= '<span>Hotline: ' . $comConNumber . ' </span><br/>';
        $message .= '<span>' . $comEmail . '</span>';
        $message .= '</div>';
        $message .= '</body>';
        $message .= '</html>';
     
        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $reply_email_name, $visitor_email, $visitor_name, $visitorSubject, $message);

        if ($visitorMail) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}
Inquiry.php000064400000113211150766207320006724 0ustar00<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Description of Inquiry
 *
 * @author Suharshana DsW
 */
class Inquiry
{
    public $id;
    public $name;
    public $email;
    public $phone;
    public $address;
//    public $property;
    public $message;
    public $created_at;
    public function __construct($id)
    {
        if ($id) {
            $query = "SELECT * FROM `inquiry` WHERE `id`=" . $id;
            $db = new Database();
            $result = mysql_fetch_array($db->readQuery($query));
            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->email = $result['email'];
            $this->phone = $result['phone'];
            $this->address = $result['address'];
//            $this->property = $result['property'];
            $this->message = $result['message'];
            $this->created_at = $result['created_at'];
            return $this;
        }
    }
    public function create()
    {
        date_default_timezone_set('Asia/Colombo');
        $createdAt = date('Y-m-d H:i:s');
        $query = "INSERT INTO `inquiry` ("
            . "`created_at`,"
            . "`name`,"
            . "`email`,"
            . "`phone`,"
            . "`address`,"
//            . "`property`,"
            . "`message`"
            . ") VALUES  ('"
            . $createdAt . "','"
            . $this->name . "','"
            . $this->email . "','"
            . $this->phone . "','"
            . $this->address . "','"
//            . $this->property . "', '"
            . $this->message . "')";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }
    public function all()
    {
        $query = "SELECT * FROM `inquiry` ORDER BY `id` DESC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getInquiriesByMember($member)
    {
        $query = "SELECT * FROM `inquiry` WHERE `property` IN (SELECT `id` FROM `property` WHERE `member` = $member) ORDER BY `id` DESC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function update()
    {
        $query = "UPDATE  `inquiry` SET "
            . "`name` ='" . $this->name . "', "
            . "`email` ='" . $this->email . "', "
            . "`phone` ='" . $this->phone . "', "
            . "`address` ='" . $this->address . "', "
//            . "`property` ='" . $this->property . "', "
            . "`message` ='" . $this->message . "' "
            . "`created_at` ='" . $this->created_at . "' "
            . "WHERE `id` = '" . $this->id . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }
    public function delete()
    {
        $query = 'DELETE FROM `inquiry` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }
    public function sendMail($inquiry)
    {
        require_once "Mail.php";
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "http://" . $_SERVER['HTTP_HOST'];
        //----------------------- DISPLAY STRINGS ---------------------
        $comany_name = "3D Creations";
        $website_name = "www.srilankaproperties.lk";
        $comConNumber = "+94 11 111 111";
        $comEmail = "[email protected]";
        $comOwner = "";
        $customer_msg = 'Hello, and thank you for your interest in ' . $comany_name . '.We have received your property inquiry, and we will get back to you as soon as possible.';
        //----------------------- LOGO ---------------------------------
        $logo = $site_link . '/contact-form/img/logo.png';
        //$logo = 'https://ci4.googleusercontent.com/proxy/lz0tSijRTHwJ3I7PQ1iXA67lYFfULG0evRbR_St785VeiABNukQPJl-JGBcLKTkZz1q4pG6g25P1uxTW4dYkOznHHNV3f-zB=s0-d-e1-ft#http://http://sunilayurveda.galle.website/contact-form/img/logo.jpg';
        // ----------------------- POST VARIABLES --------------------------
        $visitor_name = $inquiry->name;
        $visitor_email = $inquiry->email;
//        $property = $inquiry->property;
//        $PROPERTY = new Property($property);
//        $MEMBER = new Member($PROPERTY->member);

        //---------------------- SERVER WEBMAIL LOGIN ------------------------
        $host = "sg1-ls7.a2hosting.com";
        $username = "[email protected]";
        $password = "TestEmail123";
        //------------------------ MAIL ESSENTIALS --------------------------------
        $webmail = "[email protected]";
        $visitorSubject = "Thank You " . $visitor_name . " - 3D Creations";
        $companySubject = "Property Inquiry - #" . $property;
        $visitor_message = '<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
    
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
            <title>Synotec Email</title>
    
        </head>
    
    
    
        <body>
    
            <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                <tbody>
                    <tr> 
                        <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                            <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                <tbody>
    
                                    <tr> 
                                        <td bgcolor=""> 
                                            <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                                <tbody> 
    
                                                    <tr> 
                                                        <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody>
                                                                    <tr><td>
                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0">
    
                                                                                <tbody><tr>
    
    
    
                                                                                        <td width="182">
    
                                                                                            <a href="' . $site_link . '" alt="" class="CToWUd" border="0">
                                                                                            <img src="' . $logo . '" alt="" class="CToWUd" border="0">
                                                                                            </a>
                                                                                        </td>
    
                                                                                        <td width="393">
    
                                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
    
                                                                                                <tbody><tr>
    
                                                                                                        <td valign="middle" height="46" align="right">
    
                                                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0">
    
                                                                                                                <tbody><tr>
    
                                                                                                                        <td width="67%" align="right">
    
                                                                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
    
                                                                                                                                <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.gallecabsandtours.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
    
                                                                                                                                    <h4>' . $website_name . '</h4>
    
                                                                                                                                </a>
    
                                                                                                                            </font>
    
                                                                                                                        </td>
    
                                                                                                                        <td width="4%">&nbsp;</td>
    
                                                                                                                    </tr>
    
                                                                                                                </tbody></table>
    
                                                                                                        </td>
    
                                                                                                    </tr>
    
                                                                                                    <tr>
    
                                                                                                        <td height="30">
                                                                                                        <img src="https://ci3.googleusercontent.com/proxy/TYJ_zOrASsobTeDz_yvavwzKTAX7JrJGTJyCeRScsDTzGF54pub4t0wIRdM4iU3Avx31-3oG9cLkfEWyndCW6CIvp3jtKfO3KpewNC4=s0-d-e1-ft#https://synotec.lk/sites-mail-files/PROMO-GREEN2_01_04.jpg" alt="" class="CToWUd" width="393" height="30" border="0">
                                                                                                        </td>
    
                                                                                                    </tr>
    
                                                                                                </tbody></table>
    
                                                                                        </td>
    
                                                                                    </tr>
    
                                                                                </tbody></table>
                                                                        </td>
                                                                    </tr><tr> 
                                                                        <td style="font-size:20px;color:#33468f;line-height:28px;font-family:Arial,Helvetica,sans-serif;padding-bottom:20px;padding-top: 0px;font-weight: 600;" align="left"> Thank You ! </td> 
                                                                    </tr>
                                                                </tbody> 
                                                            </table> 
    
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
    
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $visitor_name . ' </td> 
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> <p> ' . $customer_msg . ' </p></td> 
                                                                    </tr> 
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:10px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px 10px" align="left"> <p> Best regards, </p>
                                                                            <p> ' . $comOwner . '</p>
                                                                        </td> 
                                                                    </tr>
    
    
    
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#fff" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                                    </tr> 
                                                                </tbody> 
                                                                <tbody><tr> 
                                                                        <td style="padding:10px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0"> 
                                                                            </p><p style="line-height:24px;margin:0;padding:0">' . $comany_name . '</p>
                                                                            <p style="line-height:24px;margin:0;padding:0">Email : ' . $comEmail . ' </p> 
                                                                            <p style="line-height:24px;margin:0;padding:0">Tel: ' . $comConNumber . '</p> </td> 
                                                                    </tr> 
                                                                </tbody></table> 
                                                 
    
    
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                    </tr> 
                                                    <tr> 
                                                    
                                                                                </tr> 
                                                </tbody> 
                                            </table> </td> 
                                    </tr> 
                                    <tr> 
                                        <td id="m_-1040695829873221998footer_content"> 
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                                <tbody>
                                                    <tr> 
                                                        <td> 
                                                            <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                                <tbody> 
    
    
                                                                    <tr> 
                                                                        <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                    </tr> 
                                                                    <tr></tr> 
                                                                </tbody> 
                                                            </table> </td> 
                                                    </tr> 
                                                </tbody>
                                            </table> </td> 
                                    </tr> 
                                </tbody>
                            </table> </td> 
                    </tr> 
                </tbody>
            </table>
    
    
    
        </body>
    
    </html>';
        $visitorHeaders = array(
            'MIME-Version' => '1.0', 'Content-Type' => "text/html; charset=ISO-8859-1", 'From' => $webmail,
            'To' => $visitor_email,
            'Reply-To' => $MEMBER->email,
            'Subject' => $visitorSubject
        );
        $smtp = Mail::factory('smtp', array(
            'host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password
        ));
        $visitorMail = $smtp->send($visitor_email, $visitorHeaders, $visitor_message);
        if (PEAR::isError($visitorMail)) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    public function sendMailToMember($inquiry)
    {
        require_once "Mail.php";
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "http://" . $_SERVER['HTTP_HOST'];
        //----------------------- DISPLAY STRINGS ---------------------
        $comany_name = "Sri Lanka Properties";
        $website_name = "www.srilankaproperties.lk";
        $comConNumber = "+94 11 111 111";
        $comEmail = "[email protected]";
        $comOwner = "Sri Lanka Properties";
        //----------------------- LOGO ---------------------------------
        $logo = $site_link . '/contact-form/img/logo.png';
        //$logo = 'https://ci4.googleusercontent.com/proxy/lz0tSijRTHwJ3I7PQ1iXA67lYFfULG0evRbR_St785VeiABNukQPJl-JGBcLKTkZz1q4pG6g25P1uxTW4dYkOznHHNV3f-zB=s0-d-e1-ft#http://http://sunilayurveda.galle.website/contact-form/img/logo.jpg';
        // ----------------------- POST VARIABLES --------------------------
        $visitor_name = $inquiry->name;
        $visitor_email = $inquiry->email;
        $visitor_phone = $inquiry->phone;
//        $property = $inquiry->property;
        $visitor_address = $inquiry->address;
        $message = $inquiry->message;
//        $PROPERTY = new Property($property);
//        $MEMBER = new Member($PROPERTY->member);
        //---------------------- SERVER WEBMAIL LOGIN ------------------------
        $host = "sg1-ls7.a2hosting.com";
        $username = "[email protected]";
        $password = "TestEmail123";
        //------------------------ MAIL ESSENTIALS --------------------------------
        $webmail = "[email protected]";
        $visitorSubject = "Thank You " . $visitor_name . " - 3D Creations";
        $companySubject = "Property Inquiry - #" . $property;
        $company_message = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr>
                                                                    <td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="182">
                                                                                        <a href="' . $site_link . '" target="_blank"> <img src="' . $logo . '" alt="" class="CToWUd" border="0"></img>
                                                                                        </a>
                                                                                    </td>
                                                                                    <td width="393">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="67%" align="right">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.gallecabsandtours.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                    <td width="4%">&nbsp;</td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                                <tr>
                                                                                                    <td height="30">
                                                                                                    <img src="https://ci3.googleusercontent.com/proxy/TYJ_zOrASsobTeDz_yvavwzKTAX7JrJGTJyCeRScsDTzGF54pub4t0wIRdM4iU3Avx31-3oG9cLkfEWyndCW6CIvp3jtKfO3KpewNC4=s0-d-e1-ft#https://synotec.lk/sites-mail-files/PROMO-GREEN2_01_04.jpg" alt="" class="CToWUd" width="393" height="30" border="0">
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $MEMBER->name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> <p> You have a new property inquiry from website. Kindly request your attention on this matter. The details of the inquiry are shown bellow.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                   <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Name : ' . $visitor_name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Email : <a href="mailto:' . $visitor_email . '" rel="noreferrer" target="_blank">' . $visitor_email . '</a>
                                                                            </font>
                                                                        </li>
                                                                        
     <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                 Contact Number : ' . $visitor_phone . '
                                                                            </font>
                                                                        </li>
                                                                             <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                  Address : ' . $visitor_address . '
                                                                            </font>
                                                                        </li>
                                                                        </li>
                                                                             <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                  Property : ' . $PROPERTY->title . ' (#' . $property . ')
                                                                            </font>
                                                                        </li>
                                             
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding-bottom:8px" align="left"> ' . $message . '</td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table>
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';
        $companyHeaders = array(
            'MIME-Version' => '1.0', 'Content-Type' => "text/html; charset=ISO-8859-1", 'From' => $webmail,
            'To' => $MEMBER->email,
            'Reply-To' => $visitor_email,
            'Subject' => $companySubject
        );
        $smtp = Mail::factory('smtp', array(
            'host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password
        ));
        $companyMail = $smtp->send($MEMBER->email, $companyHeaders, $company_message);
        if (PEAR::isError($companyMail)) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}
ProductCategory.php000064400000006411150766207320010405 0ustar00<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Description of ProductCategory
 *
 * @author Nipuni
 */
class ProductCategory {
    public $id;
    public $name;
    public $image_name;
    public $queue;
    public function __construct($id) {
        if ($id) {
            $query = "SELECT `id`,`name`,`image_name`,`queue` FROM `product_category` WHERE `id`=" . $id;
            $db = new Database();
            $result = mysql_fetch_array($db->readQuery($query));
            $this->id = $result['id'];
            $this->name = $result['name'];
            $this->image_name = $result['image_name'];
            $this->queue = $result['queue'];
            return $this;
        }
    }
    public function create() {
        $query = "INSERT INTO `product_category` (`name`,`image_name`,`queue`) VALUES  ('"
                . $this->name . "','"
                . $this->image_name . "', '"
                . $this->queue . "')";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }
    public function all() {
        $query = "SELECT * FROM `product_category`";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
     public function getProductsByProductCategory($product_category) {
        $query = "SELECT * FROM `product` WHERE `product_category` = $product_category ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function update() {
        $query = "UPDATE  `product_category` SET "
                . "`name` ='" . $this->name . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }
    public function delete() {
       
       
        $this->deletePhotos();
//        unlink(Helper::getSitePath() . "upload/product_category/" . $this->image_name);
        $query = 'DELETE FROM `product_category` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }
    public function deletePhotos() {
        
        $PRODUCT = new Product(NULL);
        $allPhotos = $PRODUCT->getProductById($this->id);
        foreach ($allPhotos as $photo) {
            $IMG = $PRODUCT->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/product_category/product/" . $IMG);
          
            $PRODUCT->id = $photo["id"];
            $PRODUCT->delete();
        }
    }
}
News.php000064400000007544150766236760006225 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Offer

 *

 * @author Suharshana DsW

 */
class News {

    public $id;
    public $title;
    public $image_name;
    public $date;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name`,`date`,`short_description`,`description`,`queue` FROM `news` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];
            
            $this->date = $result['date'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `news` (`title`,`image_name`,`date`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->date . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `news` ORDER BY id DESC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `news` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`date` ='" . $this->date . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $this->deletePhotos();



        unlink(Helper::getSitePath() . "upload/news/" . $this->image_name);



        $query = 'DELETE FROM `news` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $NEWS_PHOTOS = new NewsPhoto(NULL);



        $allPhotos = $NEWS_PHOTOS->getNewsPhotosById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $NEWS_PHOTOS->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/news/gallery/" . $IMG);

            unlink(Helper::getSitePath() . "upload/news/gallery/thumb/" . $IMG);



            $NEWS_PHOTOS->id = $photo["id"];

            $NEWS_PHOTOS->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `news` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}NewsPhoto.php000064400000006265150766236770007237 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of OfferPhoto

 *

 * @author Suharshana DsW

 */
class NewsPhoto {

    public $id;
    public $news;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`news`,`image_name`,`caption`,`queue` FROM `news_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->news = $result['news'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `news_photo` (`news`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->news . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `news_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `news_photo` SET "
                . "`news` ='" . $this->news . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `news_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getNewsPhotosById($news) {



        $query = "SELECT * FROM `news_photo` WHERE `news`= $news ORDER BY queue ASC";

       

        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `news_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}Events.php000064400000010077150766237010006535 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of events

 *

 * @author Suharshana DsW

 */
class Events {

    public $id;
    public $title;
    public $image_name;
    public $date;
    public $venue;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`title`,`image_name`,`date`,`venue`,`short_description`,`description`,`queue` FROM `events` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->title = $result['title'];

            $this->image_name = $result['image_name'];
            
            $this->date = $result['date'];
            
            $this->venue = $result['venue'];

            $this->short_description = $result['short_description'];

            $this->description = $result['description'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `events` (`title`,`image_name`,`date`,`venue`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->date . "', '"
                . $this->venue . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `events` ORDER BY date DESC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `events` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`date` ='" . $this->date . "', "
                . "`venue` ='" . $this->venue . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        

        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $this->deletePhotos();



        unlink(Helper::getSitePath() . "upload/event/" . $this->image_name);



        $query = 'DELETE FROM `events` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function deletePhotos() {



        $EVENT_PHOTO = new EventsPhoto(NULL);



        $allPhotos = $EVENT_PHOTO->getEventsPhotosById($this->id);



        foreach ($allPhotos as $photo) {



            $IMG = $EVENT_PHOTO->image_name = $photo["image_name"];

            unlink(Helper::getSitePath() . "upload/event/gallery/" . $IMG);

            unlink(Helper::getSitePath() . "upload/event/gallery/thumb/" . $IMG);



            $EVENT_PHOTO->id = $photo["id"];

            $EVENT_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {

        $query = "UPDATE `events` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}EventsPhoto.php000064400000006646150766237030007560 0ustar00<?php

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

/**

 * Description of Activities_photo

 *

 * @author Suharshana DsW

 */
class EventsPhoto {

    public $id;
    public $events;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {

        if ($id) {



            $query = "SELECT `id`,`events`,`image_name`,`caption`,`queue` FROM `events_photo` WHERE `id`=" . $id;



            $db = new Database();



            $result = mysql_fetch_array($db->readQuery($query));



            $this->id = $result['id'];

            $this->events = $result['events'];

            $this->image_name = $result['image_name'];

            $this->caption = $result['caption'];

            $this->queue = $result['queue'];



            return $this;
        }
    }

    public function create() {



        $query = "INSERT INTO `events_photo` (`events`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->events . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            $last_id = mysql_insert_id();



            return $this->__construct($last_id);
        } else {

            return FALSE;
        }
    }

    public function all() {



        $query = "SELECT * FROM `events_photo` ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }



        return $array_res;
    }

    public function update() {



        $query = "UPDATE  `events_photo` SET "
                . "`events` ='" . $this->events . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";



        $db = new Database();



        $result = $db->readQuery($query);



        if ($result) {

            return $this->__construct($this->id);
        } else {

            return FALSE;
        }
    }

    public function delete() {



        $query = 'DELETE FROM `events_photo` WHERE id="' . $this->id . '"';



        $db = new Database();



        return $db->readQuery($query);
    }

    public function getEventsPhotosById($events) {



        $query = "SELECT * FROM `events_photo` WHERE `events`= $events ORDER BY queue ASC";



        $db = new Database();



        $result = $db->readQuery($query);

        $array_res = array();



        while ($row = mysql_fetch_array($result)) {

            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function arrange($key, $img) {

        $query = "UPDATE `events_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        return $result;
    }

}ProductTypePhotos.php000064400000006457150766244720010765 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ProductTypePhotos
 *
 * @author sublime
 */
class ProductTypePhotos {
     public $id;
    public $type;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`type`,`image_name`,`caption`,`queue` FROM `product_type_photos` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->type = $result['type'];
            $this->image_name = $result['image_name'];
            $this->caption = $result['caption'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `product_type_photos` (`type`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->type . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `product_type_photos` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `product_type_photos` SET "
                . "`type` ='" . $this->type . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `product_type_photos` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getProductTypePhotosById($type) {

        $query = "SELECT * FROM `product_type_photos` WHERE `type`= $type ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `product_type_photos` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}
Invoice.php000064400000007161150766357530006677 0ustar00<?php

/**
 * Description of Invoice
 *
 * @author sublime
 */
class Invoice {

    public $id;
    public $date;
    public $created_at;
    public $customer;
    public $customer_address;
    public $customer_phone;
    public $function_date;
    public $number_of_pax;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT "
                    . "`id`,"
                    . "`date`,"
                    . "`created_at`,"
                    . "`customer`,"
                    . "`customer_address`,"
                    . "`customer_phone`,"
                    . "`function_date`,"
                    . "`number_of_pax`"
                    . " FROM "
                    . "`invoice`"
                    . " WHERE "
                    . "`id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->date = $result['date'];
            $this->created_at = $result['created_at'];
            $this->customer = $result['customer'];
            $this->customer_address = $result['customer_address'];
            $this->customer_phone = $result['customer_phone'];
            $this->function_date = $result['function_date'];
            $this->number_of_pax = $result['number_of_pax'];

            return $result;
        }
    }

    public function create() {

        $query = "INSERT INTO `invoice` ("
                . "date, "
                . "created_at, "
                . "customer, "
                . "customer_address, "
                . "customer_phone, "
                . "function_date, "
                . "number_of_pax"
                . ") VALUES  ("
                . "'" . $this->date . "',"
                . " '" . $this->created_at . "',"
                . " '" . $this->customer . "',"
                . " '" . $this->customer_address . "',"
                . " '" . $this->customer_phone . "',"
                . " '" . $this->function_date . "',"
                . " '" . $this->number_of_pax . "'"
                . ")";

        $db = new Database();

        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `invoice`";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function filter($date_from, $date_to, $invoice) {


        $w = array();
        $where = '';

        if (!empty($date_from)) {
            if (!empty($date_from) && !empty($date_to)) {
                $w[] = "`date` BETWEEN '" . $date_from . "' AND '" . $date_to . "' ";
            } else {
                $w[] = "`date` = '" . $date_from . "'";
            }
        }

        if (!empty($invoice)) {
            $w[] = "`id` = '" . $invoice . "'";
        }

        if (count($w)) {
            $where = 'WHERE ' . implode(' AND ', $w);
        }

        $query = "SELECT * FROM `invoice` " . $where . " ORDER BY `id` ASC";

        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

}
InvoiceItem.php000064400000004425150766357530007516 0ustar00<?php

/**
 * Description of Invoice
 *
 * @author sublime
 */
class InvoiceItem {

    public $id;
    public $invoice;
    public $description;
    public $amount;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT "
                    . "`id`,"
                    . "`invoice`,"
                    . "`description`,"
                    . "`amount`"
                    . " FROM "
                    . "`invoice_item`"
                    . " WHERE "
                    . "`id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->invoice = $result['invoice'];
            $this->description = $result['description'];
            $this->amount = $result['amount'];

            return $result;
        }
    }

    public function create() {

        $query = "INSERT INTO `invoice_item` ("
                . "invoice, "
                . "description, "
                . "amount"
                . ") VALUES  ("
                . "'" . $this->invoice . "',"
                . " '" . $this->description . "',"
                . " '" . $this->amount . "'"
                . ")";

        $db = new Database();

        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function getAllByInvoice() {

        $query = "SELECT * FROM `invoice_item` WHERE `invoice`= '" . $this->invoice . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function getTotalByInvoice() {

        $query = "SELECT * FROM `invoice_item` WHERE `invoice`= '" . $this->invoice . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        $total = 0;

        while ($row = mysql_fetch_array($result)) {

            $total = $total + $row['amount'];
        }

        return $total;
    }

}
Excursions.php000064400000007630150767655710007450 0ustar00<?php

/**
 * Description of excursions
 *
 * @author Suharshana DsW
 */
class Excursions {

    public $id;
    public $title;
    public $image_name;
    public $short_description;
    public $description;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`title`,`image_name`,`short_description`,`description`,`queue` FROM `excursions` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->title = $result['title'];
            $this->image_name = $result['image_name'];
            $this->short_description = $result['short_description'];
            $this->description = $result['description'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `excursions` (`title`,`image_name`,`short_description`,`description`,`queue`) VALUES  ('"
                . $this->title . "','"
                . $this->image_name . "', '"
                . $this->short_description . "', '"
                . $this->description . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `excursions` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `excursions` SET "
                . "`title` ='" . $this->title . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`short_description` ='" . $this->short_description . "', "
                . "`description` ='" . $this->description . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $this->deletePhotos();

        unlink(Helper::getSitePath() . "upload/excursion/" . $this->image_name);

        $query = 'DELETE FROM `excursions` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function deletePhotos() {

        $EXCURSION_PHOTO = new ExcursionsPhoto(NULL);

        $allPhotos = $EXCURSION_PHOTO->getExcursionsPhotosById($this->id);

        foreach ($allPhotos as $photo) {

            $IMG = $EXCURSION_PHOTO->image_name = $photo["image_name"];
            unlink(Helper::getSitePath() . "upload/excursion/gallery/" . $IMG);
            unlink(Helper::getSitePath() . "upload/excursion/gallery/thumb/" . $IMG);

            $EXCURSION_PHOTO->id = $photo["id"];
            $EXCURSION_PHOTO->delete();
        }
    }

    public function arrange($key, $img) {
        $query = "UPDATE `excursions` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

    public function getExcursionsWithoutThisID($excursions) {
        $query = "SELECT * FROM `excursions` WHERE `id`!= $excursions ORDER BY queue ASC";
        
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

}
Database_1.php000064400000003036150767655720007227 0ustar00<?php

/**
 * Description of User
 *
 * @author sublime holdings
 * @web www.sublime.lk
 **/
 
 
class Database {

    
//    private $host = 'kelum818.ipagemysql.com';
//    private $name = 'masalagewatta';
//    private $user = 'masalagewatta';
//    private $password = 'Masal@903430';
     
    private $host = 'localhost';
    private $name = 'new-admin';
    private $user = 'root';
    private $password = '';

    public function __construct() {
        mysql_connect($this->host, $this->user, $this->password) or die("Invalid host  or user details");
        mysql_select_db($this->name) or die("Unable to select database");
    }

    public function readQuery($query) {

        $result = mysql_query($query) or die(mysql_error());
        return $result;

//        $qu1 = explode(" ", $query)[0];
//
//        if ($qu1 === 'SELECT' || $qu1 === 'select') {
//            $result = mysql_query($query) or die(mysql_error());
//            return $result;
//        } else {
//            if (!isset($_SESSION)) {
//                session_start();
//            }
//
//            if (
//                    $_SESSION["LOGIN"] === true &&
//                    parse_url($_SERVER['HTTP_REFERER'])["host"] == $this->domain &&
//                    $_SESSION['TOKEN'] == 'Vr-EFV!Fn6qCCUHYF2&cFzLw_thehorizonvilla-H5Dx'
//            ) {
//
//                $result = mysql_query($query) or die(mysql_error());
//                return $result;
//            } else {
//                sendSecurityAlert($this->domain);
//            }
//        }
    }

}
ExcursionsPhoto.php000064400000006340150767655730010461 0ustar00<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Excursions_photo
 *
 * @author Suharshana DsW
 */
class ExcursionsPhoto {

    public $id;
    public $excursions;
    public $image_name;
    public $caption;
    public $queue;

    public function __construct($id) {
        if ($id) {

            $query = "SELECT `id`,`excursions`,`image_name`,`caption`,`queue` FROM `excursions_photo` WHERE `id`=" . $id;

            $db = new Database();

            $result = mysql_fetch_array($db->readQuery($query));

            $this->id = $result['id'];
            $this->excursions = $result['excursions'];
            $this->image_name = $result['image_name'];
            $this->caption = $result['caption'];
            $this->queue = $result['queue'];

            return $this;
        }
    }

    public function create() {

        $query = "INSERT INTO `excursions_photo` (`excursions`,`image_name`,`caption`,`queue`) VALUES  ('"
                . $this->excursions . "','"
                . $this->image_name . "', '"
                . $this->caption . "', '"
                . $this->queue . "')";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            $last_id = mysql_insert_id();

            return $this->__construct($last_id);
        } else {
            return FALSE;
        }
    }

    public function all() {

        $query = "SELECT * FROM `excursions_photo` ORDER BY queue ASC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }

        return $array_res;
    }

    public function update() {

        $query = "UPDATE  `excursions_photo` SET "
                . "`excursions` ='" . $this->excursions . "', "
                . "`image_name` ='" . $this->image_name . "', "
                . "`caption` ='" . $this->caption . "', "
                . "`queue` ='" . $this->queue . "' "
                . "WHERE `id` = '" . $this->id . "'";

        $db = new Database();

        $result = $db->readQuery($query);

        if ($result) {
            return $this->__construct($this->id);
        } else {
            return FALSE;
        }
    }

    public function delete() {

        $query = 'DELETE FROM `excursions_photo` WHERE id="' . $this->id . '"';

        $db = new Database();

        return $db->readQuery($query);
    }

    public function getExcursionsPhotosById($excursions) {

        $query = "SELECT * FROM `excursions_photo` WHERE `excursions`= $excursions ORDER BY queue ASC";

        $db = new Database();

        $result = $db->readQuery($query);
        $array_res = array();

        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    public function arrange($key, $img) {
        $query = "UPDATE `excursions_photo` SET `queue` = '" . $key . "'  WHERE id = '" . $img . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        return $result;
    }

}resize-class.php000064400000015331150767745760007714 0ustar00<?php

Class resize {

    // *** Class variables
    private $image;
    private $width;
    private $height;
    private $imageResized;

    function __construct($fileName) {
        // *** Open up the file 
        $this->image = $this->openImage($fileName);

        // *** Get width and height
        $this->width = imagesx($this->image);
        $this->height = imagesy($this->image);
    }

    private function openImage($file) {
        // *** Get extension
        $extension = strtolower(strrchr($file, '.'));

        switch ($extension) {
            case '.jpg':
            case '.jpeg':
                $img = @imagecreatefromjpeg($file);
                break;
            case '.gif':
                $img = @imagecreatefromgif($file);
                break;
            case '.png':
                $img = @imagecreatefrompng($file);
                break;
            default:
                $img = false;
                break;
        }
        return $img;
    }

    public function resizeImage($newWidth, $newHeight, $option = "auto") {

        // *** Get optimal width and height - based on $option
        $optionArray = $this->getDimensions($newWidth, $newHeight, strtolower($option));

        $optimalWidth = $optionArray['optimalWidth'];
        $optimalHeight = $optionArray['optimalHeight'];

        // *** Resample - create image canvas of x, y size
        $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
        imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);

        // *** if option is 'crop', then crop too
        if ($option == 'crop') {
            $this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight);
        }
    }

    private function getDimensions($newWidth, $newHeight, $option) {

        switch ($option) {
            case 'exact':
                $optimalWidth = $newWidth;
                $optimalHeight = $newHeight;
                break;
            case 'portrait':
                $optimalWidth = $this->getSizeByFixedHeight($newHeight);
                $optimalHeight = $newHeight;
                break;
            case 'landscape':
                $optimalWidth = $newWidth;
                $optimalHeight = $this->getSizeByFixedWidth($newWidth);
                break;
            case 'auto':
                $optionArray = $this->getSizeByAuto($newWidth, $newHeight);
                $optimalWidth = $optionArray['optimalWidth'];
                $optimalHeight = $optionArray['optimalHeight'];
                break;
            case 'crop':
                $optionArray = $this->getOptimalCrop($newWidth, $newHeight);
                $optimalWidth = $optionArray['optimalWidth'];
                $optimalHeight = $optionArray['optimalHeight'];
                break;
        }
        return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
    }

    private function getSizeByFixedHeight($newHeight) {
        $ratio = $this->width / $this->height;
        $newWidth = $newHeight * $ratio;
        return $newWidth;
    }

    private function getSizeByFixedWidth($newWidth) {
        $ratio = $this->height / $this->width;
        $newHeight = $newWidth * $ratio;
        return $newHeight;
    }

    private function getSizeByAuto($newWidth, $newHeight) {
        if ($this->height < $this->width) {
            // *** Image to be resized is wider (landscape)
            $optimalWidth = $newWidth;
            $optimalHeight = $this->getSizeByFixedWidth($newWidth);
        } elseif ($this->height > $this->width) {
            // *** Image to be resized is taller (portrait)
            $optimalWidth = $this->getSizeByFixedHeight($newHeight);
            $optimalHeight = $newHeight;
        } else {
            // *** Image to be resizerd is a square
            if ($newHeight < $newWidth) {
                $optimalWidth = $newWidth;
                $optimalHeight = $this->getSizeByFixedWidth($newWidth);
            } else if ($newHeight > $newWidth) {
                $optimalWidth = $this->getSizeByFixedHeight($newHeight);
                $optimalHeight = $newHeight;
            } else {
                // *** Sqaure being resized to a square
                $optimalWidth = $newWidth;
                $optimalHeight = $newHeight;
            }
        }

        return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
    }

    private function getOptimalCrop($newWidth, $newHeight) {

        $heightRatio = $this->height / $newHeight;
        $widthRatio = $this->width / $newWidth;

        if ($heightRatio < $widthRatio) {
            $optimalRatio = $heightRatio;
        } else {
            $optimalRatio = $widthRatio;
        }

        $optimalHeight = $this->height / $optimalRatio;
        $optimalWidth = $this->width / $optimalRatio;

        return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
    }

    private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight) {
        // *** Find center - this will be used for the crop
        $cropStartX = ( $optimalWidth / 2) - ( $newWidth / 2 );
        $cropStartY = ( $optimalHeight / 2) - ( $newHeight / 2 );

        $crop = $this->imageResized;
        //imagedestroy($this->imageResized);
        // *** Now crop from center to exact requested size
        $this->imageResized = imagecreatetruecolor($newWidth, $newHeight);
        imagecopyresampled($this->imageResized, $crop, 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight, $newWidth, $newHeight);
    }

    public function saveImage($savePath, $imageQuality = "100") {
        // *** Get extension
        $extension = strrchr($savePath, '.');
        $extension = strtolower($extension);

        switch ($extension) {
            case '.jpg':
            case '.jpeg':
                if (imagetypes() & IMG_JPG) {
                    imagejpeg($this->imageResized, $savePath, $imageQuality);
                }
                break;

            case '.gif':
                if (imagetypes() & IMG_GIF) {
                    imagegif($this->imageResized, $savePath);
                }
                break;

            case '.png':
                // *** Scale quality from 0-100 to 0-9
                $scaleQuality = round(($imageQuality / 100) * 9);

                // *** Invert quality setting as 0 is best, not 9
                $invertScaleQuality = 9 - $scaleQuality;

                if (imagetypes() & IMG_PNG) {
                    imagepng($this->imageResized, $savePath, $invertScaleQuality);
                }
                break;

            // ... etc

            default:
                // *** No extension - No save.
                break;
        }

        imagedestroy($this->imageResized);
    }

}