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 :  /proc/3951580/cwd/tmp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/3951580/cwd/tmp/pl_helpers.php
function im_dmy( $s ) {
    $s = trim( (string) $s );
    if ( $s === '' ) return null;
    $s = preg_replace( '/\s+\d{1,2}:\d{2}.*$/', '', $s ); // evtl. Uhrzeit abschneiden
    $dt = DateTime::createFromFormat( 'd/m/Y', $s );
    if ( $dt instanceof DateTime ) return $dt->format( 'Y-m-d' );
    $dt = DateTime::createFromFormat( 'd.m.Y', $s );
    if ( $dt instanceof DateTime ) return $dt->format( 'Y-m-d' );
    return null;
}

/** "15:00 Uhr" / "15.00" -> "15:00:00" (oder null). */
function im_time( $s ) {
    $s = str_replace( '.', ':', trim( (string) $s ) );
    if ( $s === '' ) return null;
    if ( preg_match( '/(\d{1,2}):(\d{2})/', $s, $m ) ) {
        $h = (int) $m[1]; $mi = (int) $m[2];
        if ( $h >= 0 && $h < 24 && $mi >= 0 && $mi < 60 ) return sprintf( '%02d:%02d:00', $h, $mi );
    }
    return null;
}

/** "135,00 €" -> 135.00 */
function im_money( $s ) {
    $s = preg_replace( '/[^0-9,.\-]/', '', (string) $s );
    if ( $s === '' ) return 0.0;
    $s = str_replace( '.', '', $s );   // Tausenderpunkt
    $s = str_replace( ',', '.', $s );  // Dezimalkomma
    return (float) $s;
}

/** Kennzeichen normalisieren (für Abgleich): nur A-Z/0-9, Großbuchstaben. */
function im_norm_plate( $s ) { return strtoupper( preg_replace( '/[^A-Za-z0-9]/', '', (string) $s ) ); }
/** Schiffsname normalisieren (für Abgleich): nur A-Z/0-9, Großbuchstaben (AIDAdiva==AIDA DIVA). */
function im_norm_ship( $s ) { return strtoupper( preg_replace( '/[^A-Za-z0-9]/', '', (string) $s ) ); }
/** Freitext normalisieren (lower, getrimmt, Mehrfach-Spaces zu einem). */
function im_norm_txt( $s ) { return mb_strtolower( trim( preg_replace( '/\s+/', ' ', (string) $s ) ), 'UTF-8' ); }

/** ParkingList-CSV (seaside travel) als Dry-Run parsen. */
/**
 * ParkingList-CSV in strukturierte Zeilen parsen (für Vorschau UND Import identisch).
 * Rückgabe: array(ok, rows[], warnings[], sum, halle, aussen, ships{}, minA, maxA, gotAddress, n) | array(ok=false, message)
 */
function im_parking_parse( $tmp ) {
    $fh = fopen( $tmp, 'r' );
    if ( !$fh ) return array( 'ok' => false, 'message' => 'Datei nicht lesbar.' );
    $header = fgetcsv( $fh, 0, ',' );
    if ( !$header ) { fclose( $fh ); return array( 'ok' => false, 'message' => 'Leere oder ungültige CSV.' ); }

    $find = function ( $needle ) use ( $header ) {
        foreach ( $header as $i => $h ) { if ( stripos( (string) $h, $needle ) !== false ) return $i; }
        return -1;
    };
    $findAll = function ( $needle ) use ( $header ) {
        $o = array();
        foreach ( $header as $i => $h ) { if ( stripos( (string) $h, $needle ) !== false ) $o[] = $i; }
        return $o;
    };
    $iNo = $find( 'BuchungsNbr' ); $iDate = $find( 'Buchungsdatum' ); $iLot = $find( 'Parkplatz' );
    $iContact = $find( 'Name' ); $iPlate = $find( 'KfZ' ); $iPers = $find( 'Personen' );
    $iArr = $find( 'Ankunft am Parkplatz' ); $iRet = $find( 'Ankunft am Flughafen' ); $iPrice = $find( 'Price' );
    $flights = $findAll( 'FlightNbr' );
    $iShip1 = isset( $flights[0] ) ? $flights[0] : -1;
    $iShip2 = isset( $flights[1] ) ? $flights[1] : -1;
    $iStreet  = $find( 'Stra' );
    $iAddr    = ( $iStreet < 0 ) ? ( $find( 'Anschrift' ) >= 0 ? $find( 'Anschrift' ) : $find( 'Adresse' ) ) : -1;
    $iZip     = $find( 'PLZ' ); if ( $iZip < 0 ) $iZip = $find( 'Postleit' );
    $iCity    = $find( 'Ort' ); if ( $iCity < 0 ) $iCity = $find( 'Stadt' );
    $iCountry = $find( 'Land' );
    $hasAddrColumns = ( $iStreet >= 0 || $iAddr >= 0 || $iZip >= 0 || $iCity >= 0 );

    $get = function ( $r, $i ) { return ( $i >= 0 && isset( $r[$i] ) ) ? trim( (string) $r[$i] ) : ''; };
    $splitBr = function ( $v ) { return preg_split( '#<br\s*/?>#i', (string) $v ); };

    $rows = array(); $warnings = array();
    $sum = 0.0; $halle = 0; $aussen = 0; $ships = array(); $minA = null; $maxA = null; $n = 0; $gotAddress = false;

    while ( ( $r = fgetcsv( $fh, 0, ',' ) ) !== false ) {
        $nonEmpty = false;
        foreach ( $r as $c ) { if ( trim( (string) $c ) !== '' ) { $nonEmpty = true; break; } }
        if ( !$nonEmpty ) continue;
        $n++;

        $contact = $splitBr( $get( $r, $iContact ) );
        $cname  = trim( strip_tags( isset( $contact[0] ) ? $contact[0] : '' ) );
        $cmail  = trim( isset( $contact[1] ) ? $contact[1] : '' );
        $cphone = trim( isset( $contact[2] ) ? $contact[2] : '' );
        $parts  = preg_split( '/\s+/', $cname );
        $clast  = count( $parts ) ? $parts[ count( $parts ) - 1 ] : '';
        $cfirst = ( count( $parts ) > 1 ) ? trim( preg_replace( '/\s+\S+$/', '', $cname ) ) : '';

        $street = ''; $zip = ''; $city = ''; $country = '';
        if ( $iStreet >= 0 )  $street = $get( $r, $iStreet );
        if ( $iZip >= 0 )     $zip    = $get( $r, $iZip );
        if ( $iCity >= 0 )    $city   = $get( $r, $iCity );
        if ( $iCountry >= 0 ) $country = $get( $r, $iCountry );
        if ( $iAddr >= 0 ) {
            $a = preg_replace( '#<br\s*/?>#i', ', ', $get( $r, $iAddr ) );
            $pp = array_map( 'trim', explode( ',', $a ) );
            if ( $street === '' && isset( $pp[0] ) ) $street = $pp[0];
            if ( isset( $pp[1] ) && preg_match( '/^(\d{4,5})\s+(.+)$/', $pp[1], $mm ) ) { if ( $zip === '' ) $zip = $mm[1]; if ( $city === '' ) $city = $mm[2]; }
            elseif ( isset( $pp[1] ) && $city === '' ) $city = $pp[1];
        }
        if ( !$hasAddrColumns && count( $contact ) > 3 ) {
            $extra = array();
            for ( $k = 3; $k < count( $contact ); $k++ ) { $t = trim( strip_tags( $contact[$k] ) ); if ( $t !== '' ) $extra[] = $t; }
            if ( count( $extra ) ) {
                if ( $street === '' ) $street = $extra[0];
                if ( isset( $extra[1] ) ) { if ( preg_match( '/^(\d{4,5})\s+(.+)$/', $extra[1], $mm ) ) { if ( $zip === '' ) $zip = $mm[1]; if ( $city === '' ) $city = $mm[2]; } elseif ( $city === '' ) $city = $extra[1]; }
            }
        }
        $rowHasAddr = ( $street !== '' || $zip !== '' || $city !== '' );
        if ( $rowHasAddr ) $gotAddress = true;
        $addrLabel = trim( $street . ( ( $zip !== '' || $city !== '' ) ? ', ' . trim( $zip . ' ' . $city ) : '' ) );

        $lot = $get( $r, $iLot );
        $typ = ( stripos( $lot, 'hallen' ) !== false ) ? 'Halle' : 'Außen';
        if ( $typ === 'Halle' ) $halle++; else $aussen++;

        $arrP = $splitBr( $get( $r, $iArr ) );
        $aDate = im_dmy( isset( $arrP[0] ) ? $arrP[0] : '' );
        $aTime = trim( preg_replace( '/uhr/i', '', isset( $arrP[1] ) ? $arrP[1] : '' ) );
        $retP = $splitBr( $get( $r, $iRet ) );
        $rDate = im_dmy( isset( $retP[0] ) ? $retP[0] : '' );
        $rTime = trim( preg_replace( '/uhr/i', '', isset( $retP[1] ) ? $retP[1] : '' ) );

        $ship = $get( $r, $iShip1 ); if ( $ship === '' ) $ship = $get( $r, $iShip2 );
        $ship = trim( $ship ); if ( $ship !== '' ) $ships[$ship] = true;

        $price = im_money( $get( $r, $iPrice ) ); $sum += $price;
        $plate = $get( $r, $iPlate );
        $no    = $get( $r, $iNo );

        if ( $plate === '' ) $warnings[] = 'Zeile ' . $n . ': kein Kennzeichen';
        if ( $aDate === null ) $warnings[] = 'Zeile ' . $n . ': Anreisedatum unlesbar';
        if ( $aDate !== null ) { if ( $minA === null || $aDate < $minA ) $minA = $aDate; if ( $maxA === null || $aDate > $maxA ) $maxA = $aDate; }

        $rows[] = array(
            'no' => $no, 'bdate' => $get( $r, $iDate ), 'typ' => $typ, 'name' => $cname, 'firstname' => $cfirst, 'lastname' => $clast,
            'mail' => $cmail, 'phone' => $cphone, 'plate' => $plate, 'pers' => (int) $get( $r, $iPers ),
            'street' => $street, 'zip' => $zip, 'city' => $city, 'country' => $country, 'addr' => $addrLabel, 'rowHasAddr' => $rowHasAddr,
            'aDateRaw' => $aDate, 'rDateRaw' => $rDate, 'aTime' => $aTime, 'cruise_checkin' => im_time( $aTime ),
            'arrival' => ( $aDate ? date( 'd.m.Y', strtotime( $aDate ) ) : ( isset( $arrP[0] ) ? trim( $arrP[0] ) : '' ) ) . ( $aTime ? ' ' . $aTime : '' ),
            'ship' => $ship,
            'return' => ( $rDate ? date( 'd.m.Y', strtotime( $rDate ) ) : ( isset( $retP[0] ) ? trim( $retP[0] ) : '' ) ) . ( $rTime ? ' ' . $rTime : '' ),
            'price' => $price,
            'status' => 'new', 'diff' => array(), 'match' => null,
        );
    }
    fclose( $fh );
    if ( !$gotAddress ) $warnings[] = 'Keine Adressdaten in der Datei gefunden (Adresse konnte nicht erfasst werden).';

    return array( 'ok' => true, 'rows' => $rows, 'warnings' => $warnings, 'sum' => $sum, 'halle' => $halle,
                  'aussen' => $aussen, 'ships' => $ships, 'minA' => $minA, 'maxA' => $maxA, 'gotAddress' => $gotAddress, 'n' => $n );
}

/** Bestehende eigene/ParkingList-Buchungen im Anreisezeitraum, Schlüssel normPlate|begin (mit IDs). */
function im_parking_existing_map( $db, $minA, $maxA ) {
    $map = array();
    if ( $minA === null ) return $map;
    $ex = $db->rawQuery(
        "SELECT b.booking_id, b.booking_customer, b.booking_invoice, b.booking_serial, b.booking_begin, b.booking_end,
                b.booking_type, b.booking_event, b.booking_cruise_checkin,
                c.customer_lastname, c.customer_street, c.customer_zipcode, c.customer_city
           FROM pacim_booking b
           INNER JOIN pacim_customer c ON c.customer_id = b.booking_customer AND c.customer_source IN ('Parken-am-Schiff.de','ParkingList')
          WHERE b.booking_begin BETWEEN ? AND ?",
        array( $minA, $maxA )
    );
    foreach ( (array) $ex as $e ) {
        $k = im_norm_plate( $e['booking_serial'] ) . '|' . substr( (string) $e['booking_begin'], 0, 10 );
        if ( !isset( $map[$k] ) ) $map[$k] = $e;
    }
    return $map;
}

/** Klassifiziert Zeilen (new/update/duplicate), setzt status/diff/match. Rückgabe [new,update,duplicate]. */
function im_parking_classify( &$rows, $map ) {
    $cNew = 0; $cUpd = 0; $cDup = 0;
    foreach ( $rows as $idx => $row ) {
        if ( $row['plate'] === '' || $row['aDateRaw'] === null ) { $rows[$idx]['status'] = 'new'; $cNew++; continue; }
        $k = im_norm_plate( $row['plate'] ) . '|' . $row['aDateRaw'];
        if ( !isset( $map[$k] ) ) { $rows[$idx]['status'] = 'new'; $cNew++; continue; }
        $e = $map[$k];
        $rows[$idx]['match'] = $e;
        $diff = array();
        $exTyp = ( (int) $e['booking_type'] === 1 ) ? 'Halle' : 'Außen';
        if ( $exTyp !== $row['typ'] ) $diff[] = 'Stellplatz';
        if ( $row['rDateRaw'] && substr( (string) $e['booking_end'], 0, 10 ) !== $row['rDateRaw'] ) $diff[] = 'Rückreise';
        if ( !empty( $row['cruise_checkin'] ) && substr( (string) $e['booking_cruise_checkin'], 0, 5 ) !== substr( $row['cruise_checkin'], 0, 5 ) ) $diff[] = 'Anreisezeit';
        if ( $row['ship'] !== '' && im_norm_ship( $e['booking_event'] ) !== im_norm_ship( $row['ship'] ) ) $diff[] = 'Schiff';
        if ( $row['lastname'] !== '' && im_norm_txt( $e['customer_lastname'] ) !== '' && im_norm_txt( $e['customer_lastname'] ) !== im_norm_txt( $row['lastname'] ) ) $diff[] = 'Name';
        if ( $row['rowHasAddr'] ) {
            if ( im_norm_txt( $e['customer_street'] )  !== im_norm_txt( $row['street'] ) ) $diff[] = 'Straße';
            if ( im_norm_txt( $e['customer_zipcode'] ) !== im_norm_txt( $row['zip'] ) )    $diff[] = 'PLZ';
            if ( im_norm_txt( $e['customer_city'] )    !== im_norm_txt( $row['city'] ) )   $diff[] = 'Ort';
        }
        if ( count( $diff ) ) { $rows[$idx]['status'] = 'update'; $rows[$idx]['diff'] = $diff; $cUpd++; }
        else { $rows[$idx]['status'] = 'duplicate'; $cDup++; }
    }
    return array( $cNew, $cUpd, $cDup );
}

/** Nächste fortlaufende Buchungsnummer (YY-NNNNN). */
function im_next_booking_no( $db ) {
    $r = $db->rawQueryOne( "SELECT MAX(CAST(SUBSTRING_INDEX(booking_no,'-',-1) AS UNSIGNED))+1 AS nx FROM pacim_booking WHERE booking_no REGEXP '^[0-9]{2}-[0-9]+$'" );
    $nx = ( $r && $r['nx'] ) ? (int) $r['nx'] : 1;
    return date( 'y' ) . '-' . $nx;
}

/**
 * Event anhand Anreise(+Rückreise) + Schiff auflösen. Liefert array('id','title')
 * mit dem KANONISCHEN Titel aus der DB (z. B. „AIDA DIVA" -> „AIDAdiva") oder null.
 * Abgleich über normalisierten Schiffsnamen (Groß/Klein, Leer-/Sonderzeichen egal).
 */
function im_event_match( $db, $begin, $end, $ship ) {
    if ( !$begin || $ship === '' ) return null;
    $ns = im_norm_ship( $ship );
    if ( $ns === '' ) return null;

    // 1) gleiches An- UND Abreisedatum, 2) Fallback nur Anreisedatum
    $sets = array();
    if ( $end ) $sets[] = $db->rawQuery( "SELECT event_calendar_id AS id, event_calendar_title AS title FROM pacim_events WHERE DATE(event_calendar_begin)=? AND DATE(event_calendar_end)=?", array( $begin, $end ) );
    $sets[] = $db->rawQuery( "SELECT event_calendar_id AS id, event_calendar_title AS title FROM pacim_events WHERE DATE(event_calendar_begin)=?", array( $begin ) );

    foreach ( $sets as $rows ) {
        if ( empty( $rows ) ) continue;
        // exakter (normalisierter) Treffer bevorzugt
        foreach ( $rows as $r ) { if ( im_norm_ship( $r['title'] ) === $ns ) return array( 'id' => (int) $r['id'], 'title' => $r['title'] ); }
        // sonst Präfix-Treffer (z. B. „MSC Magnifica " vs „MSC Magnifica")
        foreach ( $rows as $r ) {
            $nt = im_norm_ship( $r['title'] );
            if ( $nt !== '' && ( strpos( $nt, $ns ) === 0 || strpos( $ns, $nt ) === 0 ) ) return array( 'id' => (int) $r['id'], 'title' => $r['title'] );
        }
    }
    return null;
}

Youez - 2016 - github.com/yon3zu
LinuXploit