Example #1
0
 public function __construct()
 {
     $operation = new UniversalConnect();
     $this->hookup = $operation->doConnect();
     $res = "SHOW TABLES LIKE {$this->tableMaster}";
     if (!$this->hookup->query($res)) {
         $sql = "CREATE TABLE {$this->tableMaster} (uname NVARCHAR(15),\npw NVARCHAR(120))";
     }
     if ($this->hookup->query($sql) === true) {
         printf("Tabela {$this->tableMaster} została utworzona.<br/> \n");
     }
     $this->hookup->close();
 }
Example #2
0
 public function __construct()
 {
     $operation = new UniversalConnect();
     $this->hookup = $operation->doConnect();
     $drop = "DROP TABLE IF EXISTS {$this->tableMaster}";
     if ($this->hookup->query($drop) === true) {
         printf("Stara tabela {$this->tableMaster} została usunięta<br>");
     }
     $sql = "CREATE TABLE {$this->tableMaster} (uname NVARCHAR(15),\n                pw NVARCHAR(120))";
     if ($this->hookup->query($sql) === true) {
         printf("Tabela {$this->tableMaster} zostala utworzona <br>");
     }
     $this->hookup->close();
 }
Example #3
0
 public function login($uNow, $pNow)
 {
     $uname = $uNow;
     $pw = md5($pNow);
     $this->logGood = false;
     $this->tableMaster = "proxyLog";
     $this->hookup = UniversalConnect::doConnect();
     $sql = "SELECT uname, pw FROM {$this->tableMaster} WHERE uname='{$uname}'";
     if ($result = $this->hookup->query($sql)) {
         $row = $result->fetch_array(MYSQL_ASSOC);
         if ($row['pw'] == $pw) {
             $this->logGood = true;
         }
         $result->close();
     } elseif (($result = $this->hookup->query($sql)) === false) {
         printf("Błąd: %s <br>", $this->hookup->error);
         exit;
     }
     $this->hookup->close();
     if ($this->logGood) {
         $this->request();
     } else {
         echo "Podane dane są nieprawidłowe";
     }
 }
 public function algorithm(array $dataPack)
 {
     $this->tableMaster = IStrategy::TABLENOW;
     $this->hookup = UniversalConnect::doConnect();
     //Create Query Statement
     $sql = "SELECT * FROM {$this->tableMaster}";
     //Conditional statement in MySQL command
     if ($result = $this->hookup->query($sql)) {
         printf("Select returned %d rows.<p />", $result->num_rows);
         echo "<link rel='stylesheet' href='main.css'>";
         echo "<table>";
         while ($finfo = mysqli_fetch_field($result)) {
             echo "<th>&nbsp;{$finfo->name}</th>";
         }
         echo "</tr>\n";
         while ($row = mysqli_fetch_row($result)) {
             echo "<tr >";
             foreach ($row as $cell) {
                 echo "<td >{$cell}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
         $result->close();
     }
     $this->hookup->close();
 }
    public function giveProduct()
    {
        $this->return .= <<<HTML
                <div id="currencyHistoryBoard" class="card">
                <table style="width:100%">
                    <tr class="blue">
                        <th class="center">Currency</th>
                        <th class="center">Time</th>
                        <th class="center">Bid Rate</th>
                        <th class="center">Offer Rate</th>
                    </tr>
HTML;
        $db = UniversalConnect::doConnect();
        $query = "SELECT starttime FROM startendtime LIMIT 1";
        $result = $db->query($query);
        $row = $result->fetch_assoc();
        $startTime = $row["starttime"];
        $query = "SELECT currency.shortname, valuechanges.newbuyvalue, valuechanges.newsellvalue, valuechanges.time FROM valuechanges INNER JOIN currency ON valuechanges.currencyid = currency.currencyid WHERE valuechanges.yetcompleted=0 ORDER BY valuechanges.time DESC";
        $result = $db->query($query) or die($db->error);
        while ($row = $result->fetch_assoc()) {
            $this->return .= "<tr>";
            $this->return .= "<td class=\"center\">" . $row["shortname"] . "</td>";
            $this->return .= "<td class=\"center\">" . FormatTimePassed::format($row["time"] + $startTime) . "</td>";
            $this->return .= "<td class=\"center\">" . number_format($row["newbuyvalue"], 2) . "</td>";
            $this->return .= "<td class=\"center\">" . number_format($row["newsellvalue"], 2) . "</td>";
            $this->return .= "</tr>";
        }
        $this->return .= "</table></div>";
        return $this->return;
    }
Example #6
0
 public static function open()
 {
     if (empty(self::$conn)) {
         self::$conn = UniversalConnect::open();
         self::$conn->beginTransaction();
     }
 }
Example #7
0
 public function login($uNow, $pNow)
 {
     $uname = $uNow;
     $pw = md5($pNow);
     $this->logGood = false;
     $this->tableMaster = "proxyLog";
     $this->hookup = UniversalConnect::doConnect();
     $sql = "SELECT pw FROM {$this->tableMaster} WHERE uname='{$uname}'";
     if ($result = $this->hookup->query($sql)) {
         $row = $result->fetch_array(MYSQLI_ASSOC);
         if ($row['pw'] == $pw) {
             $this->logGood = true;
         }
         $result->close();
     } elseif (($result = $this->hookup->query($sql)) === false) {
         printf("Failed %s <br> ", $this->hookup->error);
         exit;
     }
     $this->hookup->close();
     if ($this->logGood) {
         $this->request();
     } else {
         echo "Username or password not on record.";
     }
 }
 public function authenticate($username = null, $password = null)
 {
     if (is_null($username) || is_null($password)) {
         return false;
     }
     $db = UniversalConnect::doConnect();
     $usernameToCheck = $db->real_escape_string(trim($username));
     $passwordToCheck = $db->real_escape_string(trim($password));
     $query = "SELECT userkey, password, usertype FROM users WHERE userid=\"{$usernameToCheck}\" LIMIT 1";
     $result = $db->query($query) or die($db->error . $query);
     if ($result->num_rows < 1) {
         return false;
     }
     while ($row = $result->fetch_assoc()) {
         if (password_verify($passwordToCheck, $row["password"])) {
             if (password_needs_rehash($row["password"], PASSWORD_DEFAULT)) {
                 $newHash = password_hash($passwordToCheck, PASSWORD_DEFAULT);
                 $query = "UPDATE users SET password=\"{$newHash}\" WHERE userkey=" . $row["userkey"];
                 $db->query($query);
             }
             return true;
         } else {
             return false;
         }
     }
 }
 public function algorithm(array $dataPack)
 {
     $this->tableMaster = IStrategy::TABLENOW;
     $this->hookup = UniversalConnect::doConnect();
     $this->dataPack = $dataPack;
     $field = $this->dataPack[0];
     $term = $this->dataPack[1];
     $this->sql = "SELECT * FROM {$this->tableMaster} WHERE {$field}='{$term}'";
     //Conditional statement in MySQL query for data output
     $ret = $this->hookup->query($this->sql);
     if ($result = $this->hookup->query($this->sql)) {
         echo "<link rel='stylesheet' href='main.css'>";
         echo "<table>";
         while ($row = mysqli_fetch_row($result)) {
             echo "<tr>";
             foreach ($row as $cell) {
                 echo "<td>{$cell}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
         $result->close();
     }
     $this->hookup->close();
     return $ret;
 }
Example #10
0
 public function removeRecord()
 {
     $this->hookup = UniversalConnect::doConnect();
     $this->disappear = $this->hookup->real_escape_string($_POST['delete']);
     $this->dataPack = array($this->disappear);
     $this->hookup->close();
 }
 public function __construct($directoryLayer)
 {
     if (session_status() === PHP_SESSION_NONE) {
         session_start();
     }
     $this->pathToRoot = GenerateRootPath::getRoot($directoryLayer);
     $userkey = intval($_SESSION["userkey"]);
     $db = UniversalConnect::doConnect();
     $query = "SELECT name, networth FROM users WHERE userkey={$userkey} LIMIT 1";
     $result = $db->query($query) or die;
     if ($row = $result->fetch_assoc()) {
         $this->name = $row["name"];
         $this->marketValue = $row["networth"];
     }
     $query = "SELECT amount FROM wallet WHERE userkey={$userkey} AND currencyid=1 LIMIT 1";
     $result = $db->query($query) or die;
     if ($row = $result->fetch_assoc()) {
         $this->netPosition = $row["amount"] - 10000000;
     }
     $query = "SELECT transid FROM transactions WHERE userkey={$userkey} AND (transtype=0 OR transtype=1)";
     $result = $db->query($query) or die;
     $this->transactionCount = $result->num_rows;
     $this->basecurr = new BaseCurrency();
     $this->return = "";
     $db->close();
 }
Example #12
0
 public function __construct()
 {
     $this->tableMaster = "proxyLog";
     $this->hookup = UniversalConnect::doConnect();
     $this->un = $this->un = $this->hookup->real_escape_string(trim($_POST['uname']));
     $this->pw = $this->un = $this->hookup->real_escape_string(trim($_POST['pw']));
     $this->getIface($this->proxy = new Proxy());
 }
Example #13
0
 public function query($query)
 {
     die("primera");
     self::$hookup = mysqli_connect(self::$server, self::$user, self::$pass, self::$currentDB);
     $result = mysqli_query(self::$hookup, $query);
     var_dump($result);
     die("aqui");
 }
 public function executeStrategy()
 {
     //Get table name and make connection
     $this->tableMaster = IAdminStrat::ULTRA;
     $this->hookup = UniversalConnect::doConnect();
     $this->displayAll();
     $this->hookup->close();
 }
Example #15
0
 public function __construct()
 {
     $this->hookup = UniversalConnect::doConnect();
     $this->tableMaster = "your_table_name";
     $this->dropTable();
     $this->makeTable();
     $this->hookup->close();
 }
Example #16
0
 public function doConnect()
 {
     self::$hookup = mysqli_connect(self::$server, self::$user, self::$pass, self::$currentDB, self::$port);
     if (self::$hookup) {
     } elseif (mysqli_connect_error(self::$hookup)) {
         echo 'Oto blad: ' . mysqli_connect_error();
     }
     return self::$hookup;
 }
 public function __construct()
 {
     try {
         $this->test = UniversalConnect::doConnect();
         mysqli_set_charset($this->test, 'utf8');
         //echo "You're hooked up, Ace!<br/>";
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Example #18
0
 public function doConnect()
 {
     self::$hookup = mysqli_connect(self::$server, self::$user, self::$pass, self::$currentDB);
     if (self::$hookup) {
         echo "successfull connection to MySQL<br>";
     } elseif (mysqli_connect_error(self::$hookup)) {
         echo "Here is why it failed: " . mysqli_connect_error();
     }
     return self::$hookup;
 }
 public static function doConnect()
 {
     self::$hookup = mysqli_connect(self::$server, self::$user, self::$pass, self::$currentDB);
     if (self::$hookup) {
         //echo "Successful connection to MySQL:<p/>";
     } elseif (mysqli_connect_error(self::$hookup)) {
         echo 'Here is why it failed: ' . mysqli_connect_error();
     }
     return self::$hookup;
 }
Example #20
0
 public function __construct()
 {
     $this->tableMaster = "survey";
     $this->hookup = UniversalConnect::doConnect();
     $sql = "CREATE TABLE IF NOT EXISTS {$this->tableMaster} (\n                id          SERIAL,\n                company     NVARCHAR(40),\n                devdes      NVARCHAR(12),\n                lang        NVARCHAR(15),\n                plat        NVARCHAR(15),\n                style       NVARCHAR(20),\n                device      NVARCHAR(12),\n                PRIMARY KEY (id))";
     if ($this->hookup->query($sql) === true) {
         printf("Tabela {$this->tableMaster} zostala utworzona <br>");
     }
     $this->hookup->close();
 }
 public function executeStrategy()
 {
     //Get table name and make connection
     $this->tableMaster = IAdminStrat::ULTRA;
     $this->hookup = UniversalConnect::doConnect();
     $this->getLastRecord();
     $this->page = $this->getPage();
     $this->hookup->close();
     return $this->page;
 }
Example #22
0
 public function __construct()
 {
     $this->tableMaster = "helpdesk";
     $this->hookup = UniversalConnect::doConnect();
     $sql = "CREATE TABLE IF NOT EXISTS {$this->tableMaster} (\n                id          INT NOT NULL AUTO_INCREMENT,\n                chain       VARCHAR(3),\n                response    TEXT,\n                PRIMARY KEY (id))";
     if ($this->hookup->query($sql) === true) {
         printf("Tabela {$this->tableMaster} zostala utworzona <br>");
     }
     $this->hookup->close();
 }
    public function giveProduct()
    {
        $this->return .= <<<HTML
                <div id="leaderboard" class="card">
                <table style="width:100%">
                    <tr class="blue">
                        <th class="center">Rank</th>
                        <th class="center">Name</th>
                        <th class="center">
HTML;
        $this->return .= "Mark-to-Market Value ";
        $this->return .= "(" . $this->basecurr->getShortName() . ")</th></tr>";
        $db = UniversalConnect::doConnect();
        $query = "SELECT name, networth FROM users WHERE usertype=1 ORDER BY networth DESC";
        $result = $db->query($query) or die($db->error);
        $number = 1;
        $tietally = 0;
        $previousNetWorth = -PHP_INT_MAX;
        while ($row = $result->fetch_assoc()) {
            $this->return .= "<tr>";
            if ($row["networth"] == $previousNetWorth) {
                $number--;
                $this->return .= "<td class=\"center\">" . $number . "</td>";
                $tietally++;
                $this->return .= "<td class=\"center\">" . $row["name"] . "</td>";
                //if($gameEnded)
                $this->return .= "<td class=\"center\">" . number_format($row["networth"], 2) . "</td>";
                //else
                //    $this->return .= "<td class=\"center\">".number_format($row["networth"], 2)."</td>";
            } else {
                if ($tietally != 0) {
                    $number += $tietally;
                    $this->return .= "<td class=\"center\">" . $number . "</td>";
                    $tietally = 0;
                    $this->return .= "<td class=\"center\">" . $row["name"] . "</td>";
                    //if($gameEnded)
                    $this->return .= "<td class=\"center\">" . number_format($row["networth"], 2) . "</td>";
                    //else
                    //    $this->return .= "<td class=\"center\">".number_format($row["networth"], 2)."</td>";
                } else {
                    $this->return .= "<td class=\"center\">" . $number . "</td>";
                    $this->return .= "<td class=\"center\">" . $row["name"] . "</td>";
                    //if($gameEnded)
                    $this->return .= "<td class=\"center\">" . number_format($row["networth"], 2) . "</td>";
                    //else
                    //    $this->return .= "<td class=\"center\">".number_format($row["networth"], 2)."</td>";
                }
            }
            $number++;
            $previousNetWorth = $row["networth"];
            $this->return .= "</tr>";
        }
        $this->return .= "</table></div>";
        return $this->return;
    }
 public function __construct()
 {
     //Get table name and make connection
     $this->tableMaster = "Addresses";
     $this->hookup = UniversalConnect::doConnect();
     //Get data from HTML form
     $this->id = $_POST['id'];
     //Call private methods for MySql operations
     $this->doDelete();
     $this->hookup->close();
 }
Example #25
0
 private function updateData()
 {
     $this->hookup = UniversalConnect::doConnect();
     $this->sql = "UPDATE  {$this->tableMaster}\n\t\t\t\tSET topic='{$this->topic}',\n\t\t\t\theader='{$this->header}',\n\t\t\t\tgraphic='{$this->graphic}',\n\t\t\t\tstory='{$this->story}'\n\t\t\t\tWHERE id='{$this->id}'";
     try {
         $this->hookup->query($this->sql);
         printf("Story with topic, %s and header %s and %s graphic has been updated in table, %s :", $this->topic, $this->header, $this->graphic, $this->tableMaster);
     } catch (Exception $e) {
         echo "There is a problem: " . $e->getMessage();
         exit;
     }
 }
 private function enterData()
 {
     $this->tableMaster = IAdminStrat::ULTRA;
     $this->hookup = UniversalConnect::doConnect();
     $this->sql = "INSERT INTO {$this->tableMaster} (topic,header,graphic,story)\n\t\t\t\t\t  VALUES ('{$this->topic}','{$this->header}', '{$this->graphic}','{$this->story}')";
     try {
         $this->hookup->query($this->sql);
         printf("Story with topic, %s and header %s and %s graphic has been entered into table, %s :", $this->topic, $this->header, $this->graphic, $this->tableMaster);
     } catch (Exception $e) {
         echo "There is a problem: " . $e->getMessage();
         exit;
     }
 }
 public function authenticate()
 {
     $db = UniversalConnect::doConnect();
     date_default_timezone_set('Asia/Singapore');
     $query = "SELECT starttime FROM startendtime WHERE timeid = 1 LIMIT 1";
     $result = $db->query($query);
     $row = $result->fetch_assoc();
     if (time() < $row["starttime"]) {
         return false;
     } else {
         return true;
     }
 }
 public static function doConnect()
 {
     self::$hookup = mysqli_connect(self::$server, self::$user, self::$pass, self::$currentDB);
     try {
         self::$hookup;
         //Uncomment following line for develop/debug
         echo "Successful MySql connection:<br />";
     } catch (Exception $e) {
         echo "There is a problem: " . $e->getMessage();
         exit;
     }
     return self::$hookup;
 }
    public function giveProduct()
    {
        if (session_status() === PHP_SESSION_NONE) {
            session_start();
        }
        $userkey = intval($_SESSION["userkey"]);
        $db = UniversalConnect::doConnect();
        $this->return .= <<<HTML
<div id="currencyHistoryBoard" class="card">
            <table style="width:100%">
                    <tr class="blue center">
                        <th>No.</th>
                        <th>Time</th>
                        <th>Transaction Type</th>
                        <th>Rate Transacted</th>
                        <th>Amount Sold</th>
                        <th>Amount Received</th>
                    </tr>
HTML;
        $query = "SELECT transactions.transtype, currency.shortname, transactions.amount, transactions.rate, transactions.receiveamt, transactions.time FROM transactions INNER JOIN currency ON currency.currencyid = transactions.currencyid WHERE transactions.userkey = {$userkey} ORDER BY time DESC";
        $result = $db->query($query) or die($db->error);
        $count = 1;
        if ($result->num_rows <= 0) {
            $this->return .= "<tr><td class=\"center\" colspan=\"6\">No previous transactions found.</td></tr>";
        } else {
            while ($row = $result->fetch_assoc()) {
                $this->return .= "<tr class=\"center\">";
                if (intval($row["transtype"]) === 0) {
                    $newcurrname = $row["shortname"];
                    $this->return .= "<td>{$count}</td>";
                    $this->return .= "<td>" . FormatTimePassed::format($row["time"]) . "</td>";
                    $this->return .= "<td>" . $this->baseCurrency->getShortName() . " to {$newcurrname} (Sell)</td>";
                    $this->return .= "<td>" . $row["rate"] . "</td>";
                    $this->return .= "<td>" . $this->baseCurrency->getShortName() . number_format($row["amount"], 2) . "</td>";
                    $this->return .= "<td>{$newcurrname}" . number_format($row["receiveamt"], 2) . "</td>";
                } else {
                    $newcurrname = $row["shortname"];
                    $this->return .= "<td>{$count}</td>";
                    $this->return .= "<td>" . FormatTimePassed::format($row["time"]) . "</td>";
                    $this->return .= "<td>{$newcurrname} to " . $this->baseCurrency->getShortName() . " (Buy)</td>";
                    $this->return .= "<td>" . $row["rate"] . "</td>";
                    $this->return .= "<td>{$newcurrname}" . number_format($row["amount"]) . "</td>";
                    $this->return .= "<td>" . $this->baseCurrency->getShortName() . number_format($row["receiveamt"]) . "</td>";
                }
                $count++;
                $this->return .= "</tr>";
            }
        }
        $this->return .= "</table></div>";
        return $this->return;
    }
 public function gameEnded()
 {
     date_default_timezone_set('Asia/Singapore');
     $db = UniversalConnect::doConnect();
     $query = "SELECT endtime FROM startendtime WHERE timeid=1 LIMIT 1";
     $result = $db->query($query);
     // or die($db->error);
     $row = $result->fetch_assoc();
     if ($row["endtime"] < time()) {
         return true;
     } else {
         return false;
     }
 }