| Current Path : /home/wuectly/www/03cbe/ |
| Current File : /home/wuectly/www/03cbe/Php.php.tar |
home/wuectly/www/libraries/regularlabs/src/Condition/Php.php 0000604 00000011630 15245741067 0020260 0 ustar 00 <?php
/**
* @package Regular Labs Library
* @version 21.4.10972
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Filesystem\File as JFile;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
use Joomla\CMS\Version;
use RegularLabs\Library\RegEx;
/**
* Class Php
* @package RegularLabs\Library\Condition
*/
class Php
extends \RegularLabs\Library\Condition
{
public function pass()
{
if ( ! is_array($this->selection))
{
$this->selection = [$this->selection];
}
$pass = false;
foreach ($this->selection as $php)
{
// replace \n with newline and other fix stuff
$php = str_replace('\|', '|', $php);
$php = RegEx::replace('(?<!\\\)\\\n', "\n", $php);
$php = trim(str_replace('[:REGEX_ENTER:]', '\n', $php));
if ($php == '')
{
$pass = true;
break;
}
ob_start();
$pass = (bool) $this->execute($php, $this->article, $this->module);
ob_end_clean();
if ($pass)
{
break;
}
}
return $this->_($pass);
}
private function getArticleById($id = 0)
{
if ( ! $id)
{
return null;
}
if ( ! class_exists('ContentModelArticle'))
{
require_once JPATH_SITE . '/components/com_content/models/article.php';
}
$model = JModel::getInstance('article', 'contentModel');
if ( ! method_exists($model, 'getItem'))
{
return null;
}
return $model->getItem($id);
}
public function execute($string = '', $article = null, $module = null)
{
if ( ! $function_name = $this->getFunctionName($string))
{
// Something went wrong!
return true;
}
return $this->runFunction($function_name, $string, $article, $module);
}
private function runFunction($function_name = 'rl_function', $string = '', $article = null, $module = null)
{
if ( ! $article && strpos($string, '$article') !== false)
{
if ($this->request->option == 'com_content' && $this->request->view == 'article')
{
$article = $this->getArticleById($this->request->id);
}
}
return $function_name($article, $module);
}
private function getFunctionName($string = '')
{
$function_name = 'regularlabs_php_' . md5($string);
if (function_exists($function_name))
{
return $function_name;
}
$contents = $this->generateFileContents($function_name, $string);
self::createFunctionInMemory($contents);
if ( ! function_exists($function_name))
{
// Something went wrong!
return false;
}
return $function_name;
}
public static function createFunctionInMemory($string = '')
{
$file_name = getmypid() . '_' . md5($string);
$tmp_path = JFactory::getConfig()->get('tmp_path', JPATH_ROOT . '/tmp');
$temp_file = $tmp_path . '/regularlabs' . '/' . $file_name;
// Write file
if ( ! file_exists($temp_file) || is_writable($temp_file))
{
JFile::write($temp_file, $string);
}
// Include file
include_once $temp_file;
// Delete file
if ( ! JFactory::getApplication()->get('debug'))
{
@chmod($temp_file, 0777);
@unlink($temp_file);
}
}
private function generateFileContents($function_name = 'rl_function', $string = '')
{
$init_variables = self::getVarInits();
$contents = [
'<?php',
'defined(\'_JEXEC\') or die;',
'function ' . $function_name . '($article, $module){',
implode("\n", $init_variables),
$string,
';return true;',
';}',
];
$contents = implode("\n", $contents);
// Remove Zero Width spaces / (non-)joiners
$contents = str_replace(
[
"\xE2\x80\x8B",
"\xE2\x80\x8C",
"\xE2\x80\x8D",
],
'',
$contents
);
return $contents;
}
public static function getVarInits()
{
return [
'$app = $mainframe = RegularLabs\Library\Condition\Php::getApplication();',
'$document = $doc = RegularLabs\Library\Condition\Php::getDocument();',
'$database = $db = JFactory::getDbo();',
'$user = JFactory::getUser();',
'$Itemid = $app->input->getInt(\'Itemid\');',
];
}
public static function getApplication()
{
if (JFactory::getApplication()->input->get('option') != 'com_finder')
{
return JFactory::getApplication();
}
return CMSApplication::getInstance('site');
}
public static function getDocument()
{
if (JFactory::getApplication()->input->get('option') != 'com_finder')
{
return JFactory::getDocument();
}
$lang = JFactory::getLanguage();
$version = new Version;
$attributes = [
'charset' => 'utf-8',
'lineend' => 'unix',
'tab' => "\t",
'language' => $lang->getTag(),
'direction' => $lang->isRtl() ? 'rtl' : 'ltr',
'mediaversion' => $version->getMediaVersion(),
];
return \JDocument::getInstance('html', $attributes);
}
}
home/wuectly/www/libraries/vendor/joomla/registry/src/Format/Php.php 0000604 00000005033 15246311615 0021676 0 ustar 00 <?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
/**
* PHP class format handler for Registry
*
* @since 1.0
*/
class Php extends AbstractRegistryFormat
{
/**
* Converts an object into a php class string.
* - NOTE: Only one depth level is supported.
*
* @param object $object Data Source Object
* @param array $params Parameters used by the formatter
*
* @return string Config class formatted string
*
* @since 1.0
*/
public function objectToString($object, $params = array())
{
// A class must be provided
$class = !empty($params['class']) ? $params['class'] : 'Registry';
// Build the object variables string
$vars = '';
foreach (get_object_vars($object) as $k => $v)
{
if (is_scalar($v))
{
$vars .= "\tpublic $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
}
elseif (\is_array($v) || \is_object($v))
{
$vars .= "\tpublic $" . $k . ' = ' . $this->getArrayString((array) $v) . ";\n";
}
}
$str = "<?php\n";
// If supplied, add a namespace to the class object
if (isset($params['namespace']) && $params['namespace'] !== '')
{
$str .= 'namespace ' . $params['namespace'] . ";\n\n";
}
$str .= 'class ' . $class . " {\n";
$str .= $vars;
$str .= '}';
// Use the closing tag if it not set to false in parameters.
if (!isset($params['closingtag']) || $params['closingtag'] !== false)
{
$str .= "\n?>";
}
return $str;
}
/**
* Parse a PHP class formatted string and convert it into an object.
*
* @param string $data PHP Class formatted string to convert.
* @param array $options Options used by the formatter.
*
* @return object Data object.
*
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
return new \stdClass;
}
/**
* Method to get an array as an exported string.
*
* @param array $a The array to get as a string.
*
* @return string
*
* @since 1.0
*/
protected function getArrayString($a)
{
$s = 'array(';
$i = 0;
foreach ($a as $k => $v)
{
$s .= $i ? ', ' : '';
$s .= '"' . $k . '" => ';
if (\is_array($v) || \is_object($v))
{
$s .= $this->getArrayString((array) $v);
}
else
{
$s .= '"' . addslashes($v) . '"';
}
$i++;
}
$s .= ')';
return $s;
}
}