Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function thisPage(){
- $this->smarty->assign('kats', 0);
- if(isset($_GET['kat'])){
- $this->smarty->assign('kats', $this->mysqli->escape_string($_GET['kat']));
- $kat = $this->mysqli->escape_string($_GET['kat']);
- $rechte = $kat;
- $thisKat = $this->mysqli->query("SELECT * FROM kategorien WHERE id = '".$kat."'");
- if($thisKat->num_rows == 1){
- $thisKat = $thisKat->fetch_object();
- $this->smarty->assign('kat_name', utf8_encode($thisKat->name));
- $cars = $this->mysqli->query("SELECT * FROM items WHERE kat_id = '".$thisKat->id."' ORDER by name");
- while($Car = $cars->fetch_object()){
- $thisWert = $this->mysqli->query("SELECT * FROM werte WHERE car_id = '".$Car->id."' ORDER by time DESC LIMIT 1")->fetch_object();
- $lastWert = $this->mysqli->query("SELECT * FROM werte WHERE car_id = '".$Car->id."' ORDER by time DESC LIMIT 1,1");
- if($lastWert->num_rows == 1){
- $lastWert = $lastWert->fetch_object();
- if($thisWert->Preis_1 > $lastWert->Preis_1){
- $color = "green";
- $unterschied = $thisWert->Preis_1 - $lastWert->Preis_1;
- $prozent = round(($unterschied * 100) / $thisWert->Preis_1, 2);
- $change = '+ '.number_format($unterschied, 0, '.', '.'). '$ ('.$prozent.'%)';
- } elseif($thisWert->Preis_1 < $lastWert->Preis_1){
- $color = "red";
- $unterschied = $lastWert->Preis_1 - $thisWert->Preis_1;
- $prozent = round(($unterschied * 100) / $thisWert->Preis_1, 2);
- $change = '- '.number_format($unterschied, 0, '.', '.'). '$ ('.$prozent.'%)';
- } else {
- $color = "grey";
- $change = "Keine Veränderung";
- }
- } else {
- $color = "grey";
- if($thisWert->time < time() - 86400){
- $change = "Keine Veränderungen";
- } else {
- $change = "Neu eingefügt";
- }
- }
- if($this->rechte < $rechte){
- $change = "Keine Rechte";
- $color = "grey";
- }
- $newCars[] = array(
- "id" => $Car->id,
- "name" => $Car->name,
- "car_id" => $Car->car_id,
- "color" => $color,
- "change" => $change
- );
- }
- $this->smarty->assign('newCars', $newCars);
- } else {
- header("Location: index.php?page=car");
- exit;
- }
- } else {
- // Neusten Änderungen
- $this->smarty->assign('kats', 0);
- $newestChanges = $this->mysqli->query("SELECT distinct car_id, MAX(time) FROM werte GROUP BY car_id ORDER by MAX(time) DESC LIMIT 20");
- while($thisChanges = $newestChanges->fetch_object()){
- $thisChange = $this->mysqli->query("SELECT * FROM werte WHERE car_id = '".$thisChanges->car_id."' ORDER by time DESC LIMIT 1")->fetch_object();
- $lastWert = $this->mysqli->query("SELECT * FROM werte WHERE car_id = '".$thisChange->car_id."' ORDER by time DESC LIMIT 1,1");
- if($lastWert->num_rows == 1){
- $lastWert = $lastWert->fetch_object();
- if($thisChange->Preis_1 > $lastWert->Preis_1){
- $color = "green";
- $unterschied = $thisChange->Preis_1 - $lastWert->Preis_1;
- $prozent = round(($unterschied * 100) / $thisChange->Preis_1, 2);
- $change = '+ '.number_format($unterschied, 0, '.', '.'). ' $ ('.$prozent.' %)';
- } elseif($thisChange->Preis_1 < $lastWert->Preis_1){
- $color = "red";
- $unterschied = $lastWert->Preis_1 - $thisChange->Preis_1;
- $prozent = round(($unterschied * 100) / $thisChange->Preis_1, 2);
- $change = '- '.number_format($unterschied, 0, '.', '.'). ' $ ('.$prozent.' %)';
- } else {
- $color = "grey";
- $change = "Keine Veränderung";
- }
- } else {
- $color = "grey";
- if($thisChange->time < time() - 86400){
- $change = "Keine Veränderungen";
- } else {
- $change = "Neu eingefügt";
- }
- }
- $car_name = $this->mysqli->query("SELECT * FROM items WHERE id = '".$thisChange->car_id."'");
- if($car_name->num_rows == 1){
- $name = $car_name->fetch_object();
- $id = $name->id;
- $car_id = $name->car_id;
- $rechte = $name->kat_id;
- $name = $name->name;
- } else {
- $name = "Unbekannt";
- $car_id = 0;
- $id = 0;
- $rechte = 0;
- }
- if($this->rechte < $rechte){
- $change = "Keine Rechte";
- $color = "grey";
- }
- $newCars[] = array(
- "id" => $id,
- "name" => $name,
- "car_id" => $car_id,
- "color" => $color,
- "change" => $change
- );
- }
- $this->smarty->assign('newCars', $newCars);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment