示例#1
0
function RemoveAuction($config, $jsonResult)
{
    $id = $_GET['auction_id'];
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    $conn->query("DELETE FROM allegro where auction_id='" . $id . "';");
}
示例#2
0
function AddProduct($config, $jsonResult)
{
    $cargo_id = $_GET["cargo_id"];
    $kind_id = "";
    $kind = $_GET["kind"];
    $amount = $_GET["amount"];
    $sql1 = "SELECT COUNT(name) as kind_amount , kind_id FROM kind WHERE name = '" . $kind . "';";
    $sql2 = "INSERT INTO kind(name) VALUES('" . $kind . "')";
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $result1 = $conn->query($sql1);
        foreach ($result1 as $row) {
            if ($row['kind_amount'] === "0") {
                $conn->query($sql2);
                $kind_id = $conn->conn->lastInsertId();
            } else {
                $kind_id = $row['kind_id'];
            }
        }
        $conn->query("INSERT INTO product(cargo_id , amount , kind_id) VALUES(" . $cargo_id . " , " . $amount . " , " . $kind_id . ")");
        $product_id = $conn->conn->lastInsertId();
        $jsonResult->json_data['result_data'] = $product_id;
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
示例#3
0
 public static function fetchOne($sql)
 {
     $con = new connection();
     $con->execute($sql);
     $con->fetch();
     return $con->rows;
 }
示例#4
0
 function the_cat($by_name = null, $linked = null)
 {
     if ($this->is_object()) {
         if (!empty($this->cat)) {
             // Gibt die ID der Kategorie zurück
             if (null == $by_name) {
                 return $this->cat;
                 // Gibt den Titel der Kategorie zurück
             } else {
                 $db = new connection();
                 $get_the_catname = $db->query('SELECT * FROM object WHERE id=' . $this->cat);
                 $the_catname = $db->fetch_array();
                 if (null !== $linked) {
                     // Kategorie wird als Link ausgegeben
                     return '<a href="./?cat=' . $the_catname['id'] . '" rel="nofollow">' . $the_catname['title'] . '</a> ';
                 } else {
                     // Kategorie wird nicht als Link ausgegeben
                     return $the_catname['title'] . " ";
                 }
             }
         } else {
             return false;
         }
     }
 }
示例#5
0
    function has_items($id)
    {
        $db = new connection();
        $db->query('SELECT * FROM object WHERE type="page" AND status=1 AND parent_id=' . $id);
        if ($this->has_child($id)) {
            ?>
<ul class="submenu">
<?php 
        }
        while ($result = $db->fetch_array()) {
            ?>
<li><a href='./?page_id=<?php 
            echo $result['id'];
            ?>
'><?php 
            echo $result['menu_title'];
            ?>
</a>
<?php 
            if ($this->has_items($result['id'])) {
                echo $this->has_items($result['id']);
            }
            ?>
</li>
<?php 
        }
        if ($this->has_child($id)) {
            ?>
</ul>
<?php 
        }
    }
 public static function getRowCount()
 {
     $con = new connection();
     $connection = $con->getConnection();
     $query = "select * from manufacturer";
     $result = $connection->query($query) or die(mysqli_error($connection));
     return mysqli_num_rows($result) + 10;
 }
示例#7
0
function dateExists()
{
    $date = date('Y-m-d', strtotime($_GET['date']));
    $sql = "SELECT COUNT(*) AS count FROM ipodate WHERE ipodate = '" . mysql_escape_string($date) . "'";
    $con = new connection();
    $con->execute($sql);
    die($con->fetch());
}
示例#8
0
 public function uploadFile($uploadclassObj)
 {
     $fileid = $uploadclassObj->getFileid();
     $upload_filename = $uploadclassObj->getFilename();
     $con = new connection();
     $connection = $con->getConnection();
     $query = "insert into uploads values(null, '{$fileid}', '{$upload_filename}')";
     $result = $connection->query($query) or die(mysqli_error($connection));
 }
示例#9
0
 public function getUserByName($name)
 {
     $con = new connection();
     $db = $con->getConnection();
     $sql = "SELECT * FROM user WHERE name=" . $name;
     foreach ($db->query($sql) as $row) {
         $user[] = array('id' => $row['id'], 'name' => $row['name'], 'password' => $row['password'], 'mail' => $row['mail'], 'adresse' => $row['adresse'], 'tel' => $row['tel']);
     }
 }
示例#10
0
function GetAuctionList($config, $jsonResult)
{
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    $result = $conn->query("SELECT auction_id , name , sandbox FROM allegro;");
    foreach ($result as $row) {
        array_push($jsonResult->json_data['result_data'], array('id' => $row['auction_id'], 'name' => $row['name'], 'sandbox' => $row['sandbox']));
    }
}
示例#11
0
function GetCargoName($config, $jsonResult)
{
    $cargo_id = $_GET['cargo_id'];
    $conn = new connection($config);
    $result = $conn->query("SELECT name FROM cargo WHERE cargo_id = " . $cargo_id . ";");
    foreach ($result as $row) {
        array_push($jsonResult->json_data["result_data"], $row['name']);
    }
    $jsonResult->json_data["result_code"] = JSON::$resultCodes['ok'];
}
示例#12
0
function AddCargo($config, $jsonResult)
{
    $name = $_GET['name'];
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $conn->query("INSERT INTO cargo(name) VALUES('" . $name . "');");
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
示例#13
0
 function useralive($userid)
 {
     $con= new connection();
     $con->execute("select time from users where iduser='******'");
     $con->fetch();
     $time1=  $con->rows['time'];
     if ($time1<(time()-13))
     return false;
     else
     return true;
 }
示例#14
0
function getSymbols()
{
    // get the full list of IPOs in the database
    $sql = "SELECT DISTINCT symbol FROM ipo";
    $con = new connection();
    $con->execute($sql);
    $symbols = array();
    while ($con->fetch()) {
        $symbols[] = $con->rows["symbol"];
    }
    return $symbols;
}
示例#15
0
function getCargoListWithKinds($config, $jsonResult)
{
    $conn = new connection(new Config(null, null));
    $result = array();
    $cargoes = $conn->query("SELECT * FROM cargo");
    foreach ($cargoes as $cargo) {
        $kinds = $conn->query("SELECT DISTINCT kind.name\n                FROM product INNER JOIN kind on product.kind_id = kind.kind_id\n                WHERE cargo_id =" . $cargo['cargo_id']);
        $kinds = $kinds->fetchAll();
        array_push($result, array('name' => $cargo['name'], 'kinds' => $kinds));
    }
    $jsonResult->json_data['result_data'] = $result;
}
示例#16
0
 public function query()
 {
     //get connection object
     $connection = new connection();
     //get query object
     $query = new query();
     //get database connection
     $pdo = $connection->connect();
     //set database connection on query object
     $query->setConnection($pdo);
     return $query;
 }
示例#17
0
function getSymbols()
{
    // get a list of all IPOs that don't have first day open/close price set
    $sql = "SELECT DISTINCT symbol, ipodate FROM ipo WHERE closeprice = 0 OR openprice = 0";
    $con = new connection();
    $con->execute($sql);
    $symbols = array();
    while ($con->fetch()) {
        $symbols[] = array("symbol" => $con->rows["symbol"], "ipodate" => $con->rows["ipodate"]);
    }
    return $symbols;
}
示例#18
0
function getSymbols()
{
    // get a list of IPOs from database that are missing the ipoprice
    $sql = "SELECT DISTINCT symbol FROM ipo WHERE ipoprice IS NULL";
    $con = new connection();
    $con->execute($sql);
    $symbols = array();
    while ($con->fetch()) {
        $symbols[] = $con->rows["symbol"];
    }
    return $symbols;
}
示例#19
0
function AddItems($config, $jsonResult)
{
    $conn = new connection($config);
    $product_id = $_GET['product_id'];
    $amount = $_GET['amount'];
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $conn->query("UPDATE product SET amount = amount + " . $amount . " WHERE product_id = " . $product_id);
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
示例#20
0
 public function getAllCategories()
 {
     $aCategories = array();
     $oConnection = new connection();
     $sSQL = "SELECT TypeID\n\t\tFROM tbproducttype";
     $oResult = $oConnection->query($sSQL);
     while ($aRow = $oConnection->fetch_array($oResult)) {
         $oCategory = new category();
         $oCategory->load($aRow["TypeID"]);
         $aCategories[] = $oCategory;
     }
     $oConnection->close_connection();
     return $aCategories;
 }
示例#21
0
 public function load($iRecordID)
 {
     $oCon = new connection();
     $sSQL = "SELECT RecordID, Title, Artist, Price, GenreID, PhotoPath\n\t\t\t\tFROM tbrecords \n\t\t\t\tWHERE RecordID = " . $iRecordID;
     $oResultSet = $oCon->query($sSQL);
     $aRow = $oCon->fetchArray($oResultSet);
     $this->iRecordID = $aRow['RecordID'];
     $this->sTitle = $aRow['Title'];
     $this->sArtist = $aRow['Artist'];
     $this->fPrice = $aRow['Price'];
     $this->iGenreID = $aRow['GenreID'];
     $this->iPhotoPath = $aRow['PhotoPath'];
     $oCon->close();
 }
示例#22
0
function GetCargoList($config, $jsonResult)
{
    $conn = new connection($config);
    $result = $conn->query("SELECT\n                            COUNT(DISTINCT kind_id) as kind_amount ,\n                            COUNT(product_id) as product_amount ,\n                            SUM(amount) as item_amount,\n                            cargo.cargo_id,\n                            cargo.name as cargo_name\n                            FROM product\n                            RIGHT JOIN cargo on product.cargo_id = cargo.cargo_id\n                            GROUP BY cargo.name\n                            ORDER BY cargo.cargo_id;");
    print $conn->error;
    foreach ($result as $row) {
        array_push($jsonResult->json_data["result_data"], array('kind_amount' => $row['kind_amount'], 'product_amount' => $row['product_amount'], 'item_amount' => $row['item_amount'], 'cargo_id' => $row['cargo_id'], 'cargo_name' => $row['cargo_name']));
    }
    if ($result->rowCount() === 0) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['no_cargoes'];
    } else {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    }
}
示例#23
0
function symbolsNoScore()
{
    // get a list of IPOs and their dates from the database that are missing tweets/hype or are in the future
    $sql = "SELECT DISTINCT symbol, ipodate FROM ipo WHERE hype IS NULL OR ipodate >= CURDATE()";
    $con = new connection();
    $con->execute($sql);
    $symbols = array();
    while ($con->fetch()) {
        $symbol = array();
        $symbol["symbol"] = $con->rows["symbol"];
        $symbol["ipodate"] = strtotime($con->rows["ipodate"]);
        $symbols[] = $symbol;
    }
    return $symbols;
}
function getProductList($kind_name)
{
    $productsWithPhotos = array();
    $conn = new connection(new Config(null, null));
    $products = $conn->query("SELECT product_id , amount , kind.name as kind\nFROM product INNER JOIN kind on product.kind_id = kind.kind_id\nWHERE kind.name = '" . $kind_name . "';");
    print $conn->error;
    foreach ($products as $product) {
        $tmp_photos = array();
        $photos = $conn->query("SELECT photo.photo_id as id, photo.extension\n                from product inner join photo on product.product_id = photo.product_id\n                where product.product_id = '" . $product['product_id'] . "';");
        foreach ($photos as $photo) {
            array_push($tmp_photos, new Photo($photo['id'], $photo['extension']));
        }
        array_push($productsWithPhotos, new Product($product['product_id'], $product['kind'], $product['amount'], $tmp_photos));
    }
    return $productsWithPhotos;
}
示例#25
0
function RemoveProduct($config, $jsonResult)
{
    $conn = new connection($config);
    $product_id = $_GET['product_id'];
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $conn->query("DELETE FROM product WHERE product_id=" . $product_id . ";");
        $result = $conn->query("SELECT photo_id , extension FROM photo WHERE product_id = " . $product_id . ";");
        foreach ($result as $row) {
            $photo_id = $row['$photo_id'];
            unlink('../images/' . $photo_id . '.' . $row['extension']);
            $conn->query("DELETE FROM photo WHERE photo_id = " . $photo_id . ";");
        }
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
示例#26
0
 function __construct()
 {
     try {
         parent::__construct();
     } catch (mysqli_sql_exception $e) {
         throw $e;
     }
 }
function getCargoListWithKinds($config, $jsonResult)
{
    $kind_name = $_GET['kind_name'];
    $productsWithPhotos = array();
    $conn = new connection($config);
    $products = $conn->query("SELECT product_id , amount , kind.name as kind\nFROM product INNER JOIN kind on product.kind_id = kind.kind_id\nWHERE kind.name = '" . $kind_name . "';");
    print $conn->error;
    foreach ($products as $product) {
        $tmp_photos = array();
        $photos = $conn->query("SELECT photo.photo_id as id, photo.extension\n                from product inner join photo on product.product_id = photo.product_id\n                where product.product_id = '" . $product['product_id'] . "';");
        foreach ($photos as $photo) {
            array_push($tmp_photos, new Photo($photo['id'], $photo['extension']));
        }
        array_push($productsWithPhotos, new Product($product['product_id'], $product['kind'], $product['amount'], $tmp_photos));
    }
    $jsonResult->json_data['result_data'] = $productsWithPhotos;
}
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_DATABASE, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
         self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
     }
     return self::$instance;
 }
示例#29
0
function AddAuction($config, $jsonResult)
{
    $id = $_GET['auction_id'];
    $sandbox = $_GET['sandbox'];
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    $allegroConn = new ALLEGRO();
    if ($sandbox) {
        if (!$allegroConn->Connect($allegroConn->sandbox)) {
            $jsonResult->json_data['result_code'] = JSON::$resultCodes['allegro_error'];
            return;
        }
    } else {
        if (!$allegroConn->Connect($allegroConn->production)) {
            $jsonResult->json_data['result_code'] = JSON::$resultCodes['allegro_error'];
            return;
        }
    }
    $itemInfoRequest = array('sessionHandle' => $allegroConn->sessionNumber, 'itemsIdArray' => array($id + 0), 'getDesc' => 1, 'getPostageOptions' => 1);
    try {
        $auction_info = $allegroConn->GetItemsInfo($itemInfoRequest);
    } catch (Exception $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['allegro_error'];
        return;
    }
    $auction_name = $auction_info->arrayItemListInfo->item->itemInfo->itName;
    if ($auction_name !== null) {
        if ($sandbox) {
            $sandbox = 1;
        } else {
            $sandbox = 0;
        }
        $jsonResult->json_data['result_data'] = array('auction_id' => $id, 'name' => $auction_name, 'sandbox' => $sandbox);
    } else {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['allegro_no_auction_name'];
        return;
    }
    try {
        $conn->query("INSERT INTO allegro VALUES ('" . $id . "' , '" . $auction_name . "' , " . $sandbox . ");");
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
        return;
    }
}
示例#30
0
function get_user_modules($login)
{
    //get every module added by the user
    $sql = "SELECT * \n\t\t\t\tFROM module INNER JOIN menu_utilisateur \n\t\t\t\t\tON module.id = menu_utilisateur.module\n\t\t\t\tWHERE menu_utilisateur.utilisateur = '" . phpCAS::getUser() . "';";
    $conn = new connection();
    $conn->Connect();
    $response = $conn->Conn->query($sql);
    $retour = array();
    while ($vResult = $response->fetch()) {
        $module = array();
        $module[titre] = $vResult['titre'];
        $module[description] = $vResult['description'];
        $module[lien] = $vResult['lien'];
        $module[id] = $vResult['id'];
        $module[img] = $vResult['img'];
        $retour[] = $module;
    }
    return $retour;
}