403Webshell
Server IP : 217.160.0.95  /  Your IP : 216.73.216.74
Web Server : Apache
System : Linux infong-uk56 4.4.400-icpu-108 #2 SMP Wed Feb 11 11:51:01 UTC 2026 x86_64
User : u78863098 ( 10368940)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /homepages/oneclick/WordPress/7.0/601/scripts/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /homepages/oneclick/WordPress/7.0/601/scripts/core/wpconfigreader.php
<?php

namespace Core;

use \Exceptions\ConfigurationException;

class WPConfigReader
{
    /**
     * basically at least: strlen(<?php require('c.php');)
     */
    const MIN_LENGTH_CONFIGURATION = 25;

    /**
     * default wp config filename
     */
    const DEFAULT_FILENAME = 'wp-config.php';
    /**
     * @var string
     */
    protected $path;

    /**
     * @var string
     */
    protected $fileName;

    /**
     * @var string
     */
    protected $content;

    /**
     * @param string $pathToWPConfig
     * @param string $fileName
     * @throws ConfigurationException
     */
    public function __construct($pathToWPConfig, $fileName = self::DEFAULT_FILENAME)
    {
        $this->setPathToWPConfig($pathToWPConfig, $fileName);
    }


    /**
     * @throws ConfigurationException
     */
    public function readConfig()
    {
        $this->content = file_get_contents($this->path . $this->fileName);
        if (strlen(trim($this->content)) < self::MIN_LENGTH_CONFIGURATION) {
            throw ConfigurationException::createException(ConfigurationException::CONFIG_EMPTY, $this->path);
        }
    }

    /**
     * @param string $pathToWPConfig
     * @param string $fileName
     * @throws ConfigurationException
     */
    public function setPathToWPConfig($pathToWPConfig, $fileName = self::DEFAULT_FILENAME)
    {
        $pathToWPConfig = rtrim($pathToWPConfig,'/') . '/';
        if (!is_dir($pathToWPConfig)) {
            throw ConfigurationException::createException(ConfigurationException::CONFIG_PATH_NOT_EXISTING, $pathToWPConfig);
        }
        if (!file_exists($pathToWPConfig . $fileName)) {
            throw ConfigurationException::createException(ConfigurationException::CONFIG_NOT_FOUND, $pathToWPConfig);
        }
        $this->path = $pathToWPConfig;
        $this->fileName = $fileName;
    }

    /**
     * e.g.: getConfigurationConstant('DB_NAME') => 'wordpress'
     *
     * @param string $name
     * @return string
     */
    public function getConfigurationConstant($name)
    {
        if (empty($this->content)) {
            $this->readConfig();
        }

        $pattern = sprintf('#define\(.+%s.+,(.+)\);#', preg_quote($name, '#'));
        if (preg_match($pattern, $this->content, $res)) {
            return trim($res[1],' "\'');
        }
        return null;
    }

    /**
     * e.g. getVariableValue('table_prefix') => 'wp_'
     *
     * @param string $name ( without leading $ )
     * @return string
     */
    public function getVariableValue($name)
    {
        if (empty($this->content)) {
            $this->readConfig();
        }

        $pattern = sprintf('#\$%s.+=(.+);#', preg_quote($name, '#'));
        if (preg_match($pattern, $this->content, $res)) {
            return trim($res[1],' "\'');
        }
        return null;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit