From 0dc2cdc7f45f6ea41915076bf3b1c968d9529407 Mon Sep 17 00:00:00 2001 From: shreesh arora Date: Tue, 4 May 2021 14:55:15 +0530 Subject: [PATCH] added parser_autoload | updated --- classes/Tools.php | 4 +- tools/parser_sql/builders/index.php | 38 +++++++--------- tools/parser_sql/exceptions/index.php | 38 +++++++--------- tools/parser_sql/index.php | 44 ++++++++---------- tools/parser_sql/lexer/index.php | 38 +++++++--------- tools/parser_sql/php_sql_parser_autoload.php | 47 ++++++++++++++++++++ tools/parser_sql/positions/index.php | 38 +++++++--------- tools/parser_sql/processors/index.php | 38 +++++++--------- tools/parser_sql/utils/index.php | 38 +++++++--------- 9 files changed, 164 insertions(+), 159 deletions(-) create mode 100644 tools/parser_sql/php_sql_parser_autoload.php diff --git a/classes/Tools.php b/classes/Tools.php index 22ddaf612..17ac7a88d 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2222,8 +2222,8 @@ class ToolsCore public static function parserSQL($sql) { if (strlen($sql) > 0) { - require_once(_PS_TOOL_DIR_.'parser_sql/PHPSQLParser.php'); - $parser = new PHPSQLParser($sql); + require_once _PS_TOOL_DIR_.'parser_sql/php_sql_parser_autoload.php'; + $parser = new PHPSQLParser\PHPSQLParser($sql); return $parser->parsed; } return false; diff --git a/tools/parser_sql/builders/index.php b/tools/parser_sql/builders/index.php index 9a99a8662..051e0122d 100644 --- a/tools/parser_sql/builders/index.php +++ b/tools/parser_sql/builders/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Location: ../"); +header('Location: ../../../'); exit; diff --git a/tools/parser_sql/exceptions/index.php b/tools/parser_sql/exceptions/index.php index 9a99a8662..051e0122d 100644 --- a/tools/parser_sql/exceptions/index.php +++ b/tools/parser_sql/exceptions/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Location: ../"); +header('Location: ../../../'); exit; diff --git a/tools/parser_sql/index.php b/tools/parser_sql/index.php index df55e1000..051e0122d 100644 --- a/tools/parser_sql/index.php +++ b/tools/parser_sql/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); + +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../../../'); exit; diff --git a/tools/parser_sql/lexer/index.php b/tools/parser_sql/lexer/index.php index 9a99a8662..051e0122d 100644 --- a/tools/parser_sql/lexer/index.php +++ b/tools/parser_sql/lexer/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Location: ../"); +header('Location: ../../../'); exit; diff --git a/tools/parser_sql/php_sql_parser_autoload.php b/tools/parser_sql/php_sql_parser_autoload.php new file mode 100644 index 000000000..093d61b52 --- /dev/null +++ b/tools/parser_sql/php_sql_parser_autoload.php @@ -0,0 +1,47 @@ + +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +require_once __DIR__.'/PHPSQLParser.php'; + +function classAutoLoader($class) +{ + // check if php sql parser file is called + if(0 !== strpos($class, 'PHPSQLParser')) { + return; + } + + $className = end(explode('\\', $class)); + if(class_exists($className)) { + return; + } + + $class = str_replace('PHPSQLParser\\', '', $class); + + // create path for required file + $classFile = __DIR__.'/'.str_replace('\\', '/', $class).'.php'; + + if (!file_exists($classFile) || !is_file($classFile)) { + return; + } + + require $classFile; +} + +spl_autoload_register('classAutoLoader'); \ No newline at end of file diff --git a/tools/parser_sql/positions/index.php b/tools/parser_sql/positions/index.php index 9a99a8662..051e0122d 100644 --- a/tools/parser_sql/positions/index.php +++ b/tools/parser_sql/positions/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Location: ../"); +header('Location: ../../../'); exit; diff --git a/tools/parser_sql/processors/index.php b/tools/parser_sql/processors/index.php index 9a99a8662..051e0122d 100644 --- a/tools/parser_sql/processors/index.php +++ b/tools/parser_sql/processors/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Location: ../"); +header('Location: ../../../'); exit; diff --git a/tools/parser_sql/utils/index.php b/tools/parser_sql/utils/index.php index 9a99a8662..051e0122d 100644 --- a/tools/parser_sql/utils/index.php +++ b/tools/parser_sql/utils/index.php @@ -1,35 +1,29 @@ -* @copyright 2007-2017 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA +* @author Webkul IN +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html */ -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Location: ../"); +header('Location: ../../../'); exit;