403Webshell
Server IP : 202.61.199.114  /  Your IP : 216.73.217.139
Web Server : nginx/1.22.1
System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
User : web20 ( 1018)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/seaside.pacim.de/web/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/seaside.pacim.de/web/products-admin.php
<?php
/**
 * products-admin.php – Produktverwaltung (Einstellungen → Produkte). Session-/Admin-geschützt.
 *
 * Typen:
 *   parking  = product_id 1 (Halle) / 2 (Außen) – Preis-Staffelung nach Tagen (pacim_parking_prices)
 *   service  = product_id >= 3 – Einzelpreis je Jahr (pacim_product_prices, Basis: pacim_products.product_price)
 *
 * Preise werden in der DB NETTO gespeichert; im UI BRUTTO ein-/ausgegeben (MwSt je Produkt).
 *
 * Aktionen: list | service-save | service-delete | parking-save
 */
require_once( __DIR__ . '/includes/config.inc.php' );
@ini_set( 'display_errors', '0' );
error_reporting( 0 );
ob_start();

function pa_json( $a ) { while ( ob_get_level() > 0 ) ob_end_clean(); header( 'Content-Type: application/json; charset=utf-8' ); echo json_encode( $a ); exit(); }
function pa_fail( $m ) { pa_json( array( 'ok' => false, 'error' => $m ) ); }

if ( ! function_exists( 'is_admin' ) || ! is_admin() ) { http_response_code( 403 ); pa_json( array( 'ok' => false, 'error' => 'forbidden' ) ); }

$db     = new MysqliDb( MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB );
$action = $_GET['action'] ?? ( $_POST['action'] ?? '' );

function pa_net( $brutto, $tax ) { $tax = (float) $tax; return round( ( (float) $brutto ) / ( 1 + $tax / 100 ), 6 ); }
function pa_brutto( $net, $tax ) { $tax = (float) $tax; return round( ( (float) $net ) * ( 1 + $tax / 100 ), 2 ); }

/* ----------------------------------------------------------------- list */
if ( $action === 'list' ) {
    $cur  = (int) date( 'Y' );
    $year = (int) ( $_GET['year'] ?? $cur );
    if ( $year <= 0 ) $year = $cur;

    // verfügbare Jahre = vorhandene Preisjahre + aktuelles & nächstes Jahr
    $years = array( $cur, $cur + 1 );
    foreach ( $db->rawQuery( "SELECT DISTINCT year y FROM pacim_parking_prices UNION SELECT DISTINCT year y FROM pacim_product_prices" ) as $r ) $years[] = (int) $r['y'];
    $years = array_values( array_unique( array_filter( $years ) ) );
    rsort( $years );

    // Parkplatz-Produkte (1/2) mit Staffelung des Jahres
    $parking = array();
    foreach ( $db->rawQuery( "SELECT product_id, product_title, product_tax, product_visible FROM pacim_products WHERE product_id IN (1,2) ORDER BY product_id" ) as $p ) {
        $tax = (float) $p['product_tax'];
        $tiers = array();
        foreach ( $db->rawQuery( "SELECT price_id, days_range, price FROM pacim_parking_prices WHERE product_id = ? AND year = ? ORDER BY price_id", array( (int) $p['product_id'], $year ) ) as $t ) {
            $tiers[] = array( 'range' => $t['days_range'], 'brutto' => pa_brutto( $t['price'], $tax ) );
        }
        $parking[] = array( 'product_id' => (int) $p['product_id'], 'title' => $p['product_title'], 'tax' => $tax, 'visible' => (int) $p['product_visible'], 'tiers' => $tiers );
    }

    // Service-Produkte (>=3)
    $services = array();
    foreach ( $db->rawQuery( "SELECT product_id, product_title, product_price, product_tax, product_visible FROM pacim_products WHERE product_id >= 3 ORDER BY product_id" ) as $p ) {
        $tax = (float) $p['product_tax'];
        $yr = $db->rawQueryOne( "SELECT price FROM pacim_product_prices WHERE product_id = ? AND year = ? LIMIT 1", array( (int) $p['product_id'], $year ) );
        $net = $yr ? (float) $yr['price'] : (float) $p['product_price'];
        $services[] = array(
            'product_id' => (int) $p['product_id'], 'title' => $p['product_title'], 'tax' => $tax,
            'brutto' => pa_brutto( $net, $tax ), 'visible' => (int) $p['product_visible'], 'has_year_price' => $yr ? true : false,
        );
    }

    pa_json( array( 'ok' => true, 'year' => $year, 'years' => $years, 'parking' => $parking, 'services' => $services ) );
}

/* ----------------------------------------------------------------- service speichern */
if ( $action === 'service-save' ) {
    $id     = (int) ( $_POST['product_id'] ?? 0 );
    $title  = trim( (string) ( $_POST['title'] ?? '' ) );
    $tax    = (float) ( $_POST['tax'] ?? 19 );
    $brutto = (float) ( $_POST['brutto'] ?? 0 );
    $year   = (int) ( $_POST['year'] ?? date( 'Y' ) );
    if ( $title === '' ) pa_fail( 'Bitte eine Bezeichnung angeben.' );
    if ( $tax < 0 ) pa_fail( 'Ungültige MwSt.' );
    $net = pa_net( $brutto, $tax );

    if ( $id <= 0 ) {
        $id = $db->insert( 'pacim_products', array( 'product_title' => $title, 'product_description' => '', 'product_price' => $net, 'product_tax' => $tax ) );
        if ( ! $id ) pa_fail( 'Produkt konnte nicht angelegt werden.' );
    } else {
        if ( $id < 3 ) pa_fail( 'Parkplatz-Produkte werden über die Staffelung verwaltet.' );
        $db->where( 'product_id', $id );
        $db->update( 'pacim_products', array( 'product_title' => $title, 'product_price' => $net, 'product_tax' => $tax ) );
    }
    // Jahrespreis upserten
    $ex = $db->rawQueryOne( "SELECT price_id FROM pacim_product_prices WHERE product_id = ? AND year = ?", array( $id, $year ) );
    if ( $ex ) { $db->where( 'price_id', (int) $ex['price_id'] ); $db->update( 'pacim_product_prices', array( 'price' => $net ) ); }
    else $db->insert( 'pacim_product_prices', array( 'product_id' => $id, 'year' => $year, 'price' => $net ) );
    pa_json( array( 'ok' => true, 'product_id' => (int) $id ) );
}

/* ----------------------------------------------------------------- service löschen */
if ( $action === 'service-delete' ) {
    $id = (int) ( $_POST['product_id'] ?? 0 );
    if ( $id < 3 ) pa_fail( 'Dieses Produkt kann nicht gelöscht werden.' );
    $db->rawQuery( "DELETE FROM pacim_product_prices WHERE product_id = ?", array( $id ) );
    $db->where( 'product_id', $id );
    $db->delete( 'pacim_products' );
    pa_json( array( 'ok' => true ) );
}

/* ----------------------------------------------------------------- parking (Staffelung) speichern */
if ( $action === 'parking-save' ) {
    $id    = (int) ( $_POST['product_id'] ?? 0 );
    $tax   = (float) ( $_POST['tax'] ?? 19 );
    $title = trim( (string) ( $_POST['title'] ?? '' ) );
    $year  = (int) ( $_POST['year'] ?? date( 'Y' ) );
    if ( $id !== 1 && $id !== 2 ) pa_fail( 'Ungültiges Parkplatz-Produkt.' );
    if ( $tax < 0 ) pa_fail( 'Ungültige MwSt.' );
    $tiersIn = json_decode( (string) ( $_POST['tiers'] ?? '[]' ), true );
    if ( ! is_array( $tiersIn ) ) pa_fail( 'Ungültige Staffelung.' );

    // Bereiche normalisieren + validieren
    $rows = array();
    foreach ( $tiersIn as $t ) {
        $from = (int) ( $t['from'] ?? 0 );
        $open = ! empty( $t['open'] );
        $to   = (int) ( $t['to'] ?? 0 );
        $brut = (float) ( $t['brutto'] ?? 0 );
        if ( $from < 1 ) continue;
        if ( $open ) $range = $from . '+';
        else { if ( $to < $from ) $to = $from; $range = $from . '-' . $to; }
        $rows[] = array( 'range' => $range, 'price' => pa_net( $brut, $tax ) );
    }
    if ( ! count( $rows ) ) pa_fail( 'Bitte mindestens eine Staffel angeben.' );

    // Produkt (Titel/MwSt) + Staffelung des Jahres ersetzen
    $upd = array( 'product_tax' => $tax );
    if ( $title !== '' ) $upd['product_title'] = $title;
    $db->where( 'product_id', $id );
    $db->update( 'pacim_products', $upd );

    $db->rawQuery( "DELETE FROM pacim_parking_prices WHERE product_id = ? AND year = ?", array( $id, $year ) );
    foreach ( $rows as $r ) $db->insert( 'pacim_parking_prices', array( 'product_id' => $id, 'days_range' => $r['range'], 'price' => $r['price'], 'year' => $year ) );
    pa_json( array( 'ok' => true, 'product_id' => $id, 'tiers' => count( $rows ) ) );
}

/* ----------------------------------------------------------------- Sichtbarkeit umschalten */
if ( $action === 'toggle-visible' ) {
    $id = (int) ( $_POST['product_id'] ?? 0 );
    if ( $id <= 0 || ! $db->rawQueryOne( "SELECT product_id FROM pacim_products WHERE product_id = ?", array( $id ) ) ) pa_fail( 'Produkt nicht gefunden.' );
    $visible = ! empty( $_POST['visible'] ) ? 1 : 0;
    $db->where( 'product_id', $id );
    $db->update( 'pacim_products', array( 'product_visible' => $visible ) );
    pa_json( array( 'ok' => true, 'product_id' => $id, 'visible' => $visible ) );
}

pa_fail( 'unknown_action' );

Youez - 2016 - github.com/yon3zu
LinuXploit